Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Large refactor and new features #6

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/composer.lock
/vendor/
.idea
# PhpStorm
.idea

# composer
/vendor

# PhpStan
.phpstan*.neon
phpstan*.neon
!.phpstan.dist.neon
!.phpstan.dist.*.neon
8 changes: 8 additions & 0 deletions .phpstan.dist.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
includes:
- vendor/phpstan/phpstan-strict-rules/rules.neon
parameters:
scanFiles:
- stubs/mock.stub
paths:
- src
level: 10
22 changes: 16 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
{
"name": "macopedia/phpstan-magento1",
"description": "Extension for PHPStan to allow analysis of Magento 1 code.",
"type": "library",
"type": "phpstan-extension",
"license": "MIT",
"require": {
"phpstan/phpstan": "^1.12.11 | ^2.0.2",
"php": ">= 7.4"
},
"replace": {
"inviqa/phpstan-magento1": "0.1.5",
"vianetz/phpstan-magento1": "0.1.5"
"require-dev": {
"phpstan/phpstan": "^2.0",
"phpstan/phpstan-strict-rules": "^2.0"
},
"autoload": {
"psr-4": {
"PHPStanMagento1\\": "src/"
}
},
"replace": {
"inviqa/phpstan-magento1": "0.1.5",
"vianetz/phpstan-magento1": "0.1.5"
},
"scripts": {
"test-quality": [
"phpstan analyse"
Expand All @@ -23,5 +27,11 @@
"@test-quality"
]
},
"license": "MIT"
"extra": {
"phpstan": {
"includes": [
"extension.neon"
]
}
}
}
127 changes: 127 additions & 0 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 0 additions & 56 deletions extension-mage-autoload.neon

This file was deleted.

75 changes: 50 additions & 25 deletions extension.neon
Original file line number Diff line number Diff line change
@@ -1,51 +1,76 @@
parametersSchema:
magentoRootPath: string()
enforceMagicMethodDocBlock: bool()
useLocalXml: bool()
parameters:
magentoRootPath: %currentWorkingDirectory%/htdocs
excludePaths:
- */app/code/local/*/*/data/*
- */app/code/local/*/*/sql/*
enforceMagicMethodDocBlock: false
useLocalXml: false
bootstrapFiles:
- phpstan-bootstrap.php
scanFiles:
- %magentoRootPath%/app/Mage.php
typeAliases:
Mage_Catalog_Model_Entity_Product_Collection: 'Mage_Catalog_Model_Resource_Product_Collection'
callback: 'callable'
earlyTerminatingMethodCalls:
Mage:
- throwException
- %currentWorkingDirectory%/app/Mage.php

services:
mageCoreConfig:
class: PHPStanMagento1\Config\MageCoreConfig
arguments:
useLocalXml: %useLocalXml%

## Dynamic Return Type Extension to return correct class from Mage::getModel() etc
-
class: PHPStanMagento1\Reflection\Varien\Object\MagicMethodsReflectionExtension
class: PHPStanMagento1\Type\MageTypeExtension
arguments:
mageCoreConfig: @mageCoreConfig
className: Mage
tags:
- phpstan.broker.methodsClassReflectionExtension
- phpstan.broker.dynamicStaticMethodReturnTypeExtension
-
class: PHPStanMagento1\Type\Mage\CoreModelLayout\Helper
class: PHPStanMagento1\Type\MageTypeExtension
arguments:
mageCoreConfig: @mageCoreConfig
className: Mage_Core_Block_Abstract
tags:
- phpstan.broker.dynamicMethodReturnTypeExtension
-
class: PHPStanMagento1\Type\Mage\CoreBlockAbstract\Helper
class: PHPStanMagento1\Type\MageTypeExtension
arguments:
mageCoreConfig: @mageCoreConfig
className: Mage_Core_Model_Abstract
tags:
- phpstan.broker.dynamicMethodReturnTypeExtension
-
class: PHPStanMagento1\Type\Mage\CoreModelLayout\GetBlockSingleton
class: PHPStanMagento1\Type\MageTypeExtension
arguments:
mageCoreConfig: @mageCoreConfig
className: Mage_Core_Model_Layout
tags:
- phpstan.broker.dynamicMethodReturnTypeExtension
-
class: PHPStanMagento1\Type\Mage\GetModel
class: PHPStanMagento1\Type\MageTypeExtension
arguments:
mageCoreConfig: @mageCoreConfig
className: Mage_Core_Controller_Varien_Action
tags:
- phpstan.broker.dynamicStaticMethodReturnTypeExtension
- phpstan.broker.dynamicMethodReturnTypeExtension

## Rule to detect invalid class names returned by the Dynamic Return Type Extension
-
class: PHPStanMagento1\Type\Mage\GetResourceModel
class: PHPStanMagento1\Rules\MageInvalidTypeRule
arguments:
mageCoreConfig: @mageCoreConfig
tags:
- phpstan.broker.dynamicStaticMethodReturnTypeExtension
- phpstan.rules.rule

## Class Reflection Extension for Varien_Object's magic methods
-
class: PHPStanMagento1\Type\Mage\GetSingleton
class: PHPStanMagento1\Reflection\VarienObjectReflectionExtension
arguments:
enforceDocBlock: %enforceMagicMethodDocBlock%
tags:
- phpstan.broker.dynamicStaticMethodReturnTypeExtension
- phpstan.broker.methodsClassReflectionExtension

## PHP-Parser Extension to allow phtml and data install scripts to access protected methods with $this
-
class: PHPStanMagento1\Type\Mage\Helper
class: PHPStanMagento1\PhpDoc\BindThisScopeResolverExtension
tags:
- phpstan.broker.dynamicStaticMethodReturnTypeExtension
- phpstan.parser.richParserNodeVisitor
- phpstan.phpDoc.typeNodeResolverExtension
42 changes: 0 additions & 42 deletions phpstan-bootstrap-mage-autoload.php

This file was deleted.

Loading