PHPSA\Definition\ClassDefinition::getProperty PHP Method

getProperty() public method

public getProperty ( string $name, boolean $inherit = false ) : PhpParser\Node\Stmt\PropertyProperty
$name string
$inherit boolean
return PhpParser\Node\Stmt\PropertyProperty
    public function getProperty($name, $inherit = false)
    {
        assert($this->hasProperty($name, $inherit));
        if (isset($this->properties[$name])) {
            return $this->properties[$name];
        }
        if ($inherit && $this->extendsClassDefinition) {
            return $this->extendsClassDefinition->getProperty($name, true);
        }
        return null;
    }

Usage Example

Example #1
0
 /**
  * @param string $name
  * @param bool $inherit
  * @return Node\Stmt\PropertyProperty
  */
 public function getProperty($name, $inherit = false)
 {
     assert($this->hasProperty($name, $inherit));
     if (isset($this->properties[$name])) {
         return $this->properties[$name];
     }
     if ($inherit && $this->extendsClassDefinition) {
         return $this->extendsClassDefinition->getProperty($name, true);
     }
     return null;
 }