Skip to content

Commit e4067be

Browse files
committed
Merge branch '4.x'
2 parents c9f7e78 + 229e4e0 commit e4067be

File tree

18 files changed

+43
-46
lines changed

18 files changed

+43
-46
lines changed

.github/workflows/tests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ jobs:
88
fail-fast: true
99
matrix:
1010
os: [ ubuntu-latest, windows-latest ]
11-
php: [ "8.0", "7.4", "7.3", "7.2" ]
11+
php: [ "8.3", "8.2", "8.1", "8.0", "7.4", "7.3", "7.2" ]
1212

1313
name: PHP ${{ matrix.php }} - ${{ matrix.os }}
1414
runs-on: ${{ matrix.os }}
1515

1616
steps:
1717
- name: Checkout code
18-
uses: actions/checkout@v2
18+
uses: actions/checkout@v4
1919

2020
- name: Cache dependencies
21-
uses: actions/cache@v2
21+
uses: actions/cache@v4
2222
with:
2323
path: ~/.composer/cache/files
2424
key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}

README.md

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Former
22
## A Laravelish way to create and format forms
33

4-
[![Build Status](http://img.shields.io/travis/formers/former.svg?style=flat)](https://travis-ci.org/formers/former)
54
[![Latest Stable Version](http://img.shields.io/packagist/v/anahkiasen/former.svg?style=flat)](https://packagist.org/packages/anahkiasen/former)
65
[![Total Downloads](http://img.shields.io/packagist/dt/anahkiasen/former.svg?style=flat)](https://packagist.org/packages/anahkiasen/former)
76

@@ -66,12 +65,8 @@ Add then alias Former's main class by adding its facade to the `aliases` array i
6665

6766
'Former' => 'Former\Facades\Former',
6867

69-
### Table of contents
68+
-----
7069

71-
- [Getting started][]
72-
- [Features][]
73-
- [Usage and Examples][]
70+
### Documentation
7471

75-
[Getting started]: https://github.com/formers/former/wiki/Getting-started
76-
[Features]: https://github.com/formers/former/wiki/Features
77-
[Usage and Examples]: https://github.com/formers/former/wiki/Usage-and-Examples
72+
Please refer to the [wiki](https://github.com/formers/former/wiki) for the full documentation.

composer.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,20 @@
1717
],
1818
"require": {
1919
"php": "^7.2|^8.0",
20-
"anahkiasen/html-object": "~1.4",
21-
"illuminate/config": "^5.1.3|^6.0|^7.0|^8.0",
22-
"illuminate/container": "^5.1.3|^6.0|^7.0|^8.0",
23-
"illuminate/contracts": "^5.1.3|^6.0|^7.0|^8.0",
24-
"illuminate/http": "^5.1.3|^6.0|^7.0|^8.0",
25-
"illuminate/routing": "^5.1.3|^6.0|^7.0|^8.0",
26-
"illuminate/session": "^5.1.3|^6.0|^7.0|^8.0",
27-
"illuminate/translation": "^5.1.3|^6.0|^7.0|^8.0",
28-
"illuminate/support": "^5.1.3|^6.0|^7.0|^8.0"
20+
"illuminate/config": "^5.1.3|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0",
21+
"illuminate/container": "^5.1.3|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0",
22+
"illuminate/contracts": "^5.1.3|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0",
23+
"illuminate/http": "^5.1.3|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0",
24+
"illuminate/routing": "^5.1.3|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0",
25+
"illuminate/session": "^5.1.3|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0",
26+
"illuminate/translation": "^5.1.3|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0",
27+
"illuminate/support": "^5.1.3|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0",
28+
"kylekatarnls/html-object": "^1.5"
2929
},
3030
"require-dev": {
3131
"phpunit/phpunit": "^8.5",
3232
"mockery/mockery": "^1.3",
33-
"illuminate/database": "^5.1.3|^6.0|^7.0|^8.0"
33+
"illuminate/database": "^5.1.3|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0"
3434
},
3535
"autoload": {
3636
"psr-4": {

src/Former/Form/Elements.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,15 @@ public function label($label, $for = null, $attributes = array())
6262
{
6363
if (!$label instanceof Htmlable) {
6464
$oldLabel = (string) $label;
65-
$label = Helpers::translate($oldLabel);
65+
$label = Helpers::translate($oldLabel, '');
6666

6767
// If there was no change to the label,
6868
// then a Laravel translation did not occur
6969
if (lcfirst($label) == $oldLabel) {
7070
$label = str_replace('_', ' ', $label);
7171
}
7272
} else {
73-
$label = (string) $label->toHtml();
73+
$label = $label->toHtml();
7474
}
7575

7676
$attributes['for'] = $for;

src/Former/Form/Fields/Choice.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ public function getOption($key, $value)
191191

192192
public function getCheckables($choiceType)
193193
{
194-
if (!(is_array($this->value) || $this->value instanceof \ArrayAccess)) {
194+
if ($this->value !== null && !(is_array($this->value) || $this->value instanceof \ArrayAccess)) {
195195
$this->value = explode(',', $this->value);
196196
}
197197

@@ -233,7 +233,7 @@ public function getCheckables($choiceType)
233233
}
234234

235235
// If inline items, add class
236-
$isInline = $this->inline ? ' '.$this->app['former.framework']->getInlineLabelClass($this) : null;
236+
$isInline = $this->inline ? ' '.$this->app['former.framework']->getInlineLabelClass($this) : '';
237237

238238
// In Bootsrap 3, don't append the the checkable type (radio/checkbox) as a class if
239239
// rendering inline.

src/Former/Form/Group.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ protected function getHelp()
532532
$inline = $this->app['former.framework']->createValidationError($errors);
533533
}
534534

535-
return join(null, array($inline, $block));
535+
return implode('', array($inline, $block));
536536
}
537537

538538
/**

src/Former/Former.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ public function getValue($field, $fallback = null)
250250
*/
251251
public function getPost($name, $fallback = null)
252252
{
253-
$name = str_replace(array('[', ']'), array('.', ''), $name);
253+
$name = str_replace(array('[', ']'), array('.', ''), $name ?? '');
254254
$name = trim($name, '.');
255255
$oldValue = $this->app['request']->old($name, $fallback);
256256

src/Former/Framework/Nude.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,9 @@ public function placeAround($item)
161161
public function prependAppend($field, $prepend, $append)
162162
{
163163
$return = '<div>';
164-
$return .= join(null, $prepend);
164+
$return .= implode('', $prepend);
165165
$return .= $field->render();
166-
$return .= join(null, $append);
166+
$return .= implode('', $append);
167167
$return .= '</div>';
168168

169169
return $return;

src/Former/Framework/TwitterBootstrap.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,9 +353,9 @@ public function prependAppend($field, $prepend, $append)
353353
}
354354

355355
$return = '<div class="'.join(' ', $class).'">';
356-
$return .= join(null, $prepend);
356+
$return .= implode('', $prepend);
357357
$return .= $field->render();
358-
$return .= join(null, $append);
358+
$return .= implode('', $append);
359359
$return .= '</div>';
360360

361361
return $return;

src/Former/Framework/TwitterBootstrap3.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,9 +406,9 @@ public function placeAround($item)
406406
public function prependAppend($field, $prepend, $append)
407407
{
408408
$return = '<div class="input-group">';
409-
$return .= join(null, $prepend);
409+
$return .= implode('', $prepend);
410410
$return .= $field->render();
411-
$return .= join(null, $append);
411+
$return .= implode('', $append);
412412
$return .= '</div>';
413413

414414
return $return;

src/Former/Framework/TwitterBootstrap4.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,9 +438,9 @@ public function placeAround($item, $place = null)
438438
public function prependAppend($field, $prepend, $append)
439439
{
440440
$return = '<div class="input-group">';
441-
$return .= join(null, $prepend);
441+
$return .= implode('', $prepend);
442442
$return .= $field->render();
443-
$return .= join(null, $append);
443+
$return .= implode('', $append);
444444
$return .= '</div>';
445445

446446
return $return;

src/Former/Helpers.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public static function translate($key, $fallback = null)
5858
{
5959
// If nothing was given, return nothing, bitch
6060
if (!$key) {
61-
return null;
61+
return $fallback;
6262
}
6363

6464
// If no fallback, use the key

src/Former/Traits/Checkable.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,8 @@ protected function items($_items)
304304

305305
// Grouped fields
306306
if ($this->isGrouped()) {
307-
$attributes['id'] = str_replace('[]', null, $fallback);
308-
$fallback = str_replace('[]', null, $this->name).'[]';
307+
$attributes['id'] = str_replace('[]', '', $fallback);
308+
$fallback = str_replace('[]', '', $this->name).'[]';
309309
}
310310

311311
// If we haven't any name defined for the checkable, try to compute some
@@ -361,7 +361,7 @@ protected function createCheckable($item, $fallbackValue = 1)
361361
}
362362

363363
// If inline items, add class
364-
$isInline = $this->inline ? ' '.$this->app['former.framework']->getInlineLabelClass($this) : null;
364+
$isInline = $this->inline ? ' '.$this->app['former.framework']->getInlineLabelClass($this) : '';
365365

366366
// In Bootsrap 3 or 4 or 5, don't append the the checkable type (radio/checkbox) as a class if
367367
// rendering inline.

tests/Dummy/DummyButton.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
class DummyButton
55
{
6+
private $text;
7+
68
public function __construct($text)
79
{
810
$this->text = $text;

tests/Fields/RadioTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ private function matchRadio(
3434
'disabled' => $disabled === 'disabled' ? 'disabled' : null,
3535
'id' => $name,
3636
'type' => 'radio',
37-
'name' => preg_replace('/[0-9]/', null, $name),
37+
'name' => preg_replace('/[0-9]/', '', $name),
3838
'checked' => 'checked',
3939
'value' => $value,
4040
);

tests/Framework/TwitterBootstrapTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ public function createPrependAppendMatcher($prepend = array(), $append = array()
4444
'<label for="foo" class="control-label">Foo</label>'.
4545
'<div class="controls">'.
4646
'<div class="'.implode(' ', $class).'">'.
47-
join(null, $prepend).
47+
implode('', $prepend).
4848
'<input id="foo" type="text" name="foo">'.
49-
join(null, $append).
49+
implode('', $append).
5050
'</div>'.
5151
'</div>'.
5252
'</div>';

tests/GroupTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ public function createPrependAppendMatcher($prepend = array(), $append = array()
7878
'<label for="foo" class="control-label">Foo</label>'.
7979
'<div class="controls">'.
8080
'<div class="'.implode(' ', $class).'">'.
81-
join(null, $prepend).
81+
implode('', $prepend).
8282
'<input id="foo" type="text" name="foo">'.
83-
join(null, $append).
83+
implode('', $append).
8484
'</div>'.
8585
'</div>'.
8686
'</div>';

tests/TestCases/FormerTests.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ protected function matchField($attributes = array(), $type = 'text', $name = 'fo
128128
*/
129129
protected function matchLabel($name = 'foo', $field = 'foo', $required = false)
130130
{
131-
$text = str_replace('[]', null, $name);
131+
$text = str_replace('[]', '', $name);
132132
if ($required) {
133133
$text .= '*';
134134
}
@@ -664,7 +664,7 @@ public static function findNodes(DOMDocument $dom, array $options, $isHtml = tru
664664

665665
foreach ($options['attributes'] as $name => $value) {
666666
// match by regexp if like "regexp:/foo/i"
667-
if (preg_match('/^regexp\s*:\s*(.*)/i', $value, $matches)) {
667+
if (!empty($value) && preg_match('/^regexp\s*:\s*(.*)/i', $value, $matches)) {
668668
if (!preg_match($matches[1], $node->getAttribute($name))) {
669669
$invalid = true;
670670
}

0 commit comments

Comments
 (0)