bobthecow/psysh

`_HumbugBox235824e31c05\PhpParser\Node\Scalar\LNumber` not found when using `require`

Closed this issue · 1 comments

When I try to use require or require_once with PsySH, I get the error _HumbugBox235824e31c05\PhpParser\Node\Scalar\LNumber not found, as shown below:

$ psysh --verbose 
Psy Shell v0.12.4 (PHP 8.3.8 — cli) by Justin Hileman
> require_once 'vendor/autoload.php'

   Error  Class "_HumbugBox235824e31c05\PhpParser\Node\Scalar\LNumber" not found.

--
 () at phar:///Users/supriyo/.bin/psysh/src/CodeCleaner/RequirePass.php:22
 Psy\CodeCleaner\RequirePass->enterNode() at phar:///Users/supriyo/.bin/psysh/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:59
 _HumbugBox235824e31c05\PhpParser\NodeTraverser->traverseNode() at phar:///Users/supriyo/.bin/psysh/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:144
 _HumbugBox235824e31c05\PhpParser\NodeTraverser->traverseArray() at phar:///Users/supriyo/.bin/psysh/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:37
 _HumbugBox235824e31c05\PhpParser\NodeTraverser->traverse() at phar:///Users/supriyo/.bin/psysh/src/CodeCleaner.php:118
 Psy\CodeCleaner->clean() at phar:///Users/supriyo/.bin/psysh/src/Shell.php:410
 Psy\Shell->addCode() at phar:///Users/supriyo/.bin/psysh/src/Shell.php:264
 Psy\Shell->getInput() at phar:///Users/supriyo/.bin/psysh/src/ExecutionLoopClosure.php:16
 Psy\{closure}() at phar:///Users/supriyo/.bin/psysh/src/ExecutionClosure.php:42
 Psy\ExecutionClosure->execute() at phar:///Users/supriyo/.bin/psysh/src/Shell.php:183
 Psy\Shell->doInteractiveRun() at phar:///Users/supriyo/.bin/psysh/src/Shell.php:167
 Psy\Shell->doRun() at phar:///Users/supriyo/.bin/psysh/vendor/symfony/console/Application.php:124
 _HumbugBox235824e31c05\Symfony\Component\Console\Application->run() at phar:///Users/supriyo/.bin/psysh/src/Shell.php:156
 Psy\Shell->run() at phar:///Users/supriyo/.bin/psysh/src/functions.php:258
 Psy\{closure}() at /Users/supriyo/.bin/psysh:155

However, when I use include, it works:

psysh --verbose
Psy Shell v0.12.4 (PHP 8.3.8 — cli) by Justin Hileman
> include 'vendor/autoload.php';
= Composer\Autoload\ClassLoader {#3935}

In all of these cases, PsySH is being run from the phar as opposed to being run from a composer installation.

Thanks! I've got a fix for this (and a couple of other unreported but related issues) going into the next stable release.