3v4l.org

run code in 300+ PHP versions simultaneously
<?php class CountHelper { public static function count_if_you_can($var) { if (is_array($var)) { return count($var); } elseif (is_object($var)) { if ($var instanceof Countable) { return count($var); } else { return 1; } } elseif ($var === NULL) { return 0; } else { return 1; } } } function teste($var) { $result = CountHelper::count_if_you_can($var); var_dump($result); $result = count($var); var_dump($result); } echo teste(123);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZPYcT
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   42     0  E >   INIT_FCALL                                               'teste'
          1        SEND_VAL                                                 123
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
          4      > RETURN                                                   1

Function teste:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZPYcT
function name:  teste
number of ops:  14
compiled vars:  !0 = $var, !1 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   RECV                                             !0      
   35     1        INIT_STATIC_METHOD_CALL                                  'CountHelper', 'count_if_you_can'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0  $2      
          4        ASSIGN                                                   !1, $2
   36     5        INIT_FCALL                                               'var_dump'
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                                 
   38     8        COUNT                                            ~5      !0
          9        ASSIGN                                                   !1, ~5
   39    10        INIT_FCALL                                               'var_dump'
         11        SEND_VAR                                                 !1
         12        DO_ICALL                                                 
   40    13      > RETURN                                                   null

End of function teste

Class CountHelper:
Function count_if_you_can:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 6
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 15
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 13
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 19
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZPYcT
function name:  count_if_you_can
number of ops:  21
compiled vars:  !0 = $var
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    7     1        TYPE_CHECK                                  128          !0
          2      > JMPZ                                                     ~1, ->6
    9     3    >   COUNT                                            ~2      !0
          4      > RETURN                                                   ~2
          5*       JMP                                                      ->20
   11     6    >   TYPE_CHECK                                  256          !0
          7      > JMPZ                                                     ~3, ->15
   13     8    >   INSTANCEOF                                               !0, 'Countable'
          9      > JMPZ                                                     ~4, ->13
   15    10    >   COUNT                                            ~5      !0
         11      > RETURN                                                   ~5
         12*       JMP                                                      ->14
   19    13    > > RETURN                                                   1
         14*       JMP                                                      ->20
   22    15    >   TYPE_CHECK                                    2          !0
         16      > JMPZ                                                     ~6, ->19
   24    17    > > RETURN                                                   0
         18*       JMP                                                      ->20
   28    19    > > RETURN                                                   1
   30    20*     > RETURN                                                   null

End of function count_if_you_can

End of class CountHelper.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
176.67 ms | 1403 KiB | 16 Q