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

Extension doesn't work with phpstan 1.10 #170

Open
garak opened this issue Mar 5, 2023 · 6 comments
Open

Extension doesn't work with phpstan 1.10 #170

garak opened this issue Mar 5, 2023 · 6 comments

Comments

@garak
Copy link

garak commented Mar 5, 2023

After upgrading from phpstan 1.9 to 1.10, I started getting many errors like this:

Trying to mock an undefined method X on class Y".

Downgrading to 1.9 solves the problems, but I'd like to use the latest version.

The installed version of phpstan-phpunit is the current latest one (1.3.10)

@ondrejmirtes
Copy link
Member

Does class Y have method X? Can you show more about the problem, the code?

@garak
Copy link
Author

garak commented Mar 5, 2023

Does class Y have method X? Can you show more about the problem, the code?

Of course it does. As told above, everything runs fine with phpstan 1.9
This is the commit in which my build started failing, you can see some code there: dustin10/VichUploaderBundle@7ead900

@ondrejmirtes
Copy link
Member

This is dg/bypass-finals problem again. Normally you can't mock final classes. PHPStan mostly doesn't play well with dg/bypass-finals.

@garak
Copy link
Author

garak commented Mar 6, 2023

So I'm forced to stay on phpstan 1.9? :-(

@ondrejmirtes
Copy link
Member

No. You have many options:

  1. Ignore this error with: https://phpstan.org/user-guide/ignoring-errors
  2. Stop mocking final classes (it's a bad hack), either by introducing an interface, or by making the class non-final.

Of course 1) is easier.

@garak
Copy link
Author

garak commented Mar 6, 2023

I see.
So, probably this should be clarified in the docs. I can propose a PR, if you agree.

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

No branches or pull requests

2 participants