Return an array of traits that the class implements.

@return string[]
422666
public function traits() {
        $traits = $this->reflection()->getTraitNames();
        $parent = get_parent_class($this->_class);

        while ($parent) {
            $traits = array_merge($traits, class_uses($parent));
            $parent = get_parent_class($parent);
        }

        return array_values($traits);
    }
704429
protected function traitsInit()
    {
        $traits = $this->getUsedTraits();
        $reflection = new \ReflectionClass($this);
        foreach($traits as $trait) {
            $methodName = 'initTrait' . $trait;
            if($reflection->hasMethod($methodName)) {
                $this->$methodName();
            }
        }
    }
359159
public function getInspectionData()
    {
        return [
            static::PARAM_CLASSES    => $this->declaredClasses,
            static::PARAM_INTERFACES => $this->declaredInterfaces,
            static::PARAM_TRAITS     => $this->declaredTraits,
            static::PARAM_FUNCTIONS  => $this->declaredFunctions,
            static::PARAM_CONSTANTS  => $this->declaredConstants,
        ];
    }
223656
public function behaviors()
    {
        return [
            'blameable' => [
                'class' => BlameableBehavior::className(),
                'createdByAttribute' => 'createdBy',
                'updatedByAttribute' => 'updatedBy',
            ],
            'timestamp' => [
                'class' => TimestampBehavior::className(),
                'attributes' => [
                    ActiveRecord::EVENT_BEFORE_INSERT => ['createdAt'],
                    ActiveRecord::EVENT_BEFORE_UPDATE => ['updatedAt']
                ]
            ],
            'purify' => [
                'class' => PurifyBehavior::className(),
                'attributes' => ['content']
            ]
        ];
    }
690813
protected static function getConstants(): array
    {
        $calledClass = get_called_class();

        if (!array_key_exists($calledClass, static::$constCacheArray)) {
            $reflect = new ReflectionClass($calledClass);
            static::$constCacheArray[$calledClass] = $reflect->getConstants();
        }

        return static::$constCacheArray[$calledClass];
    }
920296
private function traitAdaptation() {
    /** @var NameNode $qualified_name */
    $qualified_name = $this->name();
    if ($qualified_name->childCount() === 1 && $this->currentType !== T_DOUBLE_COLON) {
      return $this->traitAlias($qualified_name);
    }
    $node = new TraitMethodReferenceNode();
    $node->addChild($qualified_name, 'traitName');
    $this->mustMatch(T_DOUBLE_COLON, $node);
    $this->mustMatch(T_STRING, $node, 'methodReference', TRUE);
    if ($this->currentType === T_AS) {
      return $this->traitAlias($node);
    }
    $method_reference_node = $node;
    $node = new TraitPrecedenceNode();
    $node->addChild($method_reference_node, 'traitMethodReference');
    $this->mustMatch(T_INSTEADOF, $node);
    $trait_names = new CommaListNode();
    do {
      $trait_names->addChild($this->name());
    } while ($this->tryMatch(',', $trait_names));
    $node->addChild($trait_names, 'traitNames');
    $this->endStatement($node);
    return $node;
  }
992200
public function getConstants(): array
    {
        // Check cache.
        if (null === $this->constants) {
            $tokens          = $this->getTokenStream();
            $this->constants = [];

            // Fetch start of class so we do not
            // include use statements that import traits.
            $class = $this->getClassNameLocation();

            // Find all the use statements and parse them one by one
            // and then add them to the use_statements cache.
            $loc = 0;
            while (($loc = $tokens->scan($loc, [T_CONST])) && $loc < $class) {
                $this->constants[] = $this->parseConst($loc++);
            }
        }

        return $this->constants;
    }
583503
public function getEmbeddableProperties(): array
    {
        if (null !== $this->embeddableProperties) {
            return $this->embeddableProperties;
        }
        $traits = $this->reflectionClass->getTraits();
        $return = [];
        foreach ($traits as $traitName => $traitReflection) {
            if (\ts\stringContains($traitName, '\\Entity\\Embeddable\\Traits')) {
                $property                     = $traitReflection->getProperties()[0]->getName();
                $embeddableObjectInterfaceFqn = $this->getTypesFromVarComment(
                    $property,
                    $this->getReflectionHelper()->getTraitProvidingProperty($traitReflection, $property)
                )[0];
                $embeddableObject             = $this->getNamespaceHelper()
                                                     ->getEmbeddableObjectFqnFromEmbeddableObjectInterfaceFqn(
                                                         $embeddableObjectInterfaceFqn
                                                     );
                $return[$property]            = $embeddableObject;
            }
        }

        return $return;
    }
729600
function &traits()
    {
        $traits = NULL;
        foreach ($this->_classes as $name => $trait) {
            if ($trait->isTrait()) {
                $traits[$name] =& $this->_classes[$name];
            }
        }

        return $traits;
    }
1139771
protected static function define_properties() {
        return [
            'id' => [
                'type' => PARAM_INT,
                'description' => 'Badge id',
            ],
            'name' => [
                'type' => PARAM_TEXT,
                'description' => 'Badge name',
            ],
            'version' => [
                'type' => PARAM_TEXT,
                'description' => 'Version',
                'optional' => true,
                'null' => NULL_ALLOWED,
            ],
            'language' => [
                'type' => PARAM_NOTAGS,
                'description' => 'Language',
                'optional' => true,
                'null' => NULL_ALLOWED,
            ],
            'type' => [
                'type' => PARAM_INT,
                'description' => 'Type',
                'optional' => true,
            ],
        ];
    }
