class ClassMethodsParametersCountCheck extends AbstractMethodFlagCheck (View source)

Validates that the number of parameters in stub methods matches reflection.

For each class identified by $entityId the validator:

  1. Iterates all methods reported by reflection for the class.
  2. Looks up each method in the version-filtered stub hierarchy (parent classes and interfaces), stripping PS_UNRESERVEPREFIX where needed.
  3. If the stub method is not found it is silently skipped — existence is ClassMethodsExistCheck's responsibility.
  4. When both sides are found, the stub parameter list is filtered by version (PhpStormStubsElementAvailable from/to → sinceVersion/removedVersion) and the resulting count is compared with the reflection count.

Parameter version filtering uses inclusive boundaries for removedVersion (<=), consistent with how PhpStormStubsElementAvailable to is interpreted elsewhere (e.g. to: '7.1' means the parameter is still available in PHP 7.1).

Parameters are deduplicated by name after version filtering. When a version-bounded placeholder and a variadic share the same name (e.g. a to: '7.4' placeholder $vars followed by ...$vars), they represent a single mandatory variadic parameter and are counted once.

Known problems are supported at two granularities:

  • class-level: EntityType::CLASS_TYPE + classId + 'ParametersCountCheck' → skips all parameter-count checks for the class.
  • method-level: EntityType::METHOD + '\ClassName::methodName' + 'ParametersCountCheck' → skips only that specific mismatch.

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, string $checkName, 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

string
getCheckName()

No description

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

Compare a flag on the reflection and stub method.

bool
supports(string $phpVersion)

No description

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

No description

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, string $checkName, 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
string $checkName
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 string getCheckName()

No description

Return Value

string

protected string|null describeMismatch(string $methodEntityId, mixed $reflMethod, PHPMethod $stubMethod, string $phpVersion)

Compare a flag on the reflection and stub method.

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

Parameters

string $methodEntityId
mixed $reflMethod

reflection method object

PHPMethod $stubMethod
string $phpVersion

Return Value

string|null

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