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 strtolower(preg_replace_callback( '~([^\\\\]*\\\\)*([A-Z][a-z]*)~', function($m) { return ($m[1] ? '' : '_') . $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/lXdbd
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 = 18
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 18
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
filename:       /in/lXdbd
function name:  testSnakeCasedModelNames
number of ops:  20
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, ->18
          2    > > FE_FETCH_R                                               $2, !0, ->18
   10     3    >   NOP                                                      
          4        FAST_CONCAT                                      ~3      !0, '+%3D%3E+'
          5        ECHO                                                     ~3
   11     6        INIT_FCALL                                               'strtolower'
          7        INIT_FCALL                                               'preg_replace_callback'
   12     8        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     9        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FlXdbd%3A13%240'
   15    10        SEND_VAL                                                 ~4
   16    11        SEND_VAR                                                 !0
         12        DO_ICALL                                         $5      
         13        SEND_VAR                                                 $5
         14        DO_ICALL                                         $6      
         15        ECHO                                                     $6
   18    16        ECHO                                                     '%0A---%0A'
    9    17      > JMP                                                      ->2
         18    >   FE_FREE                                                  $2
   20    19      > RETURN                                                   null

End of function testsnakecasedmodelnames

Function %00%7Bclosure%7D%2Fin%2FlXdbd%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/lXdbd
function name:  {closure}
number of ops:  10
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    >   FETCH_DIM_R                                      ~3      !0, 2
          7        CONCAT                                           ~4      ~2, ~3
          8      > RETURN                                                   ~4
   15     9*     > RETURN                                                   null

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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
167.58 ms | 1403 KiB | 18 Q