From e44c1d675e0e3ad0dc874e73f7bad56db6e00ed1 Mon Sep 17 00:00:00 2001 From: Younes ENNAJI Date: Thu, 19 Sep 2024 07:30:11 +0100 Subject: [PATCH] ci: fix phpstan errors --- CHANGELOG.md | 1 + src/Laravel/Facade/Flasher.php | 25 ++++++++----------- src/Noty/Laravel/Facade/Noty.php | 23 ++++++----------- src/Notyf/Laravel/Facade/Notyf.php | 17 ++++--------- src/Prime/Plugin/FlasherPlugin.php | 6 ++++- .../Response/Presenter/HtmlPresenter.php | 1 + src/SweetAlert/Laravel/Facade/SweetAlert.php | 19 +++++--------- src/Toastr/Laravel/Facade/Toastr.php | 12 ++++----- taskfile.dist.yml | 2 +- 9 files changed, 43 insertions(+), 63 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 197049d4..c3266baa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## [Unreleased](https://github.com/php-flasher/php-flasher/compare/v2.0.1...2.x) +* feature [Flasher] add escapeHtml option for secure HTML escaping in notifications. See [PR #196](https://github.com/php-flasher/php-flasher/pull/196) by [yoeunes](https://github.com/yoeunes) * feature [Flasher] add Default configuration options. See [PR #183](https://github.com/php-flasher/php-flasher/pull/183) by [AhmedGamal](https://github.com/AhmedGamal) * feature [Laravel] Refactor middleware to use Symfony's base response class, addressing compatibility issues. See [PR #184](https://github.com/php-flasher/php-flasher/pull/184) by [yoeunes](https://github.com/yoeunes) diff --git a/src/Laravel/Facade/Flasher.php b/src/Laravel/Facade/Flasher.php index 6f1400dc..3c8d9798 100644 --- a/src/Laravel/Facade/Flasher.php +++ b/src/Laravel/Facade/Flasher.php @@ -13,37 +13,32 @@ use Illuminate\Support\Facades\Facade; * @method static NotificationBuilder title(string $message) * @method static NotificationBuilder message(string $message) * @method static NotificationBuilder type(string $message) - * @method static NotificationBuilder options(array $options, bool $merge = true) + * @method static NotificationBuilder options(array $options, bool $merge = true) * @method static NotificationBuilder option(string $name, $value) * @method static NotificationBuilder priority(int $priority) * @method static NotificationBuilder hops(int $amount) * @method static NotificationBuilder keep() * @method static NotificationBuilder delay(int $delay) - * @method static NotificationBuilder translate(array $parameters = [], ?string $locale = null) + * @method static NotificationBuilder translate(array $parameters = [], ?string $locale = null) * @method static NotificationBuilder handler(string $handler) - * @method static NotificationBuilder context(array $context) + * @method static NotificationBuilder context(array $context) * @method static NotificationBuilder when(bool|\Closure $condition) * @method static NotificationBuilder unless(bool|\Closure $condition) * @method static NotificationBuilder with(StampInterface[] $stamps = array()) * @method static NotificationBuilder withStamp(StampInterface $stamp) - * @method static Envelope success(string $message, array $options = [], ?string $title = null) - * @method static Envelope error(string $message, array $options = [], ?string $title = null) - * @method static Envelope info(string $message, array $options = [], ?string $title = null) - * @method static Envelope warning(string $message, array $options = [], ?string $title = null) - * @method static Envelope flash(?string $type = null, ?string $message = null, array $options = [], ?string $title = null) - * @method static Envelope preset(string $preset, array $parameters = []) + * @method static Envelope success(string $message, array $options = [], ?string $title = null) + * @method static Envelope error(string $message, array $options = [], ?string $title = null) + * @method static Envelope info(string $message, array $options = [], ?string $title = null) + * @method static Envelope warning(string $message, array $options = [], ?string $title = null) + * @method static Envelope flash(?string $type = null, ?string $message = null, array $options = [], ?string $title = null) + * @method static Envelope preset(string $preset, array $parameters = []) * @method static Envelope operation(string $operation, string|object|null $resource = null) * @method static Envelope created(string|object|null $resource = null) * @method static Envelope updated(string|object|null $resource = null) * @method static Envelope saved(string|object|null $resource = null) * @method static Envelope deleted(string|object|null $resource = null) * @method static Envelope push() - * @method static Envelope addSuccess(string $message, array $options = [], ?string $title = null) - * @method static Envelope addError(string $message, array $options = [], ?string $title = null) - * @method static Envelope addInfo(string $message, array $options = [], ?string $title = null) - * @method static Envelope addWarning(string $message, array $options = [], ?string $title = null) - * @method static Envelope addFlash(?string $type = null, ?string $message = null, array $options = [], ?string $title = null) - * @method static Envelope addPreset(string $preset, array $parameters = []) + * @method static Envelope addPreset(string $preset, array $parameters = []) * @method static Envelope addCreated(string|object|null $resource = null) * @method static Envelope addUpdated(string|object|null $resource = null) * @method static Envelope addDeleted(string|object|null $resource = null) diff --git a/src/Noty/Laravel/Facade/Noty.php b/src/Noty/Laravel/Facade/Noty.php index b67d85a7..bde56121 100644 --- a/src/Noty/Laravel/Facade/Noty.php +++ b/src/Noty/Laravel/Facade/Noty.php @@ -6,25 +6,18 @@ namespace Flasher\Noty\Laravel\Facade; use Flasher\Noty\Prime\NotyBuilder; use Flasher\Prime\Notification\Envelope; -use Flasher\Prime\Notification\NotificationInterface; use Flasher\Prime\Stamp\StampInterface; use Illuminate\Support\Facades\Facade; /** - * @method static NotyBuilder addSuccess(string $message, array $options = array()) - * @method static NotyBuilder addError(string $message, array $options = array()) - * @method static NotyBuilder addWarning(string $message, array $options = array()) - * @method static NotyBuilder addInfo(string $message, array $options = array()) - * @method static NotyBuilder addFlash(NotificationInterface|string $type, string $message = null, array $options = array()) + * @method static NotyBuilder success(string $message, array $options = array()) + * @method static NotyBuilder error(string $message, array $options = array()) + * @method static NotyBuilder warning(string $message, array $options = array()) + * @method static NotyBuilder info(string $message, array $options = array()) * @method static NotyBuilder flash(StampInterface[] $stamps = array()) - * @method static NotyBuilder type(string $type, string $message = null, array $options = array()) * @method static NotyBuilder message(string $message) - * @method static NotyBuilder options(array $options, bool $merge = true) + * @method static NotyBuilder options(array $options, bool $merge = true) * @method static NotyBuilder option(string $name, string $value) - * @method static NotyBuilder success(string $message = null, array $options = array()) - * @method static NotyBuilder error(string $message = null, array $options = array()) - * @method static NotyBuilder info(string $message = null, array $options = array()) - * @method static NotyBuilder warning(string $message = null, array $options = array()) * @method static NotyBuilder priority(int $priority) * @method static NotyBuilder hops(int $amount) * @method static NotyBuilder keep() @@ -35,12 +28,12 @@ use Illuminate\Support\Facades\Facade; * @method static NotyBuilder handler(string $handler) * @method static Envelope getEnvelope() * @method static NotyBuilder text(string $text) - * @method static NotyBuilder alert(string $message = null, array $options = array()) + * @method static NotyBuilder alert(string $message = null, array $options = array()) * @method static NotyBuilder layout(string $layout) * @method static NotyBuilder theme(string $theme) * @method static NotyBuilder timeout(bool|int $timeout) * @method static NotyBuilder progressBar(bool $progressBar = false) - * @method static NotyBuilder closeWith(array|string $closeWith) + * @method static NotyBuilder closeWith(string|string[] $closeWith) * @method static NotyBuilder animation(string $animation, string $effect) * @method static NotyBuilder sounds(string $option, mixed $value) * @method static NotyBuilder docTitle(string $option, mixed $docTitle) @@ -50,7 +43,7 @@ use Illuminate\Support\Facades\Facade; * @method static NotyBuilder queue(string $queue) * @method static NotyBuilder killer(bool|string $killer) * @method static NotyBuilder container(bool|string $container) - * @method static NotyBuilder buttons(array $buttons) + * @method static NotyBuilder buttons(string[] $buttons) * @method static NotyBuilder visibilityControl(bool $visibilityControl) */ final class Noty extends Facade diff --git a/src/Notyf/Laravel/Facade/Notyf.php b/src/Notyf/Laravel/Facade/Notyf.php index 9b73a72e..c12a9260 100644 --- a/src/Notyf/Laravel/Facade/Notyf.php +++ b/src/Notyf/Laravel/Facade/Notyf.php @@ -6,25 +6,18 @@ namespace Flasher\Notyf\Laravel\Facade; use Flasher\Notyf\Prime\NotyfBuilder; use Flasher\Prime\Notification\Envelope; -use Flasher\Prime\Notification\NotificationInterface; use Flasher\Prime\Stamp\StampInterface; use Illuminate\Support\Facades\Facade; /** - * @method static NotyfBuilder addSuccess(string $message, array $options = array()) - * @method static NotyfBuilder addError(string $message, array $options = array()) - * @method static NotyfBuilder addWarning(string $message, array $options = array()) - * @method static NotyfBuilder addInfo(string $message, array $options = array()) - * @method static NotyfBuilder addFlash(NotificationInterface|string $type, string $message = null, array $options = array()) + * @method static NotyfBuilder success(string $message, array $options = array()) + * @method static NotyfBuilder error(string $message, array $options = array()) + * @method static NotyfBuilder warning(string $message, array $options = array()) + * @method static NotyfBuilder info(string $message, array $options = array()) * @method static NotyfBuilder flash(StampInterface[] $stamps = array()) - * @method static NotyfBuilder type(string $type, string $message = null, array $options = array()) * @method static NotyfBuilder message(string $message) - * @method static NotyfBuilder options(array $options, bool $merge = true) + * @method static NotyfBuilder options(array $options, bool $merge = true) * @method static NotyfBuilder option(string $name, string $value) - * @method static NotyfBuilder success(string $message = null, array $options = array()) - * @method static NotyfBuilder error(string $message = null, array $options = array()) - * @method static NotyfBuilder info(string $message = null, array $options = array()) - * @method static NotyfBuilder warning(string $message = null, array $options = array()) * @method static NotyfBuilder priority(int $priority) * @method static NotyfBuilder hops(int $amount) * @method static NotyfBuilder keep() diff --git a/src/Prime/Plugin/FlasherPlugin.php b/src/Prime/Plugin/FlasherPlugin.php index 043dd7e6..f1a95eb7 100644 --- a/src/Prime/Plugin/FlasherPlugin.php +++ b/src/Prime/Plugin/FlasherPlugin.php @@ -100,7 +100,11 @@ final class FlasherPlugin extends Plugin * scripts: string[], * styles: string[], * options: array, - * plugins?: array>, + * plugins?: array, + * }>, * } $config * * @return array{ diff --git a/src/Prime/Response/Presenter/HtmlPresenter.php b/src/Prime/Response/Presenter/HtmlPresenter.php index 58603f6c..955d4196 100644 --- a/src/Prime/Response/Presenter/HtmlPresenter.php +++ b/src/Prime/Response/Presenter/HtmlPresenter.php @@ -21,6 +21,7 @@ final class HtmlPresenter implements PresenterInterface /** @var array{csp_script_nonce?: ?string, envelopes_only?: bool} $context */ $context = $response->getContext(); + /** @var array{envelopes: array} $options */ $options = $response->toArray(); $html = ''; diff --git a/src/SweetAlert/Laravel/Facade/SweetAlert.php b/src/SweetAlert/Laravel/Facade/SweetAlert.php index ee4343c0..34709892 100644 --- a/src/SweetAlert/Laravel/Facade/SweetAlert.php +++ b/src/SweetAlert/Laravel/Facade/SweetAlert.php @@ -5,26 +5,19 @@ declare(strict_types=1); namespace Flasher\SweetAlert\Laravel\Facade; use Flasher\Prime\Notification\Envelope; -use Flasher\Prime\Notification\NotificationInterface; use Flasher\Prime\Stamp\StampInterface; use Flasher\SweetAlert\Prime\SweetAlertBuilder; use Illuminate\Support\Facades\Facade; /** - * @method static SweetAlertBuilder addSuccess(string $message, array $options = array()) - * @method static SweetAlertBuilder addError(string $message, array $options = array()) - * @method static SweetAlertBuilder addWarning(string $message, array $options = array()) - * @method static SweetAlertBuilder addInfo(string $message, array $options = array()) - * @method static SweetAlertBuilder addFlash(NotificationInterface|string $type, string $message = null, array $options = array()) + * @method static SweetAlertBuilder success(string $message, array $options = array()) + * @method static SweetAlertBuilder error(string $message, array $options = array()) + * @method static SweetAlertBuilder warning(string $message, array $options = array()) + * @method static SweetAlertBuilder info(string $message, array $options = array()) * @method static SweetAlertBuilder flash(StampInterface[] $stamps = array()) - * @method static SweetAlertBuilder type(string $type, string $message = null, array $options = array()) * @method static SweetAlertBuilder message(string $message) - * @method static SweetAlertBuilder options(array $options, bool $merge = true) + * @method static SweetAlertBuilder options(array $options, bool $merge = true) * @method static SweetAlertBuilder option(string $name, string $value) - * @method static SweetAlertBuilder success(string $message = null, array $options = array()) - * @method static SweetAlertBuilder error(string $message = null, array $options = array()) - * @method static SweetAlertBuilder info(string $message = null, array $options = array()) - * @method static SweetAlertBuilder warning(string $message = null, array $options = array()) * @method static SweetAlertBuilder priority(int $priority) * @method static SweetAlertBuilder hops(int $amount) * @method static SweetAlertBuilder keep() @@ -34,7 +27,7 @@ use Illuminate\Support\Facades\Facade; * @method static SweetAlertBuilder withStamp(StampInterface $stamp) * @method static SweetAlertBuilder handler(string $handler) * @method static Envelope getEnvelope() - * @method static SweetAlertBuilder question(string $message = null, array $options = array()) + * @method static SweetAlertBuilder question(string $message = null, array $options = array()) * @method static SweetAlertBuilder title(string $title) * @method static SweetAlertBuilder titleText(string $titleText) * @method static SweetAlertBuilder html(string $html) diff --git a/src/Toastr/Laravel/Facade/Toastr.php b/src/Toastr/Laravel/Facade/Toastr.php index 8c7d82c9..d5640454 100644 --- a/src/Toastr/Laravel/Facade/Toastr.php +++ b/src/Toastr/Laravel/Facade/Toastr.php @@ -11,14 +11,14 @@ use Illuminate\Support\Facades\Facade; /** * @method static ToastrBuilder flash(StampInterface[] $stamps = array()) - * @method static ToastrBuilder type(string $type, string $message = null, array $options = array()) + * @method static ToastrBuilder type(string $type, string $message = null, array $options = array()) * @method static ToastrBuilder message(string $message) - * @method static ToastrBuilder options(array $options, bool $merge = true) + * @method static ToastrBuilder options(array $options, bool $merge = true) * @method static ToastrBuilder option(string $name, $value) - * @method static ToastrBuilder success(string $message = null, array $options = array()) - * @method static ToastrBuilder error(string $message = null, array $options = array()) - * @method static ToastrBuilder info(string $message = null, array $options = array()) - * @method static ToastrBuilder warning(string $message = null, array $options = array()) + * @method static ToastrBuilder success(string $message = null, array $options = array()) + * @method static ToastrBuilder error(string $message = null, array $options = array()) + * @method static ToastrBuilder info(string $message = null, array $options = array()) + * @method static ToastrBuilder warning(string $message = null, array $options = array()) * @method static ToastrBuilder priority(int $priority) * @method static ToastrBuilder hops(int $amount) * @method static ToastrBuilder keep() diff --git a/taskfile.dist.yml b/taskfile.dist.yml index e1ab42eb..a1d4f5cd 100644 --- a/taskfile.dist.yml +++ b/taskfile.dist.yml @@ -29,7 +29,7 @@ tasks: lint: desc: "🔍 Run various linting tools to ensure code quality." cmds: - - vendor/bin/php-cs-fixer fix --dry-run + - vendor/bin/php-cs-fixer fix - vendor/bin/phpstan analyse --memory-limit=-1 - composer validate --strict - vendor/bin/phplint