Bug #76478 [Opn->Ver]: ReflectionParameter#allowsNull() returns false for indirect nullable decls

From: Date: Thu, 14 Jun 2018 17:30:43 +0000
Subject: Bug #76478 [Opn->Ver]: ReflectionParameter#allowsNull() returns false for indirect nullable decls
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-215728@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=76478&edit=1 ID: 76478 Updated by: cmb@php.net Reported by: daverandom@php.net Summary: ReflectionParameter#allowsNull() returns false for indirect nullable decls -Status: Open +Status: Verified Type: Bug Package: Reflection related Operating System: Any -PHP Version: >=5.5 +PHP Version: 7.1 Block user comment: N Private report: N New Comment: It's interesting that ::getDefaultValue() returns NULL in this case (<https://3v4l.org/R8WYD>), and that PHP < 5.6.4 didn't even allow this function definition (likely due to bug #68446). Previous Comments: ------------------------------------------------------------------------ [2018-06-14 16:39:10] daverandom@php.net Description: ------------ ReflectionParameter#allowsNull() return false for parameters where the nullability is inferred by a constant default value, where the constant has a value of NULL. https://3v4l.org/mUePZ Test script: --------------- <?php const DEFAULT_VALUE = null; function foo(\stdClass $arg = DEFAULT_VALUE) { var_dump($arg); } var_dump((new ReflectionFunction('foo'))->getParameters()[0]->allowsNull()); foo(null); Expected result: ---------------- bool(true) NULL Actual result: -------------- bool(false) NULL ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=76478&edit=1

« previous php.bugs (#215728) next »