Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Count constraint docblock causes psalm and phpstan fail on max 0 value #59307

Closed
@aguerre

Description

@aguerre

Symfony version(s) affected

7.2.0

Description

This PR #58049 affected psalm and phpstan validation on Count constraint use:

ERROR: InvalidArgument - src/XXXX/Model/MyModel.php:44:31 - Argument 1 of Symfony\Component\Validator\Constraints\Count::__construct expects int<1, max>|null, but 0 provided (see https://psalm.dev/004)
        new Assert\Count(max: 0),

With

    #[Assert\AtLeastOneOf([
        new Assert\Count(max: 0),
        new Assert\IsNull(),
        new AppAssert\IsValidSignature(),
    ])]
    private ?array $signature = [];

My $signature is an array of coordinates and can be empty for some frontend reasons.

How to reproduce

Use Count constraint with max : 0

Possible Solution

Change @param max dockblock to accept zero

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions