note 112108 added to reflectionparameter.allowsnull

From: Date: Sun, 05 May 2013 15:53:10 +0000
Subject: note 112108 added to reflectionparameter.allowsnull
Groups: php.notes 
Request: Send a blank email to php-notes+get-194704@lists.php.net to get a copy of this message
The allowsNull method look if arguments have a type. If a type is defined, null is allowed only if default value is null. <?php function myfunction ( $param ) { } echo (new ReflectionFunction("myfunction"))->getParameters()[0]->allowsNull() ? "true":"false"; ?> Result : true <?php function myfunction ( stdClass $param ) { } echo (new ReflectionFunction("myfunction"))->getParameters()[0]->allowsNull() ? "true":"false"; ?> Result : false <?php function myfunction ( stdClass $param = null ) { } echo (new ReflectionFunction("myfunction"))->getParameters()[0]->allowsNull() ? "true":"false"; ?> Result : true ---- Server IP: 69.147.83.199 Probable Submitter: 83.156.93.26 ---- Manual Page -- http://php.net/manual/en/reflectionparameter.allowsnull.php Edit -- https://master.php.net/note/edit/112108 Del: integrated -- https://master.php.net/note/delete/112108/integrated Del: useless -- https://master.php.net/note/delete/112108/useless Del: bad code -- https://master.php.net/note/delete/112108/bad+code Del: spam -- https://master.php.net/note/delete/112108/spam Del: non-english -- https://master.php.net/note/delete/112108/non-english Del: in docs -- https://master.php.net/note/delete/112108/in+docs Del: other reasons-- https://master.php.net/note/delete/112108 Reject -- https://master.php.net/note/reject/112108 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#194704) next »