Reputation: 2199
I have the following code:
$id = $ui->getWidget('import_id')->value;
I know the class type of $ui
. The getWidget()
method can return one or more types of widget classes based on the parameter passed in. Some of those widget classes have a value
parameter, and some don't.
If I want to add a doc hint to say "I know what this particular value of getWidget()
is returning", can I do that without splitting up my code? i.e. I know I can accomplish this by adding an intermediate variable, e.g.:
/** @var KnownClassWithValueProperty $idClass */
$idClass = $ui->getWidget('import_id');
$id = $idClass->value;
But ideally I'd like to not do this, but somehow type-hint the value of $ui->getWidget('import_id')
.
Thanks!
Upvotes: 0
Views: 33