I have used an interface and a trait to fulfill the interface.
interface Attachable {
public function getAttachment();
public function setAttachment($attachment);
}
trait HasAttachment {
public $attachment = null;
public function getAttachment() {
return $this->attachment;
}
public function setAttachment($attachment) {
$this->attachment = $attachment;
}
}
class SomeClass implements Attachable {
use HasAttachment;
}
I need to unset the attachment in order to serialize and store the data. But when I try this, PHPStan shows error saying it is not a known property of Attachable
/** @var $data */
if ($data instanceof Attachable) {
unset($data->attachment); // PHPStan cries here
}
I need some way to make phpstan happy in this scenario.