Skip to content

Commit

Permalink
Fix phpstan error reports
Browse files Browse the repository at this point in the history
  • Loading branch information
yhabteab committed Aug 28, 2023
1 parent 05f6a71 commit 424e86b
Show file tree
Hide file tree
Showing 12 changed files with 117 additions and 27 deletions.
55 changes: 55 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,35 @@
parameters:
ignoreErrors:
-
message: "#^Method ipl\\\\Web\\\\Common\\\\BaseItemList\\:\\:assemble\\(\\) has no return type specified\\.$#"
count: 1
path: src/Common/BaseItemList.php

-
message: "#^Method ipl\\\\Web\\\\Common\\\\BaseItemTable\\:\\:assemble\\(\\) has no return type specified\\.$#"
count: 1
path: src/Common/BaseItemTable.php

-
message: "#^Method ipl\\\\Web\\\\Common\\\\BaseListItem\\:\\:assemble\\(\\) has no return type specified\\.$#"
count: 1
path: src/Common/BaseListItem.php

-
message: "#^Method ipl\\\\Web\\\\Common\\\\BaseOrderedItemList\\:\\:assemble\\(\\) has no return type specified\\.$#"
count: 1
path: src/Common/BaseOrderedItemList.php

-
message: "#^Method ipl\\\\Web\\\\Common\\\\BaseStatusBar\\:\\:assemble\\(\\) has no return type specified\\.$#"
count: 1
path: src/Common/BaseStatusBar.php

-
message: "#^Method ipl\\\\Web\\\\Common\\\\BaseTableRowItem\\:\\:assemble\\(\\) has no return type specified\\.$#"
count: 1
path: src/Common/BaseTableRowItem.php

-
message: "#^Method ipl\\\\Web\\\\Common\\\\Card\\:\\:assemble\\(\\) has no return type specified\\.$#"
count: 1
Expand Down Expand Up @@ -1695,6 +1725,11 @@ parameters:
count: 1
path: src/Widget/Dropdown.php

-
message: "#^Method ipl\\\\Web\\\\Widget\\\\EmptyState\\:\\:assemble\\(\\) has no return type specified\\.$#"
count: 1
path: src/Widget/EmptyState.php

-
message: "#^Method ipl\\\\Web\\\\Widget\\\\HorizontalKeyValue\\:\\:__construct\\(\\) has parameter \\$key with no type specified\\.$#"
count: 1
Expand Down Expand Up @@ -1775,6 +1810,26 @@ parameters:
count: 1
path: src/Widget/Link.php

-
message: "#^Method ipl\\\\Web\\\\Widget\\\\Notice\\:\\:assemble\\(\\) has no return type specified\\.$#"
count: 1
path: src/Widget/Notice.php

-
message: "#^Method ipl\\\\Web\\\\Widget\\\\PageSeparatorItem\\:\\:assemble\\(\\) has no return type specified\\.$#"
count: 1
path: src/Widget/PageSeparatorItem.php

-
message: "#^Method ipl\\\\Web\\\\Widget\\\\ShowMore\\:\\:assemble\\(\\) has no return type specified\\.$#"
count: 1
path: src/Widget/ShowMore.php

-
message: "#^Method ipl\\\\Web\\\\Widget\\\\ShowMore\\:\\:getBaseTarget\\(\\) should return string\\|null but returns array\\|bool\\|string\\|null\\.$#"
count: 1
path: src/Widget/ShowMore.php

-
message: "#^Method ipl\\\\Web\\\\Widget\\\\StateBadge\\:\\:assemble\\(\\) has no return type specified\\.$#"
count: 1
Expand Down
13 changes: 9 additions & 4 deletions src/Common/BaseItemList.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ abstract class BaseItemList extends BaseHtmlElement
use BaseFilter;
use DetailActions;

/** @var string[] */
protected $baseAttributes = [
'class' => 'item-list',
'data-base-target' => '_next',
'data-pdfexport-page-breaks-at' => '.list-item'
];

/** @var iterable */
/** @var iterable<object> */
protected $data;

