I'm encountering an issue with PHP Hammer's static analysis, which flags an inspection error: "native type must not be used as object" when referencing a Laravel model object in factory methods. This warning appears even when the code is valid and functions as expected. It seems specific to factory methods that use model references, although it could potentially happen in other places.
Example Code
class CompanyFactory extends Factory
{
public function forCompany(Company $company): self
{
return $this->state([
'company_id' => $company->id, // Inspection error here for $company
]);
}
}
Description
I'm encountering an issue with PHP Hammer's static analysis, which flags an inspection error: "native type must not be used as object" when referencing a Laravel model object in factory methods. This warning appears even when the code is valid and functions as expected. It seems specific to factory methods that use model references, although it could potentially happen in other places.
Example Code