3v4l.org

run code in 300+ PHP versions simultaneously
<?php abstract class Base { protected $foo = null; final public function __construct(Granny $init = null) { return $this->init($init); } abstract protected function init(Granny $dependency = null); } class Granny { protected $name = null; protected $age = null; public function __construct(array $vals = null) { foreach($vals as $name => $val) { $name = 'set'.ucfirst($name); if (method_exists($this, $name)) { $this->{$name}($val); } } return $this; } //basic gettter && setters public function getAge() { return $this->age; } public function setAge($age = null) { $this->age = $age === null ? null : (int) $age; return $this; } } class Dad extends Granny { //Dad's secret private $likesMom = null; public function getLikesMom() { return $this->likesMom; } public function setLikesMom($bool = null) { $this->likesMom = $bool === null ? null : !!$bool; return $this; } } trait dependOnDad { protected function init(Dad $dependency = null) { $this->foo = $dependency; return $this; } } class Ball extends Base { use dependOnDad; } var_dump(new Ball());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8bhIF
function name:  (null)
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   61     0  E >   DECLARE_CLASS                                            'ball', 'base'
   65     1        INIT_FCALL                                               'var_dump'
          2        NEW                                              $0      'Ball'
          3        DO_FCALL                                      0          
          4        SEND_VAR                                                 $0
          5        DO_ICALL                                                 
          6      > RETURN                                                   1

Class Base:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8bhIF
function name:  __construct
number of ops:  6
compiled vars:  !0 = $init
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV_INIT                                        !0      null
    7     1        INIT_METHOD_CALL                                         'init'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0  $1      
          4      > RETURN                                                   $1
    8     5*     > 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/8bhIF
function name:  init
number of ops:  2
compiled vars:  !0 = $dependency
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV_INIT                                        !0      null
          1      > RETURN                                                   null

End of function init

End of class Base.

Class Granny:
Function __construct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 19
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 19
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 18
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 18
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
filename:       /in/8bhIF
function name:  __construct
number of ops:  23
compiled vars:  !0 = $vals, !1 = $val, !2 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV_INIT                                        !0      null
   18     1      > FE_RESET_R                                       $3      !0, ->19
          2    > > FE_FETCH_R                                       ~4      $3, !1, ->19
          3    >   ASSIGN                                                   !2, ~4
   20     4        INIT_FCALL                                               'ucfirst'
          5        SEND_VAR                                                 !2
          6        DO_ICALL                                         $6      
          7        CONCAT                                           ~7      'set', $6
          8        ASSIGN                                                   !2, ~7
   21     9        INIT_FCALL                                               'method_exists'
         10        FETCH_THIS                                       ~9      
         11        SEND_VAL                                                 ~9
         12        SEND_VAR                                                 !2
         13        DO_ICALL                                         $10     
         14      > JMPZ                                                     $10, ->18
   23    15    >   INIT_METHOD_CALL                                         !2
         16        SEND_VAR_EX                                              !1
         17        DO_FCALL                                      0          
   18    18    > > JMP                                                      ->2
         19    >   FE_FREE                                                  $3
   26    20        FETCH_THIS                                       ~12     
         21      > RETURN                                                   ~12
   27    22*     > RETURN                                                   null

End of function __construct

Function getage:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8bhIF
function name:  getAge
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   FETCH_OBJ_R                                      ~0      'age'
          1      > RETURN                                                   ~0
   32     2*     > RETURN                                                   null

End of function getage

Function setage:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 5
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8bhIF
function name:  setAge
number of ops:  12
compiled vars:  !0 = $age
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   RECV_INIT                                        !0      null
   35     1        TYPE_CHECK                                    2          !0
          2      > JMPZ                                                     ~2, ->5
          3    >   QM_ASSIGN                                        ~3      null
          4      > JMP                                                      ->7
          5    >   CAST                                          4  ~4      !0
          6        QM_ASSIGN                                        ~3      ~4
          7    >   ASSIGN_OBJ                                               'age'
          8        OP_DATA                                                  ~3
   36     9        FETCH_THIS                                       ~5      
         10      > RETURN                                                   ~5
   37    11*     > RETURN                                                   null

End of function setage

End of class Granny.

Class Dad:
Function getlikesmom:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8bhIF
function name:  getLikesMom
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   46     0  E >   FETCH_OBJ_R                                      ~0      'likesMom'
          1      > RETURN                                                   ~0
   47     2*     > RETURN                                                   null

End of function getlikesmom

Function setlikesmom:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 5
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8bhIF
function name:  setLikesMom
number of ops:  13
compiled vars:  !0 = $bool
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   48     0  E >   RECV_INIT                                        !0      null
   50     1        TYPE_CHECK                                    2          !0
          2      > JMPZ                                                     ~2, ->5
          3    >   QM_ASSIGN                                        ~3      null
          4      > JMP                                                      ->8
          5    >   BOOL_NOT                                         ~4      !0
          6        BOOL_NOT                                         ~5      ~4
          7        QM_ASSIGN                                        ~3      ~5
          8    >   ASSIGN_OBJ                                               'likesMom'
          9        OP_DATA                                                  ~3
   51    10        FETCH_THIS                                       ~6      
         11      > RETURN                                                   ~6
   52    12*     > RETURN                                                   null

End of function setlikesmom

Function __construct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 19
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 19
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 18
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 18
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
filename:       /in/8bhIF
function name:  __construct
number of ops:  23
compiled vars:  !0 = $vals, !1 = $val, !2 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV_INIT                                        !0      null
   18     1      > FE_RESET_R                                       $3      !0, ->19
          2    > > FE_FETCH_R                                       ~4      $3, !1, ->19
          3    >   ASSIGN                                                   !2, ~4
   20     4        INIT_FCALL                                               'ucfirst'
          5        SEND_VAR                                                 !2
          6        DO_ICALL                                         $6      
          7        CONCAT                                           ~7      'set', $6
          8        ASSIGN                                                   !2, ~7
   21     9        INIT_FCALL                                               'method_exists'
         10        FETCH_THIS                                       ~9      
         11        SEND_VAL                                                 ~9
         12        SEND_VAR                                                 !2
         13        DO_ICALL                                         $10     
         14      > JMPZ                                                     $10, ->18
   23    15    >   INIT_METHOD_CALL                                         !2
         16        SEND_VAR_EX                                              !1
         17        DO_FCALL                                      0          
   18    18    > > JMP                                                      ->2
         19    >   FE_FREE                                                  $3
   26    20        FETCH_THIS                                       ~12     
         21      > RETURN                                                   ~12
   27    22*     > RETURN                                                   null

End of function __construct

Function getage:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8bhIF
function name:  getAge
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   FETCH_OBJ_R                                      ~0      'age'
          1      > RETURN                                                   ~0
   32     2*     > RETURN                                                   null

End of function getage

Function setage:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 5
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8bhIF
function name:  setAge
number of ops:  12
compiled vars:  !0 = $age
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   RECV_INIT                                        !0      null
   35     1        TYPE_CHECK                                    2          !0
          2      > JMPZ                                                     ~2, ->5
          3    >   QM_ASSIGN                                        ~3      null
          4      > JMP                                                      ->7
          5    >   CAST                                          4  ~4      !0
          6        QM_ASSIGN                                        ~3      ~4
          7    >   ASSIGN_OBJ                                               'age'
          8        OP_DATA                                                  ~3
   36     9        FETCH_THIS                                       ~5      
         10      > RETURN                                                   ~5
   37    11*     > RETURN                                                   null

End of function setage

End of class Dad.

Class dependOnDad:
Function init:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8bhIF
function name:  init
number of ops:  6
compiled vars:  !0 = $dependency
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   55     0  E >   RECV_INIT                                        !0      null
   57     1        ASSIGN_OBJ                                               'foo'
          2        OP_DATA                                                  !0
   58     3        FETCH_THIS                                       ~2      
          4      > RETURN                                                   ~2
   59     5*     > RETURN                                                   null

End of function init

End of class dependOnDad.

Class Ball: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.73 ms | 1408 KiB | 19 Q