/** @var bool Whether the list contains at least one item with an icon_image */
Expand All @@ -33,7 +34,7 @@ abstract class BaseItemList extends BaseHtmlElement
/**
* Create a new item list
*
* @param iterable $data Data source of the list
* @param iterable<object> $data Data source of the list
*/
public function __construct($data)
{
Expand Down Expand Up @@ -65,18 +66,22 @@ public function hasIconImages(): bool
* Set whether the list contains at least one item with an icon_image
*
* @param bool $hasIconImages
*
* @return $this
*/
public function setHasIconImages(bool $hasIconImages)
public function setHasIconImages(bool $hasIconImages): self
{
$this->hasIconImages = $hasIconImages;

return $this;
}

/**
* Initialize the item list
*
* If you want to adjust the item list after construction, override this method.
*/
protected function init()
protected function init(): void
{
}

Expand Down
7 changes: 4 additions & 3 deletions src/Common/BaseItemTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,21 @@ abstract class BaseItemTable extends BaseHtmlElement
/** @var string Defines the layout used by this item */
public const TABLE_LAYOUT = 'table-layout';

/** @var string[] */
protected $baseAttributes = [
'class' => 'item-table',
'data-base-target' => '_next'
];

/** @var iterable */
/** @var iterable<object> */
protected $data;

protected $tag = 'ul';

/**
* Create a new item table
*
* @param iterable $data Data source of the table
* @param iterable<object> $data Data source of the table
*/
public function __construct($data)
{
Expand All @@ -52,7 +53,7 @@ public function __construct($data)
*
* If you want to adjust the item table after construction, override this method.
*/
protected function init()
protected function init(): void
{
}

Expand Down
23 changes: 13 additions & 10 deletions src/Common/BaseListItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
*/
abstract class BaseListItem extends BaseHtmlElement
{
/** @var string[] */
protected $baseAttributes = ['class' => 'list-item'];

/** @var object The associated list item */
Expand All @@ -19,6 +20,7 @@ abstract class BaseListItem extends BaseHtmlElement
/** @var BaseItemList The list where the item is part of */
protected $list;

/** @var string */
protected $tag = 'li';

/**
Expand All @@ -37,27 +39,27 @@ public function __construct($item, BaseItemList $list)
$this->init();
}

abstract protected function assembleHeader(BaseHtmlElement $header);
abstract protected function assembleHeader(BaseHtmlElement $header): void;

abstract protected function assembleMain(BaseHtmlElement $main);
abstract protected function assembleMain(BaseHtmlElement $main): void;

protected function assembleFooter(BaseHtmlElement $footer)
protected function assembleFooter(BaseHtmlElement $footer): void
{
}

protected function assembleCaption(BaseHtmlElement $caption)
protected function assembleCaption(BaseHtmlElement $caption): void
{
}

protected function assembleIconImage(BaseHtmlElement $iconImage)
protected function assembleIconImage(BaseHtmlElement $iconImage): void
{
}

protected function assembleTitle(BaseHtmlElement $title)
protected function assembleTitle(BaseHtmlElement $title): void
{
}

protected function assembleVisual(BaseHtmlElement $visual)
protected function assembleVisual(BaseHtmlElement $visual): void
{
}

Expand Down Expand Up @@ -100,7 +102,7 @@ protected function createFooter(): BaseHtmlElement
/**
* @return ?BaseHtmlElement
*/
protected function createIconImage()
protected function createIconImage(): ?BaseHtmlElement
{
if (! $this->list->hasIconImages()) {
return null;
Expand All @@ -115,8 +117,9 @@ protected function createIconImage()
return $iconImage;
}

protected function createTimestamp()
protected function createTimestamp(): ?BaseHtmlElement
{
return null;
}

protected function createTitle(): BaseHtmlElement
Expand Down Expand Up @@ -145,7 +148,7 @@ protected function createVisual()
*
* If you want to adjust the list item after construction, override this method.
*/
protected function init()
protected function init(): void
{
}

Expand Down
7 changes: 5 additions & 2 deletions src/Common/BaseStatusBar.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,27 @@
use ipl\Html\Attributes;
use ipl\Html\BaseHtmlElement;
use ipl\Html\HtmlElement;
use ipl\Orm\Model;
use ipl\Stdlib\BaseFilter;

abstract class BaseStatusBar extends BaseHtmlElement
{
use BaseFilter;

/** @var Model */
protected $summary;

protected $tag = 'div';

/** @var string[] */
protected $defaultAttributes = ['class' => 'status-bar'];

public function __construct($summary)
public function __construct(Model $summary)
{
$this->summary = $summary;
}

abstract protected function assembleTotal(BaseHtmlElement $total);
abstract protected function assembleTotal(BaseHtmlElement $total): void;

abstract protected function createStateBadges(): BaseHtmlElement;

Expand Down
16 changes: 12 additions & 4 deletions src/Common/BaseTableRowItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

abstract class BaseTableRowItem extends BaseHtmlElement
{
/** @var string[] */
protected $baseAttributes = ['class' => 'table-row'];

/** @var object The associated list item */
Expand Down Expand Up @@ -40,16 +41,23 @@ public function __construct($item, BaseItemTable $table = null)
$this->init();
}

abstract protected function assembleTitle(BaseHtmlElement $title);
abstract protected function assembleTitle(BaseHtmlElement $title): void;

protected function assembleColumns(HtmlDocument $columns)
protected function assembleColumns(HtmlDocument $columns): void
{
}

protected function assembleVisual(BaseHtmlElement $visual)
protected function assembleVisual(BaseHtmlElement $visual): void
{
}

/**
* Create column
*
* @param mixed $content
*
* @return BaseHtmlElement
*/
protected function createColumn($content = null): BaseHtmlElement
{
return new HtmlElement(
Expand Down Expand Up @@ -100,7 +108,7 @@ protected function createVisual()
*
* If you want to adjust the list item after construction, override this method.
*/
protected function init()
protected function init(): void
{
}

Expand Down
2 changes: 0 additions & 2 deletions src/Common/DetailActions.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ public function initializeDetailActions(): self
*/
protected function setMultiselectUrl(Url $url): self
{
/** @var BaseHtmlElement $this */
$this->getAttributes()
->registerAttributeCallback('data-icinga-multiselect-url', function () use ($url) {
return $this->isMultiselectSupported() ? (string) $url : null;
Expand All @@ -113,7 +112,6 @@ protected function setMultiselectUrl(Url $url): self
*/
protected function setDetailUrl(Url $url): self
{
/** @var BaseHtmlElement $this */
$this->getAttributes()
->registerAttributeCallback('data-icinga-detail-url', function () use ($url) {
return $this->getDetailActionsDisabled() ? null : (string) $url;
Expand Down
4 changes: 2 additions & 2 deletions src/Common/ListItemCommonLayout.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ trait ListItemCommonLayout
{
use CaptionDisabled;

protected function assembleHeader(BaseHtmlElement $header)
protected function assembleHeader(BaseHtmlElement $header): void
{
$header->addHtml($this->createTitle());
$header->add($this->createTimestamp());
}

protected function assembleMain(BaseHtmlElement $main)
protected function assembleMain(BaseHtmlElement $main): void
{
$main->addHtml($this->createHeader());
if (! $this->isCaptionDisabled()) {
Expand Down
6 changes: 6 additions & 0 deletions src/Widget/EmptyState.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,14 @@ class EmptyState extends BaseHtmlElement

protected $tag = 'div';

/** @var string[] */
protected $defaultAttributes = ['class' => 'empty-state'];

/**
* Create an empty state
*
* @param mixed $content
*/
public function __construct($content)
{
$this->content = $content;
Expand Down
6 changes: 6 additions & 0 deletions src/Widget/Notice.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,14 @@ class Notice extends BaseHtmlElement

protected $tag = 'p';

/** @var string[] */
protected $defaultAttributes = ['class' => 'notice'];

/**
* Create a html notice
*
* @param mixed $content
*/
public function __construct($content)
{
$this->content = $content;
Expand Down
1 change: 1 addition & 0 deletions src/Widget/PageSeparatorItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

class PageSeparatorItem extends BaseHtmlElement
{
/** @var string[] */
protected $defaultAttributes = ['class' => 'list-item page-separator'];

/** @var int */
Expand Down
Loading

0 comments on commit 424e86b

Please sign in to comment.