Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128410 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 4F1D61A00BC for ; Wed, 6 Aug 2025 20:23:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1754511703; bh=mZNFBT9vu/rLC4bDdlT4QdSBZXEefidYMET9lFg+BeQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IjEy0L7sucp9UvvcbUfiYU8OxIPLbEuRwihhrN9t6HguHMnREMoyLFWxE0Wu+p3EU pD2lWFJgCZEPUbAXlTz7cyFGCiGIhSZuPSfNgZMvF/en59On1Md+vh6lcs4N8VHHhv H1cv3MJaiDyXMx5HcgCl+j4Sm+RizqD2FYBqsiczjVpC0AoF1ZclfJhRFsuFyoqgVk 9ekoKRFFXVo9hXy/xVhkPJm6SXLI5DkHlyEDxs4Jsd9qMwaqMmqeknixod5WlA33Z5 pUz7a3K7qgtXckUlINNH2UKF7BdE7YR/Ho9aVOgZpmFfDDLf42Q7DicnRI8cST70Qx JqLqB5IQbE0ig== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id F380C1801DF for ; Wed, 6 Aug 2025 20:21:41 +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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from sonic.asd.mail.yahoo.com (sonic310-11.consmr.mail.ir2.yahoo.com [77.238.177.32]) (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, 6 Aug 2025 20:21:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.de; s=s2048; t=1754511798; bh=XyYNNaQFt+6pfi7XStzc/CtqJCtsVMrj+pj/88lTXMY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject:Reply-To; b=Bhoze49xcEobdcM8RfDC/bzH87U1XyNXoVvOTgKNK3w5i7o9abgNgbZ1DoYrD623Yq2cproV0gl1NGGe491Ec15/w46d9j3mJg3IbRHHneDZvOkwjH2O72b+zftizRON8pHH6jrpsWOPq0Bl7C2Re2PcBUMIGSEt+5m4+id1Abm9rd82H8fD8X2kL2taiQTWNL7++uPXO8mi6g72yLgwgv+e2PrdSPCvdxdu0hJzofGNxNaZoRbFWfxj/4Rj+TV7vlHcdbXsgCbwnRgPTQyBZTatPQaVDch30s0HZxbpYCejpwb1i/M9ImH+ScfZX+kICZql0RFncSbWJKy5soxYpA== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1754511798; bh=BYcMIBPKhzBus13jw4+FSTTYfA9n3YSezj6E4qqQqPY=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=lI+nqR7P98RQ+H0njSy0/JH7uok4Irvo/0UYJ0902gznP5Y2MmbkVNgqAQfqM2Sk35NlCFFaXmzGcAcjIfB2PMXRrnb9ckALz7lLpLqn/gcOoacU1JKd3TqwKQpxc7SfTP+Do7AoqGIOWnAxfEhSerUt4+MJMTK4DAT4OrBgTtcjQWfV+pnfS1r72B6oZYfcb7BKgVoRYRpHUWM/onwFebLi/la9ebsFAUto/h9bSIS2/+47MPsze4iuC5vtMjDHV8jCTgpitsjezd+TrOuql53IEVAc90YVkNi+JfYBu7N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RgeDzSJBBCvd8BKpASupUjlpUi1acH LcplqX9FW1f2EXUm_sx9pB9QyoQu6FPUShyjMu5fiViyJ9Q6Rvsy.wo1AcoKrHn5vqiq225gD8od Zd8GjimPBKHH80Pan1uxWRUG6OTp.9gF9DrxN9iYtJT6b2xVoWPbuSya04XYldIRNOfLGPQwgkgc ysz6pEJMYHkgUa_LRWQi95GybsDdMllFbeNq_5Bfl7EKwTLhE8SYZfh_P7Oh9_sZgTA-- X-Sonic-MF: X-Sonic-ID: 1c413d23-562e-4bf8-957f-94ca970518ce Received: from sonic.gate.mail.ne1.yahoo.com by sonic310.consmr.mail.ir2.yahoo.com with HTTP; Wed, 6 Aug 2025 20:23:18 +0000 Received: by hermes--production-ir2-858bd4ff7b-8tkvv (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID d966466199fa8c1c73bd08cfd51ef9d6; Wed, 06 Aug 2025 20:23:14 +0000 (UTC) Content-Type: text/plain; charset=utf-8 Message-ID: <1754498915586.19744080.519808276@yahoo.de> To: alex.daubois+php@gmail.com Cc: PHP internals list Subject: Re: [PHP-DEV] [DISCUSSION] Deprecating userland creation and cloning of __PHP_Incomplete_Class Date: Wed, 06 Aug 2025 20:23:14 +0000 In-Reply-To: References: X-Mailer: Vivaldi Mail User-Agent: Vivaldi Mail/7.5.3735.58 Content-Transfer-Encoding: quoted-printable Precedence: list list-help: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 From: hanskrentel@yahoo.de (Hans Krentel) On Wednesday 06 August 2025 10:32:34 (+02:00), Alexandre Daubois wrote: > Hello Internals, >=20 > I would like to gather feedback on the proposal to deprecate userland > creation and cloning of __PHP_Incomplete_Class objects. >=20 > Here are the reasons I believe this deprecation would be beneficial: >=20 > - __PHP_Incomplete_Class is intended to be an internal mechanism for > handling incomplete object unserialization, not for direct userland > manipulation; This is probably a misunderstanding/inaccuracy: Not __PHP_Incomplete_Class = is an (intended or otherwise) mechanism. It is a class (thin by definition)= that is used as collaborator in that (globally accessible) mechanism. The class name is reserved for PHP, because it starts with two underscore = characters. The class is final (PHP 8): $ php --rc __PHP_Incomplete_Class=20 Class [ final class __PHP_Incomplete_Class ] { - Constants [0] { } - Static properties [0] { } - Static methods [0] { } - Properties [0] { } - Methods [0] { } } Additionally I would say, that it is total for manipulation, as the problem= is that the original class was not found (a time of deserialization), and = the user needs to be able to deal with that, therefore it is in use for = manipulation, and then it is in itself a manipulation (in the reviver while= deserializing, used as a stand-in; my understanding.) > - This change would align with PHP's general direction of preventing > misuse of internal classes; Would you please be so kind and give 2-3 examples of misuse of that = internal class and 2-3 of that with other internal classes for visibility? I have to admit, I live under the boring imagination that classes are being= used, and it does not fuel my fantasy enough how classes could be misused.= > - Classes like Generator already prevent userland instantiation, > making this change consistent with existing patterns; This is probably a misunderstanding/inaccuracy: The behaviour of the = Generator class that you describe is not because it is an internal class or= follows a pattern, but its runtime properties require that. Instantiation = remains public from user land, by writing a function that has the yield = keyword in it's body (before, after or without the return statement) and = invoking it. Otherwise a Generator would not work. For comparison: __PHP_Incomplete_Class is just a class that is occasionally= used by PHP deserialization. There is absolutely no problem with language = parity in allowing this class, and I don't see why __PHP_Incomplete_Class = should require special treatment (e.g., at runtime). If there had been a problem with it, I believe it would have been fixed in = good faith. Unfortunately, I don't see any specific changes in your = proposal to verify this. > - No added-value on using this class in userland, stdClass does > already the job if one wants to manipulate "incomplete" classes. I'm not exactly the most creative person on the boat at this time of day, = but writing a PHP library that deserializes and can't find the class name = to mimic the behavior expected by PHP is, in my opinion, not =E2=80=9Cno = added value,=E2=80=9D but a preliminary assessment of the code, the use of = the language, and its interfaces by someone else. > Having stdClass and __PHP_Incomplete_Class could be misleading; Please explain by example. > - Prior to PHP 7.2, is_object() on such object returned false, showing > how this is some kind of special case. Perhaps this is not relevant at all, but I'd shared the reference to the = tracker of that. This would have allowed me to see what this "some kind of special case" = actually is/was. It looks like a bug to me that was fixed in 7.2, maybe = some cleanup in Zend. >=20 > The proposed deprecation would affect: >=20 > - Direct instantiation: `new __PHP_Incomplete_Class()` Why should instantiating with the new keyword not be allowed any longer? = What is the alternative suggestion and what is its benefit? > - Cloning operations: `clone $incompleteClassInstance` Why should cloning not be allowed any longer? What should I do instead of = cloning, e.g. when I need to deep clone an unserialized object tree that = contains it? >=20 > Regarding the impact this would have, a search for =E2=80=9Cnew > __PHP_Incomplete_Class=E2=80=9D on GitHub seems to show that it is mostly= used > in Rector rules targeting PHP 7.2. It therefore seems to me to be > minimal and worthwhile from the point of view of the robustness of the > language. How would your proposed changes make the language more robust? Which robustness principles do you see currently being violated and how = does your suggestion restore or lift them? > Adding "language: PHP" shows even less results, apart from > test files from php-src. >=20 > If this proposal receives interest, I would be happy to implement the > deprecation warnings in the engine and prepare an RFC if required. > Unless the change is actually uncontroversial? It seems to me, but I'm > looking forward to your thoughts and feedback. > > Best, > Alexandre Daubois >=20 Comments/asks -- hakre