php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #68828 spl-object-hash shows object only but can use callable
Submitted: 2015-01-13 19:21 UTC Modified: 2015-01-13 19:58 UTC
From: mgcummings at yahoo dot com Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: 5.4.36 OS: N/A
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: mgcummings at yahoo dot com
New email:
PHP Version: OS:

 

 [2015-01-13 19:21 UTC] mgcummings at yahoo dot com
Description:
------------
---
From manual page: http://www.php.net/function.spl-object-hash
---
Documents say parameter can only be object but callable is also allowed and the docs should be updated to reflect it.

Test script:
---------------
$callable = function() {
    return 'test';
};
$result = spl_object_hash($callable);
// $result = '000000002ddd793a0000000047573d56' for example
print $result .PHP_EOL;



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-01-13 19:29 UTC] aharvey@php.net
-Status: Open +Status: Not a bug
 [2015-01-13 19:29 UTC] aharvey@php.net
It can only be callable if the callable is an object: $callable in this case is a Closure object, so spl_object_hash() can deal with that. spl_object_hash() would still fail with any callable that isn't an object, such as 'functionName', or [$object, 'methodName'].
 [2015-01-13 19:58 UTC] mgcummings at yahoo dot com
Sorry wasn't thinking about that you are right it doesn't work if you use something like ['test','test'] instead.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 16 09:01:33 2025 UTC