3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Coalescing { protected $attributes = [ 'attribute1' => 'value1', ]; public function __get($name) { print "GET\n"; if (array_key_exists($name, $this->attributes)) { return $this->attributes[$name]; } trigger_error("Property $name does not exist"); return null; } public function __isset($name) { print "ISSET\n"; return array_key_exists($name, $this->attributes); } } $coal = new Coalescing(); defined("T_COALESCE") && eval('var_dump($coal->attribute1 ?? "default");'); //GET //string(6) "value1" defined("T_COALESCE") && eval('var_dump($coal->attribute2 ?? "default");'); //GET //PHP Notice: Property attribute2 does not exist in /var/www/html/test.php on line 23 //PHP Stack trace: //PHP 1. {main}() /var/www/html/test.php:0 //PHP 2. Coalescing->__get() /var/www/html/test.php:41 //PHP 3. trigger_error() /var/www/html/test.php:23 ///var/www/html/test.php:41: //string(7) "default"
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5ZJJr
function name:  (null)
number of ops:  8
compiled vars:  !0 = $coal
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   NEW                                              $1      'Coalescing'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   30     3        INCLUDE_OR_EVAL                                  $4      'var_dump%28%24coal-%3Eattribute1+%3F%3F+%22default%22%29%3B', EVAL
          4        BOOL                                             ~5      $4
   34     5        INCLUDE_OR_EVAL                                  $6      'var_dump%28%24coal-%3Eattribute2+%3F%3F+%22default%22%29%3B', EVAL
          6        BOOL                                             ~7      $6
   42     7      > RETURN                                                   1

Class Coalescing:
Function __get:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 8
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5ZJJr
function name:  __get
number of ops:  16
compiled vars:  !0 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   11     1        ECHO                                                     'GET%0A'
   12     2        FETCH_OBJ_R                                      ~1      'attributes'
          3        ARRAY_KEY_EXISTS                                         !0, ~1
          4      > JMPZ                                                     ~2, ->8
   13     5    >   FETCH_OBJ_R                                      ~3      'attributes'
          6        FETCH_DIM_R                                      ~4      ~3, !0
          7      > RETURN                                                   ~4
   16     8    >   INIT_FCALL                                               'trigger_error'
          9        ROPE_INIT                                     3  ~6      'Property+'
         10        ROPE_ADD                                      1  ~6      ~6, !0
         11        ROPE_END                                      2  ~5      ~6, '+does+not+exist'
         12        SEND_VAL                                                 ~5
         13        DO_ICALL                                                 
   17    14      > RETURN                                                   null
   18    15*     > RETURN                                                   null

End of function __get

Function __isset:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5ZJJr
function name:  __isset
number of ops:  6
compiled vars:  !0 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
   22     1        ECHO                                                     'ISSET%0A'
   23     2        FETCH_OBJ_R                                      ~1      'attributes'
          3        ARRAY_KEY_EXISTS                                 ~2      !0, ~1
          4      > RETURN                                                   ~2
   24     5*     > RETURN                                                   null

End of function __isset

End of class Coalescing.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.45 ms | 1396 KiB | 15 Q