From: hanskrentel at yahoo dot de Operating system: PHP version: 5.4.13 Package: Arrays related Bug Type: Bug Bug description:sort() triggers type-conversion notice
Description: ------------ Under specific circumstances the sort() function with the `SORT_REGULAR` sort- flag triggers type-conversion notices even it is documented that no type- conversion is done[1]: > SORT_REGULAR - compare items normally (don't change types) This notice is *only* given if an object value is sorted with an integer or float. The notices for these two cases are as following: > Notice: Object of class stdClass could not be converted to int > Notice: Object of class stdClass could not be converted to double Those errors are triggered in /Zend (lxr search http://goo.gl/Zu7Zl). The sort() function returns TRUE despite the Notice and as far I was able to find out, the sorting is done, so this looks correct to me. Also this error only happens with sorting objects with integers and floats. I also tested against NULL, boolean (TRUE/FALSE), string, array, object and resource and these did not trigger the notice. I would not classify this as documentation bug because these are very specific circumstances which makes me assume that this is not the intended behavior. Something might have been just overlooked for these two cases with `SORT_REGULAR`. It should be said that there are related issues documented in #54980 and #54259 over which I originally stumbled. [1] http://php.net/sort Test script: --------------- <?php $subject = [1, (object) ['prop' => 'value']]; sort($subject); Actual result: -------------- Notice: Object of class stdClass could not be converted to int in [...] on line 3 -- Edit bug report at https://bugs.php.net/bug.php?id=64580&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=64580&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=64580&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=64580&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=64580&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=64580&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=64580&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=64580&r=needscript Try newer version: https://bugs.php.net/fix.php?id=64580&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=64580&r=support Expected behavior: https://bugs.php.net/fix.php?id=64580&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=64580&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=64580&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=64580&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64580&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=64580&r=dst IIS Stability: https://bugs.php.net/fix.php?id=64580&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=64580&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=64580&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=64580&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=64580&r=mysqlcfg