3v4l.org

run code in 500+ PHP versions simultaneously
<?php /** * sort() triggers type-conversion notice * @link https://bugs.php.net/bug.php?id=64580 */ error_reporting(~0); $errors = 0; $objects = 0; $subject = array(3, 3, 2, 3, 3, 2, 2, 3, 3, 1, 1, obj(1), 1, obj(1.2), 2, obj(2), 2, 2, 2, 2, obj(2.1), 1, 0, 0); set_error_handler('suppress_and_count'); sort($subject); restore_error_handler(); printf("sort caused %d error(s) in an array of %d member(s) of which %d are object(s).\n", $errors, count($subject), $objects); echo 'sort()-result: ', implode(', ', array_map('tostring', $subject)); // --------------- functions ----------------- // function obj($prop) { global $objects; $objects++; return (object) array('prop' => $prop); } function arr($val) { return array($val); } function tostring($val) { if (is_object($val)) { $val = sprintf('obj(%s)', $val->prop); } if (is_array($val)) { $val = '[' . implode(',', $val) . ']'; } return $val; } function suppress_and_count() { global $errors; $errors++; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/D0pnV
function name:  (null)
number of ops:  65
compiled vars:  !0 = $errors, !1 = $objects, !2 = $subject
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    7     0  E >   INIT_FCALL                                                   'error_reporting'
          1        SEND_VAL                                                     -1
          2        DO_ICALL                                                     
    8     3        ASSIGN                                                       !0, 0
    9     4        ASSIGN                                                       !1, 0
   11     5        INIT_ARRAY                                           ~6      3
          6        ADD_ARRAY_ELEMENT                                    ~6      3
          7        ADD_ARRAY_ELEMENT                                    ~6      2
          8        ADD_ARRAY_ELEMENT                                    ~6      3
          9        ADD_ARRAY_ELEMENT                                    ~6      3
         10        ADD_ARRAY_ELEMENT                                    ~6      2
         11        ADD_ARRAY_ELEMENT                                    ~6      2
         12        ADD_ARRAY_ELEMENT                                    ~6      3
         13        ADD_ARRAY_ELEMENT                                    ~6      3
         14        ADD_ARRAY_ELEMENT                                    ~6      1
         15        ADD_ARRAY_ELEMENT                                    ~6      1
         16        INIT_FCALL_BY_NAME                                           'obj'
         17        SEND_VAL_EX                                                  1
         18        DO_FCALL                                          0  $7      
         19        ADD_ARRAY_ELEMENT                                    ~6      $7
         20        ADD_ARRAY_ELEMENT                                    ~6      1
         21        INIT_FCALL_BY_NAME                                           'obj'
         22        SEND_VAL_EX                                                  1.2
         23        DO_FCALL                                          0  $8      
         24        ADD_ARRAY_ELEMENT                                    ~6      $8
         25        ADD_ARRAY_ELEMENT                                    ~6      2
         26        INIT_FCALL_BY_NAME                                           'obj'
         27        SEND_VAL_EX                                                  2
         28        DO_FCALL                                          0  $9      
         29        ADD_ARRAY_ELEMENT                                    ~6      $9
         30        ADD_ARRAY_ELEMENT                                    ~6      2
         31        ADD_ARRAY_ELEMENT                                    ~6      2
         32        ADD_ARRAY_ELEMENT                                    ~6      2
         33        ADD_ARRAY_ELEMENT                                    ~6      2
         34        INIT_FCALL_BY_NAME                                           'obj'
         35        SEND_VAL_EX                                                  2.1
         36        DO_FCALL                                          0  $10     
         37        ADD_ARRAY_ELEMENT                                    ~6      $10
         38        ADD_ARRAY_ELEMENT                                    ~6      1
         39        ADD_ARRAY_ELEMENT                                    ~6      0
         40        ADD_ARRAY_ELEMENT                                    ~6      0
         41        ASSIGN                                                       !2, ~6
   13    42        INIT_FCALL                                                   'set_error_handler'
         43        SEND_VAL                                                     'suppress_and_count'
         44        DO_ICALL                                                     
   14    45        INIT_FCALL                                                   'sort'
         46        SEND_REF                                                     !2
         47        DO_ICALL                                                     
   15    48        INIT_FCALL                                                   'restore_error_handler'
         49        DO_ICALL                                                     
   17    50        INIT_FCALL                                                   'printf'
         51        SEND_VAL                                                     'sort+caused+%25d+error%28s%29+in+an+array+of+%25d+member%28s%29+of+which+%25d+are+object%28s%29.%0A'
         52        SEND_VAR                                                     !0
         53        COUNT                                                ~15     !2
         54        SEND_VAL                                                     ~15
         55        SEND_VAR                                                     !1
         56        DO_ICALL                                                     
   19    57        ECHO                                                         'sort%28%29-result%3A+'
         58        INIT_FCALL                                                   'array_map'
         59        SEND_VAL                                                     'tostring'
         60        SEND_VAR                                                     !2
         61        DO_ICALL                                             $17     
         62        FRAMELESS_ICALL_2                implode             ~18     '%2C+', $17
         63        ECHO                                                         ~18
   46    64      > RETURN                                                       1

Function obj:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/D0pnV
function name:  obj
number of ops:  7
compiled vars:  !0 = $prop, !1 = $objects
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   23     0  E >   RECV                                                 !0      
   24     1        BIND_GLOBAL                                                  !1, 'objects'
   25     2        PRE_INC                                                      !1
   26     3        INIT_ARRAY                                           ~3      !0, 'prop'
          4        CAST                                              8  ~4      ~3
          5      > RETURN                                                       ~4
   27     6*     > RETURN                                                       null

End of function obj

Function arr:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/D0pnV
function name:  arr
number of ops:  4
compiled vars:  !0 = $val
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   29     0  E >   RECV                                                 !0      
   30     1        INIT_ARRAY                                           ~1      !0
          2      > RETURN                                                       ~1
   31     3*     > RETURN                                                       null

End of function arr

Function tostring:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 8
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 14
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
Branch analysis from position: 8
filename:       /in/D0pnV
function name:  tostring
number of ops:  16
compiled vars:  !0 = $val
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   33     0  E >   RECV                                                 !0      
   34     1        TYPE_CHECK                                      256          !0
          2      > JMPZ                                                         ~1, ->8
   35     3    >   FETCH_OBJ_R                                          ~2      !0, 'prop'
          4        ROPE_INIT                                         3  ~4      'obj%28'
          5        ROPE_ADD                                          1  ~4      ~4, ~2
          6        ROPE_END                                          2  ~3      ~4, '%29'
          7        ASSIGN                                                       !0, ~3
   37     8    >   TYPE_CHECK                                      128          !0
          9      > JMPZ                                                         ~7, ->14
   38    10    >   FRAMELESS_ICALL_2                implode             ~8      '%2C', !0
         11        CONCAT                                               ~9      '%5B', ~8
         12        CONCAT                                               ~10     ~9, '%5D'
         13        ASSIGN                                                       !0, ~10
   40    14    > > RETURN                                                       !0
   41    15*     > RETURN                                                       null

End of function tostring

Function suppress_and_count:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/D0pnV
function name:  suppress_and_count
number of ops:  3
compiled vars:  !0 = $errors
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   44     0  E >   BIND_GLOBAL                                                  !0, 'errors'
   45     1        PRE_INC                                                      !0
   46     2      > RETURN                                                       null

End of function suppress_and_count

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
162.2 ms | 3075 KiB | 19 Q