Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115762 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 29747 invoked from network); 18 Aug 2021 11:56:26 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 18 Aug 2021 11:56:26 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 639701804B4 for ; Wed, 18 Aug 2021 05:28:52 -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,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-lj1-f173.google.com (mail-lj1-f173.google.com [209.85.208.173]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 18 Aug 2021 05:28:52 -0700 (PDT) Received: by mail-lj1-f173.google.com with SMTP id s3so4750611ljp.11 for ; Wed, 18 Aug 2021 05:28:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=mT5yfrF2GpHOZFJs3+I+sOYF6GurJ/wooluWEGGuZHE=; b=WAqRKfKnbcJBAMhs0sHdzAThUeBwcEgE8+M4el9n03eQ7Lfeu+Mv8IsOL+K/evDT4/ ibXTXDfXO1mr+62+ewD0i94k2HV49WjMJ9knxEQELzkLQs6I4fI8zZLn8uiiSQA0oISU kfiICNenmvrlta2rPWZfg4BJS3Br+tER0Nia7ZLAlgA4TBWT2gZWygi6zP3xf+RnAem/ jdeXiJDll6XwVRFZO4R4y2yLJDeWMOa19LndcjBHybZcF1pGrEP7aWGoVDCmTZqjnmys TvHDihWHawvgNWsOptjaEPY+/cqlQeLFYZfPhHrrWRUggcW3K1cZyEOkGYHEJASrGny/ Kwtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=mT5yfrF2GpHOZFJs3+I+sOYF6GurJ/wooluWEGGuZHE=; b=H3RKpQW190mh93VytYjqffAQ/I9IeaD+cKOfkIWn38kAtLTugCwBGMrxd/r63dZvBv YMap6SJ76o6GsAFMpJDc/1qpe8lbzAPp8AKLiYyR0ovrYhWHbWVImLdoZkYH+IZ2fQQc 5c41AelP9S4ytWe+jP1J83edn4JiDWXV+ZdBei8w+FW+7HO5X4tluCIeBFAYjg77nPC/ R8laO8dSUvJxQF9ASk4HDnUaRRqiesY7gyVHxPFZZM95HdzA/+sJgsSCZEilcS7cSdp6 cuky8lcZe4ZTQzBBb839ypHHlqLjPe/nnyG6Gf4VziBNw0RKvfUd3SLF77Q5LVEXqjZc yRYA== X-Gm-Message-State: AOAM531WwAf0uVYmMPoR5S3Gifp8mZlaa/tqdCVtpo3duHO504KvaYGT zsYUbjWz1bacLNAqCwL8EZ7oQhSkz/E+el/BMA== X-Google-Smtp-Source: ABdhPJzbk4JvAcI+2QKNjBl8R2638iRgd+WnIkj/7Hj7mlwtqcStT03ka+fp/S46W0TNAlWNEwYKX0LiQ7EEjnN8CRo= X-Received: by 2002:a2e:8808:: with SMTP id x8mr7926240ljh.220.1629289725775; Wed, 18 Aug 2021 05:28:45 -0700 (PDT) MIME-Version: 1.0 References: <42b262eb-0d9b-8feb-cc3d-da3e36e14d1e@mabe.berlin> <5f05e230-4f19-aa5b-73c4-78dd52e95764@mabe.berlin> In-Reply-To: <5f05e230-4f19-aa5b-73c4-78dd52e95764@mabe.berlin> Date: Wed, 18 Aug 2021 14:28:35 +0200 Message-ID: To: Marc Cc: Nikita Popov , internals@lists.php.net Content-Type: multipart/alternative; boundary="00000000000057531c05c9d493b9" Subject: Re: [PHP-DEV] readonly properties From: guilliam.xavier@gmail.com (Guilliam Xavier) --00000000000057531c05c9d493b9 Content-Type: text/plain; charset="UTF-8" > > >> 2. DateInterval->days > >> > >> $interval = (new DateTime())->diff(new DateTime()); > >> var_dump($interval->days); // 0 > >> $refl = (new ReflectionObject($interval))->getProperty('days'); > >> var_dump($refl->isReadOnly()); // false > >> var_dump($refl->isPublic()); // true > >> $interval->days = 2; > >> var_dump($interval->days); // 0 > >> > > The DateInterval properties are currently implemented as getters/setters > on > > some internal state. Some of those are getter-only, but probably not > fully > > immutable. > > I was referring to the property "days" only as this is a non writable > value generated on "DateTime->diff". > > As you can see in the snipped it doesn't allow to modify days but it > also doesn't fail which seems wrong to me. > > I don't have much knowledge about internals but would it be possible to > define "public readonly int|false $days" not using getters/setters and > keep all other properties as it? > Hi, FWIW, I too agree that [$interval->days, $interval->days = 2, $interval->days] giving [0, 2, 0] without any warning (or https://3v4l.org/h8Cju for a variation) seems wrong. Regards, -- Guilliam Xavier --00000000000057531c05c9d493b9--