core icon indicating copy to clipboard operation
core copied to clipboard

AbstractFilter::denormalizePropertyName return typing issue

Open Fabrn opened this issue 1 year ago • 2 comments

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

Fabrn avatar Jan 03 '24 14:01 Fabrn

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Mar 03 '24 15:03 stale[bot]

to fix: cast as string

soyuka avatar Mar 07 '24 08:03 soyuka