From 4d5a5bc0edc023f914fa6a2f8f881c09fedf8b1c Mon Sep 17 00:00:00 2001 From: Sebastian Fey Date: Sun, 14 Jan 2024 13:04:23 +0100 Subject: [PATCH] style: Run PHP fixer Signed-off-by: Sebastian Fey --- lib/Helper/AcceptHeaderParsingHelper.php | 2 +- lib/Helper/DownloadHelper.php | 4 ++-- lib/Helper/Filter/JSON/CleanCategoryFilter.php | 2 +- lib/Helper/Filter/JSON/FixInstructionsFilter.php | 2 +- lib/Helper/Filter/JSON/FixKeywordsFilter.php | 2 +- lib/Helper/Filter/JSON/RecipeIdCopyFilter.php | 2 +- lib/Helper/HTMLParser/HttpJsonLdParser.php | 2 +- lib/Helper/HtmlToDomParser.php | 2 +- lib/Helper/UserFolderHelper.php | 2 +- lib/Migration/Version000000Date20210427082010.php | 4 ++-- lib/Migration/Version000000Date20210701093123.php | 2 +- lib/Migration/Version000000Date20220703174647.php | 2 +- lib/Service/JsonService.php | 4 ++-- lib/Service/RecipeService.php | 4 ++-- .../Setup/Migrations/AbstractMigrationTestCase.php | 4 ++-- .../Unit/Helper/ImageService/ThumbnailFileHelperTest.php | 8 ++++---- 16 files changed, 24 insertions(+), 24 deletions(-) diff --git a/lib/Helper/AcceptHeaderParsingHelper.php b/lib/Helper/AcceptHeaderParsingHelper.php index 786e86e0..905314c3 100644 --- a/lib/Helper/AcceptHeaderParsingHelper.php +++ b/lib/Helper/AcceptHeaderParsingHelper.php @@ -58,7 +58,7 @@ class AcceptHeaderParsingHelper { usort($weightedParts, function ($a, $b) { $tmp = $a['weight'] - $b['weight']; - if ($tmp < - 0.001) { + if ($tmp < -0.001) { return -1; } elseif ($tmp > 0.001) { return 1; diff --git a/lib/Helper/DownloadHelper.php b/lib/Helper/DownloadHelper.php index 5eabca99..6b84eefe 100644 --- a/lib/Helper/DownloadHelper.php +++ b/lib/Helper/DownloadHelper.php @@ -116,7 +116,7 @@ class DownloadHelper { * @throws NoDownloadWasCarriedOutException if there was no successful download carried out before calling this method. */ public function getContentType(): ?string { - if (! $this->downloaded) { + if (!$this->downloaded) { throw new NoDownloadWasCarriedOutException(); } @@ -140,7 +140,7 @@ class DownloadHelper { * @throws NoDownloadWasCarriedOutException if there was no successful download carried out before calling this method. */ public function getStatus(): int { - if (! $this->downloaded) { + if (!$this->downloaded) { throw new NoDownloadWasCarriedOutException(); } diff --git a/lib/Helper/Filter/JSON/CleanCategoryFilter.php b/lib/Helper/Filter/JSON/CleanCategoryFilter.php index 94bb7a0b..88db901d 100644 --- a/lib/Helper/Filter/JSON/CleanCategoryFilter.php +++ b/lib/Helper/Filter/JSON/CleanCategoryFilter.php @@ -20,7 +20,7 @@ class CleanCategoryFilter extends AbstractJSONFilter { } public function apply(array &$json): bool { - if (! isset($json['recipeCategory'])) { + if (!isset($json['recipeCategory'])) { $json['recipeCategory'] = ''; return true; } diff --git a/lib/Helper/Filter/JSON/FixInstructionsFilter.php b/lib/Helper/Filter/JSON/FixInstructionsFilter.php index b906a0dd..0338a613 100644 --- a/lib/Helper/Filter/JSON/FixInstructionsFilter.php +++ b/lib/Helper/Filter/JSON/FixInstructionsFilter.php @@ -53,7 +53,7 @@ class FixInstructionsFilter extends AbstractJSONFilter { } public function apply(array &$json): bool { - if (! isset($json[self::INSTRUCTIONS])) { + if (!isset($json[self::INSTRUCTIONS])) { $json[self::INSTRUCTIONS] = []; return true; } diff --git a/lib/Helper/Filter/JSON/FixKeywordsFilter.php b/lib/Helper/Filter/JSON/FixKeywordsFilter.php index 8baa9b5c..fdf6b127 100644 --- a/lib/Helper/Filter/JSON/FixKeywordsFilter.php +++ b/lib/Helper/Filter/JSON/FixKeywordsFilter.php @@ -40,7 +40,7 @@ class FixKeywordsFilter extends AbstractJSONFilter { return true; } - if (!is_string($json[self::KEYWORDS]) && ! is_array($json[self::KEYWORDS])) { + if (!is_string($json[self::KEYWORDS]) && !is_array($json[self::KEYWORDS])) { $this->logger->info($this->l->t('Could not parse the keywords for recipe {recipe}.', ['recipe' => $json['name']])); $json[self::KEYWORDS] = ''; return true; diff --git a/lib/Helper/Filter/JSON/RecipeIdCopyFilter.php b/lib/Helper/Filter/JSON/RecipeIdCopyFilter.php index 981fd28b..4eb926b0 100644 --- a/lib/Helper/Filter/JSON/RecipeIdCopyFilter.php +++ b/lib/Helper/Filter/JSON/RecipeIdCopyFilter.php @@ -8,7 +8,7 @@ namespace OCA\Cookbook\Helper\Filter\JSON; class RecipeIdCopyFilter extends AbstractJSONFilter { public function apply(array &$json): bool { $copy = $json; - if (! isset($json['id'])) { + if (!isset($json['id'])) { $json['id'] = $json['recipe_id']; } return $json !== $copy; diff --git a/lib/Helper/HTMLParser/HttpJsonLdParser.php b/lib/Helper/HTMLParser/HttpJsonLdParser.php index 5f5b8f02..d236135d 100644 --- a/lib/Helper/HTMLParser/HttpJsonLdParser.php +++ b/lib/Helper/HTMLParser/HttpJsonLdParser.php @@ -60,7 +60,7 @@ class HttpJsonLdParser extends AbstractHtmlParser { throw new HtmlParsingException($this->l->t('JSON cannot be decoded.')); } - if ($json === false || $json === true || ! is_array($json)) { + if ($json === false || $json === true || !is_array($json)) { throw new HtmlParsingException($this->l->t('No recipe was found.')); } diff --git a/lib/Helper/HtmlToDomParser.php b/lib/Helper/HtmlToDomParser.php index 0de9ae0a..a7b44160 100644 --- a/lib/Helper/HtmlToDomParser.php +++ b/lib/Helper/HtmlToDomParser.php @@ -151,7 +151,7 @@ class HtmlToDomParser { */ foreach ($errors as $error) { if (isset($ret[$error->code])) { - $ret[$error->code]['count'] ++; + $ret[$error->code]['count']++; } else { $ret[$error->code] = [ 'count' => 1, diff --git a/lib/Helper/UserFolderHelper.php b/lib/Helper/UserFolderHelper.php index 9eb88db4..cf87c410 100644 --- a/lib/Helper/UserFolderHelper.php +++ b/lib/Helper/UserFolderHelper.php @@ -129,7 +129,7 @@ class UserFolderHelper { ); } - if (! $node->isCreatable()) { + if (!$node->isCreatable()) { throw new UserFolderNotWritableException( $this->l->t('User cannot create recipe folder') ); diff --git a/lib/Migration/Version000000Date20210427082010.php b/lib/Migration/Version000000Date20210427082010.php index fc7d24e1..b3da4c40 100644 --- a/lib/Migration/Version000000Date20210427082010.php +++ b/lib/Migration/Version000000Date20210427082010.php @@ -26,7 +26,7 @@ class Version000000Date20210427082010 extends SimpleMigrationStep { $schema = $schemaClosure(); $categoriesTable = $schema->getTable('cookbook_categories'); - if (! $categoriesTable->hasIndex('categories_recipe_idx')) { + if (!$categoriesTable->hasIndex('categories_recipe_idx')) { $categoriesTable->addIndex([ 'user_id', 'recipe_id', @@ -34,7 +34,7 @@ class Version000000Date20210427082010 extends SimpleMigrationStep { } $keywordsTable = $schema->getTable('cookbook_keywords'); - if (! $keywordsTable->hasIndex('keywords_recipe_idx')) { + if (!$keywordsTable->hasIndex('keywords_recipe_idx')) { $keywordsTable->addIndex([ 'user_id', 'recipe_id', diff --git a/lib/Migration/Version000000Date20210701093123.php b/lib/Migration/Version000000Date20210701093123.php index 65d473b9..8384df59 100644 --- a/lib/Migration/Version000000Date20210701093123.php +++ b/lib/Migration/Version000000Date20210701093123.php @@ -97,7 +97,7 @@ class Version000000Date20210701093123 extends SimpleMigrationStep { if ($namesTable->hasPrimaryKey()) { $namesTable->dropPrimaryKey(); } - if (! $namesTable->hasIndex('names_recipe_idx')) { + if (!$namesTable->hasIndex('names_recipe_idx')) { $namesTable->addUniqueIndex([ 'recipe_id', 'user_id' diff --git a/lib/Migration/Version000000Date20220703174647.php b/lib/Migration/Version000000Date20220703174647.php index 9cb16ce8..41bd2ac9 100644 --- a/lib/Migration/Version000000Date20220703174647.php +++ b/lib/Migration/Version000000Date20220703174647.php @@ -33,7 +33,7 @@ class Version000000Date20220703174647 extends SimpleMigrationStep { $table = $schema->getTable('cookbook_names'); - if (! $table->hasColumn('date_created')) { + if (!$table->hasColumn('date_created')) { $table->addColumn('date_created', 'datetime_immutable', [ 'notnull' => false, ]); diff --git a/lib/Service/JsonService.php b/lib/Service/JsonService.php index 28143493..73ee9241 100644 --- a/lib/Service/JsonService.php +++ b/lib/Service/JsonService.php @@ -21,13 +21,13 @@ class JsonService { * @return bool true, if $obj is an object and optionally satisfies the type check */ public function isSchemaObject($obj, string $type = null, bool $checkContext = true, bool $uniqueType = true): bool { - if (! is_array($obj)) { + if (!is_array($obj)) { // Objects must bve encoded as arrays in JSON return false; } if ($checkContext) { - if (!isset($obj['@context']) || ! preg_match('@^https?://schema\.org/?$@', $obj['@context'])) { + if (!isset($obj['@context']) || !preg_match('@^https?://schema\.org/?$@', $obj['@context'])) { // We have no correct context property return false; } diff --git a/lib/Service/RecipeService.php b/lib/Service/RecipeService.php index 1a101a83..f6440d6f 100755 --- a/lib/Service/RecipeService.php +++ b/lib/Service/RecipeService.php @@ -256,7 +256,7 @@ class RecipeService { $recipe_file->putContent(json_encode($json)); - if (! is_null($importedHtml)) { + if (!is_null($importedHtml)) { // We imported a recipe. Save the import html file as a backup $importFile = $recipe_folder->newFile('import.html'); $importFile->putContent($importedHtml); @@ -423,7 +423,7 @@ class RecipeService { */ private function addDatesToRecipes(array &$recipes) { foreach ($recipes as $i => $recipe) { - if (! array_key_exists('dateCreated', $recipe) || ! array_key_exists('dateModified', $recipe)) { + if (!array_key_exists('dateCreated', $recipe) || !array_key_exists('dateModified', $recipe)) { $r = $this->getRecipeById($recipe['recipe_id']); $recipes[$i]['dateCreated'] = $r['dateCreated']; $recipes[$i]['dateModified'] = $r['dateModified']; diff --git a/tests/Migration/Setup/Migrations/AbstractMigrationTestCase.php b/tests/Migration/Setup/Migrations/AbstractMigrationTestCase.php index 5852ad84..8f836ff3 100644 --- a/tests/Migration/Setup/Migrations/AbstractMigrationTestCase.php +++ b/tests/Migration/Setup/Migrations/AbstractMigrationTestCase.php @@ -78,7 +78,7 @@ abstract class AbstractMigrationTestCase extends TestCase { // Reinstall app partially (just before the migration) $migrationBefore = $this->getPreviousMigrationName(); - if (! empty($migrationBefore)) { + if (!empty($migrationBefore)) { // We need to run a migration beforehand $this->migrationService->migrate($migrationBefore); $this->renewSchema(); @@ -101,7 +101,7 @@ abstract class AbstractMigrationTestCase extends TestCase { } private function hideMigrations() { - if (! file_exists(self::TMP_MIGRATIONS)) { + if (!file_exists(self::TMP_MIGRATIONS)) { mkdir(self::TMP_MIGRATIONS); } diff --git a/tests/Unit/Helper/ImageService/ThumbnailFileHelperTest.php b/tests/Unit/Helper/ImageService/ThumbnailFileHelperTest.php index ebd3fa37..77addd01 100644 --- a/tests/Unit/Helper/ImageService/ThumbnailFileHelperTest.php +++ b/tests/Unit/Helper/ImageService/ThumbnailFileHelperTest.php @@ -208,11 +208,11 @@ class ThumbnailFileHelperTest extends TestCase { $f->method('get')->willReturnMap($fileMap); $cnt = 0; - if (! $thumbExists) { - $cnt ++; + if (!$thumbExists) { + $cnt++; } - if (! $miniExists) { - $cnt ++; + if (!$miniExists) { + $cnt++; } $newFileMap = [ ['thumb.jpg', null, $thumb],