From 12b63aeec6ad573a0c5f3095be91cbd3cd187223 Mon Sep 17 00:00:00 2001 From: Felipe Figueroa Date: Tue, 16 Mar 2021 05:27:23 -0300 Subject: adding return types --- src/decorators/ActionUrlDecorator.php | 3 +++ src/decorators/ArrayMergeDecorator.php | 3 +++ src/decorators/BranchUrlDecorator.php | 3 +++ src/decorators/ConcatDecorator.php | 3 +++ src/decorators/Decorator.php | 20 ++++++++++++++++++++ src/decorators/RedirectUrlDecorator.php | 3 +++ src/decorators/UrlDecorator.php | 3 +++ src/xhtml/HTMLController.php | 7 +++++++ src/xhtml/HTMLFooterController.php | 6 ++++-- src/xhtml/HTMLNavbarController.php | 16 ++++++++++++++++ src/xhtml/HTMLTableController.php | 20 ++++++++++++++++++++ src/xhtml/XHtmlElement.php | 6 ++++++ src/xhtml/XHtmlSimpleElement.php | 5 +++++ 13 files changed, 96 insertions(+), 2 deletions(-) diff --git a/src/decorators/ActionUrlDecorator.php b/src/decorators/ActionUrlDecorator.php index d680efb6..56ba6c8d 100644 --- a/src/decorators/ActionUrlDecorator.php +++ b/src/decorators/ActionUrlDecorator.php @@ -22,6 +22,9 @@ class ActionUrlDecorator extends Decorator } } + /** + * @return string + */ public function value($fields) { $url = Decorator::get_sanitized_value($this->base, $fields); diff --git a/src/decorators/ArrayMergeDecorator.php b/src/decorators/ArrayMergeDecorator.php index 645ae3bc..47a59c83 100644 --- a/src/decorators/ArrayMergeDecorator.php +++ b/src/decorators/ArrayMergeDecorator.php @@ -14,6 +14,9 @@ class ArrayMergeDecorator extends Decorator $this->m = $arrays; } + /** + * @return array + */ public function value($fields) { $accum = []; diff --git a/src/decorators/BranchUrlDecorator.php b/src/decorators/BranchUrlDecorator.php index 954de2fe..49aebeb2 100644 --- a/src/decorators/BranchUrlDecorator.php +++ b/src/decorators/BranchUrlDecorator.php @@ -22,6 +22,9 @@ class BranchUrlDecorator extends Decorator } } + /** + * @return string + */ public function value($fields) { $url = Decorator::get_sanitized_value($this->base, $fields); diff --git a/src/decorators/ConcatDecorator.php b/src/decorators/ConcatDecorator.php index 968fa67e..a81edaf6 100644 --- a/src/decorators/ConcatDecorator.php +++ b/src/decorators/ConcatDecorator.php @@ -14,6 +14,9 @@ class ConcatDecorator extends Decorator $this->c = $values; } + /** + * @return string + */ public function value($fields) { $accum = ''; diff --git a/src/decorators/Decorator.php b/src/decorators/Decorator.php index c95911e0..4eb4a66d 100644 --- a/src/decorators/Decorator.php +++ b/src/decorators/Decorator.php @@ -62,6 +62,8 @@ class Decorator /** * @param Closure $callback * @param ((mixed|string)[]|null) $params + * + * @return CallbackDecorator */ public static function callback(Closure $callback, ?array $params = null) { @@ -77,6 +79,9 @@ class Decorator return self::get_sanitized_value($var, $fields, 'url'); } + /** + * @return ConcatDecorator + */ public static function concat(/* ... */) { return new ConcatDecorator(\func_get_args()); @@ -85,6 +90,8 @@ class Decorator /** * @param array $params * @param string $str + * + * @return ReplaceDecorator */ public static function replace(string $str, array $params) { @@ -94,6 +101,8 @@ class Decorator /** * @param null|array $default * @param string $fieldName + * + * @return FieldDecorator */ public static function field(string $fieldName, ?array $default = null) { @@ -103,6 +112,8 @@ class Decorator /** * @param null|array $vars * @param mixed $base + * + * @return BranchUrlDecorator */ public static function branchurl($base, ?array $vars = null/* ... */) { @@ -122,6 +133,8 @@ class Decorator /** * @param null|array $vars * @param mixed $base + * + * @return ActionUrlDecorator */ public static function actionurl($base, ?array $vars = null/* ... */) { @@ -141,6 +154,8 @@ class Decorator /** * @param null|array $vars * @param mixed $base + * + * @return RedirectUrlDecorator */ public static function redirecturl($base, ?array $vars = null/* ... */) { @@ -160,6 +175,8 @@ class Decorator /** * @param null|array $vars * @param mixed $base + * + * @return UrlDecorator */ public static function url($base, ?array $vars = null/* ... */) { @@ -177,6 +194,9 @@ class Decorator return new UrlDecorator($base, $vars); } + /** + * @return IfEmptyDecorator + */ public static function ifempty($value, string $empty, $full = null) { return new IfEmptyDecorator($value, $empty, $full); diff --git a/src/decorators/RedirectUrlDecorator.php b/src/decorators/RedirectUrlDecorator.php index 6f824098..d9c9a982 100644 --- a/src/decorators/RedirectUrlDecorator.php +++ b/src/decorators/RedirectUrlDecorator.php @@ -22,6 +22,9 @@ class RedirectUrlDecorator extends Decorator } } + /** + * @return string + */ public function value($fields) { $url = Decorator::get_sanitized_value($this->base, $fields); diff --git a/src/decorators/UrlDecorator.php b/src/decorators/UrlDecorator.php index 19745627..e34504b5 100644 --- a/src/decorators/UrlDecorator.php +++ b/src/decorators/UrlDecorator.php @@ -22,6 +22,9 @@ class UrlDecorator extends Decorator } } + /** + * @return string + */ public function value($fields) { $url = Decorator::get_sanitized_value($this->base, $fields); diff --git a/src/xhtml/HTMLController.php b/src/xhtml/HTMLController.php index 1b70a205..7063ac72 100644 --- a/src/xhtml/HTMLController.php +++ b/src/xhtml/HTMLController.php @@ -72,6 +72,9 @@ class HTMLController } } + /** + * @return \PHPPgAdmin\ContainerUtils + */ public function getContainer() { return $this->container; @@ -93,6 +96,8 @@ class HTMLController * will be generated by getActionUrl. See getActionUrl comment for array format. * @param mixed $do_print * @param null|mixed $from + * + * @return null|string */ public function printLink($link, $do_print = true, $from = null) { @@ -254,6 +259,8 @@ class HTMLController * WARNING: This field is NOT escaped! No user should be able to inject something here, use with care * @param bool $do_print true to echo, false to return * @param null|string $from which method is calling this one + * + * @return null|string */ protected function printLinksList($links, $class = '', $do_print = true, $from = null) { diff --git a/src/xhtml/HTMLFooterController.php b/src/xhtml/HTMLFooterController.php index 42648478..b232fb69 100644 --- a/src/xhtml/HTMLFooterController.php +++ b/src/xhtml/HTMLFooterController.php @@ -22,7 +22,7 @@ class HTMLFooterController extends HTMLController * * @param bool $flag sets internal $_reload_drop_database var which will be passed to the footer methods * - * @return HTMLFooterController $this the instance of this class + * @return static $this the instance of this class */ public function setReloadDropDatabase($flag) { @@ -36,7 +36,7 @@ class HTMLFooterController extends HTMLController * * @param bool $flag [description] * - * @return HTMLFooterController $this the instance of this class + * @return static $this the instance of this class */ public function setNoBottomLink($flag) { @@ -50,6 +50,8 @@ class HTMLFooterController extends HTMLController * * @param bool $doBody True to output body tag, false to return the html * @param mixed $template + * + * @return null|string */ public function printFooter($doBody = true, $template = 'footer.twig') { diff --git a/src/xhtml/HTMLNavbarController.php b/src/xhtml/HTMLNavbarController.php index 68f91585..a96dad03 100644 --- a/src/xhtml/HTMLNavbarController.php +++ b/src/xhtml/HTMLNavbarController.php @@ -145,6 +145,11 @@ class HTMLNavbarController extends HTMLController } } + /** + * @return (mixed|string)[][] + * + * @psalm-return array + */ private function _getCrumbs($trail) { $crumbs = []; @@ -178,6 +183,8 @@ class HTMLNavbarController extends HTMLController /** * @param mixed $crumbs * @param array $viewVars + * + * @return array */ private function _getSearchPathsCrumbs($crumbs, array $viewVars) { @@ -210,6 +217,8 @@ class HTMLNavbarController extends HTMLController * * @param bool $do_print true to print, false to return html * @param null|mixed $from which method is calling this one + * + * @return string */ private function printTopbar($do_print = true, $from = null): ?string { @@ -344,6 +353,9 @@ class HTMLNavbarController extends HTMLController return $topbar_html; } + /** + * @return string + */ private function getHREFSubject(string $subject) { $vars = $this->misc->getSubjectParams($subject); @@ -469,6 +481,10 @@ class HTMLNavbarController extends HTMLController /** * @param (mixed|string)[][] $trail * @param (mixed|string)[][] $the_array + * + * @return (mixed|string)[][] + * + * @psalm-return array> */ private function _getTrailsFromArray(array $trail, array $the_array) { diff --git a/src/xhtml/HTMLTableController.php b/src/xhtml/HTMLTableController.php index 96656656..8a6f2e9e 100644 --- a/src/xhtml/HTMLTableController.php +++ b/src/xhtml/HTMLTableController.php @@ -95,6 +95,9 @@ class HTMLTableController extends HTMLController $this->pre_fn = $pre_fn; } + /** + * @return string + */ public function printTable($turn_into_datatable = true, $with_body = true) { if (0 >= $this->tabledata->RecordCount()) { @@ -133,6 +136,9 @@ class HTMLTableController extends HTMLController return $tablehtml; } + /** + * @return string + */ public function getThead() { $columns = $this->columns; @@ -177,6 +183,9 @@ class HTMLTableController extends HTMLController return $thead_html; } + /** + * @return string + */ public function getTfooter() { $columns = $this->columns; @@ -203,6 +212,11 @@ class HTMLTableController extends HTMLController return $tfoot_html; } + /** + * @return string[] + * + * @psalm-return array{0: string, 1: string} + */ private function _getMaHtml() { $matop_html = ''; @@ -261,6 +275,9 @@ class HTMLTableController extends HTMLController return [$matop_html, $ma_bottomhtml]; } + /** + * @return string + */ private function getTbody() { $columns = $this->columns; @@ -374,6 +391,9 @@ class HTMLTableController extends HTMLController return $this->form; } + /** + * @return null|string + */ private function printUrlVars(&$vars, &$fields, bool $do_print = true) { $url_vars_html = ''; diff --git a/src/xhtml/XHtmlElement.php b/src/xhtml/XHtmlElement.php index 576669f8..dcd600eb 100644 --- a/src/xhtml/XHtmlElement.php +++ b/src/xhtml/XHtmlElement.php @@ -56,6 +56,9 @@ class XHtmlElement extends XHtmlSimpleElement return $this->_html(); } + /** + * @return string + */ public function _html() { $this->_htmlcode = "<{$this->_element}"; @@ -86,6 +89,9 @@ class XHtmlElement extends XHtmlSimpleElement return $this->_siblings; } + /** + * @return bool + */ public function has_siblings() { return 0 !== \count($this->_siblings); diff --git a/src/xhtml/XHtmlSimpleElement.php b/src/xhtml/XHtmlSimpleElement.php index 157ffcd3..769b113f 100644 --- a/src/xhtml/XHtmlSimpleElement.php +++ b/src/xhtml/XHtmlSimpleElement.php @@ -49,6 +49,9 @@ class XHtmlSimpleElement $this->set_attribute('class', $class); } + /** + * @return string + */ public function is_element() { $lower_classname = \mb_strtolower(\get_class($this)); @@ -58,6 +61,8 @@ class XHtmlSimpleElement /** * Private function generates xhtml. + * + * @return string */ public function _html() { -- cgit v1.2.3