Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122435 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 5FB4E1ACEBF for ; Mon, 19 Feb 2024 12:33:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1708345985; bh=eBnaxEuGjGeQUbF1pMMHsDOy3yhfFvpmjF8hE8OUPeI=; h=From:Date:Subject:To:From; b=PDiE120oAImKjdmg8harn6OTjCrA9mq+C5HzEF2NL+fcOv0RXFom57G81jMfqbvpU 9RJJ3kq6VBNaKy5XskgWV6GX1Te0Xby38FTz2d3SCzdZ1Qsa+HB+shPebSsf0UOPMR 6Xo1KgA8tUHRILAlBZ1h2YhsUob2NGQEtHExsDu3oY2CRTFfoCWchgsPLEdEolvi/e lhP2gT6cNR6gt9FsK2e12/YzFSmaiMcHsqwZmFQLSTMlVgPTyXmJb+nXutgEf2phUT reqU5BwEtk76b0OefaeGD1ie3+m6T8q1HzOuxqS780w2HZ2gV/VoewsnbQWzxk5uaI eAGdBP9VD1WAA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id EC87D180059 for ; Mon, 19 Feb 2024 12:33:04 +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=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-qv1-f47.google.com (mail-qv1-f47.google.com [209.85.219.47]) (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 ; Mon, 19 Feb 2024 04:33:04 -0800 (PST) Received: by mail-qv1-f47.google.com with SMTP id 6a1803df08f44-68ca1db07ceso28283216d6.2 for ; Mon, 19 Feb 2024 04:33:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mirtes.cz; s=google; t=1708345980; x=1708950780; darn=lists.php.net; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=eBnaxEuGjGeQUbF1pMMHsDOy3yhfFvpmjF8hE8OUPeI=; b=X59YPZEliDpKoQu7UBWq4RNrAEQkPtULGpDIHh4LCj56mfp7GOGrk/epGYWnQwta7Z 6QMTCDkxBjn/YYkqyBVcvfTxACEH171ZvqHzRR+03+EDnB/8AOu1EyKqcK03NnhSPlXv D1WH47F+u6kO+E7RPhzQSqIei7iX3Wx7BMvUA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708345980; x=1708950780; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=eBnaxEuGjGeQUbF1pMMHsDOy3yhfFvpmjF8hE8OUPeI=; b=StyDAdJgd4LYbyujWwd7e27YbXhqFun0IKlMaFa7Xx3He6O1PSTZ554nsm9UedMTRh yO97XJPUSnjNoSLJHX6FRRjAFJjetGx7OfFt23hYc05h5PiUi1XBkzCGs4p9Edm7Mu2h KAVSpi2bO1wvEANdECZjvaOf36bzqgLE6OmCiaue5IWaIwShnhYmpXyL29axAbi7PdEt ObzJ/1gPI35ckJepPFvJyiJHqjlMf3RtaUQMOZlPpPdKNJnNwZk+JOuXOm3TYWHSjh3r pEYJCZWQG1Y4+OsLpi419BF5y6Us9R9AsxXPOTwNjtv9u4i1t3w+ePzBySMmlUlLXCxe hSjA== X-Gm-Message-State: AOJu0YzBqzvffU/zKmNswK5YY17lP8afqXdHn9ORa+ikE0CcOZV1oB+8 B2wxkyiYIaAjWhGDc+f9zP9XrQ0bQd/Y4MPmfYFSZ+DnKtwLF4zqcqr4LDojvdaCHZQNZBr9i2r DLnOnOdZRNOBVaa94arsuCiF+JGQqRDskJzZ/o2VXZRVezCWYAw== X-Google-Smtp-Source: AGHT+IHZBjDPQFwhnrbEc16lA/Y+hLtrXRSsVoQVpg2L7rDmN1MySY8cijV9YlDFeVPfBvDDN3U8+e846ZSq8ATMUgY= X-Received: by 2002:a0c:da0d:0:b0:68f:315f:4c4e with SMTP id x13-20020a0cda0d000000b0068f315f4c4emr10476681qvj.17.1708345980176; Mon, 19 Feb 2024 04:33:00 -0800 (PST) Received: from 1064022179695 named unknown by gmailapi.google.com with HTTPREST; Mon, 19 Feb 2024 04:32:59 -0800 Received: from 1064022179695 named unknown by gmailapi.google.com with HTTPREST; Mon, 19 Feb 2024 04:32:55 -0800 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 (Mimestream 1.2.6) Date: Mon, 19 Feb 2024 04:32:59 -0800 Message-ID: Subject: [PHP-DEV] ArrayAccess and array_key_exists function To: PHP internals Content-Type: multipart/alternative; boundary="0000000000004d5d300611bb4b54" From: ondrej@mirtes.cz (=?UTF-8?Q?Ond=C5=99ej_Mirtes?=) --0000000000004d5d300611bb4b54 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hello everyone, I was recently surprised that ArrayAccess does not work with array_key_exists() function. I am aware that ArrayAccess objects cannot be made to work with many array functions because it does not provide a way to iterate over its keys, you can only ask for and set specific previously known keys. But it could be made to work with array_key_exists(), because it already works with isset() and there=E2=80=99s a direct method that could be used f= or this - offsetExists(). The use case I have in mind is that sometimes libraries that originally use =E2=80=9Carray=E2=80=9D in return types want to switch to objects and they = make these objects to implement ArrayAccess, for maximising the backward compatibility with the old version. This mostly works, except for array_key_exists(). Do you think we could add support for ArrayAccess objects in the 2nd parameter of array_key_exists() function? Thank you. Ond=C5=99ej Mirtes --0000000000004d5d300611bb4b54 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hello everyone,
I was recently= surprised that ArrayAccess does not work with=C2=A0array_key_exists() func= tion.

I am aware that Arra= yAccess objects cannot be made to work with many array functions because it= does not provide a way to iterate over its keys, you can only ask for and = set specific previously known keys.

But it could be made to work with=C2=A0array_key_exists(), becaus= e it already works with isset() and there=E2=80=99s a direct method that co= uld be used for this -=C2=A0offsetExists().

The use case I have in mind is that sometimes libraries t= hat originally use =E2=80=9Carray=E2=80=9D in return types want to switch t= o objects and they make these objects to implement ArrayAccess, for maximis= ing the backward compatibility with the old version. This mostly works, exc= ept for array_key_exists().

Do you think we could add support for ArrayAccess objects in the 2nd para= meter of array_key_exists() function?

Thank you.
=
Ond=C5=99ej Mirtes
=
--0000000000004d5d300611bb4b54--