Created
February 14, 2014 10:32
-
-
Save pocky/8998956 to your computer and use it in GitHub Desktop.
Pseudo-Named Argument in PHP (this is a bad idea because you loose type hinting)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Foo { | |
public static function getBar($args) | |
{ | |
$args += [ | |
'foo' => null, | |
'bar' => false, | |
'baz' => null | |
]; | |
extract($args); | |
//... | |
} | |
} | |
Foo::getBar(['foo' => 'foo']); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment