3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Vehicle { /** * @var string */ private $name; protected static $type = 'vehicle'; /** * Vehicle constructor. * * @param $name */ public function __construct($name) { $this->name = $name; } /** * @param $type * @return static */ public static function createStatic($type) { return new static($type); } /** * @param $type * @return \Vehicle */ public static function createSelf($type) { return new self($type); } /** * @return string */ public function getStaticType() { return static::$type; } /** * @return string */ public function getSelfType() { return self::$type; } } class Bicycle extends Vehicle { protected static $type = 'bicycle'; /**getSelfType * @inheritDoc */ public function __construct($name) { parent::__construct($name); } } class Car extends Vehicle { protected static $type = 'car'; /** * @inheritDoc */ public function __construct($name) { parent::__construct($name); } } $vehicle = new Vehicle('vehicle1'); $bicycle = new Bicycle('bicycle1'); $car = new Car('car1'); var_dump('new Vehicle(\'vehicle\') is a ' . get_class($vehicle)); var_dump('new Bicycle(\'bicycle\') is a ' . get_class($bicycle)); var_dump('new Car(\'car\') is a ' . get_class($car)); var_dump('$car->getSelfType() is ' . $car->getSelfType()); var_dump('$car->getStaticType() is ' . $car->getStaticType()); $staticThing1 = Vehicle::createStatic('staticThing1'); $staticThing2 = Bicycle::createStatic('staticThing2'); $staticThing3 = Car::createStatic('staticThing3'); var_dump('Vehicle::createStatic(\'staticThing1\') is a ' . get_class($staticThing1)); var_dump('Bicycle::createStatic(\'staticThing2\') is a ' . get_class($staticThing2)); var_dump('Car::createStatic(\'staticThing3\') is a ' . get_class($staticThing3)); var_dump('$staticThing3->getSelfType() is ' . $staticThing3->getSelfType()); var_dump('$staticThing3->getStaticType() is ' . $staticThing3->getStaticType()); $selfThing1 = Vehicle::createSelf('selfThing1'); $selfThing2 = Bicycle::createSelf('selfThing2'); $selfThing3 = Car::createSelf('selfThing3'); var_dump('Vehicle::createSelf(\'selfThing1\') is a ' . get_class($selfThing1)); var_dump('Bicycle::createSelf(\'selfThing2\') is a ' . get_class($selfThing2)); var_dump('Car::createSelf(\'selfThing3\') is a ' . get_class($selfThing3)); var_dump('$selfThing3->getSelfType() is ' . $selfThing3->getSelfType()); var_dump('$selfThing3->getStaticType() is ' . $selfThing3->getStaticType());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HBXAe
function name:  (null)
number of ops:  118
compiled vars:  !0 = $vehicle, !1 = $bicycle, !2 = $car, !3 = $staticThing1, !4 = $staticThing2, !5 = $staticThing3, !6 = $selfThing1, !7 = $selfThing2, !8 = $selfThing3
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   78     0  E >   NEW                                              $9      'Vehicle'
          1        SEND_VAL_EX                                              'vehicle1'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $9
   79     4        NEW                                              $12     'Bicycle'
          5        SEND_VAL_EX                                              'bicycle1'
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !1, $12
   80     8        NEW                                              $15     'Car'
          9        SEND_VAL_EX                                              'car1'
         10        DO_FCALL                                      0          
         11        ASSIGN                                                   !2, $15
   82    12        INIT_FCALL                                               'var_dump'
         13        GET_CLASS                                        ~18     !0
         14        CONCAT                                           ~19     'new+Vehicle%28%27vehicle%27%29+is+a+', ~18
         15        SEND_VAL                                                 ~19
         16        DO_ICALL                                                 
   83    17        INIT_FCALL                                               'var_dump'
         18        GET_CLASS                                        ~21     !1
         19        CONCAT                                           ~22     'new+Bicycle%28%27bicycle%27%29+is+a+', ~21
         20        SEND_VAL                                                 ~22
         21        DO_ICALL                                                 
   84    22        INIT_FCALL                                               'var_dump'
         23        GET_CLASS                                        ~24     !2
         24        CONCAT                                           ~25     'new+Car%28%27car%27%29+is+a+', ~24
         25        SEND_VAL                                                 ~25
         26        DO_ICALL                                                 
   85    27        INIT_FCALL                                               'var_dump'
         28        INIT_METHOD_CALL                                         !2, 'getSelfType'
         29        DO_FCALL                                      0  $27     
         30        CONCAT                                           ~28     '%24car-%3EgetSelfType%28%29+is+', $27
         31        SEND_VAL                                                 ~28
         32        DO_ICALL                                                 
   86    33        INIT_FCALL                                               'var_dump'
         34        INIT_METHOD_CALL                                         !2, 'getStaticType'
         35        DO_FCALL                                      0  $30     
         36        CONCAT                                           ~31     '%24car-%3EgetStaticType%28%29+is+', $30
         37        SEND_VAL                                                 ~31
         38        DO_ICALL                                                 
   89    39        INIT_STATIC_METHOD_CALL                                  'Vehicle', 'createStatic'
         40        SEND_VAL                                                 'staticThing1'
         41        DO_FCALL                                      0  $33     
         42        ASSIGN                                                   !3, $33
   90    43        INIT_STATIC_METHOD_CALL                                  'Bicycle', 'createStatic'
         44        SEND_VAL                                                 'staticThing2'
         45        DO_FCALL                                      0  $35     
         46        ASSIGN                                                   !4, $35
   91    47        INIT_STATIC_METHOD_CALL                                  'Car', 'createStatic'
         48        SEND_VAL                                                 'staticThing3'
         49        DO_FCALL                                      0  $37     
         50        ASSIGN                                                   !5, $37
   93    51        INIT_FCALL                                               'var_dump'
         52        GET_CLASS                                        ~39     !3
         53        CONCAT                                           ~40     'Vehicle%3A%3AcreateStatic%28%27staticThing1%27%29+is+a+', ~39
         54        SEND_VAL                                                 ~40
         55        DO_ICALL                                                 
   94    56        INIT_FCALL                                               'var_dump'
         57        GET_CLASS                                        ~42     !4
         58        CONCAT                                           ~43     'Bicycle%3A%3AcreateStatic%28%27staticThing2%27%29+is+a+', ~42
         59        SEND_VAL                                                 ~43
         60        DO_ICALL                                                 
   95    61        INIT_FCALL                                               'var_dump'
         62        GET_CLASS                                        ~45     !5
         63        CONCAT                                           ~46     'Car%3A%3AcreateStatic%28%27staticThing3%27%29+is+a+', ~45
         64        SEND_VAL                                                 ~46
         65        DO_ICALL                                                 
   96    66        INIT_FCALL                                               'var_dump'
         67        INIT_METHOD_CALL                                         !5, 'getSelfType'
         68        DO_FCALL                                      0  $48     
         69        CONCAT                                           ~49     '%24staticThing3-%3EgetSelfType%28%29+is+', $48
         70        SEND_VAL                                                 ~49
         71        DO_ICALL                                                 
   97    72        INIT_FCALL                                               'var_dump'
         73        INIT_METHOD_CALL                                         !5, 'getStaticType'
         74        DO_FCALL                                      0  $51     
         75        CONCAT                                           ~52     '%24staticThing3-%3EgetStaticType%28%29+is+', $51
         76        SEND_VAL                                                 ~52
         77        DO_ICALL                                                 
   99    78        INIT_STATIC_METHOD_CALL                                  'Vehicle', 'createSelf'
         79        SEND_VAL                                                 'selfThing1'
         80        DO_FCALL                                      0  $54     
         81        ASSIGN                                                   !6, $54
  100    82        INIT_STATIC_METHOD_CALL                                  'Bicycle', 'createSelf'
         83        SEND_VAL                                                 'selfThing2'
         84        DO_FCALL                                      0  $56     
         85        ASSIGN                                                   !7, $56
  101    86        INIT_STATIC_METHOD_CALL                                  'Car', 'createSelf'
         87        SEND_VAL                                                 'selfThing3'
         88        DO_FCALL                                      0  $58     
         89        ASSIGN                                                   !8, $58
  103    90        INIT_FCALL                                               'var_dump'
         91        GET_CLASS                                        ~60     !6
         92        CONCAT                                           ~61     'Vehicle%3A%3AcreateSelf%28%27selfThing1%27%29+is+a+', ~60
         93        SEND_VAL                                                 ~61
         94        DO_ICALL                                                 
  104    95        INIT_FCALL                                               'var_dump'
         96        GET_CLASS                                        ~63     !7
         97        CONCAT                                           ~64     'Bicycle%3A%3AcreateSelf%28%27selfThing2%27%29+is+a+', ~63
         98        SEND_VAL                                                 ~64
         99        DO_ICALL                                                 
  105   100        INIT_FCALL                                               'var_dump'
        101        GET_CLASS                                        ~66     !8
        102        CONCAT                                           ~67     'Car%3A%3AcreateSelf%28%27selfThing3%27%29+is+a+', ~66
        103        SEND_VAL                                                 ~67
        104        DO_ICALL                                                 
  106   105        INIT_FCALL                                               'var_dump'
        106        INIT_METHOD_CALL                                         !8, 'getSelfType'
        107        DO_FCALL                                      0  $69     
        108        CONCAT                                           ~70     '%24selfThing3-%3EgetSelfType%28%29+is+', $69
        109        SEND_VAL                                                 ~70
        110        DO_ICALL                                                 
  107   111        INIT_FCALL                                               'var_dump'
        112        INIT_METHOD_CALL                                         !8, 'getStaticType'
        113        DO_FCALL                                      0  $72     
        114        CONCAT                                           ~73     '%24selfThing3-%3EgetStaticType%28%29+is+', $72
        115        SEND_VAL                                                 ~73
        116        DO_ICALL                                                 
        117      > RETURN                                                   1

