hammer-tools / php-hammer

PHP Hammer is an inspections and tools plugin compatible with Intellij IDEA / PhpStorm.
Apache License 2.0
96 stars 3 forks source link

"PHP Hammer: native type must not be used as object" Inspection Error when Referencing Model as Object in Factories #65

Open andrewdwallo opened 2 months ago

andrewdwallo commented 2 months ago

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


class CompanyFactory extends Factory
{
    public function forCompany(Company $company): self
    {
        return $this->state([
            'company_id' => $company->id, // Inspection error here for $company
        ]);
    }
}
andrewdwallo commented 1 month ago

@rentalhost Any updates on this?