Skip to content

Commit

Permalink
rex_navigation: Property/Param-Types (#5560)
Browse files Browse the repository at this point in the history
  • Loading branch information
gharlan committed Feb 4, 2023
1 parent 19d3a20 commit e1d007a
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 190 deletions.
120 changes: 0 additions & 120 deletions .tools/phpstan/baseline.neon
Expand Up @@ -1370,126 +1370,6 @@ parameters:
count: 1
path: ../../redaxo/src/addons/structure/lib/navigation.php

-
message: "#^Method rex_navigation\\:\\:checkCallbacks\\(\\) has parameter \\$a with no type specified\\.$#"
count: 1
path: ../../redaxo/src/addons/structure/lib/navigation.php

-
message: "#^Method rex_navigation\\:\\:checkCallbacks\\(\\) has parameter \\$aContent with no type specified\\.$#"
count: 1
path: ../../redaxo/src/addons/structure/lib/navigation.php

-
message: "#^Method rex_navigation\\:\\:checkCallbacks\\(\\) has parameter \\$depth with no type specified\\.$#"
count: 1
path: ../../redaxo/src/addons/structure/lib/navigation.php

-
message: "#^Method rex_navigation\\:\\:checkCallbacks\\(\\) has parameter \\$li with no type specified\\.$#"
count: 1
path: ../../redaxo/src/addons/structure/lib/navigation.php

-
message: "#^Method rex_navigation\\:\\:checkFilter\\(\\) has parameter \\$depth with no type specified\\.$#"
count: 1
path: ../../redaxo/src/addons/structure/lib/navigation.php

-
message: "#^Method rex_navigation\\:\\:setClasses\\(\\) has parameter \\$classes with no type specified\\.$#"
count: 1
path: ../../redaxo/src/addons/structure/lib/navigation.php

-
message: "#^Method rex_navigation\\:\\:setLinkClasses\\(\\) has parameter \\$classes with no type specified\\.$#"
count: 1
path: ../../redaxo/src/addons/structure/lib/navigation.php

-
message: "#^Method rex_navigation\\:\\:show\\(\\) has parameter \\$categoryId with no type specified\\.$#"
count: 1
path: ../../redaxo/src/addons/structure/lib/navigation.php

-
message: "#^Method rex_navigation\\:\\:show\\(\\) has parameter \\$depth with no type specified\\.$#"
count: 1
path: ../../redaxo/src/addons/structure/lib/navigation.php

-
message: "#^Method rex_navigation\\:\\:show\\(\\) has parameter \\$ignoreOfflines with no type specified\\.$#"
count: 1
path: ../../redaxo/src/addons/structure/lib/navigation.php

-
message: "#^Method rex_navigation\\:\\:show\\(\\) has parameter \\$open with no type specified\\.$#"
count: 1
path: ../../redaxo/src/addons/structure/lib/navigation.php

-
message: "#^Method rex_navigation\\:\\:showBreadcrumb\\(\\) has parameter \\$categoryId with no type specified\\.$#"
count: 1
path: ../../redaxo/src/addons/structure/lib/navigation.php

-
message: "#^Method rex_navigation\\:\\:showBreadcrumb\\(\\) has parameter \\$includeCurrent with no type specified\\.$#"
count: 1
path: ../../redaxo/src/addons/structure/lib/navigation.php

-
message: "#^Method rex_navigation\\:\\:showBreadcrumb\\(\\) has parameter \\$startPageLabel with no type specified\\.$#"
count: 1
path: ../../redaxo/src/addons/structure/lib/navigation.php

-
message: "#^Property rex_navigation\\:\\:\\$callbacks has no type specified\\.$#"
count: 1
path: ../../redaxo/src/addons/structure/lib/navigation.php

-
message: "#^Property rex_navigation\\:\\:\\$classes has no type specified\\.$#"
count: 1
path: ../../redaxo/src/addons/structure/lib/navigation.php

-
message: "#^Property rex_navigation\\:\\:\\$currentArticleId has no type specified\\.$#"
count: 1
path: ../../redaxo/src/addons/structure/lib/navigation.php

-
message: "#^Property rex_navigation\\:\\:\\$currentCategoryId has no type specified\\.$#"
count: 1
path: ../../redaxo/src/addons/structure/lib/navigation.php

-
message: "#^Property rex_navigation\\:\\:\\$depth has no type specified\\.$#"
count: 1
path: ../../redaxo/src/addons/structure/lib/navigation.php

-
message: "#^Property rex_navigation\\:\\:\\$factoryCall has no type specified\\.$#"
count: 1
path: ../../redaxo/src/addons/structure/lib/navigation.php

-
message: "#^Property rex_navigation\\:\\:\\$filter has no type specified\\.$#"
count: 1
path: ../../redaxo/src/addons/structure/lib/navigation.php

-
message: "#^Property rex_navigation\\:\\:\\$linkclasses has no type specified\\.$#"
count: 1
path: ../../redaxo/src/addons/structure/lib/navigation.php

-
message: "#^Property rex_navigation\\:\\:\\$open has no type specified\\.$#"
count: 1
path: ../../redaxo/src/addons/structure/lib/navigation.php

-
message: "#^Property rex_navigation\\:\\:\\$path has no type specified\\.$#"
count: 1
path: ../../redaxo/src/addons/structure/lib/navigation.php

-
message: "#^Method rex_structure_perm\\:\\:getFieldParams\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
Expand Down
52 changes: 0 additions & 52 deletions .tools/psalm/baseline.xml
Expand Up @@ -2002,63 +2002,11 @@
</PossiblyNullReference>
</file>
<file src="redaxo/src/addons/structure/lib/navigation.php">
<MixedArgument>
<code>$a</code>
<code>$aContent</code>
<code>$categoryId</code>
<code>$categoryId</code>
<code>$depth</code>
<code>$f['metafield']</code>
<code>$ignoreOfflines</code>
<code>$includeCurrent</code>
<code>$li</code>
<code>$open</code>
<code>$pathItem</code>
<code>$startPageLabel</code>
<code>$this-&gt;currentArticleId</code>
<code>$this-&gt;currentArticleId</code>
<code>$this-&gt;path</code>
<code>$this-&gt;path</code>
<code>$va</code>
</MixedArgument>
<MixedArrayAccess>
<code>$c['callback']</code>
<code>$c['depth']</code>
<code>$f['depth']</code>
<code>$f['metafield']</code>
<code>$f['type']</code>
<code>$f['value']</code>
<code>$this-&gt;classes[$depth - 1]</code>
<code>$this-&gt;linkclasses[$depth - 1]</code>
</MixedArrayAccess>
<MixedArrayAssignment>
<code>$a['class']</code>
<code>$a['class']</code>
<code>$a['class']</code>
<code>$li['class']</code>
<code>$li['class']</code>
<code>$li['class']</code>
<code>$li['class']</code>
<code>$li['class']</code>
<code>$this-&gt;callbacks[]</code>
<code>$this-&gt;filter[]</code>
</MixedArrayAssignment>
<MixedAssignment>
<code>$a['class'][]</code>
<code>$c</code>
<code>$callback</code>
<code>$f</code>
<code>$li['class'][]</code>
<code>$path</code>
<code>$pathItem</code>
<code>$result</code>
<code>$result</code>
<code>$result</code>
<code>$va</code>
</MixedAssignment>
<MixedFunctionCall>
<code>$callback($category, $depth, $li, $a, $aContent)</code>
</MixedFunctionCall>
<MixedMethodCall>
<code>$class::$method($category, $depth, $li, $a, $aContent)</code>
<code>$method</code>
Expand Down
62 changes: 44 additions & 18 deletions redaxo/src/addons/structure/lib/navigation.php
Expand Up @@ -35,18 +35,28 @@ class rex_navigation
{
use rex_factory_trait;

private $depth; // Wieviele Ebene tief, ab der Startebene
private $open; // alles aufgeklappt, z.b. Sitemap
private $path = [];
private $classes = [];
private $linkclasses = [];
private $filter = [];
private $callbacks = [];
private int $depth = -1; // Wieviele Ebene tief, ab der Startebene
private bool $open = false; // alles aufgeklappt, z.b. Sitemap
/** @var list<int> */
private array $path = [];
/** @var array<int, string> */
private array $classes = [];
/** @var array<int, string> */
private array $linkclasses = [];
/** @var list<array{metafield: string, value: int|string, type: string, depth: int|''}> */
private array$filter = [];
/**
* @var list<array{
* callback: callable(rex_category, int, array<int|string, int|string|list<string>>,array<int|string, int|string|list<string>>, string):bool,
* depth: int|''
* }>
*/
private array $callbacks = [];

private $currentArticleId = -1; // Aktueller Artikel
private $currentCategoryId = -1; // Aktuelle Katgorie
private int $currentArticleId = -1; // Aktueller Artikel
private int $currentCategoryId = -1; // Aktuelle Katgorie

private static $factoryCall = false;
private static bool $factoryCall = false;

public function __construct()
{
Expand Down Expand Up @@ -94,6 +104,11 @@ public function get($categoryId = 0, $depth = 3, $open = false, $ignoreOfflines

/**
* @see get()
*
* @param int $categoryId
* @param int $depth
* @param bool $open
* @param bool $ignoreOfflines
* @return void
*/
public function show($categoryId = 0, $depth = 3, $open = false, $ignoreOfflines = false)
Expand All @@ -104,7 +119,7 @@ public function show($categoryId = 0, $depth = 3, $open = false, $ignoreOfflines
/**
* Generiert eine Breadcrumb-Navigation.
*
* @param string $startPageLabel Label der Startseite, falls FALSE keine Start-Page anzeigen
* @param string|false $startPageLabel Label der Startseite, falls FALSE keine Start-Page anzeigen
* @param bool $includeCurrent True wenn der aktuelle Artikel enthalten sein soll, sonst FALSE
* @param int $categoryId Id der Wurzelkategorie
*
Expand Down Expand Up @@ -178,6 +193,10 @@ public function getBreadcrumb($startPageLabel, $includeCurrent = false, $categor

/**
* @see getBreadcrumb()
*
* @param string|false $startPageLabel
* @param bool $includeCurrent
* @param int $categoryId
* @return void
*/
public function showBreadcrumb($startPageLabel = false, $includeCurrent = false, $categoryId = 0)
Expand All @@ -186,6 +205,7 @@ public function showBreadcrumb($startPageLabel = false, $includeCurrent = false,
}

/**
* @param array<int, string> $classes
* @return void
*/
public function setClasses($classes)
Expand All @@ -194,6 +214,7 @@ public function setClasses($classes)
}

/**
* @param array<int, string> $classes
* @return void
*/
public function setLinkClasses($classes)
Expand All @@ -205,9 +226,9 @@ public function setLinkClasses($classes)
* Fügt einen Filter hinzu.
*
* @param string $metafield Datenbankfeld der Kategorie
* @param mixed $value Wert für den Vergleich
* @param string $type art des Vergleichs =/</
* @param int|string $depth "" wenn auf allen Ebenen, wenn definiert, dann wird der Filter nur auf dieser Ebene angewendet
* @param int|string $value Wert für den Vergleich
* @param string $type art des Vergleichs =/</
* @param int|'' $depth "" wenn auf allen Ebenen, wenn definiert, dann wird der Filter nur auf dieser Ebene angewendet
* @return void
*/
public function addFilter($metafield = 'id', $value = '1', $type = '=', $depth = '')
Expand All @@ -218,8 +239,8 @@ public function addFilter($metafield = 'id', $value = '1', $type = '=', $depth =
/**
* Fügt einen Callback hinzu.
*
* @param callable $callback z.B. myFunc oder myClass::myMethod
* @param int|string $depth "" wenn auf allen Ebenen, wenn definiert, dann wird der Filter nur auf dieser Ebene angewendet
* @param callable(rex_category,int,array<int|string, int|string|list<string>>,array<int|string, int|string|list<string>>,string):bool $callback z.B. myFunc oder myClass::myMethod
* @param int|'' $depth "" wenn auf allen Ebenen, wenn definiert, dann wird der Filter nur auf dieser Ebene angewendet
*
* @return $this
*/
Expand All @@ -242,7 +263,7 @@ private function _setActivePath()

$this->path = [];
if ('' != $path) {
$this->path = explode('|', $path);
$this->path = array_map(intval(...), explode('|', $path));
}

$this->currentArticleId = $articleId;
Expand All @@ -254,6 +275,7 @@ private function _setActivePath()
}

/**
* @param int $depth
* @return bool
*/
private function checkFilter(rex_category $category, $depth)
Expand Down Expand Up @@ -292,7 +314,7 @@ private function checkFilter(rex_category $category, $depth)
}
break;
case 'regex':
if (!preg_match($va, (string) $mf)) {
if (!preg_match((string) $va, (string) $mf)) {
return false;
}
break;
Expand All @@ -310,6 +332,10 @@ private function checkFilter(rex_category $category, $depth)
}

/**
* @param int $depth
* @param array<int|string, int|string|list<string>> $li
* @param array<int|string, int|string|list<string>> $a
* @param string $aContent
* @return bool
*/
private function checkCallbacks(rex_category $category, $depth, &$li, &$a, &$aContent)
Expand Down

0 comments on commit e1d007a

Please sign in to comment.