Skip to content

Add support for method_exists() guards#12

Merged
johnbillion merged 3 commits intojohnbillion:method-existsfrom
staabm:method-exists
Oct 30, 2024
Merged

Add support for method_exists() guards#12
johnbillion merged 3 commits intojohnbillion:method-existsfrom
staabm:method-exists

Conversation

@staabm
Copy link
Copy Markdown
Contributor

@staabm staabm commented Oct 30, 2024

implementation for #6


in case you find more variants which needs fixing and are not covered yet, please send another failing test-case and I will provide a followup

use PHPStan\Node\Printer\ExprPrinter;
use function count;

final class MethodExistsVisitor extends NodeVisitorAbstract {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I tried several variants, even those mentioned in phpstan/phpstan#11648

I went with the visitor, as I got the impression that this SinceVersionRule is expected to work on the $requiresAtLeast parameter of SinceVersionRule, no matter which version of wordpress itself is installed at the time of analysis.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Yep that's correct 👍

@staabm staabm marked this pull request as ready for review October 30, 2024 10:52
@staabm
Copy link
Copy Markdown
Contributor Author

staabm commented Oct 30, 2024

I think this should work as a initial iteration (in case you don't have remarks)

Copy link
Copy Markdown
Owner

@johnbillion johnbillion left a comment

Choose a reason for hiding this comment

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

Thank you so much Markus. This is all looking good and everything is passing.

@johnbillion johnbillion merged commit a571bed into johnbillion:method-exists Oct 30, 2024
@staabm staabm deleted the method-exists branch October 30, 2024 14:43
@johnbillion johnbillion added this to the 0.3.0 milestone Oct 30, 2024
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.

2 participants