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!
$uibased on, with agetWidgetForBlahBlah(), and set the return value for that. Obviously this doesn't scale well, but you do get the added benefit of runtime type enforcement by PHP at least.