3v4l.org

run code in 500+ PHP versions simultaneously
<?php declare(strict_types=1); namespace Monolog\Handler; class LogRecord implements \ArrayAccess { public function __construct( public readonly string $message, public readonly int $level, public readonly array $context, public array $extra, // only field that is modifiable in theory ) {} // ... public function offsetSet(mixed $offset, mixed $value): void { if (is_null($offset)) { throw new \LogicException('Unsupported operation'); } else { $this->{$offset} = $value; } } public function offsetExists(mixed $offset): bool { return isset($this->{$offset}); } public function offsetUnset(mixed $offset): void { throw new \LogicException('Unsupported operation'); } public function offsetGet(mixed $offset): mixed { return $this->{$offset} ?? null; } } // Record for forward-compat in V2 would be added as: // interface Record implements \ArrayAccess {} interface HandlerInterfaceV2 { public function handle(array $record): bool; } interface HandlerInterfaceV3 { public function handle(LogRecord $record): bool; } class HandlerCompatPHP81OnV2 implements HandlerInterfaceV2 { public function handle(array|LogRecord $record): bool { echo $record['message']; return false; } } class HandlerCompatPHP81OnV3 implements HandlerInterfaceV3 { public function handle(array|LogRecord $record): bool { echo $record['message']; return false; } } class HandlerCompatOnV2 implements HandlerInterfaceV2 { public function handle($record): bool { echo $record['message']; return false; } } class HandlerCompatOnV3 implements HandlerInterfaceV3 { public function handle($record): bool { echo $record['message']; return false; } } class HandlerV2Only implements HandlerInterfaceV2 { public function handle(array $record): bool { echo $record['message']; return false; } } class HandlerV3Only implements HandlerInterfaceV3 { public function handle(LogRecord $record): bool { echo $record->message; return false; } } $record = new LogRecord('foo', 100, [], []); $handler = new HandlerCompatOnV3; $handler->handle($record); $handler = new HandlerV3Only; $handler->handle($record);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Dcj4I
function name:  (null)
number of ops:  27
compiled vars:  !0 = $record, !1 = $handler
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    5     0  E >   DECLARE_CLASS                                                'monolog%5Chandler%5Clogrecord'
   48     1        DECLARE_CLASS                                                'monolog%5Chandler%5Chandlercompatphp81onv2'
   51     2        DECLARE_CLASS                                                'monolog%5Chandler%5Chandlercompatphp81onv3'
   55     3        DECLARE_CLASS                                                'monolog%5Chandler%5Chandlercompatonv2'
   58     4        DECLARE_CLASS                                                'monolog%5Chandler%5Chandlercompatonv3'
   62     5        DECLARE_CLASS                                                'monolog%5Chandler%5Chandlerv2only'
   66     6        DECLARE_CLASS                                                'monolog%5Chandler%5Chandlerv3only'
   70     7        NEW                                                  $2      'Monolog%5CHandler%5CLogRecord'
          8        SEND_VAL_EX                                                  'foo'
          9        SEND_VAL_EX                                                  100
         10        SEND_VAL_EX                                                  <array>
         11        SEND_VAL_EX                                                  <array>
         12        DO_FCALL                                          0          
         13        ASSIGN                                                       !0, $2
   71    14        NEW                                                  $5      'Monolog%5CHandler%5CHandlerCompatOnV3'
         15        DO_FCALL                                          0          
         16        ASSIGN                                                       !1, $5
   72    17        INIT_METHOD_CALL                                             !1, 'handle'
         18        SEND_VAR_EX                                                  !0
         19        DO_FCALL                                          0          
   73    20        NEW                                                  $9      'Monolog%5CHandler%5CHandlerV3Only'
         21        DO_FCALL                                          0          
         22        ASSIGN                                                       !1, $9
   74    23        INIT_METHOD_CALL                                             !1, 'handle'
         24        SEND_VAR_EX                                                  !0
         25        DO_FCALL                                          0          
         26      > RETURN                                                       1

Class Monolog\Handler\LogRecord:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Dcj4I
function name:  __construct
number of ops:  13
compiled vars:  !0 = $message, !1 = $level, !2 = $context, !3 = $extra
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    7     0  E >   RECV                                                 !0      
    8     1        RECV                                                 !1      
    9     2        RECV                                                 !2      
   10     3        RECV                                                 !3      
    7     4        ASSIGN_OBJ                                                   'message'
          5        OP_DATA                                                      !0
    8     6        ASSIGN_OBJ                                                   'level'
          7        OP_DATA                                                      !1
    9     8        ASSIGN_OBJ                                                   'context'
          9        OP_DATA                                                      !2
   10    10        ASSIGN_OBJ                                                   'extra'
         11        OP_DATA                                                      !3
   11    12      > RETURN                                                       null

End of function __construct

Function offsetset:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 11
Branch analysis from position: 6
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Dcj4I
function name:  offsetSet
number of ops:  14
compiled vars:  !0 = $offset, !1 = $value
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   14     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
   15     2        INIT_NS_FCALL_BY_NAME                                        'Monolog%5CHandler%5Cis_null'
          3        SEND_VAR_EX                                                  !0
          4        DO_FCALL                                          0  $2      
          5      > JMPZ                                                         $2, ->11
   16     6    >   NEW                                                  $3      'LogicException'
          7        SEND_VAL_EX                                                  'Unsupported+operation'
          8        DO_FCALL                                          0          
          9      > THROW                                             0          $3
   15    10*       JMP                                                          ->13
   18    11    >   ASSIGN_OBJ                                                   !0
         12        OP_DATA                                                      !1
   20    13      > RETURN                                                       null

End of function offsetset

Function offsetexists:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Dcj4I
function name:  offsetExists
number of ops:  6
compiled vars:  !0 = $offset
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   22     0  E >   RECV                                                 !0      
   23     1        ISSET_ISEMPTY_PROP_OBJ                               ~1      !0
          2        VERIFY_RETURN_TYPE                                           ~1
          3      > RETURN                                                       ~1
   24     4*       VERIFY_RETURN_TYPE                                           
          5*     > RETURN                                                       null

End of function offsetexists

Function offsetunset:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/Dcj4I
function name:  offsetUnset
number of ops:  6
compiled vars:  !0 = $offset
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   26     0  E >   RECV                                                 !0      
   27     1        NEW                                                  $1      'LogicException'
          2        SEND_VAL_EX                                                  'Unsupported+operation'
          3        DO_FCALL                                          0          
          4      > THROW                                             0          $1
   28     5*     > RETURN                                                       null

End of function offsetunset

Function offsetget:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Dcj4I
function name:  offsetGet
number of ops:  7
compiled vars:  !0 = $offset
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   30     0  E >   RECV                                                 !0      
   31     1        FETCH_OBJ_IS                                         ~1      !0
          2        COALESCE                                             ~2      ~1
          3        QM_ASSIGN                                            ~2      null
          4      > RETURN                                                       ~2
   32     5*       VERIFY_RETURN_TYPE                                           
          6*     > RETURN                                                       null

End of function offsetget

End of class Monolog\Handler\LogRecord.

Class Monolog\Handler\HandlerInterfaceV2:
Function handle:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Dcj4I
function name:  handle
number of ops:  3
compiled vars:  !0 = $record
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   41     0  E >   RECV                                                 !0      
          1        VERIFY_RETURN_TYPE                                           
          2      > RETURN                                                       null

End of function handle

End of class Monolog\Handler\HandlerInterfaceV2.

Class Monolog\Handler\HandlerInterfaceV3:
Function handle:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Dcj4I
function name:  handle
number of ops:  3
compiled vars:  !0 = $record
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   45     0  E >   RECV                                                 !0      
          1        VERIFY_RETURN_TYPE                                           
          2      > RETURN                                                       null

End of function handle

End of class Monolog\Handler\HandlerInterfaceV3.

Class Monolog\Handler\HandlerCompatPHP81OnV2:
Function handle:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Dcj4I
function name:  handle
number of ops:  6
compiled vars:  !0 = $record
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   49     0  E >   RECV                                                 !0      
          1        FETCH_DIM_R                                          ~1      !0, 'message'
          2        ECHO                                                         ~1
          3      > RETURN                                                       <false>
          4*       VERIFY_RETURN_TYPE                                           
          5*     > RETURN                                                       null

End of function handle

End of class Monolog\Handler\HandlerCompatPHP81OnV2.

Class Monolog\Handler\HandlerCompatPHP81OnV3:
Function handle:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Dcj4I
function name:  handle
number of ops:  6
compiled vars:  !0 = $record
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   52     0  E >   RECV                                                 !0      
          1        FETCH_DIM_R                                          ~1      !0, 'message'
          2        ECHO                                                         ~1
          3      > RETURN                                                       <false>
          4*       VERIFY_RETURN_TYPE                                           
          5*     > RETURN                                                       null

End of function handle

End of class Monolog\Handler\HandlerCompatPHP81OnV3.

Class Monolog\Handler\HandlerCompatOnV2:
Function handle:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Dcj4I
function name:  handle
number of ops:  6
compiled vars:  !0 = $record
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   56     0  E >   RECV                                                 !0      
          1        FETCH_DIM_R                                          ~1      !0, 'message'
          2        ECHO                                                         ~1
          3      > RETURN                                                       <false>
          4*       VERIFY_RETURN_TYPE                                           
          5*     > RETURN                                                       null

End of function handle

End of class Monolog\Handler\HandlerCompatOnV2.

Class Monolog\Handler\HandlerCompatOnV3:
Function handle:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Dcj4I
function name:  handle
number of ops:  6
compiled vars:  !0 = $record
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   59     0  E >   RECV                                                 !0      
          1        FETCH_DIM_R                                          ~1      !0, 'message'
          2        ECHO                                                         ~1
          3      > RETURN                                                       <false>
          4*       VERIFY_RETURN_TYPE                                           
          5*     > RETURN                                                       null

End of function handle

End of class Monolog\Handler\HandlerCompatOnV3.

Class Monolog\Handler\HandlerV2Only:
Function handle:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Dcj4I
function name:  handle
number of ops:  6
compiled vars:  !0 = $record
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   63     0  E >   RECV                                                 !0      
          1        FETCH_DIM_R                                          ~1      !0, 'message'
          2        ECHO                                                         ~1
          3      > RETURN                                                       <false>
          4*       VERIFY_RETURN_TYPE                                           
          5*     > RETURN                                                       null

End of function handle

End of class Monolog\Handler\HandlerV2Only.

Class Monolog\Handler\HandlerV3Only:
Function handle:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Dcj4I
function name:  handle
number of ops:  6
compiled vars:  !0 = $record
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   67     0  E >   RECV                                                 !0      
          1        FETCH_OBJ_R                                          ~1      !0, 'message'
          2        ECHO                                                         ~1
          3      > RETURN                                                       <false>
          4*       VERIFY_RETURN_TYPE                                           
          5*     > RETURN                                                       null

End of function handle

End of class Monolog\Handler\HandlerV3Only.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
170.71 ms | 1387 KiB | 14 Q