Last active
November 3, 2015 00:13
-
-
Save krmgns/87bc8a671ec4ceab31c4 to your computer and use it in GitHub Desktop.
Spoofing PHP for default values with type-hint in functions/methods.
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 | |
function foo(bool $x = true) { var_dump($x); } | |
?> | |
Fatal error: Default value for parameters with a class type hint can only be NULL in /var/www/... on line 2 | |
<?php | |
// what the fuck? :) | |
define('None', ''); | |
define('True', true); | |
define('False', false); | |
function foo(bool $x = True) { var_dump($x); } | |
?> | |
// no error? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment