Edit report at https://bugs.php.net/bug.php?id=62042&edit=1
ID: 62042 Comment by: joseaugustodearaujonascimento at gmail dot com Reported by: phplists at stanvassilev dot com Summary: Fatal error when merging files due to class/function/symbol name collision Status: Open Type: Bug Package: Unknown/Other Function Operating System: All PHP Version: 5.3.13 Block user comment: N Private report: N New Comment: The same problem arises when in a two namespace context. # File: App\N2\Foo.php namespace App\N2; use App\N1\Bar; class Foo { } # File: App\N2\Bar.php namespace App\N2; class Bar { } # File: App\N1\Bar.php namespace App\N1; class Bar { } Using Bar of App\N1 cause the same problem. I think that the use in App\N2\Foo.php should only be valid on the App\N2\Foo class context and not reflected on the entire namespace as the error message suggest. Previous Comments: ------------------------------------------------------------------------ [2012-05-15 21:05:08] phplists at stanvassilev dot com Description: ------------ These two namespaces work as expected when in two separate files, and when included together at runtime work as expected as well, but once they're merged in the same file they result in a Fatal Error: namespace Foo { class Bar {} } namespace Foo { use Bar; } Fatal error: Cannot use Bar as Bar because the name is already in use. I understand this behavior was introduced with good intentions, but all it does is break working code when files are merged together. The alternative namespace construct was introduced specifically to support merging of multiple files together without side effects, and this is such a side effect. Expected result: ---------------- I expect that "use" statements should override default resolutions, and no Fatal Error should be produced (the EXACT behavior we have right now when the above is spread in two files which are required() at runtime). Actual result: -------------- Fatal Error when merging code. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=62042&edit=1