Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125464 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id 7E6CD1A00BD for ; Sat, 7 Sep 2024 03:18:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1725679219; bh=eRg8BYpZ+lC0SNObq8bPKpNOhxlLn/yTAosqI+k0FtE=; h=Subject:To:References:From:Date:In-Reply-To:From; b=h3jRRt+ZybRtiuK/scdeKuwilmAfg2BvbdN4Y9XWOYQ62PxGLm37U6Z9o3DcjYfv2 hJayC9WjkwZtEqx4VbBHkcUl1jq41Q6NumA2zORbRyuwhprN2GfAFtxqKJ8KW/jdxK SiAZ99UE0Ln4qsTxuCGJKhzVMb6kG/cuxCoOsiOxh1nGivHa3uoJYzg/fjdTsVLGOj 0q3nTfKasYZuAPldnVw3w3G7CKoHusZQIKUCUftaaMVE3/SMt2PLqqbZ35gxPr1InW h3xMNX8ydI08LBK7js6XKrC1z56E6pAReeENHpZE8vVPqO1vZ7Lj7zEmuwKyrAfQaz APBReT8BCU2aw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 51A4118006F for ; Sat, 7 Sep 2024 03:20:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: * X-Spam-Status: No, score=1.5 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_40, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING, HTML_MESSAGE,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_SOFTFAIL,STOX_BOUND_090909_B autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from giraffe.ash.relay.mailchannels.net (giraffe.ash.relay.mailchannels.net [23.83.222.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sat, 7 Sep 2024 03:20:17 +0000 (UTC) X-Sender-Id: a2hosting|x-authuser|juliette@adviesenzo.nl Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 2F9C9845E5 for ; Sat, 7 Sep 2024 03:18:17 +0000 (UTC) Received: from nl1-ss105.a2hosting.com (unknown [127.0.0.6]) (Authenticated sender: a2hosting) by relay.mailchannels.net (Postfix) with ESMTPA id AF8E085872 for ; Sat, 7 Sep 2024 03:18:15 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1725679096; a=rsa-sha256; cv=none; b=7SIGnoBZWeRUEDbO5wiE5SgVVsTzC6Vqgpf3VaKv6ddjTuK6kotVUJxZI38KGSoCZRWHfa 517iOoVWWbJ6uY5iUBIr9USip7nHTCa/Tz947YNO5MiyTZRKfaLvEJPBLSnj9mLDrfhGHR 5QofYoJvgtUlrleVzdqNOMfd7K0yHBobVGPVmdTOFjZ81/HOZRszhMubMQSODKjgWy1rc5 1Zt+mdoJMaeVkfz27Mxkr82EyjG3fI5ZH7Q5ooQxDRN0lpyubH4k2JwyylR65Wwur71UkO Zg5UHi5UlqTyE1hN/xPc91D/P0ARvPuooOkQYpLK9gUdGcvBzOjbZnMDKhpvnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1725679096; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references:dkim-signature; bh=JAUhsc8EsEzRRKjcKCXttWSLmYsuGeBMprr/A/o2M88=; b=TWYaz3R6FOMmzZ3TbLcM1n+qH0Scah8puNXiJkd4EuHFgHIfyRRycyQpnjcGOmXpN4K1QS 23OpQ66Ut8jx+JNmglddn1A7BCLiOwpClOc1USBFOz1d5qRjFbZffBH2qKmgBocix6ntIs BGZqXgmdj2fWzW+neqvXrb6lTNL39+zU2/RfnIKswz2mqFnZ5Rq8rCOf48IQvItf3NwGdp +9wQ2H+RaCDJQxUMI1q63UHtNTYHWkExNm6b5zqrKKRu/2zBRLWS4i2xWGzVdlU5SymczF 3rPFkh8bObnDBOYDr48KjsfsBJKcB5gPLWlYasMk4BONtvYSTgp4gs6sqQ4WdQ== ARC-Authentication-Results: i=1; rspamd-85dcd79db4-pk26r; auth=pass smtp.auth=a2hosting smtp.mailfrom=php-internals_nospam@adviesenzo.nl X-Sender-Id: a2hosting|x-authuser|juliette@adviesenzo.nl X-MC-Relay: Neutral X-MailChannels-SenderId: a2hosting|x-authuser|juliette@adviesenzo.nl X-MailChannels-Auth-Id: a2hosting X-Industry-Shelf: 60d2981c10310f64_1725679096229_994545469 X-MC-Loop-Signature: 1725679096229:1384820952 X-MC-Ingress-Time: 1725679096229 Received: from nl1-ss105.a2hosting.com (nl1-ss105.a2hosting.com [85.187.142.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.99.80.198 (trex/7.0.2); Sat, 07 Sep 2024 03:18:16 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=adviesenzo.nl; s=default; h=Content-Type:In-Reply-To:MIME-Version:Date: Message-ID:From:References:To:Subject:Sender:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=JAUhsc8EsEzRRKjcKCXttWSLmYsuGeBMprr/A/o2M88=; b=XFxNbab8uEFWxPm18KOX/uVWuH VEg90yP585gU4tRQJefzljgwu6TfgZkCmnFbp4ue8rHBul+aAVT/VPA5a87N60bv8fSuvKl/Z10Td B18jrgRXohMQF+sMgnRh1pivq6v363D5MmIvUpEdR3IvGSxKnz6p9obgaAvJCptTp0vQ=; Received: from mailnull by nl1-ss105.a2hosting.com with spam-scanner (Exim 4.97.1) (envelope-from ) id 1smlxl-0000000BlNP-3rZo for internals@lists.php.net; Sat, 07 Sep 2024 05:18:13 +0200 X-ImunifyEmail-Filter-Info: SUVfVkxfUEJMX0VNQUlMXzAxIFJDVkRfVklBX1NNVFBfQVVU SCBSQ1Z EX1RMU19BTEwgSUVfVkxfUEJMX0RPTUFJTl8wMSBWRVJJTE9DS19DQi BNSURfUkhTX01BVENIX0ZST00gQkFZRVNfSEFNIEZST01fRVFfRU5WR lJPTSBBU04gTUlNRV9UUkFDRSBSQ1ZEX0NPVU5UX09ORSBBUkNfTkEg RlJPTV9IQVNfRE4gVE9fRE5fTk9ORSBSQ1BUX0NPVU5UX09ORSBJRV9 WTF9QQkxfQUNDT1VOVF8wMSBUT19NQVRDSF9FTlZSQ1BUX0FMTCBfRF JVR1NfTU1fRElTQ09VTlQgTUlNRV9VTktOT1dO X-ImunifyEmail-Filter-Action: no action X-ImunifyEmail-Filter-Score: 1.82 X-ImunifyEmail-Filter-Version: 3.8.5/202409030831 Received: from [31.201.40.213] (port=53913 helo=[192.168.1.16]) by nl1-ss105.a2hosting.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.97.1) (envelope-from ) id 1smlxo-0000000BlN2-0STT for internals@lists.php.net; Sat, 07 Sep 2024 05:18:13 +0200 Subject: Re: [PHP-DEV] bikeshed: Typed Aliases To: internals@lists.php.net References: <0fa39535-f22d-4eba-b4df-90abe39e683a@app.fastmail.com> Message-ID: <66DBC5CA.3050901@adviesenzo.nl> Date: Sat, 7 Sep 2024 05:17:30 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.7.0 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 In-Reply-To: <0fa39535-f22d-4eba-b4df-90abe39e683a@app.fastmail.com> Content-Type: multipart/alternative; boundary="------------020003080404080200000002" X-AuthUser: juliette@adviesenzo.nl From: php-internals_nospam@adviesenzo.nl (Juliette Reinders Folmer) This is a multi-part message in MIME format. --------------020003080404080200000002 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit 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 --------------020003080404080200000002 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 7bit
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
--------------020003080404080200000002--