Closed
Description
Symfony version(s) affected
6.0.2
Description
I stumbled upon a TypeError: Cannot assign string to property App\Api\Model\Request\CoordsCheckerRequest::$latitude of type float
.
Browsing the code, I see there is a TypeError -> InvalidArgumentException wrapper:
https://github.com/symfony/symfony/blob/6.0/src/Symfony/Component/PropertyAccess/PropertyAccessor.php#L206-L217
Looks like another one should be added there.
How to reproduce
class CoordsCheckerRequest {
public float $longitude;
}
$accessor = new PropertyAccessor();
$request = new CoordsCheckerRequest();
$accessor->setValue($request, 'longitude', 'foo');
Possible Solution
if (preg_match('/^Cannot assign (\S+) to property \S+::\$\S+ of type (\S+)$/', $message, $matches)) {
[, $actualType, $expectedType] = $matches;
throw new InvalidArgumentException(sprintf('Expected argument of type "%s", "%s" given at property path "%s".', $expectedType, 'NULL' === $actualType ? 'null' : $actualType, $propertyPath), 0, $previous);
}
Additional Context
No response