Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/Classifiers/Classifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@
try {
$proc->start();

if ($cores !== '0') {
if ((int)$cores !== 0) {
@exec('taskset -cp ' . implode(',', range(0, (int)$cores, 1)) . ' ' . ((string)$proc->getPid()));
}

Expand Down Expand Up @@ -317,7 +317,7 @@

/**
* @param File $file
* @return string

Check failure on line 320 in lib/Classifiers/Classifier.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

InvalidFalsableReturnType

lib/Classifiers/Classifier.php:320:13: InvalidFalsableReturnType: The declared return type 'string' for OCA\Recognize\Classifiers\Classifier::generatePreviewWithProvider does not allow false, but 'false|string' contains false (see https://psalm.dev/143)
* @throws \OCA\Recognize\Exception\Exception|NotFoundException
*/
public function generatePreviewWithProvider(File $file): string {
Expand All @@ -336,7 +336,7 @@
// Create a temporary file *with the correct extension*
$tmpname = $this->tempManager->getTemporaryFile('.jpg');

$tmpfile = fopen($tmpname, 'wb');

Check failure on line 339 in lib/Classifiers/Classifier.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

PossiblyFalseArgument

lib/Classifiers/Classifier.php:339:20: PossiblyFalseArgument: Argument 1 of fopen cannot be false, possibly string value expected (see https://psalm.dev/104)

if ($tmpfile === false) {
throw new \OCA\Recognize\Exception\Exception('Could not open tmpfile');
Expand All @@ -350,10 +350,10 @@
throw new \OCA\Recognize\Exception\Exception('Could not copy preview file to temp folder');
}

$imagetype = exif_imagetype($tmpname);

Check failure on line 353 in lib/Classifiers/Classifier.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

PossiblyFalseArgument

lib/Classifiers/Classifier.php:353:31: PossiblyFalseArgument: Argument 1 of exif_imagetype cannot be false, possibly string value expected (see https://psalm.dev/104)

if (in_array($imagetype, [IMAGETYPE_WEBP, IMAGETYPE_AVIF, false])) { // To troubleshoot if it is a webp or avif.
$imageString = file_get_contents($tmpname);

Check failure on line 356 in lib/Classifiers/Classifier.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

PossiblyFalseArgument

lib/Classifiers/Classifier.php:356:37: PossiblyFalseArgument: Argument 1 of file_get_contents cannot be false, possibly string value expected (see https://psalm.dev/104)
if ($imageString === false) {
throw new \OCA\Recognize\Exception\Exception('Could not load preview file from temp folder');
}
Expand All @@ -362,19 +362,19 @@
throw new \OCA\Recognize\Exception\Exception('Could not load preview file from temp folder');
}
$use_gd_quality = (int)\OCP\Server::get(IConfig::class)->getSystemValue('recognize.preview.quality', '100');
if (imagejpeg($previewImage, $tmpname, $use_gd_quality) === false) {

Check failure on line 365 in lib/Classifiers/Classifier.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

PossiblyFalseArgument

lib/Classifiers/Classifier.php:365:33: PossiblyFalseArgument: Argument 2 of imagejpeg cannot be false, possibly null|resource|string value expected (see https://psalm.dev/104)
imagedestroy($previewImage);
throw new \OCA\Recognize\Exception\Exception('Could not copy preview file to temp folder');
}
imagedestroy($previewImage);
}

return $tmpname;

Check failure on line 372 in lib/Classifiers/Classifier.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

FalsableReturnStatement

lib/Classifiers/Classifier.php:372:10: FalsableReturnStatement: The declared return type 'string' for OCA\Recognize\Classifiers\Classifier::generatePreviewWithProvider does not allow false, but the function returns 'false|string' (see https://psalm.dev/137)
}

/**
* @param string $path
* @return string

Check failure on line 377 in lib/Classifiers/Classifier.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

InvalidFalsableReturnType

lib/Classifiers/Classifier.php:377:13: InvalidFalsableReturnType: The declared return type 'string' for OCA\Recognize\Classifiers\Classifier::generatePreviewWithGD does not allow false, but 'false|string' contains false (see https://psalm.dev/143)
* @throws \OCA\Recognize\Exception\Exception
*/
public function generatePreviewWithGD(string $path): string {
Expand Down Expand Up @@ -414,7 +414,7 @@
$tmpname = $this->tempManager->getTemporaryFile('.jpg');

$use_gd_quality = (int)\OCP\Server::get(IConfig::class)->getSystemValue('recognize.preview.quality', '100');
if (imagejpeg($previewImage, $tmpname, $use_gd_quality) === false) {

Check failure on line 417 in lib/Classifiers/Classifier.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

PossiblyFalseArgument

lib/Classifiers/Classifier.php:417:32: PossiblyFalseArgument: Argument 2 of imagejpeg cannot be false, possibly null|resource|string value expected (see https://psalm.dev/104)
imagedestroy($image);
imagedestroy($previewImage);
throw new \OCA\Recognize\Exception\Exception('Could not copy preview file to temp folder');
Expand All @@ -422,6 +422,6 @@
imagedestroy($image);
imagedestroy($previewImage);

return $tmpname;

Check failure on line 425 in lib/Classifiers/Classifier.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

FalsableReturnStatement

lib/Classifiers/Classifier.php:425:10: FalsableReturnStatement: The declared return type 'string' for OCA\Recognize\Classifiers\Classifier::generatePreviewWithGD does not allow false, but the function returns 'false|string' (see https://psalm.dev/137)
}
}
Loading