Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:121517 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 35826 invoked from network); 29 Oct 2023 21:53:06 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 29 Oct 2023 21:53:06 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id BE5611804BC for ; Sun, 29 Oct 2023 14:53:04 -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=-0.2 required=5.0 tests=BAYES_20,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-lj1-f171.google.com (mail-lj1-f171.google.com [209.85.208.171]) (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 ; Sun, 29 Oct 2023 14:53:03 -0700 (PDT) Received: by mail-lj1-f171.google.com with SMTP id 38308e7fff4ca-2c523ac38fbso56777211fa.0 for ; Sun, 29 Oct 2023 14:53:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698616382; x=1699221182; 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=8JF3wugsFe9KBBOT+EckChhXPC5H1MzsBnon/pJijRk=; b=VpTLn7pucZx4mqc5rxClNgWdmNzHu0Glm/ZPADeo94diZA1sv8SIkWNc0J0ocCwFCt 2pdSyIqSQdYp032lsUqVs+KIUBi4Y0hAsYThMYhH0tvDOX35oUbB44eoN0jRkLTqsPu4 xfT5tJF8Ir57ZpPZWuwtMu39ZffOTszuddrus+6ftJ3QOQOqRr+zwgbOmDxqikH+MTNX 9bYufMtzLYRodUrx7/WSoauBspOkz9HK2sTyQpwqUV6C+OjeXLZEVQR1khpnW0mhv86R tA2LQdiSTFriJaz6vGV8uIlIu+CjExLEOo1YWErS7uR/6BKZS0NtDf6hjMY/Fwxs7BCN FvZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698616382; x=1699221182; 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=8JF3wugsFe9KBBOT+EckChhXPC5H1MzsBnon/pJijRk=; b=o/ZyS5xFLUUrsLCdMpfyXuteTjc3lb2h15wVhYz8eKC4l9N7nGStdxmdQyKfL28N58 7+y+u2EnXSXFdFvbaREvF7aKzoJylRzB/wOBF3wubFXu3gBjGy5qwoK1nAxDMl3O13Aj J5Mf4YBODc3YcQ/OrBzwO/a9YqJIxi15DUoFI3pECwTmqN+E8KZAJM8R5elKsz7LtA2p Ny0UpqGfynwO2FgqmYtR5ivSpJdQVj3YE6PbpLVIhtb4bQeWt5jeGOvu9QlGXRex9B22 5TWvArfTpA75et6lBJ7PfkkNMuRRe21HL5BHPNmgvQtSRZEQ417dCtMNzCBeJ7VMeW6H SATQ== X-Gm-Message-State: AOJu0YxpVfKsbuQTe4b5s8zq/YO3HXJm+qxzGv9WD+fBId/d4cWtE0hM fYkEAUzbOqF8E5bz0f6s+z4ww3tYPZ5O1m7xgsc= X-Google-Smtp-Source: AGHT+IEs9kO9RE6WMxdzyLpHoGLl07xcoX2YodHdcdyEdPGNE1nsNlLqLl8Gkm1PRGToW5xN77mnpWenzL8Sfq+X2p0= X-Received: by 2002:a2e:87d1:0:b0:2c5:d3c:8f4d with SMTP id v17-20020a2e87d1000000b002c50d3c8f4dmr5557109ljj.13.1698616381810; Sun, 29 Oct 2023 14:53:01 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Sun, 29 Oct 2023 22:52:50 +0100 Message-ID: To: Oladoyinbo Vincent Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary="0000000000000c2a940608e1f212" Subject: Re: [PHP-DEV] Basic Type Alias From: jorg.sowa@gmail.com (Jorg Sowa) --0000000000000c2a940608e1f212 Content-Type: text/plain; charset="UTF-8" I really like the idea and I would love to see it in PHP. I'm wondering however, what would be the scope of the feature and how complex would be designed type system. Examples I saw in this thread could be easily replaced with union and intersection types (i.e. numeric as int|float). In my opinion, there is a little benefit implementing in this shape making the PHP core more complex. The two use cases of user defined types in PHP which would benefit a lot IMO, would be: 1. Typed arrays similar to Typescript. 2. Semantic types which would increase the security of systems. Example: type UserId = int; function setUserId_1(int $userId){} function setUserId_2(UserId $userId){} setUserId_1(5); // OK setUserId_2(5); // TypeError setUserId_1(UserId(5)); // OK setUserId_2(UserId(5)); // OK Kind regards, Jorg --0000000000000c2a940608e1f212--