From 438271537401559b46832fea3c675cd9d236b41c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 19 Sep 2024 01:11:36 +0000 Subject: [PATCH 1/2] Build(deps-dev): Bump nextcloud/coding-standard from 1.2.3 to 1.3.0 Bumps [nextcloud/coding-standard](https://github.com/nextcloud/coding-standard) from 1.2.3 to 1.3.0. - [Release notes](https://github.com/nextcloud/coding-standard/releases) - [Changelog](https://github.com/nextcloud/coding-standard/blob/master/CHANGELOG.md) - [Commits](https://github.com/nextcloud/coding-standard/compare/v1.2.3...v1.3.0) --- updated-dependencies: - dependency-name: nextcloud/coding-standard dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- composer.lock | 197 +++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 153 insertions(+), 44 deletions(-) diff --git a/composer.lock b/composer.lock index afb980b3e..90ad305c3 100644 --- a/composer.lock +++ b/composer.lock @@ -119,6 +119,119 @@ ], "time": "2022-12-30T00:15:36+00:00" }, + { + "name": "erickskrauch/php-cs-fixer-custom-fixers", + "version": "1.3.0", + "source": { + "type": "git", + "url": "https://github.com/erickskrauch/php-cs-fixer-custom-fixers.git", + "reference": "36fb7f8204c1e17d9b8a24910e2147d0a3973b9c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/erickskrauch/php-cs-fixer-custom-fixers/zipball/36fb7f8204c1e17d9b8a24910e2147d0a3973b9c", + "reference": "36fb7f8204c1e17d9b8a24910e2147d0a3973b9c", + "shasum": "" + }, + "require": { + "friendsofphp/php-cs-fixer": "^3", + "php": "^7.4 || ^8.0" + }, + "require-dev": { + "ely/php-code-style": "^1", + "ergebnis/composer-normalize": "^2.28", + "php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.2", + "phpspec/prophecy": "^1.15", + "phpspec/prophecy-phpunit": "^2.0", + "phpstan/extension-installer": "^1.3", + "phpstan/phpstan": "^1.11.x-dev", + "phpstan/phpstan-phpunit": "^1.3", + "phpstan/phpstan-strict-rules": "^1.5", + "phpunit/phpunit": "^9.5", + "phpunitgoodpractices/polyfill": "^1.5", + "phpunitgoodpractices/traits": "^1.9.1", + "symfony/phpunit-bridge": "^6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "ErickSkrauch\\PhpCsFixer\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "ErickSkrauch", + "email": "erickskrauch@ely.by" + } + ], + "description": "A set of custom fixers for PHP-CS-Fixer", + "homepage": "https://github.com/erickskrauch/php-cs-fixer-custom-fixers", + "keywords": [ + "Code style", + "dev", + "php-cs-fixer" + ], + "support": { + "issues": "https://github.com/erickskrauch/php-cs-fixer-custom-fixers/issues", + "source": "https://github.com/erickskrauch/php-cs-fixer-custom-fixers/tree/1.3.0" + }, + "time": "2024-06-21T20:19:52+00:00" + }, + { + "name": "kubawerlos/php-cs-fixer-custom-fixers", + "version": "v3.22.0", + "source": { + "type": "git", + "url": "https://github.com/kubawerlos/php-cs-fixer-custom-fixers.git", + "reference": "8701394f0c7cd450ac4fa577d24589122c1d5d5e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/kubawerlos/php-cs-fixer-custom-fixers/zipball/8701394f0c7cd450ac4fa577d24589122c1d5d5e", + "reference": "8701394f0c7cd450ac4fa577d24589122c1d5d5e", + "shasum": "" + }, + "require": { + "ext-filter": "*", + "ext-tokenizer": "*", + "friendsofphp/php-cs-fixer": "^3.61.1", + "php": "^7.4 || ^8.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.6.4 || ^10.5.29" + }, + "type": "library", + "autoload": { + "psr-4": { + "PhpCsFixerCustomFixers\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Kuba Werłos", + "email": "werlos@gmail.com" + } + ], + "description": "A set of custom fixers for PHP CS Fixer", + "support": { + "issues": "https://github.com/kubawerlos/php-cs-fixer-custom-fixers/issues", + "source": "https://github.com/kubawerlos/php-cs-fixer-custom-fixers/tree/v3.22.0" + }, + "time": "2024-08-16T20:44:35+00:00" + }, { "name": "myclabs/deep-copy", "version": "1.11.1", @@ -180,19 +293,21 @@ }, { "name": "nextcloud/coding-standard", - "version": "v1.2.3", + "version": "v1.3.0", "source": { "type": "git", "url": "https://github.com/nextcloud/coding-standard.git", - "reference": "bc9c53a5306114b60c4363057aff9c2ed10a54da" + "reference": "e2e6cb1518e3d56ebfb2365bb9fa91ecb50a374c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nextcloud/coding-standard/zipball/bc9c53a5306114b60c4363057aff9c2ed10a54da", - "reference": "bc9c53a5306114b60c4363057aff9c2ed10a54da", + "url": "https://api.github.com/repos/nextcloud/coding-standard/zipball/e2e6cb1518e3d56ebfb2365bb9fa91ecb50a374c", + "reference": "e2e6cb1518e3d56ebfb2365bb9fa91ecb50a374c", "shasum": "" }, "require": { + "erickskrauch/php-cs-fixer-custom-fixers": "^1.3", + "kubawerlos/php-cs-fixer-custom-fixers": "^3.22", "php": "^7.3|^8.0", "php-cs-fixer/shim": "^3.17" }, @@ -215,9 +330,9 @@ "description": "Nextcloud coding standards for the php cs fixer", "support": { "issues": "https://github.com/nextcloud/coding-standard/issues", - "source": "https://github.com/nextcloud/coding-standard/tree/v1.2.3" + "source": "https://github.com/nextcloud/coding-standard/tree/v1.3.0" }, - "time": "2024-08-23T14:32:32+00:00" + "time": "2024-09-18T15:52:45+00:00" }, { "name": "nextcloud/ocp", @@ -432,16 +547,16 @@ }, { "name": "php-cs-fixer/shim", - "version": "v3.62.0", + "version": "v3.64.0", "source": { "type": "git", "url": "https://github.com/PHP-CS-Fixer/shim.git", - "reference": "7a91d5ce45c486f5b445d95901228507a02f60ae" + "reference": "81ccfd24baf3a10810dab1152c403981a790b837" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHP-CS-Fixer/shim/zipball/7a91d5ce45c486f5b445d95901228507a02f60ae", - "reference": "7a91d5ce45c486f5b445d95901228507a02f60ae", + "url": "https://api.github.com/repos/PHP-CS-Fixer/shim/zipball/81ccfd24baf3a10810dab1152c403981a790b837", + "reference": "81ccfd24baf3a10810dab1152c403981a790b837", "shasum": "" }, "require": { @@ -478,9 +593,9 @@ "description": "A tool to automatically fix PHP code style", "support": { "issues": "https://github.com/PHP-CS-Fixer/shim/issues", - "source": "https://github.com/PHP-CS-Fixer/shim/tree/v3.62.0" + "source": "https://github.com/PHP-CS-Fixer/shim/tree/v3.64.0" }, - "time": "2024-08-07T17:03:46+00:00" + "time": "2024-08-30T23:10:11+00:00" }, { "name": "php-webdriver/webdriver", @@ -1506,16 +1621,16 @@ }, { "name": "sebastian/diff", - "version": "4.0.5", + "version": "4.0.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "74be17022044ebaaecfdf0c5cd504fc9cd5a7131" + "reference": "ba01945089c3a293b01ba9badc29ad55b106b0bc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/74be17022044ebaaecfdf0c5cd504fc9cd5a7131", - "reference": "74be17022044ebaaecfdf0c5cd504fc9cd5a7131", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/ba01945089c3a293b01ba9badc29ad55b106b0bc", + "reference": "ba01945089c3a293b01ba9badc29ad55b106b0bc", "shasum": "" }, "require": { @@ -1560,7 +1675,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/diff/issues", - "source": "https://github.com/sebastianbergmann/diff/tree/4.0.5" + "source": "https://github.com/sebastianbergmann/diff/tree/4.0.6" }, "funding": [ { @@ -1568,7 +1683,7 @@ "type": "github" } ], - "time": "2023-05-07T05:35:17+00:00" + "time": "2024-03-02T06:30:58+00:00" }, { "name": "sebastian/environment", @@ -2172,20 +2287,20 @@ }, { "name": "symfony/polyfill-mbstring", - "version": "v1.28.0", + "version": "v1.31.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "42292d99c55abe617799667f454222c54c60e229" + "reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/42292d99c55abe617799667f454222c54c60e229", - "reference": "42292d99c55abe617799667f454222c54c60e229", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/85181ba99b2345b0ef10ce42ecac37612d9fd341", + "reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=7.2" }, "provide": { "ext-mbstring": "*" @@ -2195,9 +2310,6 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.28-dev" - }, "thanks": { "name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill" @@ -2235,7 +2347,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.28.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.31.0" }, "funding": [ { @@ -2251,30 +2363,27 @@ "type": "tidelift" } ], - "time": "2023-07-28T09:04:16+00:00" + "time": "2024-09-09T11:45:10+00:00" }, { "name": "symfony/polyfill-php80", - "version": "v1.28.0", + "version": "v1.31.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "6caa57379c4aec19c0a12a38b59b26487dcfe4b5" + "reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/6caa57379c4aec19c0a12a38b59b26487dcfe4b5", - "reference": "6caa57379c4aec19c0a12a38b59b26487dcfe4b5", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/60328e362d4c2c802a54fcbf04f9d3fb892b4cf8", + "reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=7.2" }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.28-dev" - }, "thanks": { "name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill" @@ -2318,7 +2427,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.28.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.31.0" }, "funding": [ { @@ -2334,20 +2443,20 @@ "type": "tidelift" } ], - "time": "2023-01-26T09:26:14+00:00" + "time": "2024-09-09T11:45:10+00:00" }, { "name": "symfony/process", - "version": "v5.4.28", + "version": "v5.4.40", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "45261e1fccad1b5447a8d7a8e67aa7b4a9798b7b" + "reference": "deedcb3bb4669cae2148bc920eafd2b16dc7c046" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/45261e1fccad1b5447a8d7a8e67aa7b4a9798b7b", - "reference": "45261e1fccad1b5447a8d7a8e67aa7b4a9798b7b", + "url": "https://api.github.com/repos/symfony/process/zipball/deedcb3bb4669cae2148bc920eafd2b16dc7c046", + "reference": "deedcb3bb4669cae2148bc920eafd2b16dc7c046", "shasum": "" }, "require": { @@ -2380,7 +2489,7 @@ "description": "Executes commands in sub-processes", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/process/tree/v5.4.28" + "source": "https://github.com/symfony/process/tree/v5.4.40" }, "funding": [ { @@ -2396,7 +2505,7 @@ "type": "tidelift" } ], - "time": "2023-08-07T10:36:04+00:00" + "time": "2024-05-31T14:33:22+00:00" }, { "name": "theseer/tokenizer", From 75e0e27a515c78e95fef329d1572c8c5d239c53c Mon Sep 17 00:00:00 2001 From: Christian Wolf Date: Fri, 20 Sep 2024 00:30:48 +0200 Subject: [PATCH 2/2] Update code styling Signed-off-by: Christian Wolf --- lib/Controller/CategoryApiController.php | 2 +- lib/Controller/CategoryController.php | 2 +- lib/Controller/ConfigApiController.php | 2 +- lib/Controller/ConfigController.php | 2 +- .../Implementation/CategoryImplementation.php | 4 +++- .../Implementation/ConfigImplementation.php | 2 +- .../Implementation/KeywordImplementation.php | 3 ++- .../Implementation/RecipeImplementation.php | 11 ++++++++++- lib/Controller/KeywordApiController.php | 2 +- lib/Controller/KeywordController.php | 2 +- lib/Controller/MainController.php | 4 +++- lib/Controller/RecipeApiController.php | 2 +- lib/Controller/RecipeController.php | 2 +- lib/Controller/UtilApiController.php | 1 + lib/Db/RecipeDb.php | 8 ++++++-- lib/Helper/AcceptHeaderParsingHelper.php | 2 ++ lib/Helper/DownloadHelper.php | 2 +- lib/Helper/EncodingGuessingHelper.php | 4 +++- lib/Helper/FileSystem/RecipeNameHelper.php | 2 +- .../Filter/DB/NormalizeRecipeFileFilter.php | 2 +- lib/Helper/Filter/DB/RecipeDatesFilter.php | 4 ++++ lib/Helper/Filter/JSON/AbstractJSONFilter.php | 1 + .../Filter/JSON/ExtractImageUrlFilter.php | 6 ++++++ lib/Helper/Filter/JSON/FixDescriptionFilter.php | 3 ++- lib/Helper/Filter/JSON/FixDurationsFilter.php | 3 ++- lib/Helper/Filter/JSON/FixImageSchemeFilter.php | 2 ++ lib/Helper/Filter/JSON/FixIngredientsFilter.php | 2 ++ .../Filter/JSON/FixInstructionsFilter.php | 5 +++-- lib/Helper/Filter/JSON/FixKeywordsFilter.php | 1 + lib/Helper/Filter/JSON/FixNutritionFilter.php | 4 +++- lib/Helper/Filter/JSON/FixRecipeYieldFilter.php | 2 ++ lib/Helper/Filter/JSON/FixTimestampsFilter.php | 3 ++- lib/Helper/Filter/JSON/FixToolsFilter.php | 4 +++- lib/Helper/Filter/JSON/FixUrlFilter.php | 3 ++- lib/Helper/Filter/JSON/JSONFilter.php | 2 +- lib/Helper/Filter/JSON/RecipeIdCopyFilter.php | 1 + lib/Helper/Filter/JSON/RecipeIdTypeFilter.php | 1 + .../Output/EnsureNutritionPresentFilter.php | 2 +- .../Filter/Output/RecipeJSONOutputFilter.php | 2 +- lib/Helper/Filter/Output/RecipeStubFilter.php | 2 +- lib/Helper/HTMLParser/HttpMicrodataParser.php | 2 +- lib/Helper/HtmlToDomParser.php | 2 ++ lib/Helper/ImageService/ImageFileHelper.php | 2 +- .../ImageService/ImageGenerationHelper.php | 2 +- lib/Helper/ImageService/ThumbnailFileHelper.php | 3 ++- lib/Helper/RestParameterParser.php | 4 ++++ lib/Helper/TextCleanupHelper.php | 2 +- lib/Helper/TimestampHelper.php | 12 ++++++++---- lib/Helper/UserConfigHelper.php | 4 +++- lib/Helper/UserFolderHelper.php | 2 +- .../Version000000Date20210701093123.php | 1 + lib/Search/Provider.php | 3 ++- lib/Service/DbCacheService.php | 6 +++++- lib/Service/HtmlDownloadService.php | 3 ++- lib/Service/ImageService.php | 3 ++- lib/Service/JsonService.php | 1 + lib/Service/RecipeService.php | 8 +++++++- .../DownloadHelper/DownloadHelperTest.php | 1 + .../Implementation/RecipeImplementationTest.php | 2 ++ .../Helper/Filter/DB/RecipeDatesFilterTest.php | 1 + .../Filter/JSON/FixDurationsFilterTest.php | 6 ++++-- .../Filter/JSON/FixTimestampsFilterTest.php | 6 ++++-- .../Filter/JSON/SchemaConformityFilterTest.php | 1 + tests/Unit/Helper/Filter/JSONFilterTest.php | 2 ++ .../Filter/RecipeJSONOutputFilterTest.php | 2 ++ .../HTMLParser/HttpMicrodataParserTest.php | 2 +- tests/Unit/Helper/HtmlToDomParserTest.php | 17 +++++++++++------ .../ImageService/ThumbnailFileHelperTest.php | 2 ++ 68 files changed, 158 insertions(+), 58 deletions(-) diff --git a/lib/Controller/CategoryApiController.php b/lib/Controller/CategoryApiController.php index 677cad736..8381f40df 100644 --- a/lib/Controller/CategoryApiController.php +++ b/lib/Controller/CategoryApiController.php @@ -14,7 +14,7 @@ class CategoryApiController extends ApiController { public function __construct( string $AppName, IRequest $request, - CategoryImplementation $categoryImplementation + CategoryImplementation $categoryImplementation, ) { parent::__construct($AppName, $request); diff --git a/lib/Controller/CategoryController.php b/lib/Controller/CategoryController.php index f28d86f7b..a2559112c 100644 --- a/lib/Controller/CategoryController.php +++ b/lib/Controller/CategoryController.php @@ -14,7 +14,7 @@ class CategoryController extends Controller { public function __construct( string $AppName, IRequest $request, - CategoryImplementation $categoryImplementation + CategoryImplementation $categoryImplementation, ) { parent::__construct($AppName, $request); diff --git a/lib/Controller/ConfigApiController.php b/lib/Controller/ConfigApiController.php index 4d0e3be72..9f862beea 100644 --- a/lib/Controller/ConfigApiController.php +++ b/lib/Controller/ConfigApiController.php @@ -14,7 +14,7 @@ class ConfigApiController extends ApiController { public function __construct( $AppName, IRequest $request, - ConfigImplementation $configImplementation + ConfigImplementation $configImplementation, ) { parent::__construct($AppName, $request); diff --git a/lib/Controller/ConfigController.php b/lib/Controller/ConfigController.php index 4c65e61d8..6d4abc60e 100644 --- a/lib/Controller/ConfigController.php +++ b/lib/Controller/ConfigController.php @@ -14,7 +14,7 @@ class ConfigController extends Controller { public function __construct( $AppName, IRequest $request, - ConfigImplementation $configImplementation + ConfigImplementation $configImplementation, ) { parent::__construct($AppName, $request); diff --git a/lib/Controller/Implementation/CategoryImplementation.php b/lib/Controller/Implementation/CategoryImplementation.php index 11f98c0ce..4d96d46c7 100644 --- a/lib/Controller/Implementation/CategoryImplementation.php +++ b/lib/Controller/Implementation/CategoryImplementation.php @@ -19,7 +19,7 @@ class CategoryImplementation { public function __construct( RecipeService $service, DbCacheService $dbCacheService, - RestParameterParser $restParameterParser + RestParameterParser $restParameterParser, ) { $this->service = $service; $this->dbCacheService = $dbCacheService; @@ -35,6 +35,7 @@ public function index() { $this->dbCacheService->triggerCheck(); $categories = $this->service->getAllCategoriesInSearchIndex(); + return new JSONResponse($categories, 200); } @@ -60,6 +61,7 @@ public function rename($category) { $r['recipeCategory'] = $json['name']; $this->service->addRecipe($r); } + // Update cache $this->dbCacheService->updateCache(); diff --git a/lib/Controller/Implementation/ConfigImplementation.php b/lib/Controller/Implementation/ConfigImplementation.php index 354f39052..49a0a2f63 100644 --- a/lib/Controller/Implementation/ConfigImplementation.php +++ b/lib/Controller/Implementation/ConfigImplementation.php @@ -23,7 +23,7 @@ public function __construct( RecipeService $recipeService, DbCacheService $dbCacheService, RestParameterParser $restParser, - UserFolderHelper $userFolder + UserFolderHelper $userFolder, ) { $this->service = $recipeService; $this->dbCacheService = $dbCacheService; diff --git a/lib/Controller/Implementation/KeywordImplementation.php b/lib/Controller/Implementation/KeywordImplementation.php index 4030bc64b..d2ae61bc4 100644 --- a/lib/Controller/Implementation/KeywordImplementation.php +++ b/lib/Controller/Implementation/KeywordImplementation.php @@ -14,7 +14,7 @@ class KeywordImplementation { public function __construct( RecipeService $recipeService, - DbCacheService $dbCacheService + DbCacheService $dbCacheService, ) { $this->service = $recipeService; $this->dbCacheService = $dbCacheService; @@ -28,6 +28,7 @@ public function index() { $this->dbCacheService->triggerCheck(); $keywords = $this->service->getAllKeywordsInSearchIndex(); + return new JSONResponse($keywords, 200); } } diff --git a/lib/Controller/Implementation/RecipeImplementation.php b/lib/Controller/Implementation/RecipeImplementation.php index 74bf456e0..913ecd3fd 100644 --- a/lib/Controller/Implementation/RecipeImplementation.php +++ b/lib/Controller/Implementation/RecipeImplementation.php @@ -48,7 +48,7 @@ public function __construct( RecipeJSONOutputFilter $recipeJSONOutputFilter, RecipeStubFilter $stubFilter, AcceptHeaderParsingHelper $acceptHeaderParsingHelper, - IL10N $iL10N + IL10N $iL10N, ) { $this->request = $request; $this->service = $recipeService; @@ -72,12 +72,14 @@ public function index() { } else { $recipes = $this->service->findRecipesInSearchIndex(isset($_GET['keywords']) ? $_GET['keywords'] : ''); } + foreach ($recipes as $i => $recipe) { $recipes[$i]['imageUrl'] = $this->urlGenerator->linkToRoute('cookbook.recipe.image', ['id' => $recipe['recipe_id'], 'size' => 'thumb']); $recipes[$i]['imagePlaceholderUrl'] = $this->urlGenerator->linkToRoute('cookbook.recipe.image', ['id' => $recipe['recipe_id'], 'size' => 'thumb16']); $recipes[$i] = $this->stubFilter->apply($recipes[$i]); } + return new JSONResponse($recipes, Http::STATUS_OK); } @@ -123,6 +125,7 @@ public function update($id) { 'file' => $ex->getFile(), 'line' => $ex->getLine(), ]; + return new JSONResponse($json, Http::STATUS_CONFLICT); } catch (NoRecipeNameGivenException $ex) { $json = [ @@ -130,8 +133,10 @@ public function update($id) { 'file' => $ex->getFile(), 'line' => $ex->getLine(), ]; + return new JSONResponse($json, Http::STATUS_UNPROCESSABLE_ENTITY); } + $this->dbCacheService->addRecipe($file); return new JSONResponse($file->getParent()->getId(), Http::STATUS_OK); @@ -157,6 +162,7 @@ public function create() { 'file' => $ex->getFile(), 'line' => $ex->getLine(), ]; + return new JSONResponse($json, Http::STATUS_CONFLICT); } catch (NoRecipeNameGivenException $ex) { $json = [ @@ -164,6 +170,7 @@ public function create() { 'file' => $ex->getFile(), 'line' => $ex->getLine(), ]; + return new JSONResponse($json, Http::STATUS_UNPROCESSABLE_ENTITY); } } @@ -209,6 +216,7 @@ public function image($id) { $json = [ 'msg' => $this->l->t('No image with the matching MIME type was found on the server.'), ]; + return new JSONResponse($json, Http::STATUS_NOT_ACCEPTABLE); } else { // The client accepts the SVG file. Send it. @@ -245,6 +253,7 @@ public function import() { 'line' => $ex->getLine(), 'file' => $ex->getFile(), ]; + return new JSONResponse($json, Http::STATUS_CONFLICT); } catch (\Exception $e) { return new JSONResponse($e->getMessage(), 400); diff --git a/lib/Controller/KeywordApiController.php b/lib/Controller/KeywordApiController.php index f410f440d..308e12f1c 100644 --- a/lib/Controller/KeywordApiController.php +++ b/lib/Controller/KeywordApiController.php @@ -14,7 +14,7 @@ class KeywordApiController extends ApiController { public function __construct( string $AppName, IRequest $request, - KeywordImplementation $keywordImplementation + KeywordImplementation $keywordImplementation, ) { parent::__construct($AppName, $request); diff --git a/lib/Controller/KeywordController.php b/lib/Controller/KeywordController.php index f5ac9ff64..8c1452e59 100644 --- a/lib/Controller/KeywordController.php +++ b/lib/Controller/KeywordController.php @@ -14,7 +14,7 @@ class KeywordController extends Controller { public function __construct( string $AppName, IRequest $request, - KeywordImplementation $keywordImplementation + KeywordImplementation $keywordImplementation, ) { parent::__construct($AppName, $request); diff --git a/lib/Controller/MainController.php b/lib/Controller/MainController.php index 9a7206a4f..06ed20e6c 100755 --- a/lib/Controller/MainController.php +++ b/lib/Controller/MainController.php @@ -23,7 +23,7 @@ public function __construct( string $AppName, IRequest $request, DbCacheService $dbCacheService, - UserFolderHelper $userFolder + UserFolderHelper $userFolder, ) { parent::__construct($AppName, $request); @@ -47,6 +47,7 @@ public function index(): TemplateResponse { Util::addScript('cookbook', 'cookbook-guest'); return new TemplateResponse($this->appName, 'invalid_guest'); } + /* * The UserNotLoggedInException will not be caught here. It should never happen as the middleware of NC * will prevent the controller to be called. If this does not happen for some reason, let the exception be @@ -56,6 +57,7 @@ public function index(): TemplateResponse { $this->dbCacheService->triggerCheck(); Util::addScript('cookbook', 'cookbook-main'); + return new TemplateResponse($this->appName, 'index'); // templates/index.php } } diff --git a/lib/Controller/RecipeApiController.php b/lib/Controller/RecipeApiController.php index 116cec579..909251b0a 100644 --- a/lib/Controller/RecipeApiController.php +++ b/lib/Controller/RecipeApiController.php @@ -16,7 +16,7 @@ class RecipeApiController extends ApiController { public function __construct( string $AppName, IRequest $request, - RecipeImplementation $recipeImplementation + RecipeImplementation $recipeImplementation, ) { parent::__construct($AppName, $request); diff --git a/lib/Controller/RecipeController.php b/lib/Controller/RecipeController.php index 31af18c3d..0cdd874a8 100755 --- a/lib/Controller/RecipeController.php +++ b/lib/Controller/RecipeController.php @@ -15,7 +15,7 @@ class RecipeController extends Controller { public function __construct( $AppName, IRequest $request, - RecipeImplementation $recipeImplementation + RecipeImplementation $recipeImplementation, ) { parent::__construct($AppName, $request); diff --git a/lib/Controller/UtilApiController.php b/lib/Controller/UtilApiController.php index 9c560dc4a..f15796cdf 100644 --- a/lib/Controller/UtilApiController.php +++ b/lib/Controller/UtilApiController.php @@ -26,6 +26,7 @@ public function getApiVersion(): JSONResponse { 'minor' => 2 ] ]; + return new JSONResponse($response, 200); } } diff --git a/lib/Db/RecipeDb.php b/lib/Db/RecipeDb.php index 97310eccb..daefcc747 100755 --- a/lib/Db/RecipeDb.php +++ b/lib/Db/RecipeDb.php @@ -24,7 +24,7 @@ class RecipeDb { public function __construct( IDBConnection $db, - IL10N $l + IL10N $l, ) { $this->db = $db; $this->l = $l; @@ -143,6 +143,7 @@ public function unique(array $result) { if (!isset($recipe['recipe_id'])) { continue; } + if (isset($unique_result[$recipe['recipe_id']])) { continue; } @@ -299,6 +300,7 @@ public function getRecipesByCategory(string $category, string $user_id) { } else { $x['category'] = $category; } + return $x; }, $result); @@ -409,10 +411,11 @@ public function groupKeywordInResult(array $result) { $recipesGroupedTags[$recipe['recipe_id']] = $recipe; } else { if (!is_null($recipe['keywords'])) { - $recipesGroupedTags[$recipe['recipe_id']]['keywords'] .= ','.$recipe['keywords']; + $recipesGroupedTags[$recipe['recipe_id']]['keywords'] .= ',' . $recipe['keywords']; } } } + return $recipesGroupedTags; } @@ -606,6 +609,7 @@ public function addCategoryOfRecipe(int $recipeId, string $categoryName, string if (empty($categoryName)) { $categoryName = '*'; } + // else if(is_array($json['recipeCategory'])) // { // $json['recipeCategory'] = reset($json['recipeCategory']); diff --git a/lib/Helper/AcceptHeaderParsingHelper.php b/lib/Helper/AcceptHeaderParsingHelper.php index 786e86e03..f2a37f4d6 100644 --- a/lib/Helper/AcceptHeaderParsingHelper.php +++ b/lib/Helper/AcceptHeaderParsingHelper.php @@ -38,6 +38,7 @@ public function parseHeader(string $header): array { } } } + return $extensions; } @@ -103,6 +104,7 @@ private function getFileTypes(string $mime): array { case '*/*': return ['jpg', 'png', 'svg']; } + return []; } } diff --git a/lib/Helper/DownloadHelper.php b/lib/Helper/DownloadHelper.php index 5eabca994..5299edb93 100644 --- a/lib/Helper/DownloadHelper.php +++ b/lib/Helper/DownloadHelper.php @@ -38,7 +38,7 @@ class DownloadHelper { private $l; public function __construct( - IL10N $l + IL10N $l, ) { $this->downloaded = false; $this->l = $l; diff --git a/lib/Helper/EncodingGuessingHelper.php b/lib/Helper/EncodingGuessingHelper.php index df59998e0..37f66f60c 100644 --- a/lib/Helper/EncodingGuessingHelper.php +++ b/lib/Helper/EncodingGuessingHelper.php @@ -14,7 +14,7 @@ class EncodingGuessingHelper { private $l; public function __construct( - IL10N $l + IL10N $l, ) { $this->l = $l; } @@ -55,6 +55,7 @@ private function guessFromContentType(string $contentType): ?string { return $subparts[1]; } } + // Fallback: We did not find anything in the Content-Type return null; } @@ -65,6 +66,7 @@ private function guessFromMainContent(string $content): ?string { if ($ret === 1) { return $matches[1]; } + return null; } } diff --git a/lib/Helper/FileSystem/RecipeNameHelper.php b/lib/Helper/FileSystem/RecipeNameHelper.php index 71de5b492..3e1ee13ed 100644 --- a/lib/Helper/FileSystem/RecipeNameHelper.php +++ b/lib/Helper/FileSystem/RecipeNameHelper.php @@ -17,7 +17,7 @@ class RecipeNameHelper { public function __construct( IL10N $l, - LoggerInterface $logger + LoggerInterface $logger, ) { $this->l = $l; $this->logger = $logger; diff --git a/lib/Helper/Filter/DB/NormalizeRecipeFileFilter.php b/lib/Helper/Filter/DB/NormalizeRecipeFileFilter.php index f58c7bf81..5922cc258 100644 --- a/lib/Helper/Filter/DB/NormalizeRecipeFileFilter.php +++ b/lib/Helper/Filter/DB/NormalizeRecipeFileFilter.php @@ -9,7 +9,7 @@ class NormalizeRecipeFileFilter { private $filters; public function __construct( - RecipeDatesFilter $datesFilter + RecipeDatesFilter $datesFilter, ) { $this->filters = [ $datesFilter, diff --git a/lib/Helper/Filter/DB/RecipeDatesFilter.php b/lib/Helper/Filter/DB/RecipeDatesFilter.php index dd5ca4571..092cbb3a3 100644 --- a/lib/Helper/Filter/DB/RecipeDatesFilter.php +++ b/lib/Helper/Filter/DB/RecipeDatesFilter.php @@ -54,6 +54,7 @@ public function apply(array &$json, File $recipe): bool { $ret = true; } } + /* The else case is not considered: If only the creation time is given, this is a valid recipe (no modifications so far). @@ -72,6 +73,7 @@ private function getTimeFromFile(File $file): string { if ($timestamp === 0) { $timestamp = $file->getUploadTime(); } + if ($timestamp === 0) { $timestamp = $file->getMTime(); } @@ -108,6 +110,7 @@ private function checkDateFormat(array &$json, string $name, bool &$ret) { if ($json[$name] > 0) { $json[$name] = $this->getDateFromTimestamp($json[$name]); $ret = true; + return; } } @@ -115,6 +118,7 @@ private function checkDateFormat(array &$json, string $name, bool &$ret) { // We cannot read the format. Removing it from teh recipe $json[$name] = null; $ret = true; + return; } } diff --git a/lib/Helper/Filter/JSON/AbstractJSONFilter.php b/lib/Helper/Filter/JSON/AbstractJSONFilter.php index 352983a7e..a68ffb4cc 100644 --- a/lib/Helper/Filter/JSON/AbstractJSONFilter.php +++ b/lib/Helper/Filter/JSON/AbstractJSONFilter.php @@ -34,6 +34,7 @@ protected function setJSONValue(array &$json, string $key, $value): bool { $json[$key] = $value; return true; } + return false; } } diff --git a/lib/Helper/Filter/JSON/ExtractImageUrlFilter.php b/lib/Helper/Filter/JSON/ExtractImageUrlFilter.php index 656470ee5..fd180666e 100644 --- a/lib/Helper/Filter/JSON/ExtractImageUrlFilter.php +++ b/lib/Helper/Filter/JSON/ExtractImageUrlFilter.php @@ -40,6 +40,7 @@ public function apply(array &$json): bool { // It is neither a plain string nor a JSON object $this->logger->info($this->l->t('The given image for the recipe %s cannot be parsed. Aborting and skipping it.', [$json['name']])); $json['image'] = ''; + return true; } @@ -47,6 +48,7 @@ public function apply(array &$json): bool { if (isset($json['image']['url'])) { // We have a single object. Use it. $json['image'] = $json['image']['url']; + return true; } @@ -55,9 +57,11 @@ public function apply(array &$json): bool { if (is_string($x)) { return $x; } + if (is_array($x) && isset($x['url']) && $x['url'] && is_string($x['url'])) { return $x['url']; } + return null; }, $json['image']); $images = array_filter($images); @@ -65,12 +69,14 @@ public function apply(array &$json): bool { if (count($images) === 1) { reset($images); $json['image'] = current($images); + return true; } if (count($images) === 0) { $this->logger->info($this->l->t('No valid recipe was left after heuristics of recipe %s.', [$json['name']])); $json['image'] = ''; + return true; } diff --git a/lib/Helper/Filter/JSON/FixDescriptionFilter.php b/lib/Helper/Filter/JSON/FixDescriptionFilter.php index ca404511f..be32210d5 100644 --- a/lib/Helper/Filter/JSON/FixDescriptionFilter.php +++ b/lib/Helper/Filter/JSON/FixDescriptionFilter.php @@ -29,7 +29,7 @@ class FixDescriptionFilter extends AbstractJSONFilter { public function __construct( IL10N $l, LoggerInterface $logger, - TextCleanupHelper $textCleanupHelper + TextCleanupHelper $textCleanupHelper, ) { $this->l = $l; $this->logger = $logger; @@ -47,6 +47,7 @@ public function apply(array &$json): bool { $changed = $description !== $json[self::DESCRIPTION]; $json[self::DESCRIPTION] = $description; + return $changed; } } diff --git a/lib/Helper/Filter/JSON/FixDurationsFilter.php b/lib/Helper/Filter/JSON/FixDurationsFilter.php index 5bb346b3f..58043e2e2 100644 --- a/lib/Helper/Filter/JSON/FixDurationsFilter.php +++ b/lib/Helper/Filter/JSON/FixDurationsFilter.php @@ -30,7 +30,7 @@ class FixDurationsFilter extends AbstractJSONFilter { public function __construct( IL10N $l, LoggerInterface $logger, - ISO8601DurationHelper $isoHelper + ISO8601DurationHelper $isoHelper, ) { $this->l = $l; $this->logger = $logger; @@ -51,6 +51,7 @@ private function fixDate(array &$json, string $type, bool &$changed): void { if (!isset($json[$type])) { $json[$type] = null; $changed = true; + return; } diff --git a/lib/Helper/Filter/JSON/FixImageSchemeFilter.php b/lib/Helper/Filter/JSON/FixImageSchemeFilter.php index 6bd3707cf..f88ea93fe 100644 --- a/lib/Helper/Filter/JSON/FixImageSchemeFilter.php +++ b/lib/Helper/Filter/JSON/FixImageSchemeFilter.php @@ -23,11 +23,13 @@ public function apply(array &$json): bool { if (!isset($json['url'])) { throw new InvalidRecipeException($this->l->t('Could not guess image URL as no recipe URL was found.')); } + if (preg_match('/^([a-zA-Z]+:)\/\//', $json['url'], $matches) !== 1) { throw new InvalidRecipeException($this->l->t('Could not guess image URL scheme from recipe URL %s', [$json['url']])); } $json['image'] = $matches[1] . $json['image']; + return true; } else { return false; diff --git a/lib/Helper/Filter/JSON/FixIngredientsFilter.php b/lib/Helper/Filter/JSON/FixIngredientsFilter.php index 29222fced..3fa3c3b30 100644 --- a/lib/Helper/Filter/JSON/FixIngredientsFilter.php +++ b/lib/Helper/Filter/JSON/FixIngredientsFilter.php @@ -49,6 +49,7 @@ public function apply(array &$json): bool { $ingredients = array_map(function ($t) { $t = trim($t); $t = $this->textCleaner->cleanUp($t, false); + return $t; }, $ingredients); $ingredients = array_filter($ingredients, fn ($t) => ($t)); @@ -56,6 +57,7 @@ public function apply(array &$json): bool { $changed = $ingredients !== $json[self::INGREDIENTS]; $json[self::INGREDIENTS] = $ingredients; + return $changed; } } diff --git a/lib/Helper/Filter/JSON/FixInstructionsFilter.php b/lib/Helper/Filter/JSON/FixInstructionsFilter.php index b906a0dd8..dc58a992e 100644 --- a/lib/Helper/Filter/JSON/FixInstructionsFilter.php +++ b/lib/Helper/Filter/JSON/FixInstructionsFilter.php @@ -44,7 +44,7 @@ public function __construct( IL10N $l, LoggerInterface $logger, TextCleanupHelper $textCleanupHelper, - JsonService $jsonService + JsonService $jsonService, ) { $this->l = $l; $this->logger = $logger; @@ -110,7 +110,6 @@ public function apply(array &$json): bool { $instructions = array_merge(...$instructions); } - $instructions = array_map(function ($x) { $x = trim($x); $x = $this->textCleaner->cleanUp($x, false); @@ -123,6 +122,7 @@ public function apply(array &$json): bool { $changed = $instructions !== $json[self::INSTRUCTIONS]; $json[self::INSTRUCTIONS] = $instructions; + return $changed; } @@ -205,6 +205,7 @@ private function parseString(array $json): array { $pieces = preg_split('/[\n\r]+/', $json[self::INSTRUCTIONS]); $pieces = array_map(fn ($x) => (strip_tags($x)), $pieces); $pieces = array_filter($pieces); + return $pieces; } diff --git a/lib/Helper/Filter/JSON/FixKeywordsFilter.php b/lib/Helper/Filter/JSON/FixKeywordsFilter.php index 8baa9b5ce..d98e3068a 100644 --- a/lib/Helper/Filter/JSON/FixKeywordsFilter.php +++ b/lib/Helper/Filter/JSON/FixKeywordsFilter.php @@ -43,6 +43,7 @@ public function apply(array &$json): bool { 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/FixNutritionFilter.php b/lib/Helper/Filter/JSON/FixNutritionFilter.php index 40212d65b..d5b295957 100644 --- a/lib/Helper/Filter/JSON/FixNutritionFilter.php +++ b/lib/Helper/Filter/JSON/FixNutritionFilter.php @@ -24,7 +24,7 @@ class FixNutritionFilter extends AbstractJSONFilter { public function __construct( IL10N $l, - LoggerInterface $logger + LoggerInterface $logger, ) { $this->l = $l; $this->logger = $logger; @@ -39,12 +39,14 @@ public function apply(array &$json): bool { if (!is_array($json[self::NUTRITION])) { $this->logger->info($this->l->t('Could not parse the nutrition information successfully for recipe {name}.', ['name' => $json['name']])); $json[self::NUTRITION] = []; + return true; } $nutrition = $json[self::NUTRITION]; $json[self::NUTRITION] = array_filter($json[self::NUTRITION]); + return $json[self::NUTRITION] !== $nutrition; } } diff --git a/lib/Helper/Filter/JSON/FixRecipeYieldFilter.php b/lib/Helper/Filter/JSON/FixRecipeYieldFilter.php index 777bd3020..d7dc86a93 100644 --- a/lib/Helper/Filter/JSON/FixRecipeYieldFilter.php +++ b/lib/Helper/Filter/JSON/FixRecipeYieldFilter.php @@ -83,12 +83,14 @@ public function apply(array &$json): bool { )); $json[self::YIELD] = (int)$last; + return true; } // We did not find anything useful. $this->logger->info($this->l->t('Could not parse "recipeYield" field. Falling back to 1 serving.')); $json[self::YIELD] = 1; + return true; } } diff --git a/lib/Helper/Filter/JSON/FixTimestampsFilter.php b/lib/Helper/Filter/JSON/FixTimestampsFilter.php index f3df4c149..c078d6761 100644 --- a/lib/Helper/Filter/JSON/FixTimestampsFilter.php +++ b/lib/Helper/Filter/JSON/FixTimestampsFilter.php @@ -28,7 +28,7 @@ class FixTimestampsFilter extends AbstractJSONFilter { public function __construct( IL10N $l, LoggerInterface $logger, - TimestampHelper $tsHelper + TimestampHelper $tsHelper, ) { $this->l = $l; $this->logger = $logger; @@ -49,6 +49,7 @@ private function fixTimestamp(array &$json, string $type, bool &$changed): void if (!isset($json[$type])) { $json[$type] = null; $changed = true; + return; } diff --git a/lib/Helper/Filter/JSON/FixToolsFilter.php b/lib/Helper/Filter/JSON/FixToolsFilter.php index a5cf278b8..6b0c82468 100644 --- a/lib/Helper/Filter/JSON/FixToolsFilter.php +++ b/lib/Helper/Filter/JSON/FixToolsFilter.php @@ -51,13 +51,14 @@ public function apply(array &$json): bool { $t = $this->textCleaner->cleanUp($t, false); // Empty string would mean no tools (i.e., empty array) - if($t != '') { + if ($t != '') { $tools[] = $t; } } else { $tools = array_map(function ($t) { $t = trim($t); $t = $this->textCleaner->cleanUp($t, false); + return $t; }, $json[self::TOOLS]); $tools = array_filter($tools, fn ($t) => ($t)); @@ -67,6 +68,7 @@ public function apply(array &$json): bool { $changed = $tools !== $json[self::TOOLS]; $json[self::TOOLS] = $tools; + return $changed; } } diff --git a/lib/Helper/Filter/JSON/FixUrlFilter.php b/lib/Helper/Filter/JSON/FixUrlFilter.php index f3f93bf17..45026265b 100644 --- a/lib/Helper/Filter/JSON/FixUrlFilter.php +++ b/lib/Helper/Filter/JSON/FixUrlFilter.php @@ -24,7 +24,7 @@ class FixUrlFilter extends AbstractJSONFilter { public function __construct( IL10N $l, - LoggerInterface $logger + LoggerInterface $logger, ) { $this->l = $l; $this->logger = $logger; @@ -43,6 +43,7 @@ public function apply(array &$json): bool { $changed = $url !== $json[self::URL]; $json[self::URL] = $url; + return $changed; } } diff --git a/lib/Helper/Filter/JSON/JSONFilter.php b/lib/Helper/Filter/JSON/JSONFilter.php index 7724010bd..067557555 100644 --- a/lib/Helper/Filter/JSON/JSONFilter.php +++ b/lib/Helper/Filter/JSON/JSONFilter.php @@ -22,7 +22,7 @@ public function __construct( FixDescriptionFilter $fixDescriptionFilter, FixUrlFilter $fixUrlFilter, FixDurationsFilter $fixDurationsFilter, - FixNutritionFilter $fixNutritionFilter + FixNutritionFilter $fixNutritionFilter, ) { $this->filters = [ $schemaConformityFilter, diff --git a/lib/Helper/Filter/JSON/RecipeIdCopyFilter.php b/lib/Helper/Filter/JSON/RecipeIdCopyFilter.php index 981fd28b2..142b91a28 100644 --- a/lib/Helper/Filter/JSON/RecipeIdCopyFilter.php +++ b/lib/Helper/Filter/JSON/RecipeIdCopyFilter.php @@ -11,6 +11,7 @@ public function apply(array &$json): bool { if (! isset($json['id'])) { $json['id'] = $json['recipe_id']; } + return $json !== $copy; } } diff --git a/lib/Helper/Filter/JSON/RecipeIdTypeFilter.php b/lib/Helper/Filter/JSON/RecipeIdTypeFilter.php index f085617ab..ac922f1fa 100644 --- a/lib/Helper/Filter/JSON/RecipeIdTypeFilter.php +++ b/lib/Helper/Filter/JSON/RecipeIdTypeFilter.php @@ -11,6 +11,7 @@ class RecipeIdTypeFilter extends AbstractJSONFilter { public function apply(array &$json): bool { $copy = $json; $json['id'] = strval($json['id']); + return $json !== $copy; } } diff --git a/lib/Helper/Filter/Output/EnsureNutritionPresentFilter.php b/lib/Helper/Filter/Output/EnsureNutritionPresentFilter.php index a04b366ed..95a876764 100644 --- a/lib/Helper/Filter/Output/EnsureNutritionPresentFilter.php +++ b/lib/Helper/Filter/Output/EnsureNutritionPresentFilter.php @@ -20,7 +20,7 @@ class EnsureNutritionPresentFilter extends AbstractJSONFilter { public function __construct( IL10N $l, - LoggerInterface $logger + LoggerInterface $logger, ) { $this->l = $l; $this->logger = $logger; diff --git a/lib/Helper/Filter/Output/RecipeJSONOutputFilter.php b/lib/Helper/Filter/Output/RecipeJSONOutputFilter.php index db233feab..d37b44553 100644 --- a/lib/Helper/Filter/Output/RecipeJSONOutputFilter.php +++ b/lib/Helper/Filter/Output/RecipeJSONOutputFilter.php @@ -10,7 +10,7 @@ class RecipeJSONOutputFilter { private $filters; public function __construct( - EnsureNutritionPresentFilter $ensureNutritionPresentFilter + EnsureNutritionPresentFilter $ensureNutritionPresentFilter, ) { $this->filters = [ $ensureNutritionPresentFilter, diff --git a/lib/Helper/Filter/Output/RecipeStubFilter.php b/lib/Helper/Filter/Output/RecipeStubFilter.php index 8e38efcf9..a02df79a2 100644 --- a/lib/Helper/Filter/Output/RecipeStubFilter.php +++ b/lib/Helper/Filter/Output/RecipeStubFilter.php @@ -12,7 +12,7 @@ class RecipeStubFilter { public function __construct( RecipeIdTypeFilter $recipeIdTypeFilter, - RecipeIdCopyFilter $recipeIdCopyFilter + RecipeIdCopyFilter $recipeIdCopyFilter, ) { $this->filters = [ $recipeIdCopyFilter, diff --git a/lib/Helper/HTMLParser/HttpMicrodataParser.php b/lib/Helper/HTMLParser/HttpMicrodataParser.php index 52963d58f..259963d41 100644 --- a/lib/Helper/HTMLParser/HttpMicrodataParser.php +++ b/lib/Helper/HTMLParser/HttpMicrodataParser.php @@ -157,7 +157,7 @@ private function searchMultipleProperties( DOMNode $recipeNode, array $properties, array $attributes, - string $dst + string $dst, ): bool { foreach ($properties as $prop) { $entries = $this->searchChildEntries($recipeNode, $prop); diff --git a/lib/Helper/HtmlToDomParser.php b/lib/Helper/HtmlToDomParser.php index a7b44160a..1669f5ac6 100644 --- a/lib/Helper/HtmlToDomParser.php +++ b/lib/Helper/HtmlToDomParser.php @@ -85,6 +85,7 @@ public function loadHtmlString(DOMDocument $dom, string $url, string $html): DOM } catch (Exception $ex) { throw new ImportException($this->l->t('Parsing of HTML failed.'), null, $ex); } + libxml_clear_errors(); if (!$parsedSuccessfully) { @@ -215,6 +216,7 @@ private function logFatalError(int $code, array $group, string $url): void { private function formatError(string $errorMessage, LibXMLError $error): string { $firstOccurence = $this->l->t('First time it occurred in line %u and column %u', [$error->line, $error->column]); $msg = "libxml: $errorMessage $firstOccurence: {$error->message}"; + return $msg; } } diff --git a/lib/Helper/ImageService/ImageFileHelper.php b/lib/Helper/ImageService/ImageFileHelper.php index 42bcd362e..0d87e756a 100644 --- a/lib/Helper/ImageService/ImageFileHelper.php +++ b/lib/Helper/ImageService/ImageFileHelper.php @@ -18,7 +18,7 @@ class ImageFileHelper { private $l; public function __construct( - IL10N $l + IL10N $l, ) { $this->l = $l; } diff --git a/lib/Helper/ImageService/ImageGenerationHelper.php b/lib/Helper/ImageService/ImageGenerationHelper.php index 0cfd98a79..d2de382b7 100644 --- a/lib/Helper/ImageService/ImageGenerationHelper.php +++ b/lib/Helper/ImageService/ImageGenerationHelper.php @@ -28,7 +28,7 @@ class ImageGenerationHelper { private $thumbnailService; public function __construct( - ThumbnailService $thumbnailService + ThumbnailService $thumbnailService, ) { $this->thumbnailService = $thumbnailService; } diff --git a/lib/Helper/ImageService/ThumbnailFileHelper.php b/lib/Helper/ImageService/ThumbnailFileHelper.php index baaa568dc..ae16f8810 100644 --- a/lib/Helper/ImageService/ThumbnailFileHelper.php +++ b/lib/Helper/ImageService/ThumbnailFileHelper.php @@ -31,7 +31,7 @@ class ThumbnailFileHelper { public function __construct( ImageGenerationHelper $generationHelper, ImageFileHelper $fileHelper, - IL10N $l + IL10N $l, ) { $this->generationHelper = $generationHelper; $this->fileHelper = $fileHelper; @@ -58,6 +58,7 @@ public function getThumbnail(Folder $recipeFolder, int $type): File { $file = $recipeFolder->newFile($filename); $this->generationHelper->generateThumbnail($full, $type, $file); + return $file; } else { throw new NoRecipeImageFoundException( diff --git a/lib/Helper/RestParameterParser.php b/lib/Helper/RestParameterParser.php index 794ea8a6a..6e6bac3f5 100644 --- a/lib/Helper/RestParameterParser.php +++ b/lib/Helper/RestParameterParser.php @@ -33,6 +33,7 @@ public function getParameters(): array { switch (trim($parts[0])) { case 'application/json': $enc = $this->getEncoding($_SERVER[self::CONTENT_TYPE]); + return $this->parseApplicationJSON($enc); break; @@ -42,6 +43,7 @@ public function getParameters(): array { } else { throw new \Exception($this->l->t('Cannot parse non-POST multipart encoding. This is a bug.')); } + break; case 'application/x-www-form-urlencoded': @@ -51,6 +53,7 @@ public function getParameters(): array { $enc = $this->getEncoding($_SERVER[self::CONTENT_TYPE]); return $this->parseUrlEncoded($enc); } + break; } } else { @@ -69,6 +72,7 @@ private function parseApplicationJSON(string $encoding): array { if ($encoding !== 'UTF-8') { $rawData = iconv($encoding, 'UTF-8', $rawData); } + return json_decode($rawData, true); } diff --git a/lib/Helper/TextCleanupHelper.php b/lib/Helper/TextCleanupHelper.php index 198cac44b..6920dc296 100644 --- a/lib/Helper/TextCleanupHelper.php +++ b/lib/Helper/TextCleanupHelper.php @@ -14,7 +14,7 @@ class TextCleanupHelper { public function cleanUp( ?string $str, bool $removeNewlines = true, - bool $removeSlashes = false + bool $removeSlashes = false, ): string { if (!$str) { return ''; diff --git a/lib/Helper/TimestampHelper.php b/lib/Helper/TimestampHelper.php index a4ce951b8..7ddd1ba78 100644 --- a/lib/Helper/TimestampHelper.php +++ b/lib/Helper/TimestampHelper.php @@ -67,10 +67,12 @@ private function parseIsoFormat(string $timestamp): string { return $this->parseIsoCalendarDateFormat($timestamp, '-'); } catch (InvalidTimestampException $ex) { // Check next format } + try { return $this->parseIsoCalendarDateFormat($timestamp, ''); } catch (InvalidTimestampException $ex) { // Check next format } + try { return $this->parseIsoWeekDateFormat($timestamp, '-'); } catch (InvalidTimestampException $ex) { // Check next format @@ -90,7 +92,7 @@ private function parseIsoFormat(string $timestamp): string { * @throws InvalidTimestampException if $timestamp does not comply to ISO 8601 with week and weekday. */ private function parseIsoCalendarDateFormat(string $timestamp, string $dateSeparator = '-'): string { - $date = 'Y'.$dateSeparator.'m'.$dateSeparator.'d'; + $date = 'Y' . $dateSeparator . 'm' . $dateSeparator . 'd'; return $this->parseIsoTimestampWithTimeFormats($timestamp, $date); } @@ -124,6 +126,7 @@ private function parseIsoWeekDateFormat(string $timestamp, string $dateSeparator // Parse complete date including time $dateFormat = 'Y-m-d'; + return $this->parseIsoTimestampWithTimeFormats($updatedTimestamp, $dateFormat); } @@ -144,21 +147,22 @@ private function parseIsoWeekDateFormat(string $timestamp, string $dateSeparator private function parseIsoTimestampWithTimeFormats(string $timestamp, string $dateFormat): string { // Try parsing timestamp without milliseconds $dt = DateTimeImmutable::createFromFormat($dateFormat . '\\TH:i:sP', $timestamp); - if($dt) { + if ($dt) { return $dt->format(self::OUTPUT_FORMAT); } // Try parsing timestamp with dot-separated milliseconds $dt = DateTimeImmutable::createFromFormat($dateFormat . '\\TH:i:s.vP', $timestamp); - if($dt) { + if ($dt) { return $dt->format(self::OUTPUT_FORMAT); } // Try parsing timestamp with comma-separated milliseconds $dt = DateTimeImmutable::createFromFormat($dateFormat . '\\TH:i:s,vP', $timestamp); - if($dt) { + if ($dt) { return $dt->format(self::OUTPUT_FORMAT); } + throw new InvalidTimestampException($this->l->t('Could not parse timestamp {timestamp}', ['timestamp' => $timestamp])); } diff --git a/lib/Helper/UserConfigHelper.php b/lib/Helper/UserConfigHelper.php index 860bff502..f78cc5f62 100644 --- a/lib/Helper/UserConfigHelper.php +++ b/lib/Helper/UserConfigHelper.php @@ -29,7 +29,7 @@ class UserConfigHelper { public function __construct( ?string $UserId, IConfig $config, - IL10N $l + IL10N $l, ) { $this->userId = $UserId; $this->config = $config; @@ -138,6 +138,7 @@ public function getPrintImage(): bool { if ($rawValue === '') { return true; } + return $rawValue === '1'; } @@ -205,6 +206,7 @@ public function getFolderName(): string { if ($rawValue === '') { $path = '/' . $this->l->t('Recipes'); $this->setFolderName($path); + return $path; } diff --git a/lib/Helper/UserFolderHelper.php b/lib/Helper/UserFolderHelper.php index 9eb88db47..62ba45b88 100644 --- a/lib/Helper/UserFolderHelper.php +++ b/lib/Helper/UserFolderHelper.php @@ -50,7 +50,7 @@ public function __construct( ?string $UserId, IRootFolder $root, IL10N $l, - UserConfigHelper $configHelper + UserConfigHelper $configHelper, ) { $this->userId = $UserId; $this->root = $root; diff --git a/lib/Migration/Version000000Date20210701093123.php b/lib/Migration/Version000000Date20210701093123.php index 65d473b99..7c88673eb 100644 --- a/lib/Migration/Version000000Date20210701093123.php +++ b/lib/Migration/Version000000Date20210701093123.php @@ -97,6 +97,7 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt if ($namesTable->hasPrimaryKey()) { $namesTable->dropPrimaryKey(); } + if (! $namesTable->hasIndex('names_recipe_idx')) { $namesTable->addUniqueIndex([ 'recipe_id', diff --git a/lib/Search/Provider.php b/lib/Search/Provider.php index 525f7e706..16850d892 100644 --- a/lib/Search/Provider.php +++ b/lib/Search/Provider.php @@ -25,7 +25,7 @@ class Provider implements IProvider { public function __construct( IL10n $il10n, IURLGenerator $urlGenerator, - RecipeService $recipeService + RecipeService $recipeService, ) { $this->l = $il10n; $this->urlGenerator = $urlGenerator; @@ -46,6 +46,7 @@ public function getOrder(string $route, array $routeParameters): int { } elseif (strpos($route, Application::APP_ID . '.') === 0) { return -1; } + return 4; } diff --git a/lib/Service/DbCacheService.php b/lib/Service/DbCacheService.php index 8ea99f873..f58aa3925 100644 --- a/lib/Service/DbCacheService.php +++ b/lib/Service/DbCacheService.php @@ -55,7 +55,7 @@ public function __construct( RecipeService $recipeService, UserConfigHelper $userConfigHelper, NormalizeRecipeFileFilter $normalizeRecipeFileFilter, - IL10N $l + IL10N $l, ) { $this->userId = $UserId; $this->db = $db; @@ -125,6 +125,7 @@ private function parseJSONFiles() { } catch (InvalidJSONFileException $e) { continue; } + $id = $json['id']; $ret[$id] = $json; @@ -233,6 +234,7 @@ private function isDbEntryUpToDate(int $id) { if ($dbEntry['name'] !== $fileEntry['name']) { return false; } + if ($dbEntry['dateCreated'] !== $fileEntry['dateCreated']) { return false; } @@ -321,6 +323,7 @@ private function getJSONCategory(array $json): ?string { if (strlen(trim($category)) === 0) { return null; } + return $category; } @@ -335,6 +338,7 @@ private function updateKeywords() { } else { $keywords = explode(',', $textKeywords); } + $keywords = array_map(function ($v) { return trim($v); }, $keywords); diff --git a/lib/Service/HtmlDownloadService.php b/lib/Service/HtmlDownloadService.php index b17042993..443dcacd4 100644 --- a/lib/Service/HtmlDownloadService.php +++ b/lib/Service/HtmlDownloadService.php @@ -57,7 +57,7 @@ public function __construct( HtmlToDomParser $htmlParser, DownloadHelper $downloadHelper, EncodingGuessingHelper $encodingGuesser, - DownloadEncodingHelper $downloadEncodingHelper + DownloadEncodingHelper $downloadEncodingHelper, ) { $this->htmlFilters = [ $htmlEntityDecodeFilter, @@ -92,6 +92,7 @@ public function downloadRecipe(string $url): int { $dom = new DOMDocument(); $this->dom = $this->htmlParser->loadHtmlString($dom, $url, $html); + return $this->htmlParser->getState(); } diff --git a/lib/Service/ImageService.php b/lib/Service/ImageService.php index 6661d8784..ba769c20a 100644 --- a/lib/Service/ImageService.php +++ b/lib/Service/ImageService.php @@ -30,7 +30,7 @@ class ImageService { public function __construct( ImageFileHelper $fileHelper, - ThumbnailFileHelper $thumbnailHelper + ThumbnailFileHelper $thumbnailHelper, ) { $this->fileHelper = $fileHelper; $this->thumbnailHelper = $thumbnailHelper; @@ -134,6 +134,7 @@ public function setImageData(Folder $recipeFolder, string $data): void { } else { $this->fileHelper->createImage($recipeFolder)->putContent($data); } + $this->thumbnailHelper->recreateThumbnails($recipeFolder); } } diff --git a/lib/Service/JsonService.php b/lib/Service/JsonService.php index da948fa2c..9e33efb80 100644 --- a/lib/Service/JsonService.php +++ b/lib/Service/JsonService.php @@ -50,6 +50,7 @@ public function isSchemaObject($obj, ?string $type = null, bool $checkContext = if (count($obj['@type']) === 1 && $obj['@type'][0] === $type) { return true; } + return false; } diff --git a/lib/Service/RecipeService.php b/lib/Service/RecipeService.php index 9a64cf5be..ce0ae2ea7 100755 --- a/lib/Service/RecipeService.php +++ b/lib/Service/RecipeService.php @@ -77,7 +77,7 @@ public function __construct( LoggerInterface $logger, HtmlDownloadService $downloadService, RecipeExtractionService $extractionService, - JSONFilter $jsonFilter + JSONFilter $jsonFilter, ) { $this->user_id = $UserId; $this->root = $root; @@ -439,6 +439,7 @@ private function addDatesToRecipes(array &$recipes) { public function getAllRecipesInSearchIndex(): array { $recipes = $this->db->findAllRecipes($this->user_id); $this->addDatesToRecipes($recipes); + return $recipes; } @@ -452,6 +453,7 @@ public function getAllRecipesInSearchIndex(): array { public function getRecipesByCategory($category): array { $recipes = $this->db->getRecipesByCategory($category, $this->user_id); $this->addDatesToRecipes($recipes); + return $recipes; } @@ -466,6 +468,7 @@ public function getRecipesByCategory($category): array { public function getRecipesByKeywords($keywords): array { $recipes = $this->db->getRecipesByKeywords($keywords, $this->user_id); $this->addDatesToRecipes($recipes); + return $recipes; } @@ -490,6 +493,7 @@ public function findRecipesInSearchIndex(string $keywords_string): array { $recipes = $this->db->findRecipes($keywords_array, $this->user_id); $this->addDatesToRecipes($recipes); + return $recipes; } @@ -555,6 +559,7 @@ public function parseRecipeFile($file): ?array { if (!array_key_exists('dateCreated', $json) && method_exists($file, 'getCreationTime')) { $json['dateCreated'] = $file->getCreationTime(); } + if (!array_key_exists('dateModified', $json)) { $json['dateModified'] = $file->getMTime(); } @@ -575,6 +580,7 @@ public function getRecipeImageFileByFolderId($id, $size = 'thumb'): File { if (count($recipe_folders) < 1) { throw new Exception($this->il10n->t('Recipe with ID %d not found.', [$id])); } + $recipe_folder = $recipe_folders[0]; // TODO: Check that file is really an image diff --git a/tests/Integration/Helper/DownloadHelper/DownloadHelperTest.php b/tests/Integration/Helper/DownloadHelper/DownloadHelperTest.php index 1ff84d280..2cb2b9563 100644 --- a/tests/Integration/Helper/DownloadHelper/DownloadHelperTest.php +++ b/tests/Integration/Helper/DownloadHelper/DownloadHelperTest.php @@ -89,6 +89,7 @@ public function testDownload404() { if (file_exists('/www/test.txt')) { unlink('/www/test.txt'); } + $this->dut->downloadFile('http://www/test.txt'); $this->assertEquals(404, $this->dut->getStatus()); } diff --git a/tests/Unit/Controller/Implementation/RecipeImplementationTest.php b/tests/Unit/Controller/Implementation/RecipeImplementationTest.php index b97129d5c..d2ebcc1f8 100644 --- a/tests/Unit/Controller/Implementation/RecipeImplementationTest.php +++ b/tests/Unit/Controller/Implementation/RecipeImplementationTest.php @@ -210,6 +210,7 @@ private function getExpectedRecipes($recipes): array { // return $ret[$idx[$p['id']]]; $id = $p['id']; $size = $p['size']; + return "/path/to/image/$id/$size"; }); @@ -687,6 +688,7 @@ public function testIndex($recipes, $setKeywords, $keywords): void { $id = $params['id']; $size = $params['size']; + return "/path/to/controller/$id/$size"; })); diff --git a/tests/Unit/Helper/Filter/DB/RecipeDatesFilterTest.php b/tests/Unit/Helper/Filter/DB/RecipeDatesFilterTest.php index 516efd15b..8a7b26774 100644 --- a/tests/Unit/Helper/Filter/DB/RecipeDatesFilterTest.php +++ b/tests/Unit/Helper/Filter/DB/RecipeDatesFilterTest.php @@ -127,6 +127,7 @@ public function testFilterFromFile($creation, $creationPresent, $modificationPre if ($creationPresent) { $recipe['dateCreated'] = null; } + if ($modificationPresent) { $recipe['dateModified'] = null; } diff --git a/tests/Unit/Helper/Filter/JSON/FixDurationsFilterTest.php b/tests/Unit/Helper/Filter/JSON/FixDurationsFilterTest.php index fca3f6f60..204782060 100644 --- a/tests/Unit/Helper/Filter/JSON/FixDurationsFilterTest.php +++ b/tests/Unit/Helper/Filter/JSON/FixDurationsFilterTest.php @@ -51,9 +51,11 @@ public function testNonExisting($preExists, $cookExists, $totalExists) { if ($preExists) { $this->stub['prepTime'] = '0:10'; } + if ($cookExists) { $this->stub['cookTime'] = '0:20'; } + if ($totalExists) { $this->stub['totalTime'] = '0:30'; } @@ -84,7 +86,7 @@ public function dpSuccess() { public function testSuccess( $originalPrep, $originalCook, $originalTotal, $expectedPrep, $expectedCook, $expectedTotal, - $expectedChange + $expectedChange, ) { $this->iso8601DurationHelper->method('parseDuration')->willReturnMap([ ['0:10', 'PT0H10M'], @@ -121,7 +123,7 @@ public function dpExceptions() { /** @dataProvider dpExceptions */ public function testExceptions( $prepTime, $cookTime, $totalTime, - $expectedPrep, $expectedCook, $expectedTotal + $expectedPrep, $expectedCook, $expectedTotal, ) { $this->iso8601DurationHelper->method('parseDuration')->willReturnCallback(function ($x) { if ($x === 'invalid') { diff --git a/tests/Unit/Helper/Filter/JSON/FixTimestampsFilterTest.php b/tests/Unit/Helper/Filter/JSON/FixTimestampsFilterTest.php index 02e7b6a15..5549b3ecc 100644 --- a/tests/Unit/Helper/Filter/JSON/FixTimestampsFilterTest.php +++ b/tests/Unit/Helper/Filter/JSON/FixTimestampsFilterTest.php @@ -51,9 +51,11 @@ public function testNonExisting($preExists, $cookExists, $totalExists) { if ($preExists) { $this->stub['dateCreated'] = '2000-01-01T01:01:00+00:00'; } + if ($cookExists) { $this->stub['dateModified'] = '2001-01-01T01:01:00+01:00'; } + if ($totalExists) { $this->stub['datePublished'] = '2002-01-01T01:01:00,123-01:30'; } @@ -88,7 +90,7 @@ public function dpSuccess() { public function testSuccess( $originalCreated, $originalModified, $originalPublished, $expectedCreated, $expectedModified, $expectedPublished, - $expectedChange + $expectedChange, ) { $this->timestampHelper->method('parseTimestamp')->willReturnMap([ ['2000-01-01T01:01:00+00:00', '2000-01-01T01:01:00+00:00'], @@ -124,7 +126,7 @@ public function dpExceptions() { /** @dataProvider dpExceptions */ public function testExceptions( $dateCreated, $dateModified, $datePublished, - $expectedCreated, $expectedModified, $expectedPublished + $expectedCreated, $expectedModified, $expectedPublished, ) { $this->timestampHelper->method('parseTimestamp')->willReturnCallback(function ($x) { if ($x === 'invalid') { diff --git a/tests/Unit/Helper/Filter/JSON/SchemaConformityFilterTest.php b/tests/Unit/Helper/Filter/JSON/SchemaConformityFilterTest.php index 1933e85c0..1b9aa9e33 100644 --- a/tests/Unit/Helper/Filter/JSON/SchemaConformityFilterTest.php +++ b/tests/Unit/Helper/Filter/JSON/SchemaConformityFilterTest.php @@ -44,6 +44,7 @@ public function testFilter($hasContext, $context, $hasType, $type, $isChanged) { if ($hasContext) { $recipe['@context'] = $context; } + if ($hasType) { $recipe['@type'] = $type; } diff --git a/tests/Unit/Helper/Filter/JSONFilterTest.php b/tests/Unit/Helper/Filter/JSONFilterTest.php index bbb106db3..507890323 100644 --- a/tests/Unit/Helper/Filter/JSONFilterTest.php +++ b/tests/Unit/Helper/Filter/JSONFilterTest.php @@ -88,9 +88,11 @@ public function testSequence() { $callback = function ($x) use ($idx, &$counter) { $this->assertEquals($idx, $counter); $counter += 1; + return false; }; $idx += 1; + return $callback; }; diff --git a/tests/Unit/Helper/Filter/RecipeJSONOutputFilterTest.php b/tests/Unit/Helper/Filter/RecipeJSONOutputFilterTest.php index 9fe19ad4f..184cb3ac1 100644 --- a/tests/Unit/Helper/Filter/RecipeJSONOutputFilterTest.php +++ b/tests/Unit/Helper/Filter/RecipeJSONOutputFilterTest.php @@ -28,9 +28,11 @@ public function testSequence() { $callback = function ($x) use ($idx, &$counter) { $this->assertEquals($idx, $counter); $counter += 1; + return false; }; $idx += 1; + return $callback; }; diff --git a/tests/Unit/Helper/HTMLParser/HttpMicrodataParserTest.php b/tests/Unit/Helper/HTMLParser/HttpMicrodataParserTest.php index 2f22f3364..c2ad5ed88 100644 --- a/tests/Unit/Helper/HTMLParser/HttpMicrodataParserTest.php +++ b/tests/Unit/Helper/HTMLParser/HttpMicrodataParserTest.php @@ -1,6 +1,6 @@ line = $line; $ret->column = $column; $ret->message = $msg; + return $ret; } @@ -331,29 +332,31 @@ public function testSingleLogging($errorLevel, $logWarn, $logErr, $logCrit) { if ($logWarn) { $this->logger->expects($this->once())->method('info') ->with( - 'libxml: Warning %u occurred while parsing %s. '. + 'libxml: Warning %u occurred while parsing %s. ' . 'First time it occurred in line %u and column %u: The message', [] ); $this->logger->expects($this->never())->method('warning'); $this->logger->expects($this->never())->method('error'); } + if ($logErr) { $this->logger->expects($this->never())->method('info'); $this->logger->expects($this->once())->method('warning') ->with( - 'libxml: Error %u occurred while parsing %s. '. + 'libxml: Error %u occurred while parsing %s. ' . 'First time it occurred in line %u and column %u: The message', [] ); $this->logger->expects($this->never())->method('error'); } + if ($logCrit) { $this->logger->expects($this->never())->method('info'); $this->logger->expects($this->never())->method('warning'); $this->logger->expects($this->once())->method('error') ->with( - 'libxml: Fatal error %u occurred while parsing %s. '. + 'libxml: Fatal error %u occurred while parsing %s. ' . 'First time it occurred in line %u and column %u: The message', [] ); @@ -391,29 +394,31 @@ public function testMultipleLogging($errorLevel, $logWarn, $logErr, $logCrit) { if ($logWarn) { $this->logger->expects($this->once())->method('info') ->with( - 'libxml: Warning %u occurred %n times while parsing %s. '. + 'libxml: Warning %u occurred %n times while parsing %s. ' . 'First time it occurred in line %u and column %u: The message', [] ); $this->logger->expects($this->never())->method('warning'); $this->logger->expects($this->never())->method('error'); } + if ($logErr) { $this->logger->expects($this->never())->method('info'); $this->logger->expects($this->once())->method('warning') ->with( - 'libxml: Error %u occurred %n times while parsing %s. '. + 'libxml: Error %u occurred %n times while parsing %s. ' . 'First time it occurred in line %u and column %u: The message', [] ); $this->logger->expects($this->never())->method('error'); } + if ($logCrit) { $this->logger->expects($this->never())->method('info'); $this->logger->expects($this->never())->method('warning'); $this->logger->expects($this->once())->method('error') ->with( - 'libxml: Fatal error %u occurred %n times while parsing %s. '. + 'libxml: Fatal error %u occurred %n times while parsing %s. ' . 'First time it occurred in line %u and column %u: The message', [] ); diff --git a/tests/Unit/Helper/ImageService/ThumbnailFileHelperTest.php b/tests/Unit/Helper/ImageService/ThumbnailFileHelperTest.php index 399b0023f..57b15f9c8 100644 --- a/tests/Unit/Helper/ImageService/ThumbnailFileHelperTest.php +++ b/tests/Unit/Helper/ImageService/ThumbnailFileHelperTest.php @@ -211,9 +211,11 @@ public function testRecreateThumbnails($thumbExists, $miniExists) { if (! $thumbExists) { $cnt++; } + if (! $miniExists) { $cnt++; } + $newFileMap = [ ['thumb.jpg', null, $thumb], ['thumb16.jpg', null, $mini],