class ReflectionParserDispatchTest extends TestCase (View source)

Dispatch contract for the reflection parsers' canParse().

canParse() was covered only for ReflectionEnumParser and ReflectionInterfaceParser, even though EntityReflectionObjectParsersRegistry routes every reflected object purely on its result. The three class-like parsers form a partition of AdaptedReflectionClass on (isInterface, isEnum), so the property that matters is not just "the right one accepts" but "exactly one accepts" — an overlap would make dispatch order-dependent and a gap would silently drop entities.

The remaining parsers are sub-parsers invoked directly by their owners, and return false unconditionally so they can never claim a dispatch slot. That is pinned too, because a well-meaning "implement this properly" would introduce an overlap.

Methods

testExactlyTheExpectedParserClaimsEachClassLikeShape(bool $internal, bool $interface, bool $enum, array $expected)

No description

static array
classLikeShapes()

No description

testAtMostOneParserClaimsAnyShape(bool $internal, bool $interface, bool $enum)

No overlap for any shape PHP can actually produce.

static array
allFlagCombinations()

No description

testInterfaceAndEnumIsTheOnePairThatOverlaps()

The one shape where the partition overlaps: an object reporting both isInterface() and isEnum() is claimed by the enum and the interface parser, so which one wins would depend on registration order in EntityReflectionObjectParsersRegistry.

testNoInternalClassLikeShapeIsDropped(bool $interface, bool $enum)

Every internal class-like shape PHP can actually produce must be claimed by someone.

static array
realisticInternalShapes()

No description

testClassLikeObjectsAreNotClaimedByCallableParsers()

A class-like object must never be claimed by the function or parameter parsers.

testSubParsersNeverClaimAnything(string $parserClass)

Sub-parsers are invoked directly by their owning parser, never through registry dispatch, and declare canParse() === false unconditionally. Pinned so that "implementing it properly" is a deliberate decision rather than an accident that creates an overlap.

static array
subParsers()

No description

Details

testExactlyTheExpectedParserClaimsEachClassLikeShape(bool $internal, bool $interface, bool $enum, array $expected)

No description

Parameters

bool $internal
bool $interface
bool $enum
array $expected

static array classLikeShapes()

No description

Return Value

array

testAtMostOneParserClaimsAnyShape(bool $internal, bool $interface, bool $enum)

No overlap for any shape PHP can actually produce.

The contradictory interface-and-enum shape is excluded deliberately — see testInterfaceAndEnumIsTheOnePairThatOverlaps() for why it is left out rather than asserted.

Parameters

bool $internal
bool $interface
bool $enum

static array allFlagCombinations()

No description

Return Value

array

testInterfaceAndEnumIsTheOnePairThatOverlaps()

The one shape where the partition overlaps: an object reporting both isInterface() and isEnum() is claimed by the enum and the interface parser, so which one wins would depend on registration order in EntityReflectionObjectParsersRegistry.

This is asserted as the current behaviour rather than fixed, because the shape is not reachable: across 255 internal class-likes at PHP 8.6 (6 enums, 27 interfaces) there are 0 where both flags are set, and an enum is not an interface in PHP's object model. The mutual exclusion is therefore an invariant of the reflection API rather than of these three canParse() implementations — which is worth knowing, since it means the partition is total only for as long as that holds.

testNoInternalClassLikeShapeIsDropped(bool $interface, bool $enum)

Every internal class-like shape PHP can actually produce must be claimed by someone.

Parameters

bool $interface
bool $enum

static array realisticInternalShapes()

No description

Return Value

array

testFunctionParserClaimsOnlyAdaptedFunctions()

No description

testParameterParserClaimsOnlyAdaptedParameters()

No description

testClassLikeObjectsAreNotClaimedByCallableParsers()

A class-like object must never be claimed by the function or parameter parsers.

testSubParsersNeverClaimAnything(string $parserClass)

Sub-parsers are invoked directly by their owning parser, never through registry dispatch, and declare canParse() === false unconditionally. Pinned so that "implementing it properly" is a deliberate decision rather than an accident that creates an overlap.

Parameters

string $parserClass

static array subParsers()

No description

Return Value

array