Open dereuromark opened 9 months ago
Maybe a custom IDE plugin could help? With e.g. similar syntax for array shapes PHPStan/Psalm use?
* @param array{
* className: string,
* targetTable: string,
* foreignKey: string,
* webroot: string,
* dependent: bool,
* cascadeCallbacks: bool,
* conditions: array,
* sort: array,
* saveStrategy: string,
* finder: string,
* sourceTable: string
* } $options List of options to configure the association definition
*/
public function hasMany(string $associated, array $options = []): HasMany
seems to work for autocomplete, but that list makes it finite in options afaik, and there could always be more (valid) keys. That syntax doesnt then quite work I guess.
It also makes the docblock line super loong, Would be nice if there was a way outside of the param docblock line directly.
Also, PHPStan doesnt like it:
1161 Default value of the parameter # 2 $options (array{}) of method Cake\ORM\Table::hasMany() is incompatible with type array{className: string, targetTable: string, foreignKey: string, webroot: string, dependent: bool,
cascadeCallbacks: bool, conditions: array, sort: array, ...}.
💡 Array does not have offset 'className'.
Any idea on how to allow IDE (PHPStorm?) to autocomplete the 2nd arg for options array, the keys?
These are the possible keys per type: