3v4l.org

run code in 300+ PHP versions simultaneously
<?php class World { static $id = 0; protected $uid; protected $worldName; const type = 'world'; public function __construct( $worldName ) { $this->setUID(); $this->worldName = $worldName; } private function setUID() { $this->uid = self::$id++; } public function whoIsPerson( Person $person ) { $personUID = $person->getUID(); if( $personUID === 0 && $this->worldName === 'Rapture' ) return 'Jack'; elseif( $personUID === 0 && $this->worldName === 'Columbia' ) return 'Elizabeth'; else return 'Unknown Person'; } } class Person { static $id = 0; protected $uid; public function __construct() { $this->setUID(); } private function setUID() { $this->uid = self::$id++; } public function getUID() { return $this->uid; } } $person1 = new Person(); $world1 = new World('Rapture'); echo $world1->whoIsPerson( $person1 ); $world2 = new World('Columbia'); echo $world2->whoIsPerson( $person1 ); var_dump( $person1, $world1, $world2 );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mT8X5
function name:  (null)
number of ops:  25
compiled vars:  !0 = $person1, !1 = $world1, !2 = $world2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   46     0  E >   NEW                                              $3      'Person'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
   48     3        NEW                                              $6      'World'
          4        SEND_VAL_EX                                              'Rapture'
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !1, $6
   49     7        INIT_METHOD_CALL                                         !1, 'whoIsPerson'
          8        SEND_VAR_EX                                              !0
          9        DO_FCALL                                      0  $9      
         10        ECHO                                                     $9
   51    11        NEW                                              $10     'World'
         12        SEND_VAL_EX                                              'Columbia'
         13        DO_FCALL                                      0          
         14        ASSIGN                                                   !2, $10
   52    15        INIT_METHOD_CALL                                         !2, 'whoIsPerson'
         16        SEND_VAR_EX                                              !0
         17        DO_FCALL                                      0  $13     
         18        ECHO                                                     $13
   54    19        INIT_FCALL                                               'var_dump'
         20        SEND_VAR                                                 !0
         21        SEND_VAR                                                 !1
         22        SEND_VAR                                                 !2
         23        DO_ICALL                                                 
         24      > RETURN                                                   1

Class World:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mT8X5
function name:  __construct
number of ops:  6
compiled vars:  !0 = $worldName
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
    9     1        INIT_METHOD_CALL                                         'setUID'
          2        DO_FCALL                                      0          
   10     3        ASSIGN_OBJ                                               'worldName'
          4        OP_DATA                                                  !0
   11     5      > RETURN                                                   null

End of function __construct

Function setuid:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mT8X5
function name:  setUID
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   POST_INC_STATIC_PROP                             ~1      'id'
          1        ASSIGN_OBJ                                               'uid'
          2        OP_DATA                                                  ~1
   15     3      > RETURN                                                   null

End of function setuid

Function whoisperson:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 6, Position 2 = 9
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 12
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
2 jumps found. (Code = 46) Position 1 = 14, Position 2 = 17
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 20
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
Branch analysis from position: 9
filename:       /in/mT8X5
function name:  whoIsPerson
number of ops:  22
compiled vars:  !0 = $person, !1 = $personUID
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
   18     1        INIT_METHOD_CALL                                         !0, 'getUID'
          2        DO_FCALL                                      0  $2      
          3        ASSIGN                                                   !1, $2
   20     4        IS_IDENTICAL                                     ~4      !1, 0
          5      > JMPZ_EX                                          ~4      ~4, ->9
          6    >   FETCH_OBJ_R                                      ~5      'worldName'
          7        IS_IDENTICAL                                     ~6      ~5, 'Rapture'
          8        BOOL                                             ~4      ~6
          9    > > JMPZ                                                     ~4, ->12
   21    10    > > RETURN                                                   'Jack'
         11*       JMP                                                      ->21
   22    12    >   IS_IDENTICAL                                     ~7      !1, 0
         13      > JMPZ_EX                                          ~7      ~7, ->17
         14    >   FETCH_OBJ_R                                      ~8      'worldName'
         15        IS_IDENTICAL                                     ~9      ~8, 'Columbia'
         16        BOOL                                             ~7      ~9
         17    > > JMPZ                                                     ~7, ->20
   23    18    > > RETURN                                                   'Elizabeth'
         19*       JMP                                                      ->21
   25    20    > > RETURN                                                   'Unknown+Person'
   26    21*     > RETURN                                                   null

End of function whoisperson

End of class World.

Class Person:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mT8X5
function name:  __construct
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   INIT_METHOD_CALL                                         'setUID'
          1        DO_FCALL                                      0          
   35     2      > RETURN                                                   null

End of function __construct

Function setuid:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mT8X5
function name:  setUID
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   38     0  E >   POST_INC_STATIC_PROP                             ~1      'id'
          1        ASSIGN_OBJ                                               'uid'
          2        OP_DATA                                                  ~1
   39     3      > RETURN                                                   null

End of function setuid

Function getuid:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mT8X5
function name:  getUID
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   42     0  E >   FETCH_OBJ_R                                      ~0      'uid'
          1      > RETURN                                                   ~0
   43     2*     > RETURN                                                   null

End of function getuid

End of class Person.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.14 ms | 1396 KiB | 15 Q