From 6cbe0436489425263e3a489779d6cf99ad8089ae Mon Sep 17 00:00:00 2001 From: Dave Mc Nicoll Date: Tue, 19 Oct 2021 12:43:32 +0000 Subject: [PATCH] - Added a try/catch for the annotations --- src/LanguageHandler.php | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/LanguageHandler.php b/src/LanguageHandler.php index 5713407..49139c5 100644 --- a/src/LanguageHandler.php +++ b/src/LanguageHandler.php @@ -10,22 +10,27 @@ class LanguageHandler { public function verify(string $className) : ? \Notes\Annotation { - $annotation = $this->getClassAnnotations($className); - - # Should generate an equivalent of Ulmus's object reflection here ! - if ( $annotation->key ) { - return $annotation; + if ( $annotation = $this->getClassAnnotations($className) ) { + # Should generate an equivalent of Ulmus's object reflection here ! + if ( $annotation->key ) { + return $annotation; + } } return null; } - protected function getClassAnnotations(string $className) : \Notes\Annotation + protected function getClassAnnotations(string $className) : ? \Notes\Annotation { $objectResolver = new ObjectResolver($className, true, true, false, true); - if ( null !== ( $object = $objectResolver->getAnnotationFromClassname( Annotation\Language::class ) ) ) { - return $object; + try { + if ( null !== ( $object = $objectResolver->getAnnotationFromClassname( Annotation\Language::class ) ) ) { + return $object; + } + } + catch(\Exception $e) { + return null; } }