From c6b3fc512fee5f4dd221be07dda65889104313ff Mon Sep 17 00:00:00 2001 From: Matthew Brown Date: Sun, 10 Feb 2019 16:32:30 -0500 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20throw=20exception=20when=20igno?= =?UTF-8?q?ring=20trait=20absence?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Psalm/Internal/Analyzer/ClassAnalyzer.php | 7 ++++++- tests/TraitTest.php | 7 +++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Psalm/Internal/Analyzer/ClassAnalyzer.php b/src/Psalm/Internal/Analyzer/ClassAnalyzer.php index ed4db33ef..5f087dd3a 100644 --- a/src/Psalm/Internal/Analyzer/ClassAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/ClassAnalyzer.php @@ -636,7 +636,12 @@ class ClassAnalyzer extends ClassLikeAnalyzer $this->source->getAliases() ); - $trait_file_analyzer = $project_analyzer->getFileAnalyzerForClassLike($fq_trait_name); + try { + $trait_file_analyzer = $project_analyzer->getFileAnalyzerForClassLike($fq_trait_name); + } catch (\Exception $e) { + continue; + } + $trait_node = $codebase->classlikes->getTraitNode($fq_trait_name); $trait_aliases = $codebase->classlikes->getTraitAliases($fq_trait_name); $trait_analyzer = new TraitAnalyzer( diff --git a/tests/TraitTest.php b/tests/TraitTest.php index 6a1f831c6..26e8eef54 100644 --- a/tests/TraitTest.php +++ b/tests/TraitTest.php @@ -780,6 +780,13 @@ class TraitTest extends TestCase } }' ], + 'noCrashOnUndefinedIgnoredTrait' => [ + '