Class Vehicle:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HBXAe
function name:  __construct
number of ops:  4
compiled vars:  !0 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
   20     1        ASSIGN_OBJ                                               'name'
          2        OP_DATA                                                  !0
   21     3      > RETURN                                                   null

End of function __construct

Function createstatic:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HBXAe
function name:  createStatic
number of ops:  6
compiled vars:  !0 = $type
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   RECV                                             !0      
   28     1        NEW                          static              $1      
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
          4      > RETURN                                                   $1
   29     5*     > RETURN                                                   null

End of function createstatic

Function createself:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HBXAe
function name:  createSelf
number of ops:  6
compiled vars:  !0 = $type
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   RECV                                             !0      
   36     1        NEW                          self                $1      
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
          4      > RETURN                                                   $1
   37     5*     > RETURN                                                   null

End of function createself

Function getstatictype:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HBXAe
function name:  getStaticType
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   43     0  E >   FETCH_STATIC_PROP_R          unknown             ~0      'type'
          1      > RETURN                                                   ~0
   44     2*     > RETURN                                                   null

End of function getstatictype

Function getselftype:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HBXAe
function name:  getSelfType
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   50     0  E >   FETCH_STATIC_PROP_R          unknown             ~0      'type'
          1      > RETURN                                                   ~0
   51     2*     > RETURN                                                   null

