Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125172 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 3AFD61A00BD for ; Fri, 23 Aug 2024 21:21:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1724448230; bh=OAHDkvWIfkjZ6uXe3ntpg/Nx23+lDr29Jqiq/ae3XXQ=; h=Date:From:To:Cc:In-Reply-To:References:Subject:From; b=MTxvojtzvZVApELX2pkX88jVQ1zEKr4/VlZ86rHxK4HlvVjWRlNZcVgSKTQdqA9X5 DbCy6IerUTbvk0c82CbLTu7WG7AKQkalJITHaKJSTNVDqE1RNUsDN+Iq3RmzDAobAM S5ADB0BTB2j1Ir2KE5c8I/rD2ggMeFrRXUpsgzR1WW/WadE7ZnlIJgyFhAH7abkTv0 ZZRGtXYswyTHsblPLiIzrTr/yU4Z2VzPDxKGiIxcMtIgaej9xqrHDvFM8RlnU64ghu hPfRjsF/ekzRxdZGuRnzXUXTXDDwPhX7HkHgUHdEx458bFISSpSuRnqUWkY0/SWDjo eZ4FI2PIFn5FQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 0F13C180503 for ; Fri, 23 Aug 2024 21:23:49 +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.1 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,HTML_MESSAGE, RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from fhigh1-smtp.messagingengine.com (fhigh1-smtp.messagingengine.com [103.168.172.152]) (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, 23 Aug 2024 21:23:48 +0000 (UTC) Received: from phl-compute-03.internal (phl-compute-03.nyi.internal [10.202.2.43]) by mailfhigh.nyi.internal (Postfix) with ESMTP id D3E0F114AAF6; Fri, 23 Aug 2024 17:21:56 -0400 (EDT) Received: from phl-imap-09 ([10.202.2.99]) by phl-compute-03.internal (MEProxy); Fri, 23 Aug 2024 17:21:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bottled.codes; h=cc:cc:content-type:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm2; t=1724448116; x= 1724534516; bh=L0yecV7X4xs7kwdB4ZWPsGrni0X9HVMldcse/5NZokk=; b=l 9DXXAtKMGzJSYmmXN9b/Cz6tEMToSUI8lHdrMnL3QPqCUOVlpmUfc0ycM8BUiAb8 ksw1y2NU6U08mjwlT0Z+SrWL6zOolim3+lLP6AqlFtBuz4+4KES+oyYHEjeWxhmO wDmX4zXncC2JUJbZqAo7eM0u3W3x5uhElXp/oD3AXi04dWk2tl9fYJyRI49Raq4Z 4VvSGJwPmF8C9dICKrODPe86X+sgpMFIwcoiu7GwrrU+WVJe9JHaMUL0Bz9kcu53 0wXzWMjTFfhq4CgnNVFxnvgDixgGGS91dJUl3du4v+9CjHd7noDQ7bd2d1Ai8zi+ JvvGv5iYOuADhkALE0i8A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1724448116; x=1724534516; bh=L0yecV7X4xs7kwdB4ZWPsGrni0X9 HVMldcse/5NZokk=; b=MfCY3QBT48fhTCBE/AmQLt6Sz4LscdWUBo3K8D/FLhfZ trB83HW268E7X1TZ1Iv5/0RSLJwXo7Zu0Bov+4V1FZSQsidsAJkXJJkzZZzx8COf gbyFWRvqNGp3M6usbMikzpCnE8OrSvwn/RgeoWNQTiK13EsaLFwJ/sJhUtw+DjJB qDsp0VTFebFDhJ+TBHs8DlhpOeyOp64Ku765v6NhmxpVJ4DT/aPxc0uKaPQWVnUF 7P5lJRZJcCYDlJ3Bk19SIpPzmQufgxuOiQ06AnW1P8mC0K5DlXBVugMvSBuBjzvH uyzSF4ilR9nzPegBxuAlbQbHH3i3GMVjDzScvTpXGQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddruddvvddgudehlecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivg hnthhsucdlqddutddtmdenucfjughrpefoggffhffvvefkjghfufgtsegrtderreertdej necuhfhrohhmpedftfhosgcunfgrnhguvghrshdfuceorhhosgessghothhtlhgvugdrtg houggvsheqnecuggftrfgrthhtvghrnhepieeuteehvddvfeejhffgieehleehhedthfef keejffelgfevvdekudetjeejtddtnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrg hmpehmrghilhhfrhhomheprhhosgessghothhtlhgvugdrtghouggvshdpnhgspghrtghp thhtohepvddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepmhhrrdhvihhntggvnh htrdhlrghnghhlvghtsehgmhgrihhlrdgtohhmpdhrtghpthhtohepihhnthgvrhhnrghl sheslhhishhtshdrphhhphdrnhgvth X-ME-Proxy: Feedback-ID: ifab94697:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 7A8A7780065; Fri, 23 Aug 2024 17:21:56 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Date: Fri, 23 Aug 2024 23:21:36 +0200 To: "Vincent Langlet" Cc: internals@lists.php.net Message-ID: <90955b3c-db6e-497d-8d20-4090eb0882bd@app.fastmail.com> In-Reply-To: References: <8307aee0-f7c2-4e30-9823-ed38e66d0c3a@app.fastmail.com> Subject: Re: [PHP-DEV] [RFC] On the need of a `is_int_string` ? Content-Type: multipart/alternative; boundary=cb1076cf6b90481a897008b1d398cda0 From: rob@bottled.codes ("Rob Landers") --cb1076cf6b90481a897008b1d398cda0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Fri, Aug 23, 2024, at 23:10, Vincent Langlet wrote: > I found a simpler implementation later which rely on array_keys > ``` > fn is_int_string(string $s): bool =3D> \is_int(array_keys([$s =3D> nul= l])[0]); > ``` >=20 > I considered that `is_int_string` was better in the same namespace than > `is_object`, `is_array`, `is_int`, `is_numeric`, ... but maybe there w= as something better > than `int_string` to describe this category of string since english i= s not good (integish ? integable ? integerable ?). > But indeed it could be interesting to relate this method to the array = namespace... Don't forget to bottom post! I'm curious which one is faster/more efficient. :)=20 > Anyway, this topic does not seems to interest lot of developer so far = ^^' I think it would be worth writing an RFC for. While super-niche feeling,= I was literally bit by this the other day when storing what I thought w= ere numbers as keys, but it turned out they got stored as strings (2-dig= it numbers, and the zero-prefix bit me). That being said, I'm not sure h= ow this function would have helped me (other than tossing in a few asser= ts to make sure things were sane). So, writing an RFC will force you to = think about usecases like that and some examples to highlight the issue = it helps solve. =E2=80=94 Rob --cb1076cf6b90481a897008b1d398cda0 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable

=
On Fri, Aug 23, 2024, at 23:10, Vincent Langlet wrote:
<= div>I found a simpler implementation later which rely on array_keys
<= /div>
```
fn is_int_string(string $s): bool =3D> \i= s_int(array_keys([$s =3D> null])[0]);
```

I considered that `is_int_string` was better in the same= namespace than
`is_object`, `is_array`, `is_int`, `is_num= eric`, ... but maybe there was something better
 than= `int_string` to describe this category of string since english is not g= ood (integish ? integable ? integerable ?).
But indeed it = could be interesting to relate this method to the array namespace...
=

Don't forget to bottom= post!

I'm curious which one is faster/more= efficient. :) 

Anyway, this topic does = not seems to interest lot of developer so far ^^'

I think it would be worth writing an RFC for. = While super-niche feeling, I was literally bit by this the other day whe= n storing what I thought were numbers as keys, but it turned out they go= t stored as strings (2-digit numbers, and the zero-prefix bit me). That = being said, I'm not sure how this function would have helped me (other t= han tossing in a few asserts to make sure things were sane). So, writing= an RFC will force you to think about usecases like that and some exampl= es to highlight the issue it helps solve.

=E2=80=94 Rob
--cb1076cf6b90481a897008b1d398cda0--