From f2b5d9fabb2a7afcbc8cb838056acd06d783be00 Mon Sep 17 00:00:00 2001 From: neznaika0 Date: Sat, 4 Jan 2025 00:54:37 +0300 Subject: [PATCH] refactor: Fix phpstan greaterOrEqual.invalid --- system/Images/Handlers/BaseHandler.php | 32 +++++++++---------- system/Images/Handlers/ImageMagickHandler.php | 2 -- system/Images/ImageHandlerInterface.php | 20 +++++++++--- .../greaterOrEqual.invalid.neon | 8 ----- utils/phpstan-baseline/loader.neon | 1 - .../missingType.iterableValue.neon | 22 +------------ 6 files changed, 31 insertions(+), 54 deletions(-) delete mode 100644 utils/phpstan-baseline/greaterOrEqual.invalid.neon diff --git a/system/Images/Handlers/BaseHandler.php b/system/Images/Handlers/BaseHandler.php index eb704b564670..e745cb33beed 100644 --- a/system/Images/Handlers/BaseHandler.php +++ b/system/Images/Handlers/BaseHandler.php @@ -396,23 +396,6 @@ public function flip(string $dir = 'vertical') */ abstract protected function _flip(string $direction); - /** - * Overlays a string of text over the image. - * - * Valid options: - * - * - color Text Color (hex number) - * - shadowColor Color of the shadow (hex number) - * - hAlign Horizontal alignment: left, center, right - * - vAlign Vertical alignment: top, middle, bottom - * - hOffset - * - vOffset - * - fontPath - * - fontSize - * - shadowOffset - * - * @return $this - */ public function text(string $text, array $options = []) { $options = array_merge($this->textDefaults, $options); @@ -427,6 +410,21 @@ public function text(string $text, array $options = []) /** * Handler-specific method for overlaying text on an image. * + * @phpstan-param array{ + * color?: string, + * shadowColor?: string, + * hAlign?: string, + * vAlign?: string, + * hOffset?: int, + * vOffset?: int, + * fontPath?: string, + * fontSize?: int, + * shadowOffset?: int, + * opacity?: float, + * padding?: int, + * withShadow?: bool|string + * } $options + * * @return void */ abstract protected function _text(string $text, array $options = []); diff --git a/system/Images/Handlers/ImageMagickHandler.php b/system/Images/Handlers/ImageMagickHandler.php index 583a2759fd31..f1448efa7f8a 100644 --- a/system/Images/Handlers/ImageMagickHandler.php +++ b/system/Images/Handlers/ImageMagickHandler.php @@ -329,8 +329,6 @@ protected function supportedFormatCheck() /** * Handler-specific method for overlaying text on an image. * - * @return void - * * @throws Exception */ protected function _text(string $text, array $options = []) diff --git a/system/Images/ImageHandlerInterface.php b/system/Images/ImageHandlerInterface.php index 7cb635be3738..0b0c7271c988 100644 --- a/system/Images/ImageHandlerInterface.php +++ b/system/Images/ImageHandlerInterface.php @@ -117,11 +117,21 @@ public function fit(int $width, int $height, string $position); * - shadowColor Color of the shadow (hex number) * - hAlign Horizontal alignment: left, center, right * - vAlign Vertical alignment: top, middle, bottom - * - hOffset - * - vOffset - * - fontPath - * - fontSize - * - shadowOffset + * + * @phpstan-param array{ + * color?: string, + * shadowColor?: string, + * hAlign?: string, + * vAlign?: string, + * hOffset?: int, + * vOffset?: int, + * fontPath?: string, + * fontSize?: int, + * shadowOffset?: int, + * opacity?: float, + * padding?: int, + * withShadow?: bool|string + * } $options * * @return $this */ diff --git a/utils/phpstan-baseline/greaterOrEqual.invalid.neon b/utils/phpstan-baseline/greaterOrEqual.invalid.neon deleted file mode 100644 index 409b5c104e94..000000000000 --- a/utils/phpstan-baseline/greaterOrEqual.invalid.neon +++ /dev/null @@ -1,8 +0,0 @@ -# total 1 error - -parameters: - ignoreErrors: - - - message: '#^Comparison operation "\>\=" between \(array\|float\|int\) and 0 results in an error\.$#' - count: 2 - path: ../../system/Images/Handlers/ImageMagickHandler.php diff --git a/utils/phpstan-baseline/loader.neon b/utils/phpstan-baseline/loader.neon index 789d5ef7e1ef..836c935eb96b 100644 --- a/utils/phpstan-baseline/loader.neon +++ b/utils/phpstan-baseline/loader.neon @@ -21,7 +21,6 @@ includes: - function.notFound.neon - generator.returnType.neon - generator.valueType.neon - - greaterOrEqual.invalid.neon - if.condNotBoolean.neon - isset.offset.neon - isset.property.neon diff --git a/utils/phpstan-baseline/missingType.iterableValue.neon b/utils/phpstan-baseline/missingType.iterableValue.neon index 6abf970718c7..044814f98ce4 100644 --- a/utils/phpstan-baseline/missingType.iterableValue.neon +++ b/utils/phpstan-baseline/missingType.iterableValue.neon @@ -1,4 +1,4 @@ -# total 1685 errors +# total 1681 errors parameters: ignoreErrors: @@ -4687,11 +4687,6 @@ parameters: count: 1 path: ../../system/Images/Handlers/BaseHandler.php - - - message: '#^Method CodeIgniter\\Images\\Handlers\\BaseHandler\:\:_text\(\) has parameter \$options with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Images/Handlers/BaseHandler.php - - message: '#^Method CodeIgniter\\Images\\Handlers\\BaseHandler\:\:calcAspectRatio\(\) return type has no value type specified in iterable type array\.$#' count: 1 @@ -4702,11 +4697,6 @@ parameters: count: 1 path: ../../system/Images/Handlers/BaseHandler.php - - - message: '#^Method CodeIgniter\\Images\\Handlers\\BaseHandler\:\:text\(\) has parameter \$options with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Images/Handlers/BaseHandler.php - - message: '#^Property CodeIgniter\\Images\\Handlers\\BaseHandler\:\:\$supportTransparency type has no value type specified in iterable type array\.$#' count: 1 @@ -4717,11 +4707,6 @@ parameters: count: 1 path: ../../system/Images/Handlers/BaseHandler.php - - - message: '#^Method CodeIgniter\\Images\\Handlers\\ImageMagickHandler\:\:_text\(\) has parameter \$options with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Images/Handlers/ImageMagickHandler.php - - message: '#^Method CodeIgniter\\Images\\Handlers\\ImageMagickHandler\:\:process\(\) return type has no value type specified in iterable type array\.$#' count: 1 @@ -4732,11 +4717,6 @@ parameters: count: 1 path: ../../system/Images/Image.php - - - message: '#^Method CodeIgniter\\Images\\ImageHandlerInterface\:\:text\(\) has parameter \$options with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Images/ImageHandlerInterface.php - - message: '#^Method CodeIgniter\\Language\\Language\:\:formatMessage\(\) has parameter \$message with no value type specified in iterable type array\.$#' count: 1