From 02270a6755d57042ed17eadc4c295ede90ad140e Mon Sep 17 00:00:00 2001 From: Baptiste Lafontaine Date: Wed, 15 Mar 2017 12:33:05 +0100 Subject: [PATCH] Do not use nullable result directly --- ModelDescriber/ObjectModelDescriber.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ModelDescriber/ObjectModelDescriber.php b/ModelDescriber/ObjectModelDescriber.php index 303a756..909be74 100644 --- a/ModelDescriber/ObjectModelDescriber.php +++ b/ModelDescriber/ObjectModelDescriber.php @@ -22,6 +22,8 @@ class ObjectModelDescriber implements ModelDescriberInterface, ModelRegistryAwar { use ModelRegistryAwareTrait; + private $propertyInfo; + public function __construct(PropertyInfoExtractorInterface $propertyInfo) { $this->propertyInfo = $propertyInfo; @@ -33,7 +35,12 @@ class ObjectModelDescriber implements ModelDescriberInterface, ModelRegistryAwar $properties = $schema->getProperties(); $class = $model->getType()->getClassName(); - foreach ($this->propertyInfo->getProperties($class) as $propertyName) { + $propertyInfoProperties = $this->propertyInfo->getProperties($class); + if (null === $propertyInfoProperties) { + return; + } + + foreach ($propertyInfoProperties as $propertyName) { $types = $this->propertyInfo->getTypes($class, $propertyName); if (0 === count($types)) { throw new \LogicException(sprintf('The PropertyInfo component was not able to guess the type of %s::$%s', $class, $propertyName));