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

Improve code generation for factories & proxies #29

Merged
merged 7 commits into from Apr 18, 2020

Conversation

shochdoerfer
Copy link
Member

Finally the fix for #6: Instead of regenerating the factory & proxy files during each run, the generated files are now cached via PHPStan's caching mechanism.

In addition to that, the whole autoloading process was refactored. Unfortunately due to changes in the phpstan codebase it was no longer possible to inject the autolading code magically by overwriting the spl_autoload_register() calls. You have to load now the autoload.php file anyways. Technically you had to do that before anyways so I would not consider this a BC break.

To be able to use PHPStan's caching mechanism for generating
factory & proxy classes, a simplified version of a file cache
storage is added.
Unfortunately made it impossible to overload the autoloader and
magically set the custom autoloaders needed for the extension to
run. Thus I removed the registration.php file handled the magic.

This means regardless of using the .phar archive or phpstan-src
dependency, you have to manually configure the autoload.php
work-a-round in the project's phpstan configuration.
To make sure that the cached files are generated in the
same cache directory as the regular phpstan files, find
the phpstan configuration and parse it via Nette\Neon
parser. Downside: The configuration gets parsed twice but
I did not notice any bigger speed difference.
@shochdoerfer shochdoerfer merged commit f70a5a7 into bitExpert:master Apr 18, 2020
@shochdoerfer shochdoerfer added this to the 0.1.0 milestone Apr 18, 2020
@shochdoerfer shochdoerfer deleted the feature/phpstan_cache branch August 7, 2021 08:06
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

Successfully merging this pull request may close these issues.

None yet

1 participant