Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123258 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 A6C921A009C for ; Fri, 3 May 2024 06:46:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1714718861; bh=cdn6eK35sUV/pYsvygxk77CxnHehjvARozvlD0J2l7Y=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=jZwqdfid+erBegzwaOAAqkuUuHtwZ4Hmz5LafNXso2tkX7pAFlcRL4/ZAf6jGMY/H 4yIRTTfdggnXIr0u2vcFLqiDP7uh6xZj4QEiN96hbQe5XcN11DFxklDZYVOqyzq6J/ FBmWBIuQ/TXkNOekgZOuYUCHCgi8oyOGZDSBFbY3VNqBGCQGRplA6KPvY5mapP2MUn EG/lMWevc+Vy/kRVaOQKjWBw18CX9Sl6ggg5xr1IETsya52V5IGBciEiUXfX1G8Jik 4qB7kpDMxiY3a9u1ijx6sOhjO+vQo+fss4xtljdyGDVNYKqXaPqcbMQfIdfoTrWaVb I7DgclMkr4+Xw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id BCFBB180076 for ; Fri, 3 May 2024 06:47:40 +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_PASS,FREEMAIL_FROM, 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-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.41]) (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 06:47:40 +0000 (UTC) Received: by mail-lf1-f41.google.com with SMTP id 2adb3069b0e04-51f036e9f4dso2007615e87.3 for ; Thu, 02 May 2024 23:46:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714718813; x=1715323613; darn=lists.php.net; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=cdn6eK35sUV/pYsvygxk77CxnHehjvARozvlD0J2l7Y=; b=j/X297FoSAYMMnFt8RiNRwzAbxXb+Vpc9b/agLNpLWEBuCzMN0PRFzoa9SM/zAoQCI m+BpaxlNLzasUdEISLoOCggGuWo1y22xzsJevcTIK7yZgBohQR6v87cQM36ttXQDb+RL MPUS0PbYVsSt5qmZ6T/C5Tlci31i1javMWgg1bOB/6yDd8Os0VFjxVzoGWH2cc0TI6aH x3LpXoazF3iiwB8l+w8K50d2JqW+OVL+UZXuuhGWiZvhks1svMOtwzHGX8Y0SDOkjnBd LD5LIEC73/i5vmmEucgr6t/XLf+uzaO64gZQYiNRb8zq2ZzZHVhWW4aIjGHpwXqITefg iREg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714718813; x=1715323613; h=content-transfer-encoding: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=cdn6eK35sUV/pYsvygxk77CxnHehjvARozvlD0J2l7Y=; b=SeBOLtn4V3FU9RHIuKlZMMDnzotadXoWHlfnUM87i+QWWmVtKju4BiYFZ3LoztDzvQ sbXQF04X0K6WL5bTNpXH72W7oQuTHxk1uz9RgJLmXn3kmWI5/ZMG7ASjcVJo5NtSRZ4X GsSdNXxPrYsn8koQEI7fXhLqcDbBmdpUolU+S1E4ZsrU3h/fTGMufFIWgZ5hGDJhQELe uJyCxkTXcr7jk88p6e7iLLzN6V6FWWgf7QIiOZFkXePl/G4QYbzi7fVaaCfU046q8wvD /Lw+8rN8Nn8XfPfsAYSdUddIuV3s0+kjn4XCYXQIUkOhhGdDpkL0DZtjPXsIkA/flpjq F0tg== X-Forwarded-Encrypted: i=1; AJvYcCXYlVBrC/jqIsUDV2DtPyPu1zGvZjDmAyuf3YiCS3Axbkg3MlYUbjGsZoUDZScZsidQmBQRoZJtzx1vbn+9zr/0dxr48ze/tw== X-Gm-Message-State: AOJu0Yw9dQIX+4WrqA2gMVnfbR2Oced9PIp5RCaEHdabSuqylLu95DMA 5F/qq937qFIsRPxFb/nKL16aHvxNdXOwrDAbJDEy2ndsEBcoVmnUPoH44gXP7awu9/kmI2SM8b7 0daJrOSBsvLhs1HWYjtDBvPXTlic= X-Google-Smtp-Source: AGHT+IHkVluLyMwIjVi1qkWBp13fdWREIvZ6NIfyY9413qtkwKAIfeTeAjO1J5qtcVFf9e2m8Fxh+yOsyUnkwIwuMxY= X-Received: by 2002:a05:6512:281c:b0:51f:c8f:630e with SMTP id cf28-20020a056512281c00b0051f0c8f630emr1351929lfb.35.1714718812989; Thu, 02 May 2024 23:46:52 -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> <28215C90-191D-4159-9C47-86D03B9A683D@php.net> <63GXg3pF4DIRrXn-zuvO46emeZTrmkMOuiLUFwDA18PdV0y8BNqFvwidOxktGf3Z8geBiwCksbQ-Jpzg9OaxPv6VxDJRDkWCE5S2kabhmF4=@gpb.moe> In-Reply-To: <63GXg3pF4DIRrXn-zuvO46emeZTrmkMOuiLUFwDA18PdV0y8BNqFvwidOxktGf3Z8geBiwCksbQ-Jpzg9OaxPv6VxDJRDkWCE5S2kabhmF4=@gpb.moe> Date: Fri, 3 May 2024 08:46:38 +0200 Message-ID: Subject: Re: [PHP-DEV] Inconsistencies between parameter number and index when reflecting a method/function To: "Gina P. Banyard" Cc: Derick Rethans , internals@lists.php.net Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: landers.robert@gmail.com (Robert Landers) On Fri, May 3, 2024 at 4:01=E2=80=AFAM 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 positi= on, 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 Refle= ctionFunctionAbstract::getParameters() which returns the parameters zero-in= dexed. > > > > > > 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 messa= ges, 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 ind= icate 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, thi= s 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 clar= ification from internals on how to proceed. > > Best regards, > > Gina P. Banyard There's no discrepancy with ob_get_level and ob_get_status. ob_get_level starts at 0 (no ob) and ob_get_status is count(0) with no_ob. count(ob_get_status(true)) =3D=3D=3D ob_get_level() Robert Landers Software Engineer Utrecht NL