diff --git a/.github/workflows/checksum-phar.yml b/.github/workflows/checksum-phar.yml index a7e4238343..8c384727cc 100644 --- a/.github/workflows/checksum-phar.yml +++ b/.github/workflows/checksum-phar.yml @@ -80,7 +80,7 @@ jobs: uses: "shivammathur/setup-php@v2" with: coverage: "none" - php-version: "8.1" + php-version: "8.2" extensions: mbstring, intl - name: "Install dependencies" diff --git a/.github/workflows/phar.yml b/.github/workflows/phar.yml index ef0f975e49..542463f7e3 100644 --- a/.github/workflows/phar.yml +++ b/.github/workflows/phar.yml @@ -34,7 +34,7 @@ jobs: uses: "shivammathur/setup-php@v2" with: coverage: "none" - php-version: "8.1" + php-version: "8.2" extensions: mbstring, intl - name: "Install dependencies" diff --git a/bin/phpstan b/bin/phpstan index 537f3e123d..c07b8fcc16 100755 --- a/bin/phpstan +++ b/bin/phpstan @@ -35,50 +35,6 @@ use Symfony\Component\Console\Helper\ProgressBar; } $devOrPharLoader->unregister(); - $composerAutoloadFiles = $GLOBALS['__composer_autoload_files']; - if ( - !array_key_exists('e88992873b7765f9b5710cab95ba5dd7', $composerAutoloadFiles) - || !array_key_exists('3e76f7f02b41af8cea96018933f6b7e3', $composerAutoloadFiles) - || !array_key_exists('a4a119a56e50fbb293281d9a48007e0e', $composerAutoloadFiles) - || !array_key_exists('0e6d7bf4a5811bfa5cf40c5ccd6fae6a', $composerAutoloadFiles) - || !array_key_exists('e69f7f6ee287b969198c3c9d6777bd38', $composerAutoloadFiles) - || !array_key_exists('0d59ee240a4cd96ddbb4ff164fccea4d', $composerAutoloadFiles) - || !array_key_exists('b686b8e46447868025a15ce5d0cb2634', $composerAutoloadFiles) - || !array_key_exists('8825ede83f2f289127722d4e842cf7e8', $composerAutoloadFiles) - || !array_key_exists('23c18046f52bef3eea034657bafda50f', $composerAutoloadFiles) - ) { - echo "Composer autoloader changed\n"; - exit(1); - } - - // empty the global variable so that unprefixed functions from user-space can be loaded - $GLOBALS['__composer_autoload_files'] = [ - // fix unprefixed Hoa namespace - files already loaded - 'e88992873b7765f9b5710cab95ba5dd7' => true, - '3e76f7f02b41af8cea96018933f6b7e3' => true, - - // vendor/symfony/polyfill-php80/bootstrap.php - 'a4a119a56e50fbb293281d9a48007e0e' => true, - - // vendor/symfony/polyfill-mbstring/bootstrap.php - '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => true, - - // vendor/symfony/polyfill-intl-normalizer/bootstrap.php - 'e69f7f6ee287b969198c3c9d6777bd38' => true, - - // vendor/symfony/polyfill-php73/bootstrap.php - '0d59ee240a4cd96ddbb4ff164fccea4d' => true, - - // vendor/symfony/polyfill-php74/bootstrap.php - 'b686b8e46447868025a15ce5d0cb2634' => true, - - // vendor/symfony/polyfill-intl-grapheme/bootstrap.php - '8825ede83f2f289127722d4e842cf7e8' => true, - - // vendor/symfony/polyfill-php81/bootstrap.php - '23c18046f52bef3eea034657bafda50f' => true, - ]; - $autoloaderInWorkingDirectory = $vendorDirectory . '/autoload.php'; $composerAutoloaderProjectPaths = []; diff --git a/compiler/build/box.phar b/compiler/build/box.phar old mode 100755 new mode 100644 index 402ceabdc4..791f949890 Binary files a/compiler/build/box.phar and b/compiler/build/box.phar differ diff --git a/compiler/build/scoper.inc.php b/compiler/build/scoper.inc.php index 0ea6df31ec..edaad06db0 100644 --- a/compiler/build/scoper.inc.php +++ b/compiler/build/scoper.inc.php @@ -8,6 +8,7 @@ '../../resources/functionMap_php80delta.php', '../../resources/functionMetadata.php', '../../vendor/hoa/consistency/Prelude.php', + '../../vendor/hoa/protocol/Wrapper.php', '../../vendor/composer/InstalledVersions.php', '../../vendor/composer/installed.php', ]; @@ -16,13 +17,13 @@ '../../stubs', '../../vendor/jetbrains/phpstorm-stubs', '../../vendor/phpstan/php-8-stubs/stubs', - '../../vendor/symfony/polyfill-php80', - '../../vendor/symfony/polyfill-php81', - '../../vendor/symfony/polyfill-mbstring', - '../../vendor/symfony/polyfill-intl-normalizer', - '../../vendor/symfony/polyfill-php73', - '../../vendor/symfony/polyfill-php74', - '../../vendor/symfony/polyfill-intl-grapheme', +// '../../vendor/symfony/polyfill-php80', +// '../../vendor/symfony/polyfill-php81', +// '../../vendor/symfony/polyfill-mbstring', +// '../../vendor/symfony/polyfill-intl-normalizer', +// '../../vendor/symfony/polyfill-php73', +// '../../vendor/symfony/polyfill-php74', +// '../../vendor/symfony/polyfill-intl-grapheme', ]) as $file) { if ($file->getPathName() === '../../vendor/jetbrains/phpstorm-stubs/PhpStormStubsMap.php') { continue; @@ -218,19 +219,41 @@ function (string $filePath, string $prefix, string $content): string { return str_replace(sprintf('use %s\\PhpParser;', $prefix), 'use PhpParser;', $content); }, + // Patch to mimic the expected solution result for https://github.com/humbug/php-scoper/issues/963 + function (string $filePath, string $prefix, string $content): string { + return preg_replace_callback( + '/if \(\s*!\s*\\\?function_exists\(\'\\\?(?.+)\'\)\)[\s\n]{/', + static function(array $matches) use ($prefix): string { + $matchedElement = $matches[0]; + $functionFqn = $matches['functionFQN']; + + if (str_starts_with($functionFqn, $prefix)) { + return $matchedElement; + } + + return sprintf( + 'if (!function_exists(\'%1$s\') && !function_exists(\'%2$s\%1$s\')) {', + $functionFqn, + $prefix, + ); + }, + $content, + -1 + ); + }, ], 'exclude-namespaces' => [ 'PHPStan', 'PHPUnit', 'PhpParser', 'Hoa', - 'Symfony\Polyfill\Php80', - 'Symfony\Polyfill\Php81', - 'Symfony\Polyfill\Mbstring', - 'Symfony\Polyfill\Intl\Normalizer', - 'Symfony\Polyfill\Php73', - 'Symfony\Polyfill\Php74', - 'Symfony\Polyfill\Intl\Grapheme', +// 'Symfony\Polyfill\Php80', +// 'Symfony\Polyfill\Php81', +// 'Symfony\Polyfill\Mbstring', +// 'Symfony\Polyfill\Intl\Normalizer', +// 'Symfony\Polyfill\Php73', +// 'Symfony\Polyfill\Php74', +// 'Symfony\Polyfill\Intl\Grapheme', ], 'expose-global-functions' => false, 'expose-global-classes' => false,