From 24b5f36f7e0f1f6b80467330a7f41b502d464272 Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Sat, 2 Nov 2019 14:09:17 +0200 Subject: [PATCH] Templates cleanup --- Library/Documentation/Template.php | 18 +++--- templates/Api/themes/api-base/class.phtml | 2 +- templates/Api/themes/api-base/classes.phtml | 2 +- templates/Api/themes/api-base/index.phtml | 2 +- templates/Api/themes/api-base/namespace.phtml | 2 +- .../Api/themes/api-base/namespaces.phtml | 2 +- templates/Api/themes/api-base/source.phtml | 2 +- .../Api/themes/zephir/layout/layout.phtml | 6 +- .../partials/class/method-summary.phtml | 2 +- .../Api/themes/zephir/partials/index.phtml | 24 ++++---- .../zephir/partials/namespace/content.phtml | 55 ++++++++++--------- .../partials/namespace/method-details.phtml | 18 ++---- .../partials/namespace/method-summary.phtml | 36 +++++------- .../themes/zephir/partials/namespaces.phtml | 26 +++++---- .../Api/themes/zephir/partials/source.phtml | 39 ++++++++----- 15 files changed, 118 insertions(+), 118 deletions(-) diff --git a/Library/Documentation/Template.php b/Library/Documentation/Template.php index 8faae8d0d2..8752f71a8e 100644 --- a/Library/Documentation/Template.php +++ b/Library/Documentation/Template.php @@ -33,14 +33,14 @@ class Template /** * Template constructor. * - * @param Theme $theme - * @param $data - * @param $template - * @param int $nestedLevel + * @param Theme $theme + * @param array $data + * @param string $template + * @param int $nestedLevel * * @throws Exception */ - public function __construct(Theme $theme, $data, $template, $nestedLevel = 0) + public function __construct(Theme $theme, array $data, string $template, int $nestedLevel = 0) { // todo clean buffer before exception if ($nestedLevel > 800) { @@ -53,7 +53,7 @@ public function __construct(Theme $theme, $data, $template, $nestedLevel = 0) $this->nestedLevel = $nestedLevel; } - private function __getTemplatePath($fileName) + private function getTemplatePath($fileName) { if ('/' == $fileName[0] || 0 === strpos($fileName, 'phar://')) { return $fileName; @@ -69,7 +69,7 @@ private function __getTemplatePath($fileName) } /** - * set a variable that will be accessible in the template. + * Set a variable that will be accessible in the template. * * @param $name * @param $value @@ -207,7 +207,7 @@ public function parse() foreach ($this->data as $name => $value) { $$name = $value; } - $path = $this->__getTemplatePath($this->template); + $path = $this->getTemplatePath($this->template); ob_start(); include $path; $content = ob_get_clean(); @@ -215,7 +215,7 @@ public function parse() return $content; } - public function partial($fileName, array $data = []) + public function partial(string $fileName, array $data = []) { $newLevel = $this->nestedLevel + 1; diff --git a/templates/Api/themes/api-base/class.phtml b/templates/Api/themes/api-base/class.phtml index 3d819b531a..5be6774675 100644 --- a/templates/Api/themes/api-base/class.phtml +++ b/templates/Api/themes/api-base/class.phtml @@ -1 +1 @@ -partial("layout/layout.phtml",array("contentPartial"=>"partials/class/content.phtml")) ?> \ No newline at end of file +partial('layout/layout.phtml', ['contentPartial' => 'partials/class/content.phtml']) ?> diff --git a/templates/Api/themes/api-base/classes.phtml b/templates/Api/themes/api-base/classes.phtml index 6cfdfe8dbd..110c63936b 100644 --- a/templates/Api/themes/api-base/classes.phtml +++ b/templates/Api/themes/api-base/classes.phtml @@ -1 +1 @@ -partial("layout/layout.phtml",array("contentPartial"=>"partials/classes.phtml")) ?> \ No newline at end of file +partial('layout/layout.phtml', ['contentPartial' => 'partials/classes.phtml']) ?> diff --git a/templates/Api/themes/api-base/index.phtml b/templates/Api/themes/api-base/index.phtml index 7cf7bc36e3..dd64e30cc2 100644 --- a/templates/Api/themes/api-base/index.phtml +++ b/templates/Api/themes/api-base/index.phtml @@ -1 +1 @@ -partial("layout/layout.phtml",array("contentPartial"=>"partials/index.phtml")) ?> \ No newline at end of file +partial('layout/layout.phtml', ['contentPartial' => 'partials/index.phtml']) ?> diff --git a/templates/Api/themes/api-base/namespace.phtml b/templates/Api/themes/api-base/namespace.phtml index 021dcc6062..b2ca9ac49c 100644 --- a/templates/Api/themes/api-base/namespace.phtml +++ b/templates/Api/themes/api-base/namespace.phtml @@ -1 +1 @@ -partial("layout/layout.phtml",array("contentPartial"=>"partials/namespace/content.phtml")) ?> \ No newline at end of file +partial('layout/layout.phtml', ['contentPartial' => 'partials/namespace/content.phtml']) ?> diff --git a/templates/Api/themes/api-base/namespaces.phtml b/templates/Api/themes/api-base/namespaces.phtml index 3229086efc..25ae68fca7 100644 --- a/templates/Api/themes/api-base/namespaces.phtml +++ b/templates/Api/themes/api-base/namespaces.phtml @@ -1 +1 @@ -partial("layout/layout.phtml",array("contentPartial"=>"partials/namespaces.phtml")) ?> \ No newline at end of file +partial('layout/layout.phtml', ['contentPartial' => 'partials/namespaces.phtml']) ?> diff --git a/templates/Api/themes/api-base/source.phtml b/templates/Api/themes/api-base/source.phtml index 9bbe82ef6c..7f499a38c2 100644 --- a/templates/Api/themes/api-base/source.phtml +++ b/templates/Api/themes/api-base/source.phtml @@ -1 +1 @@ -partial("layout/layout.phtml",array("contentPartial"=>"partials/source.phtml")) ?> \ No newline at end of file +partial('layout/layout.phtml', ['contentPartial' => 'partials/source.phtml']) ?> diff --git a/templates/Api/themes/zephir/layout/layout.phtml b/templates/Api/themes/zephir/layout/layout.phtml index 12f7daf05c..0c5313c201 100644 --- a/templates/Api/themes/zephir/layout/layout.phtml +++ b/templates/Api/themes/zephir/layout/layout.phtml @@ -16,9 +16,9 @@ projectConfig("name") ?> API Documentation - partial("partials/assets.phtml") ?> - - partial("partials/analytics.phtml") ?> + partial('partials/assets.phtml') ?> + + partial('partials/analytics.phtml') ?>
diff --git a/templates/Api/themes/zephir/partials/class/method-summary.phtml b/templates/Api/themes/zephir/partials/class/method-summary.phtml index 08ee7e987c..d41a9a47f3 100644 --- a/templates/Api/themes/zephir/partials/class/method-summary.phtml +++ b/templates/Api/themes/zephir/partials/class/method-summary.phtml @@ -47,7 +47,7 @@ $docblock = $method->getParsedDocblock(); getName() ?>(partial("partials/class/method-summary-params.phtml" ) ?>)(partial('partials/class/method-summary-params.phtml') ?>) : diff --git a/templates/Api/themes/zephir/partials/index.phtml b/templates/Api/themes/zephir/partials/index.phtml index b921a6c29d..1009cccdd7 100644 --- a/templates/Api/themes/zephir/partials/index.phtml +++ b/templates/Api/themes/zephir/partials/index.phtml @@ -1,19 +1,19 @@ -partial("partials/breadcrumb.phtml",array("items"=> $items)) ?> +partial('partials/breadcrumb.phtml', ['items'=> []]) ?>
-
    - $ns){ ?> - -
  • - - + $ns): ?> +
  • + + + +
  • +
