diff --git a/config/set/downgrade-php80.php b/config/set/downgrade-php80.php index 2f50c083d6bd..485fe5b9752a 100644 --- a/config/set/downgrade-php80.php +++ b/config/set/downgrade-php80.php @@ -4,6 +4,7 @@ use Rector\Downgrade\Rector\LNumber\ChangePhpVersionInPlatformCheckRector; use Rector\DowngradePhp80\Rector\Class_\DowngradePropertyPromotionToConstructorPropertyAssignRector; +use Rector\DowngradePhp80\Rector\Class_\DowngradeThrowExpressionRector; use Rector\DowngradePhp80\Rector\FunctionLike\DowngradeParamMixedTypeDeclarationRector; use Rector\DowngradePhp80\Rector\FunctionLike\DowngradeReturnMixedTypeDeclarationRector; use Rector\DowngradePhp80\Rector\FunctionLike\DowngradeReturnStaticTypeDeclarationRector; @@ -24,4 +25,5 @@ ChangePhpVersionInPlatformCheckRector::TARGET_PHP_VERSION => 80000, ]]); $services->set(DowngradePropertyPromotionToConstructorPropertyAssignRector::class); + $services->set(DowngradeThrowExpressionRector::class); }; diff --git a/config/set/nette-30-param-types.php b/config/set/nette-30-param-types.php index bae905e3ef8d..cc1819d21d6f 100644 --- a/config/set/nette-30-param-types.php +++ b/config/set/nette-30-param-types.php @@ -64,30 +64,10 @@ ), new AddParamTypeDeclaration('Nette\ComponentModel\IComponent', 'setParent', 1, new StringType()), new AddParamTypeDeclaration('Nette\ComponentModel\IContainer', 'getComponents', 0, new BooleanType()), - new AddParamTypeDeclaration( - 'Nette\Forms\Container', - 'addSelect', - 0, - new StringType() - ), - new AddParamTypeDeclaration( - 'Nette\Forms\Container', - 'addSelect', - 3, - new IntegerType() - ), - new AddParamTypeDeclaration( - 'Nette\Forms\Container', - 'addMultiSelect', - 0, - new StringType() - ), - new AddParamTypeDeclaration( - 'Nette\Forms\Container', - 'addMultiSelect', - 3, - new IntegerType() - ), + new AddParamTypeDeclaration('Nette\Forms\Container', 'addSelect', 0, new StringType()), + new AddParamTypeDeclaration('Nette\Forms\Container', 'addSelect', 3, new IntegerType()), + new AddParamTypeDeclaration('Nette\Forms\Container', 'addMultiSelect', 0, new StringType()), + new AddParamTypeDeclaration('Nette\Forms\Container', 'addMultiSelect', 3, new IntegerType()), new AddParamTypeDeclaration( 'Nette\Forms\Rendering\DefaultFormRenderer', 'render', diff --git a/config/set/nette-30-return-types.php b/config/set/nette-30-return-types.php index bee8ce905b0f..ecf3c775b5b4 100644 --- a/config/set/nette-30-return-types.php +++ b/config/set/nette-30-return-types.php @@ -46,11 +46,7 @@ 'addMultiSelect', new ObjectType('Nette\Forms\Controls\MultiSelectBox') ), - new AddReturnTypeDeclaration( - 'Nette\Forms\IFormRenderer', - 'render', - new StringType() - ), + new AddReturnTypeDeclaration('Nette\Forms\IFormRenderer', 'render', new StringType()), new AddReturnTypeDeclaration( 'Nette\Forms\Controls\TextBase', 'getControl', diff --git a/config/set/nette-30.php b/config/set/nette-30.php index 6b3baa0e4f54..6a489703dd92 100644 --- a/config/set/nette-30.php +++ b/config/set/nette-30.php @@ -64,7 +64,7 @@ # @see https://github.com/nette/di/commit/a0d361192f8ac35f1d9f82aab7eb351e4be395ea 'Nette\DI\ServiceDefinition' => 'Nette\DI\Definitions\ServiceDefinition', 'Nette\DI\Statement' => 'Nette\DI\Definitions\Statement', - 'WebChemistry\Forms\Controls\Multiplier' => 'Contributte\FormMultiplier\Multiplier' + 'WebChemistry\Forms\Controls\Multiplier' => 'Contributte\FormMultiplier\Multiplier', ], ]]); $services->set(ArgumentDefaultValueReplacerRector::class)->call('configure', [[ diff --git a/rules/downgrade-php80/src/Rector/Class_/DowngradeThrowExpressionRector.php b/rules/downgrade-php80/src/Rector/Class_/DowngradeThrowExpressionRector.php new file mode 100644 index 000000000000..44a3e2446f7b --- /dev/null +++ b/rules/downgrade-php80/src/Rector/Class_/DowngradeThrowExpressionRector.php @@ -0,0 +1,70 @@ +doTestFileInfo($fileInfo); + } + + public function provideData(): Iterator + { + return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); + } + + protected function getRectorClass(): string + { + return DowngradeThrowExpressionRector::class; + } +} diff --git a/rules/downgrade-php80/tests/Rector/Class_/DowngradeThrowExpressionRector/Fixture/fixture.php.inc b/rules/downgrade-php80/tests/Rector/Class_/DowngradeThrowExpressionRector/Fixture/fixture.php.inc new file mode 100644 index 000000000000..a7bab42a994d --- /dev/null +++ b/rules/downgrade-php80/tests/Rector/Class_/DowngradeThrowExpressionRector/Fixture/fixture.php.inc @@ -0,0 +1,31 @@ + +----- + diff --git a/rules/php70/tests/Rector/Ternary/TernaryToNullCoalescingRector/Fixture/fixture.php.inc b/rules/php70/tests/Rector/Ternary/TernaryToNullCoalescingRector/Fixture/fixture.php.inc index 7eea5991d298..93142ef02213 100644 --- a/rules/php70/tests/Rector/Ternary/TernaryToNullCoalescingRector/Fixture/fixture.php.inc +++ b/rules/php70/tests/Rector/Ternary/TernaryToNullCoalescingRector/Fixture/fixture.php.inc @@ -16,7 +16,7 @@ function ternaryToNullCoalescing() $x = (isset($a) ? $a : isset($b)) ? $b : ""; - $x = isset($a) ? $a : isset($b) ? $b : isset($c) ? $c : ""; + $x = ((isset($a) ? $a : isset($b)) ? $b : isset($c)) ? $c : ""; } ?> @@ -39,7 +39,7 @@ function ternaryToNullCoalescing() $x = ($a ?? isset($b)) ? $b : ""; - $x = $a ?? isset($b) ? $b : isset($c) ? $c : ""; + $x = (($a ?? isset($b)) ? $b : isset($c)) ? $c : ""; } ?>