3v4l.org

run code in 300+ PHP versions simultaneously
<?php function formatAds(array $ad): array { $ad['last_name'] = ucfirst($ad['last_name']); $ad['first_name'] = ucfirst($ad['first_name']); $phoneNumber = str_replace(' ', '', $ad['phone_number']); $ad['phone_number'] = is_numeric($phoneNumber) && strlen($phoneNumber) === 10 ? $phoneNumber : null; return $ad; } $ad = [ "last_name" => "foo", "first_name" => "bar", "phone_number" => "04 55 66 77 11", ]; print_r(formatAds($ad));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PdTRG
function name:  (null)
number of ops:  8
compiled vars:  !0 = $ad
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   ASSIGN                                                   !0, <array>
   23     1        INIT_FCALL                                               'print_r'
          2        INIT_FCALL                                               'formatads'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $2      
          5        SEND_VAR                                                 $2
          6        DO_ICALL                                                 
          7      > RETURN                                                   1

Function formatads:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 24, Position 2 = 27
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 30
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
filename:       /in/PdTRG
function name:  formatAds
number of ops:  37
compiled vars:  !0 = $ad, !1 = $phoneNumber
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        INIT_FCALL                                               'ucfirst'
          2        FETCH_DIM_R                                      ~3      !0, 'last_name'
          3        SEND_VAL                                                 ~3
          4        DO_ICALL                                         $4      
          5        ASSIGN_DIM                                               !0, 'last_name'
          6        OP_DATA                                                  $4
    6     7        INIT_FCALL                                               'ucfirst'
          8        FETCH_DIM_R                                      ~6      !0, 'first_name'
          9        SEND_VAL                                                 ~6
         10        DO_ICALL                                         $7      
         11        ASSIGN_DIM                                               !0, 'first_name'
         12        OP_DATA                                                  $7
    8    13        INIT_FCALL                                               'str_replace'
         14        SEND_VAL                                                 '+'
         15        SEND_VAL                                                 ''
         16        FETCH_DIM_R                                      ~8      !0, 'phone_number'
         17        SEND_VAL                                                 ~8
         18        DO_ICALL                                         $9      
         19        ASSIGN                                                   !1, $9
    9    20        INIT_FCALL                                               'is_numeric'
         21        SEND_VAR                                                 !1
         22        DO_ICALL                                         $12     
         23      > JMPZ_EX                                          ~13     $12, ->27
         24    >   STRLEN                                           ~14     !1
         25        IS_IDENTICAL                                     ~15     ~14, 10
         26        BOOL                                             ~13     ~15
         27    > > JMPZ                                                     ~13, ->30
         28    >   QM_ASSIGN                                        ~16     !1
         29      > JMP                                                      ->31
         30    >   QM_ASSIGN                                        ~16     null
         31    >   ASSIGN_DIM                                               !0, 'phone_number'
         32        OP_DATA                                                  ~16
   11    33        VERIFY_RETURN_TYPE                                       !0
         34      > RETURN                                                   !0
   13    35*       VERIFY_RETURN_TYPE                                       
         36*     > RETURN                                                   null

End of function formatads

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
231.11 ms | 1010 KiB | 18 Q