Issue: https://github.com/php/php-src/issues/12927
Author: mns-tftc
### Description
The following code:
```php
<?php
public static function get_brand_by_orders(array $orders): array
{
$count_by_brand = [];
foreach ($orders as $order) {
if (isset($count_by_brand[$order->get_brand()])) {
$count_by_brand[$order->get_game()]->qty++; // this is the line where script fail
Contract.php:588
} else {
$obj = new stdClass();
$obj->brand = $order->get_brand();
$obj->count = 1;
$count_by_brand[$order->get_brand()] = $obj;
}
}
return $count_by_brand;
```
Resulted in this output:
```
"message": "Call of
Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError() throws uncaught
ErrorException: \"Narrowing occurred during type inference of ZEND_FETCH_DIM_RW. Please file a
bug report on https://github.com/php/php-src/issues\"
in /var/www/deployhq/hellcase/releases/20231211063950/app/Models/Contract/Contract.php:588",
"exception": "ErrorException",
```
But I expected this output instead:
```
```
### PHP Version
PHP 8.2.13
### Operating System
Ubuntu 20.04