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
 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 08:01:28 2024 UTC