[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
This commit is contained in:
Tomas Votruba 2022-06-06 19:28:24 +02:00 committed by GitHub
parent 0eba231b07
commit bd0104d6c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 4 additions and 138 deletions

View File

@ -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: |

View File

@ -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

View File

@ -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',
];
}

View File

@ -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.

View File

@ -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;
}
}
```

View File

@ -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.*",

View File

@ -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

View File

@ -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

View File

@ -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 . '\\');
},

View File

@ -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\*',