-
Notifications
You must be signed in to change notification settings - Fork 471
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Invalidating expressions without regexes
- Loading branch information
1 parent
3dc41f3
commit 4220e43
Showing
4 changed files
with
80 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
|
||
namespace Bug5129; | ||
|
||
use function PHPStan\Testing\assertType; | ||
|
||
class HelloWorld | ||
{ | ||
|
||
private $foo; | ||
|
||
public function sayHello(string $s): void | ||
{ | ||
$this->foo = ''; | ||
assertType('0', strlen($this->foo)); | ||
if (strlen($this->foo) > 0) { | ||
return; | ||
} | ||
|
||
assertType('0', strlen($this->foo)); | ||
|
||
$this->foo = 'x'; | ||
assertType('int<1, max>', strlen($this->foo)); | ||
if (strlen($this->foo) > 0) { | ||
return; | ||
} | ||
|
||
assertType('0', strlen($this->foo)); | ||
|
||
$this->foo = $s; | ||
assertType('int<0, max>', strlen($this->foo)); | ||
} | ||
|
||
public function sayHello2(string $s): void | ||
{ | ||
$this->foo = ''; | ||
if (!$this->isFoo($this->foo)) { | ||
return; | ||
} | ||
|
||
assertType('true', $this->isFoo($this->foo)); | ||
|
||
$this->foo = 'x'; | ||
assertType('bool', $this->isFoo($this->foo)); | ||
if (!$this->isFoo($this->foo)) { | ||
return; | ||
} | ||
assertType('true', $this->isFoo($this->foo)); | ||
|
||
$this->foo = $s; | ||
assertType('bool', $this->isFoo($this->foo)); | ||
if (!$this->isFoo($this->foo)) { | ||
return; | ||
} | ||
assertType('true', $this->isFoo($this->foo)); | ||
} | ||
|
||
public function isFoo(string $s): bool | ||
{ | ||
return strlen($s) % 3; | ||
} | ||
|
||
} |