How can I avoid this "error":
Basically docblocks for DataObject::get_one
says that it returns a DataObject
, which is true, but most of the time it is a class that extends DataObject - e.g. class HealthCheck extends DataObject
in this case.
If I write:
/** @var HealthCheck|null */
$a = DataObject::get_one(HealthCheck::class, ['Published' => true]);
return $a;
then scrutiziner does not give me an error but I do want / and can not to write it like this.
We can do the following: