ClassMethodsPhpDocConformsSignatureCheck
class ClassMethodsPhpDocConformsSignatureCheck extends AbstractClassCheck (View source)
Validates that PhpDoc types in class stubs are compatible with their signature types.
This is a stubs-only check (reflection data is never used). For each class identified by $entityId the validator:
- Looks up the class in stubs. If not found, silently succeeds.
- Iterates all version-available stub methods: checks return type and each parameter type for PhpDoc/signature compatibility.
- Iterates all version-available stub properties: checks declared type vs PhpDoc type.
- 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 three granularities:
- entity-level: entityType + entityId + 'PhpDocConformsSignatureCheck' → skips all method/property checks for the entity.
- method-level: EntityType::METHOD + 'ClassName::methodName' + 'PhpDocConformsSignatureCheck' → skips only that specific method.
- property-level: EntityType::PROPERTY + 'ClassName::$propName' + 'PhpDocConformsSignatureCheck' → skips only that specific property.
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
No description
Records a skipped-success result if a known problem covers this entity, and returns true.
Look up an entity by ID, dispatching to the right lookup method based on config.
Collect version-filtered methods, dispatching based on config.
Collect version-filtered properties, dispatching based on config.
No description
Details
__construct(ReflectionProviderInterface|null $reflectionProvider = null, KnownProblemsRegistry|null $knownProblemsRegistry = null, EntityLookupService|null $entityLookupService = null, MethodCollectionService|null $methodCollectionService = null, EntityTypeConfig|null $entityTypeConfig = null, PhpDocConformanceService|null $conformanceService = null)
No description
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.
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.
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.
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.
protected string
getEntityLabel()
No description
protected string
getEntityType()
No description
protected string
getConstantEntityType()
No description
protected PHPClass|null
findClassById(StubDataQueryInterface $storage, string $entityId)
No description
protected PHPEnum|null
findEnumById(StubDataQueryInterface $storage, string $entityId)
No description
protected PHPInterface|null
findInterfaceById(StubDataQueryInterface $storage, string $entityId)
No description
bool
supports(string $phpVersion)
No description
CheckResultSet
run(StubDataQueryInterface $stubs, string $entityId, string $phpVersion)
No description