PHPStan uses native PHP reflection to read class metadata of the project it inspects, which means it is loading the code it inspects into it's runtime.
If you'd wanted to inspect for example symfony/console
, you'll have to
- pray that it loads the version you're testing and not the version it has in it's vendor,
- pray that it is actually compatible, with the version provided.
Even after that, you're still inspecting the code, that is inspecting your code. Doesn't sound right, does it?
This project does the following
- Clones the PHPStan
- Checks out the specified version
- Optionally installs phpstan extensions (that it knows of)
- Prefixes all the vendor libraries, that PHPStan uses, to make sure you can test libraries, that PHPStan depends on
- When you've chosen to also include the extensions, it makes sure not to prefix libraries that they depend on. For example
phpstan/phpstan-doctrine
has references forDoctrine
namespace in it - we don't wanna prefix them, but only everything else. - Packages everything into a Phar file for you
The repository phpstan/phpstan-shim contains compiled phars. It would be awesome if you'd help us test them, but keep in mind this is not production ready.
git clone https://github.com/fprochazka/phpstan-compiler
cd phpstan-compiler
composer install
php -dphar.readonly=0 bin/compile [--no-extensions] [version]
Generated phar will be in tmp/
This project was inspired by
- Compilation process of Composer
- Build tools of Nette Framework (now removed, but preserved in forks)
Thank you!