-
Notifications
You must be signed in to change notification settings - Fork 92
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
Add result cache meta extension for DI container #421
base: 2.0.x
Are you sure you want to change the base?
Conversation
@ondrejmirtes did you have opportunity to look at it? I hope for your feedback as in the main extension point PR, so I can finish this properly 🙂. |
It's a bit crazy to urge me less than 24h after you opened the PR. Please avoid that next time. A literally wasn't in front of my computer since then. |
Sorry, I just didn't know you were notified about the PR because I realised I did not mention you in the description 😅. Sorry for bothering, take your time of course, just wanted to know if you're aware about this one. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can test this by:
- Create
SymfonyContainerResultCacheMetaExtension extends PHPStanTestCase
- Create a new .neon file under tests/ and link to an actual dumped container XML file which you're going to commit in this repository under tests/.
- Override
getAdditionalConfigFiles
method and supply path to the .neon file from 2) - Create
new SymfonyContainerResultCacheMetaExtension
and supply constructor arguments viaself::getContainer()->getByType()
Otherwise it may fail with `foreach() argument must be of type array|object, null given`.
ea69633
to
2bc5a26
Compare
@ondrejmirtes please make sure you're familiar with the commits' messages, as I provided additional info there. When it comes to Again, thank you very much for providing feedback and guiding about tests 🍻. |
This test ensures that hash calculated for Symfony's DI container remains the same or changes under provided conditions. This test is significantly slower than other unit tests, this is caused by rebuilding Nette container for each Symfony DI container's XML content - it's required in order to get fresh parameter/service maps from `self::getContainer()->getByType()`, because `self::getContainer()` caches containers for each `self::getAdditionalConfigFiles()` unique set, and with the same Nette config/container it would be retrieved from cache, so the hash correctness couldn't be verified properly.
2bc5a26
to
9393cf7
Compare
9393cf7
to
5f8002d
Compare
To be honest, I am not sure whether services' tags should be taken into consideration when calculating container's hash 🤔. |
Important
This feature was brought to you thanks to GetResponse - Marketing Software for Professional Email Marketing, which paid for my work on this.
Fixes #255, continues phpstan/phpstan-src#3765.
Following this experiment's results I decided to calculate meta hash based on DI container's actual content (params and services), without interacting with XML file directly.
ParameterMapFactory
andServiceMapFactory
were used for retrieving data, also I implemented "singleton" approach there, so the XML file won't be processed multiple times (once for calculating hash, then for processing rules).I start with a draft PR so I can get early feedback. I also need help when it comes to testing this, because I don't see e2e approach here. I wanted to test it on our codebase, but it's really cumbersome to setup Composer dependencies to get dev version of PHPStan and the plugin 😅.