3v4l.org

run code in 300+ PHP versions simultaneously
<?php abstract class CParent { private $arrMember = array(); private $mark; function __construct() { $this->setAttr(); } protected abstract function init(); 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/bG9ra
function name:  (null)
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   42     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 __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bG9ra
function name:  __construct
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   INIT_METHOD_CALL                                         'setAttr'
          1        DO_FCALL                                      0          
    9     2      > RETURN                                                   null

End of function __construct

Function init:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bG9ra
function name:  init
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E > > 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/bG9ra
function name:  setAttr
number of ops:  23
compiled vars:  !0 = $arr, !1 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   INIT_METHOD_CALL                                         'init'
          1        DO_FCALL                                      0  $2      
          2        ASSIGN                                                   !0, $2
   17     3      > FE_RESET_R                                       $4      !0, ->21
          4    > > FE_FETCH_R                                               $4, !1, ->21
   18     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                                                 
   20    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
   21    17    >   FETCH_DIM_R                                      ~12     !1, 'name'
         18        ASSIGN_OBJ                                               'mark'
         19        OP_DATA                                                  ~12
   17    20    > > JMP                                                      ->4
         21    >   FE_FREE                                                  $4
   23    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/bG9ra
function name:  init
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E > > RETURN                                                   <array>
   39     1*     > RETURN                                                   null

End of function init

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

End of function __construct

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/bG9ra
function name:  setAttr
number of ops:  23
compiled vars:  !0 = $arr, !1 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   INIT_METHOD_CALL                                         'init'
          1        DO_FCALL                                      0  $2      
          2        ASSIGN                                                   !0, $2
   17     3      > FE_RESET_R                                       $4      !0, ->21
          4    > > FE_FETCH_R                                               $4, !1, ->21
   18     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                                                 
   20    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
   21    17    >   FETCH_DIM_R                                      ~12     !1, 'name'
         18        ASSIGN_OBJ                                               'mark'
         19        OP_DATA                                                  ~12
   17    20    > > JMP                                                      ->4
         21    >   FE_FREE                                                  $4
   23    22      > RETURN                                                   null

End of function setattr

End of class CChild.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.77 ms | 1404 KiB | 17 Q