mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-08 04:10:51 +00:00
[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:
parent
0eba231b07
commit
bd0104d6c6
2
.github/workflows/build_scoped_rector.yaml
vendored
2
.github/workflows/build_scoped_rector.yaml
vendored
|
@ -85,7 +85,7 @@ jobs:
|
||||||
php-version: 7.2
|
php-version: 7.2
|
||||||
coverage: none
|
coverage: none
|
||||||
- run: composer global require php-parallel-lint/php-parallel-lint
|
- 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
|
# 5. copy repository meta files
|
||||||
- run: |
|
- run: |
|
||||||
|
|
1
.github/workflows/packages_tests.yaml
vendored
1
.github/workflows/packages_tests.yaml
vendored
|
@ -28,7 +28,6 @@ jobs:
|
||||||
- rectorphp/rector-nette
|
- rectorphp/rector-nette
|
||||||
- rectorphp/rector-cakephp
|
- rectorphp/rector-cakephp
|
||||||
- rectorphp/rector-phpoffice
|
- rectorphp/rector-phpoffice
|
||||||
- sabbelasichon/typo3-rector
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
# see https://github.com/actions/checkout#usage
|
# see https://github.com/actions/checkout#usage
|
||||||
|
|
|
@ -33,9 +33,6 @@ final class DowngradeRectorConfig
|
||||||
// symfony test are parts of package
|
// symfony test are parts of package
|
||||||
'*/Test/*',
|
'*/Test/*',
|
||||||
|
|
||||||
// only for dev
|
|
||||||
'packages/Testing/PhpConfigPrinter/*',
|
|
||||||
|
|
||||||
// Individual classes that can be excluded because
|
// Individual classes that can be excluded because
|
||||||
// they are not used by Rector, and they use classes
|
// they are not used by Rector, and they use classes
|
||||||
// loaded with "require-dev" so it'd throw an error
|
// loaded with "require-dev" so it'd throw an error
|
||||||
|
@ -46,10 +43,7 @@ final class DowngradeRectorConfig
|
||||||
'vendor/cweagans/*',
|
'vendor/cweagans/*',
|
||||||
// Rector doesn't use it, so we simply skip downgrading this class
|
// Rector doesn't use it, so we simply skip downgrading this class
|
||||||
'vendor/symfony/contracts/Cache/*',
|
'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/rector/rector-generator/templates',
|
||||||
'vendor/ssch/typo3-rector/config',
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ Rector instantly upgrades and refactors the PHP code of your application. It ca
|
||||||
|
|
||||||
### 1. Instant Upgrades
|
### 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.
|
Use Rector to handle **instant upgrades** for you.
|
||||||
|
|
||||||
|
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
|
@ -33,7 +33,6 @@
|
||||||
"rector/rector-phpunit": "dev-main",
|
"rector/rector-phpunit": "dev-main",
|
||||||
"rector/rector-symfony": "dev-main",
|
"rector/rector-symfony": "dev-main",
|
||||||
"sebastian/diff": "^4.0.4",
|
"sebastian/diff": "^4.0.4",
|
||||||
"ssch/typo3-rector": "dev-main",
|
|
||||||
"symfony/console": "6.1.*",
|
"symfony/console": "6.1.*",
|
||||||
"symfony/contracts": "3.1.*",
|
"symfony/contracts": "3.1.*",
|
||||||
"symfony/dependency-injection": "6.1.*",
|
"symfony/dependency-injection": "6.1.*",
|
||||||
|
|
|
@ -48,13 +48,6 @@
|
||||||
* ![](https://github.com/rectorphp/rector-doctrine/actions/workflows/tests.yaml/badge.svg)
|
* ![](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)
|
* ![](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
|
## PHP Office
|
||||||
|
|
||||||
* https://github.com/rectorphp/rector-phpoffice
|
* https://github.com/rectorphp/rector-phpoffice
|
||||||
|
|
|
@ -37,7 +37,7 @@ sh build/build-rector-scoped.sh rector-build rector-prefixed-downgraded
|
||||||
|
|
||||||
# verify syntax valid in php 7.2
|
# verify syntax valid in php 7.2
|
||||||
composer global require php-parallel-lint/php-parallel-lint
|
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
|
# Check php 7.2 can be used locally with PHP72_BIN_PATH env
|
||||||
# rector-prefixed-downgraded check
|
# rector-prefixed-downgraded check
|
||||||
|
|
24
scoper.php
24
scoper.php
|
@ -87,20 +87,6 @@ return [
|
||||||
'Symplify\SmartFileSystem\SmartFileInfo'
|
'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
|
// unprefixed PHPUnit IsEqual
|
||||||
fn (string $filePath, string $prefix, string $content): string => Strings::replace(
|
fn (string $filePath, string $prefix, string $content): string => Strings::replace(
|
||||||
$content,
|
$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
|
// 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 {
|
function (string $filePath, string $prefix, string $content): string {
|
||||||
// skip vendor, expect rector packages
|
// skip vendor, expect rector packages
|
||||||
if (\str_contains($filePath, 'vendor/') && ! \str_contains($filePath, 'vendor/rector') && ! \str_contains(
|
if (\str_contains($filePath, 'vendor/') && ! \str_contains($filePath, 'vendor/rector')) {
|
||||||
$filePath,
|
|
||||||
'vendor/ssch/typo3-rector'
|
|
||||||
)) {
|
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,11 +193,6 @@ return [
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip "Ssch\\" namespace
|
|
||||||
if (\str_contains($content, '$services->load(\'Ssch')) {
|
|
||||||
return $content;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Strings::replace($content, '#services\->load\(\'#', "services->load('" . $prefix . '\\');
|
return Strings::replace($content, '#services\->load\(\'#', "services->load('" . $prefix . '\\');
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -16,9 +16,6 @@ final class StaticEasyPrefixer
|
||||||
'Symplify\SmartFileSystem\SmartFileInfo',
|
'Symplify\SmartFileSystem\SmartFileInfo',
|
||||||
// for ComposerJson because it is part of the public API. I.e. ComposerRectorInterface
|
// for ComposerJson because it is part of the public API. I.e. ComposerRectorInterface
|
||||||
'Symplify\ComposerJsonManipulator\ValueObject\ComposerJson',
|
'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
|
// for usage in packages/Testing/PHPUnit/PlatformAgnosticAssertions.php
|
||||||
'PHPUnit\Framework\Constraint\IsEqual',
|
'PHPUnit\Framework\Constraint\IsEqual',
|
||||||
];
|
];
|
||||||
|
@ -31,7 +28,6 @@ final class StaticEasyPrefixer
|
||||||
'Rector\*',
|
'Rector\*',
|
||||||
// we use this API a lot
|
// we use this API a lot
|
||||||
'PhpParser\*',
|
'PhpParser\*',
|
||||||
'Ssch\TYPO3Rector\*',
|
|
||||||
|
|
||||||
// phpstan needs to be here, as phpstan/vendor autoload is statically generated and namespaces cannot be changed
|
// phpstan needs to be here, as phpstan/vendor autoload is statically generated and namespaces cannot be changed
|
||||||
'PHPStan\*',
|
'PHPStan\*',
|
||||||
|
|
Loading…
Reference in New Issue
Block a user