Skip to content

Commit

Permalink
update ssch/typo3-rector and rector/rector to the newest version (#76)
Browse files Browse the repository at this point in the history
Co-authored-by: Matthias Vogel <[email protected]>
  • Loading branch information
CamillH and Kanti committed Apr 10, 2024
1 parent 9c18fbb commit 500bdbe
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 71 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"phpstan/phpstan": "^1.9.0",
"pluswerk/grumphp-bom-task": "^8.0.0",
"pluswerk/grumphp-xliff-task": "^6.0.0",
"rector/rector": "^0.17.0",
"rector/rector": "^1.0.4",
"squizlabs/php_codesniffer": "^3.7.1",
"symfony/yaml": "^5.4.0 || ^6.0 || ^7.0"
},
Expand Down Expand Up @@ -75,6 +75,6 @@
},
"require-typo3": {
"saschaegerer/phpstan-typo3": "^1.8.2",
"ssch/typo3-rector": "^1.3.5"
"ssch/typo3-rector": "^2.4.0"
}
}
33 changes: 9 additions & 24 deletions phpstan-baseline-without-typo3.neon
Original file line number Diff line number Diff line change
@@ -1,42 +1,37 @@
parameters:
ignoreErrors:
-
message: "#^Class Ssch\\\\TYPO3Rector\\\\Rector\\\\General\\\\ConvertImplicitVariablesToExplicitGlobalsRector not found\\.$#"
message: "#^Class Ssch\\\\TYPO3Rector\\\\CodeQuality\\\\General\\\\ConvertImplicitVariablesToExplicitGlobalsRector not found\\.$#"
count: 1
path: rector-typo3-rule-set.php

-
message: "#^Parameter \\#1 \\$rectorClasses of method Rector\\\\Config\\\\RectorConfig\\:\\:rules\\(\\) expects array\\<class\\-string\\<Rector\\\\Core\\\\Contract\\\\Rector\\\\RectorInterface\\>\\>, array\\<int, string\\> given\\.$#"
message: "#^Parameter \\#1 \\$rectorClasses of method Rector\\\\Config\\\\RectorConfig\\:\\:rules\\(\\) expects array\\<class\\-string\\<Rector\\\\Contract\\\\Rector\\\\RectorInterface\\>\\>, array\\<int, string\\> given\\.$#"
count: 1
path: rector-typo3-rule-set.php

-
message: "#^Access to constant TYPO3_104 on an unknown class Ssch\\\\TYPO3Rector\\\\Set\\\\Typo3SetList\\.$#"
message: "#^Access to constant CODE_QUALITY on an unknown class Ssch\\\\TYPO3Rector\\\\Set\\\\Typo3SetList\\.$#"
count: 1
path: src/RectorSettings.php

-
message: "#^Access to constant TYPO3_11 on an unknown class Ssch\\\\TYPO3Rector\\\\Set\\\\Typo3SetList\\.$#"
count: 1
path: src/RectorSettings.php

-
message: "#^Access to constant TYPO3_12 on an unknown class Ssch\\\\TYPO3Rector\\\\Set\\\\Typo3SetList\\.$#"
message: "#^Access to constant GENERAL on an unknown class Ssch\\\\TYPO3Rector\\\\Set\\\\Typo3SetList\\.$#"
count: 1
path: src/RectorSettings.php

-
message: "#^Access to constant TYPO3_76 on an unknown class Ssch\\\\TYPO3Rector\\\\Set\\\\Typo3SetList\\.$#"
message: "#^Access to constant TYPO3_11 on an unknown class Ssch\\\\TYPO3Rector\\\\Set\\\\Typo3SetList\\.$#"
count: 1
path: src/RectorSettings.php

-
message: "#^Access to constant TYPO3_87 on an unknown class Ssch\\\\TYPO3Rector\\\\Set\\\\Typo3SetList\\.$#"
message: "#^Access to constant TYPO3_12 on an unknown class Ssch\\\\TYPO3Rector\\\\Set\\\\Typo3SetList\\.$#"
count: 1
path: src/RectorSettings.php

-
message: "#^Access to constant TYPO3_95 on an unknown class Ssch\\\\TYPO3Rector\\\\Set\\\\Typo3SetList\\.$#"
message: "#^Access to constant TYPO3_13 on an unknown class Ssch\\\\TYPO3Rector\\\\Set\\\\Typo3SetList\\.$#"
count: 1
path: src/RectorSettings.php

Expand All @@ -56,21 +51,11 @@ parameters:
path: src/RectorSettings.php

