Bug #72159 [Asn->Csd]: Imported Class Overrides Local Class Name

From: Date: Wed, 04 May 2016 16:45:14 +0000
Subject: Bug #72159 [Asn->Csd]: Imported Class Overrides Local Class Name
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-200892@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=72159&edit=1 ID: 72159 Updated by: nikic@php.net Reported by: rod at owsy dot com Summary: Imported Class Overrides Local Class Name -Status: Assigned +Status: Closed Type: Bug Package: Scripting Engine problem Operating System: All PHP Version: 7.0.6 Assigned To: nikic Block user comment: N Private report: N New Comment: Automatic comment on behalf of nikic Revision: http://git.php.net/?p=php-src.git;a=commit;h=9af0c96af4ded5ac0935e6cc1a2fa253ce77dfac Log: Fix bug #72159 Previous Comments: ------------------------------------------------------------------------ [2016-05-04 15:24:39] rod at owsy dot com Description: ------------ When importing a class into a namespace it seems to override any classes with that name in the current namespace (PHP 7.0+) https://3v4l.org/tGv74 Test script: --------------- <?php namespace Foo { class Bar { public $from = 'foo'; } } namespace Bazzle { use Foo\Bar; class Bar { public $from = 'bazzle'; } echo (new Bar())->from; } Expected result: ---------------- Fatal error: Cannot declare class Bazzle\Bar because the name is already in use Actual result: -------------- 'foo' is echo'd ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=72159&edit=1

« previous php.bugs (#200892) next »