17
17
use Psr \Cache \CacheItemPoolInterface ;
18
18
use Symfony \Component \Cache \Adapter \ArrayAdapter ;
19
19
use Symfony \Component \Cache \DoctrineProvider ;
20
+ use Symfony \Component \Config \Resource \ClassExistenceResource ;
20
21
21
22
/**
22
23
* Warms up annotation caches for classes found in composer's autoload class map
@@ -66,15 +67,13 @@ protected function doWarmUp($cacheDir, ArrayAdapter $arrayAdapter)
66
67
$ this ->readAllComponents ($ reader , $ class );
67
68
} catch (\ReflectionException $ e ) {
68
69
// ignore failing reflection
69
- } catch (AnnotationException $ e ) {
70
- /*
71
- * Ignore any AnnotationException to not break the cache warming process if an Annotation is badly
72
- * configured or could not be found / read / etc.
73
- *
74
- * In particular cases, an Annotation in your code can be used and defined only for a specific
75
- * environment but is always added to the annotations.map file by some Symfony default behaviors,
76
- * and you always end up with a not found Annotation.
77
- */
70
+ } catch (\Exception $ e ) {
71
+ try {
72
+ ClassExistenceResource::throwOnRequiredClass ($ class , $ e );
73
+
74
+ throw $ e ;
75
+ } catch (\ReflectionException $ e ) {
76
+ }
78
77
}
79
78
}
80
79
@@ -84,14 +83,32 @@ protected function doWarmUp($cacheDir, ArrayAdapter $arrayAdapter)
84
83
private function readAllComponents (Reader $ reader , $ class )
85
84
{
86
85
$ reflectionClass = new \ReflectionClass ($ class );
87
- $ reader ->getClassAnnotations ($ reflectionClass );
86
+
87
+ try {
88
+ $ reader ->getClassAnnotations ($ reflectionClass );
89
+ } catch (AnnotationException $ e ) {
90
+ /*
91
+ * Ignore any AnnotationException to not break the cache warming process if an Annotation is badly
92
+ * configured or could not be found / read / etc.
93
+ *
94
+ * In particular cases, an Annotation in your code can be used and defined only for a specific
95
+ * environment but is always added to the annotations.map file by some Symfony default behaviors,
96
+ * and you always end up with a not found Annotation.
97
+ */
98
+ }
88
99
89
100
foreach ($ reflectionClass ->getMethods () as $ reflectionMethod ) {
90
- $ reader ->getMethodAnnotations ($ reflectionMethod );
101
+ try {
102
+ $ reader ->getMethodAnnotations ($ reflectionMethod );
103
+ } catch (AnnotationException $ e ) {
104
+ }
91
105
}
92
106
93
107
foreach ($ reflectionClass ->getProperties () as $ reflectionProperty ) {
94
- $ reader ->getPropertyAnnotations ($ reflectionProperty );
108
+ try {
109
+ $ reader ->getPropertyAnnotations ($ reflectionProperty );
110
+ } catch (AnnotationException $ e ) {
111
+ }
95
112
}
96
113
}
97
114
}
0 commit comments