3v4l.org

run code in 500+ PHP versions simultaneously
<?php /** * This class implements ArrayAccess and the magic * isset method to test the behavior of certain operators * * It simulates having just a property called a */ class Test implements ArrayAccess { public function __isset($property) { return $property === 'a'; } public function __get($property) { return $property === 'a'? 'a' : null; } public function offsetExists ( $offset ) : bool { return $offset === 'a'; } /** * We are required by the interface to implement these methods * but they're irrelevant to our test */ public function offsetGet ( $offset ) { return $offset === 'a'? 'a' : null; } public function offsetSet ($offset , $value ) : void { return; } public function offsetUnset ($offset ) : void { return; } } /** * Start performing the actual tests, we wanna compare the * behavior of isset() and the ?? operator */ $tests = [ 'isset->a' => function($e) { return isset($e->a) && $e->a? $e->a : false; }, 'isset->b' => function($e) { return isset($e->b) && $e->b? $e->b : false; }, 'isset[a]' => function($e) { return isset($e['a']) && $e['a']? $e['a'] : false; }, 'isset[b]' => function($e) { return isset($e['b']) && $e['b']? $e['b'] : false; }, '[a]??false' => function($e) { return $e['a']??false; }, '[b]??false' => function($e) { return $e['b']??false; }, '->a??false' => function($e) { return $e->a??false; }, '->b??false' => function($e) { return $e->b??false; } ]; $a = new Test(); foreach ($tests as $caption => $fn) { echo $caption, ': ', ($fn($a)? $fn($a) : 'false'), PHP_EOL; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 22, Position 2 = 39
Branch analysis from position: 22
2 jumps found. (Code = 78) Position 1 = 23, Position 2 = 39
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 35
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 36
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
Branch analysis from position: 39
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 39
filename:       /in/v7YYP
function name:  (null)
number of ops:  41
compiled vars:  !0 = $tests, !1 = $a, !2 = $fn, !3 = $caption
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    9     0  E >   DECLARE_CLASS                                                'test'
   48     1        DECLARE_LAMBDA_FUNCTION                              ~4      [0]
          2        INIT_ARRAY                                           ~5      ~4, 'isset-%3Ea'
   49     3        DECLARE_LAMBDA_FUNCTION                              ~6      [1]
          4        ADD_ARRAY_ELEMENT                                    ~5      ~6, 'isset-%3Eb'
   50     5        DECLARE_LAMBDA_FUNCTION                              ~7      [2]
          6        ADD_ARRAY_ELEMENT                                    ~5      ~7, 'isset%5Ba%5D'
   51     7        DECLARE_LAMBDA_FUNCTION                              ~8      [3]
          8        ADD_ARRAY_ELEMENT                                    ~5      ~8, 'isset%5Bb%5D'
   52     9        DECLARE_LAMBDA_FUNCTION                              ~9      [4]
         10        ADD_ARRAY_ELEMENT                                    ~5      ~9, '%5Ba%5D%3F%3Ffalse'
   53    11        DECLARE_LAMBDA_FUNCTION                              ~10     [5]
         12        ADD_ARRAY_ELEMENT                                    ~5      ~10, '%5Bb%5D%3F%3Ffalse'
   54    13        DECLARE_LAMBDA_FUNCTION                              ~11     [6]
         14        ADD_ARRAY_ELEMENT                                    ~5      ~11, '-%3Ea%3F%3Ffalse'
   55    15        DECLARE_LAMBDA_FUNCTION                              ~12     [7]
         16        ADD_ARRAY_ELEMENT                                    ~5      ~12, '-%3Eb%3F%3Ffalse'
   47    17        ASSIGN                                                       !0, ~5
   58    18        NEW                                                  $14     'Test'
         19        DO_FCALL                                          0          
         20        ASSIGN                                                       !1, $14
   60    21      > FE_RESET_R                                           $17     !0, ->39
         22    > > FE_FETCH_R                                           ~18     $17, !2, ->39
         23    >   ASSIGN                                                       !3, ~18
   61    24        ECHO                                                         !3
         25        ECHO                                                         '%3A+'
         26        INIT_DYNAMIC_CALL                                            !2
         27        SEND_VAR_EX                                                  !1
         28        DO_FCALL                                          0  $20     
         29      > JMPZ                                                         $20, ->35
         30    >   INIT_DYNAMIC_CALL                                            !2
         31        SEND_VAR_EX                                                  !1
         32        DO_FCALL                                          0  $21     
         33        QM_ASSIGN                                            ~22     $21
         34      > JMP                                                          ->36
         35    >   QM_ASSIGN                                            ~22     'false'
         36    >   ECHO                                                         ~22
         37        ECHO                                                         '%0A'
   60    38      > JMP                                                          ->22
         39    >   FE_FREE                                                      $17
   62    40      > RETURN                                                       1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 3, Position 2 = 5
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 9
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
filename:       /in/v7YYP
function name:  {closure:/in/v7YYP:48}
number of ops:  12
compiled vars:  !0 = $e
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   48     0  E >   RECV                                                 !0      
          1        ISSET_ISEMPTY_PROP_OBJ                               ~1      !0, 'a'
          2      > JMPZ_EX                                              ~1      ~1, ->5
          3    >   FETCH_OBJ_R                                          ~2      !0, 'a'
          4        BOOL                                                 ~1      ~2
          5    > > JMPZ                                                         ~1, ->9
          6    >   FETCH_OBJ_R                                          ~3      !0, 'a'
          7        QM_ASSIGN                                            ~4      ~3
          8      > JMP                                                          ->10
          9    >   QM_ASSIGN                                            ~4      <false>
         10    > > RETURN                                                       ~4
         11*     > RETURN                                                       null

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 3, Position 2 = 5
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 9
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
filename:       /in/v7YYP
function name:  {closure:/in/v7YYP:49}
number of ops:  12
compiled vars:  !0 = $e
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   49     0  E >   RECV                                                 !0      
          1        ISSET_ISEMPTY_PROP_OBJ                               ~1      !0, 'b'
          2      > JMPZ_EX                                              ~1      ~1, ->5
          3    >   FETCH_OBJ_R                                          ~2      !0, 'b'
          4        BOOL                                                 ~1      ~2
          5    > > JMPZ                                                         ~1, ->9
          6    >   FETCH_OBJ_R                                          ~3      !0, 'b'
          7        QM_ASSIGN                                            ~4      ~3
          8      > JMP                                                          ->10
          9    >   QM_ASSIGN                                            ~4      <false>
         10    > > RETURN                                                       ~4
         11*     > RETURN                                                       null

End of Dynamic Function 1

Dynamic Function 2
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 3, Position 2 = 5
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 9
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
filename:       /in/v7YYP
function name:  {closure:/in/v7YYP:50}
number of ops:  12
compiled vars:  !0 = $e
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   50     0  E >   RECV                                                 !0      
          1        ISSET_ISEMPTY_DIM_OBJ                             0  ~1      !0, 'a'
          2      > JMPZ_EX                                              ~1      ~1, ->5
          3    >   FETCH_DIM_R                                          ~2      !0, 'a'
          4        BOOL                                                 ~1      ~2
          5    > > JMPZ                                                         ~1, ->9
          6    >   FETCH_DIM_R                                          ~3      !0, 'a'
          7        QM_ASSIGN                                            ~4      ~3
          8      > JMP                                                          ->10
          9    >   QM_ASSIGN                                            ~4      <false>
         10    > > RETURN                                                       ~4
         11*     > RETURN                                                       null

End of Dynamic Function 2

Dynamic Function 3
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 3, Position 2 = 5
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 9
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
filename:       /in/v7YYP
function name:  {closure:/in/v7YYP:51}
number of ops:  12
compiled vars:  !0 = $e
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   51     0  E >   RECV                                                 !0      
          1        ISSET_ISEMPTY_DIM_OBJ                             0  ~1      !0, 'b'
          2      > JMPZ_EX                                              ~1      ~1, ->5
          3    >   FETCH_DIM_R                                          ~2      !0, 'b'
          4        BOOL                                                 ~1      ~2
          5    > > JMPZ                                                         ~1, ->9
          6    >   FETCH_DIM_R                                          ~3      !0, 'b'
          7        QM_ASSIGN                                            ~4      ~3
          8      > JMP                                                          ->10
          9    >   QM_ASSIGN                                            ~4      <false>
         10    > > RETURN                                                       ~4
         11*     > RETURN                                                       null

End of Dynamic Function 3

Dynamic Function 4
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/v7YYP
function name:  {closure:/in/v7YYP:52}
number of ops:  6
compiled vars:  !0 = $e
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   52     0  E >   RECV                                                 !0      
          1        FETCH_DIM_IS                                         ~1      !0, 'a'
          2        COALESCE                                             ~2      ~1
          3        QM_ASSIGN                                            ~2      <false>
          4      > RETURN                                                       ~2
          5*     > RETURN                                                       null

End of Dynamic Function 4

Dynamic Function 5
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/v7YYP
function name:  {closure:/in/v7YYP:53}
number of ops:  6
compiled vars:  !0 = $e
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   53     0  E >   RECV                                                 !0      
          1        FETCH_DIM_IS                                         ~1      !0, 'b'
          2        COALESCE                                             ~2      ~1
          3        QM_ASSIGN                                            ~2      <false>
          4      > RETURN                                                       ~2
          5*     > RETURN                                                       null

End of Dynamic Function 5

Dynamic Function 6
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/v7YYP
function name:  {closure:/in/v7YYP:54}
number of ops:  6
compiled vars:  !0 = $e
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   54     0  E >   RECV                                                 !0      
          1        FETCH_OBJ_IS                                         ~1      !0, 'a'
          2        COALESCE                                             ~2      ~1
          3        QM_ASSIGN                                            ~2      <false>
          4      > RETURN                                                       ~2
          5*     > RETURN                                                       null

End of Dynamic Function 6

Dynamic Function 7
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/v7YYP
function name:  {closure:/in/v7YYP:55}
number of ops:  6
compiled vars:  !0 = $e
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   55     0  E >   RECV                                                 !0      
          1        FETCH_OBJ_IS                                         ~1      !0, 'b'
          2        COALESCE                                             ~2      ~1
          3        QM_ASSIGN                                            ~2      <false>
          4      > RETURN                                                       ~2
          5*     > RETURN                                                       null

End of Dynamic Function 7

Class Test:
Function __isset:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/v7YYP
function name:  __isset
number of ops:  4
compiled vars:  !0 = $property
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   12     0  E >   RECV                                                 !0      
   13     1        IS_IDENTICAL                                         ~1      !0, 'a'
          2      > RETURN                                                       ~1
   14     3*     > RETURN                                                       null

End of function __isset

Function __get:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 5
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/v7YYP
function name:  __get
number of ops:  8
compiled vars:  !0 = $property
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   16     0  E >   RECV                                                 !0      
   17     1        IS_IDENTICAL                                                 !0, 'a'
          2      > JMPZ                                                         ~1, ->5
          3    >   QM_ASSIGN                                            ~2      'a'
          4      > JMP                                                          ->6
          5    >   QM_ASSIGN                                            ~2      null
          6    > > RETURN                                                       ~2
   18     7*     > RETURN                                                       null

End of function __get

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

End of function offsetexists

Function offsetget:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 5
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/v7YYP
function name:  offsetGet
number of ops:  8
compiled vars:  !0 = $offset
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   29     0  E >   RECV                                                 !0      
   30     1        IS_IDENTICAL                                                 !0, 'a'
          2      > JMPZ                                                         ~1, ->5
          3    >   QM_ASSIGN                                            ~2      'a'
          4      > JMP                                                          ->6
          5    >   QM_ASSIGN                                            ~2      null
          6    > > RETURN                                                       ~2
   31     7*     > RETURN                                                       null

End of function offsetget

Function offsetset:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/v7YYP
function name:  offsetSet
number of ops:  4
compiled vars:  !0 = $offset, !1 = $value
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   33     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
   34     2      > RETURN                                                       null
   35     3*     > RETURN                                                       null

End of function offsetset

Function offsetunset:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/v7YYP
function name:  offsetUnset
number of ops:  3
compiled vars:  !0 = $offset
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   37     0  E >   RECV                                                 !0      
   38     1      > RETURN                                                       null
   39     2*     > RETURN                                                       null

End of function offsetunset

End of class Test.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
131.03 ms | 497 KiB | 7 Q