Goetas\Xsd\XsdToPhp\Php\Structure\PHPClass::getPropertyInHierarchy PHP Method

getPropertyInHierarchy() public method

public getPropertyInHierarchy ( string $name ) : Goetas\Xsd\XsdToPhp\Php\Structure\PHPProperty
$name string
return Goetas\Xsd\XsdToPhp\Php\Structure\PHPProperty
    public function getPropertyInHierarchy($name)
    {
        if ($this->hasProperty($name)) {
            return $this->getProperty($name);
        }
        if ($this instanceof PHPClass && $this->getExtends() && $this->getExtends()->hasPropertyInHierarchy($name)) {
            return $this->getExtends()->getPropertyInHierarchy($name);
        }
        return null;
    }

Usage Example

Beispiel #1
0
 protected function isOneType(PHPClass $type, $onlyParent = false)
 {
     if ($onlyParent) {
         $e = $type->getExtends();
         if ($e) {
             if ($e->hasProperty('__value')) {
                 return $e->getProperty('__value');
             }
         }
     } else {
         if ($type->hasPropertyInHierarchy('__value') && count($type->getPropertiesInHierarchy()) === 1) {
             return $type->getPropertyInHierarchy("__value");
         }
     }
 }