3v4l.org

run code in 300+ PHP versions simultaneously
<?php class NewClass { public $id; //here's your registry protected static $registry = array(); public function __construct($id) { $this->id = $id; $this->checkVars(); //if not failed, add to registry: self::$registry[] = $id; } public function checkVars() { if (empty($this->id)) { trigger_error('ID is a required parameter.'); } //checking if it's already used: elseif (in_array($this->id, self::$registry)) { trigger_error('ID "'.$this->id.'" was used already. Please insert a unique name.'); } } } $object1 = new NewClass('id1'); $object2 = new NewClass('id2'); $object3 = new NewClass('id1');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lUX2P
function name:  (null)
number of ops:  13
compiled vars:  !0 = $object1, !1 = $object2, !2 = $object3
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   NEW                                              $3      'NewClass'
          1        SEND_VAL_EX                                              'id1'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $3
   33     4        NEW                                              $6      'NewClass'
          5        SEND_VAL_EX                                              'id2'
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !1, $6
   34     8        NEW                                              $9      'NewClass'
          9        SEND_VAL_EX                                              'id1'
         10        DO_FCALL                                      0          
         11        ASSIGN                                                   !2, $9
         12      > RETURN                                                   1

Class NewClass:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lUX2P
function name:  __construct
number of ops:  9
compiled vars:  !0 = $id
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
   10     1        ASSIGN_OBJ                                               'id'
          2        OP_DATA                                                  !0
   12     3        INIT_METHOD_CALL                                         'checkVars'
          4        DO_FCALL                                      0          
   14     5        FETCH_STATIC_PROP_W          unknown             $3      'registry'
          6        ASSIGN_DIM                                               $3
          7        OP_DATA                                                  !0
   15     8      > RETURN                                                   null

End of function __construct

Function checkvars:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 2, Position 2 = 6
Branch analysis from position: 2
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 19
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
filename:       /in/lUX2P
function name:  checkVars
number of ops:  20
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   ISSET_ISEMPTY_PROP_OBJ                                   'id'
          1      > JMPZ                                                     ~0, ->6
   21     2    >   INIT_FCALL                                               'trigger_error'
          3        SEND_VAL                                                 'ID+is+a+required+parameter.'
          4        DO_ICALL                                                 
          5      > JMP                                                      ->19
   24     6    >   INIT_FCALL                                               'in_array'
          7        FETCH_OBJ_R                                      ~2      'id'
          8        SEND_VAL                                                 ~2
          9        FETCH_STATIC_PROP_R          unknown             ~3      'registry'
         10        SEND_VAL                                                 ~3
         11        DO_ICALL                                         $4      
         12      > JMPZ                                                     $4, ->19
   26    13    >   INIT_FCALL                                               'trigger_error'
         14        FETCH_OBJ_R                                      ~5      'id'
         15        CONCAT                                           ~6      'ID+%22', ~5
         16        CONCAT                                           ~7      ~6, '%22+was+used+already.+Please+insert+a+unique+name.'
         17        SEND_VAL                                                 ~7
         18        DO_ICALL                                                 
   28    19    > > RETURN                                                   null

End of function checkvars

End of class NewClass.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
170.23 ms | 1400 KiB | 17 Q