3v4l.org

run code in 300+ PHP versions simultaneously
<?php const testNamespacedClasses = [ "Namespace\To\SettingOption", "I\Was\Born\InTheUSAIwas", "Something\Onething" ]; function testSnakeCasedModelNames() { foreach (testNamespacedClasses as $class) { echo "$class => "; echo preg_replace_callback( '~([^\\\\]*\\\\)*([A-Z][a-z]*)~', function($m) { return ($m[1] ? '' : '_') . lcfirst($m[2]); }, $class ); echo "\n---\n"; } } echo testSnakeCasedModelNames();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MHSrU
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   DECLARE_CONST                                            'testNamespacedClasses', <array>
   22     1        INIT_FCALL                                               'testsnakecasedmodelnames'
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
          4      > RETURN                                                   1

Function testsnakecasedmodelnames:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 15
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 15
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
filename:       /in/MHSrU
function name:  testSnakeCasedModelNames
number of ops:  17
compiled vars:  !0 = $class
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   FETCH_CONSTANT                                   ~1      'testNamespacedClasses'
          1      > FE_RESET_R                                       $2      ~1, ->15
          2    > > FE_FETCH_R                                               $2, !0, ->15
   10     3    >   NOP                                                      
          4        FAST_CONCAT                                      ~3      !0, '+%3D%3E+'
          5        ECHO                                                     ~3
   11     6        INIT_FCALL                                               'preg_replace_callback'
   12     7        SEND_VAL                                                 '%7E%28%5B%5E%5C%5C%5D%2A%5C%5C%29%2A%28%5BA-Z%5D%5Ba-z%5D%2A%29%7E'
   13     8        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FMHSrU%3A13%240'
   15     9        SEND_VAL                                                 ~4
   16    10        SEND_VAR                                                 !0
         11        DO_ICALL                                         $5      
         12        ECHO                                                     $5
   18    13        ECHO                                                     '%0A---%0A'
    9    14      > JMP                                                      ->2
         15    >   FE_FREE                                                  $2
   20    16      > RETURN                                                   null

End of function testsnakecasedmodelnames

Function %00%7Bclosure%7D%2Fin%2FMHSrU%3A13%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 5
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MHSrU
function name:  {closure}
number of ops:  13
compiled vars:  !0 = $m
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   14     1        FETCH_DIM_R                                      ~1      !0, 1
          2      > JMPZ                                                     ~1, ->5
          3    >   QM_ASSIGN                                        ~2      ''
          4      > JMP                                                      ->6
          5    >   QM_ASSIGN                                        ~2      '_'
          6    >   INIT_FCALL                                               'lcfirst'
          7        FETCH_DIM_R                                      ~3      !0, 2
          8        SEND_VAL                                                 ~3
          9        DO_ICALL                                         $4      
         10        CONCAT                                           ~5      ~2, $4
         11      > RETURN                                                   ~5
   15    12*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FMHSrU%3A13%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
176.03 ms | 1403 KiB | 18 Q