{layout '@layout.latte'}

{block title}Trait {$trait->getName()}{/block}


{block breadcrumbs}
    {include "partial/breadcrumbs.latte",
        "type" => "Trait",
        "namespace" => $trait->getNamespaceName(),
        "name" => $trait->getShortName()
    }
{/block}


{block content}
    <h1 n:class="$trait->isDeprecated() ? deprecated">{$trait->getShortName()}</h1>

    {if $trait->getDescription()}
        <div class="panel panel-default">
            <div class="panel-body">
                {$trait|description}
            </div>
        </div>
    {/if}

    {if $trait->getTraits()}
        <dl class="tree">
            <dd>
                uses
                {foreach $trait->getTraits() as $ownTrait}
                    <a href="{$ownTrait|linkReflection}" n:class="$ownTrait->isDeprecated() ? deprecated">{$ownTrait->getName()}</a>{sep}, {/sep}
                {/foreach}
            </dd>
        </dl>
    {/if}

    {define children}
        {foreach $children as $child}
            <a href="{$child|linkReflection}" n:class="$child->isDeprecated() ? deprecated">{$child->getName()}</a>{sep}, {/sep}
        {/foreach}
    {/define}

    {if $trait->getUsers()}
        <div>
            <h2>Known Users</h2>
            {include children, children => $trait->getUsers()}
        </div>
    {/if}

    <div class="info">
        {foreach $trait->getAnnotations() as $annotation}
            {$annotation|annotation: $trait|noescape}<br>
        {/foreach}
        <a href="{$trait|linkSource}" class="open-source-code">Open source code</a>
        <br>
    </div>

    {if $trait->getOwnMethods()}
        <table class="summary table table-responsive table-bordered table-striped" id="methods">
            <tr><th colspan="3">Methods Summary</th></tr>
            {foreach $trait->getOwnMethods() as $method}
                {include "partial/method.latte", method => $method}
            {/foreach}
        </table>
    {/if}

    <table n:foreach="$trait->getTraits() as $usedTrait" class="summary table table-responsive table-bordered table-striped">
        <tr><th>Methods used from <a href="{$usedTrait->getName()|linkReflection}#methods">{$usedTrait->getName()}</a> trait</th></tr>
        <tr>
            <td>
                <code>
                    {foreach $usedTrait->getOwnMethods() as $usedTraitMethod}
                        <a href="{$usedTraitMethod|linkReflection}" n:class="$traitMethod->isDeprecated() ? deprecated">{$traitMethod->getName()}()</a>
                        {* @todo *}
                        {*{if $data['aliases']}(as {foreach $data['aliases'] as $alias}<span n:class="$data['method']->isDeprecated() ? ldeprecated">{$alias->getName()}()</span>{sep}, {/sep}{/foreach}){/if}{sep}, {/sep}*}
                    {/foreach}
                </code>
            </td>
        </tr>
    </table>

    {if $trait->getOwnProperties()}
        <table class="summary table table-responsive table-bordered table-striped" id="properties">
            <tr><th colspan="3">Properties Summary</th></tr>
            {foreach $trait->getOwnProperties() as $property}
                {include "partial/property.latte", property => $property, classOrTrait => $trait}
            {/foreach}
        </table>
    {/if}
{/block}
