Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128388 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 955D51A00BC for ; Mon, 4 Aug 2025 17:46:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1754329489; bh=ypo4FWqXu0QkxI4cBmBfGXOxbesDPwjUFs2LsmiAJw8=; h=Date:Subject:To:References:From:In-Reply-To:From; b=VvpTCY9mLvHZYXuVNgUkmx5R2oWxCS6OZt4ON2DG2MVk84GqYrTyH834KoMgRFRO6 ufcvvefTSLI5fa774A4il0jIAJpKOMiiWRQvRJ+ffJKscP8RqUeawQSRDO2Rpu1Hxq wWNdyFHwBJSJd/ZWknXZNmq+Aj1fjM/K09kjtd/xnocV4zBMJjVS5OqMD8meiO55HL GvwQE8C02hKJr3CCFvGzBSMDNW5LeKj4trtr6A0xUu/prKgkHqvCNgTsbqHriUKTsx ru2IcO4yRvmYzkJ+1xG3KD3SiUqVkPOFjHOVMkOm+aHs7GasOZ2gAOvuADnkSyD7/f MiAGdr6w4KpYw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 134011801D4 for ; Mon, 4 Aug 2025 17:44:49 +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.8 required=5.0 tests=BAYES_50,DMARC_MISSING, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from mout.kundenserver.de (mout.kundenserver.de [217.72.192.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 4 Aug 2025 17:44:48 +0000 (UTC) Received: from [192.168.178.22] ([195.52.176.114]) by mrelayeu.kundenserver.de (mreue107 [213.165.67.113]) with ESMTPSA (Nemesis) id 1MC3H1-1uvL3v4C0T-000HU3; Mon, 04 Aug 2025 19:46:27 +0200 Message-ID: <1c1aa775-07d1-4f0f-889c-4d801f7ceadf@nunninger.info> Date: Mon, 4 Aug 2025 19:46:26 +0200 Precedence: list list-help: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PHP-DEV] Blog post: If we can get partial generics, should we? To: Larry Garfield , php internals References: Content-Language: de-DE-frami, en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K1:h3d19JHO6OcJR6GBV/I3M/gzICbyTuzaOoU5xC47ehKyZq4n/4K Mn5/94E6K7lwIIwN1pksJ0CYtXY1WxbLJb/q+dWAl7PSKVKrUTNdTiwjeYRyrFKWbwkcp5c 0/XnoR/f9ZXv0pqXJpzFdc/tSKSp1gGoq2Wz0asmJ+xrjOJc5RSmWo6Sdk6QjyRGusGP1xT Lkn1SWpHMw6VuKizz8WFA== UI-OutboundReport: notjunk:1;M01:P0:BR2qHyp3E/c=;NI08oJL0SbP0ewoX7/8CL2El9Ag 3vUgYu7F4JR74g8FYlw2UtNryVJYRkd/ibpFE8tYW7a8HqFaNfRsM7N/B2gxKKiiRwF/qi+l+ SD1i/w6FbhiLrCeEATQ1CTx46dSZCqeqVLUMfkMC6yFZMJ8jP+crZUTyEbcTzF6EZiv0dEJvp rwilVI9QZ6F1JEp0ynzqyJYCrs603fazmv040zols5jsR6QR00zlUC6jXhd5f7xmGEu5xkBYl 8UDvYcL6FSfu8T6I9krXHrUnsfkR4eT8ZG6VaiRv6tRw4X+0K7hAYJQebO6OCMR9Vn8GvBfxy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u6iMdZljcYhrJPHgNXIW+AUJwLBMIlb J23XIUEUxx0jnankptWPy8/XehcW+/vEZqnt3nt15JZeJJedvFMp7LDMstNerpE0rocfW98GF 6y306PzJrBouOp8m+fp9aGjpROrKlaHILpXpkKn9mZDuJVMq/mrQCgeR+wtxysAg9ijxjhnh2 Y+WaKf4Rz4nNbYeFSrEhkOuGboaR2o6TBibmd92Nvmtukwu+hSGB7c2Osfi/eg== From: thomas@nunninger.info (Thomas Nunninger) Hi, Am 04.08.25 um 17:23 schrieb Larry Garfield: > Hi folks. I recently wrote a blog post on behalf of the PHP Foundation about some work Gina has been doing regarding generics. It's a follow-up to last year's post on a similar topic. We are especially looking for feedback from the Internals crew, and voters in particular, on whether or not to proceed. > > https://thephp.foundation/blog/2025/08/05/compile-generics/ > > Wearing my Internals/voter hat, my stance is a very strong "yes please!" Thanks for that nice write-up and potentially great improvement. Can you please elaborate why it wouldn't be possible to create "empty extending classes" during compile-time of a file when there is a "`new` generic" found? Some example to make it clearer: Given a generic class ``` namespace SomeNamespace; use Some\Entity; abstract class MyGenericClass { // ... } ``` and given an entity ``` namespace MyEntities; use Some\Entity; class UserEntity extends Entity { // ... } ``` when using a "`new` generic" in some file ``` namespace OtherNamespace; use SomeNamespace\MyGenericClass; use MyEntities\UserEntity; $myGenericObject = new MyGenericClass; ``` and when compiling that file then the compiler creates an "empty extending class" on the fly if there is none available in the OpCache (from compiling some other file with the same "`new` generic") that has code equivalent to ``` namespace SomeNamespace; use MyEntities\UserEntity; class MyGenericClass extends MyGenericClass {} ``` That simply(TM) means, to allow `<` and `>` in class names but only internally to the engine and if generated by the compiler itself. Further question: Would it be possible to automatically mark a class as abstract if it is a generic class? Probably you have thought about this option and I just don't understand anything about internals of PHP. So don't hesitate to just answer very shortly. ;-) Best regards Thomas