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 Sep 1, 2023
1 parent 1e28928 commit 8364644
Show file tree
Hide file tree
Showing 10 changed files with 116 additions and 25 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 @@ -1555,6 +1585,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 @@ -1630,6 +1665,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 @@ -15,13 +15,14 @@ abstract class BaseItemList extends BaseHtmlElement
{
use BaseFilter;

/** @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 @@ -32,7 +33,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 @@ -63,18 +64,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 @@ -17,20 +17,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 @@ -50,7 +51,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'];

Check failure on line 21 in src/Common/BaseStatusBar.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 7.2 on ubuntu-latest

PHPDoc type array<string> of property ipl\Web\Common\BaseStatusBar::$defaultAttributes is not covariant with PHPDoc type array<string, mixed> of overridden property ipl\Html\BaseHtmlElement::$defaultAttributes.

Check failure on line 21 in src/Common/BaseStatusBar.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 7.3 on ubuntu-latest

PHPDoc type array<string> of property ipl\Web\Common\BaseStatusBar::$defaultAttributes is not covariant with PHPDoc type array<string, mixed> of overridden property ipl\Html\BaseHtmlElement::$defaultAttributes.

Check failure on line 21 in src/Common/BaseStatusBar.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 7.4 on ubuntu-latest

PHPDoc type array<string> of property ipl\Web\Common\BaseStatusBar::$defaultAttributes is not covariant with PHPDoc type array<string, mixed> of overridden property ipl\Html\BaseHtmlElement::$defaultAttributes.

Check failure on line 21 in src/Common/BaseStatusBar.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.0 on ubuntu-latest

PHPDoc type array<string> of property ipl\Web\Common\BaseStatusBar::$defaultAttributes is not covariant with PHPDoc type array<string, mixed> of overridden property ipl\Html\BaseHtmlElement::$defaultAttributes.

Check failure on line 21 in src/Common/BaseStatusBar.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.1 on ubuntu-latest

PHPDoc type array<string> of property ipl\Web\Common\BaseStatusBar::$defaultAttributes is not covariant with PHPDoc type array<string, mixed> of overridden property ipl\Html\BaseHtmlElement::$defaultAttributes.

Check failure on line 21 in src/Common/BaseStatusBar.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.2 on ubuntu-latest

PHPDoc type array<string> of property ipl\Web\Common\BaseStatusBar::$defaultAttributes is not covariant with PHPDoc type array<string, mixed> of overridden property ipl\Html\BaseHtmlElement::$defaultAttributes.

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
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'];

Check failure on line 15 in src/Widget/EmptyState.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 7.2 on ubuntu-latest

PHPDoc type array<string> of property ipl\Web\Widget\EmptyState::$defaultAttributes is not covariant with PHPDoc type array<string, mixed> of overridden property ipl\Html\BaseHtmlElement::$defaultAttributes.

Check failure on line 15 in src/Widget/EmptyState.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 7.3 on ubuntu-latest

PHPDoc type array<string> of property ipl\Web\Widget\EmptyState::$defaultAttributes is not covariant with PHPDoc type array<string, mixed> of overridden property ipl\Html\BaseHtmlElement::$defaultAttributes.

Check failure on line 15 in src/Widget/EmptyState.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 7.4 on ubuntu-latest

PHPDoc type array<string> of property ipl\Web\Widget\EmptyState::$defaultAttributes is not covariant with PHPDoc type array<string, mixed> of overridden property ipl\Html\BaseHtmlElement::$defaultAttributes.

Check failure on line 15 in src/Widget/EmptyState.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.0 on ubuntu-latest

PHPDoc type array<string> of property ipl\Web\Widget\EmptyState::$defaultAttributes is not covariant with PHPDoc type array<string, mixed> of overridden property ipl\Html\BaseHtmlElement::$defaultAttributes.

Check failure on line 15 in src/Widget/EmptyState.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.1 on ubuntu-latest

PHPDoc type array<string> of property ipl\Web\Widget\EmptyState::$defaultAttributes is not covariant with PHPDoc type array<string, mixed> of overridden property ipl\Html\BaseHtmlElement::$defaultAttributes.

Check failure on line 15 in src/Widget/EmptyState.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.2 on ubuntu-latest

PHPDoc type array<string> of property ipl\Web\Widget\EmptyState::$defaultAttributes is not covariant with PHPDoc type array<string, mixed> of overridden property ipl\Html\BaseHtmlElement::$defaultAttributes.

/**
* 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'];

Check failure on line 16 in src/Widget/Notice.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 7.2 on ubuntu-latest

PHPDoc type array<string> of property ipl\Web\Widget\Notice::$defaultAttributes is not covariant with PHPDoc type array<string, mixed> of overridden property ipl\Html\BaseHtmlElement::$defaultAttributes.

Check failure on line 16 in src/Widget/Notice.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 7.3 on ubuntu-latest

PHPDoc type array<string> of property ipl\Web\Widget\Notice::$defaultAttributes is not covariant with PHPDoc type array<string, mixed> of overridden property ipl\Html\BaseHtmlElement::$defaultAttributes.

Check failure on line 16 in src/Widget/Notice.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 7.4 on ubuntu-latest

PHPDoc type array<string> of property ipl\Web\Widget\Notice::$defaultAttributes is not covariant with PHPDoc type array<string, mixed> of overridden property ipl\Html\BaseHtmlElement::$defaultAttributes.

Check failure on line 16 in src/Widget/Notice.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.0 on ubuntu-latest

PHPDoc type array<string> of property ipl\Web\Widget\Notice::$defaultAttributes is not covariant with PHPDoc type array<string, mixed> of overridden property ipl\Html\BaseHtmlElement::$defaultAttributes.

Check failure on line 16 in src/Widget/Notice.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.1 on ubuntu-latest

PHPDoc type array<string> of property ipl\Web\Widget\Notice::$defaultAttributes is not covariant with PHPDoc type array<string, mixed> of overridden property ipl\Html\BaseHtmlElement::$defaultAttributes.

Check failure on line 16 in src/Widget/Notice.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.2 on ubuntu-latest

PHPDoc type array<string> of property ipl\Web\Widget\Notice::$defaultAttributes is not covariant with PHPDoc type array<string, mixed> of overridden property ipl\Html\BaseHtmlElement::$defaultAttributes.

/**
* Create a html notice
*
* @param mixed $content
*/
public function __construct($content)
{
$this->content = $content;
Expand Down
4 changes: 4 additions & 0 deletions src/Widget/ShowMore.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,18 @@ class ShowMore extends BaseHtmlElement
{
use BaseTarget;

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

Check failure on line 15 in src/Widget/ShowMore.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 7.2 on ubuntu-latest

PHPDoc type array<string> of property ipl\Web\Widget\ShowMore::$defaultAttributes is not covariant with PHPDoc type array<string, mixed> of overridden property ipl\Html\BaseHtmlElement::$defaultAttributes.

Check failure on line 15 in src/Widget/ShowMore.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 7.3 on ubuntu-latest

PHPDoc type array<string> of property ipl\Web\Widget\ShowMore::$defaultAttributes is not covariant with PHPDoc type array<string, mixed> of overridden property ipl\Html\BaseHtmlElement::$defaultAttributes.

Check failure on line 15 in src/Widget/ShowMore.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 7.4 on ubuntu-latest

PHPDoc type array<string> of property ipl\Web\Widget\ShowMore::$defaultAttributes is not covariant with PHPDoc type array<string, mixed> of overridden property ipl\Html\BaseHtmlElement::$defaultAttributes.

Check failure on line 15 in src/Widget/ShowMore.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.0 on ubuntu-latest

PHPDoc type array<string> of property ipl\Web\Widget\ShowMore::$defaultAttributes is not covariant with PHPDoc type array<string, mixed> of overridden property ipl\Html\BaseHtmlElement::$defaultAttributes.

Check failure on line 15 in src/Widget/ShowMore.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.1 on ubuntu-latest

PHPDoc type array<string> of property ipl\Web\Widget\ShowMore::$defaultAttributes is not covariant with PHPDoc type array<string, mixed> of overridden property ipl\Html\BaseHtmlElement::$defaultAttributes.

Check failure on line 15 in src/Widget/ShowMore.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.2 on ubuntu-latest

PHPDoc type array<string> of property ipl\Web\Widget\ShowMore::$defaultAttributes is not covariant with PHPDoc type array<string, mixed> of overridden property ipl\Html\BaseHtmlElement::$defaultAttributes.

protected $tag = 'div';

/** @var ResultSet */
protected $resultSet;

/** @var Url */
protected $url;

/** @var ?string */
protected $label;

public function __construct(ResultSet $resultSet, Url $url, string $label = null)
Expand Down

0 comments on commit 8364644

Please sign in to comment.