Skip to content

Static methods are no longer callable#2420

Merged
ondrejmirtes merged 2 commits intophpstan:1.10.xfrom
staabm:bug5782
Jun 22, 2023
Merged

Static methods are no longer callable#2420
ondrejmirtes merged 2 commits intophpstan:1.10.xfrom
staabm:bug5782

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.

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

@clxmstaab clxmstaab force-pushed the bug5782 branch 3 times, most recently from bbd9866 to cae7d82 Compare June 22, 2023 08:34
@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
$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
@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

Development

Successfully merging this pull request may close these issues.

3 participants