php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30209 ReflectionClass::getMethod() lowercases attribute
Submitted: 2004-09-23 16:26 UTC Modified: 2004-09-23 21:04 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: sb at sebastian-bergmann dot de Assigned: helly (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5.0.1 OS: *
Private report: No CVE-ID: None
 [2004-09-23 16:26 UTC] sb at sebastian-bergmann dot de
Description:
------------
Calling getMethod() on a ReflectionClass object for the current object lowercases the contents of the variable that is passed to it.

Hardcoding the getMethod() parameter prevents the lowercasing while copying the value from $this->name to $name and passing that to getMethod() does not.

Reproduce code:
---------------
<?php
class Foo {
    private $name = 'testBar';
 
    public function testBar() {
        try {
           $class  = new ReflectionClass($this);
           var_dump($this);
           $method = $class->getMethod($this->name);
           var_dump($this);
        }
 
        catch (Exception $e) {}
    }
}

$foo = new Foo;
$foo->testBar();
?>


Expected result:
----------------
object(Foo)#1 (1) {
  ["name:private"]=>
  string(7) "testBar"
}
object(Foo)#1 (1) {
  ["name:private"]=>
  string(7) "testBar"
}

Actual result:
--------------
object(Foo)#1 (1) {
  ["name:private"]=>
  string(7) "testBar"
}
object(Foo)#1 (1) {
  ["name:private"]=>
  string(7) "testbar"
}

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-09-23 21:04 UTC] sebastian@php.net
This bug has been fixed in CVS.

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.


 [2004-10-07 05:25 UTC] sohu119 at sohu dot com
111
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 04:01:31 2024 UTC