Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129530 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 EF3521A00BC for ; Wed, 3 Dec 2025 21:09:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1764796175; bh=ZS/M5SwQdPHb57dU0EfNgqvG2en6HSLDIVLMoOLlPqo=; h=Date:From:To:Cc:In-Reply-To:References:Subject:From; b=BNj26YUfOzTQ2eA4pye3PrSMGiuHA16BiJ2eBcYslxISYeXO51NI+on/0kM7TZSTF bdPwZP8K6tiTC5UKPn40nL/leKMz5PuVa5Qk4uPHNai1j68zN0PZNyiW6ZZBrcwrty WW6aYAj8ySdf62Wjb0tCNy9vrl+D4NfK9AIVmfh2K7221FOYmBbBgSCYL2khDwM3NV h1N9uq2jdNIyC7yRFA1BYNqRgfRbrVwmr+ahBsBhlg4ffntJLMJNnNWA+MMoi26/kE cHx07EiY7LH4kZZfXwRSqJJSLOHPLE3eSeJq93BTqCPq7Ngwp06M/R+7T8BKY6nj64 JtCf7xGb51ajA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 8BD0B18003E for ; Wed, 3 Dec 2025 21:09:34 +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=-0.1 required=5.0 tests=BAYES_50,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 fhigh-b3-smtp.messagingengine.com (fhigh-b3-smtp.messagingengine.com [202.12.124.154]) (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 ; Wed, 3 Dec 2025 21:09:34 +0000 (UTC) Received: from phl-compute-12.internal (phl-compute-12.internal [10.202.2.52]) by mailfhigh.stl.internal (Postfix) with ESMTP id DA4587A01E6; Wed, 3 Dec 2025 16:09:28 -0500 (EST) Received: from phl-imap-05 ([10.202.2.95]) by phl-compute-12.internal (MEProxy); Wed, 03 Dec 2025 16:09:28 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bottled.codes; h=cc:cc:content-type:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm2; t=1764796168; x= 1764882568; bh=ZS/M5SwQdPHb57dU0EfNgqvG2en6HSLDIVLMoOLlPqo=; b=V vLxTiK1tpS+Hr2F6RuYRA6riOclhSltiwTGFh9alH60ujiIiJBxpE6YxRUnDHuWP 3NtuZy6PU4Xz54wanmhM4BlZ4e1DLqlB46z6Gw/nZi15DfC+GO9g3QtI1I3piCMI 6JdJomavBJxbeE3tLphqgul7ZiG+zYDdrg+AwIbJhR/gEYVViv1lld2iwGdGvGlj u0FAJokcvf+4xhlDv4e1N1YtlxLrLh8wyV7WEucr+o8U5V5Cf/ysr36ANQQB1N72 WbB8rLp1eV+xd3BzcxnIBy26IkRCQTtIiLPD58CXA2/PW3MoEFl4dhl1XeTl9FWQ fdFalyY4+xxLG/OGUiRkw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1764796168; x=1764882568; bh=ZS/M5SwQdPHb57dU0EfNgqvG2en6HSLDIVL MoOLlPqo=; b=LdVXPk0BEwmvGrS+RgA5DdwrQ61afjoKtvM45Wj3iga9uwIuqPR HnpXXrEGocKn216cGgCRcV2f5DL6MusQLS2Dy4PXHObGvAP/i5trhUU1HUr/YzSU 4L0nuyjD7U/ibRpYi9EUAaNsSltkTLUcz2t3geBDScBV6Y+7UOJXqcbS081v+Iup 0TfWFjjWjYzsPm0DpDk1N5tRTd1Rgs41ZkWZhrFaUSjnYfSkri5La4fZO0d5W6O0 4bA63CqhF8wB4nYii+rR/y8rO6H+H32sXuDzVUp8RyCj6LaRy7QH0t4zU8QmfKjE JYHS3/Uvk7XxNrlYVEx2SAO7GFe+9+FuswQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgdefkeehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceurghi lhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurh epofggfffhvfevkfgjfhfutgesrgdtreerredtjeenucfhrhhomhepfdftohgsucfnrghn uggvrhhsfdcuoehrohgssegsohhtthhlvggurdgtohguvghsqeenucggtffrrghtthgvrh hnpeeiueethedvvdefjefhgfeiheelheehtdfhfeekjefflefgvedvkeduteejjedttden ucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehrohgsse gsohhtthhlvggurdgtohguvghspdhnsggprhgtphhtthhopedvpdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopehinhhtvghrnhgrlhhssehlihhsthhsrdhphhhprdhnvghtpd hrtghpthhtohepphhmjhhonhgvshesphhmjhhonhgvshdrihho X-ME-Proxy: Feedback-ID: ifab94697:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 751911820054; Wed, 3 Dec 2025 16:09:28 -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 X-ThreadId: AJmU-qZxpztc Date: Wed, 03 Dec 2025 22:09:02 +0100 To: "Paul M. Jones" Cc: internals@lists.php.net Message-ID: <4ba0f7ca-815f-47d8-a6bf-43abe2aff842@app.fastmail.com> In-Reply-To: <45C95FE8-B0FB-4A22-9460-477533527F41@pmjones.io> References: <87e9d1bf-e407-45c1-9fad-d8759405ab8b@app.fastmail.com> <45C95FE8-B0FB-4A22-9460-477533527F41@pmjones.io> Subject: Re: [PHP-DEV] [RFC] Type Aliases Content-Type: multipart/alternative; boundary=3ef32e91959f400faffbf633a47ef6a7 From: rob@bottled.codes ("Rob Landers") --3ef32e91959f400faffbf633a47ef6a7 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Wed, Dec 3, 2025, at 22:04, Paul M. Jones wrote: > Hi Rob, >=20 > (We've been using a lot of PHPStan type aliasing lately in the Star-In= terop work, so this topic is timely.) >=20 > Is there some possibility of making the aliases more classlike so they= can be autoloaded? A la: >=20 > namespace Foo; > type number { as int|float; } >=20 > Then elsewhere: >=20 > use Foo\number; > function sum(number $a, number $b): number { return $a + $b; } >=20 > Let me know if I've missed something fundamental. >=20 >=20 > -- pmj They fundamentally cannot be autoloaded because autoloading happens at r= untime, not compile time. At least, with the current autoloader. Autoloa= ding type aliases would need to have a fundamentally different type of a= utoloading that doesn=E2=80=99t exist today. =E2=80=94 Rob --3ef32e91959f400faffbf633a47ef6a7 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
On Wed, Dec = 3, 2025, at 22:04, Paul M. Jones wrote:
Hi Rob,

(We've been us= ing a lot of PHPStan type aliasing lately in the Star-Interop work, so t= his topic is timely.)

Is there some possibility= of making the aliases more classlike so they can be autoloaded? A la:

namespace Foo;
type number { as int|fl= oat; }

Then elsewhere:

use Foo\number;
function sum(number $a, number $b): number { = return $a + $b; }

Let me know if I've missed so= mething fundamental.


-- pmj

They fundamentally cannot be autoloade= d because autoloading happens at runtime, not compile time. At least, wi= th the current autoloader. Autoloading type aliases would need to have a= fundamentally different type of autoloading that doesn=E2=80=99t exist = today.

=E2=80=94 Rob
<= /body> --3ef32e91959f400faffbf633a47ef6a7--