Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False positives for exception expression #3919

Closed
Chi-teck opened this issue Nov 5, 2023 · 2 comments
Closed

False positives for exception expression #3919

Chi-teck opened this issue Nov 5, 2023 · 2 comments
Milestone

Comments

@Chi-teck
Copy link

Chi-teck commented Nov 5, 2023

Describe the bug

Since PHP 8.0 expressions can now throw exceptions.
So the code below is valid. However, it triggers Squiz.PHP.NonExecutableCode.Unreachable warning.

Code sample

$input = TRUE;
$input ?: throw new \RuntimeException('Error.');
echo 'The code was executed';
@jrfnl
Copy link
Contributor

jrfnl commented Nov 5, 2023

Closing as already fixed via #3777, which will be included in PHPCS 3.8.0.

@jrfnl jrfnl closed this as completed Nov 5, 2023
@jrfnl
Copy link
Contributor

jrfnl commented Dec 8, 2023

FYI: the fix for this issue is included in today's PHP_CodeSniffer 3.8.0 release.

As per #3932, development on PHP_CodeSniffer will continue in the PHPCSStandards/PHP_CodeSniffer repository. If you want to stay informed, you may want to start "watching" that repo (or watching releases from that repo).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants