php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #48119 usort() docs don't mention it now takes a lambda
Submitted: 2009-04-29 23:58 UTC Modified: 2009-07-03 18:22 UTC
From: schwern at pobox dot com Assigned: kalle (profile)
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: schwern at pobox dot com
New email:
PHP Version: OS:

 

 [2009-04-29 23:58 UTC] schwern at pobox dot com
Description:
------------
The documentation for array_map() mentions...
5.3.0  	 It is now possible to use a lambda function as the callback.

That's nice to know.  usort() does not mention this, nor does it have any examples showing it off.  It would be nice if it did.

I had to compile up 5.3.0 to check that it did, in fact, work.  There also appear to be no tests for this in ext/standard/tests/array/usort*


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-05-02 02:00 UTC] kalle@php.net
All functions that accept a callback can make use of lambda style functions, I don't think its worth adding to every single function that takes a callback parameter that as of 5.3 its possible to pass a closure there. I'll leave this to one of the other doc-geeks to decide.
 [2009-05-02 03:33 UTC] schwern at pobox dot com
If you're going to go with that method, which is fine, the docs need a few things to support it.

1. The docs on the callback type have to document it.  Currently it does not.  It says "A PHP function is passed by its name as a string."  There's no mention of being able to use a lambda in 5.3.0.
http://www.php.net/manual/en/language.pseudo-types.php#language.types.callback

2. Remove any mentions of the new 5.3.0 callback syntax from specific function documentation, such as array_map.  The fact that array_map() documented it and usort() did not suggested it was an exceptional case.
 [2009-05-02 03:50 UTC] philip@php.net
The analysis here looks good.
 [2009-07-03 18:22 UTC] kalle@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 [2020-02-07 06:10 UTC] phpdocbot@php.net
Automatic comment on behalf of kalle
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=3b0392cafaa677f56f1889eacf9f99f99d82edf0
Log: Fixed #48119 (usort() docs don't mention it now takes a lambda)
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Oct 07 20:00:02 2026 UTC