Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127606 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 A9CC01A00BC for ; Thu, 5 Jun 2025 06:12:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1749103855; bh=zpk54VCON/qg8iwXjggoXUjxCnXTIWZ5UkgNqQifmmk=; h=From:Subject:Date:References:To:In-Reply-To:From; b=jk41ToaYddqdkXzv2RNbgS0bqDJiiWuOGZE6kPxSYN8HsRyBn+j1brbTtvpayi4jX G43T84kZufXoLyKizGPL4lIwv6ynnFH9LH23tvxlnKvVfR2JJpB0jLsHPreuAaJZfT YIWolKsI/foV/6uMkON4BRIjCWh16J9PWlefn25Sk4XY4IBNWvLBG5+ATsqM+EC1kY uuJd9+uALMt6SOnanhoY2hL/u/AGJRAiQ+YAvnLMTBUR4yCk/Nr/NRk0M1u+AfQnxz aaMiE0cxCWCcXSidBfd0Ze2UmdnP53gTbzLXPEL9QeYO213KNiutQ2vN6kCMrHv/7b 8i0t20eu2gA9Q== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 54473180042 for ; Thu, 5 Jun 2025 06:10:55 +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=3.9 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,HTML_MESSAGE, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from avril.gn2.hosting (avril.gn2.hosting [84.19.162.247]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 5 Jun 2025 06:10:55 +0000 (UTC) Received: from avril.gn2.hosting (localhost [127.0.0.1]) by avril.gn2.hosting (Postfix) with ESMTP id 913771C40C16 for ; Thu, 5 Jun 2025 08:12:57 +0200 (CEST) Received: from smtpclient.apple (unknown [113.210.105.166]) by avril.gn2.hosting (Postfix) with ESMTPSA id 628351C40840 for ; Thu, 5 Jun 2025 08:12:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nicksdot.dev; s=default; t=1749103977; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=bfwDULy1j94uNjvB9L3ADkB0Sq+5wI8kgKqzuEEd/ic=; b=14VfQ0HlMX1whv0wop07/3uHE7M8EGjASQsxC+m1pc+okPcGwO8IRiJt7zb+N02XiUmiua On9MN5FgOYYiOHDidq1qY/KPYMUAQq8zx3ILNhyvth3jMukqhDsicFia9N5epoFlDYl84s uIymCLCwrw9rUc7oxp5jBulf4lKbD9M/udE5b23ARraeWniteh3+VAohtTRpKPGssM69C9 0nJFVTp61oaKYmtL7+tHpUg4t/ir+3Ik3lwn6j46lE9ERMNGMYtCJCFjOg2mbDe29rvE8C zNVU7siMNqrM/lBGzpeJ/sOKSH48ahap6jzVIlJ4xVwu3wjTO+uP00F0fL8ltw== Authentication-Results: avril.gn2.hosting; auth=pass smtp.auth=php@nicksdot.dev smtp.mailfrom=php@nicksdot.dev Content-Type: multipart/alternative; boundary="Apple-Mail=_EDD0B6C4-5EF4-49D8-8034-D77445600D2D" 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 \(3826.600.51.1.1\)) Subject: Re: [PHP-DEV] Allow hooks in `readonly` promoted properties Date: Thu, 5 Jun 2025 14:12:42 +0800 References: To: internals@lists.php.net In-Reply-To: Message-ID: <3FBC491A-FE60-4583-A3A2-0A58EC384C88@nicksdot.dev> X-Mailer: Apple Mail (2.3826.600.51.1.1) X-Spamd-Bar: -- X-Spamd-Result: default: False [-2.60 / 15.00]; BAYES_HAM(-3.00)[100.00%]; MV_CASE(0.50)[]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; RCVD_COUNT_ZERO(0.00)[0]; NEURAL_HAM(-0.00)[-0.984]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; ASN(0.00)[asn:9534, ipnet:113.210.105.0/24, country:MY]; MID_RHS_MATCH_FROM(0.00)[]; FROM_HAS_DN(0.00)[]; DKIM_SIGNED(0.00)[nicksdot.dev:s=default]; FROM_EQ_ENVFROM(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; TO_DN_NONE(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; SURBL_MULTI_FAIL(0.00)[nicksdot.dev:server fail,smtpclient.apple:server fail] From: php@nicksdot.dev (Nick) --Apple-Mail=_EDD0B6C4-5EF4-49D8-8034-D77445600D2D Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Hey internals, > On 4. Jun 2025, at 20:19, Nick wrote: >> I believe at the moment that RFC text is all there is. :-) I don't = know that it's worth opening a discussion without at least a mostly-done = implementation. Also, Ilija is rather busy on other tasks at the = moment, as am I. (Unless someone else wants to jump in to implement it, = which would be fine.) >=20 > People often say =E2=80=9Cyou can just do things=E2=80=9D. So I did, = and tried to contribute the code for your existing RFC text: >=20 > https://github.com/php/php-src/pull/18757 Would this be expected to work? Can interface properties be declared = `readonly`? interface Cleaned { public readonly string $clean { get; } // has readonly } class Something implements Cleaned { public function __construct( public readonly string $clean { get =3D> trim($this->clean); } ) {} } $u =3D new Something(' Yoda '); var_dump($u->clean); In my current implementation it would throw: > Fatal error: Hooked virtual properties cannot be readonly in=20 I=E2=80=99d appreciate input here. Thanks in advance! Cheers, Nick --Apple-Mail=_EDD0B6C4-5EF4-49D8-8034-D77445600D2D Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 Hey = internals,

On 4. Jun 2025, at 20:19, Nick = <php@nicksdot.dev> wrote:
I believe at the moment that RFC text is all there is. :-) =  I don't know that it's worth opening a discussion without at least = a mostly-done implementation.  Also, Ilija is rather busy on other = tasks at the moment, as am I.  (Unless someone else wants to jump = in to implement it, which would be fine.)

People = often say =E2=80=9Cyou can just do things=E2=80=9D. So I did, and tried = to contribute the code for your existing RFC = text:

https://github.com/php/php-src/pull/18757
<= div>
Would this be expected to work? Can interface = properties be declared `readonly`?
interface Cleaned
{
public readonly string $clean { get; } // has = readonly
}

class = Something implements Cleaned
{
public function __construct(
public readonly string $clean {
get = =3D> trim($this->clean);
}
) = {}
}

$u =3D = new Something(' Yoda ');
var_dump($u->clean);
In my current = implementation it would throw:

Fatal error: Hooked virtual = properties cannot be readonly = in 

I=E2=80=99d appreciate input = here.
Thanks in = advance!

Cheers,
Nick



= --Apple-Mail=_EDD0B6C4-5EF4-49D8-8034-D77445600D2D--