Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126212 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 01FB31A00BD for ; Thu, 16 Jan 2025 13:44:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1737034918; bh=MOrQ+vHw2+a1gGwUyDAG7YKOykbuazEuSdL2JN87mew=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=Uwqncf7Sg4528Hi5i1ItndT8Kk9qRsNZLIIa9pcby26WjoMzMSGoyfp4bwedDBl6c NBJ9t6W56y/rk70M13xQTlsWoS/GVEf2Llr9Tk+RMFQGimkondEPfO74D8ubWFOElU sgSzkH9zGbAj8tu8UwonX8fnbUkXc5Np+HhQfSvYZEjB41a5qE+rHDkcplzUA+m79r cGRluXuj8Ccws/QNo+s/+oiVtWaUR3xhr/pTgHYwZdsTuEL8IlW8r0ILq0KDn/uSVu JagwZs8glnoiiGm6kckc9NJjfSVvTW0aSrPge1hMnsms7AcPp15Jh3ROoR5AbPTJqY 3HPCnJjuB8bMQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 546CA180082 for ; Thu, 16 Jan 2025 13:41:58 +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=0.2 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS, FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 16 Jan 2025 13:41:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1737035088; x=1737639888; i=cmbecker69@gmx.de; bh=/qCoVMpf6J9g+f0bKf5Qxrdl7Wfm9QJDhPpaCfapVT8=; h=X-UI-Sender-Class:Message-ID:Date:MIME-Version:Subject:To:Cc: References:From:In-Reply-To:Content-Type: Content-Transfer-Encoding:cc:content-transfer-encoding: content-type:date:from:message-id:mime-version:reply-to:subject: to; b=sBYCUJhjNt0S5CTGx8g1tR9n48GQjKQnu5dR7sMS5tVLOFiXugoMTPkE0XvaovWS DtClhPWRoBzVclKyOytXrmQO9GOZP11+E5aa6P2c/CP08VSZWUnZZaoHqEHXu8Sgj oyiEur9T80ti4qshKReep56tdH/Paio+DuDD7kpd+SK4tG8q4O/on8SLTtr3GKW5k lEp8o0LsiuUP3rFPTb70py54OdNMi46mlWMWj8yuURt2Q6X1fRffmb2xiIoEZzSwZ jCbdeceSP3Ub/tyzPbbqSwYUvXZM18QnsFCMAQrHXr71OllmUk8S6gmeIy1pCt5Gj /t8KbZJgXCWURZ59iQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [192.168.2.130] ([79.251.201.250]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MowKi-1tC3GL3dPi-00cZ4b; Thu, 16 Jan 2025 14:44:47 +0100 Message-ID: <42c0ac23-403c-42a0-ab22-88650dd16edc@gmx.de> Date: Thu, 16 Jan 2025 14:44:47 +0100 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PHP-DEV] htmlentities(): Passing null to parameter #1 ($string) of type string is deprecated To: Craig Francis , Kamil Tekiela Cc: Daniel Baldwin , php internals References: Content-Language: de-DE In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:yfkge0Sr7rsvSXYn32uy9njSaWH4rtX8fd5KrYQUG4e8X+4w74a pzEm94Y/h2HkDOEjoJocfN7gAnUhxsBFCRo66OxUHHkn4o9tXD3sdjd+IMH6cxIsvXs6bsH EObHJMLSr3LW3FYb+FhdhLpCVXjNgNCFpv4DK3562PHXtc1XTm/oSFpCOZqLlk2cCu+EAXy UHDC+Zrlm/0RV0/33Poag== UI-OutboundReport: notjunk:1;M01:P0:p1/6eB3r/5c=;arb899nMOJbBhwB8P/p4HS5KAWj 28zGFgldxlCF/zaGTAhtBVg9V14JoMMMyUPdJdnXJ2T3DUXVALF9mZnAs02P2NwHt5k1m7rfU 6A6nlm4DNIhz3yR/pGaWCHVCIhnWC0ymU/Hlb2SvwBUDuRg4Be5PjwWnKnZCBNEf/q/R0nlPh He7f4bBFJshuKxFQ6TyZ0q9Rge1nhUDJ9lW8F6s8CUOy0hw0SyloMvOqz1t5Wwg6A6LdaB6Od fQOx6NyLfz/SpudFilmyRkE1R/zRiD1KX54vDyC971llpBbEaUl0Rkf7WQkLIy9nmuogKGhtQ T3BsLiu8s3WVciut26u7D3LdkrjbFo6kf/nxkfgQW+LY9ERzhzsNS/NV1rvvVvNpvQQvxHoUG +1oQrp2a7EXw8I8f0X6QLhFl0v/152d/SCAzK/GMnWfLZ/EpPh7vspSleZpRVjEb/04XTc1kg tk68OEA5Ov0HAITdTuwwjCCO2ynd4L4Clf+H54V+fRRxaZXG6kg07IkXJvylKu1NT1PnBNen3 RFfaOVuAXrAKV/CwSnxJWWQy86/6yIZs+2BwB68OtM87DrK4jHJWcqXXrKGFuwLB5MRkGPjCC Scl664Mp+ajngV0Cp0RyhMSKK9rnq+hV7EgbgXB8EJHt6i+DS6XxilNvzOOoxlM+X2hmWjRS5 eDM890czQDc3B5FMKR5a0ZQPyGPbyWxVybg2Vr6odLWqmFeP5tXhEZKFM4cWUS2PMs7O5HjDT IQr3q2wBB9xCltAK7Ml2dSwYx+t11uCld0f2iW4+P+0ybV3Ehq0djDR4k+TOonjlSxdk51UqR GJ93xN0XS6mZlMybvjha5qIgfDXO14gjRFnWBjHcX+eRl5ZEV5jIqsnuQMy73kAJQrKXjMd2n M0YvdOvGGkxHYGk5YUKsa8rnC9SZiVIIetbxOvsElMxqjJe5Wjyp84rjuB6veQO/gjBN7GAHN BO+EYSp2V01T9/ebAZnepz9RG3G4PlzsYKy0Isyy2suua8oRrNmtZozl0lvmR5k4DuC4rUSuO ZOjCLGEj7zFd6s4kdQhqUh1v+RHhfmcXyv3f7ULpf0rGEjSZ+XETBmyYVmBLuTAPoOBXxVNbG BBp8cblODrO5+zxhgAki2i8hlYX945onw7cf3aLXx3UArwUcBOVQ+7OSnM0KSpfQ60rQydnxO Iw/d/QvKbec+SBwls8pVsAl5qE9yMCHAxBfMC2OJpZw== From: cmbecker69@gmx.de ("Christoph M. Becker") On 16.01.2025 at 02:49, Craig Francis wrote: > On Fri, 3 Jan 2025 at 16:03, Kamil Tekiela wrote: > >> It is a step towards making the user-defined functions and built-in >> functions consistent with each other. > > Just to note, it could have been "consistent" if NULL coercion was > supported for user-defined functions (when not using strict types), in t= he > same way that user defined functions coerce the other types: null is not a *scalar* type, and it shouldn't be treated as such. The fact that it still silently coerced when used as operand is something to tackle in the future, but not an argument to revert a long-standing deprecation. And of course, it's up to everyone to just brush null returns under the carpet one way or the other, but at least for functions which are not documented to return null (like htmlspecialchars()), it might be better to look for a cleaner solution, since otherwise you rely on undefined behavior. https://www.php.net/manual/en/functions.internal.php: | If the parameters given to a function are not what it expects, such as | passing an array where a string is expected, the return value of the | function is undefined. In this case it will likely return null but | this is just a convention, and cannot be relied upon. As of PHP 8.0.0, | a TypeError exception is supposed to be thrown in this case. And wrt other potential null values like for superglobals and database results, you also may be better off to handle these differently than empty strings. Note that I'm generally in the coercive type camp. Christoph