3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace PHPUnit\TestFixture; use function set_error_handler; use function trigger_error; use PHPUnit\Framework\TestCase; class SomeExternalDependency { public function __construct() { set_error_handler([$this, 'logError']); $this->triggerError(); } public static function triggerError(): void { trigger_error('error', E_USER_WARNING); } private function logError(): bool { debug_print_backtrace(); return true; } } class Issue5844Test { public function testSetErrorHandlerNonCallable(): void { new SomeExternalDependency(); $callableWithPrivateMethod = set_error_handler(static fn () => false); restore_error_handler(); restore_error_handler(); set_error_handler($callableWithPrivateMethod); echo "\nii.\n"; SomeExternalDependency::triggerError(); echo "\niii.\n"; trigger_error('error', E_USER_WARNING); // $this->assertTrue(true); } } (new Issue5844Test())->testSetErrorHandlerNonCallable();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GFd18
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   51     0  E >   NEW                                              $0      'PHPUnit%5CTestFixture%5CIssue5844Test'
          1        DO_FCALL                                      0          
          2        INIT_METHOD_CALL                                         $0, 'testSetErrorHandlerNonCallable'
          3        DO_FCALL                                      0          
          4      > RETURN                                                   1

Class PHPUnit\TestFixture\SomeExternalDependency:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GFd18
function name:  __construct
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   INIT_FCALL                                               'set_error_handler'
          1        FETCH_THIS                                       ~0      
          2        INIT_ARRAY                                       ~1      ~0
          3        ADD_ARRAY_ELEMENT                                ~1      'logError'
          4        SEND_VAL                                                 ~1
          5        DO_ICALL                                                 
   14     6        INIT_METHOD_CALL                                         'triggerError'
          7        DO_FCALL                                      0          
   15     8      > RETURN                                                   null

End of function __construct

Function triggererror:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GFd18
function name:  triggerError
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   INIT_FCALL                                               'trigger_error'
          1        SEND_VAL                                                 'error'
          2        FETCH_CONSTANT                                   ~0      'PHPUnit%5CTestFixture%5CE_USER_WARNING'
          3        SEND_VAL                                                 ~0
          4        DO_ICALL                                                 
   20     5      > RETURN                                                   null

End of function triggererror

Function logerror:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GFd18
function name:  logError
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   INIT_NS_FCALL_BY_NAME                                    'PHPUnit%5CTestFixture%5Cdebug_print_backtrace'
          1        DO_FCALL                                      0          
   26     2      > RETURN                                                   <true>
   27     3*       VERIFY_RETURN_TYPE                                       
          4*     > RETURN                                                   null

End of function logerror

End of class PHPUnit\TestFixture\SomeExternalDependency.

Class PHPUnit\TestFixture\Issue5844Test:
Function testseterrorhandlernoncallable:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GFd18
function name:  testSetErrorHandlerNonCallable
number of ops:  25
compiled vars:  !0 = $callableWithPrivateMethod
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   NEW                                              $1      'PHPUnit%5CTestFixture%5CSomeExternalDependency'
          1        DO_FCALL                                      0          
          2        FREE                                                     $1
   36     3        INIT_FCALL                                               'set_error_handler'
          4        DECLARE_LAMBDA_FUNCTION                          ~3      [0]
          5        SEND_VAL                                                 ~3
          6        DO_ICALL                                         $4      
          7        ASSIGN                                                   !0, $4
   37     8        INIT_NS_FCALL_BY_NAME                                    'PHPUnit%5CTestFixture%5Crestore_error_handler'
          9        DO_FCALL                                      0          
   38    10        INIT_NS_FCALL_BY_NAME                                    'PHPUnit%5CTestFixture%5Crestore_error_handler'
         11        DO_FCALL                                      0          
   39    12        INIT_FCALL                                               'set_error_handler'
         13        SEND_VAR                                                 !0
         14        DO_ICALL                                                 
   41    15        ECHO                                                     '%0Aii.%0A'
   42    16        INIT_STATIC_METHOD_CALL                                  'PHPUnit%5CTestFixture%5CSomeExternalDependency', 'triggerError'
         17        DO_FCALL                                      0          
   44    18        ECHO                                                     '%0Aiii.%0A'
   45    19        INIT_FCALL                                               'trigger_error'
         20        SEND_VAL                                                 'error'
         21        FETCH_CONSTANT                                   ~10     'PHPUnit%5CTestFixture%5CE_USER_WARNING'
         22        SEND_VAL                                                 ~10
         23        DO_ICALL                                                 
   48    24      > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GFd18
function name:  PHPUnit\TestFixture\{closure}
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E > > RETURN                                                   <false>
          1*     > RETURN                                                   null

End of Dynamic Function 0

End of function testseterrorhandlernoncallable

End of class PHPUnit\TestFixture\Issue5844Test.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.37 ms | 1434 KiB | 17 Q