Description
I'm trying to figure out how to run PHPStan on Magento LTS.
After dozens of tries I have a somewhat working instance.
These are the files I had to modify to make it run:
modified: app/code/core/Mage/Admin/Model/Acl/Assert/Ip.php
modified: app/code/core/Mage/Admin/Model/Acl/Assert/Time.php
modified: app/code/core/Mage/Adminhtml/Block/Widget/Grid/Block.php
modified: app/code/core/Mage/Adminhtml/Model/Extension.php
modified: app/code/core/Mage/Api/Model/Acl/Assert/Ip.php
modified: app/code/core/Mage/Api/Model/Acl/Assert/Time.php
modified: app/code/core/Mage/Authorizenet/controllers/Adminhtml/Authorizenet/Directpost/PaymentController.php
modified: app/code/core/Mage/Bundle/controllers/Adminhtml/Bundle/Product/EditController.php
modified: app/code/core/Mage/Bundle/controllers/Product/EditController.php
modified: app/code/core/Mage/Bundle/controllers/SelectionController.php
modified: app/code/core/Mage/Catalog/Model/Product/Option/Api/V2.php
modified: app/code/core/Mage/Centinel/Model/Api/Client.php
modified: app/code/core/Mage/Compiler/controllers/ProcessController.php
modified: app/code/core/Mage/Core/Model/Mysql4/Design/Theme/Collection.php
modified: app/code/core/Mage/Core/Model/Resource/Db/Collection/Abstract.php
modified: app/code/core/Mage/Dataflow/Model/Convert/Iterator.php
modified: app/code/core/Mage/Dataflow/Model/Convert/Iterator/File/Csv.php
modified: app/code/core/Mage/Dataflow/Model/Convert/Iterator/Http.php
modified: app/code/core/Mage/Dataflow/Model/Session/Adapter/Http.php
modified: app/code/core/Mage/Downloadable/controllers/Adminhtml/Downloadable/Product/EditController.php
modified: app/code/core/Mage/Downloadable/controllers/FileController.php
modified: app/code/core/Mage/Downloadable/controllers/Product/EditController.php
modified: app/code/core/Mage/GoogleBase/controllers/ItemsController.php
modified: app/code/core/Mage/GoogleBase/controllers/SelectionController.php
modified: app/code/core/Mage/GoogleBase/controllers/TypesController.php
modified: app/code/core/Mage/Install/Model/Installer/Pear.php
modified: app/code/core/Mage/Payment/Model/Paygate/Request.php
modified: app/code/core/Mage/Sales/doc/test.php
modified: app/code/core/Mage/Tag/Model/Api/V2.php
modified: app/code/core/Mage/XmlConnect/Block/Checkout/Cart/Item/Renderer/Giftcard.php
modified: app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/Pbridge/Abstract.php
modified: app/code/core/Mage/XmlConnect/Block/Customer/Form/Renderer/Date.php
modified: app/code/core/Mage/XmlConnect/Block/Customer/Form/Renderer/File.php
modified: app/code/core/Mage/XmlConnect/Block/Customer/Form/Renderer/Multiline.php
modified: app/code/core/Mage/XmlConnect/Block/Customer/Form/Renderer/Multiselect.php
modified: app/code/core/Mage/XmlConnect/Block/Customer/Form/Renderer/Select.php
modified: app/code/core/Mage/XmlConnect/Block/Customer/Form/Renderer/Text.php
modified: app/code/core/Mage/XmlConnect/Block/Customer/GiftcardCheck.php
modified: app/code/core/Mage/XmlConnect/Block/Customer/Order/Item/Renderer/Giftcard.php
modified: app/code/core/Mage/XmlConnect/Block/Customer/Order/Totals/Customerbalance.php
modified: app/code/core/Mage/XmlConnect/Block/Customer/Order/Totals/Customerbalance/Refunded.php
modified: app/code/core/Mage/XmlConnect/Block/Customer/Order/Totals/Giftcards.php
modified: composer.json
modified: lib/Varien/Db/Exception.php
modified: lib/Varien/Db/Tree.php
modified: lib/Varien/Db/Tree/Exception.php
modified: lib/Varien/Db/Tree/Node.php
modified: lib/Varien/Directory/Collection.php
modified: lib/Varien/Directory/Factory.php
modified: lib/Varien/File/CsvMulty.php
modified: lib/Varien/File/Object.php
modified: lib/Varien/Io/Sftp.php
modified: lib/Varien/Object.php
modified: lib/Varien/Pear.php
modified: lib/Varien/Pear/Package.php
deleted: lib/Zend/Date.php
deleted: lib/Zend/Db/Select.php
deleted: lib/Zend/Db/Statement.php
deleted: lib/Zend/Mime.php
deleted: lib/Zend/Serializer/Adapter/PhpCode.php
deleted: lib/Zend/Validate/Hostname.php
deleted: lib/Zend/Xml/Security.php
This is the configuration used for phpstan:
autoload_directories:
- %rootDir%/../../../app/code/community
- %rootDir%/../../../app/code/core
- %rootDir%/../../../lib/Varien
- %rootDir%/../../../lib/Zend
autoload_files:
- %rootDir%/../../../lib/Varien/Autoload.php
And this is the command:
vendor/bin/phpstan analyze -vvv -l 0 -c phpstan.neon app/code/
I'm sure I'm doing something wrong with the autoloading, as I get thousands of errors like "Call to static method app() on an unknown class Mage."
But if I use %rootDir%/../../../app/Mage.php
instead of %rootDir%/../../../lib/Varien/Autoload.php
I get all sorts of other issues with PEAR classes and so on.
Anyone interested in helping me out? Using phpstan would greatly help finding issues on magento, and would be a first step for the upcoming CI environment that's needed for the project.
Metadata
Metadata
Assignees
Type
Projects
Status