Replies: 2 comments 6 replies
-
I don't think so, because it's based on instance, it's not static. Every DI container cached by PHPStanTestCase is hashed by the used config files so it shouldn't be a problem. Every LazyTypeNodeResolverExtensionRegistryProvider should have the correct registry cached. I'm not sure at the first sight, I'll have to dive deep into it later :) |
Beta Was this translation helpful? Give feedback.
-
|
I reproduced this in a separate repo: https://github.com/canvural/bug I think my suspicion about stub files only parsed once is true. But no idea how to resolve it. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm refactoring Larastan's test suite to use
RuleTestCaseinstead of our own slow solution.But I hit a wall during the refactor 😄
We have a custom
TypeNodeResolverExtension. It's logic depends on a parameter defined in the config. And registered in config to change it accordingly.This test provides a custom config file to override the
checkModelPropertiesThe problem
When the test is ran with
./vendor/bin/phpunit --filter='testModelPropertyRuleOnModelFactory'it fails. Because the expected error did not happen. But if I run PHPStan directly with./vendor/bin/phpstan analyse -vvv --debug -c tests/Rules/Data/modelPropertyConfig.neon tests/Rules/Data/model-property-model-factory.php -l9I see the correct error.I debugged it with XDebug little bit. And I suspect that it's related to the caching in
LazyTypeNodeResolverExtensionRegistryProvider, PHPStan is doing while testing. Because whenphpunitfirst runs, it collects data in the data providers. Since Larastan has some dataProviders withgatherAssertTypes, it triggers theLazyTypeNodeResolverExtensionRegistryProvider. Then when the actual test runs, it uses the old data.What I tried?
activeflag inModelPropertyTypeNodeResolverExtensionstatic. Didn't help. Called the new static method insetUpmethods in test classes. Didn't help.autowired: falseto theModelPropertyTypeNodeResolverExtension, triedsetupto set theactiveflag. Didn't help.It's easily reproducible in the
test-refactorsof Larastan. I did not spend time to create a new repository, because I'm sure the rest of the Larastan has no effect on this bug. I verified this by removing theincludein the config file.Does anyone have any idea? Because I'm going little bit crazy 😅
Beta Was this translation helpful? Give feedback.
All reactions