From 6a281c0c9c8697b345aa59b73701a5030a61d546 Mon Sep 17 00:00:00 2001 From: Daniel Leech Date: Thu, 24 Dec 2020 15:43:45 +0000 Subject: [PATCH] Do not try and read from potentially nullable AST node --- .../Collection/ReflectionInterfaceCollection.php | 8 +++++++- .../Collection/ReflectionPropertyCollection.php | 9 ++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/Bridge/TolerantParser/Reflection/Collection/ReflectionInterfaceCollection.php b/lib/Bridge/TolerantParser/Reflection/Collection/ReflectionInterfaceCollection.php index 4d469e13b..b6ecbfa27 100644 --- a/lib/Bridge/TolerantParser/Reflection/Collection/ReflectionInterfaceCollection.php +++ b/lib/Bridge/TolerantParser/Reflection/Collection/ReflectionInterfaceCollection.php @@ -34,7 +34,13 @@ private static function fromBaseClause(ServiceLocator $serviceLocator, $baseClau } $items = []; - $children = $baseClause->interfaceNameList->children; + $nameList = $baseClause->interfaceNameList; + + if (!$nameList) { + return new self($serviceLocator, []); + } + + $children = $nameList->children; if (!$children) { return new self($serviceLocator, []); diff --git a/lib/Bridge/TolerantParser/Reflection/Collection/ReflectionPropertyCollection.php b/lib/Bridge/TolerantParser/Reflection/Collection/ReflectionPropertyCollection.php index 18662d49a..b2e6aa21a 100644 --- a/lib/Bridge/TolerantParser/Reflection/Collection/ReflectionPropertyCollection.php +++ b/lib/Bridge/TolerantParser/Reflection/Collection/ReflectionPropertyCollection.php @@ -41,7 +41,14 @@ public static function fromClassDeclarationConstructorPropertyPromotion( continue; } - $children = $classMember->parameters->children; + $parameters = $classMember->parameters; + + if (!$parameters) { + continue; + } + + $children = $parameters->children; + if (!$children) { continue; }