From e2c42b7c01da10ad2577093f8e0f81bf6774c0b1 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Tue, 14 Jul 2026 00:53:31 +0200 Subject: [PATCH 1/9] phpstan: Rename config to .dist.neon This will allow users to create their own configs overwriting e.g. `editorUrl` parameter in `phpstan.neon`. https://phpstan.org/config-reference#config-file https://phpstan.org/config-reference#clickable-editor-url Add the old name to `.gitignore` to avoid accidentally commiting it. --- .gitignore | 1 + .phpstan.neon => phpstan.dist.neon | 0 2 files changed, 1 insertion(+) rename .phpstan.neon => phpstan.dist.neon (100%) diff --git a/.gitignore b/.gitignore index 0e36ec8..8ba2eba 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /vendor /composer.lock /.idea +/phpstan.neon diff --git a/.phpstan.neon b/phpstan.dist.neon similarity index 100% rename from .phpstan.neon rename to phpstan.dist.neon From 1e4a1ebb8b8d02513ee28d41a7acff1f00c1de1a Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Tue, 14 Jul 2026 00:58:18 +0200 Subject: [PATCH 2/9] phpstan: Include sources and level in the config To allow running PHPStan without extra arguments. Picked the values used by Travis CI config. --- phpstan.dist.neon | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/phpstan.dist.neon b/phpstan.dist.neon index 25bf1ec..a3049a7 100644 --- a/phpstan.dist.neon +++ b/phpstan.dist.neon @@ -1,3 +1,8 @@ includes: - vendor/phpstan/phpstan-nette/extension.neon - vendor/phpstan/phpstan-nette/rules.neon + +parameters: + level: 7 + paths: + - src From be57af5637e89b4771fd8f91205f26440537c270 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Tue, 14 Jul 2026 00:58:33 +0200 Subject: [PATCH 3/9] composer: Add phpstan script For convenience. --- composer.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/composer.json b/composer.json index ea00042..83ac8ac 100644 --- a/composer.json +++ b/composer.json @@ -35,6 +35,9 @@ "autoload": { "psr-4": { "Nextras\\FormsRendering\\": "src/" } }, + "scripts": { + "phpstan": "phpstan analyze" + }, "autoload-dev": { "psr-4": { "NextrasDemos\\FormsRendering\\LatteMacros\\": "examples/lattemacros/", From aa7e236adf4ffcc8f3fe569a9f4f20c7ce6bb4b1 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Tue, 14 Jul 2026 01:15:20 +0200 Subject: [PATCH 4/9] LatteTags: Support nette/forms 3.3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `endLine` property was dropped: https://github.com/nette/forms/commit/c494415c85728221c8007bffec15e6c149c19f98 Let’s resort to duck typing for now so that we do not depend on a too-new version. --- src/LatteTags/LabelNode.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/LatteTags/LabelNode.php b/src/LatteTags/LabelNode.php index ca6e386..33590b5 100644 --- a/src/LatteTags/LabelNode.php +++ b/src/LatteTags/LabelNode.php @@ -33,7 +33,8 @@ public function print(PrintContext $context): string $this->attributes, $this->position, $this->content, - $this->endLine + // TODO: Drop the `endLine` support once we no longer support forms < 3.3. + property_exists($this, 'endLine') ? $this->endLine : end($this->tagRanges), ); } From 97fce17a73492451ed62d9c35870038bd2d19572 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Tue, 14 Jul 2026 01:19:13 +0200 Subject: [PATCH 5/9] Bs{4,5}FormRenderer: Fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes PHPStan errors – thes could actually happen when the form contains a `Nette\Forms\Control` subclass that is not an instance of `BaseControl`. Most controls will satisfy it but we do not want to limit ourselves to that with `instanceof` check since we also want to support third-party controls (e.g. those using `Nextras\FormComponents\Fragments\Traits\BaseControlTrait`). Hence the duck typing. --- src/Renderers/Bs4FormRenderer.php | 2 +- src/Renderers/Bs5FormRenderer.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Renderers/Bs4FormRenderer.php b/src/Renderers/Bs4FormRenderer.php index de1cafb..2397ed4 100644 --- a/src/Renderers/Bs4FormRenderer.php +++ b/src/Renderers/Bs4FormRenderer.php @@ -147,7 +147,7 @@ private function controlsInit(): void } foreach ($this->form->getControls() as $control) { - if ($this->layout === FormLayout::INLINE && !$control instanceof Controls\Checkbox) { + if ($this->layout === FormLayout::INLINE && !$control instanceof Controls\Checkbox && method_exists($control, 'getLabelPrototype')) { $control->getLabelPrototype()->addClass('my-1')->addClass('mr-2'); } diff --git a/src/Renderers/Bs5FormRenderer.php b/src/Renderers/Bs5FormRenderer.php index 8d6a025..c920aef 100644 --- a/src/Renderers/Bs5FormRenderer.php +++ b/src/Renderers/Bs5FormRenderer.php @@ -151,13 +151,13 @@ private function controlsInit(): void } foreach ($this->form->getControls() as $control) { - if ($this->layout === FormLayout::INLINE) { + if ($this->layout === FormLayout::INLINE && method_exists($control, 'getLabelPrototype')) { // Unfortunately, the aforementioned solution does not seem to expect labels // so we need to add some hacks. Notably, `.form-control`, `.form-select` and // others add `display: block`, forcing the control onto a next line. // The checkboxes are exception since they have their own inline class. - if (!$control instanceof Controls\Checkbox && !$control instanceof Controls\CheckboxList && !$control instanceof Controls\RadioList) { + if (!$control instanceof Controls\Checkbox && !$control instanceof Controls\CheckboxList && !$control instanceof Controls\RadioList && method_exists($control, 'getControlPrototype')) { $control->getControlPrototype()->addClass('d-inline-block'); // But setting `display: inline-block` is not enough since the widgets will inherit From 8e6d1a66e298a9f6466a5b4b64c0facf8724675a Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Tue, 14 Jul 2026 01:24:36 +0200 Subject: [PATCH 6/9] ci: Switch to GitHub actions We only have PHPStan but that is better than nothing. --- .github/workflows/build.yaml | 32 ++++++++++++++++++++++++++++++++ .travis.yml | 24 ------------------------ readme.md | 2 +- 3 files changed, 33 insertions(+), 25 deletions(-) create mode 100644 .github/workflows/build.yaml delete mode 100644 .travis.yml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..2dca508 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,32 @@ +name: "Build" + +on: + pull_request: + push: + branches: + - master + +jobs: + phpstan: + name: PHPStan + + runs-on: ubuntu-latest + + strategy: + matrix: + php-version: [ '8.0', '8.1', '8.2', '8.3', '8.4', '8.5' ] + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + + - name: Install dependencies + run: composer install --prefer-dist + + - name: Run PHPStan + run: composer phpstan diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 8b9ead9..0000000 --- a/.travis.yml +++ /dev/null @@ -1,24 +0,0 @@ -language: php - -php: - - 7.1 - - 7.2 - - 7.3 - -matrix: - fast_finish: true - -cache: - directories: - - $HOME/.composer/cache - -before_script: - - composer install --no-interaction --prefer-source - -script: - - vendor/bin/phpstan analyze src -l 7 -c .phpstan.neon - -after_failure: - # Print *.actual content & log content - - for i in $(find tests -name \*.actual); do echo "--- $i"; cat $i; echo; echo; done - - for i in $(find tests -name \*.log); do echo "--- $i"; cat $i; echo; echo; done diff --git a/readme.md b/readme.md index c9d2acc..1296d2f 100644 --- a/readme.md +++ b/readme.md @@ -1,7 +1,7 @@ Nextras Forms Rendering ======================= -[![Build Status](https://travis-ci.org/nextras/forms-rendering.svg?branch=master)](https://travis-ci.org/nextras/forms-rendering) +[![Build](https://github.com/nextras/forms-rendering/actions/workflows/build.yaml/badge.svg)](https://github.com/nextras/forms-rendering/actions/workflows/build.yaml) [![Downloads this Month](https://img.shields.io/packagist/dm/nextras/forms-rendering.svg?style=flat)](https://packagist.org/packages/nextras/forms-rendering) [![Stable version](http://img.shields.io/packagist/v/nextras/forms-rendering.svg?style=flat)](https://packagist.org/packages/nextras/forms-rendering) From 1af45cf84dff0ab3aacbc688ffbb343e7fabdcc3 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Tue, 14 Jul 2026 01:25:39 +0200 Subject: [PATCH 7/9] examples: Add type hints Will be needed to satisfy PHPStan. --- examples/lattemacros/LatteMacrosPresenter.php | 4 ++-- examples/renderers/RenderersPresenter.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/lattemacros/LatteMacrosPresenter.php b/examples/lattemacros/LatteMacrosPresenter.php index b26dca4..c24113d 100644 --- a/examples/lattemacros/LatteMacrosPresenter.php +++ b/examples/lattemacros/LatteMacrosPresenter.php @@ -8,12 +8,12 @@ class LatteMacrosPresenter extends Presenter { - public function actionDefault() + public function actionDefault(): void { } - public function createComponentForm() + public function createComponentForm(): Form { $form = new Form(); $form->addText('text', 'Name'); diff --git a/examples/renderers/RenderersPresenter.php b/examples/renderers/RenderersPresenter.php index dc343db..8a03322 100644 --- a/examples/renderers/RenderersPresenter.php +++ b/examples/renderers/RenderersPresenter.php @@ -25,14 +25,14 @@ class RenderersPresenter extends Presenter public $showBulky = true; - public function actionDefault() + public function actionDefault(): void { $this->template->renderer = $this->renderer; $this->template->showBulky = $this->showBulky; } - public function createComponentForm() + public function createComponentForm(): Form { $form = new Form(); $form->addText('text', 'Name'); From fee55f42310eb1fc192c03f82655ff150d2561d7 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Tue, 14 Jul 2026 01:26:09 +0200 Subject: [PATCH 8/9] phpstan: Scan `examples/` --- phpstan.dist.neon | 1 + 1 file changed, 1 insertion(+) diff --git a/phpstan.dist.neon b/phpstan.dist.neon index a3049a7..f0ef0e6 100644 --- a/phpstan.dist.neon +++ b/phpstan.dist.neon @@ -6,3 +6,4 @@ parameters: level: 7 paths: - src + - examples From a3d5fbc69cf97de53e1495caf1005e7514f26d2b Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Tue, 14 Jul 2026 01:27:02 +0200 Subject: [PATCH 9/9] phpstan: Raise level to `max` --- phpstan.dist.neon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpstan.dist.neon b/phpstan.dist.neon index f0ef0e6..ead69a6 100644 --- a/phpstan.dist.neon +++ b/phpstan.dist.neon @@ -3,7 +3,7 @@ includes: - vendor/phpstan/phpstan-nette/rules.neon parameters: - level: 7 + level: max paths: - src - examples