Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127051 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 DAEAD1A00BC for ; Sat, 5 Apr 2025 18:42:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1743878376; bh=gZaGnqQTb7c06UtQFFWAzStCAyoFi7LcqZuaQLKb6dk=; h=Date:From:To:In-Reply-To:References:Subject:From; b=ST+83K8QCVtdiyJjHjyT359QEOQlvrthDWD2kfChwIZRi2lOAU45AKUem+hbHgkHG pjiJS738dMnCg0TcLOS8kQDzY+07tdU1JHj5wwa58HsC5hJEBOdxtB6uzp093+QQQ4 QXdQKZgVECnf555Gro0yiD/sH0kKDKAziXNrVmvDEuvIzYN546f+awvFCYCUcVOwY0 1lfQdovWeh/kJ4IZfLG/am33P2xb0g/XKrqIx9+EqvfmMTMZd9gOlI2eGqZ++2sODy aTEVil6BFfMEtr0SL2vEsQV1Xd6rNDwi2ceHi35Hx98AnDDVw7xNxvGqDCDodl2laA WL2dlvlrAFXeg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 44089180087 for ; Sat, 5 Apr 2025 18:39:35 +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=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,HTML_MESSAGE, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS, SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from fout-b5-smtp.messagingengine.com (fout-b5-smtp.messagingengine.com [202.12.124.148]) (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 ; Sat, 5 Apr 2025 18:39:24 +0000 (UTC) Received: from phl-compute-12.internal (phl-compute-12.phl.internal [10.202.2.52]) by mailfout.stl.internal (Postfix) with ESMTP id D37F411400B1 for ; Sat, 5 Apr 2025 14:41:49 -0400 (EDT) Received: from phl-imap-09 ([10.202.2.99]) by phl-compute-12.internal (MEProxy); Sat, 05 Apr 2025 14:41:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bottled.codes; h=cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm3; t=1743878509; x=1743964909; bh=zUiwQw2biW a93GRYoQS1hn7I3TIlZCEo82VTjOh87FY=; b=W/5GUDOVRqvuUgsYh8FWA63+H3 WkYPJIPE/e5w/4u2d5Kc344B/neIzUG4a2DmreN4RhEnN5oXdKGGsbOifl1YMDzs zq7BF62ZF7NW5uGIZuyBfTVpV67iZkJcgG8zUjUNIjaKqKvMOYMTWa/KuFo7/6Xp M1SxK9esZ7ORlSUc3+jwpo83Cspn0tUbG4BgixlJulFj0dLbXOGEC79zAf912ydw eFeU2ytLZUOOu5QJ17dz/EnaKV1cjwpSlAQQFvpua5/lMAKizz1wRpuQ/VNJWOLc uQJ+e8tGSzFmdzkG2fD8L0cgYiKoTjKyPAib4cI28gHXWgmqi+5d1bco49bg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1743878509; x=1743964909; bh=zUiwQw2biWa93GRYoQS1hn7I3TIlZCEo82V TjOh87FY=; b=ld+yqwioETTZUKbA2VVycJghNEmUDdamTE/Qf4nJxE+K7NgJalL LwLDh4dxKNi+MHkil+peV50maqjE90sAE6IVbdjY4KgCXRkIaZp8Kq3oXsrn8jCN 2MVQYnLYk876ZhlQ1XA4jJ3o7gWITssF84riuy2uRCgXaKvm1pawP27c9kf69O/V FpJAjecM1Xw8AnCpmWenCmMELccz0bIw87zZT0lkySRaicpuyH0GWiBPVj46gk6o o7KC7514EzU3BGqtGkZn4nXq3rG6ycij0/KeZdVLL7cNLPf53/pYF3q7YODKfPrG Bu4BCTrAZYWsDRKEvxwXqJZLgjKkvlcHeSA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdduleehuddtucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggv pdfurfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpefogg ffhffvkfgjfhfutgesrgdtreerredtjeenucfhrhhomhepfdftohgsucfnrghnuggvrhhs fdcuoehrohgssegsohhtthhlvggurdgtohguvghsqeenucggtffrrghtthgvrhhnpedtue ejtdethfeulefhtdelieduteelffdtudelheffgedtieehhfelieejgfevgeenucevlhhu shhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehrohgssegsohhtth hlvggurdgtohguvghspdhnsggprhgtphhtthhopedupdhmohguvgepshhmthhpohhuthdp rhgtphhtthhopehinhhtvghrnhgrlhhssehlihhsthhsrdhphhhprdhnvght X-ME-Proxy: Feedback-ID: ifab94697:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 4E6CF780069; Sat, 5 Apr 2025 14:41:49 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 X-ThreadId: Td40fe37c6836e36c Date: Sat, 05 Apr 2025 20:41:23 +0200 To: internals@lists.php.net Message-ID: In-Reply-To: <68e5b45e-1ae1-452b-9b4d-788e11c8cfe1@scriptfusion.com> References: <68e5b45e-1ae1-452b-9b4d-788e11c8cfe1@scriptfusion.com> Subject: Re: [PHP-DEV] RFC: blank() Function as a Complement to empty() Content-Type: multipart/alternative; boundary=3e6f33ee49e44a98b8a4f194debb9915 From: rob@bottled.codes ("Rob Landers") --3e6f33ee49e44a98b8a4f194debb9915 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Sat, Apr 5, 2025, at 20:25, Bilge wrote: > On 05/04/2025 15:32, Kamil Tekiela wrote: > > > > While it has its uses empty() should be avoided whenever possible. > > > Agree. A better RFC would be to just deprecate `empty()`. >=20 > Cheers, > Bilge >=20 empty() has very many uses. Once you understand what it is shorthand for= , it makes a lot of sense to use it how it was meant to be used. For exa= mple: empty($var) ?: foo($var); which is just shorter than: if (isset($var) && $varl !=3D false) { foo($bool); } Generally, you don't use empty() on strings though, just arrays, in my s= tyle guides anyway. For strings, you use `$string =3D=3D ""` or to be mo= re proper, maybe=20 trim($value ?? '') =3D=3D '' ... but these days, trim doesn't accept `null`, so that makes it a bit m= ore wordy than it really should be. However, it is just a deprecation no= tice, so it is easy to ignore. For now. =E2=80=94 Rob --3e6f33ee49e44a98b8a4f194debb9915 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
On Sat, Apr 5, = 2025, at 20:25, Bilge wrote:
On 05/04/2025 15:32, Kamil Tekiela wrote:
>
> While it has its uses empty() should be avoide= d whenever possible.
>
Agree. A better RF= C would be to just deprecate `empty()`.

Che= ers,
Bilge


<= /div>
empty() has very many uses. Once you understand what it is sho= rthand for, it makes a lot of sense to use it how it was meant to be use= d. For example:

empty($var) ?: foo($var);

which is just shorter than:
if (isset($var) && $varl !=3D false) {
  foo($bool);
}

Genera= lly, you don't use empty() on strings though, just arrays, in my style g= uides anyway. For strings, you use `$string =3D=3D ""` or to be more pro= per, maybe

trim($value ?? '') =3D=3D ''

... but these days, trim doesn't accept `nul= l`, so that makes it a bit more wordy than it really should be. However,= it is just a deprecation notice, so it is easy to ignore. For now.
<= /div>

=E2=80=94 Rob
--3e6f33ee49e44a98b8a4f194debb9915--