-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
[FEATURE] Make suppressed error levels for ErrorHandler configurable #5303
[FEATURE] Make suppressed error levels for ErrorHandler configurable #5303
Conversation
This change adds the documentation for the recently added configuration options: * errorHandlerIgnoreSuppressedPhpDeprecations * errorHandlerIgnoreSuppressedPhpNotices * errorHandlerIgnoreSuppressedPhpWarnings * errorHandlerIgnoreSuppressedUserDeprecations * errorHandlerIgnoreSuppressedUserNotices * errorHandlerIgnoreSuppressedUserWarnings Related change sebastianbergmann/phpunit#5303
Prepared documentation part also in -> sebastianbergmann/phpunit-documentation-english#301 |
This change adds the documentation for the recently added configuration options: * errorHandlerIgnoreSuppressedPhpDeprecations * errorHandlerIgnoreSuppressedPhpNotices * errorHandlerIgnoreSuppressedPhpWarnings * errorHandlerIgnoreSuppressedUserDeprecations * errorHandlerIgnoreSuppressedUserNotices * errorHandlerIgnoreSuppressedUserWarnings Related change sebastianbergmann/phpunit#5303
PHPUnit v10 changed how it handles notices, warnings, errors and deprecations. Therefore, converting them to exception has been removed in favour of display/fail options per type. Recently, the last missing piece for notices and deprecation has been added with: #5196: Optionally (fail|stop) on (notice|deprecation) events PHPUnit v9 (and possibly earlier versions) did not converted suppressed error levels to exceptions, if the corresponded old and removed option has been set. With PHPUnit v10, only native PHP error level (notices/strict,warnings,deprecated) are not handled if suppressed using the "@" suppress operator or by `error_reporting()` configuration. User error levels (notices,warnings,deprecation,error) are no longer suppressable. It's impossible to have only one defined set, which should be suppressable AND suppressed state regonized to suite all needs for framework, packages and applications using PHPUnit to test things. This **must** be configurable for users of the PHPUnit. This change adds configuration options to configure, which error levels are suppressable/suppressed state taking into account. Configuration is only provided through the PHPUnit configuration file. CLI options would not be really usefull, due "true" defauls - and therefore some options would be needed to be added "inverse". Having this only as XML options is more then suitable. Added xml configuration file options for: * (bool) errorHandlerIgnoreSuppressedPhpDeprecations [default: true] * (bool) errorHandlerIgnoreSuppressedPhpNotices [default: true] * (bool) errorHandlerIgnoreSuppressedPhpWarnings [default: true] * (bool) errorHandlerIgnoreSuppressedUserDeprecations [default: false] * (bool) errorHandlerIgnoreSuppressedUserNotices [default: false] * (bool) errorHandlerIgnoreSuppressedUserWarnings [default: false] **NOTE** ErrorLevels, which are configured to be ignored if suppressed, will not fail with corresponding `--fail-on-*` configuration/flag. On the other hand, this means that if suppressed ignore is configured, it will fail even if suppressed. E_USER_ERROR, e.g. triggered by using `trigger_error('', E_USER_ERROR)`, are not failing like php errors (E_ERROR). They always dispatches corresponding event. Additionally, there is no `--fail-on-error` flag which could control this for E_USER_ERROR. Therefore, E_USER_ERROR is left for now and should be targeted in a dedicated change. Furthermore, a couple of tests are added to cover the new options. Resolves #5302
Codecov Report
@@ Coverage Diff @@
## main #5303 +/- ##
============================================
+ Coverage 84.80% 84.88% +0.08%
- Complexity 6030 6050 +20
============================================
Files 650 650
Lines 19132 19210 +78
============================================
+ Hits 16224 16306 +82
+ Misses 2908 2904 -4
... and 1 file with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
|
Sorry for the delay - was full with work and needed time to test with the mentioned options. To be short, this pull-request does not make much sense IMO. So I would close it for now. |
PHPUnit v10 changed how it handles notices, warnings, errors and deprecations. Therefore, converting them to exception has been removed in favour of display/fail options per type. Recently, the last missing piece for notices and deprecation has been added with:
#5196: Optionally (fail|stop) on (notice|deprecation) events
PHPUnit v9 (and possibly earlier versions) did not converted suppressed error levels to exceptions, if the corresponded old and removed option has been set. With PHPUnit v10, only native PHP error level (notices/strict,warnings,deprecated) are not handled if suppressed using the "@" suppress operator or by
error_reporting()
configuration.User error levels (notices,warnings,deprecation,error) are no longer suppressable.
It's impossible to have only one defined set, which should be suppressable AND suppressed state regonized to suite all needs for framework, packages and applications using PHPUnit to test things. This must be configurable for users of the PHPUnit.
This change adds configuration options to configure, which error levels are suppressable/suppressed state taking into account. Configuration is only provided through the PHPUnit configuration file. CLI options would not be really usefull, due "true" defauls - and therefore some options would be needed to be added "inverse". Having this only as XML options is more then suitable.
Added xml configuration file options for:
NOTE ErrorLevels, which are configured to be ignored if
suppressed, will not fail with corresponding
--fail-on-*
configuration/flag. On the other hand, this means that
if suppressed ignore is configured, it will fail even if
suppressed.
E_USER_ERROR, e.g. triggered by using
trigger_error('', E_USER_ERROR)
, are not failing like php errors (E_ERROR). They always dispatches corresponding event. Additionally, there is no--fail-on-error
flag which could control this for E_USER_ERROR. Therefore, E_USER_ERROR is left for now and should be targeted in a dedicated change.Furthermore, a couple of tests are added to cover the new options.
Resolves #5302