Closed MetalArend closed 1 year ago
This is supposed to already work as setUp is configured as an additional constructor.
Please demonstrate how it does not work for you in a small reproducing repository, thank you. You should need just a handful of files to do that.
Sorry it took me a while to set up and reproduce it. Here is a repository: https://github.com/MetalArend/strict-phpstan
php vendor/bin/phpstan
is producing a single error: Class App\Tests\Test has an uninitialized property $name. Give it default value or assign it in the constructor.
You haven't configured the phpstan-phpunit extension. I recommend you to use phpstan/extension-installer, that way you don't need to include - vendor/phpstan/phpstan-strict-rules/rules.neon
either.
:man_facepalming: :blush:
Thank you!
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Many tests written for phpunit initialise properties only in the setUp method. There's not a constructor, or the need for a default value, it's enought if the setUp method handles the initialisation.
However, PHPStan's strict rules don't seem to know that. Would it be possible and correct to make this package make PHPStan understand that when
checkUninitializedProperties
is set to true, a property initialised in the setUp method is still perfectly fine?