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 => \is_int(array_keys([$s => null])[0]);
> ```
> 
> I considered that `is_int_string` was better in the same namespace than
> `is_object`, `is_array`, `is_int`, `is_numeric`, ... but maybe there was 
> something better
>  than `int_string` to describe this category of string since english is 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. :) 

> 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 were numbers as 
keys, but it turned out they got 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 than 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 
examples to highlight the issue it helps solve.

— Rob

Reply via email to