Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:121477 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 91162 invoked from network); 26 Oct 2023 23:50:49 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 26 Oct 2023 23:50:49 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 5FAC11804F5 for ; Thu, 26 Oct 2023 16:50:48 -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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-vk1-f181.google.com (mail-vk1-f181.google.com [209.85.221.181]) (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 ; Thu, 26 Oct 2023 16:50:44 -0700 (PDT) Received: by mail-vk1-f181.google.com with SMTP id 71dfb90a1353d-49618e09f16so665871e0c.2 for ; Thu, 26 Oct 2023 16:50:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698364244; x=1698969044; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=dlAq2lJOhnxNW8E2ESoSSMbU65xJnT8pfpwTYbGSf00=; b=R3sbitKcDOfL3WzPmI49MLScHzIYx1wUGDfShYbxDrVjKTZsRkMpXUcUvbT0hVtPzs ktce19TFE6LZvbEGW1LK/LUZuRcTZWs623RSAdBtymwNvcHnFt0CruwdgjdCubbLFjOU O5KoyTjmzml8PN26FUElZaxbHvWihNV65smOKK60TSiYQi9FJs/8JqpeDkpXWDi1T1Rw YL6wIQCCwJSc+czC9V3bMcoIXUxQihZCdvqhlqeE9VLTDups9d1g3MZ3NalWoWHvcrrF 4IOV8j6nF/JF4vtm6IaPqEDm2g3XhgoLdZ6maXxjm98RDVWdOdyWxn+0mEtWgldX8mCu 8Cxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698364244; x=1698969044; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=dlAq2lJOhnxNW8E2ESoSSMbU65xJnT8pfpwTYbGSf00=; b=L53+MSTnRpBjMbTbQFVV2/dVpdRuPZV3dFhXhqI6YSDunLFxCuRdARFqF0sEnjuVwn hKefYl56lI1KT0z6FKmCdiTmbNYOJcCO2fY5X5oqVOQbbHyGWRbk1lZgI+sQtXl/3zwc KKCP3tQWxeBxvKIu9qfXe1O76xLK61NMLC46PI+/B0RYfa4LpxIp93XuieOukizpXSBB wp9xAmt9SaSn2QU7FV3W+kdw8xp9FZD62/3bUdq9Gm+iKUvZFv4QuJ5FqhKbO970tLvv kvbzENIG8bhcTl6xVMRUEiwTd9caLS/tpz+XCQQeNk0TpvLq8EV0bOv9dGKM90ObtSXA egCw== X-Gm-Message-State: AOJu0YwWwrIP4QnsaHWTbkEglilXnEfmNplEKwpQlJkNLfqFpIpazDrT xwQr5MJmKrID8GU4YVVDSAInOKKVg+5rS9IXJ0Q= X-Google-Smtp-Source: AGHT+IFhKDcWlQDDv24rShnnh0Afy11X371tm0vBvDKWxOJxa5K/81rDvcjFTRhqbyP7r6Mfg9kSHR0S/O6RVDp3+ew= X-Received: by 2002:a1f:1dcd:0:b0:49a:b0be:3a00 with SMTP id d196-20020a1f1dcd000000b0049ab0be3a00mr1571823vkd.8.1698364244003; Thu, 26 Oct 2023 16:50:44 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 26 Oct 2023 20:50:07 -0300 Message-ID: To: Deleu Cc: Larry Garfield , php internals Content-Type: multipart/alternative; boundary="0000000000007693c50608a73dcf" Subject: Re: [PHP-DEV] Basic Type Alias From: ericklima.comp@gmail.com (Erick de Azevedo Lima) --0000000000007693c50608a73dcf Content-Type: text/plain; charset="UTF-8" I'll use it a lot if they'll be namespaced. It avoids name-collision using the existing ecosystem and we already use lots of "uses" in our codes. When Enums came to the party, they came namespaced as traits, classes and interfaces. The last 2 represent types, concrete and abstract. User defined types are nothing more than types, so I think the way to gois to keep it namespaced as well. About the type compatibility, covariance and contravariance, let's say I define some type inside my package: // File: C1.php => My package code namespace N1; typedef MyString = string|Stringable|\Symfony\Component\String\UnicodeString ; typedef MyBool = null|bool; typedef BigNumeric = int|float|\Brick\Math\BigNumber; class C1 { protected function myQuestionableFunction(MyString $str1): MyBool { //... } protected function myQuestionableFunction2(null|C1 $str1): ScalarNumeric { //... } } // File: C2.php => On the project of those who are using my package namespace N2; typedef ScalarNumeric = int|float; typedef Falsy = null|false; class C1 extends C2 { protected function myQuestionableFunction(string|Stringable|\Symfony\Component\String\UnicodeString $str1): Falsy { //... } protected function myQuestionableFunction2(Falsy|C1 $str1): ScalarNumeric { //... } } I propose that this code should be valid code, because, in the end, these *typedef's*, are just synonyms. *Note:* By the way, I propose to use the C/C++ keyword, which is *typedef* and dropping the syntax* "type MyType = [string, null];",* which differs too from how typehints are used and do not add any benefits *.* -- Erick --0000000000007693c50608a73dcf--