-
Notifications
You must be signed in to change notification settings - Fork 479
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Narrow to non-empty-string/non-falsey-string after mb_strlen()
- Loading branch information
1 parent
4d162fa
commit 3361c84
Showing
3 changed files
with
46 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace Bug10952b; | ||
|
||
use function PHPStan\Testing\assertType; | ||
|
||
class HelloWorld | ||
{ | ||
public function getString(): string | ||
{ | ||
return 'hallo'; | ||
} | ||
|
||
public function test(): void | ||
{ | ||
$string = $this->getString(); | ||
|
||
if (1 < mb_strlen($string)) { | ||
assertType('non-empty-string', $string); | ||
} else { | ||
assertType("string", $string); | ||
} | ||
|
||
if (mb_strlen($string) > 1) { | ||
assertType('non-empty-string', $string); | ||
} else { | ||
assertType("string", $string); | ||
} | ||
|
||
if (2 < mb_strlen($string)) { | ||
assertType('non-falsy-string', $string); | ||
} else { | ||
assertType("string", $string); | ||
} | ||
|
||
match (true) { | ||
mb_strlen($string) > 0 => assertType('non-empty-string', $string), | ||
default => assertType("''", $string), | ||
}; | ||
} | ||
} |