3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Bar { public static function baz($string) { return $string . 'baz'; } } class Renderer { public function render(&$elements) { $elements['#printed'] = TRUE; return $elements['#markup']; } } class Foo { protected $renderer; public function __construct($renderer) { $this->renderer = $renderer; } public function fooIt($text) { $variables = array( 'text' => is_array($text) ? $this->renderer->render($text) : $text, ); $text = Bar::baz($variables['text']); print $text; } } $renderer = new Renderer(); $foo = new Foo($renderer); $text_array = array( '#markup' => 'foo', ); $foo->fooIt($text_array);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UAkFP
function name:  (null)
number of ops:  12
compiled vars:  !0 = $renderer, !1 = $foo, !2 = $text_array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   NEW                                              $3      'Renderer'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
   35     3        NEW                                              $6      'Foo'
          4        SEND_VAR_EX                                              !0
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !1, $6
   37     7        ASSIGN                                                   !2, <array>
   41     8        INIT_METHOD_CALL                                         !1, 'fooIt'
          9        SEND_VAR_EX                                              !2
         10        DO_FCALL                                      0          
         11      > RETURN                                                   1

Class Bar:
Function baz:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UAkFP
function name:  baz
number of ops:  4
compiled vars:  !0 = $string
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    5     1        CONCAT                                           ~1      !0, 'baz'
          2      > RETURN                                                   ~1
    6     3*     > RETURN                                                   null

End of function baz

End of class Bar.

Class Renderer:
Function render:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UAkFP
function name:  render
number of ops:  6
compiled vars:  !0 = $elements
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
   11     1        ASSIGN_DIM                                               !0, '%23printed'
          2        OP_DATA                                                  <true>
   12     3        FETCH_DIM_R                                      ~2      !0, '%23markup'
          4      > RETURN                                                   ~2
   13     5*     > RETURN                                                   null

End of function render

End of class Renderer.

Class Foo:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UAkFP
function name:  __construct
number of ops:  4
compiled vars:  !0 = $renderer
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
   20     1        ASSIGN_OBJ                                               'renderer'
          2        OP_DATA                                                  !0
   21     3      > RETURN                                                   null

End of function __construct

Function fooit:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 9
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UAkFP
function name:  fooIt
number of ops:  19
compiled vars:  !0 = $text, !1 = $variables
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   RECV                                             !0      
   25     1        TYPE_CHECK                                  128          !0
          2      > JMPZ                                                     ~2, ->9
          3    >   FETCH_OBJ_R                                      ~3      'renderer'
          4        INIT_METHOD_CALL                                         ~3, 'render'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0  $4      
          7        QM_ASSIGN                                        ~5      $4
          8      > JMP                                                      ->10
          9    >   QM_ASSIGN                                        ~5      !0
         10    >   INIT_ARRAY                                       ~6      ~5, 'text'
   24    11        ASSIGN                                                   !1, ~6
   28    12        INIT_STATIC_METHOD_CALL                                  'Bar', 'baz'
         13        FETCH_DIM_R                                      ~8      !1, 'text'
         14        SEND_VAL                                                 ~8
         15        DO_FCALL                                      0  $9      
         16        ASSIGN                                                   !0, $9
   30    17        ECHO                                                     !0
   31    18      > RETURN                                                   null

End of function fooit

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.25 ms | 1403 KiB | 13 Q