diff --git a/.github/workflows/rector_run.yaml b/.github/workflows/along_other_packages.yaml similarity index 65% rename from .github/workflows/rector_run.yaml rename to .github/workflows/along_other_packages.yaml index 69e05a5278f..3465ac77301 100644 --- a/.github/workflows/rector_run.yaml +++ b/.github/workflows/along_other_packages.yaml @@ -1,4 +1,4 @@ -name: Rector Run +name: Along Other Packages on: pull_request: null @@ -7,7 +7,7 @@ on: - main jobs: - rector_run: + along_other_packages: runs-on: ubuntu-latest strategy: @@ -16,21 +16,17 @@ jobs: php_version: ['7.1', '7.2', '7.3', '7.4', '8.0'] commands: - - name: 'Finalize Entity' - install: composer require doctrine/orm - run: vendor/bin/rector process ../tests/fixture-finalize --config ../ci/rector-finalize.php --ansi + name: 'Composer Dependency' + install: composer require symfony/console:2.8 --ansi + run: vendor/bin/rector list --debug --ansi - - name: 'Composer Dependency' - install: composer require symfony/console 2.8 - run: vendor/bin/rector list --debug --ansi + name: 'PHP Parser 3.1' + install: composer require nikic/php-parser:^3.1 --ansi - name: 'Along PHPStan' install: composer require phpstan/phpstan:0.12.86 --dev --ansi - run: | - vendor/bin/rector list --ansi - vendor/bin/phpstan -h --ansi name: "PHP ${{ matrix.php_version }}" @@ -42,19 +38,19 @@ jobs: php-version: ${{ matrix.php_version }} coverage: none + # wait for deploy to packagist + - run: sleep 70 + - run: | mkdir standalone cd standalone - # wait for deploy to packagist - sleep 70 - run: | - cd standalone # run composer require rector/rector:dev-main --dev --ansi ${{ matrix.commands.install }} + working-directory: standalone - - run: | - cd standalone - ${{ matrix.commands.run }} + run: vendor/bin/rector list --ansi + working-directory: standalone diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 6a59a1d8e5d..b0cd9010e7a 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -1,3 +1,6 @@ +# This workflow runs system tests: Use the Rector application from the source +# checkout to process "fixture" projects in tests/system-tests +# to see if those can be processed successfully name: End to End tests on: @@ -12,39 +15,28 @@ jobs: strategy: fail-fast: false matrix: - php: ['7.4', '8.0'] + php_version: ['7.1', '7.2', '7.3', '7.4', '8.0'] + directory: + - 'e2e/attributes' + - 'e2e/dont-execute-code' + - 'e2e/finalize' + - 'e2e/parse-php7-code' + - 'e2e/parse-php8-code' + + name: End to end test - ${{ matrix.directory }} - name: PHP ${{ matrix.php }} system tests steps: - uses: actions/checkout@v2 - uses: shivammathur/setup-php@v2 with: - php-version: ${{ matrix.php }} - coverage: none # disable xdebug, pcov + php-version: ${{ matrix.php_version }} + coverage: none - # This workflow runs system tests: Use the Rector application from the source - # checkout to process "fixture" projects in tests/system-tests - # to see if those can be processed successfully + - + run: composer install --ansi + working-directory: ${{ matrix.directory }} - - name: Generate Composer autoloaders in fixture directories - run: | - for FIXTURE in `find e2e -mindepth 1 -maxdepth 1 -type d`; do - (cd $FIXTURE; composer install --no-progress --ansi) - done - - - name: Run system tests - run: | - HAS_FAILURES=0 - - for FIXTURE in `find e2e -mindepth 1 -maxdepth 1 -type d`; do - echo "-----> Running $FIXTURE <-----" - if (cd $FIXTURE; ../../bin/rector process --dry-run --clear-cache); then - echo "-----> Result: OK <-----" - else - echo "-----> Result: FAILED <-----" - HAS_FAILURES=1 - fi - done - - exit $HAS_FAILURES + - + run: ../../bin/rector process --dry-run --ansi + working-directory: ${{ matrix.directory }} diff --git a/.github/workflows/php8_attributes.yaml b/.github/workflows/php8_attributes.yaml deleted file mode 100644 index 4132adfa0f0..00000000000 --- a/.github/workflows/php8_attributes.yaml +++ /dev/null @@ -1,21 +0,0 @@ -name: PHP 8 Attributes - -on: - pull_request: null - push: - branches: - - main - -jobs: - php8_attributes: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - - uses: shivammathur/setup-php@v2 - with: - php-version: '8.0' - coverage: none - - - run: bin/rector process tests/fixture-php8-attributes --config ci/rector-attributes.php --ansi diff --git a/.github/workflows/php_parser_3.yaml b/.github/workflows/php_parser_3.yaml deleted file mode 100644 index 58c20db43e1..00000000000 --- a/.github/workflows/php_parser_3.yaml +++ /dev/null @@ -1,25 +0,0 @@ -name: PHP Parser 3 - -on: - pull_request: null - push: - branches: - - main - -jobs: - php_parser_3: - runs-on: ubuntu-latest - - steps: - - - uses: shivammathur/setup-php@v2 - with: - php-version: 7.1 - coverage: none - - # wait for deploy to packagist - - run: sleep 70 - - - run: composer require nikic/php-parser:^3.1 --ansi - - run: composer require rector/rector:dev-main --dev --ansi - - run: vendor/bin/rector list --ansi diff --git a/e2e/attributes/composer.json b/e2e/attributes/composer.json new file mode 100644 index 00000000000..a8d803fa520 --- /dev/null +++ b/e2e/attributes/composer.json @@ -0,0 +1,5 @@ +{ + "autoload-dev": { + "directories": ["stubs"] + } +} diff --git a/e2e/attributes/rector.php b/e2e/attributes/rector.php new file mode 100644 index 00000000000..f2ea9e04f5d --- /dev/null +++ b/e2e/attributes/rector.php @@ -0,0 +1,16 @@ +import(SymfonySetList::SYMFONY_52); + + $parameters = $containerConfigurator->parameters(); + $parameters->set(Option::PHP_VERSION_FEATURES, PhpVersion::PHP_80); + $parameters->set(Option::SOURCE, [__DIR__ . '/src']); +}; diff --git a/e2e/attributes/src/route.php b/e2e/attributes/src/route.php new file mode 100644 index 00000000000..f951959c055 --- /dev/null +++ b/e2e/attributes/src/route.php @@ -0,0 +1,13 @@ + $value) { + $method = 'set'.str_replace('_', '', $key); + if (!method_exists($this, $method)) { + throw new \BadMethodCallException(sprintf('Unknown property "%s" on annotation "%s".', $key, \get_class($this))); + } + $this->$method($value); + } + } + + public function setPath($path) + { + $this->path = $path; + } + + public function getPath() + { + return $this->path; + } + + public function setLocalizedPaths(array $localizedPaths) + { + $this->localizedPaths = $localizedPaths; + } + + public function getLocalizedPaths(): array + { + return $this->localizedPaths; + } + + public function setHost($pattern) + { + $this->host = $pattern; + } + + public function getHost() + { + return $this->host; + } + + public function setName($name) + { + $this->name = $name; + } + + public function getName() + { + return $this->name; + } + + public function setRequirements($requirements) + { + $this->requirements = $requirements; + } + + public function getRequirements() + { + return $this->requirements; + } + + public function setOptions($options) + { + $this->options = $options; + } + + public function getOptions() + { + return $this->options; + } + + public function setDefaults($defaults) + { + $this->defaults = $defaults; + } + + public function getDefaults() + { + return $this->defaults; + } + + public function setSchemes($schemes) + { + $this->schemes = \is_array($schemes) ? $schemes : [$schemes]; + } + + public function getSchemes() + { + return $this->schemes; + } + + public function setMethods($methods) + { + $this->methods = \is_array($methods) ? $methods : [$methods]; + } + + public function getMethods() + { + return $this->methods; + } + + public function setCondition($condition) + { + $this->condition = $condition; + } + + public function getCondition() + { + return $this->condition; + } +} diff --git a/e2e/finalize/composer.json b/e2e/finalize/composer.json new file mode 100644 index 00000000000..cebce1733e6 --- /dev/null +++ b/e2e/finalize/composer.json @@ -0,0 +1,10 @@ +{ + "autoload": { + "psr-4": { + "Rector\\e2e\\": "src" + } + }, + "require-dev": { + "doctrine/orm": "^2.7" + } +} diff --git a/e2e/finalize/rector.php b/e2e/finalize/rector.php new file mode 100644 index 00000000000..290907417b1 --- /dev/null +++ b/e2e/finalize/rector.php @@ -0,0 +1,11 @@ +services(); + $services->set(FinalizeClassesWithoutChildrenRector::class); +}; diff --git a/e2e/finalize/src/SkipSomeEntity.php b/e2e/finalize/src/SkipSomeEntity.php new file mode 100644 index 00000000000..11baf123bec --- /dev/null +++ b/e2e/finalize/src/SkipSomeEntity.php @@ -0,0 +1,14 @@ +parameters(); + $parameters->set(Option::PATHS, [__DIR__.'/src']); + + $containerConfigurator->import(SetList::PHP_53); +}; diff --git a/e2e/parse-php8-code/src/Foo.php b/e2e/parse-php8-code/src/Foo.php new file mode 100644 index 00000000000..5e0a9146264 --- /dev/null +++ b/e2e/parse-php8-code/src/Foo.php @@ -0,0 +1,10 @@ += 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); if ($useStaticLoader) { require __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticInit7195c74efd61d60849353b7e230e5264::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticInitdb1c54988d45f3f5809e48373d975091::getInitializer($loader)); } else { $classMap = require __DIR__ . '/autoload_classmap.php'; if ($classMap) { @@ -42,19 +42,19 @@ class ComposerAutoloaderInit7195c74efd61d60849353b7e230e5264 $loader->register(true); if ($useStaticLoader) { - $includeFiles = Composer\Autoload\ComposerStaticInit7195c74efd61d60849353b7e230e5264::$files; + $includeFiles = Composer\Autoload\ComposerStaticInitdb1c54988d45f3f5809e48373d975091::$files; } else { $includeFiles = require __DIR__ . '/autoload_files.php'; } foreach ($includeFiles as $fileIdentifier => $file) { - composerRequire7195c74efd61d60849353b7e230e5264($fileIdentifier, $file); + composerRequiredb1c54988d45f3f5809e48373d975091($fileIdentifier, $file); } return $loader; } } -function composerRequire7195c74efd61d60849353b7e230e5264($fileIdentifier, $file) +function composerRequiredb1c54988d45f3f5809e48373d975091($fileIdentifier, $file) { if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { require $file; diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index c566f80f35f..c3e9aab0300 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -4,7 +4,7 @@ namespace Composer\Autoload; -class ComposerStaticInit7195c74efd61d60849353b7e230e5264 +class ComposerStaticInitdb1c54988d45f3f5809e48373d975091 { public static $files = array ( 'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php', @@ -3465,9 +3465,9 @@ class ComposerStaticInit7195c74efd61d60849353b7e230e5264 public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInit7195c74efd61d60849353b7e230e5264::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInit7195c74efd61d60849353b7e230e5264::$prefixDirsPsr4; - $loader->classMap = ComposerStaticInit7195c74efd61d60849353b7e230e5264::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInitdb1c54988d45f3f5809e48373d975091::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInitdb1c54988d45f3f5809e48373d975091::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInitdb1c54988d45f3f5809e48373d975091::$classMap; }, null, ClassLoader::class); } diff --git a/vendor/scoper-autoload.php b/vendor/scoper-autoload.php index 95b3b50b960..3b10e517c29 100644 --- a/vendor/scoper-autoload.php +++ b/vendor/scoper-autoload.php @@ -21,8 +21,8 @@ if (!class_exists('SomeTestCase', false) && !interface_exists('SomeTestCase', fa if (!class_exists('CheckoutEntityFactory', false) && !interface_exists('CheckoutEntityFactory', false) && !trait_exists('CheckoutEntityFactory', false)) { spl_autoload_call('RectorPrefix20210511\CheckoutEntityFactory'); } -if (!class_exists('ComposerAutoloaderInit7195c74efd61d60849353b7e230e5264', false) && !interface_exists('ComposerAutoloaderInit7195c74efd61d60849353b7e230e5264', false) && !trait_exists('ComposerAutoloaderInit7195c74efd61d60849353b7e230e5264', false)) { - spl_autoload_call('RectorPrefix20210511\ComposerAutoloaderInit7195c74efd61d60849353b7e230e5264'); +if (!class_exists('ComposerAutoloaderInitdb1c54988d45f3f5809e48373d975091', false) && !interface_exists('ComposerAutoloaderInitdb1c54988d45f3f5809e48373d975091', false) && !trait_exists('ComposerAutoloaderInitdb1c54988d45f3f5809e48373d975091', false)) { + spl_autoload_call('RectorPrefix20210511\ComposerAutoloaderInitdb1c54988d45f3f5809e48373d975091'); } if (!class_exists('Doctrine\Inflector\Inflector', false) && !interface_exists('Doctrine\Inflector\Inflector', false) && !trait_exists('Doctrine\Inflector\Inflector', false)) { spl_autoload_call('RectorPrefix20210511\Doctrine\Inflector\Inflector'); @@ -95,9 +95,9 @@ if (!function_exists('print_node')) { return \RectorPrefix20210511\print_node(...func_get_args()); } } -if (!function_exists('composerRequire7195c74efd61d60849353b7e230e5264')) { - function composerRequire7195c74efd61d60849353b7e230e5264() { - return \RectorPrefix20210511\composerRequire7195c74efd61d60849353b7e230e5264(...func_get_args()); +if (!function_exists('composerRequiredb1c54988d45f3f5809e48373d975091')) { + function composerRequiredb1c54988d45f3f5809e48373d975091() { + return \RectorPrefix20210511\composerRequiredb1c54988d45f3f5809e48373d975091(...func_get_args()); } } if (!function_exists('parseArgs')) {