3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Container extends ArrayObject { function __set($k,$c){$this[$k]=$c;} function __get($k){return $this->get($k);} function get(string $id){return $this[$id]($this);} function has(string $id): bool {return isset($this[$id]);} } class Fizz { public function __toString() { return 'Fizz'; } } class Buzz { public function __toString() { return 'Buzz'; } } class FizzBuzz { public function __construct( private Fizz $fizz, private Buzz $buzz ) {} public function __invoke(int $i): string { if (!($i % 15)) return $this->fizz . $this->buzz; if (!($i % 3)) return (string) $this->fizz; if (!($i % 5)) return (string) $this->buzz; return (string) $i; } } $c = new Container; $c->fizz = fn () => new Fizz; $c->buzz = fn () => new Buzz; $c->fizzBuzz = fn ($c) => new FizzBuzz($c->fizz, $c->buzz); foreach (range(1, 15) as $i) { echo $c->get('fizzBuzz')($i) . "\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 19, Position 2 = 29
Branch analysis from position: 19
2 jumps found. (Code = 78) Position 1 = 20, Position 2 = 29
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
filename:       /in/2odC6
function name:  (null)
number of ops:  31
compiled vars:  !0 = $c, !1 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   DECLARE_CLASS                                            'fizz'
   11     1        DECLARE_CLASS                                            'buzz'
   25     2        NEW                                              $2      'Container'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $2
   26     5        DECLARE_LAMBDA_FUNCTION                          ~6      [0]
          6        ASSIGN_OBJ                                               !0, 'fizz'
          7        OP_DATA                                                  ~6
   27     8        DECLARE_LAMBDA_FUNCTION                          ~8      [1]
          9        ASSIGN_OBJ                                               !0, 'buzz'
         10        OP_DATA                                                  ~8
   28    11        DECLARE_LAMBDA_FUNCTION                          ~10     [2]
         12        ASSIGN_OBJ                                               !0, 'fizzBuzz'
   29    13        OP_DATA                                                  ~10
   32    14        INIT_FCALL                                               'range'
         15        SEND_VAL                                                 1
         16        SEND_VAL                                                 15
         17        DO_ICALL                                         $11     
         18      > FE_RESET_R                                       $12     $11, ->29
         19    > > FE_FETCH_R                                               $12, !1, ->29
   33    20    >   INIT_METHOD_CALL                                         !0, 'get'
         21        SEND_VAL_EX                                              'fizzBuzz'
         22        DO_FCALL                                      0  $13     
         23        INIT_DYNAMIC_CALL                                        $13
         24        SEND_VAR_EX                                              !1
         25        DO_FCALL                                      0  $14     
         26        CONCAT                                           ~15     $14, '%0A'
         27        ECHO                                                     ~15
   32    28      > JMP                                                      ->19
         29    >   FE_FREE                                                  $12
   34    30      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2odC6
function name:  {closure}
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   NEW                                              $0      'Fizz'
          1        DO_FCALL                                      0          
          2      > RETURN                                                   $0
          3*     > RETURN                                                   null

End of Dynamic Function 0

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

End of Dynamic Function 1

Dynamic Function 2
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2odC6
function name:  {closure}
number of ops:  11
compiled vars:  !0 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   RECV                                             !0      
   29     1        NEW                                              $1      'FizzBuzz'
          2        CHECK_FUNC_ARG                                           
          3        FETCH_OBJ_FUNC_ARG                               $2      !0, 'fizz'
          4        SEND_FUNC_ARG                                            $2
          5        CHECK_FUNC_ARG                                           
          6        FETCH_OBJ_FUNC_ARG                               $3      !0, 'buzz'
          7        SEND_FUNC_ARG                                            $3
          8        DO_FCALL                                      0          
          9      > RETURN                                                   $1
         10*     > RETURN                                                   null

End of Dynamic Function 2

Class Container:
Function __set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2odC6
function name:  __set
number of ops:  6
compiled vars:  !0 = $k, !1 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        FETCH_THIS                                       $2      
          3        ASSIGN_DIM                                               $2, !0
          4        OP_DATA                                                  !1
          5      > RETURN                                                   null

End of function __set

Function __get:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2odC6
function name:  __get
number of ops:  6
compiled vars:  !0 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        INIT_METHOD_CALL                                         'get'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0  $1      
          4      > RETURN                                                   $1
          5*     > RETURN                                                   null

End of function __get

Function get:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2odC6
function name:  get
number of ops:  9
compiled vars:  !0 = $id
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        FETCH_THIS                                       ~1      
          2        FETCH_DIM_R                                      ~2      ~1, !0
          3        INIT_DYNAMIC_CALL                                        ~2
          4        FETCH_THIS                                       $3      
          5        SEND_VAR_EX                                              $3
          6        DO_FCALL                                      0  $4      
          7      > RETURN                                                   $4
          8*     > RETURN                                                   null

End of function get

Function has:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2odC6
function name:  has
number of ops:  7
compiled vars:  !0 = $id
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        FETCH_THIS                                       ~1      
          2        ISSET_ISEMPTY_DIM_OBJ                         0  ~2      ~1, !0
          3        VERIFY_RETURN_TYPE                                       ~2
          4      > RETURN                                                   ~2
          5*       VERIFY_RETURN_TYPE                                       
          6*     > RETURN                                                   null

End of function has

End of class Container.

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

End of function __tostring

End of class Fizz.

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

End of function __tostring

End of class Buzz.

Class FizzBuzz:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2odC6
function name:  __construct
number of ops:  7
compiled vars:  !0 = $fizz, !1 = $buzz
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        ASSIGN_OBJ                                               'fizz'
          3        OP_DATA                                                  !0
          4        ASSIGN_OBJ                                               'buzz'
          5        OP_DATA                                                  !1
   16     6      > RETURN                                                   null

End of function __construct

Function __invoke:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 9
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 16
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 23
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2odC6
function name:  __invoke
number of ops:  28
compiled vars:  !0 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
   18     1        MOD                                              ~1      !0, 15
          2        BOOL_NOT                                         ~2      ~1
          3      > JMPZ                                                     ~2, ->9
          4    >   FETCH_OBJ_R                                      ~3      'fizz'
          5        FETCH_OBJ_R                                      ~4      'buzz'
          6        CONCAT                                           ~5      ~3, ~4
          7        VERIFY_RETURN_TYPE                                       ~5
          8      > RETURN                                                   ~5
   19     9    >   MOD                                              ~6      !0, 3
         10        BOOL_NOT                                         ~7      ~6
         11      > JMPZ                                                     ~7, ->16
         12    >   FETCH_OBJ_R                                      ~8      'fizz'
         13        CAST                                          6  ~9      ~8
         14        VERIFY_RETURN_TYPE                                       ~9
         15      > RETURN                                                   ~9
   20    16    >   MOD                                              ~10     !0, 5
         17        BOOL_NOT                                         ~11     ~10
         18      > JMPZ                                                     ~11, ->23
         19    >   FETCH_OBJ_R                                      ~12     'buzz'
         20        CAST                                          6  ~13     ~12
         21        VERIFY_RETURN_TYPE                                       ~13
         22      > RETURN                                                   ~13
   21    23    >   CAST                                          6  ~14     !0
         24        VERIFY_RETURN_TYPE                                       ~14
         25      > RETURN                                                   ~14
   22    26*       VERIFY_RETURN_TYPE                                       
         27*     > RETURN                                                   null

End of function __invoke

End of class FizzBuzz.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.49 ms | 1458 KiB | 14 Q