You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
bug #48346 [HttpKernel] In DateTimeValueResolver, convert previously defined date attribute to the expected class (GromNaN)
This PR was merged into the 6.1 branch.
Discussion
----------
[HttpKernel] In DateTimeValueResolver, convert previously defined date attribute to the expected class
| Q | A
| ------------- | ---
| Branch? | 6.1
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | Fix https://github.com/symfony/symfony/pull/48098/files#r1013997729
| License | MIT
Convert an instance of `DateTimeInterface` to the expected class if the value was predefined in the request attributes.
```php
# in a request listener
$request->attributes->set('date', new \DateTimeImmutable());
```
```php
class MyController
{
public function index(\DateTime $date)
{
// Use the $date
}
}
```
```
Uncaught TypeError: MyController::index(): Argument #1 ($date) must be of type DateTime, DateTimeImmutable given
```
Commits
-------
22a1567 Convert previously defined date attribute to the expected class
0 commit comments