Skip to content

Commit

Permalink
Fixed phpstan/code sniffer
Browse files Browse the repository at this point in the history
  • Loading branch information
paveljanda committed May 27, 2019
1 parent 9186f6b commit 9152c0e
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 45 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ before_script:
- mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql

script:
- composer phpstan
- composer phpcs
- vendor/bin/tester tests/ -c tests/php.ini

jobs:
Expand Down
6 changes: 1 addition & 5 deletions src/Column/Column.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,7 @@ public function isSortable(): bool
return $this->sortable;
}

if ($this->sortable !== '') {
return true;
}

return false;
return $this->sortable !== '';
}


Expand Down
11 changes: 6 additions & 5 deletions src/DataGrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ class DataGrid extends Control
private $customPaginatorTemplate = null;

/**
* @var string
* @var string|null
*/
private $componentFullName;

Expand Down Expand Up @@ -2047,7 +2047,7 @@ public function handleResetFilter(): void
$this->deleteSessionData('_grid_has_sorted');
}

foreach ($this->getSessionData() as $key => $val) {
foreach (array_keys($this->getSessionData()) as $key) {
if (!in_array($key, [
'_grid_perPage',
'_grid_sort',
Expand Down Expand Up @@ -2501,7 +2501,9 @@ public function getPerPage()
$perPage = reset($itemsPerPageList);
}

return $perPage === 'all' ? 'all' : (int) $perPage;
return $perPage === 'all'
? 'all'
: (int) $perPage;
}


Expand Down Expand Up @@ -2998,10 +3000,9 @@ public function getColumnsSummary(): ?ColumnsSummary

/**
* Gets component's full name in component tree
* @return string
* @throws DataGridHasToBeAttachedToPresenterComponentException
*/
public function getFullName() : string
public function getFullName(): string
{
if ($this->componentFullName === null) {
throw new DataGridHasToBeAttachedToPresenterComponentException(
Expand Down
6 changes: 3 additions & 3 deletions src/GroupAction/GroupActionCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,14 @@ public function addToFormContainer(Container $container): void

$groupActionSelect->addCondition(Form::FILLED)
->toggle(
strtolower((string) $this->datagrid->getFullName()) . 'group_action_submit'
strtolower($this->datagrid->getFullName()) . 'group_action_submit'
);

$container->addSubmit('submit', 'ublaboo_datagrid.execute')
->setValidationScope([$container])
->setAttribute(
'id',
strtolower((string) $this->datagrid->getFullName()) . 'group_action_submit'
strtolower($this->datagrid->getFullName()) . 'group_action_submit'
);

$form->onSubmit[] = [$this, 'submitted'];
Expand Down Expand Up @@ -146,7 +146,7 @@ public function submitted(Form $form): void
*/
$http_ids = $form->getHttpData(
Form::DATA_LINE | Form::DATA_KEYS,
strtolower((string) $this->datagrid->getFullName()) . '_group_action_item[]'
strtolower($this->datagrid->getFullName()) . '_group_action_item[]'
);

$ids = array_keys($http_ids);
Expand Down
2 changes: 0 additions & 2 deletions tests/Cases/CreateLinkTest.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ declare(strict_types=1);

namespace Ublaboo\DataGrid\Tests\Cases;

use InvalidArgumentException;
use Nette\Application\UI\InvalidLinkException;
use Nette\Application\UI\Presenter;
use Tester\Assert;
use Tester\TestCase;
Expand Down
1 change: 0 additions & 1 deletion tests/Cases/DataSources/ArrayDataSourceTest.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ declare(strict_types=1);

namespace Ublaboo\DataGrid\Tests\Cases\DataSources;

use Ublaboo;
use Ublaboo\DataGrid\DataSource\ArrayDataSource;
use Ublaboo\DataGrid\Tests\Files\TestingDataGridFactory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use Doctrine\Common\Collections\ArrayCollection;
use Tester\Assert;
use Ublaboo;
use Ublaboo\DataGrid\DataSource\DoctrineCollectionDataSource;
use Ublaboo\DataGrid\Filter\FilterText;
use Ublaboo\DataGrid\Tests\Files\TestingDataGridFactory;
Expand Down
50 changes: 26 additions & 24 deletions tests/Cases/ItemsPerPageTest.phpt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* TEST: ItemsPerPageTest
* @testCase Ublaboo\DataGrid\Tests\Cases\ItemsPerPageTest
Expand Down Expand Up @@ -32,41 +34,41 @@ class ItemsPerPageTest extends Tester\TestCase

public function testGetPerPage()
{
$this->grid->setItemsPerPageList([10, 20, 50], false);
$this->grid->setItemsPerPageList([10, 20, 50], false);

$this->grid->perPage = 20;
Tester\Assert::same(20, $this->grid->getPerPage());
$this->grid->perPage = 20;
Tester\Assert::same(20, $this->grid->getPerPage());

$this->grid->perPage = 'all';
Tester\Assert::same(10, $this->grid->getPerPage());
$this->grid->perPage = 'all';
Tester\Assert::same(10, $this->grid->getPerPage());
}

public function testGetPerPageAll()
{
$this->grid->setItemsPerPageList([10, 20, 50], true);
public function testGetPerPageAll()
{
$this->grid->setItemsPerPageList([10, 20, 50], true);

$this->grid->perPage = 20;
Tester\Assert::same(20, $this->grid->getPerPage());
$this->grid->perPage = 20;
Tester\Assert::same(20, $this->grid->getPerPage());

$this->grid->perPage = 'all';
Tester\Assert::same('all', $this->grid->getPerPage());
}
$this->grid->perPage = 'all';
Tester\Assert::same('all', $this->grid->getPerPage());
}

public function testGetPerPageAllTranslated()
{
$translator = new Ublaboo\DataGrid\Localization\SimpleTranslator([
'ublaboo_datagrid.all' => 'všechny'
]);
$this->grid->setTranslator($translator);
{
$translator = new Ublaboo\DataGrid\Localization\SimpleTranslator([
'ublaboo_datagrid.all' => 'všechny',
]);
$this->grid->setTranslator($translator);

$this->grid->setItemsPerPageList([10, 20, 50], true);
$this->grid->setItemsPerPageList([10, 20, 50], true);

$this->grid->perPage = 20;
Tester\Assert::same(20, $this->grid->getPerPage());
$this->grid->perPage = 20;
Tester\Assert::same(20, $this->grid->getPerPage());

$this->grid->perPage = 'all';
Tester\Assert::same('all', $this->grid->getPerPage());
}
$this->grid->perPage = 'all';
Tester\Assert::same('all', $this->grid->getPerPage());
}
}

$test = new ItemsPerPageTest();
Expand Down
4 changes: 0 additions & 4 deletions tests/Files/TestingPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Ublaboo\DataGrid\Tests\Files;

use Nette\Application\UI\Component;
use Nette\Application\UI\Presenter;
use Ublaboo\DataGrid\DataGrid;

Expand All @@ -31,9 +30,6 @@ public function link(string $destination, $args = []): string
}


/**
* {@inheritDoc}
*/
/*protected function createRequest(
Component $component,
string $destination,
Expand Down

0 comments on commit 9152c0e

Please sign in to comment.