The end of May brought two exciting releases for PHPStan and the PHPStan Deprecation Rules extension. With the version of PHPStan v0.11.8, descriptions added to the @deprecated
tag can be parsed and returned in rule checks. The v0.11.2 of the PHPStan Deprecation Rules extension implements this feature and returns that description instead of a generic "Call to deprecated X Y" messaging.
It is exciting to see this functionality in the wild. The original feature request, from November 2018, required feature development on PHPStan's phpdoc-parser and PHPStan itself. The first bits of code landed in mid-March and the complete functionality released by the end of May. Gábor Hojtsy has already updated the Upgrade Status module to take advantage of these features.
Drupal Check was a little behind, but the ability to display messages now exists. The v1.0.11 release will display deprecated code usage descriptions. The tool currently requires a development tag of PHPStan until v0.11.9 is released. Drupal Check performs some unique loading techniques to support various ways users are installing the tool which broke in PHPStan v0.11.8.
Here are those commits, for those interested:
- Ignore files using a stream wrapper, loading configurations which prefixed with
phar://
were causing errors when using the Drupal Check binary - Support PhpAdapter for configurations, to support project-level installations and global Composer installs, PHP configuration is used to discover the vendor directory dynamically. Support for the PhpAdapter had to be added back.
Contributing to another project has been a fun and challenging experience. PHPStan uses the Nette framework, and this has been my first experience working with its components. It also involved contributing to different projects to ensure a piece of functionality was available. My initial work was done in PHPStan itself, which was hacky. Ondřej identified it should belong in the phpdoc-parser
library. I have briefly worked with PHP in an abstract-syntax tree format or as tokens but never trying to extract description messages based off a tag in a document block. All I can say is thank you Derick Rethans for creating and maintaining Xdebug. Without the ability to use Xdebug for step debugging, I would have spent many more days working through this code.
Support Open Source
If you are using any of these open source tools, I highly recommend supporting their maintainers.
All of my work for Drupal Check and PHPStan has been supported by Centarro for our Centarro Toolbox + Support, as part of our Quality Monitor service.
Support PHPStan development through its Patreon page: https://www.patreon.com/join/phpstan
Support Xdebug through Derick Rethans' Patreon page: https://www.patreon.com/bePatron?u=7864328
Want more? Sign up for my weekly newsletter