php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #50152 ReflectionClass::hasProperty behaves like isset() not property_exists
Submitted: 2009-11-11 18:39 UTC Modified: 2009-11-11 18:53 UTC
From: felipe@php.net Assigned: felipe (profile)
Status: Closed Package: Reflection related
PHP Version: 5.3SVN-2009-11-11 (SVN) OS: Linux
Private report: No CVE-ID: None
 [2009-11-11 18:39 UTC] felipe@php.net
Description:
------------
This change looks to be introduced accidentaly in HEAD, and was MFHd by me times ago. the hasProperty() is currently using the __isset magic method, this doesn't look right from a reflection perspective. It must behaves like property_exists() that doesn't uses the magic stuff.

Reproduce code:
---------------
<?php

class foo {
	function __isset($a) {
		var_dump($a);		
		return 1;
	}
}

$x = new foo;
$ref = new ReflectionObject($x);
var_dump($ref->hasProperty('b'));


Expected result:
----------------
bool(false)

Actual result:
--------------
string(1) "b"
bool(true)


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-11-11 18:52 UTC] svn@php.net
Automatic comment from SVN on behalf of felipe
Revision: http://svn.php.net/viewvc/?view=revision&revision=290515
Log: - Fixed bug #50152 (ReflectionClass::hasProperty hehaves like isset() not property_exists)
  [5_2 is OK]
 [2009-11-11 18:53 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.

5.2 is okay, it already checks like property_exists().
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 09:01:32 2024 UTC