Skip to main content

phpstan-magento 0.30.0 released!

· One min read
Stephan Hochdörfer
Head of IT Business Operations

Yesterday, we released version 0.30.0 of our bitexpert/phpstan-magento extension for PHPStan.

The latest release of our PHPStan extension for Magento adds two more rules to help you improve your code base:

  1. Resource models should be used directly: This rule detects and reports calls of \Magento\Framework\Model\AbtractModel::getResource(). The method is deprecated for a while now in favor of service contracts. In general, instead of accessing the resource model via the getResource() method, inject it via Dependency injection.
  2. Do not use setTemplate() in Block classes. Kudos to the ExtDN folks for this rule. Setters are deprecated in Block classes because constructor arguments should be preferred instead. Any call to $this->setTemplate() after calling upon the parent constructor would undo the configuration via XML layout.

If you disagree with these rules, you can ignore the specific errors or disable both rules globally.

Enjoy the latest release! If you run into problems, open an issue on GitHub.