Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123267 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 B36D01A009C for ; Sat, 4 May 2024 12:31:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1714825937; bh=6aV2XIWhJ1d1lRbmq/a21RvrcPA9CfiH3xWWuoJd9FM=; h=Date:To:From:Cc:Subject:In-Reply-To:References:From; b=VXBp3IEKdfArQV8zgY+MhaWZJ7TMEk6QrhA5SpCxMCto2WwBDiPZCD3x6QrD2/g+w l8SX6cs452HFOi5x33wfr0x5Pph2yNgimXqutbVP5SfAaBtUAraO1kgaRxHbf3Oj/T 12SKrt2n7A2iGsgNzCyPlBhg4Grz3E2JXsUam7BQNDQ/b9YbbfL/fKEVJgEyF+KXka virOenoKbNVgRRjKsRXygyLKBKrh+eUMQcvZ1SsCggrjYO6hJjcacIUygEQ5yBTKiD w5T2cTPysqohbBRCLLwCkCFMoJWplOxO7K0Y1x9HjfbMJPPC+zz2r6n+W5Zg3u8WxQ yg/dq2iNKy/5g== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 9DFE7180041 for ; Sat, 4 May 2024 12:32:15 +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,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,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 mail-4317.proton.ch (mail-4317.proton.ch [185.70.43.17]) (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 ; Sat, 4 May 2024 12:32:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gpb.moe; s=protonmail; t=1714825887; x=1715085087; bh=6aV2XIWhJ1d1lRbmq/a21RvrcPA9CfiH3xWWuoJd9FM=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=Lg4L70R/ibKfoODjF382ke+7pnmHIhWV1OGKDng5n8E9ZTGDy6G/NiJCkmXQ7lBAW 2GMsjSSxY070fugugM0BUVna3V8kYLaR9VpJ3JLBtDsW8J6ptA4LB31TmjlJcNjjo2 sfdssv0iowEwbeqcUBM5ta1EvilGQX+8C9beCmbJJDLy8SUSAlAa8/mC1JL/UafX+y Zg7ZRy7/4PTTsp4rJ+Rltm9+x6Wau7oSaJvYZEx6l/DYCAnot9UfUG1MBG0XqfnGFs dAsKBQAVerRRyXLlCONLbE2dioEFxX9q/oHQhLIBG6dNKCdq0uHkLWdAE8J0t8yuxl 2c7oPDQyABtyg== Date: Sat, 04 May 2024 12:31:22 +0000 To: Derick Rethans Cc: internals@lists.php.net Subject: Re: [PHP-DEV] Inconsistencies between parameter number and index when reflecting a method/function Message-ID: <89FBdQLFoPeFTpM_oW8b66OxnmqHwtV3fuD_zYXkmzxGZRR5WXOfsxPN6JEITl2kKXXAwM8viekTx3uiE7xdiTgpIgFDqXzWuNZ54mC0w0k=@gpb.moe> In-Reply-To: <5b7ac8bb-6f88-a7e2-ac7e-f57b0970a5ba@php.net> References: <88ea5de8-22ea-4c23-b570-229acd546c10@app.fastmail.com> <28215C90-191D-4159-9C47-86D03B9A683D@php.net> <63GXg3pF4DIRrXn-zuvO46emeZTrmkMOuiLUFwDA18PdV0y8BNqFvwidOxktGf3Z8geBiwCksbQ-Jpzg9OaxPv6VxDJRDkWCE5S2kabhmF4=@gpb.moe> <5b7ac8bb-6f88-a7e2-ac7e-f57b0970a5ba@php.net> Feedback-ID: 96993444:user:proton X-Pm-Message-ID: 4a6a18f2b419efa06c7e16110a99257c950660b8 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: internals@gpb.moe ("Gina P. Banyard") On Friday, 3 May 2024 at 16:47, Derick Rethans wrote: > On Fri, 3 May 2024, Gina P. Banyard wrote: >=20 > > On Thursday, 2 May 2024 at 21:33, Derick Rethans derick@php.net wrote: > >=20 > > > On 2 May 2024 13:48:36 BST, Ollie Read php@ollie.codes wrote: > > >=20 > > > > 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. > > > >=20 > > > > 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. > > >=20 > > > 0-indexed, as that's what PHP does everywhere else. > >=20 > > Well not really, if you have an error (TypeError or ValueError) which > > indicate what parameter is the problem, it will be 1-indexed. >=20 >=20 > Which API in PHP is 1-indexed? >=20 > 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 t= he function returns 0 then output buffering is disabled. However, if you retrieve the full statuses of output handlers via ob_get_st= atus() 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 *withi= n* PHP. Like I said earlier, I don't frankly care *what* the consensus is, but cons= idering it was split *within* the reviewers of the PR it needed to be broug= ht 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