Bug #53900 [Opn->Bgs]: Reflection API shows wrong class name for namespaced type hints
Edit report at http://bugs.php.net/bug.php?id=53900&edit=1
ID: 53900
Updated by: johannes@php.net
Reported by: sebastian@php.net
Summary: Reflection API shows wrong class name for namespaced
type hints
-Status: Open
+Status: Bogus
Type: Bug
Package: Scripting Engine problem
Operating System: Irrelevant
PHP Version: trunk-SVN-2011-02-01 (SVN)
Block user comment: N
Private report: N
New Comment:
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
Escencially this situation:
<?php
namespace A;
class C {}
function f(A\C $ab) {}
namespace C;
\A\f(new \A\C);
Catchable fatal error: Argument 1 passed to A\a() must be an instance of
A\A\b, instance of A\B given, called in Command line code on line 1 and
defined in Command line code on line 1
Previous Comments:
------------------------------------------------------------------------
[2011-02-01 11:04:50] sebastian@php.net
Description:
------------
When using namespaced classes as a type hint like in the test script
attached to this bug report, the ReflectionParameter object generated
for the parameter contains a fully-qualified class name for the type
hinted class where the name of the namespace is duplicated (see actual
output).
This also causes ReflectionParameter::getClass() to fail as no
ReflectionClass object can be created for the invalid class name.
Test script:
---------------
<?php
namespace ImageTransform;
interface FileAccessAdapter
{
public function create(ImageTransform\Image $image, $width, $height);
}
$method = new \ReflectionMethod('ImageTransform\FileAccessAdapter',
'create');
foreach ($method->getParameters() as $parameter) {
print $parameter;
}
?>
Expected result:
----------------
Parameter #0 [ <required> ImageTransform\Image $image ]Parameter #1 [
<required> $width ]Parameter #2 [ <required> $height ]
Actual result:
--------------
Parameter #0 [ <required> ImageTransform\ImageTransform\Image $image
]Parameter #1 [ <required> $width ]Parameter #2 [ <required> $height ]
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=53900&edit=1
Thread (2 messages)