Skip to content

Commit 916a5c0

Browse files
staatzstreichxabbuh
authored andcommitted
Update templating.rst
- 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 #1 ($request) must be of type Request"
1 parent 8e56130 commit 916a5c0

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

create_framework/templating.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,14 @@ framework does not need to be modified in any way, create a new
142142
``app.php`` file::
143143

144144
// example.com/src/app.php
145+
use Symfony\Component\HttpFoundation\Request;
145146
use Symfony\Component\HttpFoundation\Response;
146147
use Symfony\Component\Routing;
147148

148149
function is_leap_year($year = null)
149150
{
150151
if (null === $year) {
151-
$year = date('Y');
152+
$year = (int)date('Y');
152153
}
153154

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

0 commit comments

Comments
 (0)