Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/vendor
/composer.lock
/.idea
/phpstan.neon
24 changes: 0 additions & 24 deletions .travis.yml

This file was deleted.

3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
"autoload": {
"psr-4": { "Nextras\\FormsRendering\\": "src/" }
},
"scripts": {
"phpstan": "phpstan analyze"
},
"autoload-dev": {
"psr-4": {
"NextrasDemos\\FormsRendering\\LatteMacros\\": "examples/lattemacros/",
Expand Down
4 changes: 2 additions & 2 deletions examples/lattemacros/LatteMacrosPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
4 changes: 2 additions & 2 deletions examples/renderers/RenderersPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
6 changes: 6 additions & 0 deletions .phpstan.neon → phpstan.dist.neon
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
includes:
- vendor/phpstan/phpstan-nette/extension.neon
- vendor/phpstan/phpstan-nette/rules.neon

parameters:
level: max
paths:
- src
- examples
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
3 changes: 2 additions & 1 deletion src/LatteTags/LabelNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Renderers/Bs4FormRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

Expand Down
4 changes: 2 additions & 2 deletions src/Renderers/Bs5FormRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down