From 6ad84aad171de063fba3b79b4b72d63a725d3b0f Mon Sep 17 00:00:00 2001 From: Deeka Wong Date: Wed, 20 Dec 2023 12:21:16 +0800 Subject: [PATCH] Support customized local configuration files for PHPStan and PHPUnit (#502) * Support customized local configuration files for PHPStan and PHPUnit * Optimize * Fix return type declarations in Kafka and Log facades * Refactor array and collection mixins * Update type hint for process method in TaskHandleListener * Update CacheInterface and Cache class * Refactor ParameterParser class by removing unused code * Refactor Etcd and Nacos drivers, and fix EnvWriter return statement * Fix type hinting in exception handling functions * Fix column value retrieval in FastPaginate.php * Refactor validation rules in ValidationAspect.php * Update helper functions and fix deprecated functions * Refactor log writer to use null coalescing operator for default values * Fix code formatting and remove unused code * Update variable type in ResponseSequence class and fix factory function in Functions.php * Fix code inconsistencies and improve code readability * Update phpstan.neon.dist to include phpstan-baseline.neon This commit updates the phpstan.neon.dist file to include the phpstan-baseline.neon file. The previous include statement for vendor/phpstan/phpstan-deprecation-rules/rules.neon has been commented out. This change ensures that the phpstan-baseline.neon file is included in the analysis performed by vendor/bin/phpstan. * Update PHPStan configuration file * Fix isInstanceCall method logic * Refactor access log message formatting --------- Co-authored-by: Deeka Wong <8337659+huangdijia@users.noreply.github.com> --- src/ArrMixin.php | 4 +--- src/CollectionMixin.php | 6 +++--- src/RequestMixin.php | 10 +++++----- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/ArrMixin.php b/src/ArrMixin.php index 8bb434c..63e37f2 100644 --- a/src/ArrMixin.php +++ b/src/ArrMixin.php @@ -108,12 +108,10 @@ public static function sortDesc() /** * Recursively sort an array by keys and values in descending order. - * - * @return array */ public function sortRecursiveDesc() { - return fn ($array, $options = SORT_REGULAR) => $this->sortRecursive($array, $options, true); + return fn ($array, $options = SORT_REGULAR) => $this->sortRecursive($array); // , $options, true } public function undot() diff --git a/src/CollectionMixin.php b/src/CollectionMixin.php index 37dfcc3..9b7d92c 100644 --- a/src/CollectionMixin.php +++ b/src/CollectionMixin.php @@ -172,7 +172,7 @@ public function sortKeysUsing() public function undot() { - return fn () => new Collection(Arr::undot($this->all())); + return fn () => new Collection(Arr::undot($this->all())); /* @phpstan-ignore-line */ } public function value() @@ -198,11 +198,11 @@ public function whenNotEmpty() public function unlessEmpty() { - return fn (callable $callback, callable $default = null) => $this->whenNotEmpty($callback, $default); + return fn (callable $callback, callable $default = null) => $this->whenNotEmpty($callback, $default); /* @phpstan-ignore-line */ } public function unlessNotEmpty() { - return fn (callable $callback, callable $default = null) => $this->whenEmpty($callback, $default); + return fn (callable $callback, callable $default = null) => $this->whenEmpty($callback, $default); /* @phpstan-ignore-line */ } } diff --git a/src/RequestMixin.php b/src/RequestMixin.php index 57b8d1c..7b69f8b 100644 --- a/src/RequestMixin.php +++ b/src/RequestMixin.php @@ -119,7 +119,7 @@ public function filled() $keys = is_array($key) ? $key : func_get_args(); foreach ($keys as $value) { - if ($this->isEmptyString($value)) { + if ($this->isEmptyString($value)) { /* @phpstan-ignore-line */ return false; } } @@ -221,7 +221,7 @@ public function isNotFilled() $keys = is_array($key) ? $key : func_get_args(); foreach ($keys as $value) { - if (! $this->isEmptyString($value)) { + if (! $this->isEmptyString($value)) { /* @phpstan-ignore-line */ return false; } } @@ -247,7 +247,7 @@ public function merge() public function mergeIfMissing() { - return fn (array $input) => $this->merge( + return fn (array $input) => $this->merge( /* @phpstan-ignore-line */ collect($input) ->filter(fn ($value, $key) => $this->missing($key)) ->toArray() @@ -301,9 +301,9 @@ public function string() public function wantsJson() { return function () { - $acceptable = explode(',', $this->header('ACCEPT') ?? ''); + $acceptable = explode(',', $this->header('ACCEPT')); - return Str::contains(strtolower($acceptable[0]) ?? '', ['/json', '+json']); + return Str::contains(strtolower($acceptable[0]), ['/json', '+json']); }; }