Skip to content

Commit 40ebfc0

Browse files
committed
Improve #12
1 parent c5d0308 commit 40ebfc0

File tree

2 files changed

+7
-19
lines changed

2 files changed

+7
-19
lines changed

Inpsyde/PhpcsHelpers.php

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -501,11 +501,7 @@ public static function isVoidReturn(File $file, int $returnPosition): bool
501501
$returnPosition = $nextToReturn + 1;
502502
$followedBySemicolon = ($tokens[$returnPosition]['code'] ?? '') === T_SEMICOLON;
503503

504-
if (!$followedBySemicolon) {
505-
return false;
506-
}
507-
508-
return true;
504+
return $followedBySemicolon;
509505
}
510506

511507
/**
@@ -522,21 +518,9 @@ public static function isNullReturn(File $file, int $returnPosition): bool
522518
}
523519

524520
$returnPosition++;
525-
$nextToReturn = $file->findNext([T_WHITESPACE], $returnPosition, null, true, null, true);
526-
$nextToReturnType = $tokens[$nextToReturn]['code'] ?? '';
527-
528-
if ($nextToReturnType !== T_NULL) {
529-
return false;
530-
}
531-
532-
$returnPosition = $nextToReturn + 1;
533-
$followedBySemicolon = ($tokens[$returnPosition]['code'] ?? '') === T_SEMICOLON;
534-
535-
if (!$followedBySemicolon) {
536-
return false;
537-
}
521+
$nextToReturn = $file->findNext([T_WHITESPACE, T_NULL], $returnPosition, null, true, null, true);
538522

539-
return true;
523+
return ($tokens[$nextToReturn]['code'] ?? '') === T_SEMICOLON;
540524
}
541525

542526
/**

tests/fixtures/return-type-declaration.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ function h(): void
6363
return null === true;
6464
}
6565

66+
function hh(): void {
67+
return null;
68+
}
69+
6670
function gen(string $content): \Generator
6771
{
6872
$line = strtok($content, "\n");

0 commit comments

Comments
 (0)