Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:121670 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 98986 invoked from network); 14 Nov 2023 12:39:23 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 14 Nov 2023 12:39:23 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 8AA2D18050B for ; Tue, 14 Nov 2023 04:39:22 -0800 (PST) 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,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-yw1-f174.google.com (mail-yw1-f174.google.com [209.85.128.174]) (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 ; Tue, 14 Nov 2023 04:39:21 -0800 (PST) Received: by mail-yw1-f174.google.com with SMTP id 00721157ae682-5bf58204b7aso59174607b3.3 for ; Tue, 14 Nov 2023 04:39:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dqxtech.net; s=google; t=1699965561; x=1700570361; 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=GqaXz/jyQhz32XKB1TZdHlODEDnNX4A5whDy0m6TmiI=; b=MEQKK/yDq2AI+R1QXrvBjs441SaR+GgN1nYlqGTmj78iIu9e0fTo+f0mc23bgm/AGC +5F5qYQ3OSgZASVjnl2SRTx0OOedNaoviAR4qY6pmqOCKnKvR438013mjT7t1C1K/WP2 VCY6sTO+5KW/ACd6+fQbKFy613ldDA1GswSanS9VxDrNHABee2MT/Bj1RPc+01/8Fhw8 L4+5stpniZVsStmWz7bRCnNJyYThavvOrteqrVHMWhz7X8uzQDRRiG5lnKx+cDwAB1ov kODJdQmroE4jWBLvLudf0eVrm52uU8Cm9qak7bK19JLcxp9eBvSVNDe7yxwpalm2Bu00 +xsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699965561; x=1700570361; 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=GqaXz/jyQhz32XKB1TZdHlODEDnNX4A5whDy0m6TmiI=; b=LArwotU7oSyVB2EQ6wdBUiOtBMeavTj44qsbqxO3Y284ODRBmBnGwJnVES/d5qXxL+ r9Fv6hbt6BfaJQc1jV5RfQwWOMnFJ76+S29f56oi5sfFYBssKq7JS1GQ6cgx2i57zZl6 76uvs2/frxxIebxmk4MzBlNmF6ivIGmjzg0udKZcQXkgFXQUJcoMqOShXeXcZXMEXwJo v6hqXpLkTfXnMdr90/LgCzJtN3E86grL2l508U+vHhbMF6SJrf5fuCgQSrfmtTFNj5Fh bZhCzUNbgHQIFZ3I3SJEz0qT6hbcmIXEyXV1p+xHkl4pESHukfMfWlSL3NWkhH7jI+Vy Q6fQ== X-Gm-Message-State: AOJu0YyZIbmk22lS9gX41o9+FX1xRR1OQxZ1jMkHkqhoYoCncIW/iTRV k1Lf6ab9rvrp9tTNUOtpJaE2iBYA3npf7kBzzlqHtQ== X-Google-Smtp-Source: AGHT+IF1CbvlcI6BT6dYGytLNEZEzC+39JAnQo9WdYPO5oxm5UlvnFuaLSi9qC2Cw2YbYkWm9TbE4iFGUk/3UCgkaEY= X-Received: by 2002:a0d:c886:0:b0:5a7:c777:2be1 with SMTP id k128-20020a0dc886000000b005a7c7772be1mr8941019ywd.11.1699965561280; Tue, 14 Nov 2023 04:39:21 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 14 Nov 2023 13:39:10 +0100 Message-ID: To: Robert Landers Cc: PHP internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] Array functions with strict comparison From: andreas@dqxtech.net (Andreas Hennings) Hello Robert, On Tue, 14 Nov 2023 at 11:09, Robert Landers wrote: > > Andreas, > > Just out of curiosity, what is the use case for this? I can't really > think of a practical case where strict checking is needed for these > functions. Usually, you have a really good idea of what is in the > arrays when writing the code and can handle any edge cases (like > nulls, empty strings, etc) long before you reach for these functions. I could ask the reverse question: When do you ever need a non-strict comparison? I think in most modern php development, you would prefer the strict comparison version simply because it is more simple and predictable. But for real examples. One thing I remember is array_diff($arr, [null]) to remove NULL values, without removing empty strings. Perhaps we could say this is a special case that could be solved in other ways, because we only remove one value. Another thing is when writing reusable general-purpose functions that should work for all arrays. The caller might know the types of the array values, but the developer of the reusable function does not. Another problem is if your arrays contain anything that is not stringable. like objects and arrays. Maybe I will remember other examples that are more practical. Btw, as a general note on strict vs non-strict: In some cases you want a "half strict" comparison, where '5' equals 5, but true does NOT equal '1'. But for now I am happy to focus on pure strict comparison. Andreas > > Robert Landers > Software Engineer > Utrecht NL > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php >