The expression return $this->key could return the type Doctrine\Annotations\Par...arser\Ast\ConstantFetch which is incompatible with the type-hinted return Doctrine\Annotations\Parser\Ast\Value|null. Consider adding an additional type-check to rule them out.