Skip to content

Autogenerated id column should be positive-int #567

@ghost

Description

I want to mark a Doctrine entity $id field that is autogenerated by database engine as @var positive-int. However PHPStan complains.

class Entity
{
    /**
     * @var positive-int|null
     */
    #[ORM\Column(type: 'integer', options: ['unsigned' => true])]
    #[ORM\Id]
    #[ORM\GeneratedValue(strategy: 'IDENTITY')]
    private ?int $id;
}

PHPStan output:
Property App\Rma\Domain\Rma\Rma::$id type mapping mismatch: database can contain int but property expects int<1, max>|null.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions