Class PHPStan\Type\NativeTypePosition

final

Where a native PHP type declaration is written, and for which PHP version.

Passed to Type::toNativePhpTypeNode(). Instead of exposing the position itself, it answers what the position allows, e.g. isCallableAllowed() is false for properties and class constants, and isNullAllowed() is false for a standalone type before PHP 8.2.

Compound types pass a derived position to their members: toUnionMember() for each member of A|B, toNullableInner() for A in ?A, toIntersectionMember() for each member of A&B. That is how e.g. an intersection type knows it can only be part of a union (DNF) since PHP 8.2.

$type->toNativePhpTypeNode(NativeTypePosition::returnType(new PhpVersion(80100)));
Methods