php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #50146 property_exists: Closure object cannot have properties
Submitted: 2009-11-11 10:24 UTC Modified: 2009-11-11 18:59 UTC
From: spam04 at pornel dot net Assigned: felipe (profile)
Status: Closed Package: Reflection related
PHP Version: 5.3SVN-2009-11-11 (snap) OS: *
Private report: No CVE-ID: None
 [2009-11-11 10:24 UTC] spam04 at pornel dot net
Description:
------------
property_exists() rejects closures with "Closure object cannot have properties" rather than simply always returning false.

Since closures pass is_object() test, it's hard to avoid this error without testing for "instanceof Closure" as well, which is discouraged in the docs.


Reproduce code:
---------------
$obj = function(){}

is_object($obj) && property_exists($obj,'foo');


Expected result:
----------------
false

(either they should not be considered objects, or property_exists should accept any object).


Actual result:
--------------
"Closure object cannot have properties"

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-11-11 18:59 UTC] felipe@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 [2009-11-11 18:59 UTC] svn@php.net
Automatic comment from SVN on behalf of felipe
Revision: http://svn.php.net/viewvc/?view=revision&revision=290516
Log: - Fixed bug #50146 (property_exists: Closure object cannot have properties)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 02:01:28 2024 UTC