From 074f8aeabd348c69e24b764acfcad24f1c4fb056 Mon Sep 17 00:00:00 2001
From: Maxime Aknin <aknin.maxime@gmail.com>
Date: Mon, 14 Mar 2022 23:39:10 +0100
Subject: [PATCH] Catch filemtime warning thrown as ErrorException

When ReflectionClass->getFileName() returns a filename with eval()'d in it, filemtime emits a warning which is thrown as an Error Exception in Symfony by default.

- Related to this issue in doctrineannotations: https://github.com/doctrine/annotations/issues/186
---
 .../FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php  | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php
index 6bc39acc27923..57d6f85f08b05 100644
--- a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php
+++ b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php
@@ -85,7 +85,7 @@ private function readAllComponents(Reader $reader, string $class)
 
         try {
             $reader->getClassAnnotations($reflectionClass);
-        } catch (AnnotationException $e) {
+        } catch (AnnotationException | \ErrorException $e) {
             /*
              * Ignore any AnnotationException to not break the cache warming process if an Annotation is badly
              * configured or could not be found / read / etc.
@@ -99,14 +99,14 @@ private function readAllComponents(Reader $reader, string $class)
         foreach ($reflectionClass->getMethods() as $reflectionMethod) {
             try {
                 $reader->getMethodAnnotations($reflectionMethod);
-            } catch (AnnotationException $e) {
+            } catch (AnnotationException | \ErrorException $e) {
             }
         }
 
         foreach ($reflectionClass->getProperties() as $reflectionProperty) {
             try {
                 $reader->getPropertyAnnotations($reflectionProperty);
-            } catch (AnnotationException $e) {
+            } catch (AnnotationException | \ErrorException $e) {
             }
         }
     }