Skip to content

Instantly share code, notes, and snippets.

@havvg
Created July 18, 2013 15:36
Show Gist options
  • Save havvg/6030341 to your computer and use it in GitHub Desktop.
Save havvg/6030341 to your computer and use it in GitHub Desktop.
allow instantiation of optional typed parameter
<?php
class Foo
{
public function bar(Response $response = new Response())
{
// ..
}
// Instead of:
public function bar(Response $response = null)
{
if (null === $response) {
$response = new Response();
}
// ..
}
}
@havvg
Copy link
Author

havvg commented Jul 19, 2013

@adrienbrault Well, yes this won't work in that case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment