On Friday, 3 May 2024 at 16:47, Derick Rethans <der...@php.net> wrote:

> On Fri, 3 May 2024, Gina P. Banyard wrote:
> 
> > On Thursday, 2 May 2024 at 21:33, Derick Rethans der...@php.net 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.
> > 
> > Well not really, if you have an error (TypeError or ValueError) which
> > indicate what parameter is the problem, it will be 1-indexed.
> 
> 
> Which API in PHP is 1-indexed?
> 
> cheers,
> Derick

I have given the 1-index API which is ob_get_level() in my email reply, so I'm 
confused by the question here.
ob_get_level() starts at 1 for the 1st level and increases from there. If the 
function returns 0 then output buffering is disabled.

However, if you retrieve the full statuses of output handlers via 
ob_get_status() it returns a 0-index array.
So to get the correspondence between the output buffer from ob_get_level() and 
ob_get_status() you need to do +/- 1 with the indexes/levels.

I am just pointing out that such a difference in APIs already exists *within* 
PHP.

Like I said earlier, I don't frankly care *what* the consensus is, but 
considering it was split *within* the reviewers of the PR it needed to be 
brought to the attention of internals.
I find 0-indexing in this case utterly confusing, but that's possibly just me.
And if most people are in favour of 0-indexing, then let it be 0-indexing.


Best regards,

Gina P. Banyard

Reply via email to