Skip to content
Code-Schnipsel Gruppen Projekte

Revisionen vergleichen

Änderungen werden so angezeigt, als ob die Quellrevision mit der Zielrevision zusammengeführt würde. Erfahre mehr über den Vergleich von Revisionen.

Quelle

Zielprojekt auswählen
No results found

Ziel

Zielprojekt auswählen
  • quiqqer/package-menu
1 Ergebnis
Änderungen anzeigen
Commits auf Quelle (3)
  • Henning Leutz's avatar
    chore: update phpstan version and remove phpstan-baseline · 6f309bd3
    verfasst von Henning Leutz
    This commit updates the version of phpstan specified in .phive/phars.xml file to 1.* and the
    current installed version to 1.12.13.
    
    Additionally, it removes all the previously ignored errors in phpstan-baseline.neon. The actions
    were taken possibly due to fixes to these errors or related update in the codebase causing them to
    be obsolete.
    
    Please ensure related checks/errors do not surface again due to the removed baseline ignores.
    6f309bd3
  • Henning Leutz's avatar
    fix(phpstan): enhance code readability and adopt safer practices · 78d9b1e2
    verfasst von Henning Leutz
    Several changes have been made across multiple files to enhance code readability and follow safer
    coding practices.
    
    1. Breakdown of long lines of attributes/code into multiple lines with added comments for better
    readability. This was done in Submenu.php
    
    2. Replaced '==' operation with 'empty()' function to check for empty strings in Submenu.php
    
    3. Safer checking of if method 'getCachePath' exists on 'getSite' to avoid potential errors &
    Ensure the last insert ID is always an integer in the database PDO in DropDownMenu.php and
    Factory.php
    
    4. Refactor conditions for more clear type hinting in multiple files; including
    Independent/Handler.php, Independent/Items/AbstractMenuItem.php, Independent/Items/Site.php,
    Independent/Menu.php, MegaMenu.php, and NavTabs.php
    
    The concept of safe concatenation or use of '|null|' has been introduced where needed across many
    files.
    
    Related: #38
    78d9b1e2
  • Henning Leutz's avatar
    Merge branch 'next-3.x' into 'main' · 12da4391
    verfasst von Henning Leutz
    chore: update phpstan version and remove phpstan-baseline
    
    See merge request !36
    12da4391
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<phive xmlns="https://phar.io/phive"> <phive xmlns="https://phar.io/phive">
<phar name="phpstan" version="1.11.8" installed="1.11.8" location="./tools/phpstan" copy="false"/> <phar name="phpstan" version="1.*" installed="1.12.13" location="./tools/phpstan" copy="false"/>
<phar name="phpunit" version="^10.5.20" installed="10.5.20" location="./tools/phpunit" copy="false"/> <phar name="phpunit" version="^10.5.20" installed="10.5.20" location="./tools/phpunit" copy="false"/>
<phar name="phpcs" version="^3.10.1" installed="3.10.1" location="./tools/phpcs" copy="false"/> <phar name="phpcs" version="^3.10.1" installed="3.10.1" location="./tools/phpcs" copy="false"/>
<phar name="phpcbf" version="^3.10.1" installed="3.10.1" location="./tools/phpcbf" copy="false"/> <phar name="phpcbf" version="^3.10.1" installed="3.10.1" location="./tools/phpcbf" copy="false"/>
......
parameters:
ignoreErrors:
-
message: "#^Strict comparison using \\=\\=\\= between mixed and '' will always evaluate to false\\.$#"
count: 1
path: src/QUI/Menu/Bricks/Submenu.php
-
message: "#^Call to an undefined method QUI\\\\Interfaces\\\\Projects\\\\Site\\:\\:getCachePath\\(\\)\\.$#"
count: 1
path: src/QUI/Menu/DropDownMenu.php
-
message: "#^Parameter \\#1 \\$menuId of static method QUI\\\\Menu\\\\Independent\\\\Handler\\:\\:getMenu\\(\\) expects int, string\\|false given\\.$#"
count: 1
path: src/QUI/Menu/Independent/Factory.php
-
message: "#^Call to an undefined method QUI\\\\Interfaces\\\\Projects\\\\Site\\:\\:getCachePath\\(\\)\\.$#"
count: 1
path: src/QUI/Menu/MegaMenu.php
-
message: "#^Variable \\$Site in PHPDoc tag @var does not match any variable in the foreach loop\\: \\$data, \\$dataSet$#"
count: 1
path: src/QUI/Menu/NavTabs.php
...@@ -32,19 +32,27 @@ public function __construct(array $attributes = []) ...@@ -32,19 +32,27 @@ public function __construct(array $attributes = [])
// defaults values // defaults values
$this->setAttributes([ $this->setAttributes([
'class' => 'quiqqer-menu-bricks-submenu', 'class' => 'quiqqer-menu-bricks-submenu',
'startId' => false, // id or site link 'startId' => false,
'menuId' => false, // id of an independent menu // id or site link
'template' => 'list-buttonStyle', // 'list-buttonStyle', 'list-simple', 'box-imageTop', 'box-imageOverlay' 'menuId' => false,
// id of an independent menu
'template' => 'list-buttonStyle',
// 'list-buttonStyle', 'list-simple', 'box-imageTop', 'box-imageOverlay'
'controlBgColor' => '', 'controlBgColor' => '',
'controlBgPadding' => '1rem', 'controlBgPadding' => '1rem',
'linkColor' => '', 'linkColor' => '',
'linkColorHover' => '', 'linkColorHover' => '',
'itemsAlignment' => 'center', // 'start', 'center', 'end', 'space-between', 'space-around' 'itemsAlignment' => 'center',
'showImages' => true, // if true, icons or images will be displayed // 'start', 'center', 'end', 'space-between', 'space-around'
'imageFitMode' => 'cover', // any valid css property for image-fit attribute , i.e. 'cover', 'contain', 'scale-down' 'showImages' => true,
'imageContainerHeight' => '',// any valid css property (with unit!) for height attribute, i.e. '150px', '10vw' or even clamp() function (if no value passed the container will be a square) // if true, icons or images will be displayed
'imageFitMode' => 'cover',
// any valid css property for image-fit attribute , i.e. 'cover', 'contain', 'scale-down'
'imageContainerHeight' => '',
// any valid css property (with unit!) for height attribute, i.e. '150px', '10vw' or even clamp() function (if no value passed the container will be a square)
'boxBgColor' => '#f5f5f6', 'boxBgColor' => '#f5f5f6',
'boxWidth' => '250px'// any valid css property (with unit!) for height attribute, i.e. '250px', '10vw' or even clamp() function 'boxWidth' => '250px'
// any valid css property (with unit!) for height attribute, i.e. '250px', '10vw' or even clamp() function
]); ]);
parent::__construct($attributes); parent::__construct($attributes);
...@@ -52,12 +60,6 @@ public function __construct(array $attributes = []) ...@@ -52,12 +60,6 @@ public function __construct(array $attributes = [])
$this->setAttribute('cacheable', false); $this->setAttribute('cacheable', false);
} }
/**
* (non-PHPdoc)
*
* @throws Exception
* @see \QUI\Control::create()
*/
public function getBody(): string public function getBody(): string
{ {
$Engine = QUI::getTemplateManager()->getEngine(); $Engine = QUI::getTemplateManager()->getEngine();
...@@ -70,7 +72,7 @@ public function getBody(): string ...@@ -70,7 +72,7 @@ public function getBody(): string
$linkColorHover = $this->getAttribute('linkColorHover'); $linkColorHover = $this->getAttribute('linkColorHover');
if ($linkColor === '') { if (empty($linkColor)) {
$linkColorHover = 'inherit'; $linkColorHover = 'inherit';
} }
......
...@@ -48,16 +48,18 @@ public function __construct(array $attributes = []) ...@@ -48,16 +48,18 @@ public function __construct(array $attributes = [])
public function getBody(): string public function getBody(): string
{ {
$cache = EventHandler::menuCacheName() . '/dropDownMenu/'; $cache = EventHandler::menuCacheName() . '/dropDownMenu/';
$siteCachePath = '';
$attributes = $this->getAttributes(); $attributes = $this->getAttributes();
$attributes = array_filter($attributes, function ($entry) { $attributes = array_filter($attributes, function ($entry) {
return is_object($entry) === false; return is_object($entry) === false;
}); });
$cache .= md5( if (method_exists($this->getSite(), 'getCachePath')) {
$this->getSite()->getCachePath() . $siteCachePath = $this->getSite()->getCachePath();
serialize($attributes) }
);
$cache .= md5($siteCachePath . serialize($attributes));
try { try {
return QUI\Cache\Manager::get($cache); return QUI\Cache\Manager::get($cache);
......
...@@ -24,8 +24,7 @@ public static function createMenu(): Menu ...@@ -24,8 +24,7 @@ public static function createMenu(): Menu
'data' => '' 'data' => ''
]); ]);
$lastId = QUI::getPDO()->lastInsertId(); $lastId = (int)QUI::getPDO()->lastInsertId();
$Menu = Handler::getMenu($lastId); $Menu = Handler::getMenu($lastId);
try { try {
......
...@@ -36,8 +36,10 @@ public static function getMenu(int $menuId): Menu ...@@ -36,8 +36,10 @@ public static function getMenu(int $menuId): Menu
* @param QUI\Projects\Project|null $Project * @param QUI\Projects\Project|null $Project
* @return string * @return string
*/ */
public static function getMenuCacheName(bool|int $menuId = false, QUI\Projects\Project $Project = null): string public static function getMenuCacheName(
{ bool | int $menuId = false,
null | QUI\Projects\Project $Project = null
): string {
if ($Project) { if ($Project) {
$project = $Project->getName(); $project = $Project->getName();
$lang = $Project->getLang(); $lang = $Project->getLang();
......
...@@ -32,7 +32,7 @@ public function __construct(array $attributes = []) ...@@ -32,7 +32,7 @@ public function __construct(array $attributes = [])
* @param ?Locale $Locale * @param ?Locale $Locale
* @return string * @return string
*/ */
public function getTitle(Locale $Locale = null): string public function getTitle(null | Locale $Locale = null): string
{ {
if ($Locale === null) { if ($Locale === null) {
$Locale = QUI::getLocale(); $Locale = QUI::getLocale();
...@@ -56,7 +56,7 @@ public function getTitle(Locale $Locale = null): string ...@@ -56,7 +56,7 @@ public function getTitle(Locale $Locale = null): string
* @param ?Locale $Locale * @param ?Locale $Locale
* @return string * @return string
*/ */
public function getShort(Locale $Locale = null): string public function getShort(null | Locale $Locale = null): string
{ {
if ($Locale === null) { if ($Locale === null) {
$Locale = QUI::getLocale(); $Locale = QUI::getLocale();
...@@ -86,7 +86,7 @@ public function getShort(Locale $Locale = null): string ...@@ -86,7 +86,7 @@ public function getShort(Locale $Locale = null): string
* @param Locale|null $Locale * @param Locale|null $Locale
* @return string * @return string
*/ */
public function getName(Locale $Locale = null): string public function getName(null | Locale $Locale = null): string
{ {
if ($Locale === null) { if ($Locale === null) {
$Locale = QUI::getLocale(); $Locale = QUI::getLocale();
...@@ -117,7 +117,7 @@ public function getName(Locale $Locale = null): string ...@@ -117,7 +117,7 @@ public function getName(Locale $Locale = null): string
* @param Locale|null $Locale * @param Locale|null $Locale
* @return string * @return string
*/ */
public function getTitleAttribute(Locale $Locale = null): string public function getTitleAttribute(null | Locale $Locale = null): string
{ {
return $this->getName($Locale); return $this->getName($Locale);
} }
...@@ -222,7 +222,7 @@ public function getCustomData(): mixed ...@@ -222,7 +222,7 @@ public function getCustomData(): mixed
* @param Locale|null $Locale * @param Locale|null $Locale
* @return string * @return string
*/ */
public function getHTML(QUI\Locale $Locale = null): string public function getHTML(null | Locale $Locale = null): string
{ {
if ($Locale === null) { if ($Locale === null) {
$Locale = QUI::getLocale(); $Locale = QUI::getLocale();
......
...@@ -102,7 +102,7 @@ public function getIcon(): string ...@@ -102,7 +102,7 @@ public function getIcon(): string
* @param Locale|null $Locale * @param Locale|null $Locale
* @return string * @return string
*/ */
public function getName(Locale $Locale = null): string public function getName(null | Locale $Locale = null): string
{ {
$Site = $this->getSite(); $Site = $this->getSite();
...@@ -114,10 +114,10 @@ public function getName(Locale $Locale = null): string ...@@ -114,10 +114,10 @@ public function getName(Locale $Locale = null): string
} }
/** /**
* @param QUI\Locale|null $Locale * @param Locale|null $Locale
* @return string * @return string
*/ */
public function getTitle(QUI\Locale $Locale = null): string public function getTitle(null | Locale $Locale = null): string
{ {
$Site = $this->getSite(); $Site = $this->getSite();
......
...@@ -34,7 +34,7 @@ class Menu ...@@ -34,7 +34,7 @@ class Menu
* @throws QUI\Exception * @throws QUI\Exception
* @throws QUI\Database\Exception * @throws QUI\Database\Exception
*/ */
public function __construct(int|array $menuId) public function __construct(int | array $menuId)
{ {
if (is_numeric($menuId)) { if (is_numeric($menuId)) {
$data = Handler::getMenuData($menuId); $data = Handler::getMenuData($menuId);
...@@ -93,7 +93,7 @@ public function __construct(int|array $menuId) ...@@ -93,7 +93,7 @@ public function __construct(int|array $menuId)
* @param array $children * @param array $children
* @return void * @return void
*/ */
protected function buildChildren(AbstractMenuItem|Menu $Parent, array $children): void protected function buildChildren(AbstractMenuItem | Menu $Parent, array $children): void
{ {
foreach ($children as $item) { foreach ($children as $item) {
$type = $item['type']; $type = $item['type'];
...@@ -180,7 +180,7 @@ public function getId(): int ...@@ -180,7 +180,7 @@ public function getId(): int
* @param QUI\Locale|null $Locale * @param QUI\Locale|null $Locale
* @return string * @return string
*/ */
public function getTitle(QUI\Locale $Locale = null): string public function getTitle(null | QUI\Locale $Locale = null): string
{ {
if ($this->title === null) { if ($this->title === null) {
return ''; return '';
...@@ -203,7 +203,7 @@ public function getTitle(QUI\Locale $Locale = null): string ...@@ -203,7 +203,7 @@ public function getTitle(QUI\Locale $Locale = null): string
* @param QUI\Locale|null $Locale * @param QUI\Locale|null $Locale
* @return string * @return string
*/ */
public function getWorkingTitle(QUI\Locale $Locale = null): string public function getWorkingTitle(null | QUI\Locale $Locale = null): string
{ {
if ($this->workingTitle === null) { if ($this->workingTitle === null) {
return ''; return '';
......
...@@ -26,7 +26,7 @@ class MegaMenu extends AbstractMenu ...@@ -26,7 +26,7 @@ class MegaMenu extends AbstractMenu
/** /**
* @var SlideOut|SlideOutAdvanced|null * @var SlideOut|SlideOutAdvanced|null
*/ */
protected SlideOutAdvanced|null|SlideOut $Mobile = null; protected SlideOutAdvanced | null | SlideOut $Mobile = null;
/** /**
* @var array * @var array
...@@ -101,17 +101,18 @@ public function __construct(array $attributes = []) ...@@ -101,17 +101,18 @@ public function __construct(array $attributes = [])
public function getBody(): string public function getBody(): string
{ {
$cache = EventHandler::menuCacheName() . '/megaMenu/'; $cache = EventHandler::menuCacheName() . '/megaMenu/';
$siteCachePath = '';
$attributes = $this->getAttributes(); $attributes = $this->getAttributes();
$attributes = array_filter($attributes, function ($entry) { $attributes = array_filter($attributes, function ($entry) {
return is_object($entry) === false; return is_object($entry) === false;
}); });
$cache .= md5( if (method_exists($this->getSite(), 'getCachePath')) {
$this->getSite()->getCachePath() . $siteCachePath = $this->getSite()->getCachePath();
serialize($attributes) }
);
$cache .= md5($siteCachePath . serialize($attributes));
$childControl = $this->getMenuControl($this->getAttribute('display')); $childControl = $this->getMenuControl($this->getAttribute('display'));
$showMenuDelay = 0; $showMenuDelay = 0;
...@@ -245,7 +246,7 @@ public function getStart(): QUI\Interfaces\Projects\Site ...@@ -245,7 +246,7 @@ public function getStart(): QUI\Interfaces\Projects\Site
* @param $control * @param $control
* @return false|string * @return false|string
*/ */
public function getMenuControl($control): bool|string public function getMenuControl($control): bool | string
{ {
switch ($control) { switch ($control) {
case 'Image': case 'Image':
...@@ -333,7 +334,7 @@ protected function getSite(): QUI\Interfaces\Projects\Site ...@@ -333,7 +334,7 @@ protected function getSite(): QUI\Interfaces\Projects\Site
* @throws QUI\Exception * @throws QUI\Exception
* @throws Exception * @throws Exception
*/ */
protected function getMobileMenu($slideOutParam): SlideOut|SlideOutAdvanced protected function getMobileMenu($slideOutParam): SlideOut | SlideOutAdvanced
{ {
if ($this->getProject()->getConfig('mobileMenu.settings.type') == 'slideoutAdvanced') { if ($this->getProject()->getConfig('mobileMenu.settings.type') == 'slideoutAdvanced') {
$Menu = new QUI\Menu\SlideOutAdvanced($slideOutParam); $Menu = new QUI\Menu\SlideOutAdvanced($slideOutParam);
......
...@@ -86,7 +86,7 @@ public function getBody(): string ...@@ -86,7 +86,7 @@ public function getBody(): string
* @return array|string * @return array|string
* @throws QUI\Exception * @throws QUI\Exception
*/ */
private function getChildrenFromParent(): array|string private function getChildrenFromParent(): array | string
{ {
$ParentSite = null; $ParentSite = null;
...@@ -152,7 +152,6 @@ public function setData(array $data) ...@@ -152,7 +152,6 @@ public function setData(array $data)
$entries = []; $entries = [];
/** @var QUI\Projects\Site $Site */
foreach ($data as $dataSet) { foreach ($data as $dataSet) {
if (count($dataSet) < 2) { if (count($dataSet) < 2) {
continue; continue;
......