Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependabot & format fixes for stable30 #262

Merged
merged 3 commits into from
Aug 31, 2024
Merged
Show file tree
Hide file tree
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/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
use Psr\Log\LoggerInterface;

class Application extends App implements IBootstrap {
public const APP_NAME = "workflow_ocr";
public const APP_NAME = 'workflow_ocr';

/**
* Application constructor.
Expand Down
2 changes: 1 addition & 1 deletion lib/BackgroundJobs/ProcessFileJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@

namespace OCA\WorkflowOcr\BackgroundJobs;

use \OCP\Files\File;
use OCA\WorkflowOcr\Model\WorkflowSettings;
use OCA\WorkflowOcr\Service\INotificationService;
use OCA\WorkflowOcr\Service\IOcrService;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Files\File;
use Psr\Log\LoggerInterface;

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Migration/Version2702Date20230908170345.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function description(): string {
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
try {
$this->deleteNonDeliverableNotifications();
} catch(\Throwable $e) {
} catch (\Throwable $e) {
$output->warning('Could not delete non-deliverable notifications: ' . $e->getMessage() . '. Please see https://github.com/R0Wi-DEV/workflow_ocr/issues/221.');
}

Expand Down
4 changes: 2 additions & 2 deletions lib/Model/WorkflowSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class WorkflowSettings {
/**
* @param string $json The serialized JSON string used in frontend as input for the Vue component
*/
public function __construct(string $json = null) {
public function __construct(?string $json = null) {
$this->setJson($json);
}

Expand Down Expand Up @@ -109,7 +109,7 @@ public static function canConstruct(string $json): bool {
/**
* @return void
*/
private function setJson(string $json = null) {
private function setJson(?string $json = null) {
if (!$json) {
return;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Notification/Notifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
use Psr\Log\LoggerInterface;

class Notifier implements INotifier {
/** @var IFactory*/
/** @var IFactory */
private $l10nFactory;
/** @var IURLGenerator */
private $urlGenerator;
Expand Down Expand Up @@ -116,7 +116,7 @@ public function prepare(INotification $notification, string $languageCode): INot
return $notification;
}

private function tryGetRichParamForFile(string $uid, int $fileId) : array | bool {
private function tryGetRichParamForFile(string $uid, int $fileId) : array|bool {
try {
$userFolder = $this->rootFolder->getUserFolder($uid);
/** @var File[] */
Expand Down
6 changes: 3 additions & 3 deletions lib/OcrProcessors/IOcrProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
interface IOcrProcessor {
/**
* Processes OCR on the given file
* @param File $file The file to be processed
* @param WorkflowSettings $settings The settings to be used for this specific workflow
* @param GlobalSettings $globalSettings The global settings configured for all OCR workflows on this system
* @param File $file The file to be processed
* @param WorkflowSettings $settings The settings to be used for this specific workflow
* @param GlobalSettings $globalSettings The global settings configured for all OCR workflows on this system
* @return OcrProcessorResult
* @throws OcrNotPossibleException
*/
Expand Down
4 changes: 2 additions & 2 deletions lib/OcrProcessors/OcrMyPdfBasedProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ public function ocrFile(File $file, WorkflowSettings $settings, GlobalSettings $
$this->logger->info('Temporary sidecar file at \'{path}\' was empty', ['path' => $this->sidecarFileAccessor->getOrCreateSidecarFile()]);
}

$this->logger->debug("OCR processing was successful");
$this->logger->debug('OCR processing was successful');

return new OcrProcessorResult($ocrFileContent, "pdf", $recognizedText);
return new OcrProcessorResult($ocrFileContent, 'pdf', $recognizedText);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Service/IEventService.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ interface IEventService {
/**
* Emits events
*
* @param OcrProcessorResult $result The processed ocr result
* @param OcrProcessorResult $result The processed ocr result
*
*/
public function textRecognized(OcrProcessorResult $result, File $node);
Expand Down
2 changes: 1 addition & 1 deletion lib/Service/INotificationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ interface INotificationService {
* @param string $message The error message that should be displayed in the notification.
* @param int $fileId Optional file ID of the file that failed to OCR. If given, user can jump to the file via link.
*/
public function createErrorNotification(?string $userId, string $message, int $fileId = null);
public function createErrorNotification(?string $userId, string $message, ?int $fileId = null);
}
6 changes: 3 additions & 3 deletions lib/Service/IOcrService.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ interface IOcrService {
/**
* Processes OCR on the given file. Creates a new file version and emits appropriate events.
*
* @param int $fileId The id if the file to be processed
* @param string $uid The id of the user who has access to this file
* @param WorkflowSettings $settings The settings to be used for processing
* @param int $fileId The id if the file to be processed
* @param string $uid The id of the user who has access to this file
* @param WorkflowSettings $settings The settings to be used for processing
*
* @throws \OCA\WorkflowOcr\Exception\OcrNotPossibleException
* @throws \OCA\WorkflowOcr\Exception\OcrProcessorNotFoundException
Expand Down
2 changes: 1 addition & 1 deletion lib/Service/NotificationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function __construct(IManager $notificationManager) {
/**
* @return void
*/
public function createErrorNotification(?string $userId, string $message, int $fileId = null) {
public function createErrorNotification(?string $userId, string $message, ?int $fileId = null) {
// We don't create unbound notifications
if (!$userId) {
return;
Expand Down
10 changes: 5 additions & 5 deletions lib/Service/OcrService.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public function runOcrProcess(int $fileId, string $uid, WorkflowSettings $settin

try {
$result = $ocrProcessor->ocrFile($file, $settings, $globalSettings);
} catch(OcrResultEmptyException $ex) {
} catch (OcrResultEmptyException $ex) {
// #232: it's okay to have an empty result if the file was skipped due to OCR mode
if ($settings->getOcrMode() === WorkflowSettings::OCR_MODE_SKIP_FILE) {
$this->logger->debug('Skipping empty OCR result for file with id {fileId} because OCR mode is set to \'skip file\'', ['fileId' => $fileId]);
Expand All @@ -135,7 +135,7 @@ public function runOcrProcess(int $fileId, string $uid, WorkflowSettings $settin
if ($result->getRecognizedText() !== '') {
$newFilePath = $originalFileExtension === $newFileExtension ?
$filePath :
$filePath . ".pdf";
$filePath . '.pdf';

$this->createNewFileVersion($newFilePath, $fileContent, $fileId);
}
Expand Down Expand Up @@ -204,9 +204,9 @@ private function processTagsAfterSuccessfulOcr(File $file, WorkflowSettings $set
}

/**
* @param string $filePath The filepath of the file to write
* @param string $ocrContent The new filecontent (which was OCR processed)
* @param int $fileId The id of the file to write. Used for locking.
* @param string $filePath The filepath of the file to write
* @param string $ocrContent The new filecontent (which was OCR processed)
* @param int $fileId The id of the file to write. Used for locking.
*/
private function createNewFileVersion(string $filePath, string $ocrContent, int $fileId) : void {
$dirPath = dirname($filePath);
Expand Down
18 changes: 9 additions & 9 deletions lib/Wrapper/ICommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@
interface ICommand {
/**
* @param string $command the command or full command string to execute,
* like 'gzip' or 'gzip -d'. You can still call addArg() to add more
* arguments to the command. If $escapeCommand was set to true, the command
* gets escaped with escapeshellcmd().
* like 'gzip' or 'gzip -d'. You can still call addArg() to add more
* arguments to the command. If $escapeCommand was set to true, the command
* gets escaped with escapeshellcmd().
* @return ICommand for method chaining
*/
public function setCommand(string $command) : ICommand;

/**
* @param string $stdIn If set, the string will be piped to the
* command via standard input. This enables the same functionality as
* piping on the command line. It can also be a resource like a file
* handle or a stream in which case its content will be piped into the
* command like an input redirection.
* command via standard input. This enables the same functionality as
* piping on the command line. It can also be a resource like a file
* handle or a stream in which case its content will be piped into the
* command like an input redirection.
* @return ICommand for method chaining
*/
public function setStdIn(string $stdIn) : ICommand;
Expand All @@ -50,7 +50,7 @@ public function setStdIn(string $stdIn) : ICommand;
* Execute the command
*
* @return bool whether execution was successful. If `false`, error details
* can be obtained from getError(), getStdErr() and getExitCode().
* can be obtained from getError(), getStdErr() and getExitCode().
*/
public function execute() : bool;

Expand All @@ -63,7 +63,7 @@ public function getOutput(bool $trim = true) : string;
/**
* @param bool $trim whether to `trim()` the return value. The default is `true`.
* @return string the error message, either stderr or an internal message.
* Empty string if none.
* Empty string if none.
*/
public function getError(bool $trim = true) : string;

Expand Down
2 changes: 1 addition & 1 deletion lib/Wrapper/ViewWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

namespace OCA\WorkflowOcr\Wrapper;

use \OC\Files\View;
use OC\Files\View;

class ViewWrapper implements IView {
/** @var View */
Expand Down
Loading
Loading