Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126199 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 DA2A41A00BD for ; Fri, 3 Jan 2025 16:00:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1735919852; bh=SG51D867DXUkjxWF7DyeTuHRE0ZjEma4nmmwUa7gmHc=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=SFPyrndSvzFJBN6P5M6Au8boLwhCui+FxUnOSDn6gj+yrd0OYR3C6o96sv0aHe22D ImjjUatcIC/r48zhJLOKuXuJB4Pw6HC0mswER+ct3AzDQWdAeMJHW8G92OlGtOjXvE xlc1AAnJq0e00ISpLojwDXfvHBe/UkAwxtXkWAx3jLbIqzuk0gHTaEt1NqR+CDVgHb GaFwW5+G+VYDEPKuVJSAb/AIFIGRnWmE1dtthsbVjCs9bP7WSyEWHJdfmk2tIv0ohu F7r421hES20plnsunJhOGe9wMMpijfKOOLmwMMANU2hobibnUogYwqP3M0aLPybTXV 7hQxysDZB5hFg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 6485E18004B for ; Fri, 3 Jan 2025 15:57:31 +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.8 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_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-lj1-f173.google.com (mail-lj1-f173.google.com [209.85.208.173]) (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 ; Fri, 3 Jan 2025 15:57:27 +0000 (UTC) Received: by mail-lj1-f173.google.com with SMTP id 38308e7fff4ca-300392cc4caso142497601fa.3 for ; Fri, 03 Jan 2025 08:00:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1735920024; x=1736524824; darn=lists.php.net; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=SG51D867DXUkjxWF7DyeTuHRE0ZjEma4nmmwUa7gmHc=; b=IrN6GFOhlTygT62ntDeCjUq/k0GbPUhMYUcGfgWTZCM3QbVpNuppWI/eSPukMQ3WyN Rd5E8YcQQ4dTmx1BD5R6xCgYw2CJoF0lG+F42XOUja1CpigaTeozf6uiUlyvb69v33lU rw2yIOyTbQ5FSzYtSLrcWKJ+cpTBOX/E77lkpEfwhrPGI43XNcGDN215jEnEJ3CKS6BT L1MdslDsRDU0e7Tz+i994tP8o5PkEiFeGMmeQLKmHb0TimQsDlHAPsmMjz1IT6QLYhNw njK2sGqCdBYEWoYJ4jMSAOLL6JhjL0bFbRI9B0Zf3j8XN/udXoxZwj5hLW3VlTwCRnIA riRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735920024; x=1736524824; h=content-transfer-encoding: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=SG51D867DXUkjxWF7DyeTuHRE0ZjEma4nmmwUa7gmHc=; b=qrIXWs4OPEhi1d+mw+ae9dL24zmnyLZY1rvlWE1+jAJAaBXbqTb7ypBOZLe105Zyw5 rW5HMSFup7bn0Ic/XacpXjQNkzj8FRsx1SyvoBylaHnFUFlhZU7ABmSuinLBVoGkn3V1 S12b1mWCqIEEsXiGrczxvyl2bntywyPi3gD0BJ27dCqyt4uJl+9I0RFGF4SGjmVjTdoo duTrNUQnk8F7T5erFQybMQuzupH9jVbd96f8uHRgbqXJQWms/tBm24PrUUWZ58NhI6TZ tM/q0QHNXRHPnz35r9aeGgF5mRIlaGUwTGmJBMsYiNXloDCmT7y6ZsrjRz1VE70qPg98 GcnA== X-Gm-Message-State: AOJu0Yzi5NjIj8hzQOQ8s5oZlknkEJWuJ2ZtSbMysDoqtIP7R0ExWCIV fEJyTLiZ0oPRdwBcwPL2tFvy/fvDu9yWTvRRiWMEQACE+LFGNwPLDqBGTkFl7XI/P0W6IQTjLR0 ahWI28qjpL5D5N++fIVDNF2e/MeuNgLZvgLCSHg== X-Gm-Gg: ASbGncuWDYuErjdgLhbTszb1iurY4METYSDA4enWZQPz5CIj6e6kPjvEgft5CO+NUKf hfQ3vOOgDtJrFTgb525jE69kFB3MyjSCtSsDP2kuqG0/T/JPY4OcAvqftQH6DqlHI7s0IEVo= X-Google-Smtp-Source: AGHT+IGRdR3QnGeOxDd3ft6OK8A4tspCJWU8HX+tbUadNSqA9ecy8+GbjXrSvlQBANepmonOdV7z/oiZC3yZ0hysvek= X-Received: by 2002:a2e:bc26:0:b0:2ff:cfbb:c893 with SMTP id 38308e7fff4ca-304685032femr145296621fa.6.1735920023466; Fri, 03 Jan 2025 08:00:23 -0800 (PST) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: In-Reply-To: Date: Fri, 3 Jan 2025 16:00:11 +0000 Message-ID: Subject: Re: [PHP-DEV] htmlentities(): Passing null to parameter #1 ($string) of type string is deprecated To: Daniel Baldwin Cc: php internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: tekiela246@gmail.com (Kamil Tekiela) Hi Daniel, I am not sure that the mailing list is the best place to ask such a question. In fact, this question already exists on Stack Overflow: https://stackoverflow.com/q/71707325 As of PHP 8.4, this is still not an error. It was deprecated in PHP 8.1 and won't be turned into an error until at least PHP 9.0. The deprecation of this confusing behaviour has been heavily contested, but many agree that it is a good step forward. It is a step towards making the user-defined functions and built-in functions consistent with each other. You say that $fieldValue in your code can be either a string or null, but you don't explain why it can be null. Anytime you have a union of two types, you need to design your code around it, so I presume you have a good reason to allow null. Using ?? '=E2=80=99 is a cheap solution t= o avoid the deprecation message, but it's not a good solution. You're not really handling the null value in any meaningful way. You're equating it to an empty string, so it begs the question of why the value is a union of two types in the first place. So in summary, the "error" isn't confusing or broken; your code is. Your email isn't a very good discussion starter, so I imagine you won't get many replies. I hope my explanation and the link to Stack Overflow will help you in your current situation. I also encourage you to read the mailing list rules if you haven't done so already: https://github.com/php/php-src/blob/master/docs/mailinglist-rules.md Regards, Kamil Tekiela