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

[php2cpg] Resolve static method call name when called by self #3736

Merged
merged 4 commits into from
Oct 18, 2023

Conversation

wunused
Copy link
Contributor

@wunused wunused commented Oct 16, 2023

When a static method call is made by referring to self, the AST node created for it failed to resolve the proper method full name.

For example:

<?php
class Foo {
    static function bar($x) {
        return 0;
    }
    function baz($x) {
        self::bar($x);
    }
}

The method full name of the call node for self::bar($x) is self::bar, but it should be Foo::bar.

This PR resolves the method full name of functions called by self.


case Some(expr) =>
// composeMethodFullName(name, call.isStatic)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to leave in commented-out code, then please supply a note

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, and thanks for the catch - this comment has been removed.

@DavidBakerEffendi DavidBakerEffendi added the php Relates to php2cpg label Oct 16, 2023
@DavidBakerEffendi DavidBakerEffendi marked this pull request as ready for review October 17, 2023 13:10
Copy link
Collaborator

@DavidBakerEffendi DavidBakerEffendi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will approve once commented-out code is addressed

Copy link
Collaborator

@DavidBakerEffendi DavidBakerEffendi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving since this seems sound to me

@DavidBakerEffendi DavidBakerEffendi merged commit 5a970d4 into joernio:master Oct 18, 2023
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
php Relates to php2cpg
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants