[PHP-BUG] Req #78640 [NEW]: Add method allowsNull to ReflectionProperty

[email protected] ("alan at aondra dot com") Mon, 07 Oct 2019 12:35:15 +0000
Newsgroups php.standards
Message-ID <[email protected]>
From:             alan at aondra dot com
Operating system: 
PHP version:      7.4.0RC3
Package:          PHP Language Specification
Bug Type:         Feature/Change Request
Bug description:Add method allowsNull to ReflectionProperty

Description:
------------
With the introduction of typed class properties, there is also the
nullable flag represented as a question mark, for example:

    class Foo
    {
        public ?string $bar;
    }

In keeping with the naming convention in ReflectionParameter and
ReflectionType, the request is to also include a method with this name
in the ReflectionProperty.

Test script:
---------------
class Foo
{
    public ?string $bar;
    public string $baz;
}

$barMeta = new ReflectionProperty(Foo::class, 'bar');
$bazMeta = new ReflectionProperty(Foo::class, 'baz');

var_dump( $barMeta->allowsNull() );
var_dump( $bazMeta->allowsNull() );


Expected result:
----------------
true
false


-- 
Edit bug report at https://bugs.php.net/bug.php?id=78640&edit=1
-- 
Fix committed:                    https://bugs.php.net/fix.php?id=78640&r=fixed
Fixed in release:                 https://bugs.php.net/fix.php?id=78640&r=alreadyfixed
Need backtrace:                   https://bugs.php.net/fix.php?id=78640&r=needtrace
Need Reproduce Script:            https://bugs.php.net/fix.php?id=78640&r=needscript
Try newer version:                https://bugs.php.net/fix.php?id=78640&r=oldversion
Not developer issue:              https://bugs.php.net/fix.php?id=78640&r=support
Expected behavior:                https://bugs.php.net/fix.php?id=78640&r=notwrong
Not enough info:                  https://bugs.php.net/fix.php?id=78640&r=notenoughinfo
Submitted twice:                  https://bugs.php.net/fix.php?id=78640&r=submittedtwice
register_globals:                 https://bugs.php.net/fix.php?id=78640&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=78640&r=phptooold
Daylight Savings:                 https://bugs.php.net/fix.php?id=78640&r=dst
IIS Stability:                    https://bugs.php.net/fix.php?id=78640&r=isapi
Install GNU Sed:                  https://bugs.php.net/fix.php?id=78640&r=gnused
Floating point limitations:       https://bugs.php.net/fix.php?id=78640&r=float
No Zend Extensions:               https://bugs.php.net/fix.php?id=78640&r=nozend
MySQL Configuration Error:        https://bugs.php.net/fix.php?id=78640&r=mysqlcfg