End of function getselftype

End of class Vehicle.

Class Bicycle:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HBXAe
function name:  __construct
number of ops:  5
compiled vars:  !0 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   61     0  E >   RECV                                             !0      
   62     1        INIT_STATIC_METHOD_CALL                                  
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
   63     4      > RETURN                                                   null

End of function __construct

Function createstatic:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HBXAe
function name:  createStatic
number of ops:  6
compiled vars:  !0 = $type
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   RECV                                             !0      
   28     1        NEW                          static              $1      
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
          4      > RETURN                                                   $1
   29     5*     > RETURN                                                   null

End of function createstatic

Function createself:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HBXAe
function name:  createSelf
number of ops:  6
compiled vars:  !0 = $type
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   RECV                                             !0      
   36     1        NEW                          self                $1      
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
          4      > RETURN                                                   $1
   37     5*     > RETURN                                                   null

End of function createself

Function getstatictype:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HBXAe
function name:  getStaticType
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   43     0  E >   FETCH_STATIC_PROP_R          unknown             ~0      'type'
          1      > RETURN                                                   ~0
   44     2*     > RETURN                                                   null

End of function getstatictype

Function getselftype:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HBXAe
function name:  getSelfType
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   50     0  E >   FETCH_STATIC_PROP_R          unknown             ~0      'type'
          1      > RETURN                                                   ~0
   51     2*     > RETURN                                                   null

End of function getselftype

End of class Bicycle.

Class Car:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HBXAe
function name:  __construct
number of ops:  5
compiled vars:  !0 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   73     0  E >   RECV                                             !0      
   74     1        INIT_STATIC_METHOD_CALL                                  
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
   75     4      > RETURN                                                   null

End of function __construct

Function createstatic:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HBXAe
function name:  createStatic
number of ops:  6
compiled vars:  !0 = $type
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   RECV                                             !0      
   28     1        NEW                          static              $1      
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
          4      > RETURN                                                   $1
   29     5*     > RETURN                                                   null

End of function createstatic

Function createself:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HBXAe
function name:  createSelf
number of ops:  6
compiled vars:  !0 = $type
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   RECV                                             !0      
   36     1        NEW                          self                $1      
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
          4      > RETURN                                                   $1
   37     5*     > RETURN                                                   null

End of function createself

Function getstatictype:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HBXAe
function name:  getStaticType
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   43     0  E >   FETCH_STATIC_PROP_R          unknown             ~0      'type'
          1      > RETURN                                                   ~0
   44     2*     > RETURN                                                   null

End of function getstatictype

Function getselftype:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HBXAe
function name:  getSelfType
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   50     0  E >   FETCH_STATIC_PROP_R          unknown             ~0      'type'
          1      > RETURN                                                   ~0
   51     2*     > RETURN                                                   null

End of function getselftype

End of class Car.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.21 ms | 1021 KiB | 14 Q