Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:119226 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 48982 invoked from network); 3 Jan 2023 17:08:19 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 3 Jan 2023 17:08:19 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 51F30180503 for ; Tue, 3 Jan 2023 09:08:19 -0800 (PST) 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_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) (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 ; Tue, 3 Jan 2023 09:08:15 -0800 (PST) Received: by mail-pj1-f53.google.com with SMTP id fz16-20020a17090b025000b002269d6c2d83so1495168pjb.0 for ; Tue, 03 Jan 2023 09:08:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=6/EzQDXfCoCa+uk7xkFQaDNebPxdS6l3N7ndmyy2csM=; b=hBr2acMDRxBGFpEm25qDC+iyeE47JPN/aChe8HM97KDdb/v3YC9GGBt9BTiQHr7N2s SYGQewz7/U84hGDhMjsOSKZ1jlnH/CiF6udT7nvze2bLhdea8zEf1sQLuKNGODtTvZnj shZNV7PSC9e7rkfcSxWv02zbQtFc2B7MN4RUikpTwGrcu5IGhiNmLdw78mp5NBEyJSEZ 2fW0MNyJLZjThm+ZjcJ4a6F6vtUbsKRd/2GdLQBwrlRiJ5DpbBLy1kDzHkmscWF/c8b2 /VIYGDoO7iKNZCo4pqMSdFN/4meC4rYhHGigL+GjvXapX6MNDU7XQm+rR8FMwJs+3sC0 ifHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=6/EzQDXfCoCa+uk7xkFQaDNebPxdS6l3N7ndmyy2csM=; b=zPWUp4Hz9grPG8SC+ExANKICgeZkAeyrFFGIMBPmvVL4xVa71FDjhmCCYIAk7j0Kkt oQzrvP1OkcQr664VcFT7GSXiAFn/cSzbbktyThYFMY9lLrC3Bzvb7KWqKmzCGpVegsiX vbadFBoqlpVKLryK6kwdKf6kfc0yYwQZYbYCLoPvW6zd5Ito0X3JZunvpUQprJMGt6HX a4178jGHeeuPwr2JkYMY7FQBawDEHXY/u/R/AdV426xfwt/lkP4haVP/aqP8hbbMl+Q6 ExxURTeQx47296PSS56WByuQozHPFNe8l8e08yFWLONKIUO2qSgFjtqDftgT7pEzrweo 4Urg== X-Gm-Message-State: AFqh2kr2W4t4Fwc6fPUIIPlYM+uhiC3VWK0B4n9UPRbPNRYGmdK2kcYd Q2BjIFlX6DIGrndaxsrFs7nf5oOxzqw0W7Z7+k4= X-Google-Smtp-Source: AMrXdXsM99ikSRWlW+IYp1w7FAJsolzrHTntaFgEzFdamFUOEk0CTc7tQTZ3mho9xAShVAjzlqwREpopdSVH+oZbr+s= X-Received: by 2002:a17:903:25cf:b0:192:9a42:b820 with SMTP id jc15-20020a17090325cf00b001929a42b820mr1126438plb.70.1672765694721; Tue, 03 Jan 2023 09:08:14 -0800 (PST) MIME-Version: 1.0 References: <42306d40-5e47-b571-5898-6d7739302ab3@gmx.de> In-Reply-To: <42306d40-5e47-b571-5898-6d7739302ab3@gmx.de> Date: Tue, 3 Jan 2023 19:08:01 +0200 Message-ID: To: "Christoph M. Becker" Cc: Philip Hofstetter , PHP internals Content-Type: multipart/alternative; boundary="00000000000006c5f305f15f1d4b" Subject: Re: [PHP-DEV] Re: DateTimeImmutable::modify() return type: doc or language bug? From: drealecs@gmail.com (=?UTF-8?Q?Alexandru_P=C4=83tr=C4=83nescu?=) --00000000000006c5f305f15f1d4b Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Jan 3, 2023, 17:44 Christoph M. Becker wrote: > On 03.01.2023 at 10:48, Philip Hofstetter wrote: > > > `DateTimeImmutable::modify()` is documented as returning > > `DateTimeImmutable`, but it seems to actually be more specifically > > returning `static`: > > > > https://3v4l.org/j9ZSo > > > > Now I'm wondering whether this is a documentation issue (where it > > should return `static|false` and has not been updated to account for > > that return type's availability yet) or whether this is a language > > issue and the method is supposed to be returning `DateTimeImmutable` > > instead, though that's probably a considerable BC break. > > It is not recommendable to extend DateTime(Immutable); these classes > have not been designed for that; for instance (and that may actually be > the only issue), __construct() is not called (). > But interestingly __clone() is called: https://3v4l.org/A7Gd2 I agree that extending should not be the way to go. However, there are some well known libraries that do it, like Carbon. Of course, we cannot easily make them final, but I don't think we > should encourage users to subclass by documenting return types as static > =E2=80=93 besides that the current return type is not wrong (it's just no= t as > specific as it could be). > > > If you agree that it's a doc bug, I'll submit a PR. > > As of PHP 8.0.0, the single-source-of-truth regarding the signatures are > the stub files[1]. The signatures in the PHP manual can be > automatically generated from these. Therefore the stubs would need to > be changed (first). > > [1] > > > -- > Christoph M. Becker > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php > > --00000000000006c5f305f15f1d4b--