Skip to content

Commit

Permalink
adding return types
Browse files Browse the repository at this point in the history
  • Loading branch information
ffflabs committed Mar 16, 2021
1 parent 5679998 commit 12b63ae
Show file tree
Hide file tree
Showing 13 changed files with 96 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/decorators/ActionUrlDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ public function __construct($base, $queryVars = null)
}
}

/**
* @return string
*/
public function value($fields)
{
$url = Decorator::get_sanitized_value($this->base, $fields);
Expand Down
3 changes: 3 additions & 0 deletions src/decorators/ArrayMergeDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ public function __construct($arrays)
$this->m = $arrays;
}

/**
* @return array
*/
public function value($fields)
{
$accum = [];
Expand Down
3 changes: 3 additions & 0 deletions src/decorators/BranchUrlDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ public function __construct($base, $queryVars = null)
}
}

/**
* @return string
*/
public function value($fields)
{
$url = Decorator::get_sanitized_value($this->base, $fields);
Expand Down
3 changes: 3 additions & 0 deletions src/decorators/ConcatDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ public function __construct($values)
$this->c = $values;
}

/**
* @return string
*/
public function value($fields)
{
$accum = '';
Expand Down
20 changes: 20 additions & 0 deletions src/decorators/Decorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ public static function get_sanitized_value(&$var, array &$fields, ?string $esc =
/**
* @param Closure $callback
* @param ((mixed|string)[]|null) $params
*
* @return CallbackDecorator
*/
public static function callback(Closure $callback, ?array $params = null)
{
Expand All @@ -77,6 +79,9 @@ public static function value_url(&$var, array &$fields)
return self::get_sanitized_value($var, $fields, 'url');
}

/**
* @return ConcatDecorator
*/
public static function concat(/* ... */)
{
return new ConcatDecorator(\func_get_args());
Expand All @@ -85,6 +90,8 @@ public static function concat(/* ... */)
/**
* @param array $params
* @param string $str
*
* @return ReplaceDecorator
*/
public static function replace(string $str, array $params)
{
Expand All @@ -94,6 +101,8 @@ public static function replace(string $str, array $params)
/**
* @param null|array $default
* @param string $fieldName
*
* @return FieldDecorator
*/
public static function field(string $fieldName, ?array $default = null)
{
Expand All @@ -103,6 +112,8 @@ public static function field(string $fieldName, ?array $default = null)
/**
* @param null|array $vars
* @param mixed $base
*
* @return BranchUrlDecorator
*/
public static function branchurl($base, ?array $vars = null/* ... */)
{
Expand All @@ -122,6 +133,8 @@ public static function branchurl($base, ?array $vars = null/* ... */)
/**
* @param null|array $vars
* @param mixed $base
*
* @return ActionUrlDecorator
*/
public static function actionurl($base, ?array $vars = null/* ... */)
{
Expand All @@ -141,6 +154,8 @@ public static function actionurl($base, ?array $vars = null/* ... */)
/**
* @param null|array $vars
* @param mixed $base
*
* @return RedirectUrlDecorator
*/
public static function redirecturl($base, ?array $vars = null/* ... */)
{
Expand All @@ -160,6 +175,8 @@ public static function redirecturl($base, ?array $vars = null/* ... */)
/**
* @param null|array $vars
* @param mixed $base
*
* @return UrlDecorator
*/
public static function url($base, ?array $vars = null/* ... */)
{
Expand All @@ -177,6 +194,9 @@ public static function url($base, ?array $vars = null/* ... */)
return new UrlDecorator($base, $vars);
}

/**
* @return IfEmptyDecorator
*/
public static function ifempty($value, string $empty, $full = null)
{
return new IfEmptyDecorator($value, $empty, $full);
Expand Down
3 changes: 3 additions & 0 deletions src/decorators/RedirectUrlDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ public function __construct($base, $queryVars = null)
}
}

/**
* @return string
*/
public function value($fields)
{
$url = Decorator::get_sanitized_value($this->base, $fields);
Expand Down
3 changes: 3 additions & 0 deletions src/decorators/UrlDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ public function __construct($base, $queryVars = null)
}
}

/**
* @return string
*/
public function value($fields)
{
$url = Decorator::get_sanitized_value($this->base, $fields);
Expand Down
7 changes: 7 additions & 0 deletions src/xhtml/HTMLController.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ public function __construct(\PHPPgAdmin\ContainerUtils $container, $controller_n
}
}

/**
* @return \PHPPgAdmin\ContainerUtils
*/
public function getContainer()
{
return $this->container;
Expand All @@ -93,6 +96,8 @@ public function getContainer()
* 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)
{
Expand Down Expand Up @@ -254,6 +259,8 @@ protected function getActionUrl(&$action, &$fields, $from = null)
* 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)
{
Expand Down
6 changes: 4 additions & 2 deletions src/xhtml/HTMLFooterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -36,7 +36,7 @@ public function setReloadDropDatabase($flag)
*
* @param bool $flag [description]
*
* @return HTMLFooterController $this the instance of this class
* @return static $this the instance of this class
*/
public function setNoBottomLink($flag)
{
Expand All @@ -50,6 +50,8 @@ public function setNoBottomLink($flag)
*
* @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')
{
Expand Down
16 changes: 16 additions & 0 deletions src/xhtml/HTMLNavbarController.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ public function printTabs($alltabs, $activetab, $do_print = true, $from = null)
}
}

/**
* @return (mixed|string)[][]
*
* @psalm-return array<array-key, array{url: string, iconalt?: mixed|string, title?: mixed, icon?: string, text?: mixed, helpurl?: string}>
*/
private function _getCrumbs($trail)
{
$crumbs = [];
Expand Down Expand Up @@ -178,6 +183,8 @@ private function _getCrumbs($trail)
/**
* @param mixed $crumbs
* @param array $viewVars
*
* @return array
*/
private function _getSearchPathsCrumbs($crumbs, array $viewVars)
{
Expand Down Expand Up @@ -210,6 +217,8 @@ private function _getSearchPathsCrumbs($crumbs, array $viewVars)
*
* @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
{
Expand Down Expand Up @@ -344,6 +353,9 @@ private function printTopbar($do_print = true, $from = null): ?string
return $topbar_html;
}

/**
* @return string
*/
private function getHREFSubject(string $subject)
{
$vars = $this->misc->getSubjectParams($subject);
Expand Down Expand Up @@ -469,6 +481,10 @@ private function _getTrail($subject = null)
/**
* @param (mixed|string)[][] $trail
* @param (mixed|string)[][] $the_array
*
* @return (mixed|string)[][]
*
* @psalm-return array<array-key, array<array-key, mixed|string>>
*/
private function _getTrailsFromArray(array $trail, array $the_array)
{
Expand Down
20 changes: 20 additions & 0 deletions src/xhtml/HTMLTableController.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ public function initialize(&$tabledata, &$columns, &$actions, $place, $nodata =
$this->pre_fn = $pre_fn;
}

/**
* @return string
*/
public function printTable($turn_into_datatable = true, $with_body = true)
{
if (0 >= $this->tabledata->RecordCount()) {
Expand Down Expand Up @@ -133,6 +136,9 @@ public function printTable($turn_into_datatable = true, $with_body = true)
return $tablehtml;
}

/**
* @return string
*/
public function getThead()
{
$columns = $this->columns;
Expand Down Expand Up @@ -177,6 +183,9 @@ public function getThead()
return $thead_html;
}

/**
* @return string
*/
public function getTfooter()
{
$columns = $this->columns;
Expand All @@ -203,6 +212,11 @@ public function getTfooter()
return $tfoot_html;
}

/**
* @return string[]
*
* @psalm-return array{0: string, 1: string}
*/
private function _getMaHtml()
{
$matop_html = '';
Expand Down Expand Up @@ -261,6 +275,9 @@ private function _getMaHtml()
return [$matop_html, $ma_bottomhtml];
}

/**
* @return string
*/
private function getTbody()
{
$columns = $this->columns;
Expand Down Expand Up @@ -374,6 +391,9 @@ private function getForm()
return $this->form;
}

/**
* @return null|string
*/
private function printUrlVars(&$vars, &$fields, bool $do_print = true)
{
$url_vars_html = '';
Expand Down
6 changes: 6 additions & 0 deletions src/xhtml/XHtmlElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ public function fetch()
return $this->_html();
}

/**
* @return string
*/
public function _html()
{
$this->_htmlcode = "<{$this->_element}";
Expand Down Expand Up @@ -86,6 +89,9 @@ public function get_siblings()
return $this->_siblings;
}

/**
* @return bool
*/
public function has_siblings()
{
return 0 !== \count($this->_siblings);
Expand Down
5 changes: 5 additions & 0 deletions src/xhtml/XHtmlSimpleElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ public function set_class($class): void
$this->set_attribute('class', $class);
}

/**
* @return string
*/
public function is_element()
{
$lower_classname = \mb_strtolower(\get_class($this));
Expand All @@ -58,6 +61,8 @@ public function is_element()

/**
* Private function generates xhtml.
*
* @return string
*/
public function _html()
{
Expand Down

0 comments on commit 12b63ae

Please sign in to comment.