Prepare formatted trait array.

@param array $traits

@return array
764928
protected function prepareTraits(array $traits)
    {
        \natcasesort($traits);

        // My kingdom for a generator.
        $ret = [];

        foreach ($traits as $name) {
            if ($this->showItem($name)) {
                $ret[$name] = [
                    'name'  => $name,
                    'style' => self::IS_CLASS,
                    'value' => $this->presentSignature($name),
                ];
            }
        }

        return $ret;
    }
204239
protected function formatParameters(array $params)
    {
        $formatted = [];

        foreach ($params as $name => $value) {
            if (!in_array($name, ['member_count', 'room_limit', 'path', 'version_type'], true)) {
                continue;
            }

            if ('version_type' === $name && !in_array($value, ['develop', 'trial', 'release'], true)) {
                throw new InvalidArgumentException('Invalid value of attribute "version_type".');
            }

            $formatted[] = [
                'name' => $name,
                'value' => strval($value),
            ];
        }

        return $formatted;
    }
247458
protected function prepareAttributes(array $attributes)
    {
        $attributes['data-sitekey'] = $this->sitekey;
        if (!isset($attributes['class'])) {
            $attributes['class'] = '';
        }
        $attributes['class'] = trim('g-recaptcha ' . $attributes['class']);

        return $attributes;
    }
1357463
protected function getUsedTraits()
    {
        $reflection = new \ReflectionClass($this);
        $properties = $reflection->getProperties();
        $traits = [];
        foreach($properties as $property) {
            $name = $property->getName();
            if(substr($name, 0, 3) == 'has') {
                $traits[] = substr($name, 3);
            }
        }
        return $traits;
    }
1091896
public function getOwnMethods($filter = -1)
    {
        $return = $this->getMethods($filter);

        $traitMethods = $traitAliases = array();
        foreach ($this->getTraits() as $trait) {
            $traitAliases = array_merge($traitAliases, $this->getTraitAliases());
            foreach ($trait->getMethods($filter) as $method) {
                $traitMethods[] = $method->getName();
            }
        }

        $traitMethods = array_merge($traitMethods, array_keys($traitAliases));

        foreach ($return as $key => $val) {
            if ($val->class === $this->getName() && in_array($val->getName(), $traitMethods) === false) {
                $return[$key] = new ReflectionMethod($this->getName(), $val->getName());
            } else {
                unset($return[$key]);
            }
        }

        return array_values($return);
    }
434842
protected function prepareConstants(array $constants)
    {
        // My kingdom for a generator.
        $ret = [];

        $names = \array_keys($constants);
        \natcasesort($names);

        foreach ($names as $name) {
            if ($this->showItem($name)) {
                $ret[$name] = [
                    'name'  => $name,
                    'style' => self::IS_CONSTANT,
                    'value' => $this->presentRef($constants[$name]),
                ];
            }
        }

        return $ret;
    }
658504
protected function prepareParams(array $params)
    {
        foreach ($params as $key => $param) {
            if (gettype($param) === 'boolean') {
                $params[$key] = (string)(($param) ? 'true' : 'false');
            }
        }
        return $params;
    }
973232
private function prepareFields(array $fields)
    {
        $include = null;
        foreach ($fields as $key => $type) {
            $type = (bool) $type;
            if (null === $include) {
                $include = $type;
            }
            if ($type !== $include) {
                PersisterException::badRequest('Field projection mismatch. You cannot both exclude and include fields.');
            }
            $fields[$key] = $type;
        }
        return [$fields, $include];
    }
12941
protected function buildContext(array $properties)
    {
        $items = [];

        foreach ($properties as $key => $value) {
            $items[] = [
                    'Key' => $this->sanitizeString($key),
                    'Value' => $this->sanitizeString($value),
            ];
        }

        if (!$items) {
            return [];
        }

        return ['Entry' => $items];
    }
120828
private function loadClassTraits(array $classes)
    {
        $hierarchy = [];

        foreach ($classes as $class) {
            $traits = $this->loadTraits($class->getTraits());

            // Reverse the order of the traits list, (deepest becomes first as later traits overwrite).
            // And add them before the class (class overwrites traits).
            $hierarchy = array_merge($hierarchy, array_reverse($traits));
            $hierarchy[] = $class->name;
        }

        return $hierarchy;
    }
745441
public static function traits($class, $recursive=false, $autoload=true)
    {

        if (!$recursive) {
            return class_uses($class, $autoload);
        }

        $traits = [];

        // Collect the "use" statements in class and parent classes
        do {
            $traits = array_merge(class_uses($class, $autoload), $traits);
        } while ($class = get_parent_class($class));

        // Copy the found traits into an array we can alter
        $allTraits = $traits;

        foreach ($traits as $trait) {
            $allTraits += static::traitsOfTrait($trait);
        }

        return array_unique($allTraits);
    }
251603
public function generateFields(array $fields): array
    {
        $traitFqns = [];
        foreach ($fields as list($fieldFqn, $fieldType)) {
            try {
                $traitFqns[] = $this->fieldGenerator->generateField($fieldFqn, $fieldType);
            } catch (\Exception $e) {
                throw new \RuntimeException(
                    'Failed building field with $fieldFqn: ' . $fieldFqn . ' and $fieldType ' . $fieldType,
                    $e->getCode(),
                    $e
                );
            }
        }

        return $traitFqns;
    }
649549
public function prepareInsertFields(array $fields)
    {
        if ($this->isSortEnabled()) {
            $fields[$this->sortIndexFieldName] = $this->getMaxSortIndex() + 1;
        }
        
        return $fields;
    }
685851
protected function stdWrapValues(array $values)
    {
        $renderedValues = [];

        foreach ($values as $propertyName => $propertyInstruction)
        {
            $plainPropertyName = rtrim($propertyName, '.');
            if (!empty($propertyInstruction['children.'])) {
                $renderedValues[$plainPropertyName] = $this->stdWrapValues(
                    $propertyInstruction['children.']
                );
            } else {
                $renderedValues[$plainPropertyName] = $this->cObj->stdWrap(
                    '',
                    $propertyInstruction
                );
            }
        }

        return $renderedValues;
    }
117825
protected function createTrait($trait)
    {
        if($this->traitNameExists($trait) === true) {
            return $this->error('Trait already exists');
        }

        $this->createTraitDirectory();

        $this->createTraitFile($trait);
    }
425210
public function toArray()
    {
        // First, call the trait method before filtering
        // with Entity specific methods
        $attributes = $this->attributesToArray($this->attributes);

        foreach ($this->attributes as $key => $attribute) {
            if (in_array($key, $this->hidden)) {
                unset($attributes[$key]);
                continue;
            }
            if ($this->hasGetMutator($key)) {
                $method = 'get'.$this->getMutatorMethod($key);
                $attributes[$key] = $this->$method($attribute);
            }
        }

        return $attributes;
    }
218390
protected function prepareAttributes(array $attributes)
    {
        $attributesCollected = '';

        foreach ($attributes as $attribute => $value) {
            // Check value-less attributes to be embedded properly
            if ($value === null) {
                $attributesCollected .= ' '.$attribute;
            } else {
                $value = (is_array($value)) ? $value[0] : $value;
                $attributesCollected .= ' '.$attribute.'="'.$value.'"';
            }
        }

        return $attributesCollected;
    }