Skip to content

Commit bbd93c8

Browse files
committed
Merge remote-tracking branch 'origin/2.2.x' into 2.3.x
2 parents 04d3b6c + 59ded7b commit bbd93c8

48 files changed

Lines changed: 1822 additions & 18 deletions

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: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,16 @@ jobs:
140140
OUTPUT=$(../../bin/phpstan -vvv 2>&1)
141141
echo "$OUTPUT"
142142
../bashunit -a contains 'Result cache restored. 0 files will be reanalysed.' "$OUTPUT"
143+
- script: |
144+
cd e2e/result-cache-11
145+
echo -n > phpstan-baseline.neon
146+
../../bin/phpstan -vvv
147+
patch -b src/Coll.php < patch-1.patch
148+
cat baseline-1.neon > phpstan-baseline.neon
149+
../../bin/phpstan -vvv
150+
mv src/Coll.php.orig src/Coll.php
151+
echo -n > phpstan-baseline.neon
152+
../../bin/phpstan -vvv
143153
- script: |
144154
cd e2e/bug-14514
145155
composer install
@@ -842,7 +852,7 @@ jobs:
842852
composer update test/logger --no-cache
843853
OUTPUT=$(../bashunit -a exit_code "0" "../../bin/phpstan analyse -vv")
844854
echo "$OUTPUT"
845-
../bashunit -a contains 'Composer packages changed (test/logger); re-analysing only the files depending on them.' "$OUTPUT"
855+
../bashunit -a contains 'Composer packages changed (test/logger); re-analysing the files depending on them and the files with errors.' "$OUTPUT"
846856
../bashunit -a contains 'Result cache restored. 1 file will be reanalysed.' "$OUTPUT"
847857
- script: |
848858
cd e2e/result-cache-path-repository
@@ -853,7 +863,7 @@ jobs:
853863
composer update psr/log --no-cache
854864
OUTPUT=$(../bashunit -a exit_code "0" "../../bin/phpstan analyse -vv")
855865
echo "$OUTPUT"
856-
../bashunit -a contains 'Composer packages changed (psr/log); re-analysing only the files depending on them.' "$OUTPUT"
866+
../bashunit -a contains 'Composer packages changed (psr/log); re-analysing the files depending on them and the files with errors.' "$OUTPUT"
857867
../bashunit -a contains 'Result cache restored. 1 file will be reanalysed.' "$OUTPUT"
858868
# Editing a file of an installed package is not a valid thing to do - the next Composer
859869
# command overwrites it - so PHPStan does not track it and keeps the cached results, even
@@ -965,6 +975,25 @@ jobs:
965975
OUTPUT=$(../bashunit -a exit_code "0" "../../bin/phpstan analyse -vv --error-format raw")
966976
echo "$OUTPUT"
967977
../bashunit -a not_contains 'is not a file or it does not exist' "$OUTPUT"
978+
- script: |
979+
cd e2e/result-cache-vendor-class-appears
980+
composer install
981+
# The class does not exist yet, and an error about a class that does not exist records no
982+
# dependency on anything - there is no file to point at.
983+
OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw")
984+
echo "$OUTPUT"
985+
../bashunit -a contains 'Foo.php:10:Parameter $logger of method ResultCacheE2EVendorClassAppears\Foo::doFoo() has invalid type Psr\Log\PluginProvidedLogger.' "$OUTPUT"
986+
# Composer updates the package, and a plugin writes the class into it on the way - which is
987+
# what phpstan/phpstan#15164 is about. Nothing the cache knows about points at that file,
988+
# so the files with errors have to be re-analysed on a package change; otherwise the error
989+
# stands while a run from a cleared cache reports nothing.
990+
patch -p0 < updatePsrLog.patch
991+
composer update psr/log --no-cache
992+
cp plugin-writes/PluginProvidedLogger.php vendor/psr/log/src/PluginProvidedLogger.php
993+
OUTPUT=$(../bashunit -a exit_code "0" "../../bin/phpstan analyse -vv --error-format raw")
994+
echo "$OUTPUT"
995+
../bashunit -a contains 'Composer packages changed (psr/log); re-analysing the files depending on them and the files with errors.' "$OUTPUT"
996+
../bashunit -a not_contains 'has invalid type Psr\Log\PluginProvidedLogger' "$OUTPUT"
968997
- script: |
969998
cd e2e/result-cache-extension-update
970999
composer install

conf/bleedingEdge.neon

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@ parameters:
2626
finiteTypesInHaystack: true
2727
switchConditionAlwaysFalse: true
2828
checkImportedClassNameCase: true
29+
sortWithoutEffect: true

conf/config.level5.neon

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ conditionalTags:
1212
phpstan.rules.rule: %featureToggles.checkPrintfParameterTypes%
1313
PHPStan\Rules\DateIntervalInstantiationRule:
1414
phpstan.rules.rule: %featureToggles.checkDateIntervalConstructor%
15+
PHPStan\Rules\Functions\SortWithoutEffectRule:
16+
phpstan.rules.rule: %featureToggles.sortWithoutEffect%
1517

1618
autowiredAttributeServices:
1719
# registers rules with #[RegisteredRule] attribute
@@ -26,3 +28,8 @@ services:
2628
checkStrictPrintfPlaceholderTypes: %checkStrictPrintfPlaceholderTypes%
2729
-
2830
class: PHPStan\Rules\DateIntervalInstantiationRule
31+
-
32+
class: PHPStan\Rules\Functions\SortWithoutEffectRule
33+
arguments:
34+
treatPhpDocTypesAsCertain: %treatPhpDocTypesAsCertain%
35+
treatPhpDocTypesAsCertainTip: %tips.treatPhpDocTypesAsCertain%

conf/config.neon

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ parameters:
5757
finiteTypesInHaystack: false
5858
switchConditionAlwaysFalse: false
5959
checkImportedClassNameCase: false
60+
sortWithoutEffect: false
6061
fileExtensions:
6162
- php
6263
checkAdvancedIsset: false

conf/parametersSchema.neon

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ parametersSchema:
5555
finiteTypesInHaystack: bool()
5656
switchConditionAlwaysFalse: bool()
5757
checkImportedClassNameCase: bool()
58+
sortWithoutEffect: bool()
5859
])
5960
fileExtensions: listOf(string())
6061
checkAdvancedIsset: bool()
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
parameters:
2+
ignoreErrors:
3+
-
4+
message: '#^Cannot call method name\(\) on TestResultCache11\\Item\|false\.$#'
5+
identifier: method.nonObject
6+
count: 1
7+
path: src/consumer.php

e2e/result-cache-11/patch-1.patch

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/e2e/result-cache-11/src/Coll.php b/e2e/result-cache-11/src/Coll.php
2+
index 9a6395d..773bb21 100644
3+
--- a/e2e/result-cache-11/src/Coll.php
4+
+++ b/e2e/result-cache-11/src/Coll.php
5+
@@ -4,7 +4,7 @@ namespace TestResultCache11;
6+
7+
/**
8+
* @template TValue of object
9+
- * @extends \Iterator<int, TValue>
10+
+ * @extends \Iterator<int, TValue|false>
11+
*/
12+
interface Coll extends \Iterator
13+
{

e2e/result-cache-11/phpstan-baseline.neon

Whitespace-only changes.

e2e/result-cache-11/phpstan.neon

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
includes:
2+
- phpstan-baseline.neon
3+
4+
parameters:
5+
level: 8
6+
paths:
7+
- src
8+

e2e/result-cache-11/src/Coll.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
namespace TestResultCache11;
4+
5+
/**
6+
* @template TValue of object
7+
* @extends \Iterator<int, TValue>
8+
*/
9+
interface Coll extends \Iterator
10+
{
11+
}
12+

0 commit comments

Comments
 (0)