3v4l.org

run code in 500+ PHP versions simultaneously
<?php namespace Foo; use function set_error_handler; use function trigger_error; 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 Test { 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); } } (new Test())->testSetErrorHandlerNonCallable();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mZ9E3
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   47     0  E >   NEW                                                  $0      'Foo%5CTest'
          1        DO_FCALL                                          0          
          2        INIT_METHOD_CALL                                             $0, 'testSetErrorHandlerNonCallable'
          3        DO_FCALL                                          0          
          4      > RETURN                                                       1

Class Foo\SomeExternalDependency:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mZ9E3
function name:  __construct
number of ops:  9
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   11     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                                                     
   13     6        INIT_METHOD_CALL                                             'triggerError'
          7        DO_FCALL                                          0          
   14     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/mZ9E3
function name:  triggerError
number of ops:  6
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   18     0  E >   INIT_FCALL                                                   'trigger_error'
          1        SEND_VAL                                                     'error'
          2        FETCH_CONSTANT                                       ~0      'Foo%5CE_USER_WARNING'
          3        SEND_VAL                                                     ~0
          4        DO_ICALL                                                     
   19     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/mZ9E3
function name:  logError
number of ops:  5
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   23     0  E >   INIT_NS_FCALL_BY_NAME                                        'Foo%5Cdebug_print_backtrace'
          1        DO_FCALL                                          0          
   25     2      > RETURN                                                       <true>
   26     3*       VERIFY_RETURN_TYPE                                           
          4*     > RETURN                                                       null

End of function logerror

End of class Foo\SomeExternalDependency.

Class Foo\Test:
Function testseterrorhandlernoncallable:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mZ9E3
function name:  testSetErrorHandlerNonCallable
number of ops:  20
compiled vars:  !0 = $callableWithPrivateMethod
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   33     0  E >   NEW                                                  $1      'Foo%5CSomeExternalDependency'
          1        DO_FCALL                                          0          
          2        FREE                                                         $1
   34     3        INIT_FCALL                                                   'set_error_handler'
          4        DECLARE_LAMBDA_FUNCTION                              ~3      [0]
          5        SEND_VAL                                                     ~3
          6        DO_ICALL                                             $4      
          7        ASSIGN                                                       !0, $4
   35     8        INIT_NS_FCALL_BY_NAME                                        'Foo%5Crestore_error_handler'
          9        DO_FCALL                                          0          
   39    10        ECHO                                                         '%0Aii.%0A'
   40    11        INIT_STATIC_METHOD_CALL                                      'Foo%5CSomeExternalDependency', 'triggerError'
         12        DO_FCALL                                          0          
   42    13        ECHO                                                         '%0Aiii.%0A'
   43    14        INIT_FCALL                                                   'trigger_error'
         15        SEND_VAL                                                     'error'
         16        FETCH_CONSTANT                                       ~8      'Foo%5CE_USER_WARNING'
         17        SEND_VAL                                                     ~8
         18        DO_ICALL                                                     
   44    19      > 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/mZ9E3
function name:  {closure:Foo\Test::testSetErrorHandlerNonCallable():34}
number of ops:  2
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   34     0  E > > RETURN                                                       <false>
          1*     > RETURN                                                       null

End of Dynamic Function 0

End of function testseterrorhandlernoncallable

End of class Foo\Test.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
148.14 ms | 499 KiB | 13 Q