Skip to content

support 'HasMethodType' on StaticCall#1969

Merged
ondrejmirtes merged 4 commits intophpstan:1.9.xfrom
staabm:static-has-method
Nov 5, 2022
Merged

support 'HasMethodType' on StaticCall#1969
ondrejmirtes merged 4 commits intophpstan:1.9.xfrom
staabm:static-has-method

Conversation

@staabm
Copy link
Copy Markdown
Contributor

@staabm staabm commented Nov 5, 2022

@staabm staabm force-pushed the static-has-method branch from 2fee0d2 to 2302a61 Compare November 5, 2022 09:44
@staabm staabm marked this pull request as ready for review November 5, 2022 10:06
@phpstan-bot
Copy link
Copy Markdown
Collaborator

This pull request has been marked as ready for review.

@staabm staabm force-pushed the static-has-method branch from 94d479a to 4e8c9d6 Compare November 5, 2022 11:12
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.

Should we add isClassString on Type as a followup?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Of course :)

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.

we already have ConstantStringType->isClassString(): bool,

public function isClassString(): bool
{
if ($this->isClassString) {
return true;
}
$reflectionProvider = ReflectionProviderStaticAccessor::getInstance();
return $reflectionProvider->hasClass($this->value);
}

therefore we need a different name for this new method... any suggestions?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

isClassStringType

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

And make it nicer for 2.0

@ondrejmirtes
Copy link
Copy Markdown
Member

Yeah, I guess this is usable. Thank you :)

Copy link
Copy Markdown
Member

@ondrejmirtes ondrejmirtes left a comment

Choose a reason for hiding this comment

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

We should also test a scenario when a method doesn't exist - for example when we're not in method_exists at all, or when we call a different method than what was asked in method_exists.

@staabm staabm force-pushed the static-has-method branch from 51ae84d to 95dba26 Compare November 5, 2022 13:29
@staabm staabm force-pushed the static-has-method branch from 95dba26 to 9d1bca9 Compare November 5, 2022 13:32
@ondrejmirtes ondrejmirtes merged commit 7f6df07 into phpstan:1.9.x Nov 5, 2022
@ondrejmirtes
Copy link
Copy Markdown
Member

Thank you!

@staabm staabm deleted the static-has-method branch November 5, 2022 14:12
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.

False positives when using method_exists() with a static method

3 participants