Bug #79155 [NEW]: Wrong ReflectionType::allowsNull value with multiple property definition

From: Date: Wed, 22 Jan 2020 13:33:37 +0000
Subject: Bug #79155 [NEW]: Wrong ReflectionType::allowsNull value with multiple property definition
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-225044@lists.php.net to get a copy of this message
From: ondrej at mirtes dot cz Operating system: PHP version: 7.4.1 Package: Reflection related Bug Type: Bug Bug description:Wrong ReflectionType::allowsNull value with multiple property definition Description: ------------ When I define multiple properties within a single statement and a native typehint, ReflectionType reports wrong allowsNull(): private ?DateTimeImmutable $startDate, $endDate; Reproduction: https://3v4l.org/hITTk Related PHPStan issue: https://github.com/phpstan/phpstan/issues/2886 Test script: --------------- <?php declare(strict_types=1); final class CreateStatementRequest { private ?DateTimeImmutable $startDate, $endDate; } $ref = new \ReflectionClass(CreateStatementRequest::class); foreach ($ref->getProperties() as $refProperty) { var_dump($refProperty->getName()); $refType = $refProperty->getType(); var_dump($refType->getName()); var_dump($refType->allowsNull()); var_dump('---'); } Expected result: ---------------- string(9) "startDate" string(17) "DateTimeImmutable" bool(true) string(3) "---" string(7) "endDate" string(17) "DateTimeImmutable" bool(true) string(3) "---" Actual result: -------------- string(9) "startDate" string(17) "DateTimeImmutable" bool(true) string(3) "---" string(7) "endDate" string(17) "DateTimeImmutable" bool(false) string(3) "---" -- Edit bug report at https://bugs.php.net/bug.php?id=79155&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=79155&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=79155&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=79155&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=79155&r=needscript Try newer version: https://bugs.php.net/fix.php?id=79155&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=79155&r=support Expected behavior: https://bugs.php.net/fix.php?id=79155&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=79155&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=79155&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=79155&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=79155&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=79155&r=dst IIS Stability: https://bugs.php.net/fix.php?id=79155&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=79155&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=79155&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=79155&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=79155&r=mysqlcfg

« previous php.bugs (#225044) next »