Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes phpstan/phpstan#5656 Closes phpstan/phpstan#5362 Closes phpstan/phpstan#3867
- Loading branch information
1 parent
28923f6
commit d4557a6
Showing
5 changed files
with
118 additions
and
0 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,24 @@ | ||
<?php | ||
|
||
namespace Bug3867; | ||
|
||
class Demo | ||
{ | ||
public function analyze(): void | ||
{ | ||
$try = [ | ||
"methodOne", | ||
"methodTwo" | ||
]; | ||
|
||
do { | ||
$method = array_shift($try); | ||
|
||
$result = $this->$method(); | ||
|
||
if (!empty($result)) { | ||
break; | ||
} | ||
} while (count($try) > 0); | ||
} | ||
} |
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,32 @@ | ||
<?php | ||
|
||
namespace Bug5362; | ||
|
||
class Foo | ||
{ | ||
|
||
function doFoo(int $retry): void { | ||
echo "\nfoo: ".$retry; | ||
throw new \Exception(); | ||
} | ||
|
||
function doBar() | ||
{ | ||
$retry = 2; | ||
|
||
do { | ||
try { | ||
$this->doFoo($retry); | ||
|
||
break; | ||
} catch (\Exception $e) { | ||
if (0 === $retry) { | ||
throw $e; | ||
} | ||
|
||
--$retry; | ||
} | ||
} while ($retry > 0); | ||
} | ||
|
||
} |
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 Bug5656; | ||
|
||
function okpoValidate(array $values): bool | ||
{ | ||
$c = count($values); | ||
if (8 !== $c && 10 !== $c) { | ||
return false; | ||
} | ||
|
||
$expected = array_pop($values); | ||
|
||
$control = 0; | ||
for ($start = 1; $start <= 3; $start += 2) { | ||
$i = $start; | ||
$control = 0; | ||
foreach ($values as $v) { | ||
if ($i > 10) { | ||
$i = 1; | ||
} | ||
$control += $i * $v; | ||
++$i; | ||
} | ||
|
||
$control %= 11; | ||
|
||
if (10 !== $control) { | ||
break; | ||
} | ||
} | ||
|
||
if (10 === $control) { | ||
$control = 0; | ||
} | ||
|
||
return $expected === $control; | ||
} | ||
|
||
$values = [0, 1, 0, 6, 0, 6, 2, 3, 1, 5]; | ||
okpoValidate($values); |