File tree Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -148,8 +148,7 @@ public function process(File $phpCsFile, $stackPointer): void
148148
149149 if ($ methodSignatureValue ['nullable ' ]) {
150150 $ type = 'null ' ;
151-
152- if (!in_array ($ type , $ parts , true )) {
151+ if (!in_array ($ type , $ parts , true ) && !$ this ->hasShorthand ($ parts )) {
153152 $ parts [] = $ type ;
154153 $ error = 'Doc block error: ` ' . $ content . '` seems to be missing type ` ' . $ type . '`. ' ;
155154 $ fix = $ phpCsFile ->addFixableError ($ error , $ classNameIndex , 'Nullable ' );
@@ -262,4 +261,20 @@ protected function isClassString(string $type, array $parts): bool
262261
263262 return false ;
264263 }
264+
265+ /**
266+ * @param array<string> $parts
267+ *
268+ * @return bool
269+ */
270+ protected function hasShorthand (array $ parts ): bool
271+ {
272+ foreach ($ parts as $ part ) {
273+ if (str_starts_with ($ part , '? ' )) {
274+ return true ;
275+ }
276+ }
277+
278+ return false ;
279+ }
265280}
You can’t perform that action at this time.
0 commit comments