-
-
Notifications
You must be signed in to change notification settings - Fork 75
Unexpected parsing scenario #1111
Copy link
Copy link
Closed
Labels
Description
Bug report
| Question | Answer |
|---|---|
| PHP-Scoper version | 0.18.16 |
| PHP version | 8.3.6 |
| Platform with version | Fedora 40 |
Hi,
I just met a PhpParser\UnexpectedParsingScenario exception and was kindly asked to report it, so here I am ;-)
Here is a test case to reproduce, with the default generated scoper.inc.php :
testclass.php
<?php
namespace Foo;
class Bar {
protected static $class = '\\Foo\\Baz';
public function test()
{
return new static::$class('abc');
}
}PhpScoper output and stack trace :
$ ./vendor/bin/php-scoper -vvv inspect testclass.php
Using the configuration file "/tmp/test/scoper.inc.php".
In UnexpectedParsingScenario.php line 23:
[Humbug\PhpScoper\PhpParser\UnexpectedParsingScenario]
Unexpected case. Please report it.
Exception trace:
at /tmp/test/vendor/humbug/php-scoper/src/PhpParser/UnexpectedParsingScenario.php:23
Humbug\PhpScoper\PhpParser\UnexpectedParsingScenario::create() at /tmp/test/vendor/humbug/php-scoper/src/PhpParser/NodeVisitor/StringScalarPrefixer.php:216
Humbug\PhpScoper\PhpParser\NodeVisitor\StringScalarPrefixer->prefixNewStringArg() at /tmp/test/vendor/humbug/php-scoper/src/PhpParser/NodeVisitor/StringScalarPrefixer.php:195
Humbug\PhpScoper\PhpParser\NodeVisitor\StringScalarPrefixer->prefixStringArg() at /tmp/test/vendor/humbug/php-scoper/src/PhpParser/NodeVisitor/StringScalarPrefixer.php:166
Humbug\PhpScoper\PhpParser\NodeVisitor\StringScalarPrefixer->prefixStringScalar() at /tmp/test/vendor/humbug/php-scoper/src/PhpParser/NodeVisitor/StringScalarPrefixer.php:135
Humbug\PhpScoper\PhpParser\NodeVisitor\StringScalarPrefixer->enterNode() at /tmp/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:114
PhpParser\NodeTraverser->traverseNode() at /tmp/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:227
PhpParser\NodeTraverser->traverseArray() at /tmp/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:98
PhpParser\NodeTraverser->traverseNode() at /tmp/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:139
PhpParser\NodeTraverser->traverseNode() at /tmp/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:227
PhpParser\NodeTraverser->traverseArray() at /tmp/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:98
PhpParser\NodeTraverser->traverseNode() at /tmp/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:227
PhpParser\NodeTraverser->traverseArray() at /tmp/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:98
PhpParser\NodeTraverser->traverseNode() at /tmp/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:227
PhpParser\NodeTraverser->traverseArray() at /tmp/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:98
PhpParser\NodeTraverser->traverseNode() at /tmp/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:227
PhpParser\NodeTraverser->traverseArray() at /tmp/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:76
PhpParser\NodeTraverser->traverse() at /tmp/test/vendor/humbug/php-scoper/src/PhpParser/NodeTraverser.php:59
Humbug\PhpScoper\PhpParser\NodeTraverser->traverse() at /tmp/test/vendor/humbug/php-scoper/src/Scoper/PhpScoper.php:65
Humbug\PhpScoper\Scoper\PhpScoper->scopePhp() at /tmp/test/vendor/humbug/php-scoper/src/Scoper/PhpScoper.php:52
Humbug\PhpScoper\Scoper\PhpScoper->scope() at /tmp/test/vendor/humbug/php-scoper/src/Scoper/PatchScoper.php:34
Humbug\PhpScoper\Scoper\PatchScoper->scope() at /tmp/test/vendor/humbug/php-scoper/src/Console/Command/InspectCommand.php:215
Humbug\PhpScoper\Console\Command\InspectCommand->scopeFile() at /tmp/test/vendor/humbug/php-scoper/src/Console/Command/InspectCommand.php:127
Humbug\PhpScoper\Console\Command\InspectCommand->execute() at /tmp/test/vendor/fidry/console/src/Bridge/Command/SymfonyCommand.php:103
Fidry\Console\Bridge\Command\SymfonyCommand->execute() at /tmp/test/vendor/symfony/console/Command/Command.php:279
Symfony\Component\Console\Command\Command->run() at /tmp/test/vendor/symfony/console/Application.php:1076
Symfony\Component\Console\Application->doRunCommand() at /tmp/test/vendor/symfony/console/Application.php:342
Symfony\Component\Console\Application->doRun() at /tmp/test/vendor/symfony/console/Application.php:193
Symfony\Component\Console\Application->run() at /tmp/test/vendor/fidry/console/src/Application/ApplicationRunner.php:83
Fidry\Console\Application\ApplicationRunner->run() at /tmp/test/vendor/fidry/console/src/Application/ApplicationRunner.php:62
Fidry\Console\Application\ApplicationRunner::runApplication() at /tmp/test/vendor/humbug/php-scoper/bin/php-scoper:64
include() at /tmp/test/vendor/bin/php-scoper:119
inspect [-d|--working-dir WORKING-DIR] [-p|--prefix PREFIX] [-c|--config CONFIG] [--no-config] [--php-version PHP-VERSION] [--] <file-path>
If the test case is changed to the following :
<?php
namespace Foo;
class Bar {
protected static $class = '\\Foo\\Baz';
public function test()
{
return new static::$class('');
}
}then it works just fine.
The initial issue was found in the PhpXmlRpc package, specifically this class
Reactions are currently unavailable