Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123262 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 B60761A009C for ; Fri, 3 May 2024 09:10:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1714727486; bh=Ma4U4vR4zNesFKmHCdrKFFjQalPHgcg0sQvfTQbuhnA=; h=In-Reply-To:References:Date:From:To:Cc:Subject:From; b=K+4IzKg/ziup1B7isW4v9gNWoc/Ft3lXuihvoq0iUMVJA3L7L6hlqVrhhS07JIyCi 8QQFraJdCJcLd6SVWwYlK0pCmgzes1F6xTxOHikdirta8DK23ZbX4er7+ZFn63Prxt gPaLCszMehUV7EcCh5Y61rKGmUHSL3ofRUrviq6NYKhJs+haK1SpCYWcw0/l6k+5gk rHHxYssVoHp0tlhcROAyE8h7G5HJ0TLpPmbSK+oDctnCLscr4+hxUixza+hKbO08kG cTArOmC4T23TT0hVfKE9MfkVCf0YH1Je3Y1zr5iC29g207KAbm94qhW6+ma6uzHsh2 QJ2K7LAm8z4wg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 7E01A18007A for ; Fri, 3 May 2024 09:11:25 +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.1 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,HTML_MESSAGE, RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,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 fhigh8-smtp.messagingengine.com (fhigh8-smtp.messagingengine.com [103.168.172.159]) (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 ; Fri, 3 May 2024 09:11:24 +0000 (UTC) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailfhigh.nyi.internal (Postfix) with ESMTP id D92CC114018B; Fri, 3 May 2024 05:10:38 -0400 (EDT) Received: from imap44 ([10.202.2.94]) by compute2.internal (MEProxy); Fri, 03 May 2024 05:10:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ollie.codes; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm3; t=1714727438; x=1714813838; bh=j/mOMJBVNq 24e7Omr+vTIfruK0IrVRHU9H2i8JTCY5A=; b=PWn/6L+dkzHvBC3hDLpj93zl1t xpfMlxo2QqXry29Pbnc2Mdc+FGUQh47ADSf0AjJ5nXqH2DQIUEOWW0gkdhc5WiHA XWQmkuY294aqXipey/T5RP6oHx6t3LuXayVkQIDYZQLmurCgjwqB5iZ1o+LsNcBo 0sgbnGCD0uSa0dGoq8rh5CxAEG5mhybvM1789GP25afOnOzpvGanX+HFpFE4Q8fi BXi1Dye4u+5Mc5Bj3+77W5whjtl2wYUNZpEJrMvFxlhh2oS51Nf3Q+EujVh1C0ce yTdvFJ1rttA1kUeW+/333rhBE8WQF+2MOK7amLbT1V+N5X5N6PTWvD50JYRQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1714727438; x=1714813838; bh=j/mOMJBVNq24e7Omr+vTIfruK0Ir VRHU9H2i8JTCY5A=; b=P4LHHTPsArWMH51xHtRmykRc4UD7sqIZILmSoGL7D4Pj ACb23plcC5DFr5FJl4I0UWIGFxa4WISFhm/kfWPucQTmCLVajwAGSouVeGI7ik0d R7Lta50eflE2AnF2YLu4uIyiFuMC43td9pnJXOWoP7M+MhhHG4dv6LN0tYDdJcbx z+8LrhCrPSdy1fE6nAQU8gZlpAYhk9w5DyP2CTCkoVYJMgBWhYITbZqWM/fU2l+z 2GhemcGtQ3a1gqItJAUeSQ9xXB8mrFHNXG9o6jAcOFKypRaky5vhZ0pFyRvcQEfa wfoPNMUauhTsgfiYrTX516/zcFXM4pdQEq3SDr7svg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvddvtddgudduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvfevufgtsegrtderreerredtnecuhfhrohhmpedfqfhl lhhivgcutfgvrggufdcuoehphhhpseholhhlihgvrdgtohguvghsqeenucggtffrrghtth gvrhhnpedtvefggfdtgfethfeftdehvdeujefffeegieelvedtkefhjefhtdetveevveeh udenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehphh hpseholhhlihgvrdgtohguvghs X-ME-Proxy: Feedback-ID: i835c46d5:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 5924436A16D1; Fri, 3 May 2024 05:10:38 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.11.0-alpha0-417-gddc99d37d-fm-hotfix-20240424.001-g2c179674 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 Message-ID: In-Reply-To: <63GXg3pF4DIRrXn-zuvO46emeZTrmkMOuiLUFwDA18PdV0y8BNqFvwidOxktGf3Z8geBiwCksbQ-Jpzg9OaxPv6VxDJRDkWCE5S2kabhmF4=@gpb.moe> References: <88ea5de8-22ea-4c23-b570-229acd546c10@app.fastmail.com> <28215C90-191D-4159-9C47-86D03B9A683D@php.net> <63GXg3pF4DIRrXn-zuvO46emeZTrmkMOuiLUFwDA18PdV0y8BNqFvwidOxktGf3Z8geBiwCksbQ-Jpzg9OaxPv6VxDJRDkWCE5S2kabhmF4=@gpb.moe> Date: Fri, 03 May 2024 10:10:18 +0100 To: "Gina P. Banyard" , "Derick Rethans" Cc: =?UTF-8?Q?Bj=C3=B6rn_Larsson?= Subject: Re: [PHP-DEV] Inconsistencies between parameter number and index when reflecting a method/function Content-Type: multipart/alternative; boundary=06d9b4a962044aeea7de115d4970204d From: php@ollie.codes ("Ollie Read") --06d9b4a962044aeea7de115d4970204d Content-Type: text/plain On Fri, May 3, 2024, at 1:45 AM, Gina P. Banyard wrote: > On Thursday, 2 May 2024 at 21:33, Derick Rethans wrote: > > > On 2 May 2024 13:48:36 BST, Ollie Read php@ollie.codes wrote: > > > > > These methods accept an integer to retrieve a parameter by its position, or a string to retrieve by its name. So far, I have built this so that if you required the first parameter, it's parameter 0. I treat it this way because the only other place where we deal with parameter indexes, is ReflectionFunctionAbstract::getParameters() which returns the parameters zero-indexed. > > > > > > The question that is holding this PR back is should these methods be 1 indexed, so that the provided position is consistent with the error messages, or how a person would typically count, or should they be 0 indexed to remain consistent with the existing API. > > > > > > 0-indexed, as that's what PHP does everywhere else. > > > > cheers > > Derick > > Well not really, if you have an error (TypeError or ValueError) which indicate what parameter is the problem, it will be 1-indexed. > > Which, for me, makes it more logical to have it 1-indexed. > If the ReflectionFunctionAbstract::getParameters() API did not exist, this is what I would have pushed for. > > Moreover, PHP already has a 1-indexed and 0-indexed discrepancy with the ob_get_level() and ob_get_status() functions. > > In the end, I don't really care what we choose, but this just needed clarification from internals on how to proceed. > > Best regards, > > Gina P. Banyard > It looks like the consensus seems to be 0-indexed, but I'm happy to allow it a bit more time to get a few more opinions if you'd prefer. I do totally understand what you're saying, though. I think people are typically already capable of differentiation. We know that the first entry in a list array, so entry 1, is index 0. Not to mention the way getPosition() and getParameters() works. --- Best Regards, *Ollie Read* --06d9b4a962044aeea7de115d4970204d Content-Type: text/html Content-Transfer-Encoding: quoted-printable
On Fri, May 3, = 2024, at 1:45 AM, Gina P. Banyard wrote:
On Thursday, 2 May 2024 at 21:33, Derick R= ethans <derick@php.net> wrot= e:

> On 2 May 2024 13:48:36 BST, Ollie R= ead php@ollie.codes wrote:

> > These methods accept an = integer to retrieve a parameter by its position, or a string to retrieve= by its name. So far, I have built this so that if you required the firs= t parameter, it's parameter 0. I treat it this way because the only othe= r place where we deal with parameter indexes, is ReflectionFunctionAbstr= act::getParameters() which returns the parameters zero-indexed.
> > 
> > The question that is holdi= ng this PR back is should these methods be 1 indexed, so that the provid= ed position is consistent with the error messages, or how a person would= typically count, or should they be 0 indexed to remain consistent with = the existing API.


<= /div>
> 0-indexed, as that's what PHP does everywhere else.

> cheers
> Derick<= br>

Well not really, if you have an error (Type= Error or ValueError) which indicate what parameter is the problem, it wi= ll be 1-indexed.

Which, for me, makes it mo= re logical to have it 1-indexed.
If the ReflectionFunction= Abstract::getParameters() API did not exist, this is what I would have p= ushed for.

Moreover, PHP already has a 1-in= dexed and 0-indexed discrepancy with the ob_get_level() and ob_get_statu= s() functions.

In the end, I don't really c= are what we choose, but this just needed clarification from internals on= how to proceed.

Best regards,

Gina P. Banyard


It looks like the consensus seems to be 0-indexed, but= I'm happy to allow it a bit more time to get a few more opinions if you= 'd prefer.

I do totally understand what you= 're saying, though. I think people are typically already capable of diff= erentiation. We know that the first entry in a list array, so entry 1, i= s index 0. Not to mention the way getPosition() and getParameters() work= s.

---
Best Regards,
Ollie Read

--06d9b4a962044aeea7de115d4970204d--