Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add support for php 8.4 #138

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
24 changes: 8 additions & 16 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,25 @@ on:
jobs:
php-tests:
runs-on: ubuntu-latest

strategy:
matrix:
dependency-version: [ stable, lowest ]
laravel: [ ^8.79, ^9.50.2, 10.*, 11.* ]
php: [ 8.0, 8.1, 8.2, 8.3 ]
laravel: [ ^9.50.2, 10.*, 11.* ]
php: [ 8.1, 8.2, 8.3, 8.4 ]
include:
- laravel: ^8.79
testbench: ^6.24
- laravel: ^9.50.2
testbench: ^7.22
- laravel: 10.*
testbench: 8.*
- laravel: 11.*
testbench: 9.x-dev
testbench: 9.*
exclude:
- php: 8.3
laravel: ^8.79
- php: 8.2
laravel: ^8.79
- php: 8.4
laravel: ^9.50.2
- php: 8.1
laravel: 11.*
- php: 8.0
laravel: 11.*
- php: 8.0
laravel: 10.*


timeout-minutes: 10

name: "${{ matrix.php }} / ${{ matrix.laravel }} (${{ matrix.dependency-version }})"
Expand All @@ -54,7 +46,7 @@ jobs:
- name: Register composer cache directory
id: composer-cache-files-dir
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@v3
Expand Down
1 change: 1 addition & 0 deletions config/default-theme.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
|--------------------------------------------------------------------------
| Default Theme
Expand Down
4 changes: 2 additions & 2 deletions src/Aire.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public function __construct(Factory $view_factory, Store $session_store, Closure
$this->form_resolver = $form_resolver;
$this->user_config = $config;

$this->setIdGenerator(function(Element $element, Form $form = null) {
$this->setIdGenerator(function(Element $element, ?Form $form = null) {
$form_id = $form->element_id ?? null;
$element_name = $element->getInputName();
$element_id = $element->element_id;
Expand Down Expand Up @@ -184,7 +184,7 @@ public function setIdGenerator(Closure $id_generator): self
* @param \Galahad\Aire\Elements\Form|null $form
* @return string
*/
public function generateAutoId(Element $element, Form $form = null): string
public function generateAutoId(Element $element, ?Form $form = null): string
{
return (string) call_user_func($this->id_generator, $element, $form);
}
Expand Down
2 changes: 1 addition & 1 deletion src/DTD/Select.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Select extends Element
{
public $name = 'select';

public function __construct(Aire $aire, Form $form = null)
public function __construct(Aire $aire, ?Form $form = null)
{
$this->view_data['options'] = new OptionsCollection();

Expand Down
2 changes: 1 addition & 1 deletion src/Elements/Attributes/ClassNames.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class ClassNames
* @param string $element_name
* @param \Galahad\Aire\Elements\Element|null $element
*/
public function __construct($element_name, Element $element = null)
public function __construct($element_name, ?Element $element = null)
{
$this->element_name = $element_name;
$this->element = $element;
Expand Down
2 changes: 1 addition & 1 deletion src/Elements/Attributes/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Collection implements Htmlable, Arrayable, ArrayAccess
* @param \Galahad\Aire\Elements\Element $element
* @param array|null $default_attributes
*/
public function __construct(Aire $aire, Element $element, array $default_attributes = null)
public function __construct(Aire $aire, Element $element, ?array $default_attributes = null)
{
$this->aire = $aire;
$this->element = $element;
Expand Down
2 changes: 1 addition & 1 deletion src/Elements/Checkbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Checkbox extends Input implements HasJsonValue
*/
protected $bind_value = false;

public function __construct(Aire $aire, Form $form = null)
public function __construct(Aire $aire, ?Form $form = null)
{
parent::__construct($aire, $form);

Expand Down
2 changes: 1 addition & 1 deletion src/Elements/CheckboxGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class CheckboxGroup extends \Galahad\Aire\DTD\Input implements HasJsonValue
'type' => 'checkbox',
];

public function __construct(Aire $aire, $options, Form $form = null)
public function __construct(Aire $aire, $options, ?Form $form = null)
{
parent::__construct($aire, $form);

Expand Down
2 changes: 1 addition & 1 deletion src/Elements/ClientValidation.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class ClientValidation implements Htmlable, NonInput
*/
protected $dev_mode = false;

public function __construct(Aire $aire, $element_id, array $rules = [], array $messages = [], string $form_request = null, $dev_mode = false)
public function __construct(Aire $aire, $element_id, array $rules = [], array $messages = [], ?string $form_request = null, $dev_mode = false)
{
$this->aire = $aire;
$this->element_id = $element_id;
Expand Down
2 changes: 1 addition & 1 deletion src/Elements/Concerns/CreatesElements.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function label(string $label): Label
* @param string|null $label
* @return \Galahad\Aire\Elements\Button
*/
public function button(string $label = null): Button
public function button(?string $label = null): Button
{
$button = new Button($this->aire, $this);

Expand Down
8 changes: 4 additions & 4 deletions src/Elements/Concerns/Groupable.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,17 @@ public function __call($method_name, $arguments)
$group_method = 0 === strpos($method_name, 'group')
? Str::camel(substr($method_name, 5))
: $method_name;

if ($this->grouped && method_exists($this->group, $group_method)) {
$this->group->$group_method(...$arguments);

return $this;
}

if (static::hasMacro($method_name)) {
return $this->callMacro($method_name, $arguments);
}

// @codeCoverageIgnoreStart
throw new BadMethodCallException(sprintf(
'Method %s::%s does not exist on the Element or Group.',
Expand Down
8 changes: 4 additions & 4 deletions src/Elements/Element.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ abstract class Element implements Htmlable
*/
protected $bind_value = true;

public function __construct(Aire $aire, Form $form = null)
public function __construct(Aire $aire, ?Form $form = null)
{
$this->aire = $aire;
$this->element_id = $aire->generateElementId();
Expand Down Expand Up @@ -221,7 +221,7 @@ public function __toString(): string
* @param string|null $key
* @return array|mixed
*/
public function getViewData(string $key = null)
public function getViewData(?string $key = null)
{
if (null === $key) {
return $this->view_data;
Expand All @@ -245,7 +245,7 @@ public function hasViewData(string $key): bool
return Arr::has($this->view_data, $key);
}

public function when($value = null, callable $callback = null, callable $default = null)
public function when($value = null, ?callable $callback = null, ?callable $default = null)
{
$value = $value instanceof Closure
? $value($this)
Expand All @@ -270,7 +270,7 @@ public function when($value = null, callable $callback = null, callable $default
return $this;
}

public function unless($value = null, callable $callback = null, callable $default = null)
public function unless($value = null, ?callable $callback = null, ?callable $default = null)
{
$value = $value instanceof Closure
? $value($this)
Expand Down
6 changes: 3 additions & 3 deletions src/Elements/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class Form extends \Galahad\Aire\DTD\Form implements NonInput
*/
protected $on_close;

public function __construct(Aire $aire, UrlGenerator $url, Router $router = null, Store $session_store = null)
public function __construct(Aire $aire, UrlGenerator $url, ?Router $router = null, ?Store $session_store = null)
{
parent::__construct($aire);

Expand Down Expand Up @@ -334,7 +334,7 @@ public function getBoundValue($name, $default = null)
* @param ?string $name
* @return MessageBag|array
*/
public function getErrors(string $name = null)
public function getErrors(?string $name = null)
{
$errors = $this->session_store
->get('errors', new ViewErrorBag())
Expand Down Expand Up @@ -504,7 +504,7 @@ public function multipart(): self
* @param array $custom_messages
* @return $this
*/
public function validate($rule_source = null, array $custom_messages = null): self
public function validate($rule_source = null, ?array $custom_messages = null): self
{
$this->validate = true;

Expand Down
2 changes: 1 addition & 1 deletion src/Elements/Input.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Input extends \Galahad\Aire\DTD\Input implements HasJsonValue
'type' => 'text',
];

public function __construct(Aire $aire, Form $form = null)
public function __construct(Aire $aire, ?Form $form = null)
{
parent::__construct($aire, $form);

Expand Down
2 changes: 1 addition & 1 deletion src/Elements/Label.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Label extends \Galahad\Aire\DTD\Label implements NonInput
*/
public $group;

public function __construct(Aire $aire, Group $group = null)
public function __construct(Aire $aire, ?Group $group = null)
{
$this->group = $group;

Expand Down
2 changes: 1 addition & 1 deletion src/Elements/RadioGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class RadioGroup extends \Galahad\Aire\DTD\Input implements HasJsonValue
* @param array|\Illuminate\Support\Collection|\Illuminate\Contracts\Support\Arrayable|\Illuminate\Contracts\Support\Jsonable|\JsonSerializable|\Traversable $options
* @param \Galahad\Aire\Elements\Form|null $form
*/
public function __construct(Aire $aire, $options, Form $form = null)
public function __construct(Aire $aire, $options, ?Form $form = null)
{
parent::__construct($aire, $form);

Expand Down
2 changes: 1 addition & 1 deletion src/Elements/Select.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Select extends \Galahad\Aire\DTD\Select implements HasJsonValue
use AutoId;
use MapsValueToJsonValue;

public function __construct(Aire $aire, $options, Form $form = null)
public function __construct(Aire $aire, $options, ?Form $form = null)
{
parent::__construct($aire, $form);

Expand Down
2 changes: 1 addition & 1 deletion src/Elements/Summary.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Summary extends Element implements NonInput
'verbose' => false,
];

public function __construct(Aire $aire, Form $form = null)
public function __construct(Aire $aire, ?Form $form = null)
{
parent::__construct($aire, $form);

Expand Down
2 changes: 1 addition & 1 deletion src/Elements/Textarea.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Textarea extends \Galahad\Aire\DTD\Textarea implements HasJsonValue
'auto_size' => false,
];

public function __construct(Aire $aire, Form $form = null)
public function __construct(Aire $aire, ?Form $form = null)
{
parent::__construct($aire, $form);

Expand Down
8 changes: 4 additions & 4 deletions tests/Components/FormTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ public function test_accept_charset_attribute_can_be_set_and_unset(): void
public function test_action_attribute_can_be_set(): void
{
$value = Str::random();

$form = $this->renderBlade('<x-aire::form :action="$value" />', compact('value'));
$this->assertSelectorAttribute($form, 'form', 'action', $value);

// Action is special so it cannot be unset
}

Expand Down Expand Up @@ -265,10 +265,10 @@ public function test_method_attribute_can_be_set(): void
{
$form = $this->renderBlade('<x-aire::form method="get" />');
$this->assertSelectorAttribute($form, 'form', 'method', 'GET');

$form = $this->renderBlade('<x-aire::form method="post" />');
$this->assertSelectorAttribute($form, 'form', 'method', 'POST');

// Method cannot be unset
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Constraints/SelectorAttribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class SelectorAttribute extends CrawlerConstraint
*/
protected $value;

public function __construct(string $selector, string $attribute, string $value = null)
public function __construct(string $selector, string $attribute, ?string $value = null)
{
$this->selector = $selector;
$this->attribute = $attribute;
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ protected function assertSelectorMissingText($html, string $selector, string $te
$this->assertStringNotContainsString($text, trim($actual));
}

protected function assertSelectorAttribute($html, string $selector, string $attribute, string $value = null)
protected function assertSelectorAttribute($html, string $selector, string $attribute, ?string $value = null)
{
static::assertThat($html, new SelectorAttribute($selector, $attribute, $value));
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/AutoIdTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function test_auto_ids_are_incremented(): void

public function test_auto_id_can_be_user_defined(): void
{
$this->aire()->setIdGenerator(function(Element $element, Form $form = null) {
$this->aire()->setIdGenerator(function(Element $element, ?Form $form = null) {
return "foo-{$element->getInputName()}";
});

Expand Down
Loading