Skip to content

Commit 4e51c5a

Browse files
staabmxificurk
andcommitted
Test result-cache restore does not trigger reflection (#5617)
Co-authored-by: Petr Morávek <petr@pada.cz>
1 parent 118ca46 commit 4e51c5a

6 files changed

Lines changed: 63 additions & 0 deletions

File tree

.github/workflows/e2e-tests.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,11 @@ jobs:
307307
echo "$OUTPUT"
308308
../bashunit -a matches "Note: Using configuration file .+phpstan.neon." "$OUTPUT"
309309
../bashunit -a contains 'Result cache not used because the metadata do not match: metaExtensions' "$OUTPUT"
310+
- script: |
311+
cd e2e/result-cache-restore-without-reflection
312+
composer install
313+
../../bin/phpstan -vvv
314+
../../bin/phpstan -vvv
310315
- script: |
311316
cd e2e/bug-12606
312317
export CONFIGTEST=test
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: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"require-dev": {
3+
"phpstan/phpstan-symfony": "@dev",
4+
"phpstan/extension-installer": "^1.4",
5+
"phpstan/phpstan-doctrine": "@dev"
6+
},
7+
"autoload": {
8+
"classmap": [
9+
"lib/"
10+
]
11+
},
12+
"config": {
13+
"allow-plugins": {
14+
"phpstan/extension-installer": true
15+
}
16+
}
17+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace E2EFixture;
4+
5+
use LogicException;
6+
use PHPStan\BetterReflection\Identifier\Identifier;
7+
use PHPStan\BetterReflection\Identifier\IdentifierType;
8+
use PHPStan\BetterReflection\Reflection\Reflection;
9+
use PHPStan\BetterReflection\Reflector\Reflector;
10+
use PHPStan\BetterReflection\SourceLocator\Type\SourceLocator;
11+
12+
final class ThrowingSourceLocator implements SourceLocator
13+
{
14+
15+
public function locateIdentifier(Reflector $reflector, Identifier $identifier): ?Reflection
16+
{
17+
throw new LogicException('SourceLocator::locateIdentifier must not be called during result cache construction');
18+
}
19+
20+
public function locateIdentifiersByType(Reflector $reflector, IdentifierType $identifierType): array
21+
{
22+
throw new LogicException('SourceLocator::locateIdentifiersByType must not be called during result cache construction');
23+
}
24+
25+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
parameters:
2+
level: 8
3+
paths:
4+
- src
5+
6+
services:
7+
betterReflectionSourceLocator:
8+
class: PHPStan\BetterReflection\SourceLocator\Type\SourceLocator
9+
factory: E2EFixture\ThrowingSourceLocator
10+
autowired: false
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?php
2+
3+
echo "";
4+

0 commit comments

Comments
 (0)