File tree Expand file tree Collapse file tree 3 files changed +26
-3
lines changed
lib/Doctrine/Common/Annotations
tests/Doctrine/Tests/Common/Annotations Expand file tree Collapse file tree 3 files changed +26
-3
lines changed Original file line number Diff line number Diff line change 42
42
"doctrine/coding-standard" : " ^10" ,
43
43
"phpstan/phpstan" : " ^1.10.28" ,
44
44
"phpunit/phpunit" : " ^7.5 || ^8.5 || ^9.5" ,
45
- "symfony/cache" : " ^5.4 || ^6" ,
45
+ "symfony/cache" : " ^5.4 || ^6.4 || ^7 " ,
46
46
"vimeo/psalm" : " ^4.30 || ^5.14"
47
47
},
48
48
"suggest" : {
Original file line number Diff line number Diff line change 12
12
use function array_merge ;
13
13
use function assert ;
14
14
use function filemtime ;
15
+ use function is_file ;
15
16
use function max ;
16
17
use function rawurlencode ;
17
18
use function time ;
@@ -195,7 +196,7 @@ private function getLastModification(ReflectionClass $class): int
195
196
$ parent = $ class ->getParentClass ();
196
197
197
198
$ lastModification = max (array_merge (
198
- [$ filename ? filemtime ($ filename ) : 0 ],
199
+ [$ filename !== false && is_file ( $ filename ) ? filemtime ($ filename ) : 0 ],
199
200
array_map (function (ReflectionClass $ reflectionTrait ): int {
200
201
return $ this ->getTraitLastModificationTime ($ reflectionTrait );
201
202
}, $ class ->getTraits ()),
@@ -219,7 +220,7 @@ private function getTraitLastModificationTime(ReflectionClass $reflectionTrait):
219
220
}
220
221
221
222
$ lastModificationTime = max (array_merge (
222
- [$ fileName ? filemtime ($ fileName ) : 0 ],
223
+ [$ fileName !== false && is_file ( $ fileName ) ? filemtime ($ fileName ) : 0 ],
223
224
array_map (function (ReflectionClass $ reflectionTrait ): int {
224
225
return $ this ->getTraitLastModificationTime ($ reflectionTrait );
225
226
}, $ reflectionTrait ->getTraits ())
Original file line number Diff line number Diff line change @@ -220,6 +220,28 @@ public function testReaderIsNotHitIfCacheIsFresh(): void
220
220
);
221
221
}
222
222
223
+ public function testReaderDoesNotCacheIfFileDoesNotExistSoLastModificationCannotBeDetermined (): void
224
+ {
225
+ $ code = <<<'EOS'
226
+ namespace Doctrine\Tests\Common\Annotations;
227
+
228
+ /**
229
+ * @\Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetClass("Some data")
230
+ */
231
+ class PsrCachedEvalClass {
232
+
233
+ }
234
+ EOS;
235
+
236
+ eval ($ code );
237
+
238
+ $ reader = new PsrCachedReader (new AnnotationReader (), new ArrayAdapter (), true );
239
+ // @phpstan-ignore class.notFound
240
+ $ readAnnotations = $ reader ->getClassAnnotations (new ReflectionClass (PsrCachedEvalClass::class));
241
+
242
+ self ::assertCount (1 , $ readAnnotations );
243
+ }
244
+
223
245
protected function doTestCacheStale (string $ className , int $ lastCacheModification ): PsrCachedReader
224
246
{
225
247
$ cacheKey = rawurlencode ($ className );
You can’t perform that action at this time.
0 commit comments