mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-07 20:08:53 +00:00
[ticket/17496] Sniffer to support question mark nullable type syntax
PHPBB-17496
This commit is contained in:
parent
a5113d7cd3
commit
1b08a74508
1 changed files with 12 additions and 3 deletions
|
@ -49,11 +49,20 @@ class phpbb_Sniffs_Namespaces_UnusedUseSniff implements Sniff
|
||||||
$phpcsFile->addError($error, $stack_pointer, 'FullName');
|
$phpcsFile->addError($error, $stack_pointer, 'FullName');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for possible union types like string|MyType|null
|
/*
|
||||||
|
* Check for possible union types (like string|MyType|null)
|
||||||
|
* and question mark nullable type syntax (like ?MyType)
|
||||||
|
*/
|
||||||
$types = explode('|', $found_name);
|
$types = explode('|', $found_name);
|
||||||
if (in_array($short_name, $types, true))
|
foreach ($types as $type)
|
||||||
{
|
{
|
||||||
return true;
|
// Nullable type syntax
|
||||||
|
$type = (strpos($type, '?') === 0) ? substr($type, 1) : $type;
|
||||||
|
|
||||||
|
if ($short_name === $type)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Add table
Reference in a new issue