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

Static methods are no longer callable #2420

Merged
merged 2 commits into from
Jun 22, 2023
Merged

Conversation

staabm
Copy link
Contributor

@staabm staabm commented May 28, 2023

@staabm staabm changed the base branch from 1.11.x to 1.10.x May 28, 2023 08:43
@phpstan-bot
Copy link
Collaborator

You've opened the pull request against the latest branch 1.11.x. If your code is relevant on 1.10.x and you want it to be released sooner, please rebase your pull request and change its target to 1.10.x.

}

$method = $type->getMethod($methodName, new OutOfClassScope());
if ($method->isStatic()) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

actually this should depend on php-version.
within the type-classes we don't have access to PhpVersion though

@staabm
Copy link
Contributor Author

staabm commented Jun 22, 2023

I think it works as expected now - at least what php8 is concerned.
(The PR title is wrong, as non-static methods are no longer callable)

we don't know the php version in the type-system, so I can't differentiate between php7/8. is it acceptable as is?

@staabm staabm marked this pull request as ready for review June 22, 2023 09:16
@phpstan-bot
Copy link
Collaborator

This pull request has been marked as ready for review.

Copy link
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.

There are examples how to approach DI-registered values or services in places where DI isn't available:

For current methods we could add PhpVersionAccessor so that we can ask about the PHP version.

For future methods we should require PhpVersion as a parameter.

@clxmstaab clxmstaab force-pushed the bug5782 branch 3 times, most recently from 30e3c7a to 4630869 Compare June 22, 2023 09:57
@staabm staabm marked this pull request as draft June 22, 2023 10:39
@@ -656,7 +656,7 @@ public function test(callable $str)
{
$this->test('date');
$this->test('nonexistentFunction');
$this->test('Test\CheckIsCallable::test');
// $this->test('Test\CheckIsCallable::test'); differs between php7/8; tested separately
Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved this line into a separate new test, so I don't need to duplicate the whole call-methods.php assertions and can keep the diff small

@staabm
Copy link
Contributor Author

staabm commented Jun 22, 2023

the errors in the Carbon build job seem legit. related source

@staabm staabm marked this pull request as ready for review June 22, 2023 11:37
@phpstan-bot
Copy link
Collaborator

This pull request has been marked as ready for review.

@ondrejmirtes ondrejmirtes merged commit 7cf2c93 into phpstan:1.10.x Jun 22, 2023
387 of 389 checks passed
@ondrejmirtes
Copy link
Member

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
3 participants