diff --git a/composer.json b/composer.json index ea6d26328971..c109bbd5be55 100644 --- a/composer.json +++ b/composer.json @@ -123,7 +123,6 @@ "Rector\\NodeNestingScope\\": "packages/node-nesting-scope/src", "Rector\\Sensio\\": "rules/sensio/src", "Rector\\Shopware\\": "rules/shopware/src", - "Rector\\Silverstripe\\": "rules/silverstripe/src", "Rector\\StaticTypeMapper\\": "packages/static-type-mapper/src", "Rector\\StrictCodeQuality\\": "rules/strict-code-quality/src", "Rector\\Sylius\\": "rules/sylius/src", @@ -194,7 +193,6 @@ "Rector\\SOLID\\Tests\\": "rules/solid/tests", "Rector\\Sensio\\Tests\\": "rules/sensio/tests", "Rector\\Shopware\\Tests\\": "rules/shopware/tests", - "Rector\\Silverstripe\\Tests\\": "rules/silverstripe/tests", "Rector\\StrictCodeQuality\\Tests\\": "rules/strict-code-quality/tests", "Rector\\Sylius\\Tests\\": "rules/sylius/tests", "Rector\\SymfonyCodeQuality\\Tests\\": "rules/symfony-code-quality/tests", diff --git a/config/set/silverstripe/silverstripe.yaml b/config/set/silverstripe/silverstripe.yaml deleted file mode 100644 index dfe16729967f..000000000000 --- a/config/set/silverstripe/silverstripe.yaml +++ /dev/null @@ -1,5 +0,0 @@ -# various versions -services: - # https://github.com/silverstripe/silverstripe-upgrader/issues/76 - Rector\Silverstripe\Rector\ConstantToStaticCallRector: null - Rector\Silverstripe\Rector\DefineConstantToStaticCallRector: null diff --git a/docs/how_it_works.md b/docs/how_it_works.md index 82caf8cc9e99..c3f3b4e71870 100644 --- a/docs/how_it_works.md +++ b/docs/how_it_works.md @@ -87,6 +87,7 @@ services: ### Similar Projects - [ClangMR](https://static.googleusercontent.com/media/research.google.com/en//pubs/archive/41342.pdf) for C++ by Google (closed source) - almost idential workflow, developed independently though +- [hhast](https://github.com/hhvm/hhast) - HHVM AST + format preserving + mirations - [facebook/jscodeshift](https://github.com/facebook/jscodeshift) for Javascript - [silverstripe/silverstripe-upgrader](https://github.com/silverstripe/silverstripe-upgrader) for PHP CMS, Silverstripe - [dereuromark/upgrade](https://github.com/dereuromark/upgrade) for PHP Framework, CakePHP diff --git a/docs/rector_rules_overview.md b/docs/rector_rules_overview.md index 7a168a9961ee..0e8334822811 100644 --- a/docs/rector_rules_overview.md +++ b/docs/rector_rules_overview.md @@ -1,4 +1,4 @@ -# All 490 Rectors Overview +# All 488 Rectors Overview - [Projects](#projects) - [General](#general) @@ -59,7 +59,6 @@ - [SOLID](#solid) (11) - [Sensio](#sensio) (1) - [Shopware](#shopware) (3) -- [Silverstripe](#silverstripe) (2) - [StrictCodeQuality](#strictcodequality) (1) - [Sylius](#sylius) (1) - [Symfony](#symfony) (29) @@ -4147,7 +4146,7 @@ Change singleton class to normal class that can be registered as a service ### `FunctionToStaticMethodRector` -- class: [`Rector\Legacy\Rector\Node\FunctionToStaticMethodRector`](/../master/rules/legacy/src/Rector/Node/FunctionToStaticMethodRector.php) +- class: [`Rector\Legacy\Rector\FileSystem\FunctionToStaticMethodRector`](/../master/rules/legacy/src/Rector/FileSystem/FunctionToStaticMethodRector.php) Change functions to static calls, so composer can autoload them @@ -9282,36 +9281,6 @@ Use version from di parameter
-## Silverstripe - -### `ConstantToStaticCallRector` - -- class: [`Rector\Silverstripe\Rector\ConstantToStaticCallRector`](/../master/rules/silverstripe/src/Rector/ConstantToStaticCallRector.php) -- [test fixtures](/../master/rules/silverstripe/tests/Rector/ConstantToStaticCallRector/Fixture) - -Turns defined constant to static method call. - -```diff --SS_DATABASE_NAME; -+Environment::getEnv("SS_DATABASE_NAME"); -``` - -
- -### `DefineConstantToStaticCallRector` - -- class: [`Rector\Silverstripe\Rector\DefineConstantToStaticCallRector`](/../master/rules/silverstripe/src/Rector/DefineConstantToStaticCallRector.php) -- [test fixtures](/../master/rules/silverstripe/tests/Rector/DefineConstantToStaticCallRector/Fixture) - -Turns defined function call to static method call. - -```diff --defined("SS_DATABASE_NAME"); -+Environment::getEnv("SS_DATABASE_NAME"); -``` - -
- ## StrictCodeQuality ### `VarInlineAnnotationToAssertRector` diff --git a/rules/silverstripe/src/Rector/ConstantToStaticCallRector.php b/rules/silverstripe/src/Rector/ConstantToStaticCallRector.php deleted file mode 100644 index 36680c7cf4bf..000000000000 --- a/rules/silverstripe/src/Rector/ConstantToStaticCallRector.php +++ /dev/null @@ -1,51 +0,0 @@ -getName($node); - if ($constantName === null) { - return null; - } - - if (! Strings::startsWith($constantName, 'SS_')) { - return null; - } - - return $this->createStaticCall('Environment', 'getEnv', [new String_($constantName)]); - } -} diff --git a/rules/silverstripe/src/Rector/DefineConstantToStaticCallRector.php b/rules/silverstripe/src/Rector/DefineConstantToStaticCallRector.php deleted file mode 100644 index c8a248905f56..000000000000 --- a/rules/silverstripe/src/Rector/DefineConstantToStaticCallRector.php +++ /dev/null @@ -1,59 +0,0 @@ -args) !== 1) { - return null; - } - - if (! $this->isName($node, 'defined')) { - return null; - } - - $argumentValue = $node->args[0]->value; - if (! $argumentValue instanceof String_) { - return null; - } - - if (! Strings::startsWith($argumentValue->value, 'SS_')) { - return null; - } - - return $this->createStaticCall('Environment', 'getEnv', $node->args); - } -} diff --git a/rules/silverstripe/tests/Rector/ConstantToStaticCallRector/ConstantToStaticCallRectorTest.php b/rules/silverstripe/tests/Rector/ConstantToStaticCallRector/ConstantToStaticCallRectorTest.php deleted file mode 100644 index fd115d460326..000000000000 --- a/rules/silverstripe/tests/Rector/ConstantToStaticCallRector/ConstantToStaticCallRectorTest.php +++ /dev/null @@ -1,30 +0,0 @@ -doTestFile($file); - } - - public function provideData(): Iterator - { - return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - protected function getRectorClass(): string - { - return ConstantToStaticCallRector::class; - } -} diff --git a/rules/silverstripe/tests/Rector/ConstantToStaticCallRector/Fixture/fixture.php.inc b/rules/silverstripe/tests/Rector/ConstantToStaticCallRector/Fixture/fixture.php.inc deleted file mode 100644 index 0de6ba3b43a8..000000000000 --- a/rules/silverstripe/tests/Rector/ConstantToStaticCallRector/Fixture/fixture.php.inc +++ /dev/null @@ -1,21 +0,0 @@ - ------ - diff --git a/rules/silverstripe/tests/Rector/DefineConstantToStaticCallRector/DefineConstantToStaticCallRectorTest.php b/rules/silverstripe/tests/Rector/DefineConstantToStaticCallRector/DefineConstantToStaticCallRectorTest.php deleted file mode 100644 index 1f05b042c26c..000000000000 --- a/rules/silverstripe/tests/Rector/DefineConstantToStaticCallRector/DefineConstantToStaticCallRectorTest.php +++ /dev/null @@ -1,30 +0,0 @@ -doTestFile($file); - } - - public function provideData(): Iterator - { - return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - protected function getRectorClass(): string - { - return DefineConstantToStaticCallRector::class; - } -} diff --git a/rules/silverstripe/tests/Rector/DefineConstantToStaticCallRector/Fixture/fixture.php.inc b/rules/silverstripe/tests/Rector/DefineConstantToStaticCallRector/Fixture/fixture.php.inc deleted file mode 100644 index 091dae8b3d83..000000000000 --- a/rules/silverstripe/tests/Rector/DefineConstantToStaticCallRector/Fixture/fixture.php.inc +++ /dev/null @@ -1,25 +0,0 @@ - ------ - diff --git a/sonar-project.properties b/sonar-project.properties index 97f2c4162a21..a87e4f733ac7 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -4,9 +4,9 @@ sonar.projectKey=rectorphp_rector # relative paths to source # wildcards don't work :( -sonar.sources=compiler/src,src,rules/autodiscovery/src,rules/architecture/src,packages/attribute-aware-php-doc/src,packages/better-php-doc-parser/src,rules/cakephp/src,rules/celebrity/src,rules/code-quality/src,rules/coding-style/src,packages/console-differ/src,rules/dead-code/src,rules/doctrine/src,rules/doctrine-code-quality/src,rules/framework-migration/src,packages/file-system-rector/src,rules/elastic-search-dsl/src,rules/guzzle/src,rules/laravel/src,rules/legacy/src,rules/mysql-to-mysqli/src,rules/nette-tester-to-phpunit/src,rules/nette-to-symfony/src,rules/nette/src,packages/node-collector/src,packages/node-type-resolver/src,packages/node-name-resolver/src,rules/phpstan/src,packages/phpstan-static-type-mapper/src,rules/phpunit-symfony/src,rules/phpunit/src,rules/psr4/src,rules/php-spec-to-phpunit/src,rules/php52/src,rules/php53/src,rules/php54/src,rules/php55/src,rules/php56/src,rules/php70/src,rules/php71/src,rules/php72/src,rules/php73/src,rules/php74/src,rules/php80/src,rules/removing-static/src,rules/renaming/src,rules/restoration/src,packages/refactoring/src,rules/solid/src,rules/sensio/src,rules/shopware/src,rules/silverstripe/src,packages/static-type-mapper/src,rules/sylius/src,rules/symfony-code-quality/src,rules/symfony-phpunit/src,rules/symfony/src,rules/twig/src,rules/type-declaration/src,packages/vendor-locker/src,packages/rector-generator/src,rules/strict-code-quality/src,packages/dynamic-type-analysis/src,rules/php-deglobalize/src,rules/phalcon/src,rules/doctrine-gedmo-to-knplabs/src,packages/polyfill/src +sonar.sources=compiler/src,src,rules/autodiscovery/src,rules/architecture/src,packages/attribute-aware-php-doc/src,packages/better-php-doc-parser/src,rules/cakephp/src,rules/celebrity/src,rules/code-quality/src,rules/coding-style/src,packages/console-differ/src,rules/dead-code/src,rules/doctrine/src,rules/doctrine-code-quality/src,rules/framework-migration/src,packages/file-system-rector/src,rules/elastic-search-dsl/src,rules/guzzle/src,rules/laravel/src,rules/legacy/src,rules/mysql-to-mysqli/src,rules/nette-tester-to-phpunit/src,rules/nette-to-symfony/src,rules/nette/src,packages/node-collector/src,packages/node-type-resolver/src,packages/node-name-resolver/src,rules/phpstan/src,packages/phpstan-static-type-mapper/src,rules/phpunit-symfony/src,rules/phpunit/src,rules/psr4/src,rules/php-spec-to-phpunit/src,rules/php52/src,rules/php53/src,rules/php54/src,rules/php55/src,rules/php56/src,rules/php70/src,rules/php71/src,rules/php72/src,rules/php73/src,rules/php74/src,rules/php80/src,rules/removing-static/src,rules/renaming/src,rules/restoration/src,packages/refactoring/src,rules/solid/src,rules/sensio/src,rules/shopware/src,packages/static-type-mapper/src,rules/sylius/src,rules/symfony-code-quality/src,rules/symfony-phpunit/src,rules/symfony/src,rules/twig/src,rules/type-declaration/src,packages/vendor-locker/src,packages/rector-generator/src,rules/strict-code-quality/src,packages/dynamic-type-analysis/src,rules/php-deglobalize/src,rules/phalcon/src,rules/doctrine-gedmo-to-knplabs/src,packages/polyfill/src -sonar.tests=tests,rules/autodiscovery/tests,rules/architecture/tests,packages/better-php-doc-parser/tests,rules/cakephp/tests,rules/celebrity/tests,rules/code-quality/tests,rules/coding-style/tests,rules/dead-code/tests,rules/doctrine/tests,rules/doctrine-code-quality/tests,rules/elastic-search-dsl/tests,rules/guzzle/tests,rules/laravel/tests,rules/legacy/tests,rules/mysql-to-mysqli/tests,rules/nette-tester-to-phpunit/tests,rules/nette-to-symfony/tests,rules/nette/tests,packages/node-type-resolver/tests,utils/phpstan-extensions/src,rules/phpstan/tests,rules/phpunit-symfony/tests,rules/phpunit/tests,rules/psr4/tests,rules/php-spec-to-phpunit/tests,rules/php52/tests,rules/php53/tests,rules/php54/tests,rules/php55/tests,rules/php56/tests,rules/php70/tests,rules/php71/tests,rules/php72/tests,rules/php73/tests,rules/php74/tests,rules/php80/tests,rules/removing-static/tests,rules/renaming/tests,rules/restoration/tests,rules/solid/tests,rules/sensio/tests,rules/shopware/tests,rules/silverstripe/tests,rules/sylius/tests,rules/symfony-code-quality/tests,rules/symfony-phpunit/tests,rules/symfony/tests,rules/twig/tests,rules/type-declaration/tests,rules/strict-code-quality/tests,packages/dynamic-type-analysis/tests,rules/php-deglobalize/tests,rules/phalcon/tests,utils/documentation-generator/src,utils/phpstan-attribute-type-syncer/src,utils/phpstan-static-type-mapper-checker/src,rules/doctrine-gedmo-to-knplabs/tests,packages/polyfill/tests +sonar.tests=tests,rules/autodiscovery/tests,rules/architecture/tests,packages/better-php-doc-parser/tests,rules/cakephp/tests,rules/celebrity/tests,rules/code-quality/tests,rules/coding-style/tests,rules/dead-code/tests,rules/doctrine/tests,rules/doctrine-code-quality/tests,rules/elastic-search-dsl/tests,rules/guzzle/tests,rules/laravel/tests,rules/legacy/tests,rules/mysql-to-mysqli/tests,rules/nette-tester-to-phpunit/tests,rules/nette-to-symfony/tests,rules/nette/tests,packages/node-type-resolver/tests,utils/phpstan-extensions/src,rules/phpstan/tests,rules/phpunit-symfony/tests,rules/phpunit/tests,rules/psr4/tests,rules/php-spec-to-phpunit/tests,rules/php52/tests,rules/php53/tests,rules/php54/tests,rules/php55/tests,rules/php56/tests,rules/php70/tests,rules/php71/tests,rules/php72/tests,rules/php73/tests,rules/php74/tests,rules/php80/tests,rules/removing-static/tests,rules/renaming/tests,rules/restoration/tests,rules/solid/tests,rules/sensio/tests,rules/shopware/tests,rules/sylius/tests,rules/symfony-code-quality/tests,rules/symfony-phpunit/tests,rules/symfony/tests,rules/twig/tests,rules/type-declaration/tests,rules/strict-code-quality/tests,packages/dynamic-type-analysis/tests,rules/php-deglobalize/tests,rules/phalcon/tests,utils/documentation-generator/src,utils/phpstan-attribute-type-syncer/src,utils/phpstan-static-type-mapper-checker/src,rules/doctrine-gedmo-to-knplabs/tests,packages/polyfill/tests # see https://docs.sonarqube.org/latest/project-administration/narrowing-the-focus/#NarrowingtheFocus-patterns sonar.exclusions=src/**/*.php.inc,rules/**/*.php.inc,packages/**/*.php.inc,packages/**/Fixture/**/*,rules/**/Fixture/**/*,tests/**/Source/**/*