I have a class Table which exposes some properties via magic __get() and also provides array-like access, e.g $table['col1'] is instance of Column. Compact example:
$table = new Table();
// via magic getter
$table->readonly = false;
// $table['id'] returns Column object
$table['id']->readonly = true;
How can I document array elements to return Column? I have already doc for magic properties. I've tried to document offsetGet but it does not work, at least in PhpStorm. Example:
/**
* @property boolean $readonly
* NOTE offsetGet DOES NOT WORK
* @method Column offsetGet(string $offset)
*/
class Table implements \ArrayAccess {
}
/**
* @property boolean $readonly
*/
class Column {
}
I know how to document array variable or method return value, but adding such doc to each usage is not exactly what I'm looking for.
/** @var Table|array<string,Column> $table */
$table = new Table;
Edit: Seems the problem was in PhpStorm, it needed restart. Phpdoc for offsetGet() did the trick after all. Case closed.
