function BuilderHelpers::normalizeAttribute
Normalizes a attribute: Converts attribute to the Attribute Group if needed.
Parameters
Node\Attribute|Node\AttributeGroup $attribute:
Return value
Node\AttributeGroup The Attribute Group
10 calls to BuilderHelpers::normalizeAttribute()
- ClassConst::addAttribute in vendor/
nikic/ php-parser/ lib/ PhpParser/ Builder/ ClassConst.php - Adds an attribute group.
- Class_::addAttribute in vendor/
nikic/ php-parser/ lib/ PhpParser/ Builder/ Class_.php - Adds an attribute group.
- EnumCase::addAttribute in vendor/
nikic/ php-parser/ lib/ PhpParser/ Builder/ EnumCase.php - Adds an attribute group.
- Enum_::addAttribute in vendor/
nikic/ php-parser/ lib/ PhpParser/ Builder/ Enum_.php - Adds an attribute group.
- Function_::addAttribute in vendor/
nikic/ php-parser/ lib/ PhpParser/ Builder/ Function_.php - Adds an attribute group.
File
-
vendor/
nikic/ php-parser/ lib/ PhpParser/ BuilderHelpers.php, line 305
Class
- BuilderHelpers
- This class defines helpers used in the implementation of builders. Don't use it directly.
Namespace
PhpParserCode
public static function normalizeAttribute($attribute) : Node\AttributeGroup {
if ($attribute instanceof Node\AttributeGroup) {
return $attribute;
}
if (!$attribute instanceof Node\Attribute) {
throw new \LogicException('Attribute must be an instance of PhpParser\\Node\\Attribute or PhpParser\\Node\\AttributeGroup');
}
return new Node\AttributeGroup([
$attribute,
]);
}