<?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, some magic!
function custom_error_handler($level, $message, $file = '', $line = 0, $context = array())
{
if (error_reporting() & $level)
{
throw new Exception($message, 0, $level, $file, $line);
}
}
set_error_handler('custom_error_handler');
error_reporting(0); // Yeah, not the best solution
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?