I know I can use PhpStorm annotations like this:
/**
* Class Model
* @property string name
*/
class Model {};
$modelInstance = new Model();
$modelInstance->name;
When I type $modelInstance->
PhpStorm will offer me "name" in autocomplete.
Is it possible to create custom property annotations for instances of classes?
/**
* Class Model
* @property string name
*/
class Model {};
/**
* @var Model $modelInstance @property text
*/
$modelInstance = new Model();
$modelInstance->text; //PhpStorm does not know about this property
I would like to have property "text" in PhpStorm autocomplete but ONLY for $modelInstance
. Not for every instance of class Model.
This is my solution based on LazyOne's opinion.
/**
*
* Class ZboziDibiRow
* @property int id
* @property string name
* @property string store
* @property string uri
* @property string manufacturer
* @property string description
* @property int price
* @property string ean
* @property string code
* @property int available_in
* @property string zbozi_category_id
* @property string category_recursive_id
*/
class ZboziDibiRow extends DibiRow
{
}
Now when I have something like:
/**
* @var ZboziDibiRow[]
*/
public $products;
I will get autocomplete for:
$zbozi = new Zbozi();
foreach ($zbozi->products as $key => $product) {
$product-> ....
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With