3v4l.org

run code in 300+ PHP versions simultaneously
<?PHP class Question { public function __construct(AnswerInterface $answer) { echo "What is 2 + 2?\n"; $answer = $answer->get()->the()->answer(); if ($answer instanceof AnswerInterface) { echo $answer . PHP_EOL; } } } interface AnswerInterface { public function get(); public function the(); public function answer(); } class Answer implements AnswerInterface{ private $answer; public function get(){ $this->answer = 2; return $this; } public function the(){ $this->answer = $this->answer + 2; return $this; } public function answer(){ return $this->answer; } } $answer = new Answer; $question = new Question($answer);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/g9ekn
function name:  (null)
number of ops:  9
compiled vars:  !0 = $answer, !1 = $question
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   DECLARE_CLASS                                            'answer'
   40     1        NEW                                              $2      'Answer'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $2
   41     4        NEW                                              $5      'Question'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !1, $5
          8      > RETURN                                                   1

Class Question:
Function __construct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 13
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/g9ekn
function name:  __construct
number of ops:  14
compiled vars:  !0 = $answer
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    7     1        ECHO                                                     'What+is+2+%2B+2%3F%0A'
    8     2        INIT_METHOD_CALL                                         !0, 'get'
          3        DO_FCALL                                      0  $1      
          4        INIT_METHOD_CALL                                         $1, 'the'
          5        DO_FCALL                                      0  $2      
          6        INIT_METHOD_CALL                                         $2, 'answer'
          7        DO_FCALL                                      0  $3      
          8        ASSIGN                                                   !0, $3
    9     9        INSTANCEOF                                               !0, 'AnswerInterface'
         10      > JMPZ                                                     ~5, ->13
   10    11    >   CONCAT                                           ~6      !0, '%0A'
         12        ECHO                                                     ~6
   12    13    > > RETURN                                                   null

End of function __construct

End of class Question.

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

End of function get

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

End of function the

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

End of function answer

End of class AnswerInterface.

Class Answer:
Function get:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/g9ekn
function name:  get
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   ASSIGN_OBJ                                               'answer'
          1        OP_DATA                                                  2
   26     2        FETCH_THIS                                       ~1      
          3      > RETURN                                                   ~1
   27     4*     > RETURN                                                   null

End of function get

Function the:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/g9ekn
function name:  the
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   FETCH_OBJ_R                                      ~1      'answer'
          1        ADD                                              ~2      ~1, 2
          2        ASSIGN_OBJ                                               'answer'
          3        OP_DATA                                                  ~2
   31     4        FETCH_THIS                                       ~3      
          5      > RETURN                                                   ~3
   32     6*     > RETURN                                                   null

End of function the

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

End of function answer

End of class Answer.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.45 ms | 1453 KiB | 13 Q