3v4l.org

run code in 300+ PHP versions simultaneously
<?php enum PaymentMethods : string { case PAYPAL = 'pay with paypal'; case STRIPE = 'pay with stripe'; public static function fromName(string $method): PaymentMethods { foreach(PaymentMethods::cases() as $case) { if ($case->name === $method) { return $case; } } return null; } } $method= "PAYPAL"; var_dump(PaymentMethods::fromName($method));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bbuX6
function name:  (null)
number of ops:  9
compiled vars:  !0 = $method
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   DECLARE_CLASS                                            'paymentmethods'
   20     1        ASSIGN                                                   !0, 'PAYPAL'
   22     2        INIT_FCALL                                               'var_dump'
          3        INIT_STATIC_METHOD_CALL                                  'PaymentMethods', 'fromName'
          4        SEND_VAR_EX                                              !0
          5        DO_FCALL                                      0  $2      
          6        SEND_VAR                                                 $2
          7        DO_ICALL                                                 
          8      > RETURN                                                   1

Class PaymentMethods:
Function fromname:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 12
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 12
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 11
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/bbuX6
function name:  fromName
number of ops:  17
compiled vars:  !0 = $method, !1 = $case
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   11     1        INIT_STATIC_METHOD_CALL                                  'PaymentMethods', 'cases'
          2        DO_FCALL                                      0  $2      
          3      > FE_RESET_R                                       $3      $2, ->12
          4    > > FE_FETCH_R                                               $3, !1, ->12
   12     5    >   FETCH_OBJ_R                                      ~4      !1, 'name'
          6        IS_IDENTICAL                                             !0, ~4
          7      > JMPZ                                                     ~5, ->11
   13     8    >   VERIFY_RETURN_TYPE                                       !1
          9        FE_FREE                                                  $3
         10      > RETURN                                                   !1
   11    11    > > JMP                                                      ->4
         12    >   FE_FREE                                                  $3
   16    13        VERIFY_RETURN_TYPE                               ~6      null
         14      > RETURN                                                   ~6
   17    15*       VERIFY_RETURN_TYPE                                       
         16*     > RETURN                                                   null

End of function fromname

End of class PaymentMethods.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
136.3 ms | 998 KiB | 14 Q