diff --git a/phpstan-ext.neon b/phpstan-ext.neon new file mode 100644 index 0000000000..e173c71574 --- /dev/null +++ b/phpstan-ext.neon @@ -0,0 +1,31 @@ +services: + # move to atk4/core later (or at least atk4/data) + - + factory: Mvorisek\Atk4\Hintable\Phpstan\SeedDmrtExtension(Atk4\Core\Factory, factory, 0) + tags: + - phpstan.broker.dynamicStaticMethodReturnTypeExtension + + - + factory: Mvorisek\Atk4\Hintable\Phpstan\SeedDmrtExtension(Atk4\Ui\AbstractView, add, 0) + tags: + - phpstan.broker.dynamicMethodReturnTypeExtension + - + factory: Mvorisek\Atk4\Hintable\Phpstan\SeedDmrtExtension(Atk4\Ui\Columns, addColumn, 0) + tags: + - phpstan.broker.dynamicMethodReturnTypeExtension + - + factory: Mvorisek\Atk4\Hintable\Phpstan\SeedDmrtExtension(Atk4\Ui\Form, addControl, 1) + tags: + - phpstan.broker.dynamicMethodReturnTypeExtension + - + factory: Mvorisek\Atk4\Hintable\Phpstan\SeedDmrtExtension(Atk4\Ui\Form, controlFactory, 1) + tags: + - phpstan.broker.dynamicMethodReturnTypeExtension + - + factory: Mvorisek\Atk4\Hintable\Phpstan\SeedDmrtExtension(Atk4\Ui\Grid, addColumn, 1) + tags: + - phpstan.broker.dynamicMethodReturnTypeExtension + - + factory: Mvorisek\Atk4\Hintable\Phpstan\SeedDmrtExtension(Atk4\Ui\Table, addColumn, 1) + tags: + - phpstan.broker.dynamicMethodReturnTypeExtension diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 03b1700ef4..ecb3c0757f 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -1,5 +1,7 @@ includes: - phar://phpstan.phar/conf/bleedingEdge.neon + # remove once https://github.com/phpstan/extension-installer/issues/36 is fixed + - phpstan-ext.neon parameters: level: 6 @@ -38,10 +40,13 @@ parameters: message: '~^Call to an undefined method Atk4\\Ui\\View::addFields\(\)\.$~' - path: 'demos/form-control/calendar.php' - message: '~^Call to an undefined method Atk4\\Ui\\Form\\Control::addAction\(\)\.$~' + message: '~^Call to an undefined method Atk4\\Ui\\JsExpression::setDate\(\)\.$~' + - + path: 'demos/form-control/calendar.php' + message: '~^Call to an undefined method Atk4\\Ui\\JsExpression::open\(\)\.$~' - path: 'demos/form-control/calendar.php' - message: '~^Call to an undefined method Atk4\\Ui\\Form\\Control::getJsInstance\(\)\.$~' + message: '~^Call to an undefined method Atk4\\Ui\\JsExpression::clear\(\)\.$~' - path: 'demos/form-control/input2.php' message: '~^Call to an undefined method Atk4\\Ui\\Form\\Control::onDelete\(\)\.$~' @@ -51,21 +56,6 @@ parameters: - path: 'demos/form-control/multiline.php' message: '~^Call to an undefined method Atk4\\Ui\\Form\\Layout::addColumn\(\)\.$~' - - - path: 'demos/form-control/upload.php' - message: '~^Call to an undefined method Atk4\\Ui\\Form\\Control::onDelete\(\)\.$~' - - - path: 'demos/form-control/upload.php' - message: '~^Call to an undefined method Atk4\\Ui\\Form\\Control::clearThumbnail\(\)\.$~' - - - path: 'demos/form-control/upload.php' - message: '~^Call to an undefined method Atk4\\Ui\\Form\\Control::onUpload\(\)\.$~' - - - path: 'demos/form-control/upload.php' - message: '~^Call to an undefined method Atk4\\Ui\\Form\\Control::setThumbnailSrc\(\)\.$~' - - - path: 'demos/form-control/upload.php' - message: '~^Call to an undefined method Atk4\\Ui\\Form\\Control::setFileId\(\)\.$~' - path: 'demos/form/form-section-accordion.php' message: '~^Call to an undefined method Atk4\\Ui\\Form\\Layout::addSection\(\)\.$~' @@ -117,30 +107,15 @@ parameters: - path: 'demos/interactive/wizard.php' message: '~^Access to an undefined property Atk4\\Ui\\Form\\Control::\$placeholder\.$~' - - - path: 'src/CardDeck.php' - message: '~^Access to an undefined property Atk4\\Ui\\AbstractView::\$reload\.$~' - - - path: 'src/CardDeck.php' - message: '~^Access to an undefined property Atk4\\Ui\\AbstractView::\$queryArg\.$~' - path: 'src/CardDeck.php' message: '~^Access to an undefined property Atk4\\Ui\\AbstractView&Atk4\\Ui\\UserAction\\ExecutorInterface::\$jsSuccess\.$~' - - - path: 'src/CardDeck.php' - message: '~^Call to an undefined method Atk4\\Ui\\AbstractView::addClass\(\)\.$~' - - - path: 'src/CardDeck.php' - message: '~^Call to an undefined method Atk4\\Ui\\AbstractView::on\(\)\.$~' - path: 'src/CardDeck.php' message: '~^Call to an undefined method Atk4\\Ui\\AbstractView&Atk4\\Ui\\UserAction\\ExecutorInterface::onHook\(\)\.$~' - path: 'src/Crud.php' message: '~^Call to an undefined method Atk4\\Ui\\UserAction\\JsExecutorInterface::stickyGet\(\)\.$~' - - - path: 'src/Form.php' - message: '~^Call to an undefined method Atk4\\Ui\\AbstractView::addButton\(\)\.$~' - path: 'src/Form.php' message: '~^Call to an undefined method Atk4\\Ui\\Js\\JsChain::preventFormLeave\(\)\.$~' @@ -159,9 +134,6 @@ parameters: - path: 'src/Js/JsVueService.php' message: '~^Call to an undefined method Atk4\\Ui\\Js\\JsChain::createVue\(\)\.$~' - - - path: 'src/Menu.php' - message: '~^Call to an undefined method Atk4\\Ui\\AbstractView::setElement\(\)\.$~' - path: 'src/Menu.php' message: '~^Call to an undefined method Atk4\\Ui\\AbstractView::addClass\(\)\.$~' @@ -190,9 +162,6 @@ parameters: path: 'src/SessionTrait.php' count: 4 message: '~^Access to an undefined property Atk4\\Ui\\Tests\\SessionAbstractMock::\$name\.$~' - - - path: 'src/Table/Column.php' - message: '~^Call to an undefined method Atk4\\Ui\\AbstractView::setHoverable\(\)\.$~' - path: 'src/Table/Column.php' message: '~^Call to an undefined method Atk4\\Ui\\JsCallback::onSelectItem\(\)\.$~' @@ -264,9 +233,6 @@ parameters: # TODO these rules are generated, this ignores should be fixed in the code # for level = 3 - - - path: 'src/Card.php' - message: '~^Method Atk4\\Ui\\Card::addButton\(\) should return Atk4\\Ui\\View\ but returns Atk4\\Ui\\AbstractView\.$~' - path: 'src/CardDeck.php' message: '~^Property Atk4\\Ui\\CardDeck::\$container \(Atk4\\Ui\\View\|null\) does not accept default value of type array\.$~' @@ -276,63 +242,27 @@ parameters: - path: 'src/CardDeck.php' message: '~^Property Atk4\\Ui\\CardDeck::\$paginator \(Atk4\\Ui\\Paginator\|false\|null\) does not accept default value of type array\{''Atk4\\\\Ui\\\\Paginator''\}\.$~' - - - path: 'src/CardDeck.php' - message: '~^Property Atk4\\Ui\\CardDeck::\$container \(Atk4\\Ui\\View\|null\) does not accept Atk4\\Ui\\AbstractView\.$~' - path: 'src/CardDeck.php' message: '~^Property Atk4\\Ui\\CardDeck::\$menu \(array\|false\|null\) does not accept Atk4\\Ui\\AbstractView\.$~' - - - path: 'src/CardDeck.php' - message: '~^Property Atk4\\Ui\\CardDeck::\$search \(array\|Atk4\\Ui\\VueComponent\\ItemSearch\|false\) does not accept Atk4\\Ui\\AbstractView\.$~' - - - path: 'src/CardDeck.php' - message: '~^Property Atk4\\Ui\\CardDeck::\$paginator \(Atk4\\Ui\\Paginator\|false\|null\) does not accept Atk4\\Ui\\AbstractView\.$~' - - - path: 'src/Form/AbstractLayout.php' - message: '~^Method Atk4\\Ui\\Form\\AbstractLayout::_addControl\(\) should return Atk4\\Ui\\Form\\Control but returns Atk4\\Ui\\View\.$~' - path: 'src/Form/Layout.php' message: '~^Method Atk4\\Ui\\Form\\Layout::addButton\(\) should return Atk4\\Ui\\Button but returns Atk4\\Ui\\AbstractView\.$~' - - - path: 'src/Form/Layout.php' - message: '~^Method Atk4\\Ui\\Form\\Layout::_addControl\(\) should return Atk4\\Ui\\Form\\Control but returns Atk4\\Ui\\View\.$~' - path: 'src/Form/Layout.php' message: '~^Method Atk4\\Ui\\Form\\Layout::addSubLayout\(\) should return Atk4\\Ui\\Form\\Layout but returns Atk4\\Ui\\AbstractView\.$~' - path: 'src/Form/Layout/Custom.php' message: '~^Method Atk4\\Ui\\Form\\Layout\\Custom::addButton\(\) should return Atk4\\Ui\\Button but returns Atk4\\Ui\\AbstractView\.$~' - - - path: 'src/Form/Layout/Section.php' - message: '~^Method Atk4\\Ui\\Form\\Layout\\Section::addSection\(\) should return Atk4\\Ui\\Form\\Layout but returns Atk4\\Ui\\AbstractView\.$~' - path: 'src/Form/Layout/Section/Accordion.php' message: '~^Return type \(Atk4\\Ui\\Form\\Layout\) of method Atk4\\Ui\\Form\\Layout\\Section\\Accordion::addSection\(\) should be compatible with return type \(Atk4\\Ui\\AccordionSection\) of method Atk4\\Ui\\Accordion::addSection\(\)$~' - - - path: 'src/Form/Layout/Section/Accordion.php' - message: '~^Method Atk4\\Ui\\Form\\Layout\\Section\\Accordion::addSection\(\) should return Atk4\\Ui\\Form\\Layout but returns Atk4\\Ui\\AbstractView\.$~' - - - path: 'src/Form/Layout/Section/Tabs.php' - message: '~^Method Atk4\\Ui\\Form\\Layout\\Section\\Tabs::addTab\(\) should return Atk4\\Ui\\Form\\Layout but returns Atk4\\Ui\\AbstractView\.$~' - - - path: 'src/Grid.php' - message: '~^Property Atk4\\Ui\\Grid::\$menu \(Atk4\\Ui\\Menu\|false\) does not accept Atk4\\Ui\\AbstractView\.$~' - - - path: 'src/Grid.php' - message: '~^Property Atk4\\Ui\\Grid::\$paginator \(Atk4\\Ui\\Paginator\|false\) does not accept Atk4\\Ui\\AbstractView\.$~' - path: 'src/Grid.php' message: '~^Property Atk4\\Ui\\Grid::\$paginator \(Atk4\\Ui\\Paginator\|false\) does not accept null\.$~' - path: 'src/Grid.php' message: '~^Property Atk4\\Ui\\Grid::\$actionButtons \(Atk4\\Ui\\Table\\Column\\ActionButtons\|null\) does not accept Atk4\\Ui\\Table\\Column\.$~' - - - path: 'src/Grid.php' - message: '~^Property Atk4\\Ui\\Grid::\$selection \(Atk4\\Ui\\Table\\Column\\Checkbox\) does not accept Atk4\\Ui\\Table\\Column\.$~' - - - path: 'src/Grid.php' - message: '~^Method Atk4\\Ui\\Grid::addSelection\(\) should return Atk4\\Ui\\Table\\Column\\Checkbox but returns Atk4\\Ui\\Table\\Column\.$~' - path: 'src/Header.php' message: '~^Property Atk4\\Ui\\Header::\$icon \(string\) does not accept Atk4\\Ui\\Icon\.$~' @@ -375,6 +305,9 @@ parameters: # TODO these rules are generated, this ignores should be fixed in the code # for level = 5 + - + path: 'src/Form.php' + message: '~^Parameter #2 \$value of method Atk4\\Ui\\View::setAttr\(\) expects string\|null, int given\.$~' - path: 'src/Form/Layout/Section.php' message: '~^Parameter #1 \$object of method Atk4\\Ui\\View::add\(\) expects Atk4\\Ui\\AbstractView, array> given\.$~' @@ -405,6 +338,3 @@ parameters: - path: 'src/Panel/Right.php' message: '~^Parameter #1 \$object of method Atk4\\Ui\\App::add\(\) expects Atk4\\Ui\\AbstractView, array given\.$~' - - - path: 'src/Popup.php' - message: '~^Parameter #1 \$view of method Atk4\\Ui\\Callback::terminateJson\(\) expects Atk4\\Ui\\View, Atk4\\Ui\\AbstractView given\.$~' diff --git a/src/App.php b/src/App.php index 37690db54c..e36b2be487 100644 --- a/src/App.php +++ b/src/App.php @@ -463,7 +463,7 @@ public function initLayout($seed) $this->html->invokeInit(); } - $this->layout = $this->html->add($layout); // @phpstan-ignore-line + $this->layout = $this->html->add($layout); $this->initIncludes(); diff --git a/src/CardDeck.php b/src/CardDeck.php index 8d421af52e..97cf06502f 100644 --- a/src/CardDeck.php +++ b/src/CardDeck.php @@ -152,6 +152,7 @@ public function setModel(Model $model, array $fields = null, array $extra = null $count = $this->initPaginator(); if ($count) { foreach ($this->model as $m) { + /** @var Card */ $c = $this->cardHolder->add(Factory::factory([$this->card], ['useLabel' => $this->useLabel, 'useTable' => $this->useTable]))->addClass('segment'); $c->setModel($m, $fields); if ($extra) { diff --git a/src/Form.php b/src/Form.php index 2e43b51e99..137265a15a 100644 --- a/src/Form.php +++ b/src/Form.php @@ -157,7 +157,7 @@ protected function initLayout(): void } if (is_string($this->layout) || is_array($this->layout)) { - $this->layout = $this->add(Factory::factory($this->layout, ['form' => $this])); // @phpstan-ignore-line + $this->layout = $this->add(Factory::factory($this->layout, ['form' => $this])); } elseif (is_object($this->layout)) { $this->layout->form = $this; $this->add($this->layout); diff --git a/src/Grid.php b/src/Grid.php index 94f730d331..d9f29bda6f 100644 --- a/src/Grid.php +++ b/src/Grid.php @@ -119,7 +119,7 @@ protected function init(): void $appUniqueHashesBackup = $this->getApp()->uniqueNameHashes; $menuElementNameCountsBackup = \Closure::bind(fn () => $this->_elementNameCounts, $this->menu, AbstractView::class)(); try { - $menuRight = $this->menu->addMenuRight(); // @phpstan-ignore-line + $menuRight = $this->menu->addMenuRight(); $menuItemView = View::addTo($menuRight->addItem()->setElement('div')); $quickSearch = JsSearch::addTo($menuItemView); $this->stickyGet($quickSearch->name . '_q'); diff --git a/src/Panel/Content.php b/src/Panel/Content.php index ba2a36003b..f00964685b 100644 --- a/src/Panel/Content.php +++ b/src/Panel/Content.php @@ -40,7 +40,7 @@ public function getCallbackUrl(): string */ public function setCb(Callback $cb): void { - $this->cb = $this->add($cb); // @phpstan-ignore-line + $this->cb = $this->add($cb); } /**