PropertyNode
interface PropertyNode (View source)
Parser-agnostic interface for property AST nodes.
Exposes all property attributes needed for complete parsing.
Methods
Get the property name.
Check if the property is public.
Check if the property is protected.
Check if the property is private.
Check if the property is static.
Check if the property is readonly (PHP 8.1+).
Get the doc comment, or null if no doc comment.
Get the property attributes (PHP 8.0+).
Whether the property has a default value, matching ReflectionProperty::hasDefaultValue().
Evaluate and return the property's default value.
Details
string
getName()
Get the property name.
bool
isPublic()
Check if the property is public.
bool
isProtected()
Check if the property is protected.
bool
isPrivate()
Check if the property is private.
bool
isStatic()
Check if the property is static.
bool
isReadonly()
Check if the property is readonly (PHP 8.1+).
TypeNode|null
getType()
Get the property type, or null if no type hint.
DocCommentNode|null
getDocComment()
Get the doc comment, or null if no doc comment.
array
getAttributes()
Get the property attributes (PHP 8.0+).
bool
hasDefaultValue()
Whether the property has a default value, matching ReflectionProperty::hasDefaultValue().
Note the asymmetry between typed and untyped properties, which is why this is NOT simply "an initializer is present in the source":
public $a;untyped, no initializer => true (implicit null default)public $b = 5;untyped, initializer => truepublic int $c;typed, no initializer => false (uninitialized)public int $d = 7;typed, initializer => true
Reflection reports no untyped property as lacking a default, so an implementation that only checked for an initializer would disagree with reflection on every untyped property.
mixed
getDefaultValue()
Evaluate and return the property's default value.
Returns null for an untyped property with no initializer — that is its genuine
PHP default, even though the runtime may report a different value for an internal
class whose C declaration specifies one (e.g. \Exception::$message is protected $message; in the stubs but "" at runtime). Such a difference is a real
stub/runtime discrepancy, not an artifact of this method.