On Thu, May 2, 2024 at 2:51 PM Ollie Read <php@ollie.codes> 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 on > this. > > > --- > Best Regards, > *Ollie Read* > >