Skip to content

Commit a079fec

Browse files
committed
Scaffolding for auto-fixable errors (experimental)
1 parent f8369ec commit a079fec

14 files changed

+580
-87
lines changed

composer.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"require": {
88
"php": "^8.1",
99
"composer-runtime-api": "^2.0",
10+
"bircher/php-merge": "^4.0",
1011
"clue/ndjson-react": "^1.0",
1112
"composer/ca-bundle": "^1.2",
1213
"composer/semver": "^3.4",
@@ -37,6 +38,7 @@
3738
"react/promise": "^3.2",
3839
"react/socket": "^1.3",
3940
"react/stream": "^1.1",
41+
"sebastian/diff": "^4.0",
4042
"symfony/console": "^5.4.3",
4143
"symfony/finder": "^5.4.3",
4244
"symfony/polyfill-intl-grapheme": "^1.23",

composer.lock

Lines changed: 122 additions & 67 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

conf/config.neon

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,11 @@ services:
286286
arguments:
287287
parser: @defaultAnalysisParser
288288

289+
-
290+
class: PHPStan\Analyser\RuleErrorTransformer
291+
arguments:
292+
parser: @currentPhpVersionPhpParser
293+
289294
-
290295
class: PHPStan\Analyser\Ignore\IgnoredErrorHelper
291296
arguments:

phpstan-baseline.neon

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,18 @@ parameters:
6060
count: 1
6161
path: src/Analyser/RicherScopeGetTypeHelper.php
6262

63+
-
64+
message: '#^Call to method __construct\(\) of internal class PhpParser\\Internal\\TokenStream from outside its root namespace PhpParser\.$#'
65+
identifier: method.internalClass
66+
count: 1
67+
path: src/Analyser/RuleErrorTransformer.php
68+
69+
-
70+
message: '#^Instantiation of internal class PhpParser\\Internal\\TokenStream\.$#'
71+
identifier: new.internalClass
72+
count: 1
73+
path: src/Analyser/RuleErrorTransformer.php
74+
6375
-
6476
message: '#^Doing instanceof PHPStan\\Type\\ConstantScalarType is error\-prone and deprecated\. Use Type\:\:isConstantScalarValue\(\) or Type\:\:getConstantScalarTypes\(\) or Type\:\:getConstantScalarValues\(\) instead\.$#'
6577
identifier: phpstanApi.instanceofType
@@ -102,6 +114,24 @@ parameters:
102114
count: 1
103115
path: src/Collectors/Registry.php
104116

117+
-
118+
message: '#^Call to method getContent\(\) of internal class PhpMerge\\internal\\Line from outside its root namespace PhpMerge\.$#'
119+
identifier: method.internalClass
120+
count: 2
121+
path: src/Command/AnalyseCommand.php
122+
123+
-
124+
message: '#^Call to static method createArray\(\) of internal class PhpMerge\\internal\\Hunk from outside its root namespace PhpMerge\.$#'
125+
identifier: staticMethod.internalClass
126+
count: 2
127+
path: src/Command/AnalyseCommand.php
128+
129+
-
130+
message: '#^Call to static method createArray\(\) of internal class PhpMerge\\internal\\Line from outside its root namespace PhpMerge\.$#'
131+
identifier: staticMethod.internalClass
132+
count: 5
133+
path: src/Command/AnalyseCommand.php
134+
105135
-
106136
message: '#^Anonymous function has an unused use \$container\.$#'
107137
identifier: closure.unusedUse
@@ -204,6 +234,24 @@ parameters:
204234
count: 1
205235
path: src/Diagnose/PHPStanDiagnoseExtension.php
206236

237+
-
238+
message: '#^Call to method getTokenCode\(\) of internal class PhpParser\\Internal\\TokenStream from outside its root namespace PhpParser\.$#'
239+
identifier: method.internalClass
240+
count: 1
241+
path: src/Fixable/PhpPrinterIndentationDetectorVisitor.php
242+
243+
-
244+
message: '#^Parameter \$origTokens of method PHPStan\\Fixable\\PhpPrinterIndentationDetectorVisitor\:\:__construct\(\) has typehint with internal class PhpParser\\Internal\\TokenStream\.$#'
245+
identifier: parameter.internalClass
246+
count: 1
247+
path: src/Fixable/PhpPrinterIndentationDetectorVisitor.php
248+
249+
-
250+
message: '#^Property \$origTokens references internal class PhpParser\\Internal\\TokenStream in its type\.$#'
251+
identifier: property.internalClass
252+
count: 1
253+
path: src/Fixable/PhpPrinterIndentationDetectorVisitor.php
254+
207255
-
208256
message: '#^Access to property \$id of internal class Symfony\\Polyfill\\Php80\\PhpToken from outside its root namespace Symfony\.$#'
209257
identifier: property.internalClass

src/Analyser/AnalyserResultFinalizer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function finalize(AnalyserResult $analyserResult, bool $onlyFiles, bool $
8989
}
9090

9191
foreach ($ruleErrors as $ruleError) {
92-
$error = $this->ruleErrorTransformer->transform($ruleError, $scope, $nodeType, $node->getStartLine());
92+
$error = $this->ruleErrorTransformer->transform($ruleError, $scope, [], $node);
9393

9494
if ($error->canBeIgnored()) {
9595
foreach ($this->ignoreErrorExtensionProvider->getExtensions() as $ignoreErrorExtension) {

0 commit comments

Comments
 (0)