Zend\Code\Scanner\ClassScanner::getTraits PHP Method

getTraits() public method

Retrieve any traits used by the class.
public getTraits ( ) : ClassScanner[]
return ClassScanner[]
    public function getTraits()
    {
        if (!empty($this->traits)) {
            return $this->traits;
        }
        // get list of trait names
        $traitNames = $this->getTraitNames();
        foreach ($traitNames as $traitName) {
            $r = new ReflectionClass($traitName);
            if (!$r->isTrait()) {
                throw new Exception\RuntimeException(sprintf('Non-trait class detected as a trait: %s', $traitName));
            }
            $fileName = $r->getFileName();
            $file = new FileScanner($fileName);
            $this->traits[] = $file->getClass($traitName);
        }
        return $this->traits;
    }