Skip to content

PHP-Scoper does not work with PHP 8.5 #1139

Closed

Description

@sebastianbergmann

Yesterday, we discovered that recent releases of PHPUnit's PHAR are not scoped.

Release PHARs of PHPUnit are (still) built by me on my machine using the most recent stable version of PHP. It looks like all PHAR releases I created since I switched to PHP 8.5 were not scoped because PHP-Scoper does not work with PHP 8.5.

However, due to #1138 I did not see that the scoping did not work.

When I use the -vv CLI option I see why:

[php-scoper]  * [NO] /usr/local/src/phpunit/build/tmp/phar/theseer-tokenizer/Tokenizer.php
[php-scoper] 	Could not parse the file "/usr/local/src/phpunit/build/tmp/phar/theseer-tokenizer/Tokenizer.php".: ErrorException: Method SplObjectStorage::attach() is deprecated since 8.5, use method SplObjectStorage::offsetSet() instead in phar:///usr/local/src/phpunit/tools/php-scoper/vendor/nikic/php-parser/lib/PhpParser/Parser/Php8.php:1123
[php-scoper] Stack trace:
[php-scoper] #0 phar:///usr/local/src/phpunit/tools/php-scoper/vendor/nikic/php-parser/lib/PhpParser/Parser/Php8.php(1123): {closure:phar:///usr/local/src/phpunit/tools/php-scoper/bin/php-scoper:27}()
[php-scoper] #1 phar:///usr/local/src/phpunit/tools/php-scoper/vendor/nikic/php-parser/lib/PhpParser/ParserAbstract.php(167): _HumbugBox2acd6fc30c41\PhpParser\Parser\Php8::{closure:_HumbugBox2acd6fc30c41\PhpParser\Parser\Php8::initReduceCallbacks():1121}()
[php-scoper] #2 phar:///usr/local/src/phpunit/tools/php-scoper/vendor/nikic/php-parser/lib/PhpParser/ParserAbstract.php(85): _HumbugBox2acd6fc30c41\PhpParser\ParserAbstract->doParse()
[php-scoper] #3 phar:///usr/local/src/phpunit/tools/php-scoper/src/Scoper/PhpScoper.php(37): _HumbugBox2acd6fc30c41\PhpParser\ParserAbstract->parse()
[php-scoper] #4 phar:///usr/local/src/phpunit/tools/php-scoper/src/Scoper/PhpScoper.php(30): _HumbugBox2acd6fc30c41\Humbug\PhpScoper\Scoper\PhpScoper->scopePhp()
[php-scoper] #5 phar:///usr/local/src/phpunit/tools/php-scoper/src/Scoper/PatchScoper.php(15): _HumbugBox2acd6fc30c41\Humbug\PhpScoper\Scoper\PhpScoper->scope()
[php-scoper] #6 phar:///usr/local/src/phpunit/tools/php-scoper/src/Console/ConsoleScoper.php(136): _HumbugBox2acd6fc30c41\Humbug\PhpScoper\Scoper\PatchScoper->scope()
[php-scoper] #7 phar:///usr/local/src/phpunit/tools/php-scoper/src/Console/ConsoleScoper.php(82): _HumbugBox2acd6fc30c41\Humbug\PhpScoper\Console\ConsoleScoper->scopeFile()
[php-scoper] #8 phar:///usr/local/src/phpunit/tools/php-scoper/src/Console/ConsoleScoper.php(56): _HumbugBox2acd6fc30c41\Humbug\PhpScoper\Console\ConsoleScoper->scopeFiles()
[php-scoper] #9 phar:///usr/local/src/phpunit/tools/php-scoper/src/Console/ConsoleScoper.php(43): _HumbugBox2acd6fc30c41\Humbug\PhpScoper\Console\ConsoleScoper->doScope()
[php-scoper] #10 phar:///usr/local/src/phpunit/tools/php-scoper/src/Console/Command/AddPrefixCommand.php(63): _HumbugBox2acd6fc30c41\Humbug\PhpScoper\Console\ConsoleScoper->scope()
[php-scoper] #11 phar:///usr/local/src/phpunit/tools/php-scoper/vendor/fidry/console/src/Bridge/Command/SymfonyCommand.php(69): _HumbugBox2acd6fc30c41\Humbug\PhpScoper\Console\Command\AddPrefixCommand->execute()
[php-scoper] #12 phar:///usr/local/src/phpunit/tools/php-scoper/vendor/symfony/console/Command/Command.php(151): _HumbugBox2acd6fc30c41\Fidry\Console\Bridge\Command\SymfonyCommand->execute()
[php-scoper] #13 phar:///usr/local/src/phpunit/tools/php-scoper/vendor/symfony/console/Application.php(720): _HumbugBox2acd6fc30c41\Symfony\Component\Console\Command\Command->run()
[php-scoper] #14 phar:///usr/local/src/phpunit/tools/php-scoper/vendor/symfony/console/Application.php(243): _HumbugBox2acd6fc30c41\Symfony\Component\Console\Application->doRunCommand()
[php-scoper] #15 phar:///usr/local/src/phpunit/tools/php-scoper/vendor/symfony/console/Application.php(136): _HumbugBox2acd6fc30c41\Symfony\Component\Console\Application->doRun()
[php-scoper] #16 phar:///usr/local/src/phpunit/tools/php-scoper/vendor/fidry/console/src/Application/ApplicationRunner.php(39): _HumbugBox2acd6fc30c41\Symfony\Component\Console\Application->run()
[php-scoper] #17 phar:///usr/local/src/phpunit/tools/php-scoper/vendor/fidry/console/src/Application/ApplicationRunner.php(28): _HumbugBox2acd6fc30c41\Fidry\Console\Application\ApplicationRunner->run()
[php-scoper] #18 phar:///usr/local/src/phpunit/tools/php-scoper/bin/php-scoper(49): _HumbugBox2acd6fc30c41\Fidry\Console\Application\ApplicationRunner::runApplication()
[php-scoper] #19 /usr/local/src/phpunit/tools/php-scoper(20): require('...')
[php-scoper] #20 {main}

