Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122855 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 qa.php.net (Postfix) with ESMTPS id F1CA91A009C for ; Tue, 2 Apr 2024 13:14:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1712063713; bh=/SEzBDrFd3ofWacI9wyBOSQ/8W8bkvN+XnpEkYOtQFQ=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=Yxzna4HSnrIM9vVk4FLXWQ4mKHvnBhNtr3wWREH9d/0kxAjUV5fOdmvWzvWFffjdy UFRKgiXLFdbdrgiVUDiaN1RbzbC3Lz4xOAqPtcXiBG5t3HEaGwCMLc5b6fHPAAkvnh D+8caCQx64S6ll+kGHTw3dY/JSekXUPh/UO6PN2Y/iR9cUMirwBh5GJ44QSrIpz33i TSmz21c/PGVsZoECvxPG5kVGfJ8LmADDFz06oJyip8hqwqKvEd89HV0iLUfnmZn8vz nVbtUJ/NkxkxkspyEX3DLgVwmFmalSDGTJNvVBsQLGGd/MeDW458LrK0F7DK1zMJmI 63tuU5KT1Jecg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 33745180074 for ; Tue, 2 Apr 2024 13:15:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: *** X-Spam-Status: No, score=3.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,SPF_HELO_PASS, SPF_SOFTFAIL,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from xdebug.org (xdebug.org [82.113.146.227]) by php-smtp4.php.net (Postfix) with ESMTP for ; Tue, 2 Apr 2024 13:15:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1712063683; bh=/SEzBDrFd3ofWacI9wyBOSQ/8W8bkvN+XnpEkYOtQFQ=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=VUxt41UtniS/pPir9g4OifLL7QJt/AeakOpgSlRjElJ6P6RZLEp5RtzsI6O9hG49N Jkk12ls3hIYA1JtqMQr9EwOrQnRuMpOr2chBQGjdyP5305dyo7OSrEBZwqsK3O9As9 j9hlefZ3nCCeyH657mBAGe3LNFLvKBHJO4Iu4m0bH+UMGEtPbAmft3rtfTxWHy4/GU wJpuCz2JOCia7T6MwxF6N/DSGR54958LFUIXTNqwjJxEBvaq+dUI437W6tu0llmhIR KOHVDD0GqylvpEcsahytyFljwSgKLyvg6+mO6nxUkODC0V3DBjlGkrvQU3odui32fd f1YMIBIbpbB9Q== Received: from localhost (localhost [IPv6:::1]) by xdebug.org (Postfix) with ESMTPS id 8218A10C0D2; Tue, 02 Apr 2024 14:14:43 +0100 (BST) Date: Tue, 2 Apr 2024 14:14:43 +0100 (BST) To: Bilge cc: internals@lists.php.net Subject: Re: [PHP-DEV] First time contributor (DateTime::setDate PR) In-Reply-To: <31f7de10-a2dd-489e-bc2f-66987dc832aa@scriptfusion.com> Message-ID: References: <31f7de10-a2dd-489e-bc2f-66987dc832aa@scriptfusion.com> Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII From: derick@php.net (Derick Rethans) Hi, On Sun, 31 Mar 2024, Bilge wrote: > About the PR: I sometimes find it would be useful to only update part of the > date. The PR makes all parameters to DateTime(Immutable)::setDate > optional in a > backwards-compatible manner such that we can elect to update only the day, > month, year or any combination of the three (thanks, in part, to named > parameters). Without this modification, we must always specify all of the day, > month and year parameters to change the date. As I mentioned to you in Room 11, I am not in favour of adhoc API changes to Date/Time classes. It has now been nearly 18 years since they were originally introduced, and they indeed could do with an overhaul. I have been colllecting ideas in https://docs.google.com/document/d/1pxPSRbfATKE4TFWw72K3p7ir-02YQbTf3S3SIxOKWsk/edit#heading=h.2jol7kfhmijb Having different/better modifiers would also be a good thing to talk about, albeit perhaps on the four mentioned new classes, instead of adding them to the already existing DateTime and DateTimeImmutable classes. In any case, just allowing setDate to be able to just modify the month is going to introduce confusion, as this will be counter intuitive: $dt = new DateTimeImmutable("2024-03-31"); $newDt = $dt->setDate( month: 2 ); It is now representing 2024-03-02. This might be the right answer, but it might also be that the developer just cared about the month part (and not the day-of-month), in which case this is a WTF moment. Picking mofication APIs is not as trivial as it seems, and I would like to do it *right*. Feel free to add comments and wishes to the google doc document. In the near future, I will be writing up an RFC from this. cheers, Derick -- https://derickrethans.nl | https://xdebug.org | https://dram.io Author of Xdebug. Like it? Consider supporting me: https://xdebug.org/support mastodon: @derickr@phpc.social @xdebug@phpc.social