-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Closed
Labels
Description
This code dumps the correct $id
variable of type null
:
/**
* Show user
*
* @Route("/show/{id}", name="acme_user_show", defaults={"id"=null}, requirements={"id"="\d+"})
*/
public function showUserAction($id = null)
{
var_dump($id);
}
whereas the following code gives an $id
variable of type string string(4) "null"
/**
* Show user
*
*/
public function showUserAction($id = null)
{
var_dump($id);
}
<route id="acme_user_show" pattern="/show/{id}">
<default key="_controller">AcmeUserBundle:User:show</default>
<default key="id">null</default>
<requirement key="id">\d+</requirement>
</route>
I would assume the 2 to give similar results, is this normal?
Note: I visit the /showUser
path to test if $id
variable is null.