Hello again, While reviewing the implementation Nikita spotted a peculiar behaviour that PHP currently has in regards to string offsets. The offset is validated using the is_numeric_string but integer representation of it is computed using an explicit int cast, this is what leads to the E_NOTICE in a roundabout way.
Therefore, a string offset access such as $str['2str'] or $str['2.5'] would still evaluate to 2 under the current implementation but would generate an E_WARNING "Illegal string offset". The question becomes should such string offsets evaluate to 0 or not. The answer isn't that straight forward as a float index like 14.5 would also emit the same warning but evaluate to 14. I see 3 options: 1. Keep the current behaviour which emit the E_WARNING "Illegal string offset" and use the explicit int cast for both types of offsets ( '2str' and '2.5'), which would bring the behaviour of leading integer numeric strings in line with the one for float numeric strings. 2. Emit the E_WARNING "Illegal string offset" and evaluate to 0 for offsets like '2str', and emit the E_WARNING "String offset cast occurred" for float numeric strings like '2.5' 3. Emit the E_WARNING "Illegal string offset" and evaluate to 0 for non-numeric integer strings. As this is relatively tricky and all of the options have some change in behaviour compared to PHP 7 feedback would be very much appreciated. I'll amend the RFC to detail this behaviour. Best regards George P. Banyard