scribe
scribe copied to clipboard
GetFromInlineValidatorBase::extractEnumClassFromArrayItem Argument #1 ($arrayItem) must be of type PhpParser\\Node\\ArrayItem, PhpParser\\Node\\Expr\\ArrayItem given
Scribe version
4.34.0
PHP version
8.1
Framework
Laravel
Framework version
10.46.0
Scribe config
------ SAME AS DEFAULT CONFIG ------
What happened?
I ran php artisan scribe:generate and then I get an error:
Knuckles\Scribe\Extracting\Strategies\GetFromInlineValidatorBase::extractEnumClassFromArrayItem(): Argument #1 ($arrayItem) must be of type PhpParser\Node\ArrayItem, PhpParser\Node\Expr\ArrayItem given, called in vendor/knuckleswtf/scribe/src/Extracting/Strategies/GetFromInlineValidatorBase.php on line 88
at vendor/knuckleswtf/scribe/src/Extracting/Strategies/GetFromInlineValidatorBase.php:127 123▕ 124▕ return [$rules, $customParameterData]; 125▕ } 126▕ ➜ 127▕ protected function extractEnumClassFromArrayItem(Node\ArrayItem $arrayItem): ?string 128▕ { 129▕ $args = []; 130▕ 131▕ // Enum rule with the form "new Enum(...)"
Docs
- [X] I've checked the docs, the troubleshooting guide, and existing issues, but I didn't find a solution
Hmm, that sounds like you're using an older version of nikic/php-parser, which shouldn't be happening. Can you try running composer show nikic/php-parser
?
$ composer show nikic/php-parser name : nikic/php-parser descrip. : A PHP parser written in PHP keywords : parser, php versions : * v5.0.1 type : library license : BSD 3-Clause "New" or "Revised" License (BSD-3-Clause) (OSI approved) https://spdx.org/licenses/BSD-3-Clause.html#licenseText homepage : source : [git] https://github.com/nikic/PHP-Parser.git 2218c2252c874a4624ab2f613d86ac32d227bc69 dist : [zip] https://api.github.com/repos/nikic/PHP-Parser/zipball/2218c2252c874a4624ab2f613d86ac32d227bc69 2218c2252c874a4624ab2f613d86ac32d227bc69 path : names : nikic/php-parser
support issues : https://github.com/nikic/PHP-Parser/issues source : https://github.com/nikic/PHP-Parser/tree/v5.0.1
autoload psr-4 PhpParser\ => lib/PhpParser
requires ext-ctype * ext-json * ext-tokenizer * php >=7.4
requires (dev) ircmaxell/php-yacc ^0.0.7 phpunit/phpunit ^7.0 || ^8.0 || ^9.0
No idea. Can't reproduce it. Try updating nikic/php-parser
to the latest version. If it doesn't work, please share the code being parsed (it appears to be an inline validator) that leads to a crash (you can figure it out by looking at the logs to see what endpoint was being processed).