Describe the bug
No suggestions available for class with ArrayAccess returning object using Square brackets
Describe the eclipse environment
Eclipse PDT 8.1.0.202307051059
To Reproduce
Steps to reproduce the behavior:
Copy this code
#!/usr/bin/php
<?php
class ArrayNewObject
{
public $prop;
public function __construct($prop)
{
$this->prop = $prop;
}
}
class ArrayNewObjectCollection implements ArrayAccess
{
private $members;
/**
*
* {@inheritdoc}
* @see ArrayAccess::offsetGet()
*/
public function offsetGet(mixed $offset): ?ArrayNewObject
{
if (isset($this->members[$offset])) {
return $this->members[$offset];
} else {
return null;
}
}
public function offsetExists(mixed $offset): bool
{}
public function offsetUnset(mixed $offset): void
{}
public function offsetSet(mixed $offset, mixed $value): void
{
$this->members[$offset] = $value;
}
}
$array_new_collection = new ArrayNewObjectCollection();
$array_new_collection['my_key_1'] = new ArrayNewObject('Hello');
$array_new_collection['my_key_2'] = new ArrayNewObject('World');
2. Uncomment last line with "$array_new_collection['my_key_1']->"
3. Ctrl + Space at the end of this line
4. Search for "prop" property
**Expected behavior**
Suggestion: $array_new_collection['my_key_1']->prop
Describe the bug No suggestions available for class with ArrayAccess returning object using Square brackets
Describe the eclipse environment Eclipse PDT 8.1.0.202307051059
To Reproduce Steps to reproduce the behavior:
class ArrayNewObject {
}
class ArrayNewObjectCollection implements ArrayAccess {
}
$array_new_collection = new ArrayNewObjectCollection(); $array_new_collection['my_key_1'] = new ArrayNewObject('Hello'); $array_new_collection['my_key_2'] = new ArrayNewObject('World');
echo 'Short array access: ' . $array_new_collection['my_key_1']->prop . " " . $array_new_collection['my_key_2']->prop . PHP_EOL; echo 'Method array access: ' . $array_new_collection->offsetGet('my_key_1')->prop . " " . $array_new_collection->offsetGet('my_key_2')->prop . PHP_EOL;
//$array_new_collection['my_key_1']->