Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112331 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 61594 invoked from network); 1 Dec 2020 16:19:48 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 1 Dec 2020 16:19:48 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 1F99D1804C6 for ; Tue, 1 Dec 2020 07:47:16 -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_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com [209.85.167.46]) (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 ; Tue, 1 Dec 2020 07:47:15 -0800 (PST) Received: by mail-lf1-f46.google.com with SMTP id t6so4996266lfl.13 for ; Tue, 01 Dec 2020 07:47:15 -0800 (PST) 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=TQ4J2wMQt3xsGIREc8mMYLu2wY4VzwTNnGLdAYwpoi0=; b=qCAQ2dDr6vOfNPr6KXmS2J2eDvOAOJ0Ddr8ErwWfnz5XJrMEEhesxa7p9nhgooVAh3 x7zTwwrFJ4IXNX3HkBkjzdNALbczWjdtMLD7zxQWa6cKnTid2rG6NQmzWV0eUu3jSiKY U+l9w8BYfNWQFQZdYpOMJzNlRmBY3CUW/bYHc0L9CgTSZmeyFsItb7Fv/ncDXCKCHs++ zKmR4xqMBVkk54WABAKrE4qjE9PeZ2hCHcJXFQsCEQfACA/qnljMdYN9xfaHpTpT0o29 2JscPgfSP9n4xZwRx82cw/cHRt2r+kZDSikVEv6pBPqvCOhH6YLNIIleWv3R+8s1oTbK 0fiQ== 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=TQ4J2wMQt3xsGIREc8mMYLu2wY4VzwTNnGLdAYwpoi0=; b=qqL8bmIVrjo/U3w0GB8/7pcc+axNDa2su9Zb+KC98/47LDgKoYtQHEdI5iR7++Wycl 32dE73lhHOqWi3b9YjBJMAtpdC8fXYbDCGfF7970q+clBNdX6Sipn3GpLLtT47x7/lpa RPKeAWSfGG2Bv6JiKhiewbmaTxojdkF1eBeKGE9PFHYskhwh/UWETR7RSX8+1szzh8Qb UMp12nzaxjjr0oh1M31max0gFezsvC9nlJcL64QK0lAdF7CBT+ZXCHhbljtAfxtn3NYQ hSIoczfMHcELxwaQCIcENLSztzbWhoXeB88c8Uponi84dQRaW+x++5766gFjQrM4np5u JHTQ== X-Gm-Message-State: AOAM530xda+L1qKBJ/0CpJmXoVYweSZkukcjwRIjup5ShYtglFEIE/m2 eCB6nGNyT9jKE7OSZnJu0beCnC/JzudLe5ZC2Lk= X-Google-Smtp-Source: ABdhPJw/U97Jqjs3LUUbSmFHn+7eSLep1AJ58yQdp7OLia9n1WZ/TjnWuBH2NPgzpuZ3sjvtvV3yXZv2u7tJlR7xYjg= X-Received: by 2002:ac2:50d2:: with SMTP id h18mr1390356lfm.169.1606837633474; Tue, 01 Dec 2020 07:47:13 -0800 (PST) MIME-Version: 1.0 References: <0d07a6b09358fd2047eec9874214a297097f398762c1ca784b62ecef2eca35bc@mahalux.com> In-Reply-To: <0d07a6b09358fd2047eec9874214a297097f398762c1ca784b62ecef2eca35bc@mahalux.com> Date: Tue, 1 Dec 2020 16:46:57 +0100 Message-ID: To: =?UTF-8?B?TWljaGFlbCBWb8WZw63FoWVrIC0gxIxWVVQgRkVM?= Cc: PHP internals Content-Type: multipart/alternative; boundary="0000000000005ae37a05b5690a24" Subject: Re: [PHP-DEV] DateTimeInterface interface stub has no modify method From: nikita.ppv@gmail.com (Nikita Popov) --0000000000005ae37a05b5690a24 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Dec 1, 2020 at 4:35 PM Michael Vo=C5=99=C3=AD=C5=A1ek - =C4=8CVUT F= EL < vorismi3@fel.cvut.cz> wrote: > Intentionally? > > It is an issue for static analysers... > > With kind regards / Mit freundlichen Gr=C3=BC=C3=9Fen / S p=C5=99=C3=A1te= lsk=C3=BDm pozdravem, > > Michael Vo=C5=99=C3=AD=C5=A1ek > =C4=8CVUT FEL Yes, this is intentional. The DateTimeInterface interface (has absolutely nothing to do with stubs -- this is the same in PHP 7) only includes the methods that are present in both DateTime and DateTimeImmuatable **with the same behavior**. DateTime::modify() and DateTimeImmutable::modify(), while having the same signature, do completely different things. One performs an in-place modification, while the other doesn't. You should be doing one of two things: 1. Only accept DateTimeImmutable. 2. Accept DateTimeInterface and then use DateTimeImmutable::createFromInterface() to convert it into a DateTimeImmutable. Working on a plain DateTimeInterface only makes sense if you are using the read-only methods, which are the ones that are part of the DateTimeInterface interface. Regards, Nikita --0000000000005ae37a05b5690a24--