Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123254 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 3CD031A009C for ; Thu, 2 May 2024 20:19:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1714681192; bh=GYI0RBkUV59iKY7shvfB+Payqk1Q94sZmKbzobNUBCU=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=VCgPEHQAMOapLTfHqFBpainAAMoEjUhirhL4yQI2D77da0EFyAb71ZNVSbwa4A+Lz pJGmsKoPrK8T5lVSmwQx2eYMg59S0PafRrlrK7cWsx+/cLH+G5d2VK5O0Y/o5AaUmr 7O6/nsRlS2HhkTjoOHlyBTckD+fxPWFf4E5gGF6oM7+Dc6b+asSbKp/gvZPGhX/iV5 RP97L7HXlGOcJFrZDrL+3dirwwT8g+9m2D6jfX3QE+qEs7hkF1cMcxg2402bOexOsT AF339e9N6QiCCpj+ijs/YBMVzcDVsyvixTzUzBoShQwJyxqAme1HFz0vuay1QUDuZj Iu4W+8JD4s85g== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 5AF6C18005B for ; Thu, 2 May 2024 20:19:51 +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.8 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DMARC_MISSING,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-ua1-f46.google.com (mail-ua1-f46.google.com [209.85.222.46]) (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 ; Thu, 2 May 2024 20:19:50 +0000 (UTC) Received: by mail-ua1-f46.google.com with SMTP id a1e0cc1a2514c-7e043f577c5so1104409241.1 for ; Thu, 02 May 2024 13:19:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=beberlei-de.20230601.gappssmtp.com; s=20230601; t=1714681145; x=1715285945; 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=GYI0RBkUV59iKY7shvfB+Payqk1Q94sZmKbzobNUBCU=; b=fMvj24LX2taTt6a5HWG5Pbv+5ZEoIR7yjSVwH/hu3RonVWBbxv9iTtwfvG3iZ2b9yX g2To8RjUJgo+OuR/Jba7zQZNL5nFDGHqNZ4Mp0pPj6LiLRkPQvyueHw8rGNUifhN8CEz BpXVKscRwftPWrC6mML0ppmJW2BD2df4p9VMZth1SbReOa5RGXCLrpC3ocTWQsCzHvb3 lSup87lukb8O6j8f4Utq/9DQ0qavRCQvIgXa7d3Y/10eSAAHg2/z1w/g7I1YGTmwvmeX F6COwvLn8BkCOSxpm7JsIr0Ckl+9xfLcDbq1gyFpVCey0QyjBz1V4fc2oTfRuZq5X6C8 2TNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714681145; x=1715285945; 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=GYI0RBkUV59iKY7shvfB+Payqk1Q94sZmKbzobNUBCU=; b=aUdEgDOqK+AILMrWfcetf9epKeMDsZJhi2aYwk/qr+HyxsNdFoIpvr/4e8Lo9QIaOI RPL6E6hIrtlunQ7gefT+Zh3Fu2yjo0+igfi5d3JhhlSF5UN/IedBpEW2Y/NYb5QxZ30f qJMVQXKqx4wuJRsxHk9S7FO7T8NdR2xU8mmQKqHt2xRw5HYgE/vD1GhCgg0cM4G02L1g Ps2MBTnUhhCtikotup2NaAvX6ORfa0tFQFEcWJCIRbKUFD9FuRFOCDjDZdMWwAhXCp8z +E+TGEyx9z3SI3bYzgq4YpXoaMMEYd26G8ogiXLLgq4bcgakY+tHRJ+2tM3CCl7DuoLR qeXA== X-Gm-Message-State: AOJu0Yy2S5z+nrhhZWdV9n6VpFXdIVeEcMlKoBj6RaoU4+0ETSU4SVCC 3rGWgTTKmpJibx0jbZuBArn5Xfy+h2n5B2AhPm+89Wdxw6gknpc7X3dzxsvajLEEmmHSIDth959 BWjc98ljfkHmhk9CAWyzUiV0bjr5sj8PHoC7Wx3gvMGWtukFm X-Google-Smtp-Source: AGHT+IEt25jS4K4KU8PkSMapH4FEYfA3nzCp9FV/BrvTogTkrxgncQ2Q4D+eskhIl+G16HPXlhnftChSF9SMpftTAjw= X-Received: by 2002:a67:ea5a:0:b0:47c:3477:b48e with SMTP id r26-20020a67ea5a000000b0047c3477b48emr6106699vso.6.1714681144815; Thu, 02 May 2024 13:19:04 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 References: <88ea5de8-22ea-4c23-b570-229acd546c10@app.fastmail.com> In-Reply-To: <88ea5de8-22ea-4c23-b570-229acd546c10@app.fastmail.com> Date: Thu, 2 May 2024 22:18:53 +0200 Message-ID: Subject: Re: [PHP-DEV] Inconsistencies between parameter number and index when reflecting a method/function To: Ollie Read Cc: =?UTF-8?Q?Bj=C3=B6rn_Larsson?= Content-Type: multipart/alternative; boundary="0000000000008a580206177e5068" From: kontakt@beberlei.de (=?UTF-8?Q?Benjamin_Au=C3=9Fenhofer?=) --0000000000008a580206177e5068 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, May 2, 2024 at 2:51=E2=80=AFPM Ollie Read wrote: > Hi All, > > I've been working on a PR that introduces > ReflectionFunctionAbstract::getParameter() and > ReflectionFunctionAbstract::hasParameter(), to fall more inline with the > other method sets we have, as well as just generally making peoples lives > easier. > > The PR is here: https://github.com/php/php-src/pull/10431 > > 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. > PHP being a mostly zero indexed language I would say it should be getParamter(0) to get the parameter #1 (referred to as 1 in error messages). > > Girgias has asked that I pause the PR until we can have a discussion on > this mailing list about how to approach it, so I'm looking for feedback o= n > this. > > > --- > Best Regards, > *Ollie Read* > > --0000000000008a580206177e5068 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Thu, May 2, 2024 at 2:51=E2=80=AFP= M Ollie Read <php@ollie.codes> wrote:
Hi All,
I've been working on a PR that introduces ReflectionF= unctionAbstract::getParameter() and ReflectionFunctionAbstract::hasParamete= r(), to fall more inline with the other method sets we have, as well as jus= t generally making peoples lives easier.


These methods accept an integer to retrieve a parameter by its posi= tion, or a string to retrieve by its name. So far, I have built this so tha= t if you required the first parameter, it's parameter 0. I treat it thi= s way because the only other place where we deal with parameter indexes, is= ReflectionFunctionAbstract::getParameters() which returns the parameters z= ero-indexed.

The question that is holding this= PR back is should these methods be 1 indexed, so that the provided positio= n is consistent with the error messages, or how a person would typically co= unt, or should they be 0 indexed to remain consistent with the existing API= .

PHP being a m= ostly zero indexed language I would say it should be getParamter(0) to get = the parameter #1 (referred to as 1 in error messages).=C2=A0
Girgias has asked that I pause the PR until we can have a disc= ussion on this mailing list about how to approach it, so I'm looking fo= r feedback on this.


---
Best Regards,
Ollie Read

=
--0000000000008a580206177e5068--