Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:121449 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 41295 invoked from network); 23 Oct 2023 16:12:10 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 23 Oct 2023 16:12:10 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 347BE18050B for ; Mon, 23 Oct 2023 09:12:10 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS9370 160.16.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail.sakiot.com (mail.sakiot.com [160.16.227.216]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 23 Oct 2023 09:12:09 -0700 (PDT) Received: from smtpclient.apple (111.198.214.202.rev.vmobile.jp [202.214.198.111]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by mail.sakiot.com (Postfix) with ESMTPSA id 6BF2F401E7; Tue, 24 Oct 2023 01:12:07 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=sakiot.com; s=default; t=1698077527; bh=M9HZJXUGluxprFbv8+54luFsVG+FJJtHa1NuSAvFzOI=; h=From:Subject:Date:References:Cc:In-Reply-To:To:From; b=RV54ncHielBio51z8ukbIQ29yYznUUCuAtYBnE4Oi3hkNCNGC3o4DoUG9N6IJO+gH vRPtcD2B6oZdGkEKvDUdv6oNiovYWv0PCLcSqKOhA5A5SGXu+uJVYIVaf433CulOoM lnQmnJL5PF1uApzlkOztnVuBlVVjt1DFuloMdEOM= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (1.0) Date: Tue, 24 Oct 2023 01:11:54 +0900 Message-ID: <9261C231-B3D2-42D8-8762-45126AF19031@sakiot.com> References: <8835c45d-fb4d-4701-ae5c-aa0d956cdb8b@processus.org> Cc: PHP internals In-Reply-To: <8835c45d-fb4d-4701-ae5c-aa0d956cdb8b@processus.org> To: Pierre X-Mailer: iPhone Mail (21A360) Subject: Re: [PHP-DEV] Constructor promoted property and default value From: saki@sakiot.com (Saki Takamachi) > If I understand your use case properly, you should be confused by properti= es with default values that are not constructor-promoted as well ? Am I wron= g ? In this case, your problem is not with promoted properties ? If we specify it the way you say, the initial values =E2=80=8B=E2=80=8Bof th= e constructor arguments will be available even when the constructor is not c= alled. ``` class Foo { public function __construct() { } } $foo =3D serialize(new Foo());=20 // save to redis ---- update ---- class Foo { public function __construct( public $val =3D 'abc' ) { } } $foo =3D unserialize($redis_foo); var_dump($foo->val); // string(3) "abc" // Doesn't it look like the constructor is being called? ``` Such behavior felt a little counterintuitive. Regards. Saki