3v4l.org

run code in 300+ PHP versions simultaneously
<?php final class TestClass { public static $currentValue; public static function toValue($value) { self::$currentValue = $value; return new static(); } public static function add($value) { self::$currentValue = self::$currentValue + $value; return new static(); } public static function subtract($value) { self::$currentValue = self::$currentValue - $value; return new static(); } public static function result() { return self::$currentValue; } } $value = TestClass::toValue(5)::add(3)::subtract(2)::add(8)::result(); var_dump($value);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BspcC
function name:  (null)
number of ops:  23
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   INIT_STATIC_METHOD_CALL                                  'TestClass', 'toValue'
          1        SEND_VAL                                                 5
          2        DO_FCALL                                      0  $1      
          3        FETCH_CLASS                                   0  $2      $1
          4        INIT_STATIC_METHOD_CALL                                  $2, 'add'
          5        SEND_VAL_EX                                              3
          6        DO_FCALL                                      0  $3      
          7        FETCH_CLASS                                   0  $4      $3
          8        INIT_STATIC_METHOD_CALL                                  $4, 'subtract'
          9        SEND_VAL_EX                                              2
         10        DO_FCALL                                      0  $5      
         11        FETCH_CLASS                                   0  $6      $5
         12        INIT_STATIC_METHOD_CALL                                  $6, 'add'
         13        SEND_VAL_EX                                              8
         14        DO_FCALL                                      0  $7      
         15        FETCH_CLASS                                   0  $8      $7
         16        INIT_STATIC_METHOD_CALL                                  $8, 'result'
         17        DO_FCALL                                      0  $9      
         18        ASSIGN                                                   !0, $9
   29    19        INIT_FCALL                                               'var_dump'
         20        SEND_VAR                                                 !0
         21        DO_ICALL                                                 
         22      > RETURN                                                   1

Class TestClass:
Function tovalue:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BspcC
function name:  toValue
number of ops:  7
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    7     1        ASSIGN_STATIC_PROP                                       'currentValue'
          2        OP_DATA                                                  !0
    9     3        NEW                          static              $2      
          4        DO_FCALL                                      0          
          5      > RETURN                                                   $2
   10     6*     > RETURN                                                   null

End of function tovalue

Function add:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BspcC
function name:  add
number of ops:  9
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   13     1        FETCH_STATIC_PROP_R          unknown             ~2      'currentValue'
          2        ADD                                              ~3      ~2, !0
          3        ASSIGN_STATIC_PROP                                       'currentValue'
          4        OP_DATA                                                  ~3
   14     5        NEW                          static              $4      
          6        DO_FCALL                                      0          
          7      > RETURN                                                   $4
   15     8*     > RETURN                                                   null

End of function add

Function subtract:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BspcC
function name:  subtract
number of ops:  9
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
   18     1        FETCH_STATIC_PROP_R          unknown             ~2      'currentValue'
          2        SUB                                              ~3      ~2, !0
          3        ASSIGN_STATIC_PROP                                       'currentValue'
          4        OP_DATA                                                  ~3
   19     5        NEW                          static              $4      
          6        DO_FCALL                                      0          
          7      > RETURN                                                   $4
   20     8*     > RETURN                                                   null

End of function subtract

Function result:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BspcC
function name:  result
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   FETCH_STATIC_PROP_R          unknown             ~0      'currentValue'
          1      > RETURN                                                   ~0
   24     2*     > RETURN                                                   null

End of function result

End of class TestClass.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.22 ms | 1400 KiB | 15 Q