-
Notifications
You must be signed in to change notification settings - Fork 460
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed expression invalidation when ++ is involved
- Loading branch information
1 parent
ca37ebd
commit 9665e16
Showing
6 changed files
with
100 additions
and
11 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,41 @@ | ||
<?php | ||
|
||
namespace Bug2835AssertTypes; | ||
|
||
use function PHPStan\Analyser\assertType; | ||
|
||
class Foo | ||
{ | ||
|
||
/** | ||
* @param array<int, array> $tokens | ||
* @return bool | ||
*/ | ||
public function doFoo(array $tokens): bool { | ||
$i = 0; | ||
while (isset($tokens[$i])) { | ||
assertType('int', $i); | ||
if ($tokens[$i]['code'] !== 1) { | ||
assertType('mixed~1', $tokens[$i]['code']); | ||
$i++; | ||
assertType('int', $i); | ||
assertType('mixed', $tokens[$i]['code']); | ||
continue; | ||
} | ||
assertType('1', $tokens[$i]['code']); | ||
$i++; | ||
assertType('int', $i); | ||
assertType('mixed', $tokens[$i]['code']); | ||
if ($tokens[$i]['code'] !== 2) { | ||
assertType('mixed~2', $tokens[$i]['code']); | ||
$i++; | ||
assertType('int', $i); | ||
continue; | ||
} | ||
assertType('2', $tokens[$i]['code']); | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
} |
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,29 @@ | ||
<?php | ||
|
||
namespace Bug2835; | ||
|
||
class Foo | ||
{ | ||
|
||
/** | ||
* @param array<int, array> $tokens | ||
* @return bool | ||
*/ | ||
public function doFoo(array $tokens): bool { | ||
$i = 0; | ||
while (isset($tokens[$i])) { | ||
if ($tokens[$i]['code'] !== 1) { | ||
$i++; | ||
continue; | ||
} | ||
$i++; | ||
if ($tokens[$i]['code'] !== 2) { | ||
$i++; | ||
continue; | ||
} | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
} |