Skip to content

Commit

Permalink
Allow installation on Laravel 10 (#612)
Browse files Browse the repository at this point in the history
  • Loading branch information
stayallive authored Mar 23, 2023
1 parent 9a88328 commit 5c595b8
Show file tree
Hide file tree
Showing 17 changed files with 40 additions and 38 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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') }}
Expand Down
20 changes: 10 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
4 changes: 2 additions & 2 deletions src/Former/Form/Elements.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ 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
if (lcfirst($label) == $oldLabel) {
$label = str_replace('_', ' ', $label);
}
} else {
$label = (string) $label->toHtml();
$label = $label->toHtml();
}

$attributes['for'] = $for;
Expand Down
4 changes: 2 additions & 2 deletions src/Former/Form/Fields/Choice.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

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

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

Expand Down
4 changes: 2 additions & 2 deletions src/Former/Framework/Nude.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ public function placeAround($item)
public function prependAppend($field, $prepend, $append)
{
$return = '<div>';
$return .= join(null, $prepend);
$return .= implode('', $prepend);
$return .= $field->render();
$return .= join(null, $append);
$return .= implode('', $append);
$return .= '</div>';

return $return;
Expand Down
4 changes: 2 additions & 2 deletions src/Former/Framework/TwitterBootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -353,9 +353,9 @@ public function prependAppend($field, $prepend, $append)
}

$return = '<div class="'.join(' ', $class).'">';
$return .= join(null, $prepend);
$return .= implode('', $prepend);
$return .= $field->render();
$return .= join(null, $append);
$return .= implode('', $append);
$return .= '</div>';

return $return;
Expand Down
4 changes: 2 additions & 2 deletions src/Former/Framework/TwitterBootstrap3.php
Original file line number Diff line number Diff line change
Expand Up @@ -406,9 +406,9 @@ public function placeAround($item)
public function prependAppend($field, $prepend, $append)
{
$return = '<div class="input-group">';
$return .= join(null, $prepend);
$return .= implode('', $prepend);
$return .= $field->render();
$return .= join(null, $append);
$return .= implode('', $append);
$return .= '</div>';

return $return;
Expand Down
4 changes: 2 additions & 2 deletions src/Former/Framework/TwitterBootstrap4.php
Original file line number Diff line number Diff line change
Expand Up @@ -430,9 +430,9 @@ public function placeAround($item)
public function prependAppend($field, $prepend, $append)
{
$return = '<div class="input-group">';
$return .= join(null, $prepend);
$return .= implode('', $prepend);
$return .= $field->render();
$return .= join(null, $append);
$return .= implode('', $append);
$return .= '</div>';

return $return;
Expand Down
2 changes: 1 addition & 1 deletion src/Former/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/Former/Traits/Checkable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions tests/Dummy/DummyButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

class DummyButton
{
private $text;

public function __construct($text)
{
$this->text = $text;
Expand Down
2 changes: 1 addition & 1 deletion tests/Fields/RadioTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
Expand Down
4 changes: 2 additions & 2 deletions tests/Framework/TwitterBootstrapTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ public function createPrependAppendMatcher($prepend = array(), $append = array()
'<label for="foo" class="control-label">Foo</label>'.
'<div class="controls">'.
'<div class="'.implode(' ', $class).'">'.
join(null, $prepend).
implode('', $prepend).
'<input id="foo" type="text" name="foo">'.
join(null, $append).
implode('', $append).
'</div>'.
'</div>'.
'</div>';
Expand Down
4 changes: 2 additions & 2 deletions tests/GroupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ public function createPrependAppendMatcher($prepend = array(), $append = array()
'<label for="foo" class="control-label">Foo</label>'.
'<div class="controls">'.
'<div class="'.implode(' ', $class).'">'.
join(null, $prepend).
implode('', $prepend).
'<input id="foo" type="text" name="foo">'.
join(null, $append).
implode('', $append).
'</div>'.
'</div>'.
'</div>';
Expand Down
4 changes: 2 additions & 2 deletions tests/TestCases/FormerTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 .= '*';
}
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 5c595b8

Please sign in to comment.