diff --git a/SlevomatCodingStandard/Sniffs/TypeHints/TypeHintDeclarationSniff.php b/SlevomatCodingStandard/Sniffs/TypeHints/TypeHintDeclarationSniff.php index 294ed12ba..d78112239 100644 --- a/SlevomatCodingStandard/Sniffs/TypeHints/TypeHintDeclarationSniff.php +++ b/SlevomatCodingStandard/Sniffs/TypeHints/TypeHintDeclarationSniff.php @@ -915,14 +915,6 @@ private function getFunctionParameterTypeHintsDefinitions(\PHP_CodeSniffer\Files private function typeHintEqualsAnnotation(\PHP_CodeSniffer\Files\File $phpcsFile, int $functionPointer, string $typeHint, string $typeHintInAnnotation): bool { - if (TypeHintHelper::isSimpleTypeHint($typeHint)) { - return true; - } - - if ($typeHint === 'object') { - return $this->enableObjectTypeHint; - } - return TypeHintHelper::getFullyQualifiedTypeHint($phpcsFile, $functionPointer, $typeHint) === TypeHintHelper::getFullyQualifiedTypeHint($phpcsFile, $functionPointer, $typeHintInAnnotation); } diff --git a/tests/Sniffs/TypeHints/data/typeHintDeclarationEnabledObjectTypeHintNoErrors.php b/tests/Sniffs/TypeHints/data/typeHintDeclarationEnabledObjectTypeHintNoErrors.php index 74f097ce7..f670f5b39 100644 --- a/tests/Sniffs/TypeHints/data/typeHintDeclarationEnabledObjectTypeHintNoErrors.php +++ b/tests/Sniffs/TypeHints/data/typeHintDeclarationEnabledObjectTypeHintNoErrors.php @@ -45,4 +45,36 @@ public function returnsNullableArrayOfObjects(): ?array return []; } + /** + * @param \DateTimeImmutable $object + */ + public function parameterObjectTypeVariance(object $object) + { + + } + + /** + * @param \DateTimeImmutable|null $object + */ + public function parameterNullableObjectTypeVariance(?object $object) + { + + } + + /** + * @return \DateTimeImmutable + */ + public function returnsObjectTypeVariance(): object + { + + } + + /** + * @return \DateTimeImmutable|null + */ + public function returnsNullableObjectTypeVariance(): ?object + { + + } + }