Skip to content

Commit 6c6e8ff

Browse files
committed
implemented changes to make extension compatible with phpstan v0.12, updated README
1 parent 4065ea1 commit 6c6e8ff

File tree

5 files changed

+43
-18
lines changed

5 files changed

+43
-18
lines changed

README.md

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# phpstan-magento1 extension
1+
# PHPStan Extension for Magento 1
22

33
Extension for [PHPStan](https://github.com/phpstan/phpstan) to allow analysis of Magento 1 code.
44

5-
Currently it assumes Magento is installed in the public/ directory of the project root. Further work is needed in phpstan itself to allow more intellegence for extensions to be more customised whilst working with both phpstan/phpstan and phpstan/phpstan-shim.
5+
Currently it assumes Magento is installed in the `htdocs/` directory of the project root. Further work is needed in phpstan itself to allow more intellegence for extensions to be more customised whilst working with both phpstan/phpstan and phpstan/phpstan-shim.
66

77
## Usage
88

@@ -12,23 +12,15 @@ Make sure it has
1212

1313
```neon
1414
includes:
15-
- vendor/inviqa/phpstan-magento1/extension.neon
15+
- vendor/vianetz/phpstan-magento1/extension.neon
1616
```
1717

18-
Whilst this extension depends on phpstan/phpstan, it can also depend on phpstan/phpstan-shim, which decouples its dependencies from the project's own use of them.
19-
20-
With coupled dependencies:
18+
Then run
2119

2220
```bash
2321
composer require inviqa/phpstan-magento1 phpstan/phpstan
2422
```
2523

26-
With uncoupled phar package:
27-
28-
```bash
29-
composer require inviqa/phpstan-magento1 phpstan/phpstan-shim
30-
```
31-
3224
## Alternative Magento path
3325

3426
By default this extension assumes the Magento directory is `%currentWorkingDirectory%/htdocs`.
@@ -39,9 +31,6 @@ Add to the project's phpstan.neon:
3931
parameters:
4032
paths:
4133
- %currentWorkingDirectory%/path/to/magento/app/code/local
42-
excludes_analyse:
43-
- %currentWorkingDirectory%/path/to/magento/app/code/local/*/*/data/*
44-
- %currentWorkingDirectory%/path/to/magento/app/code/local/*/*/sql/*
4534
autoload_files:
4635
- %currentWorkingDirectory%/path/to/magento/app/Mage.php
4736
```

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "Extension for PHPStan to allow analysis of Magento 1 code.",
44
"type": "library",
55
"require": {
6-
"phpstan/phpstan": "^0.11",
6+
"phpstan/phpstan": "^0.11|^0.12",
77
"php": ">= 7.2",
88
"nikic/php-parser": "^4.4"
99
},

extension.neon

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
parameters:
2-
vendor_path: %currentWorkingDirectory%/vendor
3-
bootstrap: %vendor_path%/vianetz/phpstan-magento1/phpstan-bootstrap.php
2+
bootstrap: %currentWorkingDirectory%/vendor/vianetz/phpstan-magento1/phpstan-bootstrap.php
43
excludes_analyse:
54
- */app/code/local/*/*/data/*
65
- */app/code/local/*/*/sql/*

phpstan-bootstrap.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@
1010
// workaround Magento's use of date phpdoc typehint for string type
1111
// better would be to implement the typehint to make it appear string type
1212
class date {}
13+
14+
Mage::app();

src/Reflection/Varien/Object/MagicMethodReflection.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,39 @@ public function getVariants(): array
6161
new TrivialParametersAcceptor(),
6262
];
6363
}
64+
65+
public function getDocComment(): ?string
66+
{
67+
return null;
68+
}
69+
70+
public function isDeprecated(): \PHPStan\TrinaryLogic
71+
{
72+
return \PHPStan\TrinaryLogic::createNo();
73+
}
74+
75+
public function getDeprecatedDescription(): ?string
76+
{
77+
return null;
78+
}
79+
80+
public function isFinal(): \PHPStan\TrinaryLogic
81+
{
82+
return \PHPStan\TrinaryLogic::createNo();
83+
}
84+
85+
public function isInternal(): \PHPStan\TrinaryLogic
86+
{
87+
return \PHPStan\TrinaryLogic::createNo();
88+
}
89+
90+
public function getThrowType(): ?\PHPStan\Type\Type
91+
{
92+
return null;
93+
}
94+
95+
public function hasSideEffects(): \PHPStan\TrinaryLogic
96+
{
97+
return \PHPStan\TrinaryLogic::createNo();
98+
}
6499
}

0 commit comments

Comments
 (0)