[ticket/17512] Fix handling tokens with no/empty type hint

PHPBB-17512
This commit is contained in:
rxu 2025-05-15 17:02:03 +07:00
parent 7a4b3f52ae
commit c01d1967dd
No known key found for this signature in database
GPG key ID: 8117904FEDEFDD17

View file

@ -67,6 +67,11 @@ class UnionTypesCheckSniff implements Sniff
public function check_union_type(File $phpcsFile, $stack_pointer, $type_hint) public function check_union_type(File $phpcsFile, $stack_pointer, $type_hint)
{ {
if (empty($type_hint))
{
return;
}
if (!strpos($type_hint, '|') && $type_hint[0] == '?') // Check nullable shortcut syntax if (!strpos($type_hint, '|') && $type_hint[0] == '?') // Check nullable shortcut syntax
{ {
$type = substr($type_hint, 1); $type = substr($type_hint, 1);