Closed
Description
Symfony version(s) affected
6.3, 6.4, 7.0
Description
MapQueryString attribute fails parsing string value for boolean type.
Problem is nicely described in this issue #42715
But in this case we know for sure that it's a string (just like the CSV and XML types in AbstractObjectNormalizer.php
Don't know if it's a bug or a feature.
How to reproduce
I expect the following to be false, but true is returned.
Request Url
https://example.com?myBoolean=false
DTO
<?php
readonly class MyDTO
{
public function __construct(
public bool $myBoolean
)
}
Controller
<?php
use Symfony\Component\HttpKernel\Attribute\MapQueryString;
use Symfony\Component\Routing\Annotation\Route;
class MyController
{
#[Route('/')]
public function __invoke(
#[MapQueryString]
MyDTO $dto
) {
dd($dto->myBoolean);
}
}
Possible Solution
No response
Additional Context
No response