3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Person { public $name; public function __construct($name) { $this->name = $name; } public function getData() { return ['name' => $this->name]; } // демонстрация позднего статического связывания public final function getFullData() { return static::getData(); } } class Student extends Person { public $education; public $place; public function __construct ($name, $education, $place) { parent::__construct($name); $this->education = $education; $this->place = $place; } public function getData() { return array_merge(parent::getData(), [ 'education' => $this->education, 'place' => $this->place ]); } } $s = new Student('Alex', 'science', 'MIT'); var_dump($s->getData()); var_dump($s->getFullData());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6712J
function name:  (null)
number of ops:  17
compiled vars:  !0 = $s
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   NEW                                              $1      'Student'
          1        SEND_VAL_EX                                              'Alex'
          2        SEND_VAL_EX                                              'science'
          3        SEND_VAL_EX                                              'MIT'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !0, $1
   32     6        INIT_FCALL                                               'var_dump'
          7        INIT_METHOD_CALL                                         !0, 'getData'
          8        DO_FCALL                                      0  $4      
          9        SEND_VAR                                                 $4
         10        DO_ICALL                                                 
   33    11        INIT_FCALL                                               'var_dump'
         12        INIT_METHOD_CALL                                         !0, 'getFullData'
         13        DO_FCALL                                      0  $6      
         14        SEND_VAR                                                 $6
         15        DO_ICALL                                                 
         16      > RETURN                                                   1

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

End of function __construct

Function getdata:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6712J
function name:  getData
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   FETCH_OBJ_R                                      ~0      'name'
          1        INIT_ARRAY                                       ~1      ~0, 'name'
          2      > RETURN                                                   ~1
   10     3*     > RETURN                                                   null

End of function getdata

Function getfulldata:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6712J
function name:  getFullData
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   INIT_STATIC_METHOD_CALL                                  'getData'
          1        DO_FCALL                                      0  $0      
          2      > RETURN                                                   $0
   14     3*     > RETURN                                                   null

End of function getfulldata

End of class Person.

Class Student:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6712J
function name:  __construct
number of ops:  11
compiled vars:  !0 = $name, !1 = $education, !2 = $place
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   20     3        INIT_STATIC_METHOD_CALL                                  
          4        SEND_VAR_EX                                              !0
          5        DO_FCALL                                      0          
   21     6        ASSIGN_OBJ                                               'education'
          7        OP_DATA                                                  !1
   22     8        ASSIGN_OBJ                                               'place'
          9        OP_DATA                                                  !2
   23    10      > RETURN                                                   null

End of function __construct

Function getdata:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6712J
function name:  getData
number of ops:  12
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   INIT_FCALL                                               'array_merge'
          1        INIT_STATIC_METHOD_CALL                                  'getData'
          2        DO_FCALL                                      0  $0      
          3        SEND_VAR                                                 $0
   26     4        FETCH_OBJ_R                                      ~1      'education'
          5        INIT_ARRAY                                       ~2      ~1, 'education'
   27     6        FETCH_OBJ_R                                      ~3      'place'
          7        ADD_ARRAY_ELEMENT                                ~2      ~3, 'place'
          8        SEND_VAL                                                 ~2
          9        DO_ICALL                                         $4      
         10      > RETURN                                                   $4
   29    11*     > RETURN                                                   null

End of function getdata

Function getfulldata:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6712J
function name:  getFullData
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   INIT_STATIC_METHOD_CALL                                  'getData'
          1        DO_FCALL                                      0  $0      
          2      > RETURN                                                   $0
   14     3*     > RETURN                                                   null

End of function getfulldata

End of class Student.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.14 ms | 1400 KiB | 17 Q