Skip to content

Commit dc7fc3d

Browse files
radimvaculikf3l1x
authored andcommitted
Fix: PHPStan errors in Datagrid and FilterSelect/FilterMultiSelect
Use Nette\Application\UI\Presenter for lookupPath (IPresenter is not an IComponent) and remove redundant Form instanceof checks where lookup() already guarantees the type.
1 parent e5faff0 commit dc7fc3d

3 files changed

Lines changed: 3 additions & 12 deletions

File tree

src/Datagrid.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
use InvalidArgumentException;
4848
use Nette\Application\Attributes\Persistent;
4949
use Nette\Application\ForbiddenRequestException;
50-
use Nette\Application\IPresenter;
5150
use Nette\Application\Request;
5251
use Nette\Application\UI\Component;
5352
use Nette\Application\UI\Control;
@@ -2815,15 +2814,15 @@ public function getParentComponent(): Component
28152814
*/
28162815
public function getSortableParentPath(): string
28172816
{
2818-
if ($this->getParentComponent() instanceof IPresenter) {
2817+
if ($this->getParentComponent() instanceof Presenter) {
28192818
return '';
28202819
}
28212820

2822-
$presenter = $this->getParentComponent()->lookupPath(IPresenter::class, false);
2821+
$presenter = $this->getParentComponent()->lookupPath(Presenter::class, false);
28232822

28242823
if ($presenter === null) {
28252824
throw new UnexpectedValueException(
2826-
sprintf('%s needs %s', self::class, IPresenter::class)
2825+
sprintf('%s needs %s', self::class, Presenter::class)
28272826
);
28282827
}
28292828

src/Filter/FilterMultiSelect.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,6 @@ protected function addControl(
5757
*/
5858
$form = $container->lookup(Form::class);
5959

60-
if (!$form instanceof Form) {
61-
throw new UnexpectedValueException();
62-
}
63-
6460
$translator = $form->getTranslator();
6561

6662
if ($translator === null) {

src/Filter/FilterSelect.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@ public function addToFormContainer(Container $container): void
3838
{
3939
$form = $container->lookup(Form::class);
4040

41-
if (!$form instanceof Form) {
42-
throw new UnexpectedValueException();
43-
}
44-
4541
$translator = $form->getTranslator();
4642

4743
if ($translator === null) {

0 commit comments

Comments
 (0)