phpstan-exception-rules
phpstan-exception-rules copied to clipboard
PHPStan rules for checked & unchecked exceptions
For a code like this: ```php $lin = (int) (($value - $min) / ($d === 0.0 ? 0.5 : $d)); ``` It is impossible for the error to occur. Nonetheless,...
All features of this project are being ported to the phpstan itself. I don't know the current status but It looks like most features are done and we can mark...
**Update:** Before you spend too much time reading all the details the below, [see my comment](https://github.com/pepakriz/phpstan-exception-rules/issues/147#issuecomment-848986471) in which I explain that I think I've found the cause of my issue...
Both [`random_int`](https://www.php.net/manual/en/function.random-int.php#refsect1-function.random-int-errors) and [`random_bytes`](https://www.php.net/manual/en/function.random-bytes.php#refsect1-function.random-bytes-errors) internal functions throw `Exception` (among others), but if you try catching it - you get an error `Exception is never thrown in the corresponding try block`....
It is needed for PHP build-in DateTime/DateTimeImmutable/DateInterval classes, that throw exceptions for invalid inputs. Furthermore, this extension will mark them even if the input is hardcoded.
It would be easier to configure PHPStan exception rules correctly if warnings were emitted for potential misconfigurantions. Consider the following configuration file: ```yaml parameters: exceptionRules: checkedExceptions: # or uncheckedExceptions -...
Currently, wrapping a callable call into a `try catch` block always results in an error: ```php try { $function(); } catch (\Throwable $exception) { } ``` ``` Throwable is never...
I've been thinking a bit more about the problem discussed under 461c803a7aa1a4b7303c6bd43c533d83c72a1de6 I believe the class inheritance is not the real problem for configuring checked/unchecked exceptions. All the exceptions can...