Closed NickSun closed 1 year ago
Thank you for your report.
Please provide a minimal, self-contained, reproducing test case that shows the problem you are reporting.
Without such a minimal, self-contained, reproducing test case I will not be able to investigate this issue.
@sebastianbergmann please check this repository https://github.com/NickSun/phpunit-10-issue
There is no bug here, what you want to do is simply not possible.
Using new class
(and not new class implements ...
or new class extends ...
) you create an anonymous class that has no relationship to the type that is used in the return type declaration. Thus the object cannot be used as a return value for the method.
Summary
I'm using the Laravel framework and trying to create a simple stub for the final class
Symfony\Component\Console\Helper\ProgressBar
(I'm writing a unit test for the console command):Current behavior
Method createProgressBar may not return value of type class@anonymous, its declared return type is "Symfony\Component\Console\Helper\ProgressBar"
How to reproduce
Run the code snippet provided above
Expected behavior
No errors expected (as in PHPUnit 9)