Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix "Unable to find type name" when creating closure #804

Merged
merged 1 commit into from
Jun 9, 2024

Conversation

AegirLeet
Copy link
Contributor

$ ./vendor/bin/psysh -vvv
Psy Shell v0.12.3 (PHP 8.3.7 — cli) by Justin Hileman
> $x = function(): DateTime { return new DateTime(); };

   InvalidArgumentException  Unable to find type name.

--
 () at vendor/psy/psysh/src/CodeCleaner/ReturnTypePass.php:111
 Psy\CodeCleaner\ReturnTypePass->typeName() at vendor/psy/psysh/src/CodeCleaner/ReturnTypePass.php:58
 Psy\CodeCleaner\ReturnTypePass->enterNode() at vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:200
 PhpParser\NodeTraverser->traverseArray() at vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:114
 PhpParser\NodeTraverser->traverseNode() at vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:146
 PhpParser\NodeTraverser->traverseNode() at vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:146
 PhpParser\NodeTraverser->traverseNode() at vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:223
 PhpParser\NodeTraverser->traverseArray() at vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:91
 PhpParser\NodeTraverser->traverse() at vendor/psy/psysh/src/CodeCleaner.php:268
 Psy\CodeCleaner->clean() at vendor/psy/psysh/src/Shell.php:848
 Psy\Shell->addCode() at vendor/psy/psysh/src/Shell.php:535
 Psy\Shell->getInput() at vendor/psy/psysh/src/ExecutionLoopClosure.php:37
 Psy\{closure}() at vendor/psy/psysh/src/ExecutionClosure.php:89
 Psy\ExecutionClosure->execute() at vendor/psy/psysh/src/Shell.php:383
 Psy\Shell->doInteractiveRun() at vendor/psy/psysh/src/Shell.php:354
 Psy\Shell->doRun() at vendor/symfony/console/Application.php:175
 Symfony\Component\Console\Application->run() at vendor/psy/psysh/src/Shell.php:329
 Psy\Shell->run() at vendor/psy/psysh/src/functions.php:466
 Psy\{closure}() at vendor/psy/psysh/bin/psysh:148
 include() at vendor/bin/psysh:119

@bobthecow bobthecow merged commit 99537fd into bobthecow:main Jun 9, 2024
27 checks passed
@bobthecow
Copy link
Owner

Thank you!

@AegirLeet
Copy link
Contributor Author

I just realized this only works on nikic/php-parser 5.x, but not 4.x. The 4.x branch doesn't have the Name::$name property. I'll open another PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants