Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:121490 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 89062 invoked from network); 28 Oct 2023 07:04:07 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 28 Oct 2023 07:04:07 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 8E54F1804B0 for ; Sat, 28 Oct 2023 00:04:06 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15576 212.103.64.0/19 X-Spam-Virus: No X-Envelope-From: Received: from mx.kolabnow.com (mx.kolabnow.com [212.103.80.154]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sat, 28 Oct 2023 00:04:05 -0700 (PDT) Received: from localhost (unknown [127.0.0.1]) by mx.kolabnow.com (Postfix) with ESMTP id D0F0E30011BB for ; Sat, 28 Oct 2023 09:04:03 +0200 (CEST) Authentication-Results: ext-mx-out013.mykolab.com (amavis); dkim=pass (4096-bit key) reason="pass (just generated, assumed good)" header.d=kolabnow.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kolabnow.com; h= content-transfer-encoding:content-type:content-type:in-reply-to :from:from:content-language:references:subject:subject :mime-version:date:date:message-id:received:received:received; s=dkim20160331; t=1698476640; x=1700291041; bh=qWtmbNqUP3Xx4OV2 VQNyE0fIaOm4RFraPBU7f4v9YS8=; b=DDJwRw9vR38wAld5wjK4tY05G61AtS7N 5hcs94CZhW3NK4U1DbtTDxd3DpuimkbGuC3bmA/QyhBkhIVZDRnJKM9huvBc0wut 7LkzbyTW33jaDaXgoGXq0fTcyRHNsnKsdPYDB0WTELEXwU7Ubt2ATk5RbCh71GI4 j/XkIZ+5gzGWJkW6IGn7q606IqWdOrqUJ1cPeQ7KRD1KIcExaefgL9oQKFUDzmd+ uzPKQnRljIqS0bkh/qsrkD369KtW/Idcq/qNzoJH+PdWgHiBoQ2acFxkG7+95C02 IRB6vtJV8loHmVFq2hDBBqoMynbQCkCPDcc21Dh3QdfSpOVZTrhCOD+7c68xaN+o K6HCHv+c8AHyrmcPKuuKYJLwKQA194aF6PLYxfqyK2DsSIPvq5fGHig1yMt72TLw HGdBHX9P9QLEiim4A8Q1468XeL1YfEAWZzLPek9nOn4HADfm6uPxUtnKcnxyRPK0 h+RcNkApOrm5DKyvok8AFLdmUIX5+fdY/BCtuEPRCbMPMuvTqRvr/kde7rdIf7/w doIPm3Q+rCmqHNL93uzPEvtiYw+pVvgszS5elqlLvuhP+AXTLdI4Eqr4AUwRmON9 yoa+ktM1YrOVY8CxfhffnvZivbUuYryaGNQpNrTaPSiSV7u0WUy5//lOmo/h8kNd KFc4UYvxfm8= X-Virus-Scanned: amavis at mykolab.com Received: from mx.kolabnow.com ([127.0.0.1]) by localhost (ext-mx-out013.mykolab.com [127.0.0.1]) (amavis, port 10024) with ESMTP id 0xkXs1sSzboi for ; Sat, 28 Oct 2023 09:04:00 +0200 (CEST) Received: from int-mx009.mykolab.com (unknown [10.9.13.9]) by mx.kolabnow.com (Postfix) with ESMTPS id 3265030011BA for ; Sat, 28 Oct 2023 09:03:59 +0200 (CEST) Received: from ext-subm010.mykolab.com (unknown [10.9.6.10]) by int-mx009.mykolab.com (Postfix) with ESMTPS id 65FEC20C7689 for ; Sat, 28 Oct 2023 09:03:59 +0200 (CEST) Message-ID: <92431af8-dcb5-4144-aa23-e4ff81d13f60@alec.pl> Date: Sat, 28 Oct 2023 09:03:58 +0200 MIME-Version: 1.0 To: internals@lists.php.net References: Content-Language: en-US Autocrypt: addr=alec@alec.pl; keydata= xsBNBEy9TtkBCAC4ef0IJaqTDQNQZ5CPrHvNs5kcACvtffwydrTcRJ28dHwjZD8daSxfVYEo acyARevTOvsp36Vgq8Yt7ATu6y7MPBaPj9Lq0kwX7HM8QDn8jTfufAgMjxcw5bD+JNR5+8G9 hUF3F35gVuAd471hS+QB/Ug/PezcNx9H5yFUMuvrO3ybyIDhw5qJI2RoJMjMr5DPKUG7z810 1e/NW7y9FfHq+Ony7A70w+vcfv1L+LLX5gfrpKI3m0zKm7cj1vyxZfC9RijIzWZN3GgExexI KJdbkcg9F/zigKo72TJhgvjy6YZP03HmWZVcpsd3aIT3Tweg0cCivaKVBNcFR1oda6XvABEB AAHNFkEuTC5FLkMgPGFsZWNAYWxlYy5wbD7CwHsEEwECACUCGyMGCwkIBwMCBhUIAgkKCwQW AgMBAh4BAheABQJMvVAwAhkBAAoJEL7mdKAZNZ3BEhkH/1eAuCOSXsWg8YwZzmABoKKZfNpJ Z3QTwAMxXyCPjJMwLMLHsrVO+VbGupFcIW/q/3bvt1r8LwPB73rg0TFiHoYzeQzdnOVYFW7w OYz9BDVjLE4goDk6xN5Nj1CpBMXzQFdr3HVKyuRK1CLd9p13CofiBlLsQ4JqtosnlvSCEjTL yIajACU3kY2je1e58N5VHzZ+VMeg2xbuQJ3q1iTkYggZ+xRC1muw4Xgt2vxgfWjn7u3dmjYM T3H2WFprLZwliejHgzhWdYABdyCU5VuGCLOV+xk2UCADya0hvVVIezA/4YG3w01yjsljRrKy HFJUqw+MqagA6dsfflZSvmROKMbOwE0ETL1O2QEIANHbid+rMQ/IX0/UyVtnLWunDEg6Yl2B twHTecZ4Ym3tBxc1sbPDoYpY0DZ86gYi9DCbolrdjnrRK9ldYItVJ8rJUkEIDz/2yhjcr3s3 p2SyI94bocoG0WW+VRlssJMxTB2ihblihkY5HqT+9PgOFxnpSqz1ksTaI3JOVcokidhoB7MJ muyb28rNtZCJP7upRUwBSoZfHiL83w3Ad1Fn49QVO7kshH11lNyJ9jB17BTl1I0sj7RPqAor JcMxsSOJXW71ZcipXWym+GacY/qziQw7bT9CQYSmr4SiRV7GahD91enDkdv+pUAnb8NEifQ1 LT26XcL6Ng9EbG5AT4qI46kAEQEAAcLAXwQYAQIACQUCTL1O2QIbDAAKCRC+5nSgGTWdwe2T CACaux3lHitD8IIO5fy6RxPqym6vMlKiN0IyilahtJ0A2htNqwbFb6TukpzKw04DGSPEOGPa o4hdsLtQtqAPwqrR+FGJDc6V/jD0rPjThC3NcvkJuoi622ZLCsi8TAL5kBmF2NYd7ejszB31 5EzvpXSeES8+9pv6yshzUborEg9QKhPxW0yvrdj2OwFUlRr6/jLpKmMLzSx5F0yEg10urvfe 9Sttk5TVzHycOa1nKSzj79F1jXTl/mji/i082s1nlwb8d6LNVrm0e1tGMxSk/WpghFVVSm4O MvUvMkEEDkwGsm+mPcmX4UPcvq/wU3hGhDeVlpkfVTJQGvDbEUzTXbz6 In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Re: Basic Type Alias From: alec@alec.pl (Aleksander Machniak) On 27.10.2023 22:42, Oladoyinbo Vincent wrote: > ```php > > namespace Package; > > typedef MyTypes { > type Numeric: int|float|null; > type Chars: string|null; > type Result: bool|null; > } > > ``` > > ```php > > use Package\MyTypes; > > class Hello { > use MyTypes; > > public function A(Numeric $id, Chars $message): Result > { > } > } > > ``` Your typedef is essentially just a trait. One new keyword less. What would be missing is direct access to type. If we indeed allow type inside a class/trait, then natural syntax becomes the one used for const/var. I think your syntax 2 is the worst anyway. Syntax 3 (use-as) will not gonna fly as we already have use-as in a conflicting use for classes, unless you change it to "use type string|null as NullableString". I think Syntax 1 makes most sense, especially considering a case of long list of "subtypes" that could be class names with namespace. Types should also support visibility (public|protected|private) when in class/trait context. -- Aleksander Machniak Kolab Groupware Developer [https://kolab.org] Roundcube Webmail Developer [https://roundcube.net] ---------------------------------------------------- PGP: 19359DC1 # Blog: https://kolabian.wordpress.com