[ticket/17496] Unused use statements sniffer to check union types

PHPBB-17496
This commit is contained in:
rxu 2025-04-15 13:22:59 +07:00
parent 0c08838b29
commit 7b7a2522df
No known key found for this signature in database
GPG key ID: 8117904FEDEFDD17

View file

@ -49,7 +49,9 @@ class phpbb_Sniffs_Namespaces_UnusedUseSniff implements Sniff
$phpcsFile->addError($error, $stack_pointer, 'FullName'); $phpcsFile->addError($error, $stack_pointer, 'FullName');
} }
if ($found_name === $short_name) // Check for possible union types like string|MyType|null
$types = explode('|', $found_name);
if (in_array($short_name, $types, true))
{ {
return true; return true;
} }