Skip to content

Commit 5c595b8

Browse files
authored
Allow installation on Laravel 10 (#612)
1 parent 9a88328 commit 5c595b8

File tree

17 files changed

+40
-38
lines changed

17 files changed

+40
-38
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.1", "8.0", "7.4", "7.3", "7.2" ]
11+
php: [ "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@v3
1919

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

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|^9.0",
22-
"illuminate/container": "^5.1.3|^6.0|^7.0|^8.0|^9.0",
23-
"illuminate/contracts": "^5.1.3|^6.0|^7.0|^8.0|^9.0",
24-
"illuminate/http": "^5.1.3|^6.0|^7.0|^8.0|^9.0",
25-
"illuminate/routing": "^5.1.3|^6.0|^7.0|^8.0|^9.0",
26-
"illuminate/session": "^5.1.3|^6.0|^7.0|^8.0|^9.0",
27-
"illuminate/translation": "^5.1.3|^6.0|^7.0|^8.0|^9.0",
28-
"illuminate/support": "^5.1.3|^6.0|^7.0|^8.0|^9.0"
20+
"illuminate/config": "^5.1.3|^6.0|^7.0|^8.0|^9.0|^10.0",
21+
"illuminate/container": "^5.1.3|^6.0|^7.0|^8.0|^9.0|^10.0",
22+
"illuminate/contracts": "^5.1.3|^6.0|^7.0|^8.0|^9.0|^10.0",
23+
"illuminate/http": "^5.1.3|^6.0|^7.0|^8.0|^9.0|^10.0",
24+
"illuminate/routing": "^5.1.3|^6.0|^7.0|^8.0|^9.0|^10.0",
25+
"illuminate/session": "^5.1.3|^6.0|^7.0|^8.0|^9.0|^10.0",
26+
"illuminate/translation": "^5.1.3|^6.0|^7.0|^8.0|^9.0|^10.0",
27+
"illuminate/support": "^5.1.3|^6.0|^7.0|^8.0|^9.0|^10.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|^9.0"
33+
"illuminate/database": "^5.1.3|^6.0|^7.0|^8.0|^9.0|^10.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
@@ -440,7 +440,7 @@ protected function getHelp()
440440
$inline = $this->app['former.framework']->createValidationError($errors);
441441
}
442442

443-
return join(null, array($inline, $block));
443+
return implode('', array($inline, $block));
444444
}
445445

446446
/**

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
@@ -430,9 +430,9 @@ public function placeAround($item)
430430
public function prependAppend($field, $prepend, $append)
431431
{
432432
$return = '<div class="input-group">';
433-
$return .= join(null, $prepend);
433+
$return .= implode('', $prepend);
434434
$return .= $field->render();
435-
$return .= join(null, $append);
435+
$return .= implode('', $append);
436436
$return .= '</div>';
437437

438438
return $return;

src/Former/Helpers.php

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

6060
// 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
@@ -293,8 +293,8 @@ protected function items($_items)
293293

294294
// Grouped fields
295295
if ($this->isGrouped()) {
296-
$attributes['id'] = str_replace('[]', null, $fallback);
297-
$fallback = str_replace('[]', null, $this->name).'[]';
296+
$attributes['id'] = str_replace('[]', '', $fallback);
297+
$fallback = str_replace('[]', '', $this->name).'[]';
298298
}
299299

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

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

355355
// In Bootsrap 3 or 4, don't append the the checkable type (radio/checkbox) as a class if
356356
// 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
}
@@ -634,7 +634,7 @@ public static function findNodes(DOMDocument $dom, array $options, $isHtml = tru
634634

635635
foreach ($options['attributes'] as $name => $value) {
636636
// match by regexp if like "regexp:/foo/i"
637-
if (preg_match('/^regexp\s*:\s*(.*)/i', $value, $matches)) {
637+
if (!empty($value) && preg_match('/^regexp\s*:\s*(.*)/i', $value, $matches)) {
638638
if (!preg_match($matches[1], $node->getAttribute($name))) {
639639
$invalid = true;
640640
}

0 commit comments

Comments
 (0)