572156
public function getConfig(): array
    {
        $ref = new \ReflectionClass(get_class($this));
        $properties = $ref->getProperties();
        $config = [];

        //set default values
        foreach ($properties as $property) {
            $value = $property->getValue($this);
            if (null !== $value) {
                $config[Inflector::tableize($property->getName())] = $property->getValue($this);
            }
        }

        return $config;
    }
298186
public function getTraitsOfClass($class)
    {
        $definitions = [];

        // in case there is a hierarchy of classes
        $classes = $this->getSuperClasses($class);
        if (is_array($classes)) {
            foreach ($classes as $subClass) {
                if (isset($subClass['traits'])) {
                    foreach ($subClass['traits'] as $classTrait) {
                        foreach ($this->traits as $trait) {
                            if ($classTrait === $trait['trait']) {
                                $traitDefinition[$trait['trait']] = $trait;
                                $definitions = array_merge($definitions, $traitDefinition);
                            }
                        }
                    }
                }
            }
        }

        // trait used by the given class
        $classDefinition = isset($this->classes[$class]) ? $this->classes[$class] : null;
        if (!$classDefinition || empty($classDefinition['traits'])) {
            return $definitions;
        }
        $classTraits = $classDefinition['traits'];
        foreach ($this->traits as $trait) {
            foreach ($classTraits as $classTrait => $name) {
                if ($trait['trait'] === $name) {
                    $traitDefinition[$name] = $trait;
                    $definitions = array_merge($definitions, $traitDefinition);
                }
            }
        }

        return $definitions;
    }
678950
public function getAttributes()
    {
        return [
            'name'        => $this->name,
            'shortcut'    => $this->shortcut,
            'mode'        => $this->mode,
            'description' => $this->description,
            'default'     => $this->default,
        ];
    }
107711
public function getRequiredRelationProperties(): array
    {
        if (null !== $this->requiredRelationProperties) {
            return $this->requiredRelationProperties;
        }
        $traits = $this->reflectionClass->getTraits();
        $return = [];
        foreach ($traits as $traitName => $traitReflection) {
            if (false === \ts\stringContains($traitName, '\\HasRequired')) {
                continue;
            }
            if (false === \ts\stringContains($traitName, '\\Entity\\Relations\\')) {
                continue;
            }

            $property          = $traitReflection->getProperties()[0]->getName();
            $return[$property] = $this->getTypesFromVarComment(
                $property,
                $this->getReflectionHelper()->getTraitProvidingProperty($traitReflection, $property)
            );
        }
        $this->requiredRelationProperties = $return;

        return $return;
    }
1255733
protected function _traitNode()
    {
        $this->_codeNode();

        $token = $this->_stream->current(true);
        $body = $token[1];
        $body .= $this->_stream->skipWhitespaces();
        $body .= $name = $this->_stream->current();
        $body .= $this->_stream->next([';', '{']);
        $this->_states['body'] .= $body;
        $node = new BlockDef($body, 'trait');
        $node->name = $name;
        return $this->_states['current'] = $this->_contextualize($node);
    }
1331059
public function standardFeatures(): array
    {
        return [
            'stdout.ansi' => function () {
                // @codeCoverageIgnoreStart
                if (DIRECTORY_SEPARATOR === '\\') {
                    return
                        0 >= version_compare(
                        '10.0.10586',
                        PHP_WINDOWS_VERSION_MAJOR .
                            '.' . PHP_WINDOWS_VERSION_MINOR .
                            '.' . PHP_WINDOWS_VERSION_BUILD
                        ) ||
                        false !== getenv('ANSICON') ||
                        'ON' === getenv('ConEmuANSI') ||
                        'xterm' === getenv('TERM') ||
                        false !== getenv('BABUN_HOME');
                }
                // @codeCoverageIgnoreEnd

                return function_exists('posix_isatty') && @posix_isatty(STDOUT);
            },

            'type.object' => function () {
                try {
                    $function =
                        new ReflectionFunction(function (object $a) {});
                    $parameters = $function->getParameters();
                    $result = null === $parameters[0]->getClass();
                    // @codeCoverageIgnoreStart
                } catch (ReflectionException $e) {
                    $result = false;
                }
                // @codeCoverageIgnoreEnd

                return $result;
            },
        ];
    }
583636
private function getMethods(): array
    {
        $tests = [];
        $methods = $this->refl->getMethods(\ReflectionMethod::IS_PUBLIC);
        foreach ($methods as $method) {
            $hasTestName = preg_match(self::$testName, $method->getName());
            $docComment = $method->getDocComment();
            $hasTestAnnotation = false !== $docComment && preg_match(self::$testAnnotation, $docComment);
            $isTestMethod = $hasTestName || $hasTestAnnotation;
            if ($isTestMethod) {
                $tests[] = new ParsedFunction((string) $method->getDocComment(), 'public', $method->getName());
            }
        }

        return $tests;
    }