Skip to content

Commit 8ef5460

Browse files
committed
Auto-fixable errors
2 parents 0749d19 + 0933083 commit 8ef5460

215 files changed

Lines changed: 3598 additions & 2060 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/e2e-tests.yml‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -967,6 +967,32 @@ jobs:
967967
OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw")
968968
echo "$OUTPUT"
969969
../bashunit assert contains 'FooTrait.php (in context of class ResultCacheE2ETraitAlongsideClass\ClassUsingFooTrait):10:Method ResultCacheE2ETraitAlongsideClass\ClassUsingFooTrait::doFooTrait() should return stdClass but returns Exception. [identifier=return.type]' "$OUTPUT"
970+
- script: |
971+
cd e2e/fix
972+
composer install
973+
rm -rf src cycle tmp && cp -r original src && cp -r cycle-original cycle
974+
OUTPUT=$(AI_AGENT=1 ../bashunit assert exit_code "1" "../../bin/phpstan analyse --error-format raw")
975+
echo "$OUTPUT"
976+
../bashunit assert contains '7 of the errors can be fixed automatically. Run PHPStan again with --fix' "$OUTPUT"
977+
OUTPUT=$(../bashunit assert exit_code "0" "../../bin/phpstan analyse --fix")
978+
echo "$OUTPUT"
979+
../bashunit assert contains 'Analysing fixed code (round 4)...' "$OUTPUT"
980+
../bashunit assert not_contains 'round 5' "$OUTPUT"
981+
../bashunit assert contains 'Round 2: fixed 3 errors in 1 file' "$OUTPUT"
982+
../bashunit assert contains '[OK] 10 errors fixed in 2 files' "$OUTPUT"
983+
diff -u expected/Foo.php src/Foo.php
984+
diff -u expected/Ignored-fix.php src/Ignored.php
985+
OUTPUT=$(../bashunit assert exit_code "0" "../../bin/phpstan analyse --fix-ignored")
986+
echo "$OUTPUT"
987+
../bashunit assert contains '[OK] 2 errors fixed' "$OUTPUT"
988+
diff -u expected/Foo.php src/Foo.php
989+
diff -u expected/Ignored-fix-ignored.php src/Ignored.php
990+
OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse --fix --fix-ignored")
991+
echo "$OUTPUT"
992+
../bashunit assert contains 'No fixable errors found' "$OUTPUT"
993+
OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -c cycle.neon --fix")
994+
echo "$OUTPUT"
995+
../bashunit assert contains 'Fixing stopped after 10 rounds' "$OUTPUT"
970996
- script: |
971997
cd e2e/editor-mode
972998
OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw")

‎.github/workflows/issue-bot.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ jobs:
5454
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
5555
with:
5656
path: ./issue-bot/tmp
57-
key: "issue-bot-download-v8-${{ github.run_id }}"
57+
key: "issue-bot-download-v9-${{ github.run_id }}"
5858
restore-keys: |
59-
issue-bot-download-v8-
59+
issue-bot-download-v9-
6060
6161
- name: "Download data"
6262
working-directory: "issue-bot"

‎.github/workflows/phar.yml‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,12 @@ jobs:
7070
ignore-cache: true
7171

7272
# only sebastian/diff ^4 supports PHP 7.4 so we need that in the PHAR
73+
# it stays in require, the PHAR is built without dev dependencies and the fixer needs it
7374
- name: "Downgrade PHPUnit"
74-
run: "composer require --dev phpunit/phpunit:^9.6 sebastian/diff:^4.0 doctrine/instantiator:^1.0 --update-with-dependencies --ignore-platform-reqs"
75+
run: |
76+
composer require --no-update sebastian/diff:^4.0
77+
composer require --dev --no-update phpunit/phpunit:^9.6 doctrine/instantiator:^1.0
78+
composer update phpunit/phpunit sebastian/diff doctrine/instantiator --with-all-dependencies --ignore-platform-reqs
7579
7680
- name: "Install compiler dependencies"
7781
uses: "ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda" # v4.0.0

‎build/baseline-pre-8.0.neon‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,3 +157,27 @@ parameters:
157157
identifier: property.internalClass
158158
count: 3
159159
path: ../src/Parser/RichParser.php
160+
161+
-
162+
rawMessage: Access to property $id of internal class Symfony\Polyfill\Php80\PhpToken from outside its root namespace Symfony.
163+
identifier: property.internalClass
164+
count: 6
165+
path: ../src/Analyser/Ignore/UnmatchedIgnoreFixer.php
166+
167+
-
168+
rawMessage: Access to property $line of internal class Symfony\Polyfill\Php80\PhpToken from outside its root namespace Symfony.
169+
identifier: property.internalClass
170+
count: 7
171+
path: ../src/Analyser/Ignore/UnmatchedIgnoreFixer.php
172+
173+
-
174+
rawMessage: Access to property $pos of internal class Symfony\Polyfill\Php80\PhpToken from outside its root namespace Symfony.
175+
identifier: property.internalClass
176+
count: 1
177+
path: ../src/Analyser/Ignore/UnmatchedIgnoreFixer.php
178+
179+
-
180+
rawMessage: Access to property $text of internal class Symfony\Polyfill\Php80\PhpToken from outside its root namespace Symfony.
181+
identifier: property.internalClass
182+
count: 2
183+
path: ../src/Analyser/Ignore/UnmatchedIgnoreFixer.php

‎build/composer-dependency-analyser.php‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
];
1818

1919
$pinnedToSupportPhp72 = [
20-
'symfony/process',
2120
'symfony/service-contracts',
2221
'symfony/string',
2322
];

‎build/ignore-gte-php7.4-errors.neon‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ includes:
33

44
parameters:
55
ignoreErrors:
6-
- '#^Class PHPStan\\Rules\\RuleErrors\\RuleError(?:\d+) has an uninitialized property (?:\$message|\$line|\$identifier|\$tip|\$file|\$metadata|\$originalNode)#'
6+
- '#^Class PHPStan\\Rules\\RuleErrors\\RuleError(?:\d+) has an uninitialized property (?:\$message|\$line|\$identifier|\$tip|\$file|\$metadata|\$nodeFixes)#'
77
- '#Extension has an uninitialized property (?:\$typeSpecifier|\$broker)#'
88
-
99
message: '#has an uninitialized property#'

‎build/php-85.neon‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
parameters:
22
ignoreErrors:
3-
-
4-
rawMessage: 'Call to deprecated method setAccessible() of class ReflectionMethod.'
5-
identifier: method.deprecated
6-
count: 1
7-
path: ../src/Fixable/Patcher.php
8-
93
-
104
rawMessage: 'Call to deprecated method setAccessible() of class ReflectionProperty.'
115
identifier: method.deprecated

‎composer.json‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
"ondram/ci-detector": "^4.0",
3434
"ondrejmirtes/better-reflection": "6.75.0.4",
3535
"ondrejmirtes/composer-attribute-collector": "^1.2.0",
36-
"ondrejmirtes/php-merge": "^4.1",
3736
"ondrejmirtes/phplrt-runtime": "4.2.4.1",
3837
"phpstan/php-8-stubs": "0.4.43",
3938
"phpstan/phpdoc-parser": "2.4.1",

‎composer.lock‎

Lines changed: 1 addition & 59 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎e2e/fix/.gitignore‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/src
2+
/cycle
3+
/tmp
4+
/vendor
5+
/composer.lock

0 commit comments

Comments
 (0)