Skip to content

Commit

Permalink
defined() without string cannot be resolved and will be ignored
Browse files Browse the repository at this point in the history
  • Loading branch information
llaville committed Sep 29, 2020
1 parent ec2718c commit 83492c2
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ public function normalize($node, $format = null, array $context = [])
);
}

if (empty($this->name)) {
// indirect called cannot be resolved and will be ignored
return null;
}

$attributeParentKey = $context['nodeAttributeParentKeyStore'] ?? 'bartlett.parent';
$attributeKey = $context['nodeAttributeKeyStore'] ?? 'bartlett.data_collector';

Expand Down Expand Up @@ -124,7 +129,13 @@ public function supportsNormalization($data, $format = null)
$this->name = (string) $data->getAttribute($this->attributeNamespacedName);
}
} elseif ($this->isConstantDefineExpression($data)) {
$this->name = $data->args[0]->value->value;
$name = $data->args[0]->value;
if ($name instanceof Node\Scalar\String_) {
$this->name = $name->value;
} else {
// indirect constant naming is not resolved
$this->name = '';
}
} elseif ($data->hasAttribute($this->attributeNamespacedName)) {
$this->name = (string) $data->getAttribute($this->attributeNamespacedName);
} elseif (property_exists($data, 'name')) {
Expand Down

0 comments on commit 83492c2

Please sign in to comment.