From c01d1967ddc9ecf08c2e6e25a5a8c4048388118c Mon Sep 17 00:00:00 2001 From: rxu Date: Thu, 15 May 2025 17:02:03 +0700 Subject: [PATCH] [ticket/17512] Fix handling tokens with no/empty type hint PHPBB-17512 --- .../phpbb/Sniffs/CodeLayout/UnionTypesCheckSniff.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/build/code_sniffer/phpbb/Sniffs/CodeLayout/UnionTypesCheckSniff.php b/build/code_sniffer/phpbb/Sniffs/CodeLayout/UnionTypesCheckSniff.php index 7092c07b31..89ea31efcc 100644 --- a/build/code_sniffer/phpbb/Sniffs/CodeLayout/UnionTypesCheckSniff.php +++ b/build/code_sniffer/phpbb/Sniffs/CodeLayout/UnionTypesCheckSniff.php @@ -67,6 +67,11 @@ class UnionTypesCheckSniff implements Sniff 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 { $type = substr($type_hint, 1);