class FunctionPhpDocConformsSignatureCheck extends AbstractCallableCheck (View source)

Validates that PhpDoc types in stubs are compatible with their signature types for global functions.

This is a stubs-only check (reflection data is never used). For each function identified by $entityId the validator:

  1. Looks up the function in stubs using version-aware selection.
  2. If not found, silently succeeds — FunctionExistsCheck handles absence.
  3. For both return type and each parameter, compares the signature type with the PhpDoc type using the permissive compatibility algorithm in PhpDocConformanceTrait.
  4. Reports mismatches where sig and PhpDoc types share no common component.

Intentional patterns (typed-array narrowing, phpstan generics, resource widening, bool/false split) are accepted by the algorithm and will not be reported.

Known problems are supported at function level:

  • EntityType::FUNCTION + functionId + 'PhpDocConformsSignatureCheck' → skips the check for that specific function.

Properties

protected ReflectionProviderInterface $reflectionProvider from  AbstractReflectionCheck
protected KnownProblemsRegistry $knownProblemsRegistry from  AbstractReflectionCheck
protected EntityLookupService $entityLookup from  AbstractCallableCheck

Methods

__construct(ReflectionProviderInterface|null $reflectionProvider = null, KnownProblemsRegistry|null $knownProblemsRegistry = null, PhpDocConformanceService|null $conformanceService = 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.

findCallable(StubDataQueryInterface $storage, string $entityId, string $phpVersion)

Find a function or method in the given storage.

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, PhpDocConformanceService|null $conformanceService = null)

No description

Parameters

ReflectionProviderInterface|null $reflectionProvider
KnownProblemsRegistry|null $knownProblemsRegistry
PhpDocConformanceService|null $conformanceService

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 PHPFunction|null findCallable(StubDataQueryInterface $storage, string $entityId, string $phpVersion)

Find a function or method in the given storage.

Parameters

StubDataQueryInterface $storage
string $entityId

Format: "functionName" or "ClassName::methodName"

string $phpVersion

Return Value

PHPFunction|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