[PHP-DEV] strrchr with needle with multiple characters

2024-09-02 Thread Vincent Langlet
I was today old when I discovered the big difference between strchr and strrchr in the way they handle needle with multiple characters. It's explained in the doc https://www.php.net/manual/en/function.strrchr.php - If needle contains more than one character, only the first is used. This behavior i

Re: [PHP-DEV] [RFC] On the need of a `is_int_string` ?

2024-08-23 Thread Vincent Langlet
27; Le ven. 16 août 2024 à 01:04, Rob Landers a écrit : > On Thu, Aug 15, 2024, at 17:42, Vincent Langlet wrote: > > Hi, > > When string is used as an array key, it's sometimes casted to an int. > As explained in https://www.php.net/manual/en/language.types.array.php: > &

[PHP-DEV] [RFC] On the need of a `is_int_string` ?

2024-08-15 Thread Vincent Langlet
Hi, When string is used as an array key, it's sometimes casted to an int. As explained in https://www.php.net/manual/en/language.types.array.php: "Strings containing valid decimal ints, unless the number is preceded by a + sign, will be cast to the int type. E.g the key "8" will actually be stored

[PHP-DEV] Follow up of DateTimeException RFC

2024-06-12 Thread Vincent Langlet
Hi, There was an RFC about more appropriate date exceptions https://wiki.php.net/rfc/datetime-exceptions implemented in https://github.com/php/php-src/commit/66a1a911f1d6cd4b89c0bb5577fa77f1d6a2cb96 Looking at PHP example, it updated method return types like - Datetime::modify - DatetimeImmutable

Re: [PHP-DEV] Re: [RFC] [Discussion] [VOTE] Rounding Integers as int

2024-03-17 Thread Vincent Langlet
Hi, IMHO, the more meaningful cases of the RFC are missing : round(float, precision: >= 0): int|float // only cast to float for int overflow ceil(float): int|float // only cast to float for int overflow floor(float): int|float // only cast to float for int overflow Calling ceil or floor on integ

[PHP-DEV] Using less generic exceptions for dates

2022-11-21 Thread Vincent Langlet
Hi, When using json_encode or json_decode with the `JSON_THROW_ON_ERROR` flag, `JsonException` might be thrown. When using `new DateTime('foo')`, a generic `Exception` is thrown. Incidentally, I wonder why it's not an `InvalidArgumentException` (but that could be another debate). But my main poi

Re: [PHP-DEV] RFC: Stop to automatically cast numeric-string to int when using them as array-key

2022-01-07 Thread Vincent Langlet
> On 6 January 2022 07:29:58 GMT, James Titcumb wrote: > >Just thinking out loud, being able to identify an array type might be a > way > >forward here (using "syntax" already in use by static analysis tools in > >docblocks, for familiarity), e.g. > > > >private array $property; > > > >This might

Re: [PHP-DEV] RFC: Stop to automatically cast numeric-string to int when using them as array-key

2021-12-30 Thread Vincent Langlet
> It'd not be just a BC break, it'd be an absolutely massive BC break that > has a potential to break a ton of code and would be extremely hard to > detect. This is not something that should be changed in an advanced > version of the language. > Would you still consider this as a massive BC break

Re: [PHP-DEV] RFC: Stop to automatically cast numeric-string to int when using them as array-key

2021-12-29 Thread Vincent Langlet
> On 29/12/2021 16:58, Lynn wrote: > > While I'd love for this inconsistency to go away, I also know that this > is > > most likely such a big change that it causes months of work and broken > code > > because it relies on this behavior. It wouldn't surprise me if this > > singular change would cau

[PHP-DEV] RFC: Stop to automatically cast numeric-string to int when using them as array-key

2021-12-29 Thread Vincent Langlet
Hi, I recently discovered that an array was automatically casting numeric-string keys to int if it was possible. For instance, the following array: $a = ['01' => '01', '10' => '10']; Is not an array with the key '01' and '10' but instead consider the second key as an int. This has some implicat