class ClassMethodsParameterDefaultValueCheck extends AbstractMemberFlagCheck implements DescribesMethodMismatch (View source)

Validates that default parameter values in stub methods match those in reflection.

Only runs against the latest PHP version since stubs do not support version-aware default values (there is no LanguageLevelTypeAware equivalent for defaults).

For each class identified by $entityId the validator:

  1. Iterates all methods reported by reflection.
  2. For each reflection parameter that has an accessible default value, checks whether the stub parameter declares a matching evaluated default.
  3. Comparison is skipped when either side's value is null — this avoids false positives from stub constants that cannot be evaluated at parse time (e.g. extension-specific constants) and from genuine null defaults whose ambiguity we cannot resolve without a richer model.
  4. Parameter absent from stubs → silently skipped (ParametersCountCheck handles it).
  5. Stub has no default at all → silently skipped (OptionalParametersCheck handles it).

Known problems are supported at two granularities:

  • class-level: EntityType::CLASS_TYPE + classId + 'ParameterDefaultValueCheck'
  • method-level: EntityType::METHOD + '\ClassName::methodName' + 'ParameterDefaultValueCheck'

Constants

private FUNCTION_LOOKUP_UNSUPPORTED

private NO_DESCRIBER

Properties

protected ReflectionProviderInterface $reflectionProvider from  AbstractReflectionCheck
protected KnownProblemsRegistry $knownProblemsRegistry from  AbstractReflectionCheck
protected EntityLookupService $entityLookup from  AbstractClassCheck
protected MethodCollectionService $methodCollection from  AbstractClassCheck
protected EntityTypeConfig|null $entityTypeConfig from  AbstractClassCheck

Methods

__construct(ReflectionProviderInterface|null $reflectionProvider = null, KnownProblemsRegistry|null $knownProblemsRegistry = null, EntityLookupService|null $entityLookup = null, MethodCollectionService|null $methodCollection = null, EntityTypeConfig|null $entityTypeConfig = null)

No description

bool
skipWithKnownProblem(CheckResultSet $results, string $entityType, string $entityId, CheckType $checkType, string $phpVersion)

Records a skipped-success result if a known problem covers this entity, and returns true.

lookupEntityById(StubDataQueryInterface $storage, string $entityId)

Look up an entity by ID, dispatching to the right lookup method based on config.

array
collectEntityMethodsByConfig(PHPClassLikeObject $entity, string $phpVersion)

Collect version-filtered methods, dispatching based on config.

array
collectEntityPropertiesByConfig(PHPClassLikeObject $entity, string $phpVersion)

Collect version-filtered properties, dispatching based on config.

string
getEntityLabel()

No description

string
getEntityType()

No description

string
getConstantEntityType()

No description

PHPClass|null
findClassById(StubDataQueryInterface $storage, string $entityId)

No description

PHPEnum|null
findEnumById(StubDataQueryInterface $storage, string $entityId)

No description

findInterfaceById(StubDataQueryInterface $storage, string $entityId)

No description

CheckType
getCheckName()

No description

MemberKind
memberKind()

Which member kind this check compares. Supplies the id format, the known-problem entity type and the reflection-member accessor, all of which used to be one-line abstract hooks.

bool
supports(string $phpVersion)

No description

run(StubDataQueryInterface $stubs, string $entityId, string $phpVersion)

No description

string|null
describeMethodMismatch(string $methodEntityId, PHPMethod $reflMethod, PHPMethod $stubMethod, string $phpVersion)

Compare an attribute on the reflection and stub method.

Details

__construct(ReflectionProviderInterface|null $reflectionProvider = null, KnownProblemsRegistry|null $knownProblemsRegistry = null, EntityLookupService|null $entityLookup = null, MethodCollectionService|null $methodCollection = null, EntityTypeConfig|null $entityTypeConfig = null)

No description

Parameters

ReflectionProviderInterface|null $reflectionProvider
KnownProblemsRegistry|null $knownProblemsRegistry
EntityLookupService|null $entityLookup
MethodCollectionService|null $methodCollection
EntityTypeConfig|null $entityTypeConfig

protected bool skipWithKnownProblem(CheckResultSet $results, string $entityType, string $entityId, CheckType $checkType, string $phpVersion)

Records a skipped-success result if a known problem covers this entity, and returns true.

Returns false if validation should proceed normally.

Parameters

CheckResultSet $results
string $entityType
string $entityId
CheckType $checkType
string $phpVersion

Return Value

bool

protected PHPClassLikeObject|null lookupEntityById(StubDataQueryInterface $storage, string $entityId)

Look up an entity by ID, dispatching to the right lookup method based on config.

Defaults to class lookup when no config is set.

Parameters

StubDataQueryInterface $storage
string $entityId

Return Value

PHPClassLikeObject|null

protected array collectEntityMethodsByConfig(PHPClassLikeObject $entity, string $phpVersion)

Collect version-filtered methods, dispatching based on config.

Defaults to class hierarchy traversal when no config is set.

Parameters

PHPClassLikeObject $entity
string $phpVersion

Return Value

array

protected array collectEntityPropertiesByConfig(PHPClassLikeObject $entity, string $phpVersion)

Collect version-filtered properties, dispatching based on config.

Only classes have properties; returns empty array for enum/interface.

Parameters

PHPClassLikeObject $entity
string $phpVersion

Return Value

array

protected string getEntityLabel()

No description

Return Value

string

protected string getEntityType()

No description

Return Value

string

protected string getConstantEntityType()

No description

Return Value

string

protected PHPClass|null findClassById(StubDataQueryInterface $storage, string $entityId)

No description

Parameters

StubDataQueryInterface $storage
string $entityId

Return Value

PHPClass|null

protected PHPEnum|null findEnumById(StubDataQueryInterface $storage, string $entityId)

No description

Parameters

StubDataQueryInterface $storage
string $entityId

Return Value

PHPEnum|null

protected PHPInterface|null findInterfaceById(StubDataQueryInterface $storage, string $entityId)

No description

Parameters

StubDataQueryInterface $storage
string $entityId

Return Value

PHPInterface|null

protected CheckType getCheckName()

No description

Return Value

CheckType

protected MemberKind memberKind()

Which member kind this check compares. Supplies the id format, the known-problem entity type and the reflection-member accessor, all of which used to be one-line abstract hooks.

Return Value

MemberKind

bool supports(string $phpVersion)

No description

Parameters

string $phpVersion

Return Value

bool

CheckResultSet run(StubDataQueryInterface $stubs, string $entityId, string $phpVersion)

No description

Parameters

StubDataQueryInterface $stubs

Parsed stubs data

string $entityId

Entity identifier to validate

string $phpVersion

PHP version string

Return Value

CheckResultSet

string|null describeMethodMismatch(string $methodEntityId, PHPMethod $reflMethod, PHPMethod $stubMethod, string $phpVersion)

Compare an attribute on the reflection and stub method.

Return a descriptive failure message if there is a mismatch, or null if they match.

Both sides are PHPMethod: the reflection half is read back out of the reflection cache into the same model as the stub half, and MemberKind::METHOD only ever yields PHPClassLikeObject::getMethods(). Declaring it rather than mixed is the whole point of this interface — it lets the 12 leaves state a concrete signature instead of narrowing an inherited one — and it matches DescribesPropertyMismatch, which types both sides PHPProperty. AbstractMemberFlagCheck dispatches through a mixed argument, so a wrong type now surfaces as a TypeError here instead of a silently skipped comparison.

Parameters

string $methodEntityId
PHPMethod $reflMethod
PHPMethod $stubMethod
string $phpVersion

Return Value

string|null