3v4l.org

run code in 300+ PHP versions simultaneously
<?php enum ProductCategories: string { case A = 'A'; case B = 'B'; case C = 'C'; case D = 'D'; } interface ProductCategoryProviderInterface { public function getLocalCategoryId(ProductCategories $category): ?string; } class A implements ProductCategoryProviderInterface { public function getLocalCategoryId(ProductCategories $category): ?string { return match ($category) { ProductCategories::A => '1', ProductCategories::B => '2', default => null, }; } } class B implements ProductCategoryProviderInterface { public function getLocalCategoryId(ProductCategories $category): ?string { return match ($category) { ProductCategories::A => 'cat_a', ProductCategories::B => 'cat_B', default => null, }; } } echo (new A())->getLocalCategoryId(ProductCategories::A) . "\n"; // 1 echo (new B())->getLocalCategoryId(ProductCategories::A) . "\n"; // cat_a echo (new A())->getLocalCategoryId(ProductCategories::B) . "\n"; // 2 echo (new B())->getLocalCategoryId(ProductCategories::B) . "\n"; // cat_b echo (new A())->getLocalCategoryId(ProductCategories::C) . "\n"; // null
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uNvjU
function name:  (null)
number of ops:  44
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'productcategories'
   16     1        DECLARE_CLASS                                            'a'
   28     2        DECLARE_CLASS                                            'b'
   40     3        NEW                                              $0      'A'
          4        DO_FCALL                                      0          
          5        INIT_METHOD_CALL                                         $0, 'getLocalCategoryId'
          6        FETCH_CLASS_CONSTANT                             ~2      'ProductCategories', 'A'
          7        SEND_VAL_EX                                              ~2
          8        DO_FCALL                                      0  $3      
          9        CONCAT                                           ~4      $3, '%0A'
         10        ECHO                                                     ~4
   41    11        NEW                                              $5      'B'
         12        DO_FCALL                                      0          
         13        INIT_METHOD_CALL                                         $5, 'getLocalCategoryId'
         14        FETCH_CLASS_CONSTANT                             ~7      'ProductCategories', 'A'
         15        SEND_VAL_EX                                              ~7
         16        DO_FCALL                                      0  $8      
         17        CONCAT                                           ~9      $8, '%0A'
         18        ECHO                                                     ~9
   43    19        NEW                                              $10     'A'
         20        DO_FCALL                                      0          
         21        INIT_METHOD_CALL                                         $10, 'getLocalCategoryId'
         22        FETCH_CLASS_CONSTANT                             ~12     'ProductCategories', 'B'
         23        SEND_VAL_EX                                              ~12
         24        DO_FCALL                                      0  $13     
         25        CONCAT                                           ~14     $13, '%0A'
         26        ECHO                                                     ~14
   44    27        NEW                                              $15     'B'
         28        DO_FCALL                                      0          
         29        INIT_METHOD_CALL                                         $15, 'getLocalCategoryId'
         30        FETCH_CLASS_CONSTANT                             ~17     'ProductCategories', 'B'
         31        SEND_VAL_EX                                              ~17
         32        DO_FCALL                                      0  $18     
         33        CONCAT                                           ~19     $18, '%0A'
         34        ECHO                                                     ~19
   46    35        NEW                                              $20     'A'
         36        DO_FCALL                                      0          
         37        INIT_METHOD_CALL                                         $20, 'getLocalCategoryId'
         38        FETCH_CLASS_CONSTANT                             ~22     'ProductCategories', 'C'
         39        SEND_VAL_EX                                              ~22
         40        DO_FCALL                                      0  $23     
         41        CONCAT                                           ~24     $23, '%0A'
         42        ECHO                                                     ~24
         43      > RETURN                                                   1

Class ProductCategories: [no user functions]
Class ProductCategoryProviderInterface:
Function getlocalcategoryid:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uNvjU
function name:  getLocalCategoryId
number of ops:  3
compiled vars:  !0 = $category
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
          1        VERIFY_RETURN_TYPE                                       
          2      > RETURN                                                   null

End of function getlocalcategoryid

End of class ProductCategoryProviderInterface.

Class A:
Function getlocalcategoryid:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 44) Position 1 = 4, Position 2 = 8
Branch analysis from position: 4
2 jumps found. (Code = 44) Position 1 = 7, Position 2 = 10
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
filename:       /in/uNvjU
function name:  getLocalCategoryId
number of ops:  18
compiled vars:  !0 = $category
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
   21     1        FETCH_CLASS_CONSTANT                             ~2      'ProductCategories', 'A'
          2        IS_IDENTICAL                                             !0, ~2
          3      > JMPNZ                                                    ~1, ->8
   22     4    >   FETCH_CLASS_CONSTANT                             ~3      'ProductCategories', 'B'
          5        IS_IDENTICAL                                             !0, ~3
          6      > JMPNZ                                                    ~1, ->10
          7    > > JMP                                                      ->12
   21     8    >   QM_ASSIGN                                        ~4      '1'
          9      > JMP                                                      ->14
   22    10    >   QM_ASSIGN                                        ~4      '2'
         11      > JMP                                                      ->14
   23    12    >   QM_ASSIGN                                        ~4      null
         13      > JMP                                                      ->14
         14    >   VERIFY_RETURN_TYPE                                       ~4
         15      > RETURN                                                   ~4
   25    16*       VERIFY_RETURN_TYPE                                       
         17*     > RETURN                                                   null

End of function getlocalcategoryid

End of class A.

Class B:
Function getlocalcategoryid:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 44) Position 1 = 4, Position 2 = 8
Branch analysis from position: 4
2 jumps found. (Code = 44) Position 1 = 7, Position 2 = 10
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
filename:       /in/uNvjU
function name:  getLocalCategoryId
number of ops:  18
compiled vars:  !0 = $category
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   RECV                                             !0      
   33     1        FETCH_CLASS_CONSTANT                             ~2      'ProductCategories', 'A'
          2        IS_IDENTICAL                                             !0, ~2
          3      > JMPNZ                                                    ~1, ->8
   34     4    >   FETCH_CLASS_CONSTANT                             ~3      'ProductCategories', 'B'
          5        IS_IDENTICAL                                             !0, ~3
          6      > JMPNZ                                                    ~1, ->10
          7    > > JMP                                                      ->12
   33     8    >   QM_ASSIGN                                        ~4      'cat_a'
          9      > JMP                                                      ->14
   34    10    >   QM_ASSIGN                                        ~4      'cat_B'
         11      > JMP                                                      ->14
   35    12    >   QM_ASSIGN                                        ~4      null
         13      > JMP                                                      ->14
         14    >   VERIFY_RETURN_TYPE                                       ~4
         15      > RETURN                                                   ~4
   37    16*       VERIFY_RETURN_TYPE                                       
         17*     > RETURN                                                   null

End of function getlocalcategoryid

End of class B.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
190.36 ms | 1016 KiB | 13 Q