3v4l.org

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

Function obj:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
filename:       /in/XcNNW
function name:  obj
number of ops:  11
compiled vars:  !0 = $prop, !1 = $objects
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    9     1        BIND_GLOBAL                                              !1, 'objects'
   10     2        ISSET_ISEMPTY_CV                                 ~2      !1
          3      > JMPNZ_EX                                         ~2      ~2, ->6
          4    >   ASSIGN                                           ~3      !1, 0
          5        BOOL                                             ~2      ~3
   11     6    >   PRE_INC                                                  !1
   12     7        INIT_ARRAY                                       ~5      !0, 'prop'
          8        CAST                                          8  ~6      ~5
          9      > RETURN                                                   ~6
   13    10*     > RETURN                                                   null

End of function obj

Function tostring:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 9
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 18
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
Branch analysis from position: 9
filename:       /in/XcNNW
function name:  tostring
number of ops:  20
compiled vars:  !0 = $val
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
   16     1        TYPE_CHECK                                  256          !0
          2      > JMPZ                                                     ~1, ->9
   17     3    >   INIT_FCALL                                               'sprintf'
          4        SEND_VAL                                                 'obj%28%25s%29'
          5        FETCH_OBJ_R                                      ~2      !0, 'prop'
          6        SEND_VAL                                                 ~2
          7        DO_ICALL                                         $3      
          8        ASSIGN                                                   !0, $3
   19     9    >   TYPE_CHECK                                  128          !0
         10      > JMPZ                                                     ~5, ->18
   20    11    >   INIT_FCALL                                               'implode'
         12        SEND_VAL                                                 '%2C'
         13        SEND_VAR                                                 !0
         14        DO_ICALL                                         $6      
         15        CONCAT                                           ~7      '%5B', $6
         16        CONCAT                                           ~8      ~7, '%5D'
         17        ASSIGN                                                   !0, ~8
   22    18    > > RETURN                                                   !0
   23    19*     > RETURN                                                   null

End of function tostring

Function handler:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 3, Position 2 = 5
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
filename:       /in/XcNNW
function name:  handler
number of ops:  8
compiled vars:  !0 = $errors
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   BIND_GLOBAL                                              !0, 'errors'
   27     1        ISSET_ISEMPTY_CV                                 ~1      !0
          2      > JMPNZ_EX                                         ~1      ~1, ->5
          3    >   ASSIGN                                           ~2      !0, 0
          4        BOOL                                             ~1      ~2
   28     5    >   PRE_INC                                                  !0
   29     6      > RETURN                                                   <false>
   30     7*     > RETURN                                                   null

End of function handler

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.51 ms | 1407 KiB | 29 Q