Skip to content

Commit

Permalink
[7.x] phpstan-deprecation-rules (#1061)
Browse files Browse the repository at this point in the history
  • Loading branch information
radimvaculik authored Jan 24, 2023
1 parent 53af3f6 commit eb459b8
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 48 deletions.
2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
includes:
# - vendor/phpstan/phpstan-deprecation-rules/rules.neon
- vendor/phpstan/phpstan-deprecation-rules/rules.neon
- vendor/phpstan/phpstan-nette/extension.neon
- vendor/phpstan/phpstan-nette/rules.neon
- vendor/phpstan/phpstan-strict-rules/rules.neon
Expand Down
6 changes: 3 additions & 3 deletions src/DataGrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
use Nette\Bridges\ApplicationLatte\Template;
use Nette\ComponentModel\IContainer;
use Nette\Forms\Container;
use Nette\Forms\Control as FormControl;
use Nette\Forms\Controls\SubmitButton as FormsSubmitButton;
use Nette\Forms\Form as NetteForm;
use Nette\Forms\IControl;
use Nette\Http\SessionSection;
use Nette\Localization\Translator;
use Nette\Utils\ArrayHash;
Expand Down Expand Up @@ -1146,7 +1146,7 @@ public function createComponentFilter(): Form
->setValidationScope([$inlineAddContainer]);
$inlineAddContainer->addSubmit('cancel', 'ublaboo_datagrid.cancel')
->setValidationScope(null)
->setAttribute('data-datagrid-cancel-inline-add', true);
->setHtmlAttribute('data-datagrid-cancel-inline-add', true);

$this->inlineAdd->onControlAdd($inlineAddContainer);
$this->inlineAdd->onControlAfterAdd($inlineAddContainer);
Expand Down Expand Up @@ -1233,7 +1233,7 @@ public function setFilterContainerDefaults(Container $container, array $values,
}

try {
if (!$control instanceof IControl) {
if (!$control instanceof FormControl) {
throw new UnexpectedValueException();
}

Expand Down
6 changes: 3 additions & 3 deletions src/Filter/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ public function getAttributes(): array
protected function addAttributes(BaseControl $input): BaseControl
{
if ($this->grid->hasAutoSubmit()) {
$input->setAttribute('data-autosubmit', true);
$input->setHtmlAttribute('data-autosubmit', true);
} else {
$input->setAttribute('data-datagrid-manualsubmit', true);
$input->setHtmlAttribute('data-datagrid-manualsubmit', true);
}

foreach ($this->attributes as $key => $value) {
Expand All @@ -168,7 +168,7 @@ protected function addAttributes(BaseControl $input): BaseControl
$value = implode(' ', $value);
}

$input->setAttribute($key, $value);
$input->setHtmlAttribute($key, $value);
}

return $input;
Expand Down
14 changes: 7 additions & 7 deletions src/Filter/FilterDate.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@ public function addToFormContainer(Container $container): void
{
$control = $container->addText($this->key, $this->name);

$control->setAttribute('data-provide', 'datepicker')
->setAttribute('data-date-orientation', 'bottom')
->setAttribute('data-date-format', $this->getJsFormat())
->setAttribute('data-date-today-highlight', 'true')
->setAttribute('data-date-autoclose', 'true');
$control->setHtmlAttribute('data-provide', 'datepicker')
->setHtmlAttribute('data-date-orientation', 'bottom')
->setHtmlAttribute('data-date-format', $this->getJsFormat())
->setHtmlAttribute('data-date-today-highlight', 'true')
->setHtmlAttribute('data-date-autoclose', 'true');

$this->addAttributes($control);

if ($this->grid->hasAutoSubmit()) {
$control->setAttribute('data-autosubmit-change', true);
$control->setHtmlAttribute('data-autosubmit-change', true);
}

if ($this->getPlaceholder() !== null) {
$control->setAttribute('placeholder', $this->getPlaceholder());
$control->setHtmlAttribute('placeholder', $this->getPlaceholder());
}
}

Expand Down
28 changes: 14 additions & 14 deletions src/Filter/FilterDateRange.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,26 @@ public function addToFormContainer(Container $container): void

$from = $container->addText('from', $this->name);

$from->setAttribute('data-provide', 'datepicker')
->setAttribute('data-date-orientation', 'bottom')
->setAttribute('data-date-format', $this->getJsFormat())
->setAttribute('data-date-today-highlight', 'true')
->setAttribute('data-date-autoclose', 'true');
$from->setHtmlAttribute('data-provide', 'datepicker')
->setHtmlAttribute('data-date-orientation', 'bottom')
->setHtmlAttribute('data-date-format', $this->getJsFormat())
->setHtmlAttribute('data-date-today-highlight', 'true')
->setHtmlAttribute('data-date-autoclose', 'true');

$to = $container->addText('to', $this->nameSecond);

$to->setAttribute('data-provide', 'datepicker')
->setAttribute('data-date-orientation', 'bottom')
->setAttribute('data-date-format', $this->getJsFormat())
->setAttribute('data-date-today-highlight', 'true')
->setAttribute('data-date-autoclose', 'true');
$to->setHtmlAttribute('data-provide', 'datepicker')
->setHtmlAttribute('data-date-orientation', 'bottom')
->setHtmlAttribute('data-date-format', $this->getJsFormat())
->setHtmlAttribute('data-date-today-highlight', 'true')
->setHtmlAttribute('data-date-autoclose', 'true');

$this->addAttributes($from);
$this->addAttributes($to);

if ($this->grid->hasAutoSubmit()) {
$from->setAttribute('data-autosubmit-change', true);
$to->setAttribute('data-autosubmit-change', true);
$from->setHtmlAttribute('data-autosubmit-change', true);
$to->setHtmlAttribute('data-autosubmit-change', true);
}

$placeholders = $this->getPlaceholders();
Expand All @@ -51,13 +51,13 @@ public function addToFormContainer(Container $container): void
$textFrom = reset($placeholders);

if ($textFrom) {
$from->setAttribute('placeholder', $textFrom);
$from->setHtmlAttribute('placeholder', $textFrom);
}

$textTo = end($placeholders);

if ($textTo && ($textTo !== $textFrom)) {
$to->setAttribute('placeholder', $textTo);
$to->setHtmlAttribute('placeholder', $textTo);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Filter/FilterRange.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ public function addToFormContainer(Container $container): void
$text_from = reset($placeholders);

if ($text_from) {
$from->setAttribute('placeholder', $text_from);
$from->setHtmlAttribute('placeholder', $text_from);
}

$text_to = end($placeholders);

if ($text_to && ($text_to !== $text_from)) {
$to->setAttribute('placeholder', $text_to);
$to->setHtmlAttribute('placeholder', $text_to);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Filter/FilterText.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function addToFormContainer(Container $container): void
$this->addAttributes($control);

if ($this->getPlaceholder() !== null) {
$control->setAttribute('placeholder', $this->getPlaceholder());
$control->setHtmlAttribute('placeholder', $this->getPlaceholder());
}
}

Expand Down
22 changes: 11 additions & 11 deletions src/GroupAction/GroupActionCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ public function addToFormContainer(Container $container): void
/**
* User may set a class to the form control
*/
$control->setAttribute('class', $action->getClass());
$control->setHtmlAttribute('class', $action->getClass());

/**
* User may set additional attribtues to the form control
*/
foreach ($action->getAttributes() as $name => $value) {
$control->setAttribute($name, $value);
$control->setHtmlAttribute($name, $value);
}
}
}
Expand All @@ -78,27 +78,27 @@ public function addToFormContainer(Container $container): void
if ($action->hasOptions()) {
if ($action instanceof GroupMultiSelectAction) {
$control = $container->addMultiSelect((string) $id, '', $action->getOptions());
$control->setAttribute('data-datagrid-multiselect-id', $lookupPath . self::ID_ATTRIBUTE_PREFIX . $id);
$control->setAttribute('data-style', 'hidden');
$control->setAttribute('data-selected-icon-check', DataGrid::$iconPrefix . 'check');
$control->setHtmlAttribute('data-datagrid-multiselect-id', $lookupPath . self::ID_ATTRIBUTE_PREFIX . $id);
$control->setHtmlAttribute('data-style', 'hidden');
$control->setHtmlAttribute('data-selected-icon-check', DataGrid::$iconPrefix . 'check');
} else {
$control = $container->addSelect((string) $id, '', $action->getOptions());
}

$control->setAttribute('id', $lookupPath . self::ID_ATTRIBUTE_PREFIX . $id);
$control->setHtmlAttribute('id', $lookupPath . self::ID_ATTRIBUTE_PREFIX . $id);
}
} elseif ($action instanceof GroupTextAction) {
$control = $container->addText((string) $id, '');

$control->setAttribute('id', $lookupPath . self::ID_ATTRIBUTE_PREFIX . $id)
$control->setHtmlAttribute('id', $lookupPath . self::ID_ATTRIBUTE_PREFIX . $id)
->addConditionOn($groupActionSelect, Form::EQUAL, $id)
->setRequired('ublaboo_datagrid.choose_input_required')
->endCondition();

} elseif ($action instanceof GroupTextareaAction) {
$control = $container->addTextArea((string) $id, '');

$control->setAttribute('id', $lookupPath . self::ID_ATTRIBUTE_PREFIX . $id)
$control->setHtmlAttribute('id', $lookupPath . self::ID_ATTRIBUTE_PREFIX . $id)
->addConditionOn($groupActionSelect, Form::EQUAL, $id)
->setRequired('ublaboo_datagrid.choose_input_required');
}
Expand All @@ -107,13 +107,13 @@ public function addToFormContainer(Container $container): void
/**
* User may set a class to the form control
*/
$control->setAttribute('class', $action->getClass());
$control->setHtmlAttribute('class', $action->getClass());

/**
* User may set additional attribtues to the form control
*/
foreach ($action->getAttributes() as $name => $value) {
$control->setAttribute($name, $value);
$control->setHtmlAttribute($name, $value);
}
}
}
Expand All @@ -131,7 +131,7 @@ public function addToFormContainer(Container $container): void

