Skip to content

Commit 823ba04

Browse files
committed
TypeHintDeclarationSniff: fixed object type variance
1 parent 60eee4e commit 823ba04

File tree

2 files changed

+32
-8
lines changed

2 files changed

+32
-8
lines changed

SlevomatCodingStandard/Sniffs/TypeHints/TypeHintDeclarationSniff.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -915,14 +915,6 @@ private function getFunctionParameterTypeHintsDefinitions(\PHP_CodeSniffer\Files
915915

916916
private function typeHintEqualsAnnotation(\PHP_CodeSniffer\Files\File $phpcsFile, int $functionPointer, string $typeHint, string $typeHintInAnnotation): bool
917917
{
918-
if (TypeHintHelper::isSimpleTypeHint($typeHint)) {
919-
return true;
920-
}
921-
922-
if ($typeHint === 'object') {
923-
return $this->enableObjectTypeHint;
924-
}
925-
926918
return TypeHintHelper::getFullyQualifiedTypeHint($phpcsFile, $functionPointer, $typeHint) === TypeHintHelper::getFullyQualifiedTypeHint($phpcsFile, $functionPointer, $typeHintInAnnotation);
927919
}
928920

tests/Sniffs/TypeHints/data/typeHintDeclarationEnabledObjectTypeHintNoErrors.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,36 @@ public function returnsNullableArrayOfObjects(): ?array
4545
return [];
4646
}
4747

48+
/**
49+
* @param \DateTimeImmutable $object
50+
*/
51+
public function parameterObjectTypeVariance(object $object)
52+
{
53+
54+
}
55+
56+
/**
57+
* @param \DateTimeImmutable|null $object
58+
*/
59+
public function parameterNullableObjectTypeVariance(?object $object)
60+
{
61+
62+
}
63+
64+
/**
65+
* @return \DateTimeImmutable
66+
*/
67+
public function returnsObjectTypeVariance(): object
68+
{
69+
70+
}
71+
72+
/**
73+
* @return \DateTimeImmutable|null
74+
*/
75+
public function returnsNullableObjectTypeVariance(): ?object
76+
{
77+
78+
}
79+
4880
}

0 commit comments

Comments
 (0)