Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:121535 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 25233 invoked from network); 30 Oct 2023 17:17:57 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 30 Oct 2023 17:17:57 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 3D9F81804BC for ; Mon, 30 Oct 2023 10:17:57 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.41]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 30 Oct 2023 10:17:53 -0700 (PDT) Received: by mail-lf1-f41.google.com with SMTP id 2adb3069b0e04-5082a874098so4605531e87.3 for ; Mon, 30 Oct 2023 10:17:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698686272; x=1699291072; darn=lists.php.net; h=cc:to:subject:message-id:date:from:references:in-reply-to :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=E3oKQXNp9Db5uc9G+ZCoTpw1zxBqCWvHxpPzidtgruc=; b=bX6Gg/fATd8bPpbK4dSscPJZYuO9niZblM2x0uc8m1aQt+irqKnCDRCXVM1G9po+BL P9SHLGqU8SW/Z2IFYbzqMXWL+sIkT7mtXXbnRebGHScLKYkhOEd8JcaWuvNisZ5ywwIP GToyYqCA4tTkR9anJ5xnqfRb9IK/Ow8LvTlYPSE2F1NCmkgh17yIaMka7HyntbeFYTmk qxKK3nz9ANM2tcLwDy8atMgBVV7hT8G4KgO4gEduk8nHS/zy+qv9rD8wGSvZ5w5pGyd8 p3ffP75MNVPBu776xzYeApbbaVn8CJz8p0JvHDATfgSFoO0/BumA/SPQPjrthMWehYJV xZUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698686272; x=1699291072; h=cc:to:subject:message-id:date:from:references:in-reply-to :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=E3oKQXNp9Db5uc9G+ZCoTpw1zxBqCWvHxpPzidtgruc=; b=jPwMxswZ+8Z/MOy/I5A+Vn73Mrqo+AsFGcOWvCmWnNSO2xMem8wLZVSy7iIpkbtFN2 Q42ZGt8hoEYJBeig5xM7IMOrFjHNXUE8G0ahc3iG5MxX/ly4i38i81fSnRZq12bmJOJd jR3uedUJ6be6OEiYNFv0zYsxYgONrrPh6bta6PK3ev71CEAxGSRVXA+uhAekdRhbIylB KAkfusBFA/HyS7EJglvLjWGd9rhgDeYBcvEHPB+2ab81C865l8fCoyHBu22isuuBNHLL 0/LPhLYOpzAb1fbQnjf24CFUPgo0Xhdge1TALu+ES1KBvw/PNPtnsSVRYbliqacKXKQp cb2w== X-Gm-Message-State: AOJu0YztLof/UXzKYJgk16lHwvmRTG31C3cHuavbceA+YcpMcFYCidgK PDqpb4aPN0i9joQzUNm3sU1hjfiRy5TYML5HPjAqEUtWKK4= X-Google-Smtp-Source: AGHT+IEE6cLi+AodixQyQ8GYpp0djWJzzEZJKsEPkAahNZcFCN2TzcusBhlAZ+ZYWVhDuGOB+QQFlYzHyBrhK/3EfwE= X-Received: by 2002:a19:6905:0:b0:507:a3ae:3252 with SMTP id e5-20020a196905000000b00507a3ae3252mr6827268lfc.27.1698686271766; Mon, 30 Oct 2023 10:17:51 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a05:6022:626:b0:45:d35f:d9a7 with HTTP; Mon, 30 Oct 2023 10:17:50 -0700 (PDT) In-Reply-To: References: <22ad21cc-f6ba-49e9-b1a9-8c73fe173648@gmail.com> Date: Mon, 30 Oct 2023 22:17:50 +0500 Message-ID: To: Alessandro Rosa Cc: tag Knife , Lynn , Marcos Marcolin , internals@lists.php.net Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] New RFC : empty() function From: office.hamzaahmad@gmail.com (Hamza Ahmad) Hi there, it's a legacy function, and I don't think we can afford or we should consider this bc break. Though I don't use this function myself and also prefer other methods of input validation, still there are a lot of people that use it. Renaming this to is_empty will bring a bc break. However, the improvements to this function are worth considering. Ahmad On 10/30/23, Alessandro Rosa wrote: > Thanks everybody for joining this discussion. > I appreciated a lot the points you raised, as they are helping me to > update and improve my rfc, > whose meaning, as I hope, would look clearer than the earlier version. > > Improvements must be achieved, whatever they would cost. > Ambiguities shall be resolved. I think this is the first principle in > computer science: 0 or 1 ! :-D > In any case, they are not assumed to be resort into cut-off transitions: > they may be achieved within 3, 4 or 5 versions. > Don't be scared. > I have implemented my version in my own library and it works like a charm: > you'll have exactly what you read. > > Alessandro Rosa > > Il giorno lun 30 ott 2023 alle ore 16:59 tag Knife ha > scritto: > >> > >> > This is exactly where the problem lies. Is a string with just >> > whitespace >> > empty? Why would an ArrayObject with count 0 not be considered to be >> empty >> > while an array with count 0 is? "empty" is subjective and therefore not >> > a >> > reliable function to use. Especially in legacy code I find that people >> use >> > `empty` where they should've been using `count() === 0` and have >> > resulted >> > in bugs that weren't discovered until months or years later. The >> variations >> > of `$a === ''`, `count($a) === 0`, `! isset($a)`, and `$a === null` >> already >> > check all the scenarios you need, without risking funky bugs due to how >> the >> > internal check for "falsy" values works. >> > >> >> trust me, Ive worked on some terrible code bases that do >> exactly that and have variables redefined or dynamically assigned >> and you have to really check if it has been assigned a value or >> not and what value. >> >> It might be forgotten by everyone because of how far PHP has come >> but there is still extensive use of the @ suppressor and the >> alternative to empty would be >> >> if (@$var == "" || @$var == null || @$var == [] || count(@$var) == 0){} >> >> >> empty() is 1 of 3 functions i believe that does not throw an undefined >> variable warning if you don't @ suppress the variable you are passing in. >> >> So if you want to get rid of empty, can we reignite the talks to finally >> get rid of @ >> >