From bd0104d6c645b4f91ac8762caf9250b8723c8bde Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Mon, 6 Jun 2022 19:28:24 +0200 Subject: [PATCH] [DX] Detach typo3 from core to allow stable growth of both packages (#2446) * remove old init command docs * detach typo3 from core, for very specific domain and many direct BC breaks from rector * cleanup scoper * remove downgrade of enum package, as not used anymore * remove non-existing directory --- .github/workflows/build_scoped_rector.yaml | 2 +- .github/workflows/packages_tests.yaml | 1 - build/config/config-downgrade.php | 6 -- build/target-repository/README.md | 2 +- build/target-repository/docs/init_command.md | 93 ------------------- composer.json | 1 - dev-docs/packages_ci_status.md | 7 -- full_build.sh | 2 +- scoper.php | 24 +---- .../src/PhpScoper/StaticEasyPrefixer.php | 4 - 10 files changed, 4 insertions(+), 138 deletions(-) delete mode 100644 build/target-repository/docs/init_command.md diff --git a/.github/workflows/build_scoped_rector.yaml b/.github/workflows/build_scoped_rector.yaml index 9fdbefc2413..5b4b1470b7a 100644 --- a/.github/workflows/build_scoped_rector.yaml +++ b/.github/workflows/build_scoped_rector.yaml @@ -85,7 +85,7 @@ jobs: php-version: 7.2 coverage: none - run: composer global require php-parallel-lint/php-parallel-lint - - run: /home/runner/.composer/vendor/bin/parallel-lint rector-prefixed-downgraded --exclude rector-prefixed-downgraded/stubs --exclude rector-prefixed-downgraded/vendor/tracy/tracy/examples --exclude rector-prefixed-downgraded/vendor/ssch/typo3-rector/templates/maker --exclude rector-prefixed-downgraded/vendor/rector/rector-generator/templates --exclude rector-prefixed-downgraded/vendor/symfony/contracts/Cache --exclude rector-prefixed-downgraded/vendor/symfony/contracts/HttpClient/Test + - run: /home/runner/.composer/vendor/bin/parallel-lint rector-prefixed-downgraded --exclude rector-prefixed-downgraded/stubs --exclude rector-prefixed-downgraded/vendor/tracy/tracy/examples --exclude rector-prefixed-downgraded/vendor/rector/rector-generator/templates --exclude rector-prefixed-downgraded/vendor/symfony/contracts/Cache --exclude rector-prefixed-downgraded/vendor/symfony/contracts/HttpClient/Test # 5. copy repository meta files - run: | diff --git a/.github/workflows/packages_tests.yaml b/.github/workflows/packages_tests.yaml index a851ed0de66..ab6ebf507f6 100644 --- a/.github/workflows/packages_tests.yaml +++ b/.github/workflows/packages_tests.yaml @@ -28,7 +28,6 @@ jobs: - rectorphp/rector-nette - rectorphp/rector-cakephp - rectorphp/rector-phpoffice - - sabbelasichon/typo3-rector steps: # see https://github.com/actions/checkout#usage diff --git a/build/config/config-downgrade.php b/build/config/config-downgrade.php index be9e8e10d74..32503883c03 100644 --- a/build/config/config-downgrade.php +++ b/build/config/config-downgrade.php @@ -33,9 +33,6 @@ final class DowngradeRectorConfig // symfony test are parts of package '*/Test/*', - // only for dev - 'packages/Testing/PhpConfigPrinter/*', - // Individual classes that can be excluded because // they are not used by Rector, and they use classes // loaded with "require-dev" so it'd throw an error @@ -46,10 +43,7 @@ final class DowngradeRectorConfig 'vendor/cweagans/*', // Rector doesn't use it, so we simply skip downgrading this class 'vendor/symfony/contracts/Cache/*', - // depends on PHPUnit, that is only in dev deps - 'vendor/myclabs/php-enum/src/PHPUnit/Comparator.php', 'vendor/rector/rector-generator/templates', - 'vendor/ssch/typo3-rector/config', ]; } diff --git a/build/target-repository/README.md b/build/target-repository/README.md index f9e9cfc81c1..5805338b39d 100644 --- a/build/target-repository/README.md +++ b/build/target-repository/README.md @@ -8,7 +8,7 @@ Rector instantly upgrades and refactors the PHP code of your application. It ca ### 1. Instant Upgrades -Rector now supports upgrades from PHP 5.3 to 8.1 and major open-source projects like [Symfony](https://github.com/rectorphp/rector-symfony), [PHPUnit](https://github.com/rectorphp/rector-phpunit), [Nette](https://github.com/rectorphp/rector-nette), [Laravel](https://github.com/rectorphp/rector-laravel), [CakePHP](https://github.com/rectorphp/rector-cakephp), [Doctrine](https://github.com/rectorphp/rector-doctrine) and [TYPO3](https://github.com/sabbelasichon/typo3-rector) out of the box. Do you want to **be constantly on the latest PHP and Framework without effort**? +Rector now supports upgrades from PHP 5.3 to 8.1 and major open-source projects like [Symfony](https://github.com/rectorphp/rector-symfony), [PHPUnit](https://github.com/rectorphp/rector-phpunit), [Nette](https://github.com/rectorphp/rector-nette), [Laravel](https://github.com/rectorphp/rector-laravel), [CakePHP](https://github.com/rectorphp/rector-cakephp) and [Doctrine](https://github.com/rectorphp/rector-doctrine). Do you want to **be constantly on the latest PHP and Framework without effort**? Use Rector to handle **instant upgrades** for you. diff --git a/build/target-repository/docs/init_command.md b/build/target-repository/docs/init_command.md deleted file mode 100644 index 13dba30a0de..00000000000 --- a/build/target-repository/docs/init_command.md +++ /dev/null @@ -1,93 +0,0 @@ -# How to generate a configuration file - -To start quickly you can run the init command - -```bash -vendor/bin/rector init -``` - -This will create a `rector.php` if it doesn't already exist in your root directory with some sensitive defaults to start with. - -```php -use Rector\Php74\Rector\Property\TypedPropertyRector; -use Rector\Set\ValueObject\SetList; -use Rector\Config\RectorConfig; - -return static function (RectorConfig $rectorConfig): void { - // here we can define, what sets of rules will be applied - $rectorConfig->sets([SetList::CODE_QUALITY]); - - // register single rule - $rectorConfig->rule(TypedPropertyRector::class); -}; -``` - -The init command takes an option called `--template-type`. -If some other Rector extension like [rector-nette](https://github.com/rectorphp/rector-nette) or [typo3-rector](https://github.com/sabbelasichon/typo3-rector) provides such a custom template type you can specify it here: - -```bash -vendor/bin/rector init --template-type=typo3 -``` - -The rector.php file for TYPO3 contains useful framework specific defaults to start from: - -```php -use Ssch\TYPO3Rector\Set\Typo3SetList; -use Rector\PostRector\Rector\NameImportingPostRector; -use Rector\Config\RectorConfig; - -return static function (RectorConfig $rectorConfig): void { - $rectorConfig->sets([ - Typo3SetList::TYPO3_76, - Typo3SetList::TYPO3_87, - Typo3SetList::TYPO3_95, - Typo3SetList::TYPO3_104, - Typo3SetList::TYPO3_11, - ]); - - $rectorConfig->skip([ - NameImportingPostRector::class => [ - 'ClassAliasMap.php', - 'ext_localconf.php', - 'ext_emconf.php', - 'ext_tables.php', - __DIR__ . '/**/Configuration/TCA/*', - __DIR__ . '/**/Configuration/RequestMiddlewares.php', - __DIR__ . '/**/Configuration/Commands.php', - __DIR__ . '/**/Configuration/AjaxRoutes.php', - __DIR__ . '/**/Configuration/Extbase/Persistence/Classes.php', - ], - ]); -}; -``` - -If you just want to use the default template provided by Rector you can omit the --template-type option. - -# How to add a template type as a developer -In order to provide a new template type as a developer you should create a custom template class implementing the TemplateResolverInterface: - -```php -use Rector\Core\Contract\Template\TemplateResolverInterface; - -final class MyCustomTemplate implements TemplateResolverInterface -{ - /** - * @var string - */ - private const TYPE = 'custom'; - - public function provide(): string - { - return __DIR__ . '/path/to/custom/template.php.dist'; - } - public function supports(string $type): bool - { - return $type === self::TYPE; - } - - public function __toString(): string - { - return self::TYPE; - } -} -``` diff --git a/composer.json b/composer.json index 1147873b879..91efebb1c51 100644 --- a/composer.json +++ b/composer.json @@ -33,7 +33,6 @@ "rector/rector-phpunit": "dev-main", "rector/rector-symfony": "dev-main", "sebastian/diff": "^4.0.4", - "ssch/typo3-rector": "dev-main", "symfony/console": "6.1.*", "symfony/contracts": "3.1.*", "symfony/dependency-injection": "6.1.*", diff --git a/dev-docs/packages_ci_status.md b/dev-docs/packages_ci_status.md index 3c9bc3d1529..92f8a5194c3 100644 --- a/dev-docs/packages_ci_status.md +++ b/dev-docs/packages_ci_status.md @@ -48,13 +48,6 @@ * ![](https://github.com/rectorphp/rector-doctrine/actions/workflows/tests.yaml/badge.svg) * ![](https://github.com/rectorphp/rector-doctrine/actions/workflows/code_analysis.yaml/badge.svg) -## Typo3 - -* https://github.com/sabbelasichon/typo3-rector -* ![](https://github.com/sabbelasichon/typo3-rector/actions/workflows/tests.yaml/badge.svg) -* ![](https://github.com/sabbelasichon/typo3-rector/actions/workflows/phpstan.yaml/badge.svg) -* ![](https://github.com/sabbelasichon/typo3-rector/actions/workflows/rector.yaml/badge.svg) - ## PHP Office * https://github.com/rectorphp/rector-phpoffice diff --git a/full_build.sh b/full_build.sh index d2ddbdc43d3..616ca7b5319 100644 --- a/full_build.sh +++ b/full_build.sh @@ -37,7 +37,7 @@ sh build/build-rector-scoped.sh rector-build rector-prefixed-downgraded # verify syntax valid in php 7.2 composer global require php-parallel-lint/php-parallel-lint -~/.composer/vendor/bin/parallel-lint rector-prefixed-downgraded --exclude rector-prefixed-downgraded/stubs --exclude rector-prefixed-downgraded/vendor/tracy/tracy/examples --exclude rector-prefixed-downgraded/vendor/ssch/typo3-rector/templates/maker --exclude rector-prefixed-downgraded/vendor/rector/rector-generator/templates --exclude rector-prefixed-downgraded/vendor/symfony/contracts/Cache --exclude rector-prefixed-downgraded/vendor/symfony/contracts/HttpClient/Test +~/.composer/vendor/bin/parallel-lint rector-prefixed-downgraded --exclude rector-prefixed-downgraded/stubs --exclude rector-prefixed-downgraded/vendor/tracy/tracy/examples --exclude rector-prefixed-downgraded/vendor/rector/rector-generator/templates --exclude rector-prefixed-downgraded/vendor/symfony/contracts/Cache --exclude rector-prefixed-downgraded/vendor/symfony/contracts/HttpClient/Test # Check php 7.2 can be used locally with PHP72_BIN_PATH env # rector-prefixed-downgraded check diff --git a/scoper.php b/scoper.php index b783cc6445c..f90d022cbaa 100644 --- a/scoper.php +++ b/scoper.php @@ -87,20 +87,6 @@ return [ 'Symplify\SmartFileSystem\SmartFileInfo' ), - // unprefixed Statement - fn (string $filePath, string $prefix, string $content): string => Strings::replace( - $content, - '#' . $prefix . '\\\\Helmich\\\\TypoScriptParser\\\\Parser\\\\AST\\\\Statement#', - 'Helmich\TypoScriptParser\Parser\AST\Statement' - ), - - // unprefixed Traverser - fn (string $filePath, string $prefix, string $content): string => Strings::replace( - $content, - '#' . $prefix . '\\\\Helmich\\\\TypoScriptParser\\\\Parser\\\\Traverser\\\\Traverser#', - 'Helmich\TypoScriptParser\Parser\Traverser\Traverser' - ), - // unprefixed PHPUnit IsEqual fn (string $filePath, string $prefix, string $content): string => Strings::replace( $content, @@ -183,10 +169,7 @@ return [ // unprefix string classes, as they're string on purpose - they have to be checked in original form, not prefixed function (string $filePath, string $prefix, string $content): string { // skip vendor, expect rector packages - if (\str_contains($filePath, 'vendor/') && ! \str_contains($filePath, 'vendor/rector') && ! \str_contains( - $filePath, - 'vendor/ssch/typo3-rector' - )) { + if (\str_contains($filePath, 'vendor/') && ! \str_contains($filePath, 'vendor/rector')) { return $content; } @@ -210,11 +193,6 @@ return [ return $content; } - // skip "Ssch\\" namespace - if (\str_contains($content, '$services->load(\'Ssch')) { - return $content; - } - return Strings::replace($content, '#services\->load\(\'#', "services->load('" . $prefix . '\\'); }, diff --git a/utils/compiler/src/PhpScoper/StaticEasyPrefixer.php b/utils/compiler/src/PhpScoper/StaticEasyPrefixer.php index 4c4d4f90cb4..c35c48b779b 100644 --- a/utils/compiler/src/PhpScoper/StaticEasyPrefixer.php +++ b/utils/compiler/src/PhpScoper/StaticEasyPrefixer.php @@ -16,9 +16,6 @@ final class StaticEasyPrefixer 'Symplify\SmartFileSystem\SmartFileInfo', // for ComposerJson because it is part of the public API. I.e. ComposerRectorInterface 'Symplify\ComposerJsonManipulator\ValueObject\ComposerJson', - // for usage in Helmich\TypoScriptParser\Parser\Traverser\Visitor - 'Helmich\TypoScriptParser\Parser\AST\Statement', - 'Helmich\TypoScriptParser\Parser\Traverser\Traverser', // for usage in packages/Testing/PHPUnit/PlatformAgnosticAssertions.php 'PHPUnit\Framework\Constraint\IsEqual', ]; @@ -31,7 +28,6 @@ final class StaticEasyPrefixer 'Rector\*', // we use this API a lot 'PhpParser\*', - 'Ssch\TYPO3Rector\*', // phpstan needs to be here, as phpstan/vendor autoload is statically generated and namespaces cannot be changed 'PHPStan\*',