Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125466 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 qa.php.net (Postfix) with ESMTPS id 833F81A00BD for ; Sat, 7 Sep 2024 12:42:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1725713064; bh=Czkb1wZUTE+kaNCrWrT5Fw5pzD0U06VtijEapwncbns=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=kv/koH2HDwCB/7QBWa20WAbaGCFuIUEoBYForJN2scNofiihOeCqHtGFWzmycUkyP sCOIAQXMvDPFJuM6NcDJySfoaACNx+KJUpEOKHjGeuQBjd71jd9UfdHsFBzP7yCwm7 WHk3la4ZHuHXhgll7mT6vyNrf9xV5mf99z6XEyuhO5g/A+B7IVJp1cMEWKWlEGlqaM iBJX29NOv+Q//wZLkftlAvoapG7LwPe0p/kWbL+0agn0go6PfXTOaj3nQej+HWnPB3 JfEz/iAoQEKeP2/KPEVKj00a9dU+sjL+T61X47dZiyKU6MbHuWORO8F7eA/8x4GRZH e6xSzaYRzICPA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C1E8E18006D for ; Sat, 7 Sep 2024 12:44:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DMARC_MISSING,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-yb1-f171.google.com (mail-yb1-f171.google.com [209.85.219.171]) (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 ; Sat, 7 Sep 2024 12:44:23 +0000 (UTC) Received: by mail-yb1-f171.google.com with SMTP id 3f1490d57ef6-e1a9dc3f0a3so3276486276.0 for ; Sat, 07 Sep 2024 05:42:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=newclarity-net.20230601.gappssmtp.com; s=20230601; t=1725712943; x=1726317743; darn=lists.php.net; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=LxxiPIz4NVsgSjxTLoR23DJ4fRQUpTuWPzxAUGyhZEU=; b=HOhaq9A9RshbLWXmzILETw/1SCppru7tFBwnTmnKQfpUJOco0AwS8pydFSXL28pha4 gmBRXKOezVTHOJgO+5tbJ94w5mDihuJJFyM9AD25Md60j0UN8JBfKlkWnOivDwWQT3+8 BQpY6/00GGDXbN0th62AAe5nB2CTnQEU3aD0yuQ/Xdmu2DYALAJqKciVIv0sUl4TgUW2 CH1hSDsx77pVh66ymq7A/3o73/fiJ/2QfpwhIy/Dj1EHmWvwdvF7agMaVa+uSvV0GLKT WH7HUmT7e7pXgFKBNcLFisfplGojuTJdB/WgCCNrzcYXrsT3bYkc4vBQOx8zv2SZZ1Fd 0VQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725712943; x=1726317743; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LxxiPIz4NVsgSjxTLoR23DJ4fRQUpTuWPzxAUGyhZEU=; b=aRFJ0MUtbxrW6dImRgYMObCezJ9THSIvJSsEfLLf0EdIq6EhiJb1ph/W9iX7EOeYss RTPXxLovK+ZpVTtst4dIHJgPTGMtf3bwz2oMdg/U7FTN5ZCLNz9X1xR/szHsyG+QG03W BseQO+2E8WdbozWeY5kgEkNTa+XIWzllGiVKvAl+CgEE4X5lAx18Rtu9lOKI7x5yNVew Vr3tZTtPP7arrTmRHyl9SgNh1j30qhsjDvYGuX7CG4TmrzMXl+yg0Fk5zli2SPFb5C2S Pv2tcPTHK/2lqQoHc84Fl3tWuwDjYeK2t/gowlGItA01rNNRMMR+/Y+Yq7/e6GycS54t RgCw== X-Forwarded-Encrypted: i=1; AJvYcCX/Sh9wENl+AtxrEKInBMt0MW+YkBaL513dEYGaQZTY1t8pRdKOALVl8M0I1jnax0gtKBVzseScDpc=@lists.php.net X-Gm-Message-State: AOJu0YxFUsn++oibJq2w28lWiqXQOji92IF7y0T2BclCHVoZa1+fkjlF xH8enDFxzqLyJj0u0dS3aF4NXhXrnLalI1auSdTt4fd9sbhqXISTsOXoVJebS+uR136BxxV7edd 9rRs= X-Google-Smtp-Source: AGHT+IHSIgUOoPe0N3l+EMic4LJKLcrZaUxAQ9sSTXVi4Spkwv3k+TzxCrMkFu5RDj8gqW18gNaSfA== X-Received: by 2002:a05:690c:2a82:b0:6d9:b950:ec48 with SMTP id 00721157ae682-6db45278bb4mr52302687b3.42.1725712943098; Sat, 07 Sep 2024 05:42:23 -0700 (PDT) Received: from smtpclient.apple (c-98-252-216-111.hsd1.ga.comcast.net. [98.252.216.111]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6db5c65ad1asm2106167b3.64.2024.09.07.05.42.21 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 07 Sep 2024 05:42:21 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.10\)) Subject: Re: [PHP-DEV] bikeshed: Typed Aliases In-Reply-To: <928A2984-6035-4DA6-9EA7-12E85237C270@php.net> Date: Sat, 7 Sep 2024 08:42:21 -0400 Cc: Rob Landers , PHP internals Content-Transfer-Encoding: quoted-printable Message-ID: <71DEAAB9-D788-4EB9-A07F-E47211F92F78@newclarity.net> References: <0fa39535-f22d-4eba-b4df-90abe39e683a@app.fastmail.com> <79e58673-50ec-461e-a998-736b020e4287@app.fastmail.com> <928A2984-6035-4DA6-9EA7-12E85237C270@php.net> To: Davey Shafik , Larry Garfield X-Mailer: Apple Mail (2.3696.120.41.1.10) From: mike@newclarity.net (Mike Schinkel) > On Sep 6, 2024, at 4:45 PM, Larry Garfield = wrote: > Aliases can then be used only in parameter, return, property, and = instanceof types. Extends and implements are out of scope entirely. Is there a strong technical reason why extends and implements should be = out of scope?=20 There is definite utility for this, to create a local alias in a = namespace that can be used throughout the namespace rather than having = to refer to the external namespace in many different places. > On Sep 6, 2024, at 8:46 PM, Davey Shafik wrote: > I would very much prefer to either go all in with an Enum-like (which = means that we can hang methods on to the value) or we need to = distinguish between type hints for class-likes and type hints for = not-class-likes (*Bar anyone?). Allowing methods also have definite value as most use-cases I have seen = in other languages alias in order to add methods, especially for = enabling support of interfaces. Which, however, brings up an important distinction that other languages = have made and which I think PHP would benefit from addressing: 1. Type Alias =3D> Different Name for Same Type 2. Type Def =3D> New Type which has all the same properties and methods = of other type e.g. (being hypothetical with the syntax; bikeshed away): typealias LocalWidget: Widget typedef MyWidget: Widget { function foo() {...} } function doSomething(Widget $widget) {...} $w =3D new LocalWidget; doSomething($w); // This works, no problem as LocalWidget =3D=3D= =3D Widget $w =3D new MyWidget; doSomething($w); // This throws an error as MyWidget !=3D=3D = Widget -Mike