3v4l.org

run code in 300+ PHP versions simultaneously
<?php class AnalyzerContainer{ public function analyze(iData $data) { switch (true) { case $data instanceof Data1: $this->_getAnalyzer1()->ananlyzeData($data); break; case $data instanceof Data2: $this->_getAnalyzer2()->ananlyzeData($data); break; default: break; }; } protected function _getAnalyzer1() { return new Analyzer1(); } protected function _getAnalyzer2() { return new Analyzer2(); } } interface iData{}; class Data1 implements iData{ public $x = null; } class Data2 implements iData{ public $y = null; } class Analyzer1 { public function ananlyzeData(Data1 $data){ echo $data->x; } } class Analyzer2 { public function ananlyzeData(Data2 $data){ echo $data->y; } } $container = new AnalyzerContainer(); $data1 = new Data1(); $container->analyze($data1);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Y8MNe
function name:  (null)
number of ops:  12
compiled vars:  !0 = $container, !1 = $data1
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   DECLARE_CLASS                                            'data1'
   32     1        DECLARE_CLASS                                            'data2'
   48     2        NEW                                              $2      'AnalyzerContainer'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $2
   49     5        NEW                                              $5      'Data1'
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !1, $5
   50     8        INIT_METHOD_CALL                                         !0, 'analyze'
          9        SEND_VAR_EX                                              !1
         10        DO_FCALL                                      0          
         11      > RETURN                                                   1

Class AnalyzerContainer:
Function analyze:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 44) Position 1 = 3, Position 2 = 6
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 5, Position 2 = 12
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
filename:       /in/Y8MNe
function name:  analyze
number of ops:  20
compiled vars:  !0 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    6     1        INSTANCEOF                                               !0, 'Data1'
          2      > JMPNZ                                                    ~2, ->6
    9     3    >   INSTANCEOF                                               !0, 'Data2'
          4      > JMPNZ                                                    ~3, ->12
          5    > > JMP                                                      ->18
    7     6    >   INIT_METHOD_CALL                                         '_getAnalyzer1'
          7        DO_FCALL                                      0  $4      
          8        INIT_METHOD_CALL                                         $4, 'ananlyzeData'
          9        SEND_VAR_EX                                              !0
         10        DO_FCALL                                      0          
    8    11      > JMP                                                      ->19
   10    12    >   INIT_METHOD_CALL                                         '_getAnalyzer2'
         13        DO_FCALL                                      0  $6      
         14        INIT_METHOD_CALL                                         $6, 'ananlyzeData'
         15        SEND_VAR_EX                                              !0
         16        DO_FCALL                                      0          
   11    17      > JMP                                                      ->19
   13    18    > > JMP                                                      ->19
   15    19    > > RETURN                                                   null

End of function analyze

Function _getanalyzer1:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Y8MNe
function name:  _getAnalyzer1
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   NEW                                              $0      'Analyzer1'
          1        DO_FCALL                                      0          
          2      > RETURN                                                   $0
   19     3*     > RETURN                                                   null

End of function _getanalyzer1

Function _getanalyzer2:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Y8MNe
function name:  _getAnalyzer2
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   NEW                                              $0      'Analyzer2'
          1        DO_FCALL                                      0          
          2      > RETURN                                                   $0
   23     3*     > RETURN                                                   null

End of function _getanalyzer2

End of class AnalyzerContainer.

Class iData: [no user functions]
Class Data1: [no user functions]
Class Data2: [no user functions]
Class Analyzer1:
Function ananlyzedata:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Y8MNe
function name:  ananlyzeData
number of ops:  4
compiled vars:  !0 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   37     0  E >   RECV                                             !0      
   38     1        FETCH_OBJ_R                                      ~1      !0, 'x'
          2        ECHO                                                     ~1
   39     3      > RETURN                                                   null

End of function ananlyzedata

End of class Analyzer1.

Class Analyzer2:
Function ananlyzedata:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Y8MNe
function name:  ananlyzeData
number of ops:  4
compiled vars:  !0 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   43     0  E >   RECV                                             !0      
   44     1        FETCH_OBJ_R                                      ~1      !0, 'y'
          2        ECHO                                                     ~1
   45     3      > RETURN                                                   null

End of function ananlyzedata

End of class Analyzer2.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.14 ms | 1390 KiB | 13 Q