3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Animal { protected $color; protected $length; private function __construct(){} public static function fromLength($length) { $animal = new self(); $animal->length = $length; return $animal; } public static function fromColor($color) { $animal = new static(); $animal->color = $color; return $animal; } } class Dog extends Animal { } class Snake extends Animal { } $myAnimal = Animal::fromColor('red'); $mySnake = Snake::fromLength(10); $myDog = Dog::fromColor('brown'); var_dump($myAnimal); var_dump($mySnake); var_dump($myDog);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jrmfK
function name:  (null)
number of ops:  22
compiled vars:  !0 = $myAnimal, !1 = $mySnake, !2 = $myDog
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   INIT_STATIC_METHOD_CALL                                  'Animal', 'fromColor'
          1        SEND_VAL                                                 'red'
          2        DO_FCALL                                      0  $3      
          3        ASSIGN                                                   !0, $3
   35     4        INIT_STATIC_METHOD_CALL                                  'Snake', 'fromLength'
          5        SEND_VAL                                                 10
          6        DO_FCALL                                      0  $5      
          7        ASSIGN                                                   !1, $5
   36     8        INIT_STATIC_METHOD_CALL                                  'Dog', 'fromColor'
          9        SEND_VAL                                                 'brown'
         10        DO_FCALL                                      0  $7      
         11        ASSIGN                                                   !2, $7
   38    12        INIT_FCALL                                               'var_dump'
         13        SEND_VAR                                                 !0
         14        DO_ICALL                                                 
   39    15        INIT_FCALL                                               'var_dump'
         16        SEND_VAR                                                 !1
         17        DO_ICALL                                                 
   40    18        INIT_FCALL                                               'var_dump'
         19        SEND_VAR                                                 !2
         20        DO_ICALL                                                 
         21      > RETURN                                                   1

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

End of function __construct

Function fromlength:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jrmfK
function name:  fromLength
number of ops:  8
compiled vars:  !0 = $length, !1 = $animal
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
   12     1        NEW                          self                $2      
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $2
   13     4        ASSIGN_OBJ                                               !1, 'length'
          5        OP_DATA                                                  !0
   14     6      > RETURN                                                   !1
   15     7*     > RETURN                                                   null

End of function fromlength

Function fromcolor:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jrmfK
function name:  fromColor
number of ops:  8
compiled vars:  !0 = $color, !1 = $animal
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
   19     1        NEW                          static              $2      
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $2
   20     4        ASSIGN_OBJ                                               !1, 'color'
          5        OP_DATA                                                  !0
   21     6      > RETURN                                                   !1
   22     7*     > RETURN                                                   null

End of function fromcolor

End of class Animal.

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

End of function __construct

Function fromlength:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jrmfK
function name:  fromLength
number of ops:  8
compiled vars:  !0 = $length, !1 = $animal
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
   12     1        NEW                          self                $2      
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $2
   13     4        ASSIGN_OBJ                                               !1, 'length'
          5        OP_DATA                                                  !0
   14     6      > RETURN                                                   !1
   15     7*     > RETURN                                                   null

End of function fromlength

Function fromcolor:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jrmfK
function name:  fromColor
number of ops:  8
compiled vars:  !0 = $color, !1 = $animal
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
   19     1        NEW                          static              $2      
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $2
   20     4        ASSIGN_OBJ                                               !1, 'color'
          5        OP_DATA                                                  !0
   21     6      > RETURN                                                   !1
   22     7*     > RETURN                                                   null

End of function fromcolor

End of class Dog.

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

End of function __construct

Function fromlength:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jrmfK
function name:  fromLength
number of ops:  8
compiled vars:  !0 = $length, !1 = $animal
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
   12     1        NEW                          self                $2      
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $2
   13     4        ASSIGN_OBJ                                               !1, 'length'
          5        OP_DATA                                                  !0
   14     6      > RETURN                                                   !1
   15     7*     > RETURN                                                   null

End of function fromlength

Function fromcolor:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jrmfK
function name:  fromColor
number of ops:  8
compiled vars:  !0 = $color, !1 = $animal
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
   19     1        NEW                          static              $2      
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $2
   20     4        ASSIGN_OBJ                                               !1, 'color'
          5        OP_DATA                                                  !0
   21     6      > RETURN                                                   !1
   22     7*     > RETURN                                                   null

End of function fromcolor

End of class Snake.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.59 ms | 1404 KiB | 15 Q