Skip to content

AbstractFilter::denormalizePropertyName return typing issue #6079

@Fabrn

Description

@Fabrn

API Platform version(s) affected: 3.2.7

Description

We had an issue poping from nowhere saying the following : "ApiPlatform\Doctrine\Orm\Filter\AbstractFilter::denormalizePropertyName(): Return value must be of type string, int returned". After some investigations : we fond out that the denormalizePropertyName gets a string|int parameter, returns a string, but returns the parameter, which can be an int, as we can see here :

protected function denormalizePropertyName(string|int $property): string
{
    if (!$this->nameConverter instanceof NameConverterInterface) {
        return $property;
    }
    return implode('.', array_map($this->nameConverter->denormalize(...), explode('.', (string) $property)));
}

How to reproduce

Sadly I don't know how it happened yet, thus I'm not able to reproduce it.

Possible Solution

Either :

  • Change return type to string|int
  • Do not accept int as a valid parameter

Additional context

ApiPlatform\Doctrine\Orm\Filter\AbstractFilter::denormalizePropertyName at line 83

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