[php-src] Issue #11670: Array key name strong type
| From: | Yurunsoft | Date: | Tue, 11 Jul 2023 05:41:27 +0000 |
| Subject: | [php-src] Issue #11670: Array key name strong type | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-244942@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/11670
Author: Yurunsoft
### Description
The key names of php arrays have no strong type support so far.
An integer string key is always considered an int.
**code:**
```php
<?php
declare(strict_types=1);
$arr = ['1' => 'a', 2 => 'b'];
var_dump($arr, array_keys($arr));
```
**output:**
```log
array(2) {
[1]=>
string(1) "a"
[2]=>
string(1) "b"
}
array(2) {
[0]=>
int(1)
[1]=>
int(2)
}
```
**excepted:**
```log
array(2) {
["1"]=>
string(1) "a"
[2]=>
string(1) "b"
}
array(2) {
[0]=>
string(1) "1"
[1]=>
int(2)
}
```