{layout '@layout.latte'}

{block title}Class {$class->getName()}{/block}


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


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

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

    {if $class->getParentClass() || $class->getOwnInterfaces() || $class->getTraits()}
        <dl class="tree">
            <dd>
                {if $class->getParentClass()}
                    extends
                    <a href="{$class->getParentClass()|linkReflection}" n:class="$class->getParentClass()->isDeprecated() ? deprecated">
                        {$class->getParentClass()->getName()}
                    </a>
                {/if}

                {if $class->getOwnInterfaces()}
                    implements
                    {foreach $class->getOwnInterfaces() as $ownInterface}
                        <a href="{$ownInterface|linkReflection}" n:class="$ownInterface->isDeprecated() ? deprecated">
                            {$ownInterface->getName()}
                        </a>{sep}, {/sep}
                    {/foreach}
                {/if}

                {if $class->getTraits()}
                    uses
                    {foreach $class->getTraits() as $ownTrait}
                        <a href="{$ownTrait|linkReflection}" n:class="$ownTrait->isDeprecated() ? deprecated">{$ownTrait->getName()}</a>{sep}, {/sep}
                    {/foreach}
                {/if}
            </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 $class->getSubClasses()}
        <div>
            <h2>Known subclasses</h2>
            {include children, children => $class->getSubClasses()}
        </div>
    {/if}

    <div class="info">
        {if $class->isAbstract() || $class->isFinal()}<strong>{if $class->isAbstract()}Abstract{else}Final{/if}</strong><br>{/if}

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

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

    {foreach $class->getParentClasses() as $parentClass}
        <table class="summary table table-bordered table-responsive table-striped">
            <tr>
                <th>
                    Methods inherited from <a href="{$parentClass|linkReflection}#methods">{$parentClass->getName()}</a>
                </th>
            </tr>
            <tr>
                <td>
                    {foreach $parentClass->getOwnMethods() as $parentClassMethod}
                        <code>{block|strip}<a href="{$parentClassMethod|linkReflection}" n:class="$parentClassMethod->isDeprecated() ? deprecated">{$parentClassMethod->getName()}()</a>{/block}</code>{sep}, {/sep}
                    {/foreach}
                </td>
            </tr>
        </table>
    {/foreach}

    {foreach $class->getTraits() as $trait}
        <table class="summary table table-bordered table-responsive table-striped">
            <tr><th>Methods used from <a href="{$trait|linkReflection}#methods">{$trait->getName()}</a> trait</th></tr>
            <tr>
                <td>
                    <code>
                        {foreach $trait->getOwnMethods() as $traitMethod}
                            <a href="{$traitMethod|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() ? deprecated">{$alias->getName()}()</span>{sep}, {/sep}{/foreach}){/if}{sep}, {/sep}*}
                        {/foreach}
                    </code>
                </td>
            </tr>
        </table>
    {/foreach}

    {if $class->getOwnConstants()}
        <table class="summary table table-bordered table-responsive table-striped" id="constants">
            <tr><th colspan="3">Constants Summary</th></tr>
            {foreach $class->getOwnConstants() as $constant}
                {include "partial/constant.latte", constant => $constant}
            {/foreach}
        </table>
    {/if}

    {foreach $class->getParentClasses() as $parentClass}
        {if $parentClass->getOwnConstants()}
            <table class="summary table table-bordered table-responsive table-striped">
                <tr>
                    <th>
                        Constants inherited from <a href="{$parentClass|linkReflection}#constants">{$parentClass->getName()}</a>
                    </th>
                </tr>
                <tr>
                    {include "partial/parentConstant.latte", parentClassOrInterface => $parentClass}
                </tr>
            </table>
        {/if}
    {/foreach}

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

    {foreach $class->getParentClasses() as $parentClass}
        {if $parentClass->getOwnProperties()}
            <table class="summary table table-bordered table-responsive table-striped">
                <tr>
                    <th>
                        Properties inherited from <a href="{$parentClass|linkReflection}#properties">{$parentClass->getName()}</a>
                    </th>
                </tr>
                <tr>
                    <td>
                        {foreach $parentClass->getOwnProperties() as $parentClassProperty}
                            <code><a href="{$parentClassProperty|linkReflection}" n:class="$parentClassProperty->isDeprecated() ? deprecated, property-name">${$parentClassProperty->getName()}</a></code>{sep}, {/sep}
                        {/foreach}
                    </td>
                </tr>
            </table>
        {/if}
    {/foreach}

    {foreach $class->getTraits() as $trait}
        <table class="summary table table-bordered table-responsive table-striped">
            <tr>
                <th>Properties used from <a href="{$trait|linkReflection}#properties">{$trait->getName()}</a></th>
            </tr>
            <tr>
                <td>
                    <code>
                        {foreach $trait->getOwnProperties() as $property}
                            <a href="{$property|linkReflection}" n:class="property-name, $property->isDeprecated() ? deprecated">
                                ${$property->getName()}
                            </a>{sep}, {/sep}
                        {/foreach}
                    </code>
                </td>
            </tr>
        </table>
    {/foreach}
{/block}