This appears to be another issue (like #1092 was) with PHP-Scoper's error handler turning E_DEPRECATED issues into exceptions. Only this time, due to #1138, we do not see the crash unless we use -vv.

Activity

  1. sebastianbergmann commented on Dec 2, 2025

    @sebastianbergmann
    ContributorAuthor

    My suggestions would be:

    • Do not fail silently (topic of Patcher fatals silently ignored #1138)
    • Do not turn E_DEPRECATED issues into exceptions
    • Bail out on startup when PHP-Scoper is used with a PHP version that is not yet supported
  2. davidbarratt commented on Jan 3, 2026

    @davidbarratt

    It would be really helpful for us if the composer.json was updated to not declare that PHP 8.5 is supported when in reality it silently fails.

  3. theofidry commented on Jan 3, 2026

    @theofidry
    Member

    That ship has sailed unfortunately. And I tend to not be too strict on the PHP requirements unless absolutely needed because it's an additional maintenance burden and break on adoption when new versions are out. I appreciate it's not a universally shared opinion, but it is what it is.

    This one is particularly annoying though I'll get to it next week.

  4. marcelklehr commented on Feb 12, 2026

    @marcelklehr

    @theofidry Looking forward to your fix, whenever you get to it 💙

  5. swissspidy commented on Feb 18, 2026

    @swissspidy

    There's also Using null as an array offset is deprecated, use an empty string instead here:

  6. theofidry commented on Feb 21, 2026

    @theofidry
    Member

    Hmm the last one seems to be an issue from PHP-Parser and either I missed an update or it's still there.

    I'll diable the throwing exceptions on deprecations to get by it.

  7. theofidry commented on Mar 2, 2026

    @theofidry
    Member
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions