-
Notifications
You must be signed in to change notification settings - Fork 494
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix false positive with isset() and empty()
- Loading branch information
1 parent
d7957d8
commit 05942ca
Showing
5 changed files
with
68 additions
and
6 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
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,31 @@ | ||
<?php | ||
|
||
namespace Bug3991; | ||
|
||
use function PHPStan\Analyser\assertNativeType; | ||
use function PHPStan\Analyser\assertType; | ||
|
||
class Foo | ||
{ | ||
/** | ||
* @param \stdClass|array|null $config | ||
* | ||
* @return \stdClass | ||
*/ | ||
public static function email($config = null) | ||
{ | ||
assertNativeType('mixed', $config); | ||
assertType('array|stdClass|null', $config); | ||
if (empty($config)) | ||
{ | ||
assertNativeType('mixed', $config); | ||
assertType('array|stdClass|null', $config); | ||
$config = new \stdClass(); | ||
} elseif (! (is_array($config) || $config instanceof \stdClass)) { | ||
assertNativeType('mixed~array|stdClass|false|null', $config); | ||
assertType('*NEVER*', $config); | ||
} | ||
|
||
return new \stdClass($config); | ||
} | ||
} |