Skip to content

Bug: errorHandler removes Faker's deprecated errors #6764

Description

@kenjis

From #6758 (comment)

What happened?

--- a/system/Debug/Exceptions.php
+++ b/system/Debug/Exceptions.php
@@ -151,7 +151,7 @@ class Exceptions
      */
     public function errorHandler(int $severity, string $message, ?string $file = null, ?int $line = null)
     {
-        if (error_reporting() & $severity) {
+        if (E_ALL & $severity) {
             throw new ErrorException($message, 0, $severity, $file, $line);
         }
 
$ ./phpunit tests/system/Test/FabricatorTest.php
PHPUnit 9.5.25 #StandWithUkraine

Runtime:       PHP 8.1.11
Configuration: /Users/kenji/work/codeigniter/official/CodeIgniter4/phpunit.xml

.........E...........EEEEEEEEEEEEEEEE..........                   47 / 47 (100%)

Time: 00:00.625, Memory: 18.00 MB

There were 17 errors:

1) CodeIgniter\Test\FabricatorTest::testGetFakerReturnsUsableGenerator
ErrorException: Since fakerphp/faker 1.14: Accessing property "randomDigit" is deprecated, use "randomDigit()" instead.

/Users/kenji/work/codeigniter/official/CodeIgniter4/vendor/symfony/deprecation-contracts/function.php:25
/Users/kenji/work/codeigniter/official/CodeIgniter4/vendor/fakerphp/faker/src/Faker/Generator.php:950
/Users/kenji/work/codeigniter/official/CodeIgniter4/tests/system/Test/FabricatorTest.php:123

...

ERRORS!
Tests: 47, Assertions: 32, Errors: 17.

Anything else?

The value of error_reporting() will change in error handler when using @.
See

If a custom error handler function is set with set_error_handler(), it will still be called even though the diagnostic has been suppressed.

Warning
Prior to PHP 8.0.0, the error_reporting() called inside the custom error handler always returned 0 if the error was suppressed by the @ operator. As of PHP 8.0.0, it returns the value E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR | E_PARSE.
https://www.php.net/manual/en/language.operators.errorcontrol.php

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugVerified issues on the current code behavior or pull requests that will fix them

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions