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

Introduce Scope::getMaybeDefinedVariables #3521

Merged
merged 3 commits into from
Oct 2, 2024

Conversation

ruudk
Copy link
Contributor

@ruudk ruudk commented Oct 1, 2024

Fixes phpstan/phpstan#11772

Where would be the best way to create a test for this?

@phpstan-bot
Copy link
Collaborator

You've opened the pull request against the latest branch 2.0.x. PHPStan 2.0 is not going to be released for months. If your code is relevant on 1.12.x and you want it to be released sooner, please rebase your pull request and change its target to 1.12.x.

@ruudk ruudk changed the base branch from 2.0.x to 1.12.x October 1, 2024 17:01
@ruudk ruudk force-pushed the getMaybeDefinedVariables branch from 46fdb83 to c2195b8 Compare October 1, 2024 17:01
@ruudk
Copy link
Contributor Author

ruudk commented Oct 1, 2024

Every time 🙈

@staabm
Copy link
Contributor

staabm commented Oct 1, 2024

ruudk added 2 commits October 2, 2024 08:35
By doing this, when you are inside MutatingScope you can press "Go to test" in PHPStorm and it
navigates you right to this test.
@ruudk
Copy link
Contributor Author

ruudk commented Oct 2, 2024

@staabm Thanks. Somehow I could not find it when using Go to test in PHPStorm. I fixed that now.

The tests are added.

@ondrejmirtes This is ready for review!

@ondrejmirtes ondrejmirtes merged commit 64ed7dc into phpstan:1.12.x Oct 2, 2024
481 of 499 checks passed
@ondrejmirtes
Copy link
Member

Thank you!

@ruudk ruudk deleted the getMaybeDefinedVariables branch October 2, 2024 07:59
@@ -574,6 +574,27 @@ public function getDefinedVariables(): array
return $variables;
}

/**
* @api
* @return array<int, string>
Copy link
Contributor

Choose a reason for hiding this comment

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

why not list<string> ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copied from getDefinedVars

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great 🎉

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.

Allow to get defined variables from scope that are maybe defined
5 participants