From 96c26254ee4233167b9f43931c5917d6774cdf19 Mon Sep 17 00:00:00 2001 From: enjoys Date: Fri, 4 Apr 2025 18:06:36 +0300 Subject: [PATCH 1/2] Implicitly marking parameter as nullable is deprecated --- src/Element.php | 2 +- src/Elements/Checkbox.php | 2 +- src/Elements/Datalist.php | 2 +- src/Elements/File.php | 2 +- src/Elements/Group.php | 2 +- src/Elements/Image.php | 2 +- src/Elements/Option.php | 2 +- src/Elements/Radio.php | 2 +- src/Elements/Reset.php | 2 +- src/Elements/Select.php | 2 +- src/Elements/Submit.php | 2 +- src/Elements/Textarea.php | 2 +- src/Form.php | 10 ++--- src/Renderer/AbstractRenderer.php | 2 +- src/Renderer/Renderer.php | 2 +- src/Rule/Equal.php | 2 +- src/Rule/RuleInterface.php | 2 +- src/Rule/UploadCheck/RequiredCheck.php | 2 +- src/Rule/UploadCheck/SystemCheck.php | 2 +- src/Traits/Container.php | 58 +++++++++++++------------- src/Traits/Request.php | 2 +- 21 files changed, 53 insertions(+), 53 deletions(-) diff --git a/src/Element.php b/src/Element.php index bc69dfb..ca69f87 100644 --- a/src/Element.php +++ b/src/Element.php @@ -33,7 +33,7 @@ abstract class Element implements ElementInterface protected bool $allowSameNames = false; - public function __construct(string $name, string $label = null) + public function __construct(string $name, ?string $label = null) { $this->setRequest(); $this->setName($name); diff --git a/src/Elements/Checkbox.php b/src/Elements/Checkbox.php index c4a808d..efe81ae 100644 --- a/src/Elements/Checkbox.php +++ b/src/Elements/Checkbox.php @@ -28,7 +28,7 @@ class Checkbox extends Element implements Fillable, Ruleable, Descriptionable protected bool $allowSameNames = true; - public function __construct(string $name, string $title = null, bool $parent = true) + public function __construct(string $name, ?string $title = null, bool $parent = true) { $this->parent = $parent; $this->originalName = trim($name); diff --git a/src/Elements/Datalist.php b/src/Elements/Datalist.php index d67158b..bb251d8 100644 --- a/src/Elements/Datalist.php +++ b/src/Elements/Datalist.php @@ -22,7 +22,7 @@ class Datalist extends Element implements Fillable, Ruleable, Descriptionable protected string $type = 'option'; - public function __construct(string $name, string $title = null) + public function __construct(string $name, ?string $title = null) { parent::__construct($name, $title); $this->setAttribute(AttributeFactory::create('list', $name . '-list')); diff --git a/src/Elements/File.php b/src/Elements/File.php index edbef64..aab5b2a 100644 --- a/src/Elements/File.php +++ b/src/Elements/File.php @@ -27,7 +27,7 @@ class File extends Element implements Ruleable, Descriptionable /** * @throws ExceptionRule */ - public function __construct(string $name, string $title = null) + public function __construct(string $name, ?string $title = null) { parent::__construct($name, $title); $this->addRule(Rules::UPLOAD, [ diff --git a/src/Elements/Group.php b/src/Elements/Group.php index ed6c29f..8398c1f 100644 --- a/src/Elements/Group.php +++ b/src/Elements/Group.php @@ -16,7 +16,7 @@ class Group extends Element implements Descriptionable use Description; use Container; - public function __construct(string $title = null, string $id = null) + public function __construct(?string $title = null, ?string $id = null) { parent::__construct($id ?? \uniqid('group'), $title); } diff --git a/src/Elements/Image.php b/src/Elements/Image.php index db9bf78..c718c58 100644 --- a/src/Elements/Image.php +++ b/src/Elements/Image.php @@ -11,7 +11,7 @@ class Image extends Element { protected string $type = 'image'; - public function __construct(string $name, string $src = null) + public function __construct(string $name, ?string $src = null) { parent::__construct($name); if (!is_null($src)) { diff --git a/src/Elements/Option.php b/src/Elements/Option.php index e587f32..2b96d10 100644 --- a/src/Elements/Option.php +++ b/src/Elements/Option.php @@ -16,7 +16,7 @@ class Option extends Element implements Fillable protected string $type = 'option'; - public function __construct(string $name, string $title = null) + public function __construct(string $name, ?string $title = null) { parent::__construct($name, $title); $this->setAttributes( diff --git a/src/Elements/Radio.php b/src/Elements/Radio.php index fc01393..db80a6f 100644 --- a/src/Elements/Radio.php +++ b/src/Elements/Radio.php @@ -26,7 +26,7 @@ class Radio extends Element implements Fillable, Ruleable, Descriptionable private string $originalName; - public function __construct(string $name, string $title = null, bool $parent = true) + public function __construct(string $name, ?string $title = null, bool $parent = true) { $this->parent = $parent; $this->originalName = $name; diff --git a/src/Elements/Reset.php b/src/Elements/Reset.php index 6732b49..3607e61 100644 --- a/src/Elements/Reset.php +++ b/src/Elements/Reset.php @@ -40,7 +40,7 @@ class Reset extends Element { protected string $type = 'reset'; - public function __construct(string $name = null, string $title = null) + public function __construct(string $name = null, ?string $title = null) { $name ??= uniqid('reset'); diff --git a/src/Elements/Select.php b/src/Elements/Select.php index 4d4daeb..ee12599 100644 --- a/src/Elements/Select.php +++ b/src/Elements/Select.php @@ -22,7 +22,7 @@ class Select extends Element implements Fillable, Ruleable, Descriptionable protected string $type = 'option'; - public function __construct(string $name, string $title = null) + public function __construct(string $name, ?string $title = null) { parent::__construct($name, $title); } diff --git a/src/Elements/Submit.php b/src/Elements/Submit.php index 96410a8..df15193 100644 --- a/src/Elements/Submit.php +++ b/src/Elements/Submit.php @@ -11,7 +11,7 @@ class Submit extends Element { protected string $type = 'submit'; - public function __construct(string $name = null, string $title = null) + public function __construct(string $name = null, ?string $title = null) { if (is_null($name)) { $name = uniqid('submit'); diff --git a/src/Elements/Textarea.php b/src/Elements/Textarea.php index ab7f415..05c7e6e 100644 --- a/src/Elements/Textarea.php +++ b/src/Elements/Textarea.php @@ -23,7 +23,7 @@ class Textarea extends Element implements Ruleable, Descriptionable private string $value; - public function __construct(string $name, string $label = null) + public function __construct(string $name, ?string $label = null) { parent::__construct($name, $label); $this->value = ''; diff --git a/src/Form.php b/src/Form.php index b73f0b4..420de6a 100644 --- a/src/Form.php +++ b/src/Form.php @@ -51,11 +51,11 @@ class Form */ public function __construct( string $method = 'POST', - string $action = null, - string $id = null, - ServerRequestInterface $request = null, - DefaultsHandlerInterface $defaultsHandler = null, - Session $session = null + ?string $action = null, + ?string $id = null, + ?ServerRequestInterface $request = null, + ?DefaultsHandlerInterface $defaultsHandler = null, + ?Session $session = null ) { $this->request = $request ?? ServerRequestCreator::createFromGlobals(); $this->session = $session ?? new Session(); diff --git a/src/Renderer/AbstractRenderer.php b/src/Renderer/AbstractRenderer.php index 10fd6e0..5e68c96 100644 --- a/src/Renderer/AbstractRenderer.php +++ b/src/Renderer/AbstractRenderer.php @@ -14,7 +14,7 @@ abstract class AbstractRenderer implements RendererInterface { private Form $form; - public function __construct(Form $form = null) + public function __construct(?Form $form = null) { $this->form = $form ?? new Form(); } diff --git a/src/Renderer/Renderer.php b/src/Renderer/Renderer.php index 5cfee6b..4f84778 100644 --- a/src/Renderer/Renderer.php +++ b/src/Renderer/Renderer.php @@ -11,7 +11,7 @@ abstract class Renderer { private Form $form; - public function __construct(Form $form = null) + public function __construct(?Form $form = null) { $this->form = $form ?? new Form(); } diff --git a/src/Rule/Equal.php b/src/Rule/Equal.php index de40cae..664dfc3 100644 --- a/src/Rule/Equal.php +++ b/src/Rule/Equal.php @@ -26,7 +26,7 @@ class Equal implements RuleInterface * @param array|scalar $params * @param string|null $message */ - public function __construct(mixed $params, string $message = null) + public function __construct(mixed $params, ?string $message = null) { $this->params = (array) $params; diff --git a/src/Rule/RuleInterface.php b/src/Rule/RuleInterface.php index 5e39d1a..f484de0 100644 --- a/src/Rule/RuleInterface.php +++ b/src/Rule/RuleInterface.php @@ -16,5 +16,5 @@ interface RuleInterface */ public function validate(Ruleable $element): bool; - public function setRequest(ServerRequestInterface $request = null): void; + public function setRequest(?ServerRequestInterface $request = null): void; } diff --git a/src/Rule/UploadCheck/RequiredCheck.php b/src/Rule/UploadCheck/RequiredCheck.php index d286371..4128f2d 100644 --- a/src/Rule/UploadCheck/RequiredCheck.php +++ b/src/Rule/UploadCheck/RequiredCheck.php @@ -13,7 +13,7 @@ final class RequiredCheck implements UploadCheckInterface private Ruleable $element; private ?string $message; - public function __construct(false|UploadedFileInterface $value, Ruleable $element, string $message = null) + public function __construct(false|UploadedFileInterface $value, Ruleable $element, ?string $message = null) { $this->value = $value; $this->element = $element; diff --git a/src/Rule/UploadCheck/SystemCheck.php b/src/Rule/UploadCheck/SystemCheck.php index 6a01468..0ed6e03 100644 --- a/src/Rule/UploadCheck/SystemCheck.php +++ b/src/Rule/UploadCheck/SystemCheck.php @@ -13,7 +13,7 @@ final class SystemCheck implements UploadCheckInterface private Ruleable $element; private ?string $message; - public function __construct(false|UploadedFileInterface $value, Ruleable $element, string $message = null) + public function __construct(false|UploadedFileInterface $value, Ruleable $element, ?string $message = null) { $this->value = $value; $this->element = $element; diff --git a/src/Traits/Container.php b/src/Traits/Container.php index 303d72f..ca893d6 100644 --- a/src/Traits/Container.php +++ b/src/Traits/Container.php @@ -11,35 +11,35 @@ use Webmozart\Assert\Assert; /** - * @method Elements\Text text(string $name, string $label = null) - * @method Elements\Hidden hidden(string $name, string $value = null) - * @method Elements\Password password(string $name, string $label = null) - * @method Elements\Submit submit(string $name = null, string $title = null) - * @method Elements\Header header(string $title = null) - * @method Elements\Color color(string $name, string $label = null) - * @method Elements\Date date(string $name, string $label = null) - * @method Elements\Datetime datetime(string $name, string $label = null) - * @method Elements\Datetimelocal datetimelocal(string $name, string $label = null) - * @method Elements\Email email(string $name, string $label = null) - * @method Elements\Number number(string $name, string $label = null) - * @method Elements\Range range(string $name, string $label = null) - * @method Elements\Search search(string $name, string $label = null) - * @method Elements\Tel tel(string $name, string $label = null) - * @method Elements\Time time(string $name, string $label = null) - * @method Elements\Url url(string $name, string $label = null) - * @method Elements\Month month(string $name, string $label = null) - * @method Elements\Week week(string $name, string $label = null) - * @method Elements\Textarea textarea(string $name, string $label = null) - * @method Elements\Select select(string $name, string $label = null) - * @method Elements\Button button(string $name, string $title = null) - * @method Elements\Datalist datalist(string $name, string $label = null) - * @method Elements\Checkbox checkbox(string $name, string $label = null) - * @method Elements\Image image(string $name, string $src = null) - * @method Elements\Radio radio(string $name, string $title = null) - * @method Elements\Reset reset(string $name, string $title = null) + * @method Elements\Text text(string $name, null|string $label = null) + * @method Elements\Hidden hidden(string $name, null|string $value = null) + * @method Elements\Password password(string $name, null|string $label = null) + * @method Elements\Submit submit(null|string $name = null, null|string $title = null) + * @method Elements\Header header(null|string $title = null) + * @method Elements\Color color(string $name, null|string $label = null) + * @method Elements\Date date(string $name, null|string $label = null) + * @method Elements\Datetime datetime(string $name, null|string $label = null) + * @method Elements\Datetimelocal datetimelocal(string $name, null|string $label = null) + * @method Elements\Email email(string $name, null|string $label = null) + * @method Elements\Number number(string $name, null|string $label = null) + * @method Elements\Range range(string $name, null|string $label = null) + * @method Elements\Search search(string $name, null|string $label = null) + * @method Elements\Tel tel(string $name, null|string $label = null) + * @method Elements\Time time(string $name, null|string $label = null) + * @method Elements\Url url(string $name, null|string $label = null) + * @method Elements\Month month(string $name, null|string $label = null) + * @method Elements\Week week(string $name, null|string $label = null) + * @method Elements\Textarea textarea(string $name, null|string $label = null) + * @method Elements\Select select(string $name, null|string $label = null) + * @method Elements\Button button(string $name, null|string $title = null) + * @method Elements\Datalist datalist(string $name, null|string $label = null) + * @method Elements\Checkbox checkbox(string $name, null|string $label = null) + * @method Elements\Image image(string $name, null|string $src = null) + * @method Elements\Radio radio(string $name, null|string $title = null) + * @method Elements\Reset reset(string $name, null|string $title = null) * @method Elements\Captcha captcha(CaptchaInterface $captcha) - * @method Elements\Group group(string $title = null) - * @method Elements\File file(string $name, string $label = null) + * @method Elements\Group group(null|string $title = null) + * @method Elements\File file(string $name, null|string $label = null) * @method Elements\Csrf csrf() * @method Elements\Html html(string $html) * @@ -68,7 +68,7 @@ public function __call(string $name, array $arguments): Element /** * @psalm-suppress MixedPropertyTypeCoercion */ - public function addElement(Element $element, string $before = null, string $after = null): static + public function addElement(Element $element, ?string $before = null, ?string $after = null): static { $element->setRequest($this->getRequest()); if ($element->prepare() === true) { diff --git a/src/Traits/Request.php b/src/Traits/Request.php index 55fc323..311dcd8 100644 --- a/src/Traits/Request.php +++ b/src/Traits/Request.php @@ -14,7 +14,7 @@ trait Request */ private ServerRequestInterface $request; - public function setRequest(ServerRequestInterface $request = null): void + public function setRequest(?ServerRequestInterface $request = null): void { $this->request = $request ?? ServerRequestCreator::createFromGlobals(); } From 7ffbdcea13704515f4f4f77c45191a2748b0c130 Mon Sep 17 00:00:00 2001 From: enjoys Date: Fri, 4 Apr 2025 18:17:01 +0300 Subject: [PATCH 2/2] update ci setting --- .github/workflows/php80.yml | 2 +- .github/workflows/php81.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/php80.yml b/.github/workflows/php80.yml index 0f1e914..03bcc2f 100644 --- a/.github/workflows/php80.yml +++ b/.github/workflows/php80.yml @@ -32,7 +32,7 @@ jobs: - name: Cache Composer packages id: composer-cache - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: vendor key: ${{ runner.os }}-8.0-v3-php-${{ hashFiles('**/composer.lock') }} diff --git a/.github/workflows/php81.yml b/.github/workflows/php81.yml index 6cc8f24..ddc400b 100644 --- a/.github/workflows/php81.yml +++ b/.github/workflows/php81.yml @@ -32,7 +32,7 @@ jobs: - name: Cache Composer packages id: composer-cache - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: vendor key: ${{ runner.os }}-8.1-v3-php-${{ hashFiles('**/composer.lock') }}