Closed Chi-teck closed 4 months ago
Version: slevomat/coding-standard 8.14.1
Code to reproduce:
try { // Do something. } catch (\Exception $exception) { // Intentionally empty. } finally { \var_dump(isset($exception)); }
Error: Non-capturing catch is required.
The code example looks weird but it is valid. Apparently the corresponding sniff does not check usage of $exception variable outside of catch block.
$exception
catch
A bit different, but related with the same sniff false positive:
function () { do { try { } catch (\Throwable $e) { } } while (true); throw $e; };
Fixed in https://github.com/slevomat/coding-standard/commit/d82a6713c0063ba31e1d2bbc8a6df22798a2e370
Version: slevomat/coding-standard 8.14.1
Code to reproduce:
Error: Non-capturing catch is required.
The code example looks weird but it is valid. Apparently the corresponding sniff does not check usage of
$exception
variable outside ofcatch
block.