From:             hans at velum dot net
Operating system: Gentoo
PHP version:      5.3CVS-2007-11-15 (snap)
PHP Bug Type:     Scripting Engine problem
Bug description:  Type hints do not respect imported namespaces

Description:
------------
When using type hints, the namespaces that were imported (using "use") are
not consulted to resolve the type-hinted class names.  i.e. if I have a
class defined in namespace "foo::bar", it is assumed that *all* classes
specified as type hints used in methods in my class are in the "foo::bar"
namespace -- regardless of which other namespaces I import.

Reproduce code:
---------------
This is best illustrated with 3 files:

AClass.php:
<?php
namespace proj::a;
class AClass {}
?>

BClass.php:
<?php
namespace proj::b;
use proj::a;
class BClass {
  function setA(AClass $a) {}
}
?>

test.php:
<?php
require 'AClass.php';
require 'BClass.php';

$b = new proj::b::BClass();
$b->setA(new proj::a::AClass());
?>


Expected result:
----------------
No error.

Actual result:
--------------
Catchable fatal error: Argument 1 passed to proj::b::BClass::setA() must
be an instance of proj::b::AClass, instance of proj::a::AClass given,
called in test.php on line 6 and defined in BClass.php on line 5

-- 
Edit bug report at http://bugs.php.net/?id=43302&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=43302&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=43302&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=43302&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=43302&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=43302&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=43302&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=43302&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=43302&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=43302&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=43302&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=43302&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=43302&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=43302&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=43302&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=43302&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=43302&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=43302&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=43302&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=43302&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=43302&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=43302&r=mysqlcfg

Reply via email to