Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:121534 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 20253 invoked from network); 30 Oct 2023 16:13:56 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 30 Oct 2023 16:13:56 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id BD344180087 for ; Mon, 30 Oct 2023 09:13:55 -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,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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-oo1-f47.google.com (mail-oo1-f47.google.com [209.85.161.47]) (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 09:13:55 -0700 (PDT) Received: by mail-oo1-f47.google.com with SMTP id 006d021491bc7-586ae6edf77so2203070eaf.1 for ; Mon, 30 Oct 2023 09:13:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698682434; x=1699287234; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=zmLNCssR4TDsfQpTp3z3b4NMPxR82W6fzCxPlFxzrEc=; b=mGbbQ2/lbYjuynqP0BKcGI/Ik+NtZ7vYwAKEiaRiI42LYeE1/izfm87QeiWWP8Zg0n 4UmLr39oHCXEbNNB+aWn0fEsjAokQftOdgAgkdqQ1N4O11veFWKyi8XYe0rCs5ZGK0V1 ZdImG0DdbChHwwS2ckxO7GIX1HaUq9Pf62f1PHGtmf/LAgJ1rAF/uzaOBMSjc+codUTu 5fbA8ZL4OCWgZj/cbDcrO2D5YmcIY9RYx9xe7BkkTjd9Ob6l5N5BY0PfDWsrqiCZU/FX fbXUTjA8dmArg4XPrGV12XOUym+9gXsj4Jb/BomD+jgK84c1tzZEYSwe25p1EeU6YLLA AfTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698682434; x=1699287234; h=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=zmLNCssR4TDsfQpTp3z3b4NMPxR82W6fzCxPlFxzrEc=; b=UMcaIyQcDq9wKhJNaOYIeYKhlTZ3b14S2MAD0pxTYBcatTaBRvqX8R3Vxzi8HF63Is iqUOUKavCPkh+d3y5LWPmdJcMYJCndKGXzxtO6OD3Z+2NROMuT3bOy4/nLUd9OPT0dVc /+8ZAjvjD271NSzVvENsQiXJSCRtDt9KcSKMfQyxj84M6/1jA/VrTos/dpSrRWnHvsSk giJUzOfXFxBRhmHp74/nXck8m+HkLigllLL6CK+UlZSxuR5olpTgjEPFeI7m7fkhoPAk YJAuE2dhIgvrIQb/h2iVK0jTHXxOOVSRyoS51yuT3YVWH3zg/bFlv6JnvZQnB1UcR5WG ohwg== X-Gm-Message-State: AOJu0YzuIz+5b8SHzi+tKU39pyC4rpBJLN++RRBtCXklZtluH28k35Vh GcRprXKgXNAv151cEIRpGrokoyz4262iq+GU/zQ= X-Google-Smtp-Source: AGHT+IE7rhkTbMPWREtIaEdAH+bgi6mV8plq7R3C1ZwN+eptaX3lmvgOeBB7K5643Zj7RKZmWfXligsWP0XkHzWM8ks= X-Received: by 2002:a05:6359:600c:b0:168:e78c:e3a7 with SMTP id rw12-20020a056359600c00b00168e78ce3a7mr4583109rwb.18.1698682434363; Mon, 30 Oct 2023 09:13:54 -0700 (PDT) MIME-Version: 1.0 References: <22ad21cc-f6ba-49e9-b1a9-8c73fe173648@gmail.com> In-Reply-To: Date: Mon, 30 Oct 2023 17:13:42 +0100 Message-ID: To: tag Knife Cc: Lynn , Marcos Marcolin , internals@lists.php.net Content-Type: multipart/alternative; boundary="0000000000001627440608f153f9" Subject: Re: [PHP-DEV] New RFC : empty() function From: alessandro.a.rosa@gmail.com (Alessandro Rosa) --0000000000001627440608f153f9 Content-Type: text/plain; charset="UTF-8" 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 @ > --0000000000001627440608f153f9--