php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47019 \ReflectionParameter->getClass()->getName() is broken.
Submitted: 2009-01-06 11:49 UTC Modified: 2009-02-03 18:58 UTC
Votes:2
Avg. Score:1.0 ± 0.0
Reproduced:0 of 2 (0.0%)
From: daniel dot gorski at develnet dot org Assigned:
Status: Not a bug Package: Reflection related
PHP Version: 5.3CVS-2009-01-06 (CVS) OS: Linux
Private report: No CVE-ID: None
 [2009-01-06 11:49 UTC] daniel dot gorski at develnet dot org
Description:
------------
The \ReflectionParameter->getClass()->getName() method returns a wrong value. It omits the leading namespace slash.

Reproduce code:
---------------
namespace A\B\C;
class Bar {}

namespace D;
class Foo { function foo(\A\B\C\Bar $x) {} }

$rm = new \ReflectionMethod('\D\Foo', 'foo');
$rp = $rm->getParameters();

echo $rp[0]->getClass()->getName();

Expected result:
----------------
\A\B\C\Bar

Actual result:
--------------
A\B\C\Bar

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-02-03 18:58 UTC] stas@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Leading slash is not a part of the class name. Try this:

namespace test;

class test {
  static function foo() { echo __CLASS__; }
}

test::foo();
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 08 20:01:27 2024 UTC