-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce syntax to autocomplete from docblock? #215
Comments
If I understood the question correctly, the format from phpstan and other linters does cover the union type and the string literal type, so following should work in the plugin: (unless some breaking change in modern IDE versions broke that) /**
* @param array<'className' | 'targetTable' | 'foreignKey' | 'dependent' | 'cascadeCallbacks' | 'conditions' | 'sort' | 'saveStrategy' | 'strategy' | 'finder', mixed> $options list of options to configure the association definition
*/
public function hasMany(string $associated, array $options = []): HasMany
{
$options['<completion should come up here>'] |
I mean from the outside, the using function of ->hasMany() Your code snippet does not seem to work. Only AI (tabinePro in my case) seems to sometimes guess the possible types correctly, but more like 20% of the time. |
That said
seems to work, but that makes the docblock line super loong, would be nice if there was a way outside of the param docblock line directly. |
When completion works it suppossedly works both inside and outside the One more way, specific to the plugin, is to express the type through a dummy function: function hasManyOptionsType()
{
return [
/** The class name of the target table object */
'className' => 'example value',
/** An instance of a table object to be used as the target table */
'targetTable' => 'example value',
/** The name of the field to use as foreign key, if false none will ve used */
'foreignKey' => 'example value',
// and so on
];
}
class Something()
{
/**
* @param $options = hasManyOptionsType()
*/
public function hasMany(string $associated, array $options = []): HasMany
{
$options['<completion should come up here>']
}
}
(new Something())->hasMany('ADmad/SocialAuth.SocialProfiles', [
'<completion should come up here too>'
]); |
Refs dereuromark/cakephp-ide-helper#346
Would be nice if we could use some kind of option keys list in the docblock to document all possible
array keys for assoc arrays.
So when someone types
it would autocomplete the
foreignKey
option right away.Or are there other ways of accomplishing this?
The method and its docblock currently reads as
If sth like this list is not formal enough, maybe we can find a syntax for it that is.
The text was updated successfully, but these errors were encountered: