3v4l.org

run code in 300+ PHP versions simultaneously
<?php class CParent { private $arrMember = array(); private $mark; function CParent() { /* * If parent constructor run first, init() method'll get blank array. */ $this->setAttr(); } protected function init(){ return array(); } private function setAttr(){ $arr = $this->init(); foreach ($arr as $item){ array_push($this->arrMember, $item['name']); if (isset($item['mark']) && $item['mark'] == TRUE) $this->mark = $item['name']; } } } class CChild extends CParent { /* * I'd like to define variable within this method then pass to parent class. */ protected function init(){ return array( array('name' => 'v1', 'mark' => true), array('name' => 'v2'), array('name' => 'v3') ); } } print_r( new CChild);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/W8Tvk
function name:  (null)
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   44     0  E >   INIT_FCALL                                               'print_r'
          1        NEW                                              $0      'CChild'
          2        DO_FCALL                                      0          
          3        SEND_VAR                                                 $0
          4        DO_ICALL                                                 
          5      > RETURN                                                   1

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

End of function cparent

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

End of function init

Function setattr:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 21
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 21
Branch analysis from position: 5
2 jumps found. (Code = 46) Position 1 = 13, Position 2 = 16
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 20
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 20
Branch analysis from position: 16
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
filename:       /in/W8Tvk
function name:  setAttr
number of ops:  23
compiled vars:  !0 = $arr, !1 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   INIT_METHOD_CALL                                         'init'
          1        DO_FCALL                                      0  $2      
          2        ASSIGN                                                   !0, $2
   20     3      > FE_RESET_R                                       $4      !0, ->21
          4    > > FE_FETCH_R                                               $4, !1, ->21
   21     5    >   INIT_FCALL                                               'array_push'
          6        FETCH_OBJ_W                                      $5      'arrMember'
          7        SEND_REF                                                 $5
          8        FETCH_DIM_R                                      ~6      !1, 'name'
          9        SEND_VAL                                                 ~6
         10        DO_ICALL                                                 
   23    11        ISSET_ISEMPTY_DIM_OBJ                         0  ~8      !1, 'mark'
         12      > JMPZ_EX                                          ~8      ~8, ->16
         13    >   FETCH_DIM_R                                      ~9      !1, 'mark'
         14        BOOL                                             ~10     ~9
         15        BOOL                                             ~8      ~10
         16    > > JMPZ                                                     ~8, ->20
   24    17    >   FETCH_DIM_R                                      ~12     !1, 'name'
         18        ASSIGN_OBJ                                               'mark'
         19        OP_DATA                                                  ~12
   20    20    > > JMP                                                      ->4
         21    >   FE_FREE                                                  $4
   26    22      > RETURN                                                   null

End of function setattr

End of class CParent.

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

End of function init

Function cparent:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/W8Tvk
function name:  CParent
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   INIT_METHOD_CALL                                         'setAttr'
          1        DO_FCALL                                      0          
   12     2      > RETURN                                                   null

End of function cparent

Function setattr:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 21
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 21
Branch analysis from position: 5
2 jumps found. (Code = 46) Position 1 = 13, Position 2 = 16
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 20
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 20
Branch analysis from position: 16
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
filename:       /in/W8Tvk
function name:  setAttr
number of ops:  23
compiled vars:  !0 = $arr, !1 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   INIT_METHOD_CALL                                         'init'
          1        DO_FCALL                                      0  $2      
          2        ASSIGN                                                   !0, $2
   20     3      > FE_RESET_R                                       $4      !0, ->21
          4    > > FE_FETCH_R                                               $4, !1, ->21
   21     5    >   INIT_FCALL                                               'array_push'
          6        FETCH_OBJ_W                                      $5      'arrMember'
          7        SEND_REF                                                 $5
          8        FETCH_DIM_R                                      ~6      !1, 'name'
          9        SEND_VAL                                                 ~6
         10        DO_ICALL                                                 
   23    11        ISSET_ISEMPTY_DIM_OBJ                         0  ~8      !1, 'mark'
         12      > JMPZ_EX                                          ~8      ~8, ->16
         13    >   FETCH_DIM_R                                      ~9      !1, 'mark'
         14        BOOL                                             ~10     ~9
         15        BOOL                                             ~8      ~10
         16    > > JMPZ                                                     ~8, ->20
   24    17    >   FETCH_DIM_R                                      ~12     !1, 'name'
         18        ASSIGN_OBJ                                               'mark'
         19        OP_DATA                                                  ~12
   20    20    > > JMP                                                      ->4
         21    >   FE_FREE                                                  $4
   26    22      > RETURN                                                   null

End of function setattr

End of class CChild.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.06 ms | 1404 KiB | 17 Q