Skip to content

Instantly share code, notes, and snippets.

@krmgns
Last active November 3, 2015 00:13
Show Gist options
  • Save krmgns/87bc8a671ec4ceab31c4 to your computer and use it in GitHub Desktop.
Save krmgns/87bc8a671ec4ceab31c4 to your computer and use it in GitHub Desktop.
Spoofing PHP for default values with type-hint in functions/methods.
<?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