Skip to content

Commit 603c305

Browse files
committed
Track the files of the project's Composer autoload entries like scanned files
A class or function can appear in a file of the project's own autoload entries - PSR-4, PSR-0, classmap and files, of autoload and autoload-dev, and of packages from path repositories - without any analysed or scanned file changing, and nothing noticed it. Those files are now scanned files: a new one or a changed one is noticed and read for what it declares, and its exported nodes decide which dependents are re-analysed. A changed file of a package from a path repository is tracked file by file instead of throwing the whole result cache away; the scanned-vendor e2e test records its package as downloaded to keep covering a package from Packagist. An entry containing the vendor directory, like a namespace mapped to the project root, is walked without it and gives only PHP files, the project's entries pointing into the vendor directory are left to their package, and nothing under tmpDir counts as a scanned file - the result cache and the container would otherwise change on every run. Amp-Thread-ID: https://ampcode.com/threads/T-01a1c5c8-8d5b-7459-a22c-beb8e7ba8a3b
1 parent 8435dd9 commit 603c305

19 files changed

Lines changed: 444 additions & 31 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/vendor
2+
/composer.lock

‎e2e/result-cache-autoload-entries/classmap/.gitkeep‎

Whitespace-only changes.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "phpstan/result-cache-autoload-entries-e2e",
3+
"repositories": [
4+
{
5+
"type": "path",
6+
"url": "./path-lib"
7+
}
8+
],
9+
"require": {
10+
"test/path-lib": "*"
11+
},
12+
"autoload": {
13+
"psr-4": {
14+
"AutoloadEntries\\": "src/",
15+
"AutoloadEntries\\Lib\\": "lib/",
16+
"AutoloadEntries\\Root\\": ""
17+
},
18+
"psr-0": {
19+
"AutoloadEntries_Legacy_": "legacy/"
20+
},
21+
"classmap": ["classmap/"],
22+
"files": ["helpers.php"]
23+
},
24+
"autoload-dev": {
25+
"psr-4": {
26+
"AutoloadEntries\\Tests\\": "tests/"
27+
}
28+
}
29+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace AutoloadEntries;

‎e2e/result-cache-autoload-entries/legacy/.gitkeep‎

Whitespace-only changes.

‎e2e/result-cache-autoload-entries/lib/.gitkeep‎

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{ "name": "test/path-lib", "version": "1.0.0", "autoload": { "psr-4": { "PathLib\\": "src/" }, "files": ["functions.php"] } }
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace PathLib;

‎e2e/result-cache-autoload-entries/path-lib/src/.gitkeep‎

Whitespace-only changes.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
parameters:
2+
level: 8
3+
tmpDir: tmp
4+
paths:
5+
- src

0 commit comments

Comments
 (0)