For $item there's a polymorphic loggable relationship. In the database this is stored in items as loggable_type and loggable_id (for PHP 8+ in and Laravel).
for($items as $item) {
// ...
if ($item->loggable_type === Comment::class) {
$item->loggable->resetDates();
}
// ...
}
I'm trying to type hint that loggable within the condition is a Comment. I think I might be able to user @var but doing something like /* @var $item->loggable Comment */ doesn't work and I can't do /* @var $item Comment */ since that sets it to $item and not its property.
I'm thinking of changing the condition to if ($item->loggable instance of Comment), however I'd rather not since that requires loading and creating the Comment even if it's not used.
Is there a way to type hint $item->loggable as Comment?