diff options
author | MichaIng <micha@dietpi.com> | 2021-07-11 20:05:33 +0200 |
---|---|---|
committer | MichaIng <micha@dietpi.com> | 2021-07-12 20:05:44 +0200 |
commit | af61ac6a7afca423a33e91f509d58a907981e8bd (patch) | |
tree | b93f7be46b46d0ea66b3d0b3dc24ece7e46d0717 /apps | |
parent | bf4c0c75404cafb7aa263ae5a045216d23623029 (diff) | |
download | nextcloud-server-af61ac6a7afca423a33e91f509d58a907981e8bd.tar.gz nextcloud-server-af61ac6a7afca423a33e91f509d58a907981e8bd.zip |
Fix Psalm code scanning alerts
InvalidScalarArgument (apps/theming/lib/IconBuilder.php#L213): https://github.com/nextcloud/server/security/code-scanning/6691
InvalidScalarArgument (apps/theming/lib/IconBuilder.php#L213): https://github.com/nextcloud/server/security/code-scanning/6692
MissingReturnType (apps/theming/lib/IconBuilder.php#L226): https://github.com/nextcloud/server/security/code-scanning/6693
MissingParamType (apps/theming/lib/IconBuilder.php#L226): https://github.com/nextcloud/server/security/code-scanning/6694
MissingParamType (apps/theming/lib/IconBuilder.php#L226): https://github.com/nextcloud/server/security/code-scanning/6695
PossiblyFalseArgument (apps/theming/lib/IconBuilder.php#L232): https://github.com/nextcloud/server/security/code-scanning/6696
Signed-off-by: MichaIng <micha@dietpi.com>
Diffstat (limited to 'apps')
-rw-r--r-- | apps/theming/lib/IconBuilder.php | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/apps/theming/lib/IconBuilder.php b/apps/theming/lib/IconBuilder.php index 36f69e3e59f..fb6909089b5 100644 --- a/apps/theming/lib/IconBuilder.php +++ b/apps/theming/lib/IconBuilder.php @@ -28,7 +28,6 @@ namespace OCA\Theming; use Imagick; use ImagickPixel; -use OCP\App\AppPathNotFoundException; use OCP\Files\SimpleFS\ISimpleFile; class IconBuilder { @@ -202,8 +201,8 @@ class IconBuilder { $innerHeight = ($appIconFile->getImageHeight() - $border_h * 2); $appIconFile->adaptiveResizeImage($innerWidth, $innerHeight); // center icon - $offset_w = 512 / 2 - $innerWidth / 2; - $offset_h = 512 / 2 - $innerHeight / 2; + $offset_w = (int)(512 / 2 - $innerWidth / 2); + $offset_h = (int)(512 / 2 - $innerHeight / 2); $finalIconFile = new Imagick(); $finalIconFile->setBackgroundColor(new ImagickPixel('transparent')); @@ -223,10 +222,14 @@ class IconBuilder { return $finalIconFile; } + /** + * @param $app string app name + * @param $image string relative path to svg file in app directory + * @return string|false content of a colorized svg file + */ public function colorSvg($app, $image) { - try { - $imageFile = $this->util->getAppImage($app, $image); - } catch (AppPathNotFoundException $e) { + $imageFile = $this->util->getAppImage($app, $image); + if ($imageFile === false || $imageFile === "") { return false; } $svg = file_get_contents($imageFile); |