-
Notifications
You must be signed in to change notification settings - Fork 665
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
957854c
commit b3ab2a5
Showing
4 changed files
with
40 additions
and
5 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,29 @@ | ||
<?php | ||
|
||
namespace Psalm\Internal; | ||
|
||
use PhpParser; | ||
use PhpParser\Node; | ||
|
||
use function class_exists; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
final class BCHelper | ||
{ | ||
public static function usePHPParserV4(): bool | ||
{ | ||
return class_exists('\PhpParser\Node\Stmt\Throw'); | ||
} | ||
|
||
public static function isThrow(Node $stmt): bool | ||
{ | ||
if (self::usePHPParserV4()) { | ||
return $stmt instanceof PhpParser\Node\Stmt\Throw_; | ||
} | ||
|
||
return $stmt instanceof PhpParser\Node\Stmt\Expression | ||
&& $stmt->expr instanceof PhpParser\Node\Expr\Throw_; | ||
} | ||
} |