# Type Hints with Null

- Thread: https://externals.io/message/19482
- Original archive: https://news-web.php.net/php.internals/19482
- Started by Derick Rethans on 2005-10-07T20:29:51+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #19482 — Derick Rethans — 2005-10-07T20:29:51+00:00

URL: https://externals.io/message/19482#19482

Hello,

attached is a patch (by Markus) that allows you to make typehints 
optionally take `NULL` as default value too, f.e.:

class P { }
class T {
    function f(P $p = NULL) {
        var_dump($p);
    }
}

$o=new T();
$o->f(new P);
$o->f(NULL);
$o->f();

I would like to commit this patch to HEAD pending any objections.

regards,
Derick

-- 
Derick Rethans
http://derickrethans.nl | http://ez.no | http://xdebug.org

---

## #19484 — dz@bitxtender.com — 2005-10-07T20:36:45+00:00

URL: https://externals.io/message/19482#19484 · In reply to: #19482

Lovely.

- David


> -----Original Message-----
> From: Derick Rethans [mailto:derick@php.net]
> Sent: Friday, October 07, 2005 10:30 PM
> To: PHP Developers Mailing List
> Subject: [PHP-DEV] Type Hints with Null
> 
> Hello,
> 
> attached is a patch (by Markus) that allows you to make typehints
> optionally take `NULL` as default value too, f.e.:
> 
> class P { }
> class T {
>     function f(P $p = NULL) {
>         var_dump($p);
>     }
> }
> 
> $o=new T();
> $o->f(new P);
> $o->f(NULL);
> $o->f();
> 
> I would like to commit this patch to HEAD pending any objections.
> 
> regards,
> Derick
> 
> --
> Derick Rethans
> http://derickrethans.nl | http://ez.no | http://xdebug.org
