3v4l.org

run code in 300+ PHP versions simultaneously
<?php // https://github.com/bootgly/bootgly/blob/c54e0d585869dca734d301000cee79401640e749/Bootgly/CLI/Terminal/Output/Text.php#L329-L336 // https://github.com/bootgly/bootgly/blob/c54e0d585869dca734d301000cee79401640e749/Bootgly/ABI/Configs/Set.php#L14-L26 enum Colors : int { public function __call(string $name, array $arguments) { static $value; return match ($name) { 'get' => $value ?? $this, // $this->value; 'set' => $value = $this, // $this->value = $this; // @ PHP team: Why readonly here??? default => $this }; } case Default = 1; case Bright = 2; } function printSomething(Colors $colors, string $message): void { echo sprintf("I will print %s in %s colors\n", $message, $colors->get()->name); } Colors::Default->set(); printSomething(Colors::Bright, 'Hello World'); Colors::Bright->set(); printSomething(Colors::Default, 'Hello World');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/msluq
function name:  (null)
number of ops:  18
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   DECLARE_CLASS                                            'colors'
   29     1        FETCH_CLASS_CONSTANT                             ~0      'Colors', 'Default'
          2        INIT_METHOD_CALL                                         ~0, 'set'
          3        DO_FCALL                                      0          
   31     4        INIT_FCALL                                               'printsomething'
          5        FETCH_CLASS_CONSTANT                             ~2      'Colors', 'Bright'
          6        SEND_VAL                                                 ~2
          7        SEND_VAL                                                 'Hello+World'
          8        DO_FCALL                                      0          
   33     9        FETCH_CLASS_CONSTANT                             ~4      'Colors', 'Bright'
         10        INIT_METHOD_CALL                                         ~4, 'set'
         11        DO_FCALL                                      0          
   35    12        INIT_FCALL                                               'printsomething'
         13        FETCH_CLASS_CONSTANT                             ~6      'Colors', 'Default'
         14        SEND_VAL                                                 ~6
         15        SEND_VAL                                                 'Hello+World'
         16        DO_FCALL                                      0          
         17      > RETURN                                                   1

Function printsomething:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/msluq
function name:  printSomething
number of ops:  12
compiled vars:  !0 = $colors, !1 = $message
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   26     2        INIT_FCALL                                               'sprintf'
          3        SEND_VAL                                                 'I+will+print+%25s+in+%25s+colors%0A'
          4        SEND_VAR                                                 !1
          5        INIT_METHOD_CALL                                         !0, 'get'
          6        DO_FCALL                                      0  $2      
          7        FETCH_OBJ_R                                      ~3      $2, 'name'
          8        SEND_VAL                                                 ~3
          9        DO_ICALL                                         $4      
         10        ECHO                                                     $4
   27    11      > RETURN                                                   null

End of function printsomething

Class Colors:
Function __call:
Finding entry points
Branch analysis from position: 0
3 jumps found. (Code = 195) Position 1 = 4, Position 2 = 9, Position 3 = 13
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
filename:       /in/msluq
function name:  __call
number of ops:  18
compiled vars:  !0 = $name, !1 = $arguments, !2 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   10     2        BIND_STATIC                                              !2
   12     3      > MATCH                                                    !0, [ 'get':->4, 'set':->9, ], ->13
   13     4    >   COALESCE                                         ~4      !2
          5        FETCH_THIS                                       ~5      
          6        QM_ASSIGN                                        ~4      ~5
          7        QM_ASSIGN                                        ~6      ~4
          8      > JMP                                                      ->16
   14     9    >   FETCH_THIS                                       ~7      
         10        ASSIGN                                           ~8      !2, ~7
         11        QM_ASSIGN                                        ~6      ~8
         12      > JMP                                                      ->16
   15    13    >   FETCH_THIS                                       ~9      
         14        QM_ASSIGN                                        ~6      ~9
         15      > JMP                                                      ->16
         16    > > RETURN                                                   ~6
   17    17*     > RETURN                                                   null

End of function __call

End of class Colors.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
139.82 ms | 1005 KiB | 16 Q