Cannot pass null argument when using type hinting

The following code:

class Type {

}

function foo(Type $t) {

}

foo(null);

failed at run time:

PHP Fatal error: Argument 1 passed to foo() must not be null

Why is it not allowed to pass null just like other languages?

6 Answers
6

Leave a Comment