<?php
class X extends ArrayObject{
public function offsetSet($key, $val){
echo "offsetSet called \n";
parent::offsetSet($key, $val);
}
}
$arr = new X([]);
$arr->append('val');
$arr->offsetSet(5, 'val');
$arr->append('app');
print_r($arr);
Deprecated: Return type of X::offsetSet($key, $val) should either be compatible with ArrayObject::offsetSet(mixed $key, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/sGhkT on line 4
offsetSet called
offsetSet called
offsetSet called
X Object
(
[storage:ArrayObject:private] => Array
(
[0] => val
[5] => val
[6] => app
)
)
Parse error: syntax error, unexpected '[', expecting ')' in /in/sGhkT on line 10
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[', expecting ')' in /in/sGhkT on line 10
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/sGhkT on line 4
Process exited with code 255.
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/sGhkT on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/sGhkT on line 4
Process exited with code 255.