Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128577 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 lists.php.net (Postfix) with ESMTPS id E48C31A00BC for ; Thu, 28 Aug 2025 06:35:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1756362827; bh=GtGvD9F9fxuDfdqXAghee8v15Sin2BT/rMum9nWDzfU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fZd9cQIupZawROJ8bStuhRWX6fdLe6GOoWGhZ4phN84+rY4b9E1pMHbW3XwFtRjis cb3nTEg9aI6roccNMGZzPyN3Ukwe/oiVsVcXQzaOFCmJzMYxNOjhbsXLPn/CB8SX4q 7HO1TyeSDukVyA4jYA1cg9e7nAOOQl62vRryZqecQAH9RmPDT7rrXDsa1f3F6jyB6P HmlZV3+LEAHCF1BeSPxTE+sXlq6gLRQL0Ae7+VGPM67mppD5j68hY/F6A7fRJF3m0d LnJpvNJY7+U1RcNL00zh4CtnnH/7ef4TKg8Hz+L8CzLZVa0KPEzK2BpUshp/1pL60K eZgS72G+UIZTg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 3C20D18007E for ; Thu, 28 Aug 2025 06:33:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.2 required=5.0 tests=BAYES_40,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from sonic310-57.consmr.mail.ir2.yahoo.com (sonic310-57.consmr.mail.ir2.yahoo.com [77.238.177.30]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 28 Aug 2025 06:33:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.de; s=s2048; t=1756362916; bh=wuRr2Lm9FLBg4Xo6wpojJB3k8u5QU1//2P6fG14QTzo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject:Reply-To; b=iJUgJwCSHtYYsxNHIHnAPaDTH+yp5jctsbp38wWy3IvLdEjpnmWrWlgM/mHPY6NVBn9fZiGWxXVWujgZ7YCdyClCKs2Fh03CR1xwZSoOQA2MlJXhE1GBVuPicXk/d2DURdBMwJ6nxzU60MuuJikmU3W5xnTJiFp5a06Aw76Ss2coSGceTxTrWr9SqhITTQ/tAd9Mkm0pD9oA//gSswsTRFFEXFa+QejQm884xS6nfel4fg0CqlhKFZP36rLcZJnbsH0pCwQbDkIr1dQ16Md0cqoWsaetXaCrjT0HDPEnOmjI6umtYoqMu/sDlRHSwflOe3Aeoz1sgkwzMWhpwudyRw== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1756362916; bh=FomtoHkKIRE5cY177uCGjMJih5secRHj++SfIVE0XwI=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=ai+VUO6CcwxmV4npWMw29tPLk5tVhImjHkkTJJ06sGEiFoe9+Q0EZsGl1lhAgf5gV+Q6E7TzqTQDYa5CcqdqrR7/hdlMaZ6sz4DO9UL0v4H118AJR14z6+R/HhSHlVlSlGQlNFrw+zrAnJLCZMDgKSMvylJERddIe013tLSokjQTbISwOvYNPzcHaObzIhZmBa7+TDjTto/CFIdHRJ0iNJcjOC644uwF1bOsZ0lcjUgezij9QoxaVPuuGU436V8T0l4IjK/WDOA8HHI9OxCb/G4T9VSjZ1uumq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iucEGezeM81z RDwmQbE_XLQnf74hUvF53h9QcTyGQsdqmEjvZ1O_7_F.ZXLEWWvfZkIGys22woaZCIckJDy0D6hd B5P6z0yFB9KIWWf7GoUOi448SAfGQcuFKcdZkujosDg7nrJpg1rr_FSNJbm4oLicuFAQt2BuqnM4 k5rMwEf0qFE0CujjvSuIaVqP..O1WzKTlL7hCp2AVPmMPd2adp.rtfWA6PdOPIp3yQvz7nac- X-Sonic-MF: X-Sonic-ID: d099e13f-8027-492a-8959-118b45e8f245 Received: from sonic.gate.mail.ne1.yahoo.com by sonic310.consmr.mail.ir2.yahoo.com with HTTP; Thu, 28 Aug 2025 06:35:16 +0000 Received: by hermes--production-ir2-7d8c9489f-8n4zw (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID f15fba2abb8c0305948d1817accd465b; Thu, 28 Aug 2025 06:35:10 +0000 (UTC) Content-Type: text/plain; charset=utf-8; format=flowed Message-ID: <1756361767126.3727989781.4204927711@yahoo.de> To: ocramius@gmail.com, Kyle Katarn Cc: PHP Internals Subject: Re: [PHP-DEV] [RFC] [Discussion] Add clamp function Date: Thu, 28 Aug 2025 06:35:08 +0000 In-Reply-To: References: X-Mailer: Vivaldi Mail User-Agent: Vivaldi Mail/7.5.3735.64 Content-Transfer-Encoding: 7bit Precedence: list list-help: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 From: hanskrentel@yahoo.de (Hans Krentel) On Wednesday 27 August 2025 17:45:59 (+02:00), Marco Pivetta wrote: > I know this isn't very used in internals, but does it make sense to write > generics for the generated stubs of this function? > [...] > /** > * @template T > * @param T $value > * @param T $min > * @param T $max > * @return T > */ > function clamp (mixed $value, mixed $min, mixed $max): mixed { +1 This is an excellent suggestion. Using a template ensures type safety and clearly communicates the intended relationship between the arguments and return value, which is a significant improvement. This also highlights a minor but important clarification for the documentation. To make the behavior perfectly unambiguous, I suggest a small edit to explicitly state the bounds are inclusive. Current text: > `clamp` takes three arguments, a `$value`, `$min` and `$max`, then > checks if `$value` is within the bounds of `$min` and `$max`. Suggested edit: > `clamp` takes three arguments, a `$value`, `$min` and `$max`, then > checks if `$value` is within the bounds of `$min` and `$max` (both > inclusive). This is a minimal change that adds crucial clarity already in the first sentence. --hakre