3v4l.org

run code in 300+ 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: " . ($foo->one() ? $foo->one()->two() : null);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 22
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UNmAg
function name:  (null)
number of ops:  26
compiled vars:  !0 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   NEW                                              $1      'Foo'
          1        DO_FCALL                                      0          
          2        INIT_METHOD_CALL                                         $1, 'one'
          3        DO_FCALL                                      0  $3      
          4        JMP_NULL                                         $4      $3
          5        INIT_METHOD_CALL                                         $3, 'two'
          6        DO_FCALL                                      0  $4      
          7        CONCAT                                           ~5      'Original%3A+', $4
          8        CONCAT                                           ~6      ~5, '%0A'
          9        ECHO                                                     ~6
   19    10        NEW                                              $7      'Foo'
         11        DO_FCALL                                      0          
         12        ASSIGN                                                   !0, $7
   20    13        INIT_METHOD_CALL                                         !0, 'one'
         14        DO_FCALL                                      0  $10     
         15      > JMPZ                                                     $10, ->22
         16    >   INIT_METHOD_CALL                                         !0, 'one'
         17        DO_FCALL                                      0  $11     
         18        INIT_METHOD_CALL                                         $11, 'two'
         19        DO_FCALL                                      0  $12     
         20        QM_ASSIGN                                        ~13     $12
         21      > JMP                                                      ->23
         22    >   QM_ASSIGN                                        ~13     null
         23    >   CONCAT                                           ~14     'Transpiled%3A+', ~13
         24        ECHO                                                     ~14
         25      > RETURN                                                   1

Class Foo:
Function one:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UNmAg
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/UNmAg
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.0.0


preferences:
127.37 ms | 1403 KiB | 13 Q