Skip to content

Commit

Permalink
Apply php-cs-fixer changes
Browse files Browse the repository at this point in the history
  • Loading branch information
R0Wi authored and github-actions[bot] committed Aug 31, 2024
1 parent 1796576 commit 8f426a9
Show file tree
Hide file tree
Showing 23 changed files with 61 additions and 61 deletions.
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
2 changes: 1 addition & 1 deletion tests/Integration/Composer/AutoloaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ protected function tearDown(): void {
public function testLoadDynamicClass(): void {
$rand = Server::get(ISecureRandom::class);
$className = ucfirst($rand->generate(10, ISecureRandom::CHAR_LOWER));
$namespace = "OCA\\WorkflowOcr";
$namespace = 'OCA\\WorkflowOcr';

file_put_contents(self::getClassPath($className), <<<FILE
<?php
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/BackgroundJobs/ProcessFileJobTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ public function testLogsNonOcrExceptionsFromOcrService() {

public function dataProvider_InvalidArguments() {
$arr = [
[null, "Argument is no array"],
[['mykey' => 'myvalue'], "Undefined array key"]
[null, 'Argument is no array'],
[['mykey' => 'myvalue'], 'Undefined array key']
];
return $arr;
}
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/OcrProcessors/PdfOcrProcessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
use Psr\Log\LoggerInterface;

class PdfOcrProcessorTest extends TestCase {
private const FILE_CONTENT_BEFORE = "someFileContentBefore";
private const FILE_CONTENT_AFTER = "somePDFFileContentAfter";
private const FILE_CONTENT_BEFORE = 'someFileContentBefore';
private const FILE_CONTENT_AFTER = 'somePDFFileContentAfter';

private $fileBeforeMimeType;
private $ocrMyPdfOutput;
Expand Down Expand Up @@ -165,7 +165,7 @@ public function testThrowsErrorIfOcrFileWasEmpty() {
$this->command->expects($this->once())
->method('getStdErr')
->willReturn('stdErr');
$this->ocrMyPdfOutput = "";
$this->ocrMyPdfOutput = '';
$this->fileBefore->expects($this->once())
->method('getPath')
->willReturn('/admin/files/somefile.pdf');
Expand Down
10 changes: 5 additions & 5 deletions tests/Unit/OperationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class OperationTest extends TestCase {
/** @var IRootFolder|MockObject */
private $rootFolder;

private const SETTINGS = "{\"languages\":[\"de\"],\"removeBackground\":true}";
private const SETTINGS = '{"languages":["de"],"removeBackground":true}';

protected function setUp(): void {
parent::setUp();
Expand Down Expand Up @@ -209,7 +209,7 @@ public function testDoesNothingOnFileWithoutOwner() {
}

public function testAddWithCorrectFilePathAndUser() {
$filePath = "/admin/files/path/to/file.pdf";
$filePath = '/admin/files/path/to/file.pdf';
$fileId = 42;
$uid = 'admin';
$this->jobList->expects($this->once())
Expand Down Expand Up @@ -435,9 +435,9 @@ public function testFileAddedToQueueOnTagAssignedEvent() {

public function dataProvider_InvalidFilePaths() {
$arr = [
["/user/nofiles/somefile.pdf"],
["/invalidmount/data/somefile.pdf"],
["/some/somefile.txt"]
['/user/nofiles/somefile.pdf'],
['/invalidmount/data/somefile.pdf'],
['/some/somefile.txt']
];
return $arr;
}
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/Service/NotificationServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function testCreateErrorNotificationWithFileId() {
->method('notify')
->with($this->notification);

$this->service->createErrorNotification("user1", "testnotification", 123);
$this->service->createErrorNotification('user1', 'testnotification', 123);
}

public function testCreateErrorNotificationWithoutFileId() {
Expand Down Expand Up @@ -105,7 +105,7 @@ public function testCreateErrorNotificationWithoutFileId() {
->method('notify')
->with($this->notification);

$this->service->createErrorNotification("user1", "testnotification");
$this->service->createErrorNotification('user1', 'testnotification');
}

public function testCreateErrorNotificationDoesNothingIfUserIdIsNotSet() {
Expand All @@ -124,6 +124,6 @@ public function testCreateErrorNotificationDoesNothingIfUserIdIsNotSet() {
$this->notification->expects($this->never())
->method('setObject');

$this->service->createErrorNotification(null, "testnotification", 123);
$this->service->createErrorNotification(null, 'testnotification', 123);
}
}
6 changes: 3 additions & 3 deletions tests/Unit/Service/OcrBackendInfoServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ public function testGetInstalledLanguagesLogsWarningIfCommandStrErrOrErrOutputWa

public function testGetInstalledLanguagesThrowsIfCliDidNotProduceAnyOutput() : void {
$this->command->expects($this->once())
->method('setCommand')
->with('tesseract --list-langs');
->method('setCommand')
->with('tesseract --list-langs');
$this->command->expects($this->once())
->method('execute')
->willReturn(true);
Expand All @@ -142,7 +142,7 @@ public function testGetInstalledLanguagesThrowsIfCliDidNotProduceAnyOutput() : v

public function dataProviderInstalledLangs() {
return [
["List of available languages (4):\neng\ndeu\nosd\nchi", ["eng","deu","chi"]]
["List of available languages (4):\neng\ndeu\nosd\nchi", ['eng','deu','chi']]
];
}

Expand Down
Loading

0 comments on commit 8f426a9

Please sign in to comment.