Re: bikeshed: Typed Aliases

From: Date: Sat, 07 Sep 2024 03:17:30 +0000
Subject: Re: bikeshed: Typed Aliases
References: 1  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
On 6-9-2024 20:41, Rob Landers wrote:
- This RFC expands the "use ... as ..." syntax to allow any type expression on the left side. These aliases are PER FILE and expire once the file is compiled.
Explicitly without expressing any opinion about the RFC, I'd just like to remind you that use... import statements for classes and such are not actually per file, but per namespace and making the use ... statements for types behave differently would be very inconsistent and surprising behaviour. These are the rules (as far as I know and based on extensive testing from my side): * No namespace - use imports apply to whole file. * Curly brace scoped namespace - use imports apply only to the code within the current namespace scope. * Single unscoped namespace - use imports apply to whole file (as the whole file is within the single unscope namespace) * Multiple unscoped namespaces - use imports apply only until the next namespace declaration is encountered. Having type use behave differently to other import use statements would, I imagine, also bring up problems around "file contains 2 scoped namespaces, type use is for the file, but - as things currently are - no code is allowed in the file outside the scoped namespaces, so where to place the import for the type ? and what would it then apply to ?" Smile, Juliette

Thread (25 messages)

« previous php.internals (#125464) next »