Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129518 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 lists.php.net (Postfix) with ESMTPS id B50EC1A00BC for ; Tue, 2 Dec 2025 22:23:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1764714240; bh=qhRzFXNqLf+ASpIffRbKRRmq+3niDtfRr3XAFPq2bR4=; h=Date:From:To:Subject:From; b=XsryA2RYeZrHEgqGjsV4WZLjPYWxal9DoTCIm3L7EKxPegQYjhSDMMo5n8oE0qGCz HBkJ6sN8YZPwzX30cMV2Wa+MJpHUBG767jYOCkIxr8hmIaXWFCep63czNHthvsYBLK wtzFu4xpBr2HYh2qK4LVljD5oJmY5PWMdSO3PrnprWGCjOpTJJfUN9yc+0VbzyhwP0 ZDYZD+Yj7ffnPQvZfJ+iOft0ySMUtUvG54aFECTVRXH0MZ5v3AZntWYKSDgzaGr9ws /AvBsyJ2OMxKsL3RqOEEepiTFbt0dCLMctsR0IvnRemqzmjIc/KJKziHkR1JtvAbPt OMFTgkPl9fqvA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 688A7180050 for ; Tue, 2 Dec 2025 22:23:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,HTML_MESSAGE, RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from fout-b5-smtp.messagingengine.com (fout-b5-smtp.messagingengine.com [202.12.124.148]) (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 ; Tue, 2 Dec 2025 22:23:49 +0000 (UTC) Received: from phl-compute-12.internal (phl-compute-12.internal [10.202.2.52]) by mailfout.stl.internal (Postfix) with ESMTP id 62DB81D000B5 for ; Tue, 2 Dec 2025 17:23:43 -0500 (EST) Received: from phl-imap-05 ([10.202.2.95]) by phl-compute-12.internal (MEProxy); Tue, 02 Dec 2025 17:23:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bottled.codes; h=cc:content-type:content-type:date:date:from:from:in-reply-to :message-id:mime-version:reply-to:subject:subject:to:to; s=fm2; t=1764714223; x=1764800623; bh=qhRzFXNqLf+ASpIffRbKRRmq+3niDtfR r3XAFPq2bR4=; b=P3dPOHZBg7TOjl/9Uza33pUWf447JrMigr2Mt0nWL27UzQBV 9Ot03DlAI8O3oPj9McROQoHkxqrg4sHL8chlwAEt+oelYnzzdGVcmkndYkIJ6UX3 3L8f0WkCpE4MkkgpGayPk58Wga9tb9+m8Q3/w2AwQuGUtX5ocoGtA0wiWvOo8qc4 ZC3XqlC2MhNDjOMve2RnLrP5uwWSAHu43H8QTLVCD9y/gOP+03ZcBpGCoqwplRnR 7XpjEUrqJhyQ5Y9GtNwl9ljf/kdNBmvNpNnlScENuhNunOte/OUW/REPb7JihbBl otyPvhdLCmaQ99sBAUfbFGI4ZGsVOb96zN9lJQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:message-id :mime-version:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1764714223; x= 1764800623; bh=qhRzFXNqLf+ASpIffRbKRRmq+3niDtfRr3XAFPq2bR4=; b=g sBex1pRzKXK35RneGaGyFDBlvZJw0+JFZRlC46bh/bYfsIOHWqeDleSanhe/wNng n2iRyLfjt99Ue9D/ORKkakZERy/DPCGhiNHnk4s0ekHMzlP2UoVcVXds6Lq5n0fE T3M1TYkwRaAYVIMNqqitsD0ndPblj0nuHXvMr57Fgb4TthhcY6CTxXJdd2VvVhi4 0LIG+KBZIs9o6zUbRu24IYYqdPblO/5QK5+rbVejJ6xqCFFJUwTf5PW7WUOYQpmw 8pR4NO3NXGqdZf2hZ26NUQ+Z66pw9KwBxN4lBa/CndsMzZCI6/5IDuPj5L/vKh5L lpDAIjOyxTaId5ei23rNQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddufeduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceurghi lhhouhhtmecufedttdenucenucfjughrpefoggffhffvkffutgesrgdtreerredtjeenuc fhrhhomhepfdftohgsucfnrghnuggvrhhsfdcuoehrohgssegsohhtthhlvggurdgtohgu vghsqeenucggtffrrghtthgvrhhnpeevgeekjeeftedujedtgfduhfdtieeiheehvdegie eiudffjefgvedvleffjeegffenucffohhmrghinhepphhhphdrnhgvthenucevlhhushht vghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehrohgssegsohhtthhlvg gurdgtohguvghspdhnsggprhgtphhtthhopedupdhmohguvgepshhmthhpohhuthdprhgt phhtthhopehinhhtvghrnhgrlhhssehlihhsthhsrdhphhhprdhnvght X-ME-Proxy: Feedback-ID: ifab94697:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 8B46E1820054; Tue, 2 Dec 2025 17:23:42 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 Date: Tue, 02 Dec 2025 23:23:06 +0100 To: internals@lists.php.net Message-ID: <87e9d1bf-e407-45c1-9fad-d8759405ab8b@app.fastmail.com> Subject: [PHP-DEV] [RFC] Type Aliases Content-Type: multipart/alternative; boundary=b499d03129fc4e0789a517efd61ef786 From: rob@bottled.codes ("Rob Landers") --b499d03129fc4e0789a517efd61ef786 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hello Internals, I=E2=80=99d like to request your comments on type aliases (not to be con= fused with typedefs) at https://wiki.php.net/rfc/typed-aliases TL;DR (it=E2=80=99s actually rather short): Following the same syntax as other use'ing statements, you can alias a t= ype: use type int|float as Number; function sum(Number $a, Number $b): Number { return $a + $b; } You can also include types, with some restrictions: include types 'math-types.php'; function sum(Number $a, Number $b): Number { return $a + $b; } These are compile-time replacements that serve to make code more readabl= e and reduce repetition with no runtime overhead. Type aliases follow th= e same scoping rules as other use imports. =E2=80=94 Rob --b499d03129fc4e0789a517efd61ef786 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
Hello Intern= als,

I=E2=80=99d like to request your comments = on type aliases (not to be confused with typedefs) at https://wiki.php.net/rfc/typed-ali= ases

TL;DR (it=E2=80=99s actually rathe= r short):

Following the same syntax as other us= e'ing statements, you can alias a type:

use type int|float as Number;=0A=0A=
function sum(Number $a, Number $b): Number { return $a + $b; }

You can also include types, with some restrictions:

includ=
e types 'math-types.php';=0A=0Afunction sum(Number $a, Number $b): Numbe=
r { return $a + $b; }

These are compile-time re= placements that serve to make code more readable and reduce repetition w= ith no runtime overhead. Type aliases follow the same scoping rules as o= ther use imports.

=E2=80=94= Rob
--b499d03129fc4e0789a517efd61ef786--