Bug #77628 [Opn->Nab]: Using const AND use in the same scope.

From: Date: Sun, 17 Feb 2019 10:19:23 +0000
Subject: Bug #77628 [Opn->Nab]: Using const AND use in the same scope.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-219609@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77628&edit=1 ID: 77628 Updated by: nikic@php.net Reported by: dams@php.net Summary: Using const AND use in the same scope. -Status: Open +Status: Not a bug Type: Bug Package: *Programming Data Structures Operating System: Irrelevant PHP Version: 7.3.2 Block user comment: N Private report: N New Comment: Uses are always relative to the root namespace, you are looking for "use const A\C as D". Previous Comments: ------------------------------------------------------------------------ [2019-02-17 10:10:05] dams@php.net Description: ------------ Using an import alias and defining the constant in the same scope leads to inconsistent error message : Undefined constant 'C' C is aliased into D first. Then it is created. Its creation is validated by 'echo C', which yields the right value. 'echo D' fails, mentioning that 'C' doesn't exists. Extra note : + splitting the namespace A in two (one with const, one with use) raise the same issue. + use and const may be in any order (use first, const first), still raise the same issue. Test script: --------------- <?php namespace A { use const C as D; const C = 2; echo C; echo D; } Expected result: ---------------- 22 Actual result: -------------- 2PHP Fatal error: Uncaught Error: Undefined constant 'C' in test.php:8 Stack trace: #0 {main} thrown in test.php on line 8 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=77628&edit=1

« previous php.bugs (#219609) next »