IDE hints
cxj opened this issue · comments
It would be nice if the Model files output by this great package would include @mixin \Eloquent
as a one-line comment below the @property
comments it generates.
Example from one of my Models:
/**
* @property integer $id
* @property string $created_at
* @property string $updated_at
* @property string $table
* @property string $type
* @property boolean $enabled
* @mixin \Eloquent
*/
Then IDEs like PhpStorm will hint methods and attributes from e.g. query builders.
As I understood, these mixins are not part of Eloquent itself, but come from stand alone third party library. In that case including of this annotation should be optional. I don't think adding it to the library source code is necessary, though you can add it to your project by customising the library:
class MixinHintProcessor implements ProcessorInterface
{
public function process(EloquentModel $model, Config $config): void
{
$docBlock = $model->getDocBlock();
if ($docBlock === null) {
$docBlock = new DocBlockModel();
$model->setDocBlock($docBlock);
}
$docBlock->addContent('@mixin \Eloquent');
}
public function getPriority(): int
{
return 3;
}
}
Thank you very much for the reply! I agree with you; this seems to be better in a local customization. Thanks for the sample code.