Repository navigation
Fix fatal error on dynamic method names in assignments - #143
iMattPro merged 6 commits into
Conversation
Co-authored-by: iMattPro <303711+iMattPro@users.noreply.github.com>
@iMattPro
iMattPro
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add tests for this change
Co-authored-by: iMattPro <303711+iMattPro@users.noreply.github.com>
Co-authored-by: iMattPro <303711+iMattPro@users.noreply.github.com>
Add tests for this change
Added test_usage_dynamic_method_name_in_assignment with fixture tests/testFiles/dynamic_method_call.php. It covers $x = $this->store->{$methods[$step]}(...). The test errors with the original ArrayDimFetch::toString() crash without the fix and passes with it. All 13 tests in that file pass.
Co-authored-by: iMattPro <303711+iMattPro@users.noreply.github.com>
@iMattPro
iMattPro
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are all these lint files you added to the bin dir? That's not what I asked for. And why are phpunit results caches added to gitignore - also something we've not needed before. Get rid of this noise!
Co-authored-by: iMattPro <303711+iMattPro@users.noreply.github.com>
Uh oh!
There was an error while loading. Please reload this page.
EPV crashed with
Call to undefined method PhpParser\Node\Expr\ArrayDimFetch::toString()when scanning an assignment whose right-hand side is a method call with an array-indexed dynamic name, e.g.$removed = $this->store->{$methods[$step]}(self::DELETE_STEP);.Root cause
validateMethodCalls, the assignment branch ($node->expris aMethodCall) skipped only a fixed list of name node types:Variable,PropertyFetch,Concat,EncapsedandTernary.$node->expr->name->toString().ArrayDimFetchwas one of them, and it has notoString().Change
src/Tests/Tests/epv_test_validate_php_functions.php.toString()is now called only when the name is aNode\IdentifierorNode\Name, which are the only types that have it.Not run: the checkout had no
vendordirectory, so onlyphp -lwas run. I didn't add a regression test or try the zip from the issue. It's worth checking$x = $obj->{$arr[$i]}()against the real extension.