diff --git a/.github/workflows/build_scoped_rector_php70.yaml b/.github/workflows/build_scoped_rector_php70.yaml index d7ee50d614d1..dd078f27dbca 100644 --- a/.github/workflows/build_scoped_rector_php70.yaml +++ b/.github/workflows/build_scoped_rector_php70.yaml @@ -47,10 +47,7 @@ jobs: # the vendor/phpstan/phpstan/bootstrap.php is statically included by composer, so better add empty file - run: echo " vendor/phpstan/phpstan/bootstrap.php - run: rm -rf vendor/phpstan/phpstan/phpstan.phar - - run: rm phpstan-for-rector.neon - - # THIS MUST WORK - - run: bin/rector downgrade-paths + - run: rm -rf phpstan-for-rector.neon # 1. copy files to $NESTED_DIRECTORY directory Exclude the scoped/nested directories to prevent rsync from copying in a loop - run: rsync --exclude rector-build-php70 -av * rector-build-php70 --quiet @@ -72,8 +69,9 @@ jobs: php-version: 7.0 coverage: none - run: | - cp -R rector-prefixed-downgraded-php70/vendor/rector/* vendor/rector/ - cp -R rector-prefixed-downgraded-php70/vendor/symfony/string/* vendor/symfony/string/ + rm -rf vendor && mkdir -p vendor + cp -R rector-prefixed-downgraded-php70/vendor/* vendor/ + rm -rf php-parallel-lint composer create-project php-parallel-lint/php-parallel-lint php-parallel-lint --ansi - run: php-parallel-lint/parallel-lint rector-prefixed-downgraded-php70 --exclude rector-prefixed-downgraded-php70/stubs --exclude rector-prefixed-downgraded-php70/vendor/symfony/error-handler/Resources --exclude rector-prefixed-downgraded-php70/vendor/symfony/http-kernel/Resources --exclude rector-prefixed-downgraded-php70/vendor/rector/rector-nette/tests --exclude rector-prefixed-downgraded-php70/vendor/symfony/polyfill-mbstring/bootstrap80.php --exclude rector-prefixed-downgraded-php70/vendor/tracy/tracy/examples --exclude rector-prefixed-downgraded-php70/vendor/rector/rector-installer/tests --exclude rector-prefixed-downgraded-php70/vendor/symplify/smart-file-system/tests --exclude rector-prefixed-downgraded-php70/vendor/symfony/http-foundation/Session --exclude rector-prefixed-downgraded-php70/vendor/symfony/var-dumper --exclude rector-prefixed-downgraded-php70/vendor/nette/caching --exclude rector-prefixed-downgraded-php70/vendor/rector/rector-nette/src/Rector/LNumber --exclude rector-prefixed-downgraded-php70/vendor/symfony/http-foundation/Test --exclude rector-prefixed-downgraded-php70/vendor/symplify/simple-php-doc-parser/tests --exclude rector-prefixed-downgraded-php70/vendor/tracy/tracy/src/Tracy/Bar/panels/info.panel.phtml --exclude rector-prefixed-downgraded-php70/vendor/symfony/string/Slugger/AsciiSlugger.php diff --git a/rules/DowngradePhp71/Rector/FunctionLike/DowngradeNullableTypeDeclarationRector.php b/rules/DowngradePhp71/Rector/FunctionLike/DowngradeNullableTypeDeclarationRector.php index 1be61f56b354..92eaf7ccbf28 100644 --- a/rules/DowngradePhp71/Rector/FunctionLike/DowngradeNullableTypeDeclarationRector.php +++ b/rules/DowngradePhp71/Rector/FunctionLike/DowngradeNullableTypeDeclarationRector.php @@ -118,7 +118,7 @@ private function isNullableParam(Param $param): bool } /** - * @param ClassMethod|Function_ $functionLike + * @param ClassMethod|Function_|Closure $functionLike */ private function refactorParamType(Param $param, FunctionLike $functionLike): bool { @@ -133,7 +133,7 @@ private function refactorParamType(Param $param, FunctionLike $functionLike): bo } /** - * @param ClassMethod|Function_ $functionLike + * @param ClassMethod|Function_|Closure $functionLike */ private function decorateWithDocBlock(FunctionLike $functionLike, Param $param): void { diff --git a/scoper-php70.php b/scoper-php70.php index 1e1dde8f3d75..f20f25a6872d 100644 --- a/scoper-php70.php +++ b/scoper-php70.php @@ -77,6 +77,28 @@ function (string $filePath, string $prefix, string $content): string { ); }, + function (string $filePath, string $prefix, string $content): string { + if (! Strings::contains($filePath, 'vendor/')) { + return $content; + } + + // see https://regex101.com/r/PDGN3K/1 + $content = Strings::replace( + $content, ' + #: \?\\\\.*#', + '' + ); + + // see https://regex101.com/r/P7nbpU/1 + $content = Strings::replace( + $content, ' + #\(\?\\.*\s+#', + '(' + ); + + return $content; + }, + // get version for prefixed version function (string $filePath, string $prefix, string $content): string { if (! Strings::endsWith($filePath, 'src/Configuration/Configuration.php')) { @@ -151,7 +173,7 @@ function (string $filePath, string $prefix, string $content): string { }, function (string $filePath, string $prefix, string $content): string { - if (! Strings::endsWith($filePath, 'vendor/symplify/autowire-array-parameter/src/Skipper/ParameterSkipper.php')) { + if (! Strings::contains($filePath, 'vendor/')) { return $content; } diff --git a/utils/compiler/src/Command/DowngradePathsCommand.php b/utils/compiler/src/Command/DowngradePathsCommand.php index 407a47ef1840..6c9655065dd8 100644 --- a/utils/compiler/src/Command/DowngradePathsCommand.php +++ b/utils/compiler/src/Command/DowngradePathsCommand.php @@ -34,6 +34,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int $downgradePaths = array_merge([ // must be separated to cover container get() trait + psr container contract get() 'config', + 'vendor/phpstan/phpdoc-parser/src', + 'vendor/symfony/error-handler', + 'vendor/symfony/dependency-injection', + 'vendor/symfony/console', 'vendor/symfony vendor/psr', 'vendor/symplify vendor/nikic bin src packages rector.php', 'rules', @@ -41,6 +45,18 @@ protected function execute(InputInterface $input, OutputInterface $output): int if (file_exists(getcwd() . '/vendor/phpstan/phpstan-extracted/vendor')) { $downgradePaths[] = 'vendor/phpstan/phpstan-extracted/vendor'; + $downgradePaths[] = 'vendor/phpstan/phpstan-extracted/src'; + $downgradePaths[] = 'vendor/phpstan/phpstan-extracted/vendor/phpstan/phpdoc-parser/src'; + $downgradePaths[] = 'vendor/phpstan/phpstan-extracted/vendor/ondrejmirtes/better-reflection/src'; + $downgradePaths[] = 'vendor/phpstan/phpstan-extracted/vendor/nette/di/src'; + $downgradePaths[] = 'vendor/phpstan/phpstan-extracted/vendor/nette/php-generator/src'; + $downgradePaths[] = 'vendor/phpstan/phpstan-extracted/vendor/nette/utils/src'; + $downgradePaths[] = 'vendor/phpstan/phpstan-extracted/vendor/nette/schema/src'; + $downgradePaths[] = 'vendor/phpstan/phpstan-extracted/vendor/nette/finder/src'; + $downgradePaths[] = 'vendor/phpstan/phpstan-extracted/vendor/nette/robot-loader/src'; + $downgradePaths[] = 'vendor/phpstan/phpstan-extracted/vendor/ondram/ci-detector/src'; + $downgradePaths[] = 'vendor/phpstan/phpstan-extracted/vendor/symfony/finder'; + $downgradePaths[] = 'vendor/phpstan/phpstan-extracted/vendor/symfony/console'; } // bash format