BetterReflectionTest\Reflection\ReflectionClassTest::testAddProperty PHP Метод

testAddProperty() публичный Метод

public testAddProperty ( )
    public function testAddProperty()
    {
        $php = '<?php
            class Foo {
            }
        ';
        $reflection = (new ClassReflector(new StringSourceLocator($php)))->reflect('Foo');
        $this->assertFalse($reflection->hasProperty('bar'));
        $reflection->addProperty('publicBar', \ReflectionProperty::IS_PUBLIC);
        $this->assertTrue($reflection->hasProperty('publicBar'));
        $this->assertTrue($reflection->getProperty('publicBar')->isPublic());
        $reflection->addProperty('protectedBar', \ReflectionProperty::IS_PROTECTED);
        $this->assertTrue($reflection->hasProperty('protectedBar'));
        $this->assertTrue($reflection->getProperty('protectedBar')->isProtected());
        $reflection->addProperty('privateBar', \ReflectionProperty::IS_PRIVATE);
        $this->assertTrue($reflection->hasProperty('privateBar'));
        $this->assertTrue($reflection->getProperty('privateBar')->isPrivate());
        $reflection->addProperty('staticBar', \ReflectionProperty::IS_PUBLIC, true);
        $this->assertTrue($reflection->hasProperty('staticBar'));
        $this->assertTrue($reflection->getProperty('staticBar')->isStatic());
    }
ReflectionClassTest