$container->addSubmit('submit', 'ublaboo_datagrid.execute')
->setValidationScope([$container])
->setAttribute(
->setHtmlAttribute(
'id',
strtolower($this->datagrid->getFullName()) . 'group_action_submit'
);
Expand Down
2 changes: 1 addition & 1 deletion src/Utils/ItemDetailForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ private function getHttpData(): mixed
throw new UnexpectedValueException();
}

$path = explode(self::NAME_SEPARATOR, $lookupPath);
$path = explode(self::NameSeparator, $lookupPath);

$this->httpPost = Arrays::get($form->getHttpData(), $path, null);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Utils/NetteDatabaseSelectionHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

namespace Ublaboo\DataGrid\Utils;

use Nette\Database\ISupplementalDriver;
use Nette\Database\Driver;
use Nette\Database\Table\Selection;
use ReflectionClass;

final class NetteDatabaseSelectionHelper
{

public static function getDriver(Selection $selection): ISupplementalDriver
public static function getDriver(Selection $selection): Driver
{
$connection = self::getContext($selection)->getConnection();

Expand Down
6 changes: 3 additions & 3 deletions tests/Files/TestPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace Ublaboo\DataGrid\Tests\Files;

use Mockery;
use Nette\Application\UI\ITemplate;
use Nette\Application\UI\Presenter;
use Nette\Application\UI\Template;

final class TestPresenter extends Presenter
{
Expand All @@ -14,9 +14,9 @@ protected function createComponentGrid(): TestGridControl
return new TestGridControl();
}

protected function createTemplate(): ITemplate
protected function createTemplate(): Template
{
return Mockery::mock(ITemplate::class)
return Mockery::mock(Template::class)
->shouldReceive('getFile')
->andReturn(__DIR__ . '/template.latte')
->getMock();
Expand Down

0 comments on commit eb459b8

Please sign in to comment.