Skip to content

Commit

Permalink
Merge pull request #1706 from PHPCompatibility/feature/interfaces-new…
Browse files Browse the repository at this point in the history
…interfaces-bugfix

Interfaces/NewInterfaces: bug fix - check all parts of a type
  • Loading branch information
wimg committed Apr 21, 2024
2 parents 192c5a4 + 10cb6f9 commit 40ae925
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions PHPCompatibility/Sniffs/Interfaces/NewInterfacesSniff.php
Expand Up @@ -452,12 +452,12 @@ private function checkTypeDeclaration($phpcsFile, $stackPtr, $typeHint)
$type = \ltrim($type, '\\');

if ($type === '') {
return;
continue;
}

$typeLc = \strtolower($type);
if (isset($this->newInterfaces[$typeLc]) === false) {
return;
continue;
}

$itemInfo = [
Expand Down
4 changes: 4 additions & 0 deletions PHPCompatibility/Tests/Interfaces/NewInterfacesUnitTest.inc
Expand Up @@ -199,6 +199,10 @@ function ExpectsEnumParams(UnitEnum $enum1, BackedEnum $enum2) {}

function useRandomExtension( Random\Engine $paramA, Random\CryptoSafeEngine $paramB ) {}

function CheckAllTypeParts(
NotATarget|Stringable $a
) : NotATarget|DOMParentNode {}

// Test parse error/live coding.
// This MUST be the last test in the file!
try {
Expand Down
6 changes: 3 additions & 3 deletions PHPCompatibility/Tests/Interfaces/NewInterfacesUnitTest.php
Expand Up @@ -79,9 +79,9 @@ public static function dataNewInterface()
['SessionIdInterface', '5.5.0', [89, 117, 146], '5.6', '5.5'],
['Throwable', '5.6', [37, 52, 62, 93, 98, 103, 162, 186], '7.0'],
['SessionUpdateTimestampHandlerInterface', '5.6', [90, 142, 162], '7.0'],
['Stringable', '7.4', [112, 179], '8.0'],
['Stringable', '7.4', [112, 179, 203], '8.0'],
['DOMChildNode', '7.4', [196], '8.0'],
['DOMParentNode', '7.4', [196], '8.0'],
['DOMParentNode', '7.4', [196, 204], '8.0'],
['UnitEnum', '8.0', [198], '8.1'],
['BackedEnum', '8.0', [198], '8.1'],
['Random\Engine', '8.1', [200], '8.2'],
Expand Down Expand Up @@ -218,7 +218,7 @@ public static function dataNoFalsePositives()
[177],
[185],
[189],
[205],
[209],
];
}

Expand Down

0 comments on commit 40ae925

Please sign in to comment.