From 48328d9f26af0000039ca2eb401676436ccf568f Mon Sep 17 00:00:00 2001 From: Alex Bouma Date: Thu, 17 Feb 2022 12:50:46 +0100 Subject: [PATCH 1/8] Add testing for PHP 8.1 --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 7d2e98d3..71fa71a9 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -8,7 +8,7 @@ jobs: fail-fast: true matrix: os: [ ubuntu-latest, windows-latest ] - php: [ "8.0", "7.4", "7.3", "7.2" ] + php: [ "8.1", "8.0", "7.4", "7.3", "7.2" ] name: PHP ${{ matrix.php }} - ${{ matrix.os }} runs-on: ${{ matrix.os }} From 9a88328390abc3add9fb01136688a19b215e6760 Mon Sep 17 00:00:00 2001 From: Alex Bouma Date: Thu, 17 Feb 2022 12:50:58 +0100 Subject: [PATCH 2/8] Allow installation on Laravel 9 --- composer.json | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/composer.json b/composer.json index 0bff30c8..45b8dc26 100644 --- a/composer.json +++ b/composer.json @@ -18,19 +18,19 @@ "require": { "php": "^7.2|^8.0", "anahkiasen/html-object": "~1.4", - "illuminate/config": "^5.1.3|^6.0|^7.0|^8.0", - "illuminate/container": "^5.1.3|^6.0|^7.0|^8.0", - "illuminate/contracts": "^5.1.3|^6.0|^7.0|^8.0", - "illuminate/http": "^5.1.3|^6.0|^7.0|^8.0", - "illuminate/routing": "^5.1.3|^6.0|^7.0|^8.0", - "illuminate/session": "^5.1.3|^6.0|^7.0|^8.0", - "illuminate/translation": "^5.1.3|^6.0|^7.0|^8.0", - "illuminate/support": "^5.1.3|^6.0|^7.0|^8.0" + "illuminate/config": "^5.1.3|^6.0|^7.0|^8.0|^9.0", + "illuminate/container": "^5.1.3|^6.0|^7.0|^8.0|^9.0", + "illuminate/contracts": "^5.1.3|^6.0|^7.0|^8.0|^9.0", + "illuminate/http": "^5.1.3|^6.0|^7.0|^8.0|^9.0", + "illuminate/routing": "^5.1.3|^6.0|^7.0|^8.0|^9.0", + "illuminate/session": "^5.1.3|^6.0|^7.0|^8.0|^9.0", + "illuminate/translation": "^5.1.3|^6.0|^7.0|^8.0|^9.0", + "illuminate/support": "^5.1.3|^6.0|^7.0|^8.0|^9.0" }, "require-dev": { "phpunit/phpunit": "^8.5", "mockery/mockery": "^1.3", - "illuminate/database": "^5.1.3|^6.0|^7.0|^8.0" + "illuminate/database": "^5.1.3|^6.0|^7.0|^8.0|^9.0" }, "autoload": { "psr-4": { From 5c595b8cd47fb271b10f281e6450617e20eaddb9 Mon Sep 17 00:00:00 2001 From: Alex Bouma Date: Thu, 23 Mar 2023 10:14:36 +0100 Subject: [PATCH 3/8] Allow installation on Laravel 10 (#612) --- .github/workflows/tests.yml | 6 +++--- composer.json | 20 ++++++++++---------- src/Former/Form/Elements.php | 4 ++-- src/Former/Form/Fields/Choice.php | 4 ++-- src/Former/Form/Group.php | 2 +- src/Former/Former.php | 2 +- src/Former/Framework/Nude.php | 4 ++-- src/Former/Framework/TwitterBootstrap.php | 4 ++-- src/Former/Framework/TwitterBootstrap3.php | 4 ++-- src/Former/Framework/TwitterBootstrap4.php | 4 ++-- src/Former/Helpers.php | 2 +- src/Former/Traits/Checkable.php | 6 +++--- tests/Dummy/DummyButton.php | 2 ++ tests/Fields/RadioTest.php | 2 +- tests/Framework/TwitterBootstrapTest.php | 4 ++-- tests/GroupTest.php | 4 ++-- tests/TestCases/FormerTests.php | 4 ++-- 17 files changed, 40 insertions(+), 38 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 71fa71a9..d51f2329 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -8,17 +8,17 @@ jobs: fail-fast: true matrix: os: [ ubuntu-latest, windows-latest ] - php: [ "8.1", "8.0", "7.4", "7.3", "7.2" ] + php: [ "8.2", "8.1", "8.0", "7.4", "7.3", "7.2" ] name: PHP ${{ matrix.php }} - ${{ matrix.os }} runs-on: ${{ matrix.os }} steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Cache dependencies - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: ~/.composer/cache/files key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }} diff --git a/composer.json b/composer.json index 45b8dc26..d5189ae2 100644 --- a/composer.json +++ b/composer.json @@ -17,20 +17,20 @@ ], "require": { "php": "^7.2|^8.0", - "anahkiasen/html-object": "~1.4", - "illuminate/config": "^5.1.3|^6.0|^7.0|^8.0|^9.0", - "illuminate/container": "^5.1.3|^6.0|^7.0|^8.0|^9.0", - "illuminate/contracts": "^5.1.3|^6.0|^7.0|^8.0|^9.0", - "illuminate/http": "^5.1.3|^6.0|^7.0|^8.0|^9.0", - "illuminate/routing": "^5.1.3|^6.0|^7.0|^8.0|^9.0", - "illuminate/session": "^5.1.3|^6.0|^7.0|^8.0|^9.0", - "illuminate/translation": "^5.1.3|^6.0|^7.0|^8.0|^9.0", - "illuminate/support": "^5.1.3|^6.0|^7.0|^8.0|^9.0" + "illuminate/config": "^5.1.3|^6.0|^7.0|^8.0|^9.0|^10.0", + "illuminate/container": "^5.1.3|^6.0|^7.0|^8.0|^9.0|^10.0", + "illuminate/contracts": "^5.1.3|^6.0|^7.0|^8.0|^9.0|^10.0", + "illuminate/http": "^5.1.3|^6.0|^7.0|^8.0|^9.0|^10.0", + "illuminate/routing": "^5.1.3|^6.0|^7.0|^8.0|^9.0|^10.0", + "illuminate/session": "^5.1.3|^6.0|^7.0|^8.0|^9.0|^10.0", + "illuminate/translation": "^5.1.3|^6.0|^7.0|^8.0|^9.0|^10.0", + "illuminate/support": "^5.1.3|^6.0|^7.0|^8.0|^9.0|^10.0", + "kylekatarnls/html-object": "^1.5" }, "require-dev": { "phpunit/phpunit": "^8.5", "mockery/mockery": "^1.3", - "illuminate/database": "^5.1.3|^6.0|^7.0|^8.0|^9.0" + "illuminate/database": "^5.1.3|^6.0|^7.0|^8.0|^9.0|^10.0" }, "autoload": { "psr-4": { diff --git a/src/Former/Form/Elements.php b/src/Former/Form/Elements.php index 72ac6c97..99d415e3 100644 --- a/src/Former/Form/Elements.php +++ b/src/Former/Form/Elements.php @@ -62,7 +62,7 @@ public function label($label, $for = null, $attributes = array()) { if (!$label instanceof Htmlable) { $oldLabel = (string) $label; - $label = Helpers::translate($oldLabel); + $label = Helpers::translate($oldLabel, ''); // If there was no change to the label, // then a Laravel translation did not occur @@ -70,7 +70,7 @@ public function label($label, $for = null, $attributes = array()) $label = str_replace('_', ' ', $label); } } else { - $label = (string) $label->toHtml(); + $label = $label->toHtml(); } $attributes['for'] = $for; diff --git a/src/Former/Form/Fields/Choice.php b/src/Former/Form/Fields/Choice.php index 652e217b..c67d4609 100644 --- a/src/Former/Form/Fields/Choice.php +++ b/src/Former/Form/Fields/Choice.php @@ -191,7 +191,7 @@ public function getOption($key, $value) public function getCheckables($choiceType) { - if (!(is_array($this->value) || $this->value instanceof \ArrayAccess)) { + if ($this->value !== null && !(is_array($this->value) || $this->value instanceof \ArrayAccess)) { $this->value = explode(',', $this->value); } @@ -233,7 +233,7 @@ public function getCheckables($choiceType) } // If inline items, add class - $isInline = $this->inline ? ' '.$this->app['former.framework']->getInlineLabelClass($this) : null; + $isInline = $this->inline ? ' '.$this->app['former.framework']->getInlineLabelClass($this) : ''; // In Bootsrap 3, don't append the the checkable type (radio/checkbox) as a class if // rendering inline. diff --git a/src/Former/Form/Group.php b/src/Former/Form/Group.php index ffbe9225..8b49408f 100644 --- a/src/Former/Form/Group.php +++ b/src/Former/Form/Group.php @@ -440,7 +440,7 @@ protected function getHelp() $inline = $this->app['former.framework']->createValidationError($errors); } - return join(null, array($inline, $block)); + return implode('', array($inline, $block)); } /** diff --git a/src/Former/Former.php b/src/Former/Former.php index b6955cd7..17f9363e 100644 --- a/src/Former/Former.php +++ b/src/Former/Former.php @@ -250,7 +250,7 @@ public function getValue($field, $fallback = null) */ public function getPost($name, $fallback = null) { - $name = str_replace(array('[', ']'), array('.', ''), $name); + $name = str_replace(array('[', ']'), array('.', ''), $name ?? ''); $name = trim($name, '.'); $oldValue = $this->app['request']->old($name, $fallback); diff --git a/src/Former/Framework/Nude.php b/src/Former/Framework/Nude.php index 5fab121c..69be716b 100644 --- a/src/Former/Framework/Nude.php +++ b/src/Former/Framework/Nude.php @@ -161,9 +161,9 @@ public function placeAround($item) public function prependAppend($field, $prepend, $append) { $return = '
'; - $return .= join(null, $prepend); + $return .= implode('', $prepend); $return .= $field->render(); - $return .= join(null, $append); + $return .= implode('', $append); $return .= '
'; return $return; diff --git a/src/Former/Framework/TwitterBootstrap.php b/src/Former/Framework/TwitterBootstrap.php index 64ba7453..2d95c424 100644 --- a/src/Former/Framework/TwitterBootstrap.php +++ b/src/Former/Framework/TwitterBootstrap.php @@ -353,9 +353,9 @@ public function prependAppend($field, $prepend, $append) } $return = '
'; - $return .= join(null, $prepend); + $return .= implode('', $prepend); $return .= $field->render(); - $return .= join(null, $append); + $return .= implode('', $append); $return .= '
'; return $return; diff --git a/src/Former/Framework/TwitterBootstrap3.php b/src/Former/Framework/TwitterBootstrap3.php index c6a0a974..583c028c 100644 --- a/src/Former/Framework/TwitterBootstrap3.php +++ b/src/Former/Framework/TwitterBootstrap3.php @@ -406,9 +406,9 @@ public function placeAround($item) public function prependAppend($field, $prepend, $append) { $return = '
'; - $return .= join(null, $prepend); + $return .= implode('', $prepend); $return .= $field->render(); - $return .= join(null, $append); + $return .= implode('', $append); $return .= '
'; return $return; diff --git a/src/Former/Framework/TwitterBootstrap4.php b/src/Former/Framework/TwitterBootstrap4.php index 08f9b4b6..8e280821 100644 --- a/src/Former/Framework/TwitterBootstrap4.php +++ b/src/Former/Framework/TwitterBootstrap4.php @@ -430,9 +430,9 @@ public function placeAround($item) public function prependAppend($field, $prepend, $append) { $return = '
'; - $return .= join(null, $prepend); + $return .= implode('', $prepend); $return .= $field->render(); - $return .= join(null, $append); + $return .= implode('', $append); $return .= '
'; return $return; diff --git a/src/Former/Helpers.php b/src/Former/Helpers.php index 7e7fa1d4..0b32aad0 100644 --- a/src/Former/Helpers.php +++ b/src/Former/Helpers.php @@ -54,7 +54,7 @@ public static function translate($key, $fallback = null) { // If nothing was given, return nothing, bitch if (!$key) { - return null; + return $fallback; } // If no fallback, use the key diff --git a/src/Former/Traits/Checkable.php b/src/Former/Traits/Checkable.php index dce43166..d5eec3fe 100644 --- a/src/Former/Traits/Checkable.php +++ b/src/Former/Traits/Checkable.php @@ -293,8 +293,8 @@ protected function items($_items) // Grouped fields if ($this->isGrouped()) { - $attributes['id'] = str_replace('[]', null, $fallback); - $fallback = str_replace('[]', null, $this->name).'[]'; + $attributes['id'] = str_replace('[]', '', $fallback); + $fallback = str_replace('[]', '', $this->name).'[]'; } // If we haven't any name defined for the checkable, try to compute some @@ -350,7 +350,7 @@ protected function createCheckable($item, $fallbackValue = 1) } // If inline items, add class - $isInline = $this->inline ? ' '.$this->app['former.framework']->getInlineLabelClass($this) : null; + $isInline = $this->inline ? ' '.$this->app['former.framework']->getInlineLabelClass($this) : ''; // In Bootsrap 3 or 4, don't append the the checkable type (radio/checkbox) as a class if // rendering inline. diff --git a/tests/Dummy/DummyButton.php b/tests/Dummy/DummyButton.php index 56e0d000..7a7ab9ce 100644 --- a/tests/Dummy/DummyButton.php +++ b/tests/Dummy/DummyButton.php @@ -3,6 +3,8 @@ class DummyButton { + private $text; + public function __construct($text) { $this->text = $text; diff --git a/tests/Fields/RadioTest.php b/tests/Fields/RadioTest.php index f0fd0f76..fe318995 100644 --- a/tests/Fields/RadioTest.php +++ b/tests/Fields/RadioTest.php @@ -34,7 +34,7 @@ private function matchRadio( 'disabled' => $disabled === 'disabled' ? 'disabled' : null, 'id' => $name, 'type' => 'radio', - 'name' => preg_replace('/[0-9]/', null, $name), + 'name' => preg_replace('/[0-9]/', '', $name), 'checked' => 'checked', 'value' => $value, ); diff --git a/tests/Framework/TwitterBootstrapTest.php b/tests/Framework/TwitterBootstrapTest.php index 0cacaa26..37b5de67 100644 --- a/tests/Framework/TwitterBootstrapTest.php +++ b/tests/Framework/TwitterBootstrapTest.php @@ -44,9 +44,9 @@ public function createPrependAppendMatcher($prepend = array(), $append = array() ''. '
'. '
'. - join(null, $prepend). + implode('', $prepend). ''. - join(null, $append). + implode('', $append). '
'. '
'. ''; diff --git a/tests/GroupTest.php b/tests/GroupTest.php index 4160836a..868c5df1 100644 --- a/tests/GroupTest.php +++ b/tests/GroupTest.php @@ -78,9 +78,9 @@ public function createPrependAppendMatcher($prepend = array(), $append = array() ''. '
'. '
'. - join(null, $prepend). + implode('', $prepend). ''. - join(null, $append). + implode('', $append). '
'. '
'. ''; diff --git a/tests/TestCases/FormerTests.php b/tests/TestCases/FormerTests.php index 45cbd4f1..6117f969 100644 --- a/tests/TestCases/FormerTests.php +++ b/tests/TestCases/FormerTests.php @@ -128,7 +128,7 @@ protected function matchField($attributes = array(), $type = 'text', $name = 'fo */ protected function matchLabel($name = 'foo', $field = 'foo', $required = false) { - $text = str_replace('[]', null, $name); + $text = str_replace('[]', '', $name); if ($required) { $text .= '*'; } @@ -634,7 +634,7 @@ public static function findNodes(DOMDocument $dom, array $options, $isHtml = tru foreach ($options['attributes'] as $name => $value) { // match by regexp if like "regexp:/foo/i" - if (preg_match('/^regexp\s*:\s*(.*)/i', $value, $matches)) { + if (!empty($value) && preg_match('/^regexp\s*:\s*(.*)/i', $value, $matches)) { if (!preg_match($matches[1], $node->getAttribute($name))) { $invalid = true; } From e0e4b4f69ba9a023ad9d8d4a2474ddaa8d9b4566 Mon Sep 17 00:00:00 2001 From: pincombe Date: Wed, 24 Jan 2024 10:23:55 +0000 Subject: [PATCH 4/8] Fixed null value deprecation (#613) Co-authored-by: Alex Bouma --- src/Former/Helpers.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Former/Helpers.php b/src/Former/Helpers.php index 0b32aad0..83ecd8fc 100644 --- a/src/Former/Helpers.php +++ b/src/Former/Helpers.php @@ -29,12 +29,16 @@ public static function setApp(Container $app) /** * Encodes HTML * - * @param string $value The string to encode + * @param string|null $value The string to encode * * @return string */ public static function encode($value) { + if ($value === null) { + return ''; + } + return htmlentities($value, ENT_QUOTES, 'UTF-8', true); } From df1375320c4297c80565e4e332840b75e24a0c86 Mon Sep 17 00:00:00 2001 From: Alex Bouma Date: Wed, 24 Jan 2024 11:26:36 +0100 Subject: [PATCH 5/8] Add testing for PHP 8.3 --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d51f2329..b8c4d695 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -8,7 +8,7 @@ jobs: fail-fast: true matrix: os: [ ubuntu-latest, windows-latest ] - php: [ "8.2", "8.1", "8.0", "7.4", "7.3", "7.2" ] + php: [ "8.3", "8.2", "8.1", "8.0", "7.4", "7.3", "7.2" ] name: PHP ${{ matrix.php }} - ${{ matrix.os }} runs-on: ${{ matrix.os }} From 96aafaf3f5b0a903249281d4e564f058cea61a32 Mon Sep 17 00:00:00 2001 From: Alex Bouma Date: Fri, 22 Mar 2024 12:30:19 +0100 Subject: [PATCH 6/8] Allow installation on Laravel 11 --- composer.json | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/composer.json b/composer.json index d5189ae2..e8cf47e5 100644 --- a/composer.json +++ b/composer.json @@ -17,20 +17,20 @@ ], "require": { "php": "^7.2|^8.0", - "illuminate/config": "^5.1.3|^6.0|^7.0|^8.0|^9.0|^10.0", - "illuminate/container": "^5.1.3|^6.0|^7.0|^8.0|^9.0|^10.0", - "illuminate/contracts": "^5.1.3|^6.0|^7.0|^8.0|^9.0|^10.0", - "illuminate/http": "^5.1.3|^6.0|^7.0|^8.0|^9.0|^10.0", - "illuminate/routing": "^5.1.3|^6.0|^7.0|^8.0|^9.0|^10.0", - "illuminate/session": "^5.1.3|^6.0|^7.0|^8.0|^9.0|^10.0", - "illuminate/translation": "^5.1.3|^6.0|^7.0|^8.0|^9.0|^10.0", - "illuminate/support": "^5.1.3|^6.0|^7.0|^8.0|^9.0|^10.0", + "illuminate/config": "^5.1.3|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0", + "illuminate/container": "^5.1.3|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0", + "illuminate/contracts": "^5.1.3|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0", + "illuminate/http": "^5.1.3|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0", + "illuminate/routing": "^5.1.3|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0", + "illuminate/session": "^5.1.3|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0", + "illuminate/translation": "^5.1.3|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0", + "illuminate/support": "^5.1.3|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0", "kylekatarnls/html-object": "^1.5" }, "require-dev": { "phpunit/phpunit": "^8.5", "mockery/mockery": "^1.3", - "illuminate/database": "^5.1.3|^6.0|^7.0|^8.0|^9.0|^10.0" + "illuminate/database": "^5.1.3|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0" }, "autoload": { "psr-4": { From 87025c5f2abc6b995c928dfebaf51a33a47d19c1 Mon Sep 17 00:00:00 2001 From: Alex Bouma Date: Fri, 22 Mar 2024 12:30:34 +0100 Subject: [PATCH 7/8] Bump GH actions versions --- .github/workflows/tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b8c4d695..ace5d66f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -15,10 +15,10 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Cache dependencies - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.composer/cache/files key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }} From 229e4e042132183b57595641abadb1d3910ed8df Mon Sep 17 00:00:00 2001 From: Alex Bouma Date: Fri, 22 Mar 2024 12:32:33 +0100 Subject: [PATCH 8/8] Update the README --- README.md | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 4caddd89..32b7d7e1 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # Former ## A Laravelish way to create and format forms -[![Build Status](http://img.shields.io/travis/formers/former.svg?style=flat)](https://travis-ci.org/formers/former) [![Latest Stable Version](http://img.shields.io/packagist/v/anahkiasen/former.svg?style=flat)](https://packagist.org/packages/anahkiasen/former) [![Total Downloads](http://img.shields.io/packagist/dt/anahkiasen/former.svg?style=flat)](https://packagist.org/packages/anahkiasen/former) @@ -66,12 +65,8 @@ Add then alias Former's main class by adding its facade to the `aliases` array i 'Former' => 'Former\Facades\Former', -### Table of contents +----- -- [Getting started][] -- [Features][] -- [Usage and Examples][] +### Documentation - [Getting started]: https://github.com/formers/former/wiki/Getting-started - [Features]: https://github.com/formers/former/wiki/Features - [Usage and Examples]: https://github.com/formers/former/wiki/Usage-and-Examples +Please refer to the [wiki](https://github.com/formers/former/wiki) for the full documentation.