3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php interface Logger { public function log(string $msg); } class Application { private $logger; public function getLogger(): Logger { return $this->logger; } public function setLogger(Logger $logger) { $this->logger = $logger; } } $app = new Application; $app->setLogger(new class implements Logger { public function log(string $msg) { echo $msg; } }); var_dump($app->getLogger()->log("bla bla")); ?>
based on AYAQd
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4bYGi
function name:  (null)
number of ops:  22
compiled vars:  !0 = $app
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   2     0  E >   NOP                                                      
   6     1        NOP                                                      
  18     2        NEW                                              $3      :-5
         3        DO_FCALL                                      0          
         4        ASSIGN                                                   !0, $3
  19     5        INIT_METHOD_CALL                                         !0, 'setLogger'
         6        DECLARE_ANON_CLASS                               :6      
         7        ADD_INTERFACE                                            $6, 'Logger'
         8        VERIFY_ABSTRACT_CLASS                                    $6
         9        NEW                                              $7      :6
        10        DO_FCALL                                      0          
        11        SEND_VAR_NO_REF_EX                                       $7
        12        DO_FCALL                                      0          
  25    13        INIT_FCALL                                               'var_dump'
        14        INIT_METHOD_CALL                                         !0, 'getLogger'
        15        DO_FCALL                                      0  $10     
        16        INIT_METHOD_CALL                                         $10, 'log'
        17        SEND_VAL_EX                                              'bla+bla'
        18        DO_FCALL                                      0  $11     
        19        SEND_VAR                                                 $11
        20        DO_ICALL                                                 
  26    21      > RETURN                                                   1

Class Logger:
Function log:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4bYGi
function name:  log
number of ops:  2
compiled vars:  !0 = $msg
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   3     0  E >   RECV                                             !0      
         1      > RETURN                                                   null

End of function log

End of class Logger.

Class Application:
Function getlogger:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4bYGi
function name:  getLogger
number of ops:  5
compiled vars:  none
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  10     0  E >   FETCH_OBJ_R                                      $0      'logger'
         1        VERIFY_RETURN_TYPE                                       $0
         2      > RETURN                                                   $0
  11     3*       VERIFY_RETURN_TYPE                                       
         4*     > RETURN                                                   null

End of function getlogger

Function setlogger:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4bYGi
function name:  setLogger
number of ops:  4
compiled vars:  !0 = $logger
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  13     0  E >   RECV                                             !0      
  14     1        ASSIGN_OBJ                                               'logger'
         2        OP_DATA                                                  !0
  15     3      > RETURN                                                   null

End of function setlogger

End of class Application.

Class class@anonymous:
Function log:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4bYGi
function name:  log
number of ops:  3
compiled vars:  !0 = $msg
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  20     0  E >   RECV                                             !0      
  21     1        ECHO                                                     !0
  22     2      > RETURN                                                   null

End of function log

End of class class@anonymous.

Generated using Vulcan Logic Dumper, using php 7.3.0