Magento already uses PHPStan, but it might be clever to enhance the default ruleset with https://github.com/bitExpert/phpstan-magento