Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:130609 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 lists.php.net (Postfix) with ESMTPS id B66011A00BC for ; Sun, 12 Apr 2026 14:41:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1776004892; bh=7KeJWgsYRQxfy1Ci7WVXipCPIkPMIoEiDOw5nzavejw=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=YfugLT3ViVOFc9IMdu7fQ4MC92PckrDkDaiIzmt1/++pU2+/fzqXdI6Rw1Dzfhzy6 jAAtGkl6o+iTO+dzkHFpV7kMoZ9LMWXTDZWuv1DK9ebNU3RTtrKcAWHPz3DtTxpNho pHfW9jq+DEo5c4AGlZUSijUBKPVi0Mw33J8pZXEBJLYq/qAOH0omUphviSQ308KVrr vzY/A9+Ne4Ef1HyD4+fkM3EgekhEjEfCoB1eOvU4LdmvyC5zIsdyNXuPax0uyskG+a izsia/3xJOLoljBwuXUGA52sFk2+uE3T94D9pF+J9cS/IcTrFjt/KR3G173guYjDQj gzMXrSwVhZ8OA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 6E875180068 for ; Sun, 12 Apr 2026 14:41:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from chrono.xqk7.com (chrono.xqk7.com [176.9.45.72]) (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 ; Sun, 12 Apr 2026 14:41:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1776004883; bh=FVqP+Plw61AD8MAxG736Oh+DtTY0gQMQcOeNCTPF6a0=; h=MIME-Version:Date:From:To:Cc:Subject:In-Reply-To:References: Message-ID:Content-Type:from:to:cc:subject:message-id; b=Jt1do1dg60XCZq2dgveE3G4tgV33C8SjcuLf/xeGx7stFnar67nc5IrJhob8R1bbN UFFKlefrXP9zSOa6x7/kBwpLriDKMSebY1G/epvN7fHyofpbtPnSxAri4Yi/Q5PSYp Z/GoyHpll5X1UQeMtjySCyNW+e1VpdHUdT5tZgYx1NDA0IJSBCWKE3QC+INSzxgVBT OLSn1RbniSz+CWDfZ7ij8dXbrp/Bf64g+ee0rfJdrsU9etuRzB2d/OTJiTQ6GuHfIz HtOJTebb/5TIc1dQaysOn3apPgXFIyt+OFZSbnHSK1oEVqRQe5HrcXpBXLnVLQyxvx JgpDFalEnS9cg== Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 Date: Sun, 12 Apr 2026 16:41:22 +0200 To: Barel Cc: PHP internals Subject: Re: [PHP-DEV] [RFC] [Discussion] array_get and array_has functions In-Reply-To: References: Message-ID: <497ddb67925e86b6c0b18ffdccee1629@bastelstu.be> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit From: tim@bastelstu.be (=?UTF-8?Q?Tim_D=C3=BCsterhus?=) Hi Am 2026-04-04 16:06, schrieb Barel: > This is the link to the RFC: > https://wiki.php.net/rfc/array_get_and_array_has Thank you for your RFC. I find it not obvious at all that: - Non-(string|int) path segments will result in the default value being returned, rather than a TypeError being thrown or just proceeding with implicit coercion. - Encountering a non-array value along the path will result in the default value being returned, rather than an Exception being thrown. Returning a default value for an existing path element that is not an array feels like a source of error, particularly when any intermediate value is an object implementing ArrayAccess. I would expect the following to hold: $path = ['foo', 'bar', 'baz']; array_get($array, $path) === array_get(array_get($array, array_shift($path), []), $path); which it will not due to (2). And the further looking at the examples: $array = /* … */; array_has($array, ['product', 'name']); array_has($array, ['product', 'color']); Just looking at the code without knowing what the function does, I probably would have expected it to be either: 1. `in_array()` operating on multiple values that all need to be there. 2. `array_key_exists()` operating on multiple keys that all need to be there. But not a “path through the array”. Best regards Tim Düsterhus