PHP documentation for conditional polymorphic calls
<p>For $item, there is a polymorphic recordable relationship. In the database, this is stored in the loggable_type and loggable_id fields in the items table (for PHP 8 and Laravel). </p>
<pre class="brush:php;toolbar:false;">for($items as $item) {
// ...
if ($item->loggable_type === Comment::class) {
$item->loggable->resetDates();
}
// ...
}
</pre>
<p>I'm trying to type-hint a loggable in a condition, specifying it as a Comment type. I tried using @var, but writing it like /* @var $item->loggable Comment */ doesn't work, and I can't use /* @var $item Comment */ because that sets the type hint for $item rather than its properties.