-
Notifications
You must be signed in to change notification settings - Fork 467
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Too-wide return type - do not report void in PHPDoc union type
- Loading branch information
1 parent
b1b7782
commit 5f0b1cc
Showing
6 changed files
with
128 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
tests/PHPStan/Rules/TooWideTypehints/data/bug-11980-function.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
namespace Bug11980Function; | ||
|
||
/** | ||
* @param array<int, array<string, int>> $tokens | ||
* @param int $stackPtr | ||
* | ||
* @return int|void | ||
*/ | ||
function process($tokens, $stackPtr) | ||
{ | ||
if (empty($tokens[$stackPtr]['nested_parenthesis']) === false) { | ||
// Not a stand-alone statement. | ||
return; | ||
} | ||
|
||
$end = 10; | ||
|
||
if ($tokens[$end]['code'] !== 10 | ||
&& $tokens[$end]['code'] !== 20 | ||
) { | ||
// Not a stand-alone statement. | ||
return $end; | ||
} | ||
} | ||
|
||
/** | ||
* @param array<int, array<string, int>> $tokens | ||
* @param int $stackPtr | ||
* | ||
* @return int|void | ||
*/ | ||
function process2($tokens, $stackPtr) | ||
{ | ||
if (empty($tokens[$stackPtr]['nested_parenthesis']) === false) { | ||
// Not a stand-alone statement. | ||
return null; | ||
} | ||
|
||
$end = 10; | ||
|
||
if ($tokens[$end]['code'] !== 10 | ||
&& $tokens[$end]['code'] !== 20 | ||
) { | ||
// Not a stand-alone statement. | ||
return $end; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
namespace Bug11980; | ||
|
||
final class Demo | ||
{ | ||
|
||
/** | ||
* @param array<int, array<string, int>> $tokens | ||
* @param int $stackPtr | ||
* | ||
* @return int|void | ||
*/ | ||
public function process($tokens, $stackPtr) | ||
{ | ||
if (empty($tokens[$stackPtr]['nested_parenthesis']) === false) { | ||
// Not a stand-alone statement. | ||
return; | ||
} | ||
|
||
$end = 10; | ||
|
||
if ($tokens[$end]['code'] !== 10 | ||
&& $tokens[$end]['code'] !== 20 | ||
) { | ||
// Not a stand-alone statement. | ||
return $end; | ||
} | ||
} | ||
|
||
/** | ||
* @param array<int, array<string, int>> $tokens | ||
* @param int $stackPtr | ||
* | ||
* @return int|void | ||
*/ | ||
public function process2($tokens, $stackPtr) | ||
{ | ||
if (empty($tokens[$stackPtr]['nested_parenthesis']) === false) { | ||
// Not a stand-alone statement. | ||
return null; | ||
} | ||
|
||
$end = 10; | ||
|
||
if ($tokens[$end]['code'] !== 10 | ||
&& $tokens[$end]['code'] !== 20 | ||
) { | ||
// Not a stand-alone statement. | ||
return $end; | ||
} | ||
} | ||
} |