Skip to content

Commit

Permalink
Update templating.rst
Browse files Browse the repository at this point in the history
- parameter $year is typed with integer. date function returns string. Code works but casting to the right type feels better.
- added missing import to fix TypeError "Argument symfony#1 ($request) must be of type Request"
  • Loading branch information
staatzstreich authored Oct 23, 2023
1 parent 5cb6a81 commit 551e2d4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion create_framework/templating.rst
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,14 @@ framework does not need to be modified in any way, create a new
``app.php`` file::

// example.com/src/app.php
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing;

function is_leap_year(int $year = null): bool
{
if (null === $year) {
$year = date('Y');
$year = (int)date('Y');
}

return 0 === $year % 400 || (0 === $year % 4 && 0 !== $year % 100);
Expand Down

0 comments on commit 551e2d4

Please sign in to comment.