-
Notifications
You must be signed in to change notification settings - Fork 319
[php] Add <tmp> assignment chain for call chains / property accesses #5434
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
base: master
Are you sure you want to change the base?
Conversation
base.name shouldBe Operators.fieldAccess | ||
base.code shouldBe "$a->contents" | ||
base.argumentIndex shouldBe -1 |
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.
There must have been a misunderstanding in our last talk.
The base is the "this" argument and this is just an IDENTIFIER a
in this case.
You can reference the same IDENTIFIER node as receiver.
I just red through the PHP docu and played around with it a little bit and i think we can model the PHP classes and the call dispatch in a classic vtable style.
base.code shouldBe "$a->contents" | ||
base.argumentIndex shouldBe -1 | ||
|
||
receiver.name shouldBe "a" |
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.
Please check explicitly for the existence of the receiver.
@@ -187,4 +219,38 @@ class CallTests extends PhpCode2CpgFixture { | |||
val call = cpg.call("test").head | |||
call.code shouldBe "test(...$args)" | |||
} | |||
|
|||
"chained calls should alias calls in receivers and bases" in { |
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.
The hole tmp variable creation can be removed because in PHP the receiver and the this argument are always the same and you can just reference the same AST subtree.
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.
So, should we remove the base
altogether? From what I understand, if the base and receiver are the same AST subtree the tmp
stuff is there to reduce duplication between the two.
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.
Please add one tree for the this argument and point to one argument and one receiver edge to it. No extra base tree.
Attempting this issue revealed a number of things that were incorrectly implemented and that had to be fixed as a prerequisite:
builtin_functions.txt
in the resources$this
receiver.TODO: