3v4l.org

run code in 500+ PHP versions simultaneously
<?php class Foo { protected $state = 0; public function one() { $this->state++; return $this; } public function two() { return $this->state; } } //echo "Original: " . ((new Foo())->one()?->two()) . "\n"; $foo = new Foo(); echo "Transpiled: " . (($result = $foo->one()) ? $result->two() : null);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 11
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nAtYp
function name:  (null)
number of ops:  15
compiled vars:  !0 = $foo, !1 = $result
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   19     0  E >   NEW                                                  $2      'Foo'
          1        DO_FCALL                                          0          
          2        ASSIGN                                                       !0, $2
   20     3        INIT_METHOD_CALL                                             !0, 'one'
          4        DO_FCALL                                          0  $5      
          5        ASSIGN                                               ~6      !1, $5
          6      > JMPZ                                                         ~6, ->11
          7    >   INIT_METHOD_CALL                                             !1, 'two'
          8        DO_FCALL                                          0  $7      
          9        QM_ASSIGN                                            ~8      $7
         10      > JMP                                                          ->12
         11    >   QM_ASSIGN                                            ~8      null
         12    >   CONCAT                                               ~9      'Transpiled%3A+', ~8
         13        ECHO                                                         ~9
         14      > RETURN                                                       1

Class Foo:
Function one:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nAtYp
function name:  one
number of ops:  4
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    7     0  E >   PRE_INC_OBJ                                                  'state'
    9     1        FETCH_THIS                                           ~1      
          2      > RETURN                                                       ~1
   10     3*     > RETURN                                                       null

End of function one

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

End of function two

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
212.17 ms | 2029 KiB | 13 Q