-
Notifications
You must be signed in to change notification settings - Fork 464
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Throwable catch block also uses implicit throw points even when there…
… are explicit ones
- Loading branch information
1 parent
088518f
commit 54a204e
Showing
4 changed files
with
87 additions
and
1 deletion.
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,40 @@ | ||
<?php | ||
|
||
namespace Bug4820; | ||
|
||
use PHPStan\TrinaryLogic; | ||
use function PHPStan\Testing\assertType; | ||
use function PHPStan\Testing\assertVariableCertainty; | ||
|
||
class Param { | ||
|
||
public bool $foo; | ||
} | ||
|
||
class HelloWorld | ||
{ | ||
public function sayHello(Param $param): void | ||
{ | ||
|
||
try { | ||
$result = call_user_func([$this, 'mayThrow']); | ||
if ($param->foo) { | ||
$this->mayThrow(); | ||
} | ||
|
||
} catch (\Throwable $e) { | ||
assertType('bool', $param->foo); | ||
assertVariableCertainty(TrinaryLogic::createMaybe(), $result); | ||
throw $e; | ||
} | ||
} | ||
|
||
/** | ||
* @throws \RuntimeException | ||
*/ | ||
private function mayThrow(): void | ||
{ | ||
throw new \RuntimeException(); | ||
} | ||
|
||
} |
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,44 @@ | ||
<?php | ||
|
||
namespace Bug4879; | ||
|
||
use PHPStan\TrinaryLogic; | ||
use function PHPStan\Testing\assertVariableCertainty; | ||
|
||
class HelloWorld | ||
{ | ||
public function sayHello(bool $bool1): void | ||
{ | ||
try { | ||
if ($bool1) { | ||
throw new \Exception(); | ||
} | ||
|
||
$var = 'foo'; | ||
|
||
$this->test(); | ||
} catch (\Throwable $ex) { | ||
assertVariableCertainty(TrinaryLogic::createMaybe(), $var); | ||
} | ||
} | ||
|
||
public function sayHello2(bool $bool1): void | ||
{ | ||
try { | ||
if ($bool1) { | ||
throw new \Exception(); | ||
} | ||
|
||
$var = 'foo'; | ||
|
||
$this->test(); | ||
} catch (\Exception $ex) { | ||
assertVariableCertainty(TrinaryLogic::createNo(), $var); | ||
} | ||
} | ||
|
||
public function test(): void | ||
{ | ||
return; | ||
} | ||
} |