Skip to content

Commit

Permalink
Support of phpstan/phpdoc-parser 1.14
Browse files Browse the repository at this point in the history
  • Loading branch information
kukulich committed Dec 13, 2022
1 parent e7898e2 commit 32508da
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 3 deletions.
2 changes: 1 addition & 1 deletion SlevomatCodingStandard/Helpers/AnnotationTypeHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ public static function change(TypeNode $masterTypeNode, TypeNode $typeNodeToChan

/** @var IdentifierTypeNode $identificatorTypeNode */
$identificatorTypeNode = self::change($masterTypeNode->type, $typeNodeToChange, $changedTypeNode);
return new GenericTypeNode($identificatorTypeNode, $genericTypes);
return new GenericTypeNode($identificatorTypeNode, $genericTypes, $masterTypeNode->variances);
}

if ($masterTypeNode instanceof ArrayTypeNode) {
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"require": {
"php": "^7.2 || ^8.0",
"dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7",
"phpstan/phpdoc-parser": ">=1.11.0 <1.14.0",
"phpstan/phpdoc-parser": ">=1.14.0 <1.15.0",
"squizlabs/php_codesniffer": "^3.7.1"
},
"require-dev": {
Expand Down
15 changes: 14 additions & 1 deletion tests/Sniffs/Namespaces/ReferenceUsedNamesOnlySniffTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ public function testSearchingInAnnotations(): void
]
);

self::assertSame(56, $report->getErrorCount());
self::assertSame(59, $report->getErrorCount());

self::assertSniffError(
$report,
Expand Down Expand Up @@ -1072,6 +1072,19 @@ public function testSearchingInAnnotations(): void
'Class \Foo\Assertion should not be referenced via a fully qualified name, but via a use statement.'
);

self::assertSniffError(
$report,
229,
ReferenceUsedNamesOnlySniff::CODE_REFERENCE_VIA_FULLY_QUALIFIED_NAME,
'Class \Foo\Anything should not be referenced via a fully qualified name, but via a use statement.'
);
self::assertSniffError(
$report,
229,
ReferenceUsedNamesOnlySniff::CODE_REFERENCE_VIA_FULLY_QUALIFIED_NAME,
'Class \Foo\Something should not be referenced via a fully qualified name, but via a use statement.'
);

self::assertAllFixedInFile($report);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,3 +243,13 @@ public function psalmAssertIfFalse($parameter)
}

}

class GenericTypeProjections
{
/**
* @param Anything<covariant Something, Something> $parameter
*/
public function covariant($parameter)
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -222,3 +222,13 @@ public function psalmAssertIfFalse($parameter)
}

}

class GenericTypeProjections
{
/**
* @param \Foo\Anything<covariant \Foo\Something, \Foo\Something> $parameter
*/
public function covariant($parameter)
{
}
}

0 comments on commit 32508da

Please sign in to comment.