- -
\ No newline at end of file +
diff --git a/templates/Api/themes/zephir/partials/namespace/content.phtml b/templates/Api/themes/zephir/partials/namespace/content.phtml index ea7e811e32..559a8ed7b3 100644 --- a/templates/Api/themes/zephir/partials/namespace/content.phtml +++ b/templates/Api/themes/zephir/partials/namespace/content.phtml @@ -1,14 +1,17 @@ "Namespaces" , "url" => "/namespaces.html" ), - $items[] = array("name" => $namespaceHelper->getFullNamespace()) - ); +/** + * @var array $subNamespaces + * @var array $subClasses + * @var Zephir\Documentation\NamespaceHelper $namespaceHelper + */ + +$items = [ + ['name' => 'Namespaces' , 'url' => '/namespaces.html'], + $items[] = ['name' => $namespaceHelper->getFullNamespace()] +]; ?> -partial("partials/breadcrumb.phtml",array("items"=> $items)) ?> - - +partial('partials/breadcrumb.phtml', ['items'=> $items]) ?>
@@ -18,36 +21,36 @@
- -0 ){ ?> - + 0 ): ?>

Sub Namespaces

- - - -0 ){ ?> + + 0): ?>

Sub Classes

- - - + diff --git a/templates/Api/themes/zephir/partials/namespace/method-details.phtml b/templates/Api/themes/zephir/partials/namespace/method-details.phtml index 8e31709f7a..7a68b5bf23 100644 --- a/templates/Api/themes/zephir/partials/namespace/method-details.phtml +++ b/templates/Api/themes/zephir/partials/namespace/method-details.phtml @@ -1,26 +1,21 @@
  • -
    -
    - -

    getName() ?>

    - - isAbstract() ? "abstract" : "" ?> - isStatic() ? "static" : "" ?> - isFinal() ? "final" : "" ?> + isAbstract() ? 'abstract' : '' ?> + isStatic() ? 'static' : '' ?> + isFinal() ? 'final' : '' ?> getVisibility()) ?> - function getName() ?>(partial("partials/class/method-summary-params.phtml" ) ?>) + function getName() ?>(partial('partials/class/method-summary-params.phtml' ) ?>)
    getDocBlock() ?> @@ -29,5 +24,4 @@
    - -
  • \ No newline at end of file + diff --git a/templates/Api/themes/zephir/partials/namespace/method-summary.phtml b/templates/Api/themes/zephir/partials/namespace/method-summary.phtml index 274472cbf7..4196e7ae29 100644 --- a/templates/Api/themes/zephir/partials/namespace/method-summary.phtml +++ b/templates/Api/themes/zephir/partials/namespace/method-summary.phtml @@ -1,42 +1,32 @@
  • -
    - getReturnClassTypes()){ + if ($method->getReturnClassTypes()) { $allTypes = array_merge($allTypes,$method->getReturnClassTypes()); - } - $types = $method->getReturnTypes(); - if($types && count($types)>0 ){ - - foreach($types as $type){ - - if($type && isset($type["data-type"])) - $allTypes[] = $type["data-type"]; + if ($types && count($types) > 0) { + foreach ($types as $type) { + if ($type && isset($type['data-type'])) { + $allTypes[] = $type['data-type']; + } } } - echo implode("|",$allTypes); - + echo implode('|', $allTypes); ?> -
    - getName() ?>(partial("partials/class/method-summary-params.phtml" ) ?>) - + getName() ?>(partial('partials/class/method-summary-params.phtml') ?>)
    - -
  • \ No newline at end of file + diff --git a/templates/Api/themes/zephir/partials/namespaces.phtml b/templates/Api/themes/zephir/partials/namespaces.phtml index afc02268b9..1bbbe7a925 100644 --- a/templates/Api/themes/zephir/partials/namespaces.phtml +++ b/templates/Api/themes/zephir/partials/namespaces.phtml @@ -1,19 +1,21 @@ "Namespaces" ), - ); +/** + * @var array $namespaces + */ + +$items = [['name' => 'Namespaces']]; ?> -partial("partials/breadcrumb.phtml",array("items"=> $items)) ?> +partial('partials/breadcrumb.phtml', ['items'=> $items]) ?>
    - - -
    \ No newline at end of file + diff --git a/templates/Api/themes/zephir/partials/source.phtml b/templates/Api/themes/zephir/partials/source.phtml index e835a2a188..8010ac6686 100644 --- a/templates/Api/themes/zephir/partials/source.phtml +++ b/templates/Api/themes/zephir/partials/source.phtml @@ -1,37 +1,48 @@ "Classes" , "url" => "/classes.html" ), - $items[] = array("name" => $fullName , "url" => $this->url($classDefinition)), - $items[] = array("name" => "Source"), - ); +$items = [ + ['name' => 'Classes' , 'url' => '/classes.html'], + $items[] = ['name' => $fullName , 'url' => $this->url($classDefinition)], + $items[] = ['name' => 'Source'], +]; ?> -partial("partials/breadcrumb.phtml",array("items"=> $items)) ?> +partial('partials/breadcrumb.phtml', ['items'=> $items]) ?>
    Class - themeOption("github")){ ?> - getFilePath() ?>">Github - + themeOption('github')): ?> + + Github + +
    - Class - $nspath){ ?> + $nspath): ?> - + +

    - -
    getFilePath())) ?>
    \ No newline at end of file +
    +    getFilePath())) ?>
    +