Skip to content

Commit

Permalink
Improve error message during get magic props
Browse files Browse the repository at this point in the history
  • Loading branch information
jaapio committed Jan 16, 2020
1 parent 0eaf50e commit f9daca1
Showing 1 changed file with 25 additions and 11 deletions.
36 changes: 25 additions & 11 deletions src/phpDocumentor/Descriptor/ClassDescriptor.php
Expand Up @@ -13,9 +13,11 @@

namespace phpDocumentor\Descriptor;

use InvalidArgumentException;
use phpDocumentor\Descriptor\Tag\BaseTypes\TypedVariableAbstract;
use phpDocumentor\Reflection\Fqsen;
use function ltrim;
use function sprintf;

/**
* Descriptor representing a Class.
Expand Down Expand Up @@ -275,18 +277,30 @@ public function getMagicProperties() : Collection

$properties = new Collection();

/** @var Tag\PropertyDescriptor $propertyTag */
foreach ($propertyTags as $propertyTag) {
if (!$propertyTag instanceof TypedVariableAbstract) {
continue;
try {
/** @var Tag\PropertyDescriptor $propertyTag */
foreach ($propertyTags as $propertyTag) {
if (!$propertyTag instanceof TypedVariableAbstract) {
continue;
}
$property = new PropertyDescriptor();
$property->setName(ltrim($propertyTag->getVariableName(), '$'));
$property->setDescription($propertyTag->getDescription());
$property->setType($propertyTag->getType());
$property->setParent($this);

$properties->add($property);
}
$property = new PropertyDescriptor();
$property->setName(ltrim($propertyTag->getVariableName(), '$'));
$property->setDescription($propertyTag->getDescription());
$property->setType($propertyTag->getType());
$property->setParent($this);

$properties->add($property);
} catch (InvalidArgumentException $e) {
throw new InvalidArgumentException(
sprintf(
'Failed to get magic properties from "%s": %s',
$this->getFullyQualifiedStructuralElementName(),
$e->getMessage()
),
0,
$e
);
}

if ($this->getParent() instanceof self) {
Expand Down

0 comments on commit f9daca1

Please sign in to comment.