Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raise phpstan level to max #156

Merged
merged 7 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,21 @@ jobs:
tools: phpcs

- name: Setup dependencies
run: composer require -n --no-progress overtrue/phplint
&& git clone --single-branch --branch master https://github.com/Icinga/icingaweb2.git vendor/icingaweb2
&& git clone --single-branch --branch master https://github.com/Icinga/icingadb-web.git vendor/modules/icingadb-web
&& git clone --single-branch --branch snapshot/nightly https://github.com/Icinga/icinga-php-library.git vendor/icinga-php-library
&& git clone --single-branch --branch snapshot/nightly https://github.com/Icinga/icinga-php-thirdparty.git vendor/icinga-php-thirdparty
run: |
composer require -n --no-progress overtrue/phplint
git clone --depth 1 https://github.com/Icinga/icingaweb2.git vendor/icingaweb2
git clone --depth 1 https://github.com/Icinga/icingadb-web.git vendor/modules/icingadb-web
git clone --depth 1 -b snapshot/nightly https://github.com/Icinga/icinga-php-library.git vendor/icinga-php-library
git clone --depth 1 -b snapshot/nightly https://github.com/Icinga/icinga-php-thirdparty.git vendor/icinga-php-thirdparty

yhabteab marked this conversation as resolved.
Show resolved Hide resolved
- name: PHP Lint
if: success() || matrix.allow_failure
if: ${{ ! cancelled() }}
run: ./vendor/bin/phplint -n --exclude={^vendor/.*} -- .

- name: PHP CodeSniffer
if: success() || matrix.allow_failure
if: ${{ ! cancelled() }}
run: phpcs -wps --colors

- name: PHPStan
if: ${{ ! cancelled() }}
uses: php-actions/phpstan@v3
if: success() || matrix.allow_failure
4 changes: 2 additions & 2 deletions library/Cube/DimensionParams.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ public function add($dimension)
*
* @param $dimensions
*
* @return $this
* @return DimensionParams
*/
public static function update($dimensions)
{
$self = new static();
$self = new static();
$self->dimensions = $dimensions;

return $self;
Expand Down
19 changes: 19 additions & 0 deletions library/Cube/Ido/IdoCube.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,25 @@ abstract class IdoCube extends DbCube

public const IS_USING_ICINGADB = false;

/**
* Add a specific named dimension
*
* Right now these are just custom vars, we might support group memberships
* or other properties in future
*
* @param string $name
*
* @return $this
*/
public function addDimensionByName($name): self
{
if (count($this->filterProtectedCustomvars([$name])) === 1) {
$this->addDimension($this->createDimension($name));
}

return $this;
}

/**
* We can steal the DB connection directly from a Monitoring backend
*
Expand Down
18 changes: 0 additions & 18 deletions library/Cube/Ido/IdoHostStatusCube.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,6 @@ public function createDimension($name)
return new CustomVarDimension($name, CustomVarDimension::TYPE_HOST);
}

/**
* Add a specific named dimension
*
* Right now this are just custom vars, we might support group memberships
* or other properties in future
*
* @param string $name
* @return $this
*/
public function addDimensionByName($name)
{
if (count($this->filterProtectedCustomvars(array($name))) === 1) {
$this->addDimension($this->createDimension($name));
}

return $this;
}

/**
* This returns a list of all available Dimensions
*
Expand Down
19 changes: 0 additions & 19 deletions library/Cube/Ido/IdoServiceStatusCube.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,25 +84,6 @@ public function prepareInnerQuery()
return $select;
}

/**
* Add a specific named dimension
*
* Right now this are just custom vars, we might support group memberships
* or other properties in future
*
* @param string $name
*
* @return $this
*/
public function addDimensionByName($name)
{
if (count($this->filterProtectedCustomvars([$name])) === 1) {
$this->addDimension($this->createDimension($name));
}

return $this;
}

public function createDimension($name)
{
$this->registerAvailableDimensions();
Expand Down
5 changes: 4 additions & 1 deletion library/Cube/Web/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Icinga\Module\Icingadb\Web\Control\ProblemToggle;
use Icinga\Web\View;
use Icinga\Web\Widget\Tabextension\DashboardAction;
use ipl\Html\FormElement\CheckboxElement;
use ipl\Html\HtmlString;
use ipl\Stdlib\Filter;
use ipl\Stdlib\Str;
Expand Down Expand Up @@ -96,7 +97,9 @@ protected function renderCube(): void
$problemToggle = (new ProblemToggle($problemsOnly ?: null))
->setIdProtector([$this->getRequest(), 'protectId'])
->on(ProblemToggle::ON_SUCCESS, function (ProblemToggle $form) {
if (! $form->getElement('problems')->isChecked()) {
/** @var CheckboxElement $problems */
$problems = $form->getElement('problems');
if (! $problems->isChecked()) {
$this->redirectNow(Url::fromRequest()->remove('problems'));
} else {
$this->redirectNow(Url::fromRequest()->setParam('problems'));
Expand Down
Loading