Last active
August 29, 2015 14:08
-
-
Save pinepain/9a7755e8ce0d11082047 to your computer and use it in GitHub Desktop.
This file contains 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 | |
// http://php.net/manual/en/language.oop5.typehinting.php says that type-hinted PHP parameter | |
// that has no default value set to null can't be null. But are you sure? | |
// First, register error handler which do nothing and return nothing (this is important!) | |
set_error_handler(function () {}); | |
class SomeClass {} | |
function test(SomeClass $instance) {var_dump($instance);} | |
// NOTE: E_RECOVERABLE_ERROR (4096) occurs here | |
test(null); | |
// But what is this?! We have NULL in output! Are you surprised? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks all, I have a clue what's wrong with this code. This gist just shows weird behavior I met during debugging strange NULL value for typehinted argument.