-
message: "#^Access to constant UP_TO_TYPO3_7 on an unknown class Ssch\\\\TYPO3Rector\\\\Set\\\\Typo3LevelSetList\\.$#"
count: 1
path: src/RectorSettings.php

-
message: "#^Access to constant UP_TO_TYPO3_8 on an unknown class Ssch\\\\TYPO3Rector\\\\Set\\\\Typo3LevelSetList\\.$#"
count: 1
path: src/RectorSettings.php

-
message: "#^Access to constant UP_TO_TYPO3_9 on an unknown class Ssch\\\\TYPO3Rector\\\\Set\\\\Typo3LevelSetList\\.$#"
message: "#^Access to constant UP_TO_TYPO3_13 on an unknown class Ssch\\\\TYPO3Rector\\\\Set\\\\Typo3LevelSetList\\.$#"
count: 1
path: src/RectorSettings.php

-
message: "#^Class Ssch\\\\TYPO3Rector\\\\Rector\\\\Migrations\\\\RenameClassMapAliasRector not found\\.$#"
message: "#^Class Ssch\\\\TYPO3Rector\\\\CodeQuality\\\\General\\\\RenameClassMapAliasRector not found\\.$#"
count: 1
path: src/RectorSettings.php
1 change: 0 additions & 1 deletion phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
parameters:
ignoreErrors: []
4 changes: 2 additions & 2 deletions rector-typo3-rule-set.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

declare(strict_types=1);

use Ssch\TYPO3Rector\Rector\General\InjectMethodToConstructorInjectionRector;
use Ssch\TYPO3Rector\Rector\General\ConvertImplicitVariablesToExplicitGlobalsRector;
use Ssch\TYPO3Rector\CodeQuality\General\ConvertImplicitVariablesToExplicitGlobalsRector;
use Ssch\TYPO3Rector\CodeQuality\General\InjectMethodToConstructorInjectionRector;
use Rector\Config\RectorConfig;

return static function (RectorConfig $rectorConfig): void {
Expand Down
68 changes: 26 additions & 42 deletions src/RectorSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,21 @@
use Rector\CodeQuality\Rector\If_\ExplicitBoolCompareRector;
use Rector\CodeQuality\Rector\If_\SimplifyIfElseToTernaryRector;
use Rector\CodeQuality\Rector\Isset_\IssetOnPropertyObjectToPropertyExistsRector;
use Rector\CodingStyle\Rector\ClassMethod\UnSpreadOperatorRector;
use Rector\CodingStyle\Rector\FuncCall\CountArrayToEmptyArrayComparisonRector;
use Rector\CodingStyle\Rector\If_\NullableCompareToNullRector;
use Rector\CodingStyle\Rector\PostInc\PostIncDecToPreIncDecRector;
use Rector\CodingStyle\Rector\Switch_\BinarySwitchToIfElseRector;
use Rector\Php70\Rector\Assign\ListSwapArrayOrderRector;
use Rector\Php74\Rector\LNumber\AddLiteralSeparatorToNumberRector;
use Rector\Privatization\Rector\Property\PrivatizeFinalClassPropertyRector;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;
use Rector\Strict\Rector\BooleanNot\BooleanInBooleanNotRuleFixerRector;
use Rector\Strict\Rector\If_\BooleanInIfConditionRuleFixerRector;
use Rector\Strict\Rector\Ternary\DisallowedShortTernaryRuleFixerRector;
use Rector\TypeDeclaration\Rector\BooleanAnd\BinaryOpNullableToInstanceofRector;
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictGetterMethodReturnTypeRector;
use Ssch\TYPO3Rector\Rector\Migrations\RenameClassMapAliasRector;
use Ssch\TYPO3Rector\CodeQuality\General\RenameClassMapAliasRector;
use Ssch\TYPO3Rector\Set\Typo3LevelSetList;
use Ssch\TYPO3Rector\Set\Typo3SetList;
use Rector\DeadCode\Rector\MethodCall\RemoveEmptyMethodCallRector;
use Rector\Php73\Rector\ConstFetch\SensitiveConstantNameRector;

final class RectorSettings
Expand All @@ -45,14 +44,16 @@ public static function sets(bool $entirety = false): array

return array_filter(
[
// SetList::ACTION_INJECTION_TO_CONSTRUCTOR_INJECTION, // NO
SetList::CODE_QUALITY, // YES
SetList::CODING_STYLE, // YES
SetList::DEAD_CODE, // YES
SetList::STRICT_BOOLEANS, // only DisallowedEmptyRuleFixerRector
//SetList::GMAGICK_TO_IMAGICK, // NO
//SetList::MONOLOG_20, // no usage
//SetList::MYSQL_TO_MYSQLI, // no usage
//SetList::NAMING, //NO is not good
SetList::PRIVATIZATION, // some things may be bad
SetList::TYPE_DECLARATION, // YES
SetList::EARLY_RETURN, // YES
SetList::INSTANCEOF,
$phpFile,
//SetList::PHP_52, // YES, included in LevelSetList::class . '::UP_TO_PHP_' ...
//SetList::PHP_53, // YES, included in LevelSetList::class . '::UP_TO_PHP_' ...
Expand All @@ -67,10 +68,6 @@ public static function sets(bool $entirety = false): array
//SetList::PHP_80, // YES, included in LevelSetList::class . '::UP_TO_PHP_' ...
//SetList::PHP_81, // YES, included in LevelSetList::class . '::UP_TO_PHP_' ...
//SetList::PHP_82, // YES, included in LevelSetList::class . '::UP_TO_PHP_' ...
SetList::PRIVATIZATION, // some things may be bad
SetList::TYPE_DECLARATION, // YES
SetList::EARLY_RETURN, //YES
SetList::INSTANCEOF,
]
);
}
Expand All @@ -89,31 +86,27 @@ public static function setsTypo3(bool $entirety = false): array
[$major] = explode('.', $minimalTypo3Version, 2);

switch ($major) {
case 7:
$setList = $entirety ? Typo3LevelSetList::UP_TO_TYPO3_7 : Typo3SetList::TYPO3_76;
break;
case 8:
$setList = $entirety ? Typo3LevelSetList::UP_TO_TYPO3_8 : Typo3SetList::TYPO3_87;
break;
case 9:
$setList = $entirety ? Typo3LevelSetList::UP_TO_TYPO3_9 : Typo3SetList::TYPO3_95;
break;
case 10:
$setList = $entirety ? Typo3LevelSetList::UP_TO_TYPO3_10 : Typo3SetList::TYPO3_104;
$setList = Typo3LevelSetList::UP_TO_TYPO3_10;
break;
case 11:
$setList = $entirety ? Typo3LevelSetList::UP_TO_TYPO3_11 : Typo3SetList::TYPO3_11;
break;
case 12:
case 'dev-main':
$setList = $entirety ? Typo3LevelSetList::UP_TO_TYPO3_12 : Typo3SetList::TYPO3_12;
break;
case 13:
case 'dev-main':
$setList = $entirety ? Typo3LevelSetList::UP_TO_TYPO3_13 : Typo3SetList::TYPO3_13;
break;
}

assert(is_string($setList));
return [
$setList,
__DIR__ . '/../rector-typo3-rule-set.php',
Typo3SetList::CODE_QUALITY,
Typo3SetList::GENERAL,
];
}

Expand Down Expand Up @@ -148,16 +141,6 @@ public static function skip(): array
* TO: if($array !== []) {
*/
CountArrayToEmptyArrayComparisonRector::class,
/**
* FROM: switch($x) {
* TO: if($X === '...') {
*/
BinarySwitchToIfElseRector::class,
/**
* FROM: ->select('a', 'b')
* TO: ->select(['a', 'b'])
*/
UnSpreadOperatorRector::class,
/**
* FROM: protected string $name;
* TO: private string $name;
Expand Down Expand Up @@ -190,20 +173,21 @@ public static function skip(): array
*/
ExplicitBoolCompareRector::class,
/**
* FROM: isset($this->x);
* TO: property_exists($this, 'x') && $this->x !== null;
* FROM: (!self::$email) {
* TO: if (self::$email === '' || self::$email === '0') {
*/
IssetOnPropertyObjectToPropertyExistsRector::class,
BooleanInBooleanNotRuleFixerRector::class,
BooleanInIfConditionRuleFixerRector::class,
/**
* FROM: * @ var ObjectStorage<Moption>
* TO: * @ var ObjectStorage
* FROM: $filter['userGroup'] = max($userGroups ?: [0]);
* TO: $filter['userGroup'] = max($userGroups !== [] ? $userGroups : [0]);
*/
TypedPropertyFromStrictGetterMethodReturnTypeRector::class,
DisallowedShortTernaryRuleFixerRector::class,
/**
* perfomance issues in many projects
* @deprecated remove if rector 0.17.0 is not supported anymore:
* FROM: isset($this->x);
* TO: property_exists($this, 'x') && $this->x !== null;
*/
class_exists(RemoveEmptyMethodCallRector::class) ? RemoveEmptyMethodCallRector::class : null,
IssetOnPropertyObjectToPropertyExistsRector::class,
]);
}

Expand Down

0 comments on commit 500bdbe

Please sign in to comment.