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

$this type inside object creation #2620

Merged
merged 6 commits into from Mar 30, 2024

Conversation

mamazu
Copy link
Contributor

@mamazu mamazu commented Mar 28, 2024

That's an easy fix. If we're inside an ObjectCreationExpression and it has a name, then just continue looking up the tree.

@przepompownia
Copy link
Contributor

Seems to work inside ImplementContracts 🎉

btw. on that class this is not the last issue - it's a good implicit test case 😉

@@ -34,6 +34,29 @@ public function hello()
$this->assertEquals(false, $frame->locals()->byName('this')->first()->isProperty());
}];

yield 'It returns this with correct type' => [
Copy link
Collaborator

Choose a reason for hiding this comment

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

... in an anonymous function

@mamazu mamazu changed the title This type inside object creation $this type inside object creation Mar 29, 2024
@dantleech
Copy link
Collaborator

is this a regression or has it never worked?

@mamazu
Copy link
Contributor Author

mamazu commented Mar 29, 2024

This is a regression fix. Before adding ObjectCreationExpression to the list of ancestors it would have just ignored the instantiation and the first ancestor would have been the class definition.

@dantleech
Copy link
Collaborator

In which MR was the regression introduced?

@mamazu
Copy link
Contributor Author

mamazu commented Mar 29, 2024

#2469

@przepompownia
Copy link
Contributor

przepompownia commented Mar 29, 2024

is this a regression or has it never worked?

It's a regression, as I mentioned in #2618 (comment) (this PR should contain Fixes #2618 in the description).

@dantleech dantleech merged commit 1fe432d into phpactor:master Mar 30, 2024
10 checks passed
@mamazu mamazu deleted the this-type-inside-object-creation branch March 30, 2024 19:55
@przepompownia
Copy link
Contributor

Thank you

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

3 participants