Skip to content

Commit 7583afd

Browse files
committed
Merge remote-tracking branch 'origin/2.2.x' into 2.3.x
2 parents 09092df + 3c3db9c commit 7583afd

165 files changed

Lines changed: 9285 additions & 45 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: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -901,6 +901,70 @@ jobs:
901901
echo "$OUTPUT"
902902
../bashunit -a contains 'Result cache restored. 1 file will be reanalysed.' "$OUTPUT"
903903
../bashunit -a contains 'UsesCopied.php:16:Method ResultCacheE2EPathRepository\UsesCopied::doUsesCopied() should return int but returns string.' "$OUTPUT"
904+
- script: |
905+
cd e2e/result-cache-composer-json
906+
composer install
907+
../../bin/phpstan analyse
908+
# composer.json decides which PHP version the analysis targets (config.platform.php) and
909+
# which symbols the autoloader can reach, but its contents are hashed nowhere in the cache
910+
# metadata - composerLocks and composerInstalled cover composer.lock and installed.php, and
911+
# neither of those moves when only composer.json changes.
912+
patch -p0 < platform.patch
913+
OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw")
914+
echo "$OUTPUT"
915+
../bashunit -a contains 'Foo.php:10:Function str_contains not found.' "$OUTPUT"
916+
- script: |
917+
cd e2e/result-cache-empty-file-gains-symbol
918+
# src/script.php declares no symbol, so the cache holds no exported nodes entry for it at
919+
# all, and src/user.php uses a class that does not exist yet.
920+
OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw")
921+
echo "$OUTPUT"
922+
../bashunit -a contains 'user.php:7:Instantiated class ResultCacheE2EEmptyFileGainsSymbol\Thing not found.' "$OUTPUT"
923+
# That file now declares a class. A root symbol appeared, so the files with errors have to
924+
# be re-analysed, the same way a brand new file makes them re-analysed - the missing
925+
# exported nodes entry must not be read as "nothing changed".
926+
mv gains/script.php src/script.php
927+
OUTPUT=$(../bashunit -a exit_code "0" "../../bin/phpstan analyse -vv --error-format raw")
928+
echo "$OUTPUT"
929+
../bashunit -a not_contains 'Instantiated class ResultCacheE2EEmptyFileGainsSymbol\Thing not found.' "$OUTPUT"
930+
- script: |
931+
cd e2e/result-cache-string-class
932+
../../bin/phpstan analyse
933+
# The instantiated class is named by a constant string, so it is resolved through the type
934+
# system rather than through a name node, and the dependency graph records no edge from
935+
# Thing.php to Factory.php. Deleting the class still has to be noticed.
936+
rm src/Thing.php
937+
OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw")
938+
echo "$OUTPUT"
939+
../bashunit -a contains 'Factory.php:12:Instantiated class ResultCacheE2EStringClass\Thing not found.' "$OUTPUT"
940+
- script: |
941+
cd e2e/result-cache-import-type-deleted
942+
../../bin/phpstan analyse
943+
# Deleting the class an imported type alias comes from makes the PHPDoc of Base.php
944+
# unresolvable, and a file whose PHPDoc cannot be resolved records no dependencies at all -
945+
# the edge to User.php is dropped. The next edit of Base.php must still reach User.php.
946+
rm src/Aliases.php
947+
OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw")
948+
echo "$OUTPUT"
949+
patch -b -p0 < signature.patch
950+
OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw")
951+
echo "$OUTPUT"
952+
../bashunit -a contains 'User.php:10:Method ResultCacheE2EImportType\User::doUser() should return int but returns string.' "$OUTPUT"
953+
- script: |
954+
cd e2e/result-cache-require-deleted
955+
../../bin/phpstan analyse
956+
# The file named in require() is not analysed, not scanned and not autoloadable, so no hash
957+
# of it exists anywhere in the cache. Deleting it has to be noticed all the same: the rule
958+
# that checks the path reports an error the moment it is gone.
959+
rm config/app.php
960+
OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw")
961+
echo "$OUTPUT"
962+
../bashunit -a contains 'Foo.php:10:Path in require() "config/app.php" is not a file or it does not exist.' "$OUTPUT"
963+
# And putting it back has to clear the error again.
964+
printf '<?php declare(strict_types = 1);\n\nreturn [];\n' > config/app.php
965+
OUTPUT=$(../bashunit -a exit_code "0" "../../bin/phpstan analyse -vv --error-format raw")
966+
echo "$OUTPUT"
967+
../bashunit -a not_contains 'is not a file or it does not exist' "$OUTPUT"
904968
- script: |
905969
cd e2e/result-cache-extension-update
906970
composer install
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/vendor
2+
/composer.lock
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "phpstan/result-cache-composer-json-e2e",
3+
"autoload": {
4+
"classmap": ["src"]
5+
},
6+
"config": {
7+
"platform": {
8+
"php": "8.4.0"
9+
}
10+
}
11+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
parameters:
2+
level: 0
3+
tmpDir: tmp
4+
paths:
5+
- src
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--- composer.json
2+
+++ composer.json
3+
@@ -5,7 +5,7 @@
4+
},
5+
"config": {
6+
"platform": {
7+
- "php": "8.4.0"
8+
+ "php": "7.4.0"
9+
}
10+
}
11+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace ResultCacheE2EComposerJson;
4+
5+
class Foo
6+
{
7+
8+
public function doFoo(string $s): bool
9+
{
10+
return str_contains($s, 'a');
11+
}
12+
13+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!.*
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace ResultCacheE2EEmptyFileGainsSymbol;
4+
5+
class Thing
6+
{
7+
8+
public function doThing(): int
9+
{
10+
return 1;
11+
}
12+
13+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
parameters:
2+
level: 4
3+
tmpDir: tmp
4+
paths:
5+
- src
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php declare(strict_types = 1);
2+
3+
// Declares no symbol at all, so the result cache holds no exported nodes entry for it.
4+
5+
$x = 1;
6+
echo $x;

0 commit comments

Comments
 (0)