From b8759d13be99982914369d12254a6cfeaf6e223b Mon Sep 17 00:00:00 2001 From: Application-drop-up Date: Mon, 9 Mar 2026 19:59:26 +0900 Subject: [PATCH 1/6] feat: install rector --- .../workflows/{phpstan_test.yml => mago.yml} | 0 src/composer.json | 4 +- src/composer.lock | 667 ++++++++++++------ 3 files changed, 439 insertions(+), 232 deletions(-) rename .github/workflows/{phpstan_test.yml => mago.yml} (100%) diff --git a/.github/workflows/phpstan_test.yml b/.github/workflows/mago.yml similarity index 100% rename from .github/workflows/phpstan_test.yml rename to .github/workflows/mago.yml diff --git a/src/composer.json b/src/composer.json index cd355d5..6f82447 100644 --- a/src/composer.json +++ b/src/composer.json @@ -18,13 +18,15 @@ }, "require-dev": { "carthage-software/mago": "^1.2", + "driftingly/rector-laravel": "^2.1", "fakerphp/faker": "^1.23", "laravel/pail": "^1.1", "laravel/pint": "^1.13", "laravel/sail": "^1.26", "mockery/mockery": "^1.6", "nunomaduro/collision": "^8.1", - "phpunit/phpunit": "^11.0.1" + "phpunit/phpunit": "^11.0.1", + "rector/rector": "^2.3" }, "autoload": { "psr-4": { diff --git a/src/composer.lock b/src/composer.lock index 55154f8..1aabe4a 100644 --- a/src/composer.lock +++ b/src/composer.lock @@ -4,20 +4,20 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "6947ddd0f3d0348173e4ff27849b6613", + "content-hash": "68110e920a7d7e2ac88297daac555d38", "packages": [ { "name": "algolia/algoliasearch-client-php", - "version": "4.38.0", + "version": "4.39.0", "source": { "type": "git", "url": "https://github.com/algolia/algoliasearch-client-php.git", - "reference": "f267ae5682f0732e77843c6554e5e8083b6f7406" + "reference": "551987d31ad8ef7d0d93c17f374eaf60054a6f24" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/algolia/algoliasearch-client-php/zipball/f267ae5682f0732e77843c6554e5e8083b6f7406", - "reference": "f267ae5682f0732e77843c6554e5e8083b6f7406", + "url": "https://api.github.com/repos/algolia/algoliasearch-client-php/zipball/551987d31ad8ef7d0d93c17f374eaf60054a6f24", + "reference": "551987d31ad8ef7d0d93c17f374eaf60054a6f24", "shasum": "" }, "require": { @@ -69,22 +69,22 @@ ], "support": { "issues": "https://github.com/algolia/algoliasearch-client-php/issues", - "source": "https://github.com/algolia/algoliasearch-client-php/tree/4.38.0" + "source": "https://github.com/algolia/algoliasearch-client-php/tree/4.39.0" }, - "time": "2026-02-05T16:28:40+00:00" + "time": "2026-02-18T21:44:42+00:00" }, { "name": "brick/math", - "version": "0.14.7", + "version": "0.14.8", "source": { "type": "git", "url": "https://github.com/brick/math.git", - "reference": "07ff363b16ef8aca9692bba3be9e73fe63f34e50" + "reference": "63422359a44b7f06cae63c3b429b59e8efcc0629" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/brick/math/zipball/07ff363b16ef8aca9692bba3be9e73fe63f34e50", - "reference": "07ff363b16ef8aca9692bba3be9e73fe63f34e50", + "url": "https://api.github.com/repos/brick/math/zipball/63422359a44b7f06cae63c3b429b59e8efcc0629", + "reference": "63422359a44b7f06cae63c3b429b59e8efcc0629", "shasum": "" }, "require": { @@ -123,7 +123,7 @@ ], "support": { "issues": "https://github.com/brick/math/issues", - "source": "https://github.com/brick/math/tree/0.14.7" + "source": "https://github.com/brick/math/tree/0.14.8" }, "funding": [ { @@ -131,7 +131,7 @@ "type": "github" } ], - "time": "2026-02-07T10:57:35+00:00" + "time": "2026-02-10T14:33:43+00:00" }, { "name": "carbonphp/carbon-doctrine-types", @@ -577,16 +577,16 @@ }, { "name": "firebase/php-jwt", - "version": "v7.0.2", + "version": "v7.0.3", "source": { "type": "git", "url": "https://github.com/firebase/php-jwt.git", - "reference": "5645b43af647b6947daac1d0f659dd1fbe8d3b65" + "reference": "28aa0694bcfdfa5e2959c394d5a1ee7a5083629e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/firebase/php-jwt/zipball/5645b43af647b6947daac1d0f659dd1fbe8d3b65", - "reference": "5645b43af647b6947daac1d0f659dd1fbe8d3b65", + "url": "https://api.github.com/repos/firebase/php-jwt/zipball/28aa0694bcfdfa5e2959c394d5a1ee7a5083629e", + "reference": "28aa0694bcfdfa5e2959c394d5a1ee7a5083629e", "shasum": "" }, "require": { @@ -634,9 +634,9 @@ ], "support": { "issues": "https://github.com/firebase/php-jwt/issues", - "source": "https://github.com/firebase/php-jwt/tree/v7.0.2" + "source": "https://github.com/firebase/php-jwt/tree/v7.0.3" }, - "time": "2025-12-16T22:17:28+00:00" + "time": "2026-02-25T22:16:40+00:00" }, { "name": "fruitcake/php-cors", @@ -1878,16 +1878,16 @@ }, { "name": "laravel/prompts", - "version": "v0.3.12", + "version": "v0.3.13", "source": { "type": "git", "url": "https://github.com/laravel/prompts.git", - "reference": "4861ded9003b7f8a158176a0b7666f74ee761be8" + "reference": "ed8c466571b37e977532fb2fd3c272c784d7050d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/prompts/zipball/4861ded9003b7f8a158176a0b7666f74ee761be8", - "reference": "4861ded9003b7f8a158176a0b7666f74ee761be8", + "url": "https://api.github.com/repos/laravel/prompts/zipball/ed8c466571b37e977532fb2fd3c272c784d7050d", + "reference": "ed8c466571b37e977532fb2fd3c272c784d7050d", "shasum": "" }, "require": { @@ -1931,22 +1931,22 @@ "description": "Add beautiful and user-friendly forms to your command-line applications.", "support": { "issues": "https://github.com/laravel/prompts/issues", - "source": "https://github.com/laravel/prompts/tree/v0.3.12" + "source": "https://github.com/laravel/prompts/tree/v0.3.13" }, - "time": "2026-02-03T06:57:26+00:00" + "time": "2026-02-06T12:17:10+00:00" }, { "name": "laravel/serializable-closure", - "version": "v2.0.9", + "version": "v2.0.10", "source": { "type": "git", "url": "https://github.com/laravel/serializable-closure.git", - "reference": "8f631589ab07b7b52fead814965f5a800459cb3e" + "reference": "870fc81d2f879903dfc5b60bf8a0f94a1609e669" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/serializable-closure/zipball/8f631589ab07b7b52fead814965f5a800459cb3e", - "reference": "8f631589ab07b7b52fead814965f5a800459cb3e", + "url": "https://api.github.com/repos/laravel/serializable-closure/zipball/870fc81d2f879903dfc5b60bf8a0f94a1609e669", + "reference": "870fc81d2f879903dfc5b60bf8a0f94a1609e669", "shasum": "" }, "require": { @@ -1994,20 +1994,20 @@ "issues": "https://github.com/laravel/serializable-closure/issues", "source": "https://github.com/laravel/serializable-closure" }, - "time": "2026-02-03T06:55:34+00:00" + "time": "2026-02-20T19:59:49+00:00" }, { "name": "laravel/tinker", - "version": "v2.11.0", + "version": "v2.11.1", "source": { "type": "git", "url": "https://github.com/laravel/tinker.git", - "reference": "3d34b97c9a1747a81a3fde90482c092bd8b66468" + "reference": "c9f80cc835649b5c1842898fb043f8cc098dd741" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/tinker/zipball/3d34b97c9a1747a81a3fde90482c092bd8b66468", - "reference": "3d34b97c9a1747a81a3fde90482c092bd8b66468", + "url": "https://api.github.com/repos/laravel/tinker/zipball/c9f80cc835649b5c1842898fb043f8cc098dd741", + "reference": "c9f80cc835649b5c1842898fb043f8cc098dd741", "shasum": "" }, "require": { @@ -2058,22 +2058,22 @@ ], "support": { "issues": "https://github.com/laravel/tinker/issues", - "source": "https://github.com/laravel/tinker/tree/v2.11.0" + "source": "https://github.com/laravel/tinker/tree/v2.11.1" }, - "time": "2025-12-19T19:16:45+00:00" + "time": "2026-02-06T14:12:35+00:00" }, { "name": "league/commonmark", - "version": "2.8.0", + "version": "2.8.1", "source": { "type": "git", "url": "https://github.com/thephpleague/commonmark.git", - "reference": "4efa10c1e56488e658d10adf7b7b7dcd19940bfb" + "reference": "84b1ca48347efdbe775426f108622a42735a6579" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/commonmark/zipball/4efa10c1e56488e658d10adf7b7b7dcd19940bfb", - "reference": "4efa10c1e56488e658d10adf7b7b7dcd19940bfb", + "url": "https://api.github.com/repos/thephpleague/commonmark/zipball/84b1ca48347efdbe775426f108622a42735a6579", + "reference": "84b1ca48347efdbe775426f108622a42735a6579", "shasum": "" }, "require": { @@ -2098,9 +2098,9 @@ "phpstan/phpstan": "^1.8.2", "phpunit/phpunit": "^9.5.21 || ^10.5.9 || ^11.0.0", "scrutinizer/ocular": "^1.8.1", - "symfony/finder": "^5.3 | ^6.0 | ^7.0", - "symfony/process": "^5.4 | ^6.0 | ^7.0", - "symfony/yaml": "^2.3 | ^3.0 | ^4.0 | ^5.0 | ^6.0 | ^7.0", + "symfony/finder": "^5.3 | ^6.0 | ^7.0 || ^8.0", + "symfony/process": "^5.4 | ^6.0 | ^7.0 || ^8.0", + "symfony/yaml": "^2.3 | ^3.0 | ^4.0 | ^5.0 | ^6.0 | ^7.0 || ^8.0", "unleashedtech/php-coding-standard": "^3.1.1", "vimeo/psalm": "^4.24.0 || ^5.0.0 || ^6.0.0" }, @@ -2167,7 +2167,7 @@ "type": "tidelift" } ], - "time": "2025-11-26T21:48:24+00:00" + "time": "2026-03-05T21:37:03+00:00" }, { "name": "league/config", @@ -2253,16 +2253,16 @@ }, { "name": "league/flysystem", - "version": "3.31.0", + "version": "3.32.0", "source": { "type": "git", "url": "https://github.com/thephpleague/flysystem.git", - "reference": "1717e0b3642b0df65ecb0cc89cdd99fa840672ff" + "reference": "254b1595b16b22dbddaaef9ed6ca9fdac4956725" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/1717e0b3642b0df65ecb0cc89cdd99fa840672ff", - "reference": "1717e0b3642b0df65ecb0cc89cdd99fa840672ff", + "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/254b1595b16b22dbddaaef9ed6ca9fdac4956725", + "reference": "254b1595b16b22dbddaaef9ed6ca9fdac4956725", "shasum": "" }, "require": { @@ -2330,9 +2330,9 @@ ], "support": { "issues": "https://github.com/thephpleague/flysystem/issues", - "source": "https://github.com/thephpleague/flysystem/tree/3.31.0" + "source": "https://github.com/thephpleague/flysystem/tree/3.32.0" }, - "time": "2026-01-23T15:38:47+00:00" + "time": "2026-02-25T17:01:41+00:00" }, { "name": "league/flysystem-google-cloud-storage", @@ -2879,16 +2879,16 @@ }, { "name": "nette/schema", - "version": "v1.3.4", + "version": "v1.3.5", "source": { "type": "git", "url": "https://github.com/nette/schema.git", - "reference": "086497a2f34b82fede9b5a41cc8e131d087cd8f7" + "reference": "f0ab1a3cda782dbc5da270d28545236aa80c4002" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/schema/zipball/086497a2f34b82fede9b5a41cc8e131d087cd8f7", - "reference": "086497a2f34b82fede9b5a41cc8e131d087cd8f7", + "url": "https://api.github.com/repos/nette/schema/zipball/f0ab1a3cda782dbc5da270d28545236aa80c4002", + "reference": "f0ab1a3cda782dbc5da270d28545236aa80c4002", "shasum": "" }, "require": { @@ -2896,8 +2896,10 @@ "php": "8.1 - 8.5" }, "require-dev": { + "nette/phpstan-rules": "^1.0", "nette/tester": "^2.6", - "phpstan/phpstan": "^2.0@stable", + "phpstan/extension-installer": "^1.4@stable", + "phpstan/phpstan": "^2.1.39@stable", "tracy/tracy": "^2.8" }, "type": "library", @@ -2938,22 +2940,22 @@ ], "support": { "issues": "https://github.com/nette/schema/issues", - "source": "https://github.com/nette/schema/tree/v1.3.4" + "source": "https://github.com/nette/schema/tree/v1.3.5" }, - "time": "2026-02-08T02:54:00+00:00" + "time": "2026-02-23T03:47:12+00:00" }, { "name": "nette/utils", - "version": "v4.1.2", + "version": "v4.1.3", "source": { "type": "git", "url": "https://github.com/nette/utils.git", - "reference": "f76b5dc3d6c6d3043c8d937df2698515b99cbaf5" + "reference": "bb3ea637e3d131d72acc033cfc2746ee893349fe" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/utils/zipball/f76b5dc3d6c6d3043c8d937df2698515b99cbaf5", - "reference": "f76b5dc3d6c6d3043c8d937df2698515b99cbaf5", + "url": "https://api.github.com/repos/nette/utils/zipball/bb3ea637e3d131d72acc033cfc2746ee893349fe", + "reference": "bb3ea637e3d131d72acc033cfc2746ee893349fe", "shasum": "" }, "require": { @@ -2965,8 +2967,10 @@ }, "require-dev": { "jetbrains/phpstorm-attributes": "^1.2", + "nette/phpstan-rules": "^1.0", "nette/tester": "^2.5", - "phpstan/phpstan": "^2.0@stable", + "phpstan/extension-installer": "^1.4@stable", + "phpstan/phpstan": "^2.1@stable", "tracy/tracy": "^2.9" }, "suggest": { @@ -3027,9 +3031,9 @@ ], "support": { "issues": "https://github.com/nette/utils/issues", - "source": "https://github.com/nette/utils/tree/v4.1.2" + "source": "https://github.com/nette/utils/tree/v4.1.3" }, - "time": "2026-02-03T17:21:09+00:00" + "time": "2026-02-13T03:05:33+00:00" }, { "name": "nikic/php-parser", @@ -3091,31 +3095,31 @@ }, { "name": "nunomaduro/termwind", - "version": "v2.3.3", + "version": "v2.4.0", "source": { "type": "git", "url": "https://github.com/nunomaduro/termwind.git", - "reference": "6fb2a640ff502caace8e05fd7be3b503a7e1c017" + "reference": "712a31b768f5daea284c2169a7d227031001b9a8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nunomaduro/termwind/zipball/6fb2a640ff502caace8e05fd7be3b503a7e1c017", - "reference": "6fb2a640ff502caace8e05fd7be3b503a7e1c017", + "url": "https://api.github.com/repos/nunomaduro/termwind/zipball/712a31b768f5daea284c2169a7d227031001b9a8", + "reference": "712a31b768f5daea284c2169a7d227031001b9a8", "shasum": "" }, "require": { "ext-mbstring": "*", "php": "^8.2", - "symfony/console": "^7.3.6" + "symfony/console": "^7.4.4 || ^8.0.4" }, "require-dev": { - "illuminate/console": "^11.46.1", - "laravel/pint": "^1.25.1", + "illuminate/console": "^11.47.0", + "laravel/pint": "^1.27.1", "mockery/mockery": "^1.6.12", - "pestphp/pest": "^2.36.0 || ^3.8.4 || ^4.1.3", + "pestphp/pest": "^2.36.0 || ^3.8.4 || ^4.3.2", "phpstan/phpstan": "^1.12.32", "phpstan/phpstan-strict-rules": "^1.6.2", - "symfony/var-dumper": "^7.3.5", + "symfony/var-dumper": "^7.3.5 || ^8.0.4", "thecodingmachine/phpstan-strict-rules": "^1.0.0" }, "type": "library", @@ -3147,7 +3151,7 @@ "email": "enunomaduro@gmail.com" } ], - "description": "Its like Tailwind CSS, but for the console.", + "description": "It's like Tailwind CSS, but for the console.", "keywords": [ "cli", "console", @@ -3158,7 +3162,7 @@ ], "support": { "issues": "https://github.com/nunomaduro/termwind/issues", - "source": "https://github.com/nunomaduro/termwind/tree/v2.3.3" + "source": "https://github.com/nunomaduro/termwind/tree/v2.4.0" }, "funding": [ { @@ -3174,7 +3178,7 @@ "type": "github" } ], - "time": "2025-11-20T02:34:59+00:00" + "time": "2026-02-16T23:10:27+00:00" }, { "name": "phpoption/phpoption", @@ -3714,16 +3718,16 @@ }, { "name": "psy/psysh", - "version": "v0.12.19", + "version": "v0.12.21", "source": { "type": "git", "url": "https://github.com/bobthecow/psysh.git", - "reference": "a4f766e5c5b6773d8399711019bb7d90875a50ee" + "reference": "4821fab5b7cd8c49a673a9fd5754dc9162bb9e97" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/bobthecow/psysh/zipball/a4f766e5c5b6773d8399711019bb7d90875a50ee", - "reference": "a4f766e5c5b6773d8399711019bb7d90875a50ee", + "url": "https://api.github.com/repos/bobthecow/psysh/zipball/4821fab5b7cd8c49a673a9fd5754dc9162bb9e97", + "reference": "4821fab5b7cd8c49a673a9fd5754dc9162bb9e97", "shasum": "" }, "require": { @@ -3787,9 +3791,9 @@ ], "support": { "issues": "https://github.com/bobthecow/psysh/issues", - "source": "https://github.com/bobthecow/psysh/tree/v0.12.19" + "source": "https://github.com/bobthecow/psysh/tree/v0.12.21" }, - "time": "2026-01-30T17:33:13+00:00" + "time": "2026-03-06T21:21:28+00:00" }, { "name": "ralouphie/getallheaders", @@ -4133,16 +4137,16 @@ }, { "name": "symfony/console", - "version": "v7.4.4", + "version": "v7.4.7", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "41e38717ac1dd7a46b6bda7d6a82af2d98a78894" + "reference": "e1e6770440fb9c9b0cf725f81d1361ad1835329d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/41e38717ac1dd7a46b6bda7d6a82af2d98a78894", - "reference": "41e38717ac1dd7a46b6bda7d6a82af2d98a78894", + "url": "https://api.github.com/repos/symfony/console/zipball/e1e6770440fb9c9b0cf725f81d1361ad1835329d", + "reference": "e1e6770440fb9c9b0cf725f81d1361ad1835329d", "shasum": "" }, "require": { @@ -4207,7 +4211,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v7.4.4" + "source": "https://github.com/symfony/console/tree/v7.4.7" }, "funding": [ { @@ -4227,20 +4231,20 @@ "type": "tidelift" } ], - "time": "2026-01-13T11:36:38+00:00" + "time": "2026-03-06T14:06:20+00:00" }, { "name": "symfony/css-selector", - "version": "v7.4.0", + "version": "v7.4.6", "source": { "type": "git", "url": "https://github.com/symfony/css-selector.git", - "reference": "ab862f478513e7ca2fe9ec117a6f01a8da6e1135" + "reference": "2e7c52c647b406e2107dd867db424a4dbac91864" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/css-selector/zipball/ab862f478513e7ca2fe9ec117a6f01a8da6e1135", - "reference": "ab862f478513e7ca2fe9ec117a6f01a8da6e1135", + "url": "https://api.github.com/repos/symfony/css-selector/zipball/2e7c52c647b406e2107dd867db424a4dbac91864", + "reference": "2e7c52c647b406e2107dd867db424a4dbac91864", "shasum": "" }, "require": { @@ -4276,7 +4280,7 @@ "description": "Converts CSS selectors to XPath expressions", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/css-selector/tree/v7.4.0" + "source": "https://github.com/symfony/css-selector/tree/v7.4.6" }, "funding": [ { @@ -4296,7 +4300,7 @@ "type": "tidelift" } ], - "time": "2025-10-30T13:39:42+00:00" + "time": "2026-02-17T07:53:42+00:00" }, { "name": "symfony/deprecation-contracts", @@ -4610,16 +4614,16 @@ }, { "name": "symfony/finder", - "version": "v7.4.5", + "version": "v7.4.6", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "ad4daa7c38668dcb031e63bc99ea9bd42196a2cb" + "reference": "8655bf1076b7a3a346cb11413ffdabff50c7ffcf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/ad4daa7c38668dcb031e63bc99ea9bd42196a2cb", - "reference": "ad4daa7c38668dcb031e63bc99ea9bd42196a2cb", + "url": "https://api.github.com/repos/symfony/finder/zipball/8655bf1076b7a3a346cb11413ffdabff50c7ffcf", + "reference": "8655bf1076b7a3a346cb11413ffdabff50c7ffcf", "shasum": "" }, "require": { @@ -4654,7 +4658,7 @@ "description": "Finds files and directories via an intuitive fluent interface", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/finder/tree/v7.4.5" + "source": "https://github.com/symfony/finder/tree/v7.4.6" }, "funding": [ { @@ -4674,20 +4678,20 @@ "type": "tidelift" } ], - "time": "2026-01-26T15:07:59+00:00" + "time": "2026-01-29T09:40:50+00:00" }, { "name": "symfony/http-foundation", - "version": "v7.4.5", + "version": "v7.4.7", "source": { "type": "git", "url": "https://github.com/symfony/http-foundation.git", - "reference": "446d0db2b1f21575f1284b74533e425096abdfb6" + "reference": "f94b3e7b7dafd40e666f0c9ff2084133bae41e81" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/446d0db2b1f21575f1284b74533e425096abdfb6", - "reference": "446d0db2b1f21575f1284b74533e425096abdfb6", + "url": "https://api.github.com/repos/symfony/http-foundation/zipball/f94b3e7b7dafd40e666f0c9ff2084133bae41e81", + "reference": "f94b3e7b7dafd40e666f0c9ff2084133bae41e81", "shasum": "" }, "require": { @@ -4736,7 +4740,7 @@ "description": "Defines an object-oriented layer for the HTTP specification", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/http-foundation/tree/v7.4.5" + "source": "https://github.com/symfony/http-foundation/tree/v7.4.7" }, "funding": [ { @@ -4756,20 +4760,20 @@ "type": "tidelift" } ], - "time": "2026-01-27T16:16:02+00:00" + "time": "2026-03-06T13:15:18+00:00" }, { "name": "symfony/http-kernel", - "version": "v7.4.5", + "version": "v7.4.7", "source": { "type": "git", "url": "https://github.com/symfony/http-kernel.git", - "reference": "229eda477017f92bd2ce7615d06222ec0c19e82a" + "reference": "3b3fcf386c809be990c922e10e4c620d6367cab1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-kernel/zipball/229eda477017f92bd2ce7615d06222ec0c19e82a", - "reference": "229eda477017f92bd2ce7615d06222ec0c19e82a", + "url": "https://api.github.com/repos/symfony/http-kernel/zipball/3b3fcf386c809be990c922e10e4c620d6367cab1", + "reference": "3b3fcf386c809be990c922e10e4c620d6367cab1", "shasum": "" }, "require": { @@ -4811,7 +4815,7 @@ "symfony/config": "^6.4|^7.0|^8.0", "symfony/console": "^6.4|^7.0|^8.0", "symfony/css-selector": "^6.4|^7.0|^8.0", - "symfony/dependency-injection": "^6.4|^7.0|^8.0", + "symfony/dependency-injection": "^6.4.1|^7.0.1|^8.0", "symfony/dom-crawler": "^6.4|^7.0|^8.0", "symfony/expression-language": "^6.4|^7.0|^8.0", "symfony/finder": "^6.4|^7.0|^8.0", @@ -4855,7 +4859,7 @@ "description": "Provides a structured process for converting a Request into a Response", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/http-kernel/tree/v7.4.5" + "source": "https://github.com/symfony/http-kernel/tree/v7.4.7" }, "funding": [ { @@ -4875,20 +4879,20 @@ "type": "tidelift" } ], - "time": "2026-01-28T10:33:42+00:00" + "time": "2026-03-06T16:33:18+00:00" }, { "name": "symfony/intl", - "version": "v7.4.4", + "version": "v7.4.6", "source": { "type": "git", "url": "https://github.com/symfony/intl.git", - "reference": "7fa2d46174166bcd7829abc8717949f8a0b21fb7" + "reference": "6d6a398b18f73b3110140dbb030dcee2ae4ea81f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/intl/zipball/7fa2d46174166bcd7829abc8717949f8a0b21fb7", - "reference": "7fa2d46174166bcd7829abc8717949f8a0b21fb7", + "url": "https://api.github.com/repos/symfony/intl/zipball/6d6a398b18f73b3110140dbb030dcee2ae4ea81f", + "reference": "6d6a398b18f73b3110140dbb030dcee2ae4ea81f", "shasum": "" }, "require": { @@ -4945,7 +4949,7 @@ "localization" ], "support": { - "source": "https://github.com/symfony/intl/tree/v7.4.4" + "source": "https://github.com/symfony/intl/tree/v7.4.6" }, "funding": [ { @@ -4965,20 +4969,20 @@ "type": "tidelift" } ], - "time": "2026-01-12T12:19:02+00:00" + "time": "2026-02-09T09:33:46+00:00" }, { "name": "symfony/mailer", - "version": "v7.4.4", + "version": "v7.4.6", "source": { "type": "git", "url": "https://github.com/symfony/mailer.git", - "reference": "7b750074c40c694ceb34cb926d6dffee231c5cd6" + "reference": "b02726f39a20bc65e30364f5c750c4ddbf1f58e9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/mailer/zipball/7b750074c40c694ceb34cb926d6dffee231c5cd6", - "reference": "7b750074c40c694ceb34cb926d6dffee231c5cd6", + "url": "https://api.github.com/repos/symfony/mailer/zipball/b02726f39a20bc65e30364f5c750c4ddbf1f58e9", + "reference": "b02726f39a20bc65e30364f5c750c4ddbf1f58e9", "shasum": "" }, "require": { @@ -5029,7 +5033,7 @@ "description": "Helps sending emails", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/mailer/tree/v7.4.4" + "source": "https://github.com/symfony/mailer/tree/v7.4.6" }, "funding": [ { @@ -5049,20 +5053,20 @@ "type": "tidelift" } ], - "time": "2026-01-08T08:25:11+00:00" + "time": "2026-02-25T16:50:00+00:00" }, { "name": "symfony/mime", - "version": "v7.4.5", + "version": "v7.4.7", "source": { "type": "git", "url": "https://github.com/symfony/mime.git", - "reference": "b18c7e6e9eee1e19958138df10412f3c4c316148" + "reference": "da5ab4fde3f6c88ab06e96185b9922f48b677cd1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/mime/zipball/b18c7e6e9eee1e19958138df10412f3c4c316148", - "reference": "b18c7e6e9eee1e19958138df10412f3c4c316148", + "url": "https://api.github.com/repos/symfony/mime/zipball/da5ab4fde3f6c88ab06e96185b9922f48b677cd1", + "reference": "da5ab4fde3f6c88ab06e96185b9922f48b677cd1", "shasum": "" }, "require": { @@ -5073,7 +5077,7 @@ }, "conflict": { "egulias/email-validator": "~3.0.0", - "phpdocumentor/reflection-docblock": "<5.2|>=6", + "phpdocumentor/reflection-docblock": "<5.2|>=7", "phpdocumentor/type-resolver": "<1.5.1", "symfony/mailer": "<6.4", "symfony/serializer": "<6.4.3|>7.0,<7.0.3" @@ -5081,7 +5085,7 @@ "require-dev": { "egulias/email-validator": "^2.1.10|^3.1|^4", "league/html-to-markdown": "^5.0", - "phpdocumentor/reflection-docblock": "^5.2", + "phpdocumentor/reflection-docblock": "^5.2|^6.0", "symfony/dependency-injection": "^6.4|^7.0|^8.0", "symfony/process": "^6.4|^7.0|^8.0", "symfony/property-access": "^6.4|^7.0|^8.0", @@ -5118,7 +5122,7 @@ "mime-type" ], "support": { - "source": "https://github.com/symfony/mime/tree/v7.4.5" + "source": "https://github.com/symfony/mime/tree/v7.4.7" }, "funding": [ { @@ -5138,7 +5142,7 @@ "type": "tidelift" } ], - "time": "2026-01-27T08:59:58+00:00" + "time": "2026-03-05T15:24:09+00:00" }, { "name": "symfony/polyfill-ctype", @@ -5956,16 +5960,16 @@ }, { "name": "symfony/routing", - "version": "v7.4.4", + "version": "v7.4.6", "source": { "type": "git", "url": "https://github.com/symfony/routing.git", - "reference": "0798827fe2c79caeed41d70b680c2c3507d10147" + "reference": "238d749c56b804b31a9bf3e26519d93b65a60938" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/routing/zipball/0798827fe2c79caeed41d70b680c2c3507d10147", - "reference": "0798827fe2c79caeed41d70b680c2c3507d10147", + "url": "https://api.github.com/repos/symfony/routing/zipball/238d749c56b804b31a9bf3e26519d93b65a60938", + "reference": "238d749c56b804b31a9bf3e26519d93b65a60938", "shasum": "" }, "require": { @@ -6017,7 +6021,7 @@ "url" ], "support": { - "source": "https://github.com/symfony/routing/tree/v7.4.4" + "source": "https://github.com/symfony/routing/tree/v7.4.6" }, "funding": [ { @@ -6037,7 +6041,7 @@ "type": "tidelift" } ], - "time": "2026-01-12T12:19:02+00:00" + "time": "2026-02-25T16:50:00+00:00" }, { "name": "symfony/service-contracts", @@ -6128,16 +6132,16 @@ }, { "name": "symfony/string", - "version": "v7.4.4", + "version": "v7.4.6", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "1c4b10461bf2ec27537b5f36105337262f5f5d6f" + "reference": "9f209231affa85aa930a5e46e6eb03381424b30b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/1c4b10461bf2ec27537b5f36105337262f5f5d6f", - "reference": "1c4b10461bf2ec27537b5f36105337262f5f5d6f", + "url": "https://api.github.com/repos/symfony/string/zipball/9f209231affa85aa930a5e46e6eb03381424b30b", + "reference": "9f209231affa85aa930a5e46e6eb03381424b30b", "shasum": "" }, "require": { @@ -6195,7 +6199,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v7.4.4" + "source": "https://github.com/symfony/string/tree/v7.4.6" }, "funding": [ { @@ -6215,20 +6219,20 @@ "type": "tidelift" } ], - "time": "2026-01-12T10:54:30+00:00" + "time": "2026-02-09T09:33:46+00:00" }, { "name": "symfony/translation", - "version": "v7.4.4", + "version": "v7.4.6", "source": { "type": "git", "url": "https://github.com/symfony/translation.git", - "reference": "bfde13711f53f549e73b06d27b35a55207528877" + "reference": "1888cf064399868af3784b9e043240f1d89d25ce" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation/zipball/bfde13711f53f549e73b06d27b35a55207528877", - "reference": "bfde13711f53f549e73b06d27b35a55207528877", + "url": "https://api.github.com/repos/symfony/translation/zipball/1888cf064399868af3784b9e043240f1d89d25ce", + "reference": "1888cf064399868af3784b9e043240f1d89d25ce", "shasum": "" }, "require": { @@ -6295,7 +6299,7 @@ "description": "Provides tools to internationalize your application", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/translation/tree/v7.4.4" + "source": "https://github.com/symfony/translation/tree/v7.4.6" }, "funding": [ { @@ -6315,7 +6319,7 @@ "type": "tidelift" } ], - "time": "2026-01-13T10:40:19+00:00" + "time": "2026-02-17T07:53:42+00:00" }, { "name": "symfony/translation-contracts", @@ -6479,16 +6483,16 @@ }, { "name": "symfony/var-dumper", - "version": "v7.4.4", + "version": "v7.4.6", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", - "reference": "0e4769b46a0c3c62390d124635ce59f66874b282" + "reference": "045321c440ac18347b136c63d2e9bf28a2dc0291" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/0e4769b46a0c3c62390d124635ce59f66874b282", - "reference": "0e4769b46a0c3c62390d124635ce59f66874b282", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/045321c440ac18347b136c63d2e9bf28a2dc0291", + "reference": "045321c440ac18347b136c63d2e9bf28a2dc0291", "shasum": "" }, "require": { @@ -6542,7 +6546,7 @@ "dump" ], "support": { - "source": "https://github.com/symfony/var-dumper/tree/v7.4.4" + "source": "https://github.com/symfony/var-dumper/tree/v7.4.6" }, "funding": [ { @@ -6562,7 +6566,7 @@ "type": "tidelift" } ], - "time": "2026-01-01T22:13:48+00:00" + "time": "2026-02-15T10:53:20+00:00" }, { "name": "tijsverkoyen/css-to-inline-styles", @@ -6781,36 +6785,33 @@ "packages-dev": [ { "name": "carthage-software/mago", - "version": "1.6.0", + "version": "1.13.3", "source": { "type": "git", "url": "https://github.com/carthage-software/mago.git", - "reference": "089c4257ef6e854d5ec04d9cf3000cc92caea443" + "reference": "565646d4b0af5301b923dd0f2735a5a8868f1e90" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/carthage-software/mago/zipball/089c4257ef6e854d5ec04d9cf3000cc92caea443", - "reference": "089c4257ef6e854d5ec04d9cf3000cc92caea443", + "url": "https://api.github.com/repos/carthage-software/mago/zipball/565646d4b0af5301b923dd0f2735a5a8868f1e90", + "reference": "565646d4b0af5301b923dd0f2735a5a8868f1e90", "shasum": "" }, "require": { - "composer-plugin-api": "^2.6", "php": "~8.1 || ~8.2 || ~8.3 || ~8.4 || ~8.5 || ~8.6" }, - "require-dev": { - "composer/composer": "^2.8" + "suggest": { + "ext-curl": "To show binary download progress" }, "bin": [ "composer/bin/mago" ], - "type": "composer-plugin", - "extra": { - "class": "Mago\\MagoPlugin" - }, + "type": "library", "autoload": { - "psr-4": { - "Mago\\": "composer/" - } + "files": [ + "composer/functions.php", + "composer/internal.php" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -6828,7 +6829,7 @@ ], "support": { "issues": "https://github.com/carthage-software/mago/issues", - "source": "https://github.com/carthage-software/mago/tree/1.6.0" + "source": "https://github.com/carthage-software/mago/tree/1.13.3" }, "funding": [ { @@ -6836,7 +6837,43 @@ "type": "github" } ], - "time": "2026-02-07T00:46:32+00:00" + "time": "2026-03-02T05:49:03+00:00" + }, + { + "name": "driftingly/rector-laravel", + "version": "2.1.12", + "source": { + "type": "git", + "url": "https://github.com/driftingly/rector-laravel.git", + "reference": "2a2175eefabca6d15c247d55de17c75dc2f787a9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/driftingly/rector-laravel/zipball/2a2175eefabca6d15c247d55de17c75dc2f787a9", + "reference": "2a2175eefabca6d15c247d55de17c75dc2f787a9", + "shasum": "" + }, + "require": { + "php": "^7.4 || ^8.0", + "rector/rector": "^2.2.7", + "webmozart/assert": "^1.11" + }, + "type": "rector-extension", + "autoload": { + "psr-4": { + "RectorLaravel\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Rector upgrades rules for Laravel Framework", + "support": { + "issues": "https://github.com/driftingly/rector-laravel/issues", + "source": "https://github.com/driftingly/rector-laravel/tree/2.1.12" + }, + "time": "2026-03-06T19:59:21+00:00" }, { "name": "fakerphp/faker", @@ -7025,16 +7062,16 @@ }, { "name": "laravel/pail", - "version": "v1.2.5", + "version": "v1.2.6", "source": { "type": "git", "url": "https://github.com/laravel/pail.git", - "reference": "fdb73f5eacf03db576c710d5a00101ba185f2254" + "reference": "aa71a01c309e7f66bc2ec4fb1a59291b82eb4abf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/pail/zipball/fdb73f5eacf03db576c710d5a00101ba185f2254", - "reference": "fdb73f5eacf03db576c710d5a00101ba185f2254", + "url": "https://api.github.com/repos/laravel/pail/zipball/aa71a01c309e7f66bc2ec4fb1a59291b82eb4abf", + "reference": "aa71a01c309e7f66bc2ec4fb1a59291b82eb4abf", "shasum": "" }, "require": { @@ -7101,20 +7138,20 @@ "issues": "https://github.com/laravel/pail/issues", "source": "https://github.com/laravel/pail" }, - "time": "2026-02-04T15:10:32+00:00" + "time": "2026-02-09T13:44:54+00:00" }, { "name": "laravel/pint", - "version": "v1.27.0", + "version": "v1.27.1", "source": { "type": "git", "url": "https://github.com/laravel/pint.git", - "reference": "c67b4195b75491e4dfc6b00b1c78b68d86f54c90" + "reference": "54cca2de13790570c7b6f0f94f37896bee4abcb5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/pint/zipball/c67b4195b75491e4dfc6b00b1c78b68d86f54c90", - "reference": "c67b4195b75491e4dfc6b00b1c78b68d86f54c90", + "url": "https://api.github.com/repos/laravel/pint/zipball/54cca2de13790570c7b6f0f94f37896bee4abcb5", + "reference": "54cca2de13790570c7b6f0f94f37896bee4abcb5", "shasum": "" }, "require": { @@ -7125,13 +7162,13 @@ "php": "^8.2.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^3.92.4", - "illuminate/view": "^12.44.0", - "larastan/larastan": "^3.8.1", - "laravel-zero/framework": "^12.0.4", + "friendsofphp/php-cs-fixer": "^3.93.1", + "illuminate/view": "^12.51.0", + "larastan/larastan": "^3.9.2", + "laravel-zero/framework": "^12.0.5", "mockery/mockery": "^1.6.12", "nunomaduro/termwind": "^2.3.3", - "pestphp/pest": "^3.8.4" + "pestphp/pest": "^3.8.5" }, "bin": [ "builds/pint" @@ -7168,32 +7205,32 @@ "issues": "https://github.com/laravel/pint/issues", "source": "https://github.com/laravel/pint" }, - "time": "2026-01-05T16:49:17+00:00" + "time": "2026-02-10T20:00:20+00:00" }, { "name": "laravel/sail", - "version": "v1.52.0", + "version": "v1.53.0", "source": { "type": "git", "url": "https://github.com/laravel/sail.git", - "reference": "64ac7d8abb2dbcf2b76e61289451bae79066b0b3" + "reference": "e340eaa2bea9b99192570c48ed837155dbf24fbb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/sail/zipball/64ac7d8abb2dbcf2b76e61289451bae79066b0b3", - "reference": "64ac7d8abb2dbcf2b76e61289451bae79066b0b3", + "url": "https://api.github.com/repos/laravel/sail/zipball/e340eaa2bea9b99192570c48ed837155dbf24fbb", + "reference": "e340eaa2bea9b99192570c48ed837155dbf24fbb", "shasum": "" }, "require": { - "illuminate/console": "^9.52.16|^10.0|^11.0|^12.0", - "illuminate/contracts": "^9.52.16|^10.0|^11.0|^12.0", - "illuminate/support": "^9.52.16|^10.0|^11.0|^12.0", + "illuminate/console": "^9.52.16|^10.0|^11.0|^12.0|^13.0", + "illuminate/contracts": "^9.52.16|^10.0|^11.0|^12.0|^13.0", + "illuminate/support": "^9.52.16|^10.0|^11.0|^12.0|^13.0", "php": "^8.0", - "symfony/console": "^6.0|^7.0", - "symfony/yaml": "^6.0|^7.0" + "symfony/console": "^6.0|^7.0|^8.0", + "symfony/yaml": "^6.0|^7.0|^8.0" }, "require-dev": { - "orchestra/testbench": "^7.0|^8.0|^9.0|^10.0", + "orchestra/testbench": "^7.0|^8.0|^9.0|^10.0|^11.0", "phpstan/phpstan": "^2.0" }, "bin": [ @@ -7231,7 +7268,7 @@ "issues": "https://github.com/laravel/sail/issues", "source": "https://github.com/laravel/sail" }, - "time": "2026-01-01T02:46:03+00:00" + "time": "2026-02-06T12:16:02+00:00" }, { "name": "mockery/mockery", @@ -7378,39 +7415,36 @@ }, { "name": "nunomaduro/collision", - "version": "v8.8.3", + "version": "v8.9.1", "source": { "type": "git", "url": "https://github.com/nunomaduro/collision.git", - "reference": "1dc9e88d105699d0fee8bb18890f41b274f6b4c4" + "reference": "a1ed3fa530fd60bc515f9303e8520fcb7d4bd935" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nunomaduro/collision/zipball/1dc9e88d105699d0fee8bb18890f41b274f6b4c4", - "reference": "1dc9e88d105699d0fee8bb18890f41b274f6b4c4", + "url": "https://api.github.com/repos/nunomaduro/collision/zipball/a1ed3fa530fd60bc515f9303e8520fcb7d4bd935", + "reference": "a1ed3fa530fd60bc515f9303e8520fcb7d4bd935", "shasum": "" }, "require": { - "filp/whoops": "^2.18.1", - "nunomaduro/termwind": "^2.3.1", + "filp/whoops": "^2.18.4", + "nunomaduro/termwind": "^2.4.0", "php": "^8.2.0", - "symfony/console": "^7.3.0" + "symfony/console": "^7.4.4 || ^8.0.4" }, "conflict": { - "laravel/framework": "<11.44.2 || >=13.0.0", - "phpunit/phpunit": "<11.5.15 || >=13.0.0" + "laravel/framework": "<11.48.0 || >=14.0.0", + "phpunit/phpunit": "<11.5.50 || >=14.0.0" }, "require-dev": { - "brianium/paratest": "^7.8.3", - "larastan/larastan": "^3.4.2", - "laravel/framework": "^11.44.2 || ^12.18", - "laravel/pint": "^1.22.1", - "laravel/sail": "^1.43.1", - "laravel/sanctum": "^4.1.1", - "laravel/tinker": "^2.10.1", - "orchestra/testbench-core": "^9.12.0 || ^10.4", - "pestphp/pest": "^3.8.2 || ^4.0.0", - "sebastian/environment": "^7.2.1 || ^8.0" + "brianium/paratest": "^7.8.5", + "larastan/larastan": "^3.9.2", + "laravel/framework": "^11.48.0 || ^12.52.0", + "laravel/pint": "^1.27.1", + "orchestra/testbench-core": "^9.12.0 || ^10.9.0", + "pestphp/pest": "^3.8.5 || ^4.4.1 || ^5.0.0", + "sebastian/environment": "^7.2.1 || ^8.0.3 || ^9.0.0" }, "type": "library", "extra": { @@ -7473,7 +7507,7 @@ "type": "patreon" } ], - "time": "2025-11-20T02:55:25+00:00" + "time": "2026-02-17T17:33:08+00:00" }, { "name": "phar-io/manifest", @@ -7593,6 +7627,59 @@ }, "time": "2022-02-21T01:04:05+00:00" }, + { + "name": "phpstan/phpstan", + "version": "2.1.40", + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/9b2c7aeb83a75d8680ea5e7c9b7fca88052b766b", + "reference": "9b2c7aeb83a75d8680ea5e7c9b7fca88052b766b", + "shasum": "" + }, + "require": { + "php": "^7.4|^8.0" + }, + "conflict": { + "phpstan/phpstan-shim": "*" + }, + "bin": [ + "phpstan", + "phpstan.phar" + ], + "type": "library", + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan - PHP Static Analysis Tool", + "keywords": [ + "dev", + "static analysis" + ], + "support": { + "docs": "https://phpstan.org/user-guide/getting-started", + "forum": "https://github.com/phpstan/phpstan/discussions", + "issues": "https://github.com/phpstan/phpstan/issues", + "security": "https://github.com/phpstan/phpstan/security/policy", + "source": "https://github.com/phpstan/phpstan-src" + }, + "funding": [ + { + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://github.com/phpstan", + "type": "github" + } + ], + "time": "2026-02-23T15:04:35+00:00" + }, { "name": "phpunit/php-code-coverage", "version": "11.0.12", @@ -7942,16 +8029,16 @@ }, { "name": "phpunit/phpunit", - "version": "11.5.52", + "version": "11.5.55", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "b287d32c26f78768e391843c5a59395f24b62605" + "reference": "adc7262fccc12de2b30f12a8aa0b33775d814f00" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/b287d32c26f78768e391843c5a59395f24b62605", - "reference": "b287d32c26f78768e391843c5a59395f24b62605", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/adc7262fccc12de2b30f12a8aa0b33775d814f00", + "reference": "adc7262fccc12de2b30f12a8aa0b33775d814f00", "shasum": "" }, "require": { @@ -8024,7 +8111,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/11.5.52" + "source": "https://github.com/sebastianbergmann/phpunit/tree/11.5.55" }, "funding": [ { @@ -8048,7 +8135,67 @@ "type": "tidelift" } ], - "time": "2026-02-08T07:05:14+00:00" + "time": "2026-02-18T12:37:06+00:00" + }, + { + "name": "rector/rector", + "version": "2.3.8", + "source": { + "type": "git", + "url": "https://github.com/rectorphp/rector.git", + "reference": "bbd37aedd8df749916cffa2a947cfc4714d1ba2c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/rectorphp/rector/zipball/bbd37aedd8df749916cffa2a947cfc4714d1ba2c", + "reference": "bbd37aedd8df749916cffa2a947cfc4714d1ba2c", + "shasum": "" + }, + "require": { + "php": "^7.4|^8.0", + "phpstan/phpstan": "^2.1.38" + }, + "conflict": { + "rector/rector-doctrine": "*", + "rector/rector-downgrade-php": "*", + "rector/rector-phpunit": "*", + "rector/rector-symfony": "*" + }, + "suggest": { + "ext-dom": "To manipulate phpunit.xml via the custom-rule command" + }, + "bin": [ + "bin/rector" + ], + "type": "library", + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Instant Upgrade and Automated Refactoring of any PHP code", + "homepage": "https://getrector.com/", + "keywords": [ + "automation", + "dev", + "migration", + "refactoring" + ], + "support": { + "issues": "https://github.com/rectorphp/rector/issues", + "source": "https://github.com/rectorphp/rector/tree/2.3.8" + }, + "funding": [ + { + "url": "https://github.com/tomasvotruba", + "type": "github" + } + ], + "time": "2026-02-22T09:45:50+00:00" }, { "name": "sebastian/cli-parser", @@ -9090,16 +9237,16 @@ }, { "name": "symfony/yaml", - "version": "v7.4.1", + "version": "v7.4.6", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "24dd4de28d2e3988b311751ac49e684d783e2345" + "reference": "58751048de17bae71c5aa0d13cb19d79bca26391" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/24dd4de28d2e3988b311751ac49e684d783e2345", - "reference": "24dd4de28d2e3988b311751ac49e684d783e2345", + "url": "https://api.github.com/repos/symfony/yaml/zipball/58751048de17bae71c5aa0d13cb19d79bca26391", + "reference": "58751048de17bae71c5aa0d13cb19d79bca26391", "shasum": "" }, "require": { @@ -9142,7 +9289,7 @@ "description": "Loads and dumps YAML files", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/yaml/tree/v7.4.1" + "source": "https://github.com/symfony/yaml/tree/v7.4.6" }, "funding": [ { @@ -9162,7 +9309,7 @@ "type": "tidelift" } ], - "time": "2025-12-04T18:11:45+00:00" + "time": "2026-02-09T09:33:46+00:00" }, { "name": "theseer/tokenizer", @@ -9213,6 +9360,64 @@ } ], "time": "2025-11-17T20:03:58+00:00" + }, + { + "name": "webmozart/assert", + "version": "1.12.1", + "source": { + "type": "git", + "url": "https://github.com/webmozarts/assert.git", + "reference": "9be6926d8b485f55b9229203f962b51ed377ba68" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/webmozarts/assert/zipball/9be6926d8b485f55b9229203f962b51ed377ba68", + "reference": "9be6926d8b485f55b9229203f962b51ed377ba68", + "shasum": "" + }, + "require": { + "ext-ctype": "*", + "ext-date": "*", + "ext-filter": "*", + "php": "^7.2 || ^8.0" + }, + "suggest": { + "ext-intl": "", + "ext-simplexml": "", + "ext-spl": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.10-dev" + } + }, + "autoload": { + "psr-4": { + "Webmozart\\Assert\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } + ], + "description": "Assertions to validate method input/output with nice error messages.", + "keywords": [ + "assert", + "check", + "validate" + ], + "support": { + "issues": "https://github.com/webmozarts/assert/issues", + "source": "https://github.com/webmozarts/assert/tree/1.12.1" + }, + "time": "2025-10-29T15:56:20+00:00" } ], "aliases": [], From c39d7c9dc6ed866c404498df0f70aa213ff473c8 Mon Sep 17 00:00:00 2001 From: Application-drop-up Date: Mon, 9 Mar 2026 20:39:28 +0900 Subject: [PATCH 2/6] feat: ordering CI tests --- .github/workflows/mago.yml | 34 ++++++++++ .github/workflows/rector.yml | 43 ++++++++++++ .github/workflows/server_test.yml | 108 +++++------------------------- src/composer.json | 8 +++ 4 files changed, 101 insertions(+), 92 deletions(-) create mode 100644 .github/workflows/rector.yml diff --git a/.github/workflows/mago.yml b/.github/workflows/mago.yml index e69de29..94848b5 100644 --- a/.github/workflows/mago.yml +++ b/.github/workflows/mago.yml @@ -0,0 +1,34 @@ +name: Mago + +on: + workflow_run: + workflows: ["PHPUnit"] + types: + - completed + +jobs: + mago: + if: ${{ github.event.workflow_run.conclusion == 'success' }} + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: ${{ github.event.workflow_run.head_sha }} + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: "8.2" + coverage: none + tools: composer + + - name: Install dependencies + run: composer install --prefer-dist --no-progress --no-interaction + + - name: Setup Mago + uses: nhedger/setup-mago@v1 + + - name: Run Mago + run: mago analyze --reporting-format=github \ No newline at end of file diff --git a/.github/workflows/rector.yml b/.github/workflows/rector.yml new file mode 100644 index 0000000..8ce102a --- /dev/null +++ b/.github/workflows/rector.yml @@ -0,0 +1,43 @@ +name: Rector + +on: + pull_request: + paths: + - "app/**" + - "bootstrap/**" + - "config/**" + - "database/**" + - "routes/**" + - "tests/**" + - "composer.json" + - "composer.lock" + - "rector.php" + - ".github/workflows/rector.yml" + push: + branches: + - main + - 'feat/*' + - 'fix/*' + - 'hotfix/*' + - 'chore/*' + +jobs: + rector: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: "8.2" + coverage: none + tools: composer + + - name: Install dependencies + run: composer install --prefer-dist --no-progress --no-interaction + + - name: Run Rector dry-run + run: vendor/bin/rector process --dry-run \ No newline at end of file diff --git a/.github/workflows/server_test.yml b/.github/workflows/server_test.yml index ce2a2a1..1171840 100644 --- a/.github/workflows/server_test.yml +++ b/.github/workflows/server_test.yml @@ -1,107 +1,31 @@ -name: server tests +name: PHPUnit on: - pull_request: - types: [opened, synchronize] - paths: - - "src/**/*.php" - - "src/composer.lock" - push: - paths: - - "src/**/*.php" - - "src/composer.lock" - workflow_dispatch: {} + workflow_run: + workflows: ["Rector"] + types: + - completed jobs: - laravel: + phpunit: + if: ${{ github.event.workflow_run.conclusion == 'success' }} runs-on: ubuntu-latest - timeout-minutes: 11 - - strategy: - fail-fast: false - matrix: - php: ['7.4', '8.0', '8.1', '8.2'] - Laravel: ['8.*', '9.*', '10.*'] - - services: - mysql: - image: mysql:8.0 - env: - MYSQL_ROOT_PASSWORD: root - MYSQL_DATABASE: ${{ secrets.DB_DATABASE }} - MYSQL_USER: ${{ secrets.DB_USERNAME }} - MYSQL_PASSWORD: ${{ secrets.DB_PASSWORD }} - TZ: Asia/Tokyo - ports: - - 3306:3306 - options: >- - --health-cmd "mysqladmin ping" - --health-interval 10s - --health-timeout 5s - --health-retries 5 steps: - - name: Checkout code - uses: actions/checkout@v5 + - name: Checkout + uses: actions/checkout@v4 + with: + ref: ${{ github.event.workflow_run.head_sha }} - name: Setup PHP uses: shivammathur/setup-php@v2 with: php-version: "8.2" - tools: composer:v2 - - - name: Cache Composer dependencies - uses: actions/cache@v4 - with: - path: ~/.cache/composer - key: ${{ runner.os }}-composer-${{ hashFiles('src/composer.lock') }} + coverage: none + tools: composer - name: Install dependencies - run: | - composer install --prefer-dist --no-progress --no-suggest - composer dump-autoload -o - working-directory: ./src - - - name: Copy .env.ci to .env.testing - run: cp .env.ci .env.testing - working-directory: ./src - - - name: Ensure newline at end of .env.testing - run: printf '\n' >> .env.testing - working-directory: ./src - - - name: Set environment variables - run: | - { - echo "DB_CONNECTION=mysql" - echo "DB_HOST=127.0.0.1" - echo "DB_PORT=${{ secrets.DB_PORT }}" - echo "DB_DATABASE=${{ secrets.DB_DATABASE }}" - echo "DB_USERNAME=${{ secrets.DB_USERNAME }}" - echo "DB_PASSWORD=${{ secrets.DB_PASSWORD }}" - } >> .env.testing - working-directory: ./src - - - name: Generate application key - run: php artisan key:generate --env=testing - working-directory: ./src - env: - APP_ENV: testing - - - name: Cache config and routes - run: | - php artisan config:clear - php artisan config:cache - working-directory: ./src - env: - APP_ENV: testing - - - name: Run migrations - run: php artisan migrate --env=testing - working-directory: ./src - env: - APP_ENV: testing + run: composer install --prefer-dist --no-progress --no-interaction - - name: Run tests - run: ./vendor/bin/phpunit --stop-on-failure --testdox - working-directory: ./src \ No newline at end of file + - name: Run PHPUnit + run: php artisan test \ No newline at end of file diff --git a/src/composer.json b/src/composer.json index 6f82447..e0e2a47 100644 --- a/src/composer.json +++ b/src/composer.json @@ -41,6 +41,14 @@ } }, "scripts": { + "ci:rector": "vendor/bin/rector process --dry-run", + "ci:phpunit": "php artisan test", + "ci:mago": "mago analyze --reporting-format=github", + "ci:quality": [ + "@ci:rector", + "@ci:phpunit", + "@ci:mago" + ], "post-autoload-dump": [ "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", "@php artisan package:discover --ansi" From 80b88cbe5cec4f405294ec0460bf2d50d98d6bd3 Mon Sep 17 00:00:00 2001 From: Application-drop-up Date: Mon, 9 Mar 2026 20:41:40 +0900 Subject: [PATCH 3/6] fix: rector refactoring --- .../Common/Pagination/PaginationViewModel.php | 2 +- .../Console/Commands/BackfillStateParties.php | 6 +- .../Commands/BuildWorldHeritageLocalDb.php | 8 +- .../Commands/DumpUnescoWorldHeritageJson.php | 76 ++++-- .../Commands/ImportCountriesFromSplitFile.php | 6 +- .../ImportSiteStatePartiesFromSplitFile.php | 20 +- .../Commands/ImportWorldHeritageFromJson.php | 79 ++++-- ...tageSiteCountryExceptionsFromSplitFile.php | 24 +- .../ImportWorldHeritageSiteFromSplitFile.php | 58 +++-- .../ImportWorldHeritageSiteImagesFromJson.php | 44 +++- .../Commands/MakeManualSiteNamesJson.php | 44 +++- src/app/Console/Commands/SplitCountryJson.php | 104 ++++++-- .../Commands/SplitWorldHeritageImageJson.php | 44 ++-- .../Commands/SplitWorldHeritageJson.php | 30 +-- src/app/Console/Concerns/LoadsJsonRows.php | 20 +- src/app/Models/WorldHeritage.php | 22 +- .../AlgoliaWorldHeritageSearchAdapter.php | 21 +- .../Adapter/GcsObjectStorageAdapter.php | 4 +- .../Domains/Adapter/GcsSignedUrlAdapter.php | 2 +- .../Domains/Infra/GcsImageObjectRemover.php | 2 +- .../Test/ImageEntityCollectionTest.php | 14 +- .../Packages/Domains/Test/ImageEntityTest.php | 46 ++-- .../WorldHeritageQueryService_getByIdTest.php | 2 +- ...ritageQueryService_searchHeritagesTest.php | 1 + .../WorldHeritageEntityCollectionTest.php | 8 +- .../Domains/Test/WorldHeritageEntityTest.php | 226 +++++++++--------- .../Packages/Domains/WorldHeritageEntity.php | 13 +- .../Domains/WorldHeritageQueryService.php | 4 +- .../Domains/WorldHeritageReadQueryService.php | 4 +- .../QueryUseCases/Dto/ImageDtoCollection.php | 4 +- .../QueryUseCases/Dto/WorldHeritageDto.php | 16 +- .../Dto/WorldHeritageDetailFactory.php | 10 +- .../Dto/WorldHeritageSummaryFactory.php | 10 +- .../ListQuery/WorldHeritageListQuery.php | 6 +- .../Dto/WorldHeritageDtoCollectionTest.php | 10 +- .../Dto/WorldHeritageDtoDetailFactoryTest.php | 8 +- .../WorldHeritageDtoSummaryFactoryTest.php | 18 +- .../Tests/ImageDtoCollectionTest.php | 14 +- .../QueryUseCases/Tests/ImageDtoTest.php | 26 +- ...HeritageListQueryCollectionFactoryTest.php | 4 +- .../GetWorldHeritageByIdUseCaseTest.php | 44 ++-- ...orldHeritageDetailViewModelFactoryTest.php | 44 ++-- ...rldHeritageSummaryViewModelFactoryTest.php | 90 +++---- ...HeritageViewModelCollectionFactoryTest.php | 46 ++-- .../UseCase/Image/ImageUploadUseCase.php | 2 +- .../Tests/GetWorldHeritageByIdTest.php | 6 +- src/app/Providers/AppServiceProvider.php | 6 +- src/app/Support/CountryCodeNormalizer.php | 4 +- src/database/seeders/CountrySeeder.php | 4 +- 49 files changed, 778 insertions(+), 528 deletions(-) diff --git a/src/app/Common/Pagination/PaginationViewModel.php b/src/app/Common/Pagination/PaginationViewModel.php index 689fddb..dff1c26 100644 --- a/src/app/Common/Pagination/PaginationViewModel.php +++ b/src/app/Common/Pagination/PaginationViewModel.php @@ -14,7 +14,7 @@ public function __construct( public function toArray(): array { $items = []; - if ($this->viewModelCollection) { + if ($this->viewModelCollection instanceof \App\Packages\Features\QueryUseCases\ViewModel\WorldHeritageViewModelCollection) { $items = $this->viewModelCollection->toArray(); } else { $dtoCollection = $this->pagination->getCollection(); diff --git a/src/app/Console/Commands/BackfillStateParties.php b/src/app/Console/Commands/BackfillStateParties.php index b7324bf..1f15bcf 100644 --- a/src/app/Console/Commands/BackfillStateParties.php +++ b/src/app/Console/Commands/BackfillStateParties.php @@ -42,11 +42,13 @@ public function handle(): int ->filter(fn($c) => strlen($c) === 2) ->values(); - if ($codes->isEmpty()) continue; + if ($codes->isEmpty()) { + continue; + } $valid = Country::whereIn('state_party_code', $codes)->pluck('state_party_code')->all(); $missing = array_diff($codes->all(), $valid); - if ($missing) { + if ($missing !== []) { Log::warning("Unknown codes for site {$site->id}: ".implode(',', $missing)); } diff --git a/src/app/Console/Commands/BuildWorldHeritageLocalDb.php b/src/app/Console/Commands/BuildWorldHeritageLocalDb.php index 1d71f5a..a07e143 100644 --- a/src/app/Console/Commands/BuildWorldHeritageLocalDb.php +++ b/src/app/Console/Commands/BuildWorldHeritageLocalDb.php @@ -55,8 +55,12 @@ public function handle(): int '--site-judgements-out' => $siteJudgementsOut, '--exceptions-out' => $exceptionsOut, ]; - if ($pretty) $splitArgs['--pretty'] = true; - if ($clean) $splitArgs['--clean'] = true; + if ($pretty) { + $splitArgs['--pretty'] = true; + } + if ($clean) { + $splitArgs['--clean'] = true; + } $this->mustRun('world-heritage:split-json', $splitArgs); $this->info('Running: import-countries-split'); diff --git a/src/app/Console/Commands/DumpUnescoWorldHeritageJson.php b/src/app/Console/Commands/DumpUnescoWorldHeritageJson.php index 8fec8c5..8926ba6 100644 --- a/src/app/Console/Commands/DumpUnescoWorldHeritageJson.php +++ b/src/app/Console/Commands/DumpUnescoWorldHeritageJson.php @@ -127,7 +127,9 @@ private function dumpAll(string $baseUrl, int $limit, int $max, string $outPath, $this->info('Fetching All records (no country refine).'); $first = $this->fetch($baseUrl, null, 1, 0); - if ($first === null) return ['ok' => false, 'results' => [], 'results_raw' => []]; + if ($first === null) { + return ['ok' => false, 'results' => [], 'results_raw' => []]; + } $total = (int) ($first['total_count'] ?? 0); if ($total <= 0) { @@ -143,22 +145,32 @@ private function dumpAll(string $baseUrl, int $limit, int $max, string $outPath, $resultsRawAll = []; while (true) { - if ($max > 0 && $fetched >= $max) break; + if ($max > 0 && $fetched >= $max) { + break; + } $resp = $this->fetch($baseUrl, null, $limit, $offset); - if ($resp === null) return ['ok' => false, 'results' => [], 'results_raw' => []]; + if ($resp === null) { + return ['ok' => false, 'results' => [], 'results_raw' => []]; + } $results = $resp['results'] ?? null; - if (!is_array($results) || $results === []) break; + if (!is_array($results) || $results === []) { + break; + } foreach ($results as $row) { - if (!is_array($row)) continue; + if (!is_array($row)) { + continue; + } $resultsRawAll[] = $row; $resultsAll[] = $this->normalizeRow($row); $fetched++; - if ($max > 0 && $fetched >= $max) break 2; + if ($max > 0 && $fetched >= $max) { + break 2; + } } $offset += count($results); @@ -220,7 +232,9 @@ private function dumpOneCountry( } $first = $this->fetch($baseUrl, $country, 1, 0); - if ($first === null) return 1; + if ($first === null) { + return 1; + } $total = (int) ($first['total_count'] ?? 0); if ($total <= 0) { @@ -235,21 +249,31 @@ private function dumpOneCountry( $resultsAll = []; while (true) { - if ($max > 0 && $fetched >= $max) break; + if ($max > 0 && $fetched >= $max) { + break; + } $resp = $this->fetch($baseUrl, $country, $limit, $offset); - if ($resp === null) return 1; + if ($resp === null) { + return 1; + } $results = $resp['results'] ?? null; - if (!is_array($results) || $results === []) break; + if (!is_array($results) || $results === []) { + break; + } foreach ($results as $row) { - if (!is_array($row)) continue; + if (!is_array($row)) { + continue; + } $resultsAll[] = $this->normalizeRow($row); $fetched++; - if ($max > 0 && $fetched >= $max) break 2; + if ($max > 0 && $fetched >= $max) { + break 2; + } } $offset += count($results); @@ -300,11 +324,15 @@ private function generateCountriesFileFromResults(array $resultsAll, string $out foreach ($resultsAll as $row) { $states = $row['states_names'] ?? null; - if (!is_array($states)) continue; + if (!is_array($states)) { + continue; + } foreach ($states as $name) { $name = trim((string) $name); - if ($name === '') continue; + if ($name === '') { + continue; + } $set[$name] = true; } } @@ -470,9 +498,13 @@ private function buildCriteriaFromDumpRow(array $row): array { $raw = $row['criteria_txt'] ?? null; - if (!is_string($raw)) return []; + if (!is_string($raw)) { + return []; + } $raw = trim($raw); - if ($raw === '') return []; + if ($raw === '') { + return []; + } preg_match_all('/\(\s*([ivxlcdm]+)\s*\)/i', $raw, $m1); $vals = $m1[1] ?? []; @@ -482,15 +514,21 @@ private function buildCriteriaFromDumpRow(array $row): array $vals = $m2[1] ?? []; } - if (!is_array($vals) || $vals === []) return []; + if (!is_array($vals) || $vals === []) { + return []; + } $out = []; $seen = []; foreach ($vals as $v) { $v = strtolower(trim((string) $v)); - if ($v === '') continue; - if (!preg_match('/^[ivxlcdm]+$/', $v)) continue; + if ($v === '') { + continue; + } + if (!preg_match('/^[ivxlcdm]+$/', $v)) { + continue; + } if (!isset($seen[$v])) { $seen[$v] = true; diff --git a/src/app/Console/Commands/ImportCountriesFromSplitFile.php b/src/app/Console/Commands/ImportCountriesFromSplitFile.php index 9c0ae0b..96c907e 100644 --- a/src/app/Console/Commands/ImportCountriesFromSplitFile.php +++ b/src/app/Console/Commands/ImportCountriesFromSplitFile.php @@ -55,7 +55,9 @@ public function handle(): int $batch = []; foreach ($rows as $row) { - if ($max > 0 && $imported >= $max) break; + if ($max > 0 && $imported >= $max) { + break; + } if (!is_array($row)) { $skipped++; continue; } $code = strtoupper(trim((string) ($row['state_party_code'] ?? ''))); @@ -89,7 +91,7 @@ public function handle(): int } } - if ($batch) { + if ($batch !== []) { $imported += $this->flush($batch, $dryRun); } diff --git a/src/app/Console/Commands/ImportSiteStatePartiesFromSplitFile.php b/src/app/Console/Commands/ImportSiteStatePartiesFromSplitFile.php index 927bc00..2642df4 100644 --- a/src/app/Console/Commands/ImportSiteStatePartiesFromSplitFile.php +++ b/src/app/Console/Commands/ImportSiteStatePartiesFromSplitFile.php @@ -59,13 +59,15 @@ public function handle(): int $now = Carbon::now(); foreach ($rows as $row) { - if ($max > 0 && $imported >= $max) break; + if ($max > 0 && $imported >= $max) { + break; + } if (!is_array($row)) { $skipped++; continue; } $siteId = $row['world_heritage_site_id'] ?? null; $code = strtoupper(trim((string) ($row['state_party_code'] ?? ''))); - if (!(is_int($siteId) || (is_string($siteId) && is_numeric($siteId)))) { + if (!is_int($siteId) && !(is_string($siteId) && is_numeric($siteId))) { $skipped++; if ($strict) { $this->error("Strict: missing/invalid world_heritage_site_id: " . json_encode($row, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)); @@ -111,7 +113,7 @@ public function handle(): int } } - if ($batch) { + if ($batch !== []) { $imported += $this->flush($batch, $dryRun); } @@ -121,7 +123,9 @@ public function handle(): int private function flush(array $rows, bool $dryRun): int { - if ($dryRun) return count($rows); + if ($dryRun) { + return count($rows); + } DB::table('site_state_parties')->upsert( $rows, @@ -134,14 +138,18 @@ private function flush(array $rows, bool $dryRun): int private function toNullableInt(mixed $v): ?int { - if ($v === null || $v === '') return null; + if ($v === null || $v === '') { + return null; + } return is_numeric($v) ? (int) $v : null; } private function resolvePath(string $path): string { $path = trim($path); - if ($path === '') return $path; + if ($path === '') { + return $path; + } if (str_starts_with($path, '/') || preg_match('/^[A-Za-z]:\\\\/', $path) === 1) { return $path; diff --git a/src/app/Console/Commands/ImportWorldHeritageFromJson.php b/src/app/Console/Commands/ImportWorldHeritageFromJson.php index b69fb61..7d63746 100644 --- a/src/app/Console/Commands/ImportWorldHeritageFromJson.php +++ b/src/app/Console/Commands/ImportWorldHeritageFromJson.php @@ -40,7 +40,9 @@ public function handle(): int $now = Carbon::now(); foreach ($files as $filePath) { - if ($max > 0 && $imported >= $max) break; + if ($max > 0 && $imported >= $max) { + break; + } $results = $this->loadResultsFromJsonFile($filePath); if ($results === null) { @@ -49,7 +51,9 @@ public function handle(): int } foreach ($results as $row) { - if ($max > 0 && $imported >= $max) break; + if ($max > 0 && $imported >= $max) { + break; + } if (!is_array($row)) { $skipped++; continue; } $mapped = $this->mapFromUnescoApiRow($row); @@ -68,7 +72,7 @@ public function handle(): int } } - if ($batch) { + if ($batch !== []) { $imported += $this->flushBatch($batch); } @@ -136,7 +140,9 @@ private function mapFromUnescoApiRow(array $row): array } $stateParty = is_string($stateParty) ? strtoupper(trim($stateParty)) : null; - if ($stateParty === '') $stateParty = null; + if ($stateParty === '') { + $stateParty = null; + } if ($stateParty !== null && !preg_match('/^[A-Z]{3}$/', $stateParty)) { $stateParty = null; } @@ -156,7 +162,7 @@ private function mapFromUnescoApiRow(array $row): array 'latitude' => $this->toNullableFloat($lat), 'longitude' => $this->toNullableFloat($lon), 'short_description' => $row['short_description'] ?? $row['description'] ?? null, - 'image_url' => $row['image_url'] ?? $row['image'] ?? null, + 'image_url' => $row['image_url'] ?? null, 'thumbnail_image_id' => null, 'unesco_site_url' => $row['url'] ?? null, ]; @@ -164,18 +170,24 @@ private function mapFromUnescoApiRow(array $row): array private function criteriaFromTxt(mixed $raw): array { - if ($raw === null) return []; + if ($raw === null) { + return []; + } $s = trim((string) $raw); - if ($s === '') return []; + if ($s === '') { + return []; + } preg_match_all('/\(([^)]+)\)/', $s, $m); - if (!empty($m[1])) { + if (isset($m[1]) && $m[1] !== []) { return array_values(array_filter(array_map(fn($v) => trim((string) $v), $m[1]))); } $s = trim($s, " \t\n\r\0\x0B()"); - if ($s === '') return []; + if ($s === '') { + return []; + } return [$s]; } @@ -183,11 +195,6 @@ private function flushBatch(array $batch): int { $updateColumns = array_values(array_diff(array_keys($batch[0]), ['id'])); - dd([ - 'row_image_url' => $row['image_url'] ?? null, - 'mapped_image_url' => $this->toNullableString($row['image_url'] ?? null) - ]); - WorldHeritage::query()->upsert( $batch, ['id'], @@ -214,11 +221,17 @@ private function extractIso3StateParty(array $row): ?string } $states = $row['states'] ?? $row['state_party'] ?? null; - if (is_string($states)) $candidates[] = $states; - if (is_array($states)) $candidates[] = $states[0] ?? null; + if (is_string($states)) { + $candidates[] = $states; + } + if (is_array($states)) { + $candidates[] = $states[0] ?? null; + } foreach ($candidates as $c) { - if (!is_string($c)) continue; + if (!is_string($c)) { + continue; + } $c = strtoupper(trim($c)); if ($c !== '' && preg_match('/^[A-Z]{3}$/', $c)) { return $c; @@ -230,17 +243,23 @@ private function extractIso3StateParty(array $row): ?string private function toNullableInt(mixed $v): ?int { - if ($v === null || $v === '') return null; + if ($v === null || $v === '') { + return null; + } return is_numeric($v) ? (int) $v : null; } private function toNullableFloat(mixed $value): ?float { - if ($value === null || $value === '') return null; + if ($value === null || $value === '') { + return null; + } if (is_string($value)) { $value = str_replace(',', '', trim($value)); - if ($value === '') return null; + if ($value === '') { + return null; + } } return is_numeric($value) ? (float) $value : null; @@ -248,9 +267,13 @@ private function toNullableFloat(mixed $value): ?float private function toNullableBool(mixed $value): ?bool { - if ($value === null || $value === '') return null; + if ($value === null || $value === '') { + return null; + } - if (is_bool($value)) return $value; + if (is_bool($value)) { + return $value; + } if (is_int($value) || is_float($value)) { return ((int) $value) === 1; @@ -258,13 +281,19 @@ private function toNullableBool(mixed $value): ?bool if (is_string($value)) { $v = strtolower(trim($value)); - if ($v === '') return null; + if ($v === '') { + return null; + } $true = ['1', 'true', 't', 'yes', 'y', 'on']; $false = ['0', 'false', 'f', 'no', 'n', 'off']; - if (in_array($v, $true, true)) return true; - if (in_array($v, $false, true)) return false; + if (in_array($v, $true, true)) { + return true; + } + if (in_array($v, $false, true)) { + return false; + } } return null; diff --git a/src/app/Console/Commands/ImportWorldHeritageSiteCountryExceptionsFromSplitFile.php b/src/app/Console/Commands/ImportWorldHeritageSiteCountryExceptionsFromSplitFile.php index 2971bf7..df907ce 100644 --- a/src/app/Console/Commands/ImportWorldHeritageSiteCountryExceptionsFromSplitFile.php +++ b/src/app/Console/Commands/ImportWorldHeritageSiteCountryExceptionsFromSplitFile.php @@ -57,7 +57,9 @@ public function handle(): int $now = Carbon::now(); foreach ($rows as $row) { - if ($max > 0 && $imported >= $max) break; + if ($max > 0 && $imported >= $max) { + break; + } if (!is_array($row)) { $skipped++; continue; } $idNo = $row['id_no'] @@ -65,7 +67,7 @@ public function handle(): int ?? $row['site_id'] ?? null; - if (!(is_int($idNo) || (is_string($idNo) && is_numeric($idNo)))) { + if (!is_int($idNo) && !(is_string($idNo) && is_numeric($idNo))) { $skipped++; if ($strict) { $this->error('Strict: missing/invalid id_no: ' . json_encode($row, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)); @@ -107,7 +109,7 @@ public function handle(): int } } - if ($batch) { + if ($batch !== []) { $imported += $this->flush($batch, $dryRun); } @@ -117,7 +119,9 @@ public function handle(): int private function flush(array $rows, bool $dryRun): int { - if ($dryRun) return count($rows); + if ($dryRun) { + return count($rows); + } DB::table('world_heritage_site_country_exceptions')->upsert( $rows, @@ -131,10 +135,14 @@ private function flush(array $rows, bool $dryRun): int private function loadRows(string $path): ?array { $raw = @file_get_contents($path); - if ($raw === false) return null; + if ($raw === false) { + return null; + } $json = json_decode($raw, true); - if (!is_array($json)) return null; + if (!is_array($json)) { + return null; + } if (array_key_exists('results', $json)) { return is_array($json['results']) ? $json['results'] : null; @@ -146,7 +154,9 @@ private function loadRows(string $path): ?array private function resolvePath(string $path): string { $path = trim($path); - if ($path === '') return $path; + if ($path === '') { + return $path; + } if (str_starts_with($path, '/') || preg_match('/^[A-Za-z]:\\\\/', $path) === 1) { return $path; diff --git a/src/app/Console/Commands/ImportWorldHeritageSiteFromSplitFile.php b/src/app/Console/Commands/ImportWorldHeritageSiteFromSplitFile.php index 6e9b6f3..3974c45 100644 --- a/src/app/Console/Commands/ImportWorldHeritageSiteFromSplitFile.php +++ b/src/app/Console/Commands/ImportWorldHeritageSiteFromSplitFile.php @@ -57,7 +57,9 @@ public function handle(): int $now = Carbon::now(); foreach ($rows as $row) { - if ($max > 0 && $imported >= $max) break; + if ($max > 0 && $imported >= $max) { + break; + } if (!is_array($row)) { $skipped++; continue; } $id = $row['id'] ?? null; @@ -102,7 +104,7 @@ public function handle(): int } } - if ($batch) { + if ($batch !== []) { $imported += $this->flush($batch, $dryRun); } @@ -112,7 +114,9 @@ public function handle(): int private function flush(array $rows, bool $dryRun): int { - if ($dryRun) return count($rows); + if ($dryRun) { + return count($rows); + } $update = array_values(array_diff(array_keys($rows[0]), ['id', 'created_at'])); @@ -128,10 +132,14 @@ private function flush(array $rows, bool $dryRun): int private function loadRows(string $path): ?array { $raw = @file_get_contents($path); - if ($raw === false) return null; + if ($raw === false) { + return null; + } $json = json_decode($raw, true); - if (!is_array($json)) return null; + if (!is_array($json)) { + return null; + } if (array_key_exists('results', $json)) { return is_array($json['results']) ? $json['results'] : null; @@ -142,7 +150,9 @@ private function loadRows(string $path): ?array private function resolvePath(string $path): string { $path = trim($path); - if ($path === '') return $path; + if ($path === '') { + return $path; + } if (str_starts_with($path, '/') || preg_match('/^[A-Za-z]:\\\\/', $path) === 1) { return $path; @@ -161,33 +171,51 @@ private function resolvePath(string $path): string private function toNullableString(mixed $v): ?string { - if (!is_string($v)) return null; + if (!is_string($v)) { + return null; + } $s = trim($v); return $s === '' ? null : $s; } private function toNullableInt(mixed $v): ?int { - if ($v === null || $v === '') return null; + if ($v === null || $v === '') { + return null; + } return is_numeric($v) ? (int) $v : null; } private function toNullableFloat(mixed $v): ?float { - if ($v === null || $v === '') return null; - if (is_string($v)) $v = str_replace(',', '', trim($v)); + if ($v === null || $v === '') { + return null; + } + if (is_string($v)) { + $v = str_replace(',', '', trim($v)); + } return is_numeric($v) ? (float) $v : null; } private function toNullableBoolInt(mixed $v): ?int { - if ($v === null || $v === '') return null; - if (is_bool($v)) return $v ? 1 : 0; - if (is_int($v) || is_float($v)) return ((int) $v) === 1 ? 1 : 0; + if ($v === null || $v === '') { + return null; + } + if (is_bool($v)) { + return $v ? 1 : 0; + } + if (is_int($v) || is_float($v)) { + return ((int) $v) === 1 ? 1 : 0; + } if (is_string($v)) { $s = strtolower(trim($v)); - if (in_array($s, ['1', 'true', 't', 'yes', 'y', 'on'], true)) return 1; - if (in_array($s, ['0', 'false', 'f', 'no', 'n', 'off'], true)) return 0; + if (in_array($s, ['1', 'true', 't', 'yes', 'y', 'on'], true)) { + return 1; + } + if (in_array($s, ['0', 'false', 'f', 'no', 'n', 'off'], true)) { + return 0; + } } return null; } diff --git a/src/app/Console/Commands/ImportWorldHeritageSiteImagesFromJson.php b/src/app/Console/Commands/ImportWorldHeritageSiteImagesFromJson.php index 88e2571..a0daf2c 100644 --- a/src/app/Console/Commands/ImportWorldHeritageSiteImagesFromJson.php +++ b/src/app/Console/Commands/ImportWorldHeritageSiteImagesFromJson.php @@ -57,7 +57,9 @@ public function handle(): int $now = Carbon::now(); foreach ($files as $filePath) { - if ($max > 0 && $imported >= $max) break; + if ($max > 0 && $imported >= $max) { + break; + } $results = $this->loadResultsFromJsonFile($filePath); if ($results === null) { @@ -66,7 +68,9 @@ public function handle(): int } foreach ($results as $row) { - if ($max > 0 && $imported >= $max) break; + if ($max > 0 && $imported >= $max) { + break; + } if (!is_array($row)) { $skipped++; continue; } $mapped = $this->mapRow($row); @@ -84,7 +88,7 @@ public function handle(): int } } - if ($batch) { + if ($batch !== []) { $imported += $this->flushBatch($batch); } @@ -97,13 +101,19 @@ private function mapRow(array $row): ?array $siteId = $row['world_heritage_site_id'] ?? null; $url = $row['url'] ?? null; - if (!is_numeric($siteId)) return null; + if (!is_numeric($siteId)) { + return null; + } $siteId = (int) $siteId; - if (!is_string($url)) return null; + if (!is_string($url)) { + return null; + } $url = trim($url); - if ($url === '') return null; + if ($url === '') { + return null; + } $urlHash = hash('sha256', $url); @@ -112,7 +122,7 @@ private function mapRow(array $row): ?array 'url' => $url, 'url_hash' => $urlHash, 'sort_order' => isset($row['sort_order']) ? (int) $row['sort_order'] : 0, - 'is_primary' => !empty($row['is_primary']) ? 1 : 0, + 'is_primary' => empty($row['is_primary']) ? 0 : 1, ]; } @@ -133,10 +143,16 @@ private function flushBatch(array $batch): int private function resolvePath(string $path): string { $path = trim($path); - if ($path === '') return $path; + if ($path === '') { + return $path; + } - if (str_starts_with($path, '/')) return $path; - if (preg_match('/^[A-Za-z]:\\\\/', $path) === 1) return $path; + if (str_starts_with($path, '/')) { + return $path; + } + if (preg_match('/^[A-Za-z]:\\\\/', $path) === 1) { + return $path; + } $path = ltrim($path, '/'); @@ -175,10 +191,14 @@ private function collectJsonFiles(string $fullPath): array private function loadResultsFromJsonFile(string $filePath): ?array { $raw = @file_get_contents($filePath); - if ($raw === false) return null; + if ($raw === false) { + return null; + } $json = json_decode($raw, true); - if (!is_array($json)) return null; + if (!is_array($json)) { + return null; + } if (array_key_exists('results', $json)) { return is_array($json['results']) ? $json['results'] : null; diff --git a/src/app/Console/Commands/MakeManualSiteNamesJson.php b/src/app/Console/Commands/MakeManualSiteNamesJson.php index 56fc726..f209389 100644 --- a/src/app/Console/Commands/MakeManualSiteNamesJson.php +++ b/src/app/Console/Commands/MakeManualSiteNamesJson.php @@ -77,7 +77,9 @@ public function handle(): int $rows = $result['rows'] ?? []; $flags = JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES; - if ($pretty) $flags |= JSON_PRETTY_PRINT; + if ($pretty) { + $flags |= JSON_PRETTY_PRINT; + } $json = json_encode($rows, $flags); if ($json === false) { @@ -113,7 +115,9 @@ private function convert(string $text): array foreach ($lines as $i => $raw) { $lineNo = $i + 1; $line = trim((string) $raw); - if ($line === '') continue; + if ($line === '') { + continue; + } if (!$this->isSiteLine($line)) { if (!$this->isCountryLikeLine($line)) { @@ -167,12 +171,16 @@ private function convert(string $text): array private function isCountryLikeLine(string $line): bool { $line = trim($line); - if ($line === '') return false; - if (preg_match('/^(#|\/\/|;|※)/u', $line) === 1) return false; - if (preg_match('/^[-=]{3,}$/u', $line) === 1) return false; - if ($this->isSiteLine($line)) return false; - - return true; + if ($line === '') { + return false; + } + if (preg_match('/^(#|\/\/|;|※)/u', $line) === 1) { + return false; + } + if (preg_match('/^[-=]{3,}$/u', $line) === 1) { + return false; + } + return !$this->isSiteLine($line); } private function containsJapanese(string $s): bool @@ -200,7 +208,9 @@ private function splitNameAndYears(string $line): array private function isSiteLine(string $line): bool { $line = trim($line); - if ($line === '') return false; + if ($line === '') { + return false; + } return preg_match('/[\((]\s*\d{4}.*[\))]\s*$/u', $line) === 1; } @@ -208,9 +218,15 @@ private function isSiteLine(string $line): bool private function resolvePath(string $path): string { $path = trim($path); - if ($path === '') return $path; - if (str_starts_with($path, '/')) return $path; - if (preg_match('/^[A-Za-z]:\\\\/', $path) === 1) return $path; + if ($path === '') { + return $path; + } + if (str_starts_with($path, '/')) { + return $path; + } + if (preg_match('/^[A-Za-z]:\\\\/', $path) === 1) { + return $path; + } return base_path($path); } @@ -218,7 +234,9 @@ private function resolvePath(string $path): string private function toLocalDiskPath(string $path): string { $trimPath = trim($path); - if ($trimPath === '') return $trimPath; + if ($trimPath === '') { + return $trimPath; + } if (str_starts_with($trimPath, 'storage/app/')) { return substr($trimPath, strlen('storage/app/')); diff --git a/src/app/Console/Commands/SplitCountryJson.php b/src/app/Console/Commands/SplitCountryJson.php index ae34065..eccfb5b 100644 --- a/src/app/Console/Commands/SplitCountryJson.php +++ b/src/app/Console/Commands/SplitCountryJson.php @@ -229,7 +229,9 @@ public function handle(): int if ($names !== [] && count($names) === count($codes3)) { foreach ($codes3 as $idx => $code) { $en = trim((string)($names[$idx] ?? '')); - if ($en === '') $en = $code; + if ($en === '') { + $en = $code; + } $this->upsertCountryRow( countryMap: $countryMap, @@ -349,7 +351,9 @@ public function handle(): int private function upsertCountryRow(array &$countryMap, string $code, ?string $nameEn, array $existingJp, ?string $region): void { $code = strtoupper(trim($code)); - if ($code === '') return; + if ($code === '') { + return; + } if (!isset($countryMap[$code])) { $countryMap[$code] = [ @@ -382,10 +386,14 @@ private function upsertCountryRow(array &$countryMap, string $code, ?string $nam private function normalizeRegionCode(mixed $v): ?string { - if (!is_string($v)) return null; + if (!is_string($v)) { + return null; + } $code = strtoupper(trim($v)); - if ($code === '') return null; + if ($code === '') { + return null; + } $allowed = ['EUR', 'AFR', 'APA', 'ARB', 'LAC']; return in_array($code, $allowed, true) ? $code : null; @@ -397,7 +405,9 @@ private function collectJsonFiles(string $path): array return str_ends_with($path, '.json') ? [$path] : []; } - if (!is_dir($path)) return []; + if (!is_dir($path)) { + return []; + } $files = []; $rii = new \RecursiveIteratorIterator( @@ -417,13 +427,21 @@ private function collectJsonFiles(string $path): array private function resolvePath(string $path): string { $path = trim($path); - if ($path === '') return $path; + if ($path === '') { + return $path; + } - if (str_starts_with($path, '/')) return $path; - if (preg_match('/^[A-Za-z]:\\\\/', $path) === 1) return $path; + if (str_starts_with($path, '/')) { + return $path; + } + if (preg_match('/^[A-Za-z]:\\\\/', $path) === 1) { + return $path; + } $storageCandidate = storage_path('app/' . ltrim($path, '/')); - if (file_exists($storageCandidate)) return $storageCandidate; + if (file_exists($storageCandidate)) { + return $storageCandidate; + } return base_path($path); } @@ -439,26 +457,42 @@ private function extractRows(array $json): ?array private function readExistingCountriesJpMap(string $storageOutPath): array { - if (!Storage::disk('local')->exists($storageOutPath)) return []; + if (!Storage::disk('local')->exists($storageOutPath)) { + return []; + } $raw = (string) Storage::disk('local')->get($storageOutPath); $json = json_decode($raw, true); - if (!is_array($json)) return []; + if (!is_array($json)) { + return []; + } $rows = $this->extractRows($json); - if ($rows === null) return []; + if ($rows === null) { + return []; + } $map = []; foreach ($rows as $row) { - if (!is_array($row)) continue; + if (!is_array($row)) { + continue; + } $code = strtoupper(trim((string)($row['state_party_code'] ?? ''))); - if ($code === '') continue; + if ($code === '') { + continue; + } $jp = $row['name_jp'] ?? null; - if (is_string($jp)) $jp = trim($jp); - if ($jp === '') $jp = null; + if (is_string($jp)) { + $jp = trim($jp); + } + if ($jp === '') { + $jp = null; + } - if ($jp !== null) $map[$code] = $jp; + if ($jp !== null) { + $map[$code] = $jp; + } } ksort($map, SORT_STRING); @@ -467,13 +501,19 @@ private function readExistingCountriesJpMap(string $storageOutPath): array private function normalizeStringList(mixed $v): array { - if (!is_array($v)) return []; + if (!is_array($v)) { + return []; + } $out = []; foreach ($v as $x) { - if (!is_string($x)) continue; + if (!is_string($x)) { + continue; + } $x = trim($x); - if ($x === '') continue; + if ($x === '') { + continue; + } $out[] = $x; } return $this->uniqueList($out); @@ -485,21 +525,29 @@ private function normalizeCodeList(mixed $v): array if (is_array($v)) { foreach ($v as $x) { - if (!is_string($x)) continue; + if (!is_string($x)) { + continue; + } $x = strtoupper(trim($x)); - if ($x !== '') $out[] = $x; + if ($x !== '') { + $out[] = $x; + } } return $this->uniqueList($out); } if (is_string($v)) { $s = trim($v); - if ($s === '') return []; + if ($s === '') { + return []; + } $parts = preg_split('/[,\|;\/\s]+/', $s) ?: []; foreach ($parts as $p) { $p = strtoupper(trim($p)); - if ($p !== '') $out[] = $p; + if ($p !== '') { + $out[] = $p; + } } return $this->uniqueList($out); } @@ -512,7 +560,9 @@ private function uniqueList(array $list): array $seen = []; $out = []; foreach ($list as $v) { - if (isset($seen[$v])) continue; + if (isset($seen[$v])) { + continue; + } $seen[$v] = true; $out[] = $v; } @@ -522,7 +572,9 @@ private function uniqueList(array $list): array private function encodeJson(mixed $payload, bool $pretty): ?string { $flags = JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES; - if ($pretty) $flags |= JSON_PRETTY_PRINT; + if ($pretty) { + $flags |= JSON_PRETTY_PRINT; + } $json = json_encode($payload, $flags); return $json === false ? null : $json; diff --git a/src/app/Console/Commands/SplitWorldHeritageImageJson.php b/src/app/Console/Commands/SplitWorldHeritageImageJson.php index ab21a95..690c9a2 100644 --- a/src/app/Console/Commands/SplitWorldHeritageImageJson.php +++ b/src/app/Console/Commands/SplitWorldHeritageImageJson.php @@ -129,11 +129,9 @@ public function handle(): int } $dir = dirname($outPath); - if (!is_dir($dir)) { - if (!@mkdir($dir, 0777, true) && !is_dir($dir)) { - $this->error("Failed to create output dir: {$dir}"); - return self::FAILURE; - } + if (!is_dir($dir) && (!@mkdir($dir, 0777, true) && !is_dir($dir))) { + $this->error("Failed to create output dir: {$dir}"); + return self::FAILURE; } if (@file_put_contents($outPath, $encoded) === false) { @@ -153,15 +151,21 @@ private function extractImageUrlsPreferImagesUrls(array $row): array if (is_array($images) && $images !== []) { foreach ($images as $p) { - if (!is_string($p)) continue; + if (!is_string($p)) { + continue; + } $p = trim($p); - if ($p !== '') $urls[] = $p; + if ($p !== '') { + $urls[] = $p; + } } } elseif (is_string($images)) { $parts = preg_split('/\s*,\s*/', trim($images)) ?: []; foreach ($parts as $p) { $p = trim($p); - if ($p !== '') $urls[] = $p; + if ($p !== '') { + $urls[] = $p; + } } } @@ -169,7 +173,9 @@ private function extractImageUrlsPreferImagesUrls(array $row): array $main = $row['main_image_url']['url'] ?? null; if (is_string($main)) { $main = trim($main); - if ($main !== '') $urls[] = $main; + if ($main !== '') { + $urls[] = $main; + } } } @@ -177,7 +183,9 @@ private function extractImageUrlsPreferImagesUrls(array $row): array $out = []; foreach ($urls as $u) { - if (isset($seen[$u])) continue; + if (isset($seen[$u])) { + continue; + } $seen[$u] = true; $out[] = $u; } @@ -188,10 +196,16 @@ private function extractImageUrlsPreferImagesUrls(array $row): array private function resolvePathToFile(string $path): string { $path = trim($path); - if ($path === '') return $path; + if ($path === '') { + return $path; + } - if (str_starts_with($path, '/')) return $path; - if (preg_match('/^[A-Za-z]:\\\\/', $path) === 1) return $path; + if (str_starts_with($path, '/')) { + return $path; + } + if (preg_match('/^[A-Za-z]:\\\\/', $path) === 1) { + return $path; + } if (str_starts_with($path, 'storage/app/')) { $path = substr($path, strlen('storage/app/')); @@ -202,7 +216,9 @@ private function resolvePathToFile(string $path): string private function encodeJson(mixed $payload, bool $pretty): ?string { $flags = JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES; - if ($pretty) $flags |= JSON_PRETTY_PRINT; + if ($pretty) { + $flags |= JSON_PRETTY_PRINT; + } $json = json_encode($payload, $flags); return $json === false ? null : $json; diff --git a/src/app/Console/Commands/SplitWorldHeritageJson.php b/src/app/Console/Commands/SplitWorldHeritageJson.php index ec063a2..0d5e47b 100644 --- a/src/app/Console/Commands/SplitWorldHeritageJson.php +++ b/src/app/Console/Commands/SplitWorldHeritageJson.php @@ -75,11 +75,9 @@ public function handle(): int } $outDir = $this->resolvePathToDir($out); - if (!is_dir($outDir)) { - if (!@mkdir($outDir, 0777, true) && !is_dir($outDir)) { - $this->error("Failed to create output dir: {$outDir}"); - return self::FAILURE; - } + if (!is_dir($outDir) && (!@mkdir($outDir, 0777, true) && !is_dir($outDir))) { + $this->error("Failed to create output dir: {$outDir}"); + return self::FAILURE; } if ($clean && !$dryRun) { @@ -556,17 +554,15 @@ public function handle(): int $encodedSummary = $this->encodeJson($summary, true); if ($encodedSummary === null) { $this->warn("Failed to encode summary JSON: {$summaryPath}"); - } else { - if (!$dryRun) { - $ok = @file_put_contents($summaryPath, $encodedSummary); - if ($ok === false) { - $this->warn("Failed to write summary: {$summaryPath}"); - } else { - $this->info("Wrote summary: {$summaryPath}"); - } + } elseif (!$dryRun) { + $ok = @file_put_contents($summaryPath, $encodedSummary); + if ($ok === false) { + $this->warn("Failed to write summary: {$summaryPath}"); } else { - $this->info("[dry] would write summary: {$summaryPath}"); + $this->info("Wrote summary: {$summaryPath}"); } + } else { + $this->info("[dry] would write summary: {$summaryPath}"); } } @@ -776,10 +772,8 @@ private function normalizeSiteRowImportReady(array $row, int $siteId): array private function mergeSiteRowPreferExisting(array $existing, array $incoming): array { $fill = function (string $key, mixed $value) use (&$existing): void { - if (!array_key_exists($key, $existing) || $existing[$key] === null || $existing[$key] === '') { - if ($value !== null && $value !== '') { - $existing[$key] = $value; - } + if ((!array_key_exists($key, $existing) || $existing[$key] === null || $existing[$key] === '') && ($value !== null && $value !== '')) { + $existing[$key] = $value; } }; diff --git a/src/app/Console/Concerns/LoadsJsonRows.php b/src/app/Console/Concerns/LoadsJsonRows.php index c8c9e10..9871a01 100644 --- a/src/app/Console/Concerns/LoadsJsonRows.php +++ b/src/app/Console/Concerns/LoadsJsonRows.php @@ -7,11 +7,17 @@ trait LoadsJsonRows protected function resolvePath(string $path): string { $path = trim($path); - if ($path === '') return $path; + if ($path === '') { + return $path; + } - if (str_starts_with($path, '/')) return $path; + if (str_starts_with($path, '/')) { + return $path; + } - if (preg_match('/^[A-Za-z]:\\\\/', $path) === 1) return $path; + if (preg_match('/^[A-Za-z]:\\\\/', $path) === 1) { + return $path; + } return base_path($path); } @@ -19,10 +25,14 @@ protected function resolvePath(string $path): string protected function loadRows(string $path): ?array { $raw = @file_get_contents($path); - if ($raw === false) return null; + if ($raw === false) { + return null; + } $json = json_decode($raw, true); - if (!is_array($json)) return null; + if (!is_array($json)) { + return null; + } if (array_key_exists('results', $json)) { return is_array($json['results']) ? $json['results'] : null; diff --git a/src/app/Models/WorldHeritage.php b/src/app/Models/WorldHeritage.php index f98cfed..440dc1b 100644 --- a/src/app/Models/WorldHeritage.php +++ b/src/app/Models/WorldHeritage.php @@ -37,16 +37,6 @@ class WorldHeritage extends Model 'thumbnail_image_id', ]; - protected $casts = [ - 'criteria' => 'array', - 'is_endangered' => 'boolean', - 'year_inscribed' => 'integer', - 'area_hectares' => 'float', - 'buffer_zone_hectares' => 'float', - 'latitude' => 'float', - 'longitude' => 'float', - ]; - protected $hidden = [ 'created_at', 'updated_at', @@ -74,4 +64,16 @@ public function thumbnail(): BelongsTo { return $this->belongsTo(Image::class, 'thumbnail_image_id'); } + protected function casts(): array + { + return [ + 'criteria' => 'array', + 'is_endangered' => 'boolean', + 'year_inscribed' => 'integer', + 'area_hectares' => 'float', + 'buffer_zone_hectares' => 'float', + 'latitude' => 'float', + 'longitude' => 'float', + ]; + } } diff --git a/src/app/Packages/Domains/Adapter/AlgoliaWorldHeritageSearchAdapter.php b/src/app/Packages/Domains/Adapter/AlgoliaWorldHeritageSearchAdapter.php index b747a92..1f100d3 100644 --- a/src/app/Packages/Domains/Adapter/AlgoliaWorldHeritageSearchAdapter.php +++ b/src/app/Packages/Domains/Adapter/AlgoliaWorldHeritageSearchAdapter.php @@ -46,17 +46,14 @@ public function search( // Requirement: ISO3 -> query='' and filter by state_party_codes: $filters[] = 'state_party_codes:' . $this->escapeToken($query->countryIso3); $queryString = ''; - } else { - if ($this->hasValue($query->countryName)) { - $filters[] = $this->buildCountryOrFilter($query->countryName); - - /** - * IMPORTANT: - * Do not blank out query here. - * If the input was not a real country (e.g. "japan" typo / random word), - * we still want full-text search to work rather than returning "top hits". - */ - } + } elseif ($this->hasValue($query->countryName)) { + $filters[] = $this->buildCountryOrFilter($query->countryName); + /** + * IMPORTANT: + * Do not blank out query here. + * If the input was not a real country (e.g. "japan" typo / random word), + * we still want full-text search to work rather than returning "top hits". + */ } /** @@ -89,7 +86,7 @@ public function search( * Never execute Algolia with query='' AND no filters, * otherwise you will get "top results" unrelated to the user input. */ - $hasAnyFilter = !empty($filters); + $hasAnyFilter = $filters !== []; $hasQueryText = $this->hasValue($queryString); if (!$hasAnyFilter && !$hasQueryText) { diff --git a/src/app/Packages/Domains/Adapter/GcsObjectStorageAdapter.php b/src/app/Packages/Domains/Adapter/GcsObjectStorageAdapter.php index 1769189..50a81f3 100644 --- a/src/app/Packages/Domains/Adapter/GcsObjectStorageAdapter.php +++ b/src/app/Packages/Domains/Adapter/GcsObjectStorageAdapter.php @@ -89,7 +89,7 @@ private function resolve(string $disk, string $key): array $prefix = rtrim($config['root'] ?? $config['path_prefix'] ?? '', '/'); $objectPath = ltrim( - ($prefix ? "{$prefix}/" : '') . ltrim($key, '/'), + ($prefix !== '' && $prefix !== '0' ? "{$prefix}/" : '') . ltrim($key, '/'), '/' ); @@ -106,7 +106,7 @@ private function resolveGcs(array $cfg, string $key): array $prefix = rtrim($cfg['root'] ?? $cfg['path_prefix'] ?? '', '/'); $objectPath = ltrim( - ($prefix ? "{$prefix}/" : '') . ltrim($key, '/'), + ($prefix !== '' && $prefix !== '0' ? "{$prefix}/" : '') . ltrim($key, '/'), '/' ); diff --git a/src/app/Packages/Domains/Adapter/GcsSignedUrlAdapter.php b/src/app/Packages/Domains/Adapter/GcsSignedUrlAdapter.php index 7e56aff..c2d43f8 100644 --- a/src/app/Packages/Domains/Adapter/GcsSignedUrlAdapter.php +++ b/src/app/Packages/Domains/Adapter/GcsSignedUrlAdapter.php @@ -75,7 +75,7 @@ private function resolveGcs(array $cfg, string $key): array $prefix = rtrim($cfg['root'] ?? $cfg['path_prefix'] ?? '', '/'); $objectPath = ltrim( - ($prefix ? "{$prefix}/" : '') . ltrim($key, '/'), + ($prefix !== '' && $prefix !== '0' ? "{$prefix}/" : '') . ltrim($key, '/'), '/' ); diff --git a/src/app/Packages/Domains/Infra/GcsImageObjectRemover.php b/src/app/Packages/Domains/Infra/GcsImageObjectRemover.php index 66b72d6..c6b314e 100644 --- a/src/app/Packages/Domains/Infra/GcsImageObjectRemover.php +++ b/src/app/Packages/Domains/Infra/GcsImageObjectRemover.php @@ -34,7 +34,7 @@ private function resolve(string $disk, string $key): array } $bucket = $this->storage->bucket($cfg['bucket']); $root = trim((string)($cfg['root'] ?? ''), '/'); - $path = ltrim(($root ? "{$root}/" : '').ltrim($key, '/'), '/'); + $path = ltrim(($root !== '' && $root !== '0' ? "{$root}/" : '').ltrim($key, '/'), '/'); return [$bucket, $path]; } diff --git a/src/app/Packages/Domains/Test/ImageEntityCollectionTest.php b/src/app/Packages/Domains/Test/ImageEntityCollectionTest.php index 648a472..ed98e25 100644 --- a/src/app/Packages/Domains/Test/ImageEntityCollectionTest.php +++ b/src/app/Packages/Domains/Test/ImageEntityCollectionTest.php @@ -18,7 +18,7 @@ protected function tearDown(): void parent::tearDown(); } - private static function arrayData(): array + private function arrayData(): array { return [ [ @@ -40,7 +40,7 @@ public function test_check_collection_test_type(): void { $collection = new ImageEntityCollection(); - foreach (self::arrayData() as $data) { + foreach ($this->arrayData() as $data) { $collection->add(new ImageEntity( id: $data['id'], url: $data['url'], @@ -56,7 +56,7 @@ public function test_check_collection_test_value(): void { $collection = new ImageEntityCollection(); - foreach (self::arrayData() as $data) { + foreach ($this->arrayData() as $data) { $collection->add(new ImageEntity( id: $data['id'], url: $data['url'], @@ -66,10 +66,10 @@ public function test_check_collection_test_value(): void } foreach ($collection->getItems() as $key => $item) { $this->assertInstanceOf(ImageEntity::class, $item); - $this->assertSame(self::arrayData()[$key]['id'], $item->getId()); - $this->assertSame(self::arrayData()[$key]['url'], $item->getUrl()); - $this->assertEquals(self::arrayData()[$key]['sortOrder'], $item->getSortOrder()); - $this->assertSame(self::arrayData()[$key]['isPrimary'], $item->getIsPrimary()); + $this->assertSame($this->arrayData()[$key]['id'], $item->getId()); + $this->assertSame($this->arrayData()[$key]['url'], $item->getUrl()); + $this->assertEquals($this->arrayData()[$key]['sortOrder'], $item->getSortOrder()); + $this->assertSame($this->arrayData()[$key]['isPrimary'], $item->getIsPrimary()); } } } \ No newline at end of file diff --git a/src/app/Packages/Domains/Test/ImageEntityTest.php b/src/app/Packages/Domains/Test/ImageEntityTest.php index 3ec0a2b..1a0ac41 100644 --- a/src/app/Packages/Domains/Test/ImageEntityTest.php +++ b/src/app/Packages/Domains/Test/ImageEntityTest.php @@ -17,7 +17,7 @@ protected function tearDown(): void parent::tearDown(); } - private static function arrayNoIdData(): array + private function arrayNoIdData(): array { return [ 'id' => null, @@ -27,7 +27,7 @@ private static function arrayNoIdData(): array ]; } - private static function arrayData(): array + private function arrayData(): array { return [ 'id' => 1, @@ -40,10 +40,10 @@ private static function arrayData(): array public function test_entity_check_type_with_no_id_entity(): void { $entity = new ImageEntity( - self::arrayNoIdData()['id'], - self::arrayNoIdData()['url'], - self::arrayNoIdData()['sortOrder'], - self::arrayNoIdData()['isPrimary'], + $this->arrayNoIdData()['id'], + $this->arrayNoIdData()['url'], + $this->arrayNoIdData()['sortOrder'], + $this->arrayNoIdData()['isPrimary'], ); $this->assertInstanceOf(ImageEntity::class, $entity); @@ -52,10 +52,10 @@ public function test_entity_check_type_with_no_id_entity(): void public function test_entity_check_type_with_id_entity(): void { $entity = new ImageEntity( - self::arrayData()['id'], - self::arrayData()['url'], - self::arrayData()['sortOrder'], - self::arrayData()['isPrimary'], + $this->arrayData()['id'], + $this->arrayData()['url'], + $this->arrayData()['sortOrder'], + $this->arrayData()['isPrimary'], ); $this->assertInstanceOf(ImageEntity::class, $entity); @@ -65,29 +65,29 @@ public function test_entity_check_value(): void { $entity = new ImageEntity( id: null, - url: self::arrayData()['url'], - sortOrder: self::arrayData()['sortOrder'], - isPrimary: self::arrayData()['isPrimary'], + url: $this->arrayData()['url'], + sortOrder: $this->arrayData()['sortOrder'], + isPrimary: $this->arrayData()['isPrimary'], ); $this->assertSame(null, $entity->getId()); - $this->assertSame(self::arrayData()['url'], $entity->getUrl()); - $this->assertSame(self::arrayData()['sortOrder'], $entity->getSortOrder()); - $this->assertSame(self::arrayData()['isPrimary'], $entity->getIsPrimary()); + $this->assertSame($this->arrayData()['url'], $entity->getUrl()); + $this->assertSame($this->arrayData()['sortOrder'], $entity->getSortOrder()); + $this->assertSame($this->arrayData()['isPrimary'], $entity->getIsPrimary()); } public function test_entity_check_value_with_no_id(): void { $entity = new ImageEntity( - id: self::arrayNoIdData()['id'], - url: self::arrayNoIdData()['url'], - sortOrder: self::arrayNoIdData()['sortOrder'], - isPrimary: self::arrayNoIdData()['isPrimary'], + id: $this->arrayNoIdData()['id'], + url: $this->arrayNoIdData()['url'], + sortOrder: $this->arrayNoIdData()['sortOrder'], + isPrimary: $this->arrayNoIdData()['isPrimary'], ); $this->assertSame(null, $entity->getId()); - $this->assertSame(self::arrayNoIdData()['url'], $entity->getUrl()); - $this->assertSame(self::arrayNoIdData()['sortOrder'], $entity->getSortOrder()); - $this->assertSame(self::arrayNoIdData()['isPrimary'], $entity->getIsPrimary()); + $this->assertSame($this->arrayNoIdData()['url'], $entity->getUrl()); + $this->assertSame($this->arrayNoIdData()['sortOrder'], $entity->getSortOrder()); + $this->assertSame($this->arrayNoIdData()['isPrimary'], $entity->getIsPrimary()); } } \ No newline at end of file diff --git a/src/app/Packages/Domains/Test/QueryService/WorldHeritageQueryService_getByIdTest.php b/src/app/Packages/Domains/Test/QueryService/WorldHeritageQueryService_getByIdTest.php index d39b8e2..b78d5ca 100644 --- a/src/app/Packages/Domains/Test/QueryService/WorldHeritageQueryService_getByIdTest.php +++ b/src/app/Packages/Domains/Test/QueryService/WorldHeritageQueryService_getByIdTest.php @@ -55,7 +55,7 @@ private function refresh(): void } } - private static function arrayData(): array + private function arrayData(): array { return [ diff --git a/src/app/Packages/Domains/Test/QueryService/WorldHeritageQueryService_searchHeritagesTest.php b/src/app/Packages/Domains/Test/QueryService/WorldHeritageQueryService_searchHeritagesTest.php index 5402a1b..c19f3ff 100644 --- a/src/app/Packages/Domains/Test/QueryService/WorldHeritageQueryService_searchHeritagesTest.php +++ b/src/app/Packages/Domains/Test/QueryService/WorldHeritageQueryService_searchHeritagesTest.php @@ -18,6 +18,7 @@ final class WorldHeritageQueryService_searchHeritagesTest extends TestCase { + private \App\Packages\Domains\WorldHeritageQueryService $queryService; protected function setUp(): void { parent::setUp(); diff --git a/src/app/Packages/Domains/Test/WorldHeritageEntityCollectionTest.php b/src/app/Packages/Domains/Test/WorldHeritageEntityCollectionTest.php index 70162b3..d815f2f 100644 --- a/src/app/Packages/Domains/Test/WorldHeritageEntityCollectionTest.php +++ b/src/app/Packages/Domains/Test/WorldHeritageEntityCollectionTest.php @@ -39,7 +39,7 @@ private function refresh(): void } } - private static function arraySingleData(): array + private function arraySingleData(): array { return [ [ @@ -69,7 +69,7 @@ private static function arraySingleData(): array ]; } - private static function arrayMultiData(): array + private function arrayMultiData(): array { return [ [ @@ -243,7 +243,7 @@ public function test_multi_collection_check_type(): void $data['state_parties'] ?? [], $data['state_parties_meta'] ?? [] ); - }, self::arrayMultiData()) + }, $this->arrayMultiData()) ); $this->assertInstanceOf(WorldHeritageEntityCollection::class, $collection); @@ -276,7 +276,7 @@ public function test_multi_collection_check_count_value(): void $data['state_parties'] ?? [], $data['state_parties_meta'] ?? [] ); - }, self::arrayMultiData()) + }, $this->arrayMultiData()) ); $this->assertCount(2, $collection->getAllHeritages()); diff --git a/src/app/Packages/Domains/Test/WorldHeritageEntityTest.php b/src/app/Packages/Domains/Test/WorldHeritageEntityTest.php index e9ec897..3e7d479 100644 --- a/src/app/Packages/Domains/Test/WorldHeritageEntityTest.php +++ b/src/app/Packages/Domains/Test/WorldHeritageEntityTest.php @@ -32,7 +32,7 @@ private function refresh(): void } } - private static function arraySingleData(): array + private function arraySingleData(): array { return [ 'id' => 668, @@ -63,7 +63,7 @@ private static function arraySingleData(): array ]; } - private static function arrayMultiData(): array + private function arrayMultiData(): array { return [ 'id' => 1133, @@ -113,27 +113,27 @@ private static function arrayMultiData(): array public function test_entity_check_single_type(): void { $entity = new WorldHeritageEntity( - self::arraySingleData()['id'], - self::arraySingleData()['official_name'], - self::arraySingleData()['name'], - self::arraySingleData()['country'], - self::arraySingleData()['region'], - self::arraySingleData()['category'], - self::arraySingleData()['year_inscribed'], - self::arraySingleData()['latitude'], - self::arraySingleData()['longitude'], - self::arraySingleData()['is_endangered'], - self::arraySingleData()['name_jp'], + $this->arraySingleData()['id'], + $this->arraySingleData()['official_name'], + $this->arraySingleData()['name'], + $this->arraySingleData()['country'], + $this->arraySingleData()['region'], + $this->arraySingleData()['category'], + $this->arraySingleData()['year_inscribed'], + $this->arraySingleData()['latitude'], + $this->arraySingleData()['longitude'], + $this->arraySingleData()['is_endangered'], + $this->arraySingleData()['name_jp'], null, // countryNameJp - self::arraySingleData()['state_party'], - self::arraySingleData()['criteria'], - self::arraySingleData()['area_hectares'], - self::arraySingleData()['buffer_zone_hectares'], - self::arraySingleData()['short_description'], + $this->arraySingleData()['state_party'], + $this->arraySingleData()['criteria'], + $this->arraySingleData()['area_hectares'], + $this->arraySingleData()['buffer_zone_hectares'], + $this->arraySingleData()['short_description'], null, // collection (ImageEntityCollection) - self::arraySingleData()['unesco_site_url'], - self::arraySingleData()['state_parties'] ?? [], - self::arraySingleData()['state_parties_meta'] ?? [] + $this->arraySingleData()['unesco_site_url'], + $this->arraySingleData()['state_parties'] ?? [], + $this->arraySingleData()['state_parties_meta'] ?? [] ); $this->assertInstanceOf(WorldHeritageEntity::class, $entity); @@ -142,73 +142,73 @@ public function test_entity_check_single_type(): void public function test_entity_check_single_value(): void { $entity = new WorldHeritageEntity( - self::arraySingleData()['id'], - self::arraySingleData()['official_name'], - self::arraySingleData()['name'], - self::arraySingleData()['country'], - self::arraySingleData()['region'], - self::arraySingleData()['category'], - self::arraySingleData()['year_inscribed'], - self::arraySingleData()['latitude'], - self::arraySingleData()['longitude'], - self::arraySingleData()['is_endangered'], - self::arraySingleData()['name_jp'], + $this->arraySingleData()['id'], + $this->arraySingleData()['official_name'], + $this->arraySingleData()['name'], + $this->arraySingleData()['country'], + $this->arraySingleData()['region'], + $this->arraySingleData()['category'], + $this->arraySingleData()['year_inscribed'], + $this->arraySingleData()['latitude'], + $this->arraySingleData()['longitude'], + $this->arraySingleData()['is_endangered'], + $this->arraySingleData()['name_jp'], null, - self::arraySingleData()['state_party'], - self::arraySingleData()['criteria'], - self::arraySingleData()['area_hectares'], - self::arraySingleData()['buffer_zone_hectares'], - self::arraySingleData()['short_description'], + $this->arraySingleData()['state_party'], + $this->arraySingleData()['criteria'], + $this->arraySingleData()['area_hectares'], + $this->arraySingleData()['buffer_zone_hectares'], + $this->arraySingleData()['short_description'], null, - self::arraySingleData()['unesco_site_url'], - self::arraySingleData()['state_parties'] ?: [], - self::arraySingleData()['state_parties_meta'] ?: [] + $this->arraySingleData()['unesco_site_url'], + $this->arraySingleData()['state_parties'] ?: [], + $this->arraySingleData()['state_parties_meta'] ?: [] ); - $this->assertEquals(self::arraySingleData()['id'], $entity->getId()); - $this->assertEquals(self::arraySingleData()['official_name'], $entity->getOfficialName()); - $this->assertEquals(self::arraySingleData()['name'], $entity->getName()); - $this->assertEquals(self::arraySingleData()['country'], $entity->getCountry()); - $this->assertEquals(self::arraySingleData()['region'], $entity->getRegion()); - $this->assertEquals(self::arraySingleData()['category'], $entity->getCategory()); - $this->assertEquals(self::arraySingleData()['year_inscribed'], $entity->getYearInscribed()); - $this->assertEquals(self::arraySingleData()['latitude'], $entity->getLatitude()); - $this->assertEquals(self::arraySingleData()['longitude'], $entity->getLongitude()); - $this->assertEquals(self::arraySingleData()['is_endangered'], $entity->isEndangered()); - $this->assertEquals(self::arraySingleData()['state_party'], $entity->getStateParty()); - $this->assertEquals(self::arraySingleData()['criteria'], $entity->getCriteria()); - $this->assertEquals(self::arraySingleData()['area_hectares'], $entity->getAreaHectares()); - $this->assertEquals(self::arraySingleData()['buffer_zone_hectares'], $entity->getBufferZoneHectares()); - $this->assertEquals(self::arraySingleData()['short_description'], $entity->getShortDescription()); - $this->assertEquals(self::arraySingleData()['unesco_site_url'], $entity->getUnescoSiteUrl()); + $this->assertEquals($this->arraySingleData()['id'], $entity->getId()); + $this->assertEquals($this->arraySingleData()['official_name'], $entity->getOfficialName()); + $this->assertEquals($this->arraySingleData()['name'], $entity->getName()); + $this->assertEquals($this->arraySingleData()['country'], $entity->getCountry()); + $this->assertEquals($this->arraySingleData()['region'], $entity->getRegion()); + $this->assertEquals($this->arraySingleData()['category'], $entity->getCategory()); + $this->assertEquals($this->arraySingleData()['year_inscribed'], $entity->getYearInscribed()); + $this->assertEquals($this->arraySingleData()['latitude'], $entity->getLatitude()); + $this->assertEquals($this->arraySingleData()['longitude'], $entity->getLongitude()); + $this->assertEquals($this->arraySingleData()['is_endangered'], $entity->isEndangered()); + $this->assertEquals($this->arraySingleData()['state_party'], $entity->getStateParty()); + $this->assertEquals($this->arraySingleData()['criteria'], $entity->getCriteria()); + $this->assertEquals($this->arraySingleData()['area_hectares'], $entity->getAreaHectares()); + $this->assertEquals($this->arraySingleData()['buffer_zone_hectares'], $entity->getBufferZoneHectares()); + $this->assertEquals($this->arraySingleData()['short_description'], $entity->getShortDescription()); + $this->assertEquals($this->arraySingleData()['unesco_site_url'], $entity->getUnescoSiteUrl()); $this->assertSame(['JPN'], $entity->getStatePartyCodes()); - $this->assertSame(self::arraySingleData()['state_parties_meta'], $entity->getStatePartyMeta()); + $this->assertSame($this->arraySingleData()['state_parties_meta'], $entity->getStatePartyMeta()); } public function test_entity_check_multi_type(): void { $entity = new WorldHeritageEntity( - self::arrayMultiData()['id'], - self::arrayMultiData()['official_name'], - self::arrayMultiData()['name'], - self::arrayMultiData()['country'], - self::arrayMultiData()['region'], - self::arrayMultiData()['category'], - self::arrayMultiData()['year_inscribed'], - self::arrayMultiData()['latitude'], - self::arrayMultiData()['longitude'], - self::arrayMultiData()['is_endangered'], - self::arrayMultiData()['name_jp'], + $this->arrayMultiData()['id'], + $this->arrayMultiData()['official_name'], + $this->arrayMultiData()['name'], + $this->arrayMultiData()['country'], + $this->arrayMultiData()['region'], + $this->arrayMultiData()['category'], + $this->arrayMultiData()['year_inscribed'], + $this->arrayMultiData()['latitude'], + $this->arrayMultiData()['longitude'], + $this->arrayMultiData()['is_endangered'], + $this->arrayMultiData()['name_jp'], null, - self::arrayMultiData()['state_party'], - self::arrayMultiData()['criteria'], - self::arrayMultiData()['area_hectares'], - self::arrayMultiData()['buffer_zone_hectares'], - self::arrayMultiData()['short_description'], + $this->arrayMultiData()['state_party'], + $this->arrayMultiData()['criteria'], + $this->arrayMultiData()['area_hectares'], + $this->arrayMultiData()['buffer_zone_hectares'], + $this->arrayMultiData()['short_description'], null, - self::arrayMultiData()['unesco_site_url'], - self::arrayMultiData()['state_parties'] ?? [], - self::arrayMultiData()['state_parties_meta'] ?? [] + $this->arrayMultiData()['unesco_site_url'], + $this->arrayMultiData()['state_parties'] ?? [], + $this->arrayMultiData()['state_parties_meta'] ?? [] ); $this->assertInstanceOf(WorldHeritageEntity::class, $entity); @@ -217,48 +217,48 @@ public function test_entity_check_multi_type(): void public function test_entity_check_multi_value(): void { $entity = new WorldHeritageEntity( - self::arrayMultiData()['id'], - self::arrayMultiData()['official_name'], - self::arrayMultiData()['name'], - self::arrayMultiData()['country'], - self::arrayMultiData()['region'], - self::arrayMultiData()['category'], - self::arrayMultiData()['year_inscribed'], - self::arrayMultiData()['latitude'], - self::arrayMultiData()['longitude'], - self::arrayMultiData()['is_endangered'], - self::arrayMultiData()['name_jp'], + $this->arrayMultiData()['id'], + $this->arrayMultiData()['official_name'], + $this->arrayMultiData()['name'], + $this->arrayMultiData()['country'], + $this->arrayMultiData()['region'], + $this->arrayMultiData()['category'], + $this->arrayMultiData()['year_inscribed'], + $this->arrayMultiData()['latitude'], + $this->arrayMultiData()['longitude'], + $this->arrayMultiData()['is_endangered'], + $this->arrayMultiData()['name_jp'], null, // countryNameJp - self::arrayMultiData()['state_party'], - self::arrayMultiData()['criteria'], - self::arrayMultiData()['area_hectares'], - self::arrayMultiData()['buffer_zone_hectares'], - self::arrayMultiData()['short_description'], + $this->arrayMultiData()['state_party'], + $this->arrayMultiData()['criteria'], + $this->arrayMultiData()['area_hectares'], + $this->arrayMultiData()['buffer_zone_hectares'], + $this->arrayMultiData()['short_description'], null, // collection - self::arrayMultiData()['unesco_site_url'], - self::arrayMultiData()['state_parties'] ?? [], - self::arrayMultiData()['state_parties_meta'] ?? [] + $this->arrayMultiData()['unesco_site_url'], + $this->arrayMultiData()['state_parties'] ?? [], + $this->arrayMultiData()['state_parties_meta'] ?? [] ); - $this->assertEquals(self::arrayMultiData()['id'], $entity->getId()); - $this->assertEquals(self::arrayMultiData()['official_name'], $entity->getOfficialName()); - $this->assertEquals(self::arrayMultiData()['name'], $entity->getName()); - $this->assertEquals(self::arrayMultiData()['country'], $entity->getCountry()); - $this->assertEquals(self::arrayMultiData()['region'], $entity->getRegion()); - $this->assertEquals(self::arrayMultiData()['category'], $entity->getCategory()); - $this->assertEquals(self::arrayMultiData()['year_inscribed'], $entity->getYearInscribed()); - $this->assertEquals(self::arrayMultiData()['is_endangered'], $entity->isEndangered()); - $this->assertEquals(self::arrayMultiData()['latitude'], $entity->getLatitude()); - $this->assertEquals(self::arrayMultiData()['longitude'], $entity->getLongitude()); - $this->assertEquals(self::arrayMultiData()['criteria'], $entity->getCriteria()); - $this->assertEquals(self::arrayMultiData()['area_hectares'], $entity->getAreaHectares()); - $this->assertEquals(self::arrayMultiData()['buffer_zone_hectares'], $entity->getBufferZoneHectares()); - $this->assertEquals(self::arrayMultiData()['short_description'], $entity->getShortDescription()); - $this->assertEquals(self::arrayMultiData()['unesco_site_url'], $entity->getUnescoSiteUrl()); - $this->assertEquals(self::arrayMultiData()['state_parties'], $entity->getStatePartyCodes()); - $this->assertEquals(self::arrayMultiData()['state_parties_meta'], $entity->getStatePartyMeta()); + $this->assertEquals($this->arrayMultiData()['id'], $entity->getId()); + $this->assertEquals($this->arrayMultiData()['official_name'], $entity->getOfficialName()); + $this->assertEquals($this->arrayMultiData()['name'], $entity->getName()); + $this->assertEquals($this->arrayMultiData()['country'], $entity->getCountry()); + $this->assertEquals($this->arrayMultiData()['region'], $entity->getRegion()); + $this->assertEquals($this->arrayMultiData()['category'], $entity->getCategory()); + $this->assertEquals($this->arrayMultiData()['year_inscribed'], $entity->getYearInscribed()); + $this->assertEquals($this->arrayMultiData()['is_endangered'], $entity->isEndangered()); + $this->assertEquals($this->arrayMultiData()['latitude'], $entity->getLatitude()); + $this->assertEquals($this->arrayMultiData()['longitude'], $entity->getLongitude()); + $this->assertEquals($this->arrayMultiData()['criteria'], $entity->getCriteria()); + $this->assertEquals($this->arrayMultiData()['area_hectares'], $entity->getAreaHectares()); + $this->assertEquals($this->arrayMultiData()['buffer_zone_hectares'], $entity->getBufferZoneHectares()); + $this->assertEquals($this->arrayMultiData()['short_description'], $entity->getShortDescription()); + $this->assertEquals($this->arrayMultiData()['unesco_site_url'], $entity->getUnescoSiteUrl()); + $this->assertEquals($this->arrayMultiData()['state_parties'], $entity->getStatePartyCodes()); + $this->assertEquals($this->arrayMultiData()['state_parties_meta'], $entity->getStatePartyMeta()); $this->assertEquals( - self::arrayMultiData()['state_parties_meta']['SVK'], + $this->arrayMultiData()['state_parties_meta']['SVK'], $entity->getStatePartyMeta()['SVK'] ); } diff --git a/src/app/Packages/Domains/WorldHeritageEntity.php b/src/app/Packages/Domains/WorldHeritageEntity.php index 1aa8f98..eaee24b 100644 --- a/src/app/Packages/Domains/WorldHeritageEntity.php +++ b/src/app/Packages/Domains/WorldHeritageEntity.php @@ -4,6 +4,7 @@ class WorldHeritageEntity { + public $nameJp; public function __construct( public int $id, public string $officialName, @@ -22,7 +23,7 @@ public function __construct( public ?float $areaHectares = null, public ?float $bufferZoneHectares = null, public ?string $shortDescription = null, - public ?ImageEntityCollection $collection, + public ?ImageEntityCollection $collection = null, public ?string $unescoSiteUrl = null, private array $statePartyCodes = [], private array $statePartyMeta = [] @@ -146,18 +147,22 @@ public function isTransnational(): bool public function getPrimaryStatePartyCode(): ?string { foreach ($this->statePartyMeta as $code => $meta) { - if (!empty($meta['is_primary'])) return $code; + if (!empty($meta['is_primary'])) { + return $code; + } } return $this->statePartyCodes[0] ?? null; } public function getStatePartyCodesOrFallback(): array { - if ($this->statePartyCodes) + if ($this->statePartyCodes) { return $this->statePartyCodes; + } - if (!$this->stateParty) + if (!$this->stateParty) { return []; + } $parts = preg_split('/[;,\s]+/', strtoupper($this->stateParty)); $codes = array_filter($parts, fn($country) => preg_match('/^[A-Z]{3}$/', $country)); diff --git a/src/app/Packages/Domains/WorldHeritageQueryService.php b/src/app/Packages/Domains/WorldHeritageQueryService.php index c83dd57..3b13464 100644 --- a/src/app/Packages/Domains/WorldHeritageQueryService.php +++ b/src/app/Packages/Domains/WorldHeritageQueryService.php @@ -263,7 +263,7 @@ public function getHeritagesByIds(array $ids, int $currentPage, int $perPage): P foreach ($countries as $country) { $code = strtoupper($country->state_party_code); - if (!$code) { + if ($code === '' || $code === '0') { continue; } @@ -396,7 +396,7 @@ private function buildWorldHeritagePayload($heritage): array $statePartiesMeta = []; foreach ($countryRelations as $country) { $code = strtoupper($country->state_party_code); - if (!$code) { + if ($code === '' || $code === '0') { continue; } diff --git a/src/app/Packages/Domains/WorldHeritageReadQueryService.php b/src/app/Packages/Domains/WorldHeritageReadQueryService.php index 5182c39..ca86e35 100644 --- a/src/app/Packages/Domains/WorldHeritageReadQueryService.php +++ b/src/app/Packages/Domains/WorldHeritageReadQueryService.php @@ -14,7 +14,9 @@ public function __construct( public function findByIdsPreserveOrder(array $ids): Collection { - if (empty($ids)) return collect(); + if ($ids === []) { + return collect(); + } $modelsById = WorldHeritage::query() ->select([ diff --git a/src/app/Packages/Features/QueryUseCases/Dto/ImageDtoCollection.php b/src/app/Packages/Features/QueryUseCases/Dto/ImageDtoCollection.php index 2e83161..4e2b88d 100644 --- a/src/app/Packages/Features/QueryUseCases/Dto/ImageDtoCollection.php +++ b/src/app/Packages/Features/QueryUseCases/Dto/ImageDtoCollection.php @@ -34,7 +34,9 @@ public function first(): ?ImageDto public function primary(): ?ImageDto { foreach ($this->images as $img) { - if ($img->isPrimary) return $img; + if ($img->isPrimary) { + return $img; + } } return $this->first(); } diff --git a/src/app/Packages/Features/QueryUseCases/Dto/WorldHeritageDto.php b/src/app/Packages/Features/QueryUseCases/Dto/WorldHeritageDto.php index b9176d0..ddcf7d2 100644 --- a/src/app/Packages/Features/QueryUseCases/Dto/WorldHeritageDto.php +++ b/src/app/Packages/Features/QueryUseCases/Dto/WorldHeritageDto.php @@ -9,11 +9,11 @@ public function __construct( private readonly string $name, private readonly ?string $country = null, private readonly ?string $countryNameJp = null, - private readonly string $region, - private readonly string $category, - private readonly int $yearInscribed, - private readonly ?float $latitude, - private readonly ?float $longitude, + private readonly string $region = '', + private readonly string $category = '', + private readonly int $yearInscribed = 0, + private readonly ?float $latitude = null, + private readonly ?float $longitude = null, private readonly bool $isEndangered = false, private readonly ?string $heritageNameJp = null, private readonly ?string $stateParty = null, @@ -160,12 +160,12 @@ private function getStatePartyCodesOrFallback(): array public function hasImages(): bool { - return $this->images !== null; + return $this->images instanceof \App\Packages\Features\QueryUseCases\Dto\ImageDtoCollection; } public function getImages(): array { - return $this->images ? $this->images->toArray() : []; + return $this->images instanceof \App\Packages\Features\QueryUseCases\Dto\ImageDtoCollection ? $this->images->toArray() : []; } public function getImageUrl(): ?ImageDto @@ -206,7 +206,7 @@ public function toArray(): array if ($this->hasImages()) { $value['images'] = $this->getImages(); - } elseif ($this->imageUrl !== null) { + } elseif ($this->imageUrl instanceof \App\Packages\Features\QueryUseCases\Dto\ImageDto) { $value['thumbnail'] = $this->getImageUrl()->toArray(); } diff --git a/src/app/Packages/Features/QueryUseCases/Factory/Dto/WorldHeritageDetailFactory.php b/src/app/Packages/Features/QueryUseCases/Factory/Dto/WorldHeritageDetailFactory.php index 6d4b08e..72a2b9d 100644 --- a/src/app/Packages/Features/QueryUseCases/Factory/Dto/WorldHeritageDetailFactory.php +++ b/src/app/Packages/Features/QueryUseCases/Factory/Dto/WorldHeritageDetailFactory.php @@ -82,13 +82,13 @@ private static function normalizeStateParties(array $data): array $fieldValue = [$fieldValue]; } - if (is_array($fieldValue) && !empty($fieldValue)) { + if (is_array($fieldValue) && $fieldValue !== []) { $codes = $fieldValue; break; } } - if (empty($codes) && !empty($data['state_party'])) { + if ($codes === [] && !empty($data['state_party'])) { $codes = self::extractIso3CodesFromString((string)$data['state_party']); } @@ -120,10 +120,8 @@ private static function sanitizeIso3Codes(array $rawCodes): array foreach ($rawCodes as $rawCode) { $iso3 = strtoupper(trim((string)$rawCode)); - if (preg_match('/^[A-Z]{3}$/', $iso3)) { - if (!in_array($iso3, $normalizedCodes, true)) { - $normalizedCodes[] = $iso3; - } + if (preg_match('/^[A-Z]{3}$/', $iso3) && !in_array($iso3, $normalizedCodes, true)) { + $normalizedCodes[] = $iso3; } } diff --git a/src/app/Packages/Features/QueryUseCases/Factory/Dto/WorldHeritageSummaryFactory.php b/src/app/Packages/Features/QueryUseCases/Factory/Dto/WorldHeritageSummaryFactory.php index 382e09e..0f868f6 100644 --- a/src/app/Packages/Features/QueryUseCases/Factory/Dto/WorldHeritageSummaryFactory.php +++ b/src/app/Packages/Features/QueryUseCases/Factory/Dto/WorldHeritageSummaryFactory.php @@ -93,13 +93,13 @@ private static function normalizeStateParties(array $data): array if (is_string($value)) { $value = [$value]; } - if (is_array($value) && !empty($value)) { + if (is_array($value) && $value !== []) { $rawCodes = $value; break; } } - if (empty($rawCodes) && !empty($data['state_party'])) { + if ($rawCodes === [] && !empty($data['state_party'])) { $rawCodes = self::extractIso3CodesFromString((string)$data['state_party']); } @@ -130,10 +130,8 @@ private static function sanitizeIso3Codes(array $rawCodes): array foreach ($rawCodes as $rawCode) { $iso3 = strtoupper(trim((string)$rawCode)); - if (preg_match('/^[A-Z]{3}$/', $iso3)) { - if (!in_array($iso3, $normalizedCodes, true)) { - $normalizedCodes[] = $iso3; - } + if (preg_match('/^[A-Z]{3}$/', $iso3) && !in_array($iso3, $normalizedCodes, true)) { + $normalizedCodes[] = $iso3; } } diff --git a/src/app/Packages/Features/QueryUseCases/ListQuery/WorldHeritageListQuery.php b/src/app/Packages/Features/QueryUseCases/ListQuery/WorldHeritageListQuery.php index c30591d..0f8fd56 100644 --- a/src/app/Packages/Features/QueryUseCases/ListQuery/WorldHeritageListQuery.php +++ b/src/app/Packages/Features/QueryUseCases/ListQuery/WorldHeritageListQuery.php @@ -124,11 +124,13 @@ public function getStatePartiesMeta(): array public function getStatePartyCodesOrFallback(): array { - if ($this->state_parties_codes) + if ($this->state_parties_codes) { return $this->state_parties_codes; + } - if (!$this->state_party) + if (!$this->state_party) { return []; + } $parts = preg_split('/[;,\s]+/', strtoupper($this->state_party)); $codes = array_filter($parts, fn($country) => preg_match('/^[A-Z]{2}$/', $country)); diff --git a/src/app/Packages/Features/QueryUseCases/Tests/Dto/WorldHeritageDtoCollectionTest.php b/src/app/Packages/Features/QueryUseCases/Tests/Dto/WorldHeritageDtoCollectionTest.php index 7e0813c..29bef81 100644 --- a/src/app/Packages/Features/QueryUseCases/Tests/Dto/WorldHeritageDtoCollectionTest.php +++ b/src/app/Packages/Features/QueryUseCases/Tests/Dto/WorldHeritageDtoCollectionTest.php @@ -39,7 +39,7 @@ private function refresh(): void } } - private static function arrayData(): array + private function arrayData(): array { return [ [ @@ -133,7 +133,7 @@ private static function arrayData(): array public function test_collection_check_type(): void { - $data = self::arrayData(); + $data = $this->arrayData(); $dtoCollection = WorldHeritageDtoCollectionFactory::build($data); $this->assertInstanceOf(WorldHeritageDtoCollection::class, $dtoCollection); @@ -141,7 +141,7 @@ public function test_collection_check_type(): void public function test_collection_check_value_without_thumbnail(): void { - $data = self::arrayData(); + $data = $this->arrayData(); $dtoCollection = WorldHeritageDtoCollectionFactory::build($data); $expectFirstCode = [ @@ -172,7 +172,7 @@ public function test_collection_check_value_without_thumbnail(): void ]; foreach ($dtoCollection->getHeritages() as $index => $dto) { - $eachData = self::arrayData()[$index]; + $eachData = $this->arrayData()[$index]; $this->assertSame($eachData['id'], $dto->getId()); $this->assertSame($eachData['official_name'], $dto->getOfficialName()); @@ -200,7 +200,7 @@ public function test_collection_check_value_without_thumbnail(): void public function test_summary_array_matches_expected_with_thumbnail(): void { - $data = self::arrayData(); + $data = $this->arrayData(); $dtoCollection = WorldHeritageDtoCollectionFactory::build($data); $summary = $dtoCollection->toSummaryArray(); diff --git a/src/app/Packages/Features/QueryUseCases/Tests/Dto/WorldHeritageDtoDetailFactoryTest.php b/src/app/Packages/Features/QueryUseCases/Tests/Dto/WorldHeritageDtoDetailFactoryTest.php index 9942cb5..bda335c 100644 --- a/src/app/Packages/Features/QueryUseCases/Tests/Dto/WorldHeritageDtoDetailFactoryTest.php +++ b/src/app/Packages/Features/QueryUseCases/Tests/Dto/WorldHeritageDtoDetailFactoryTest.php @@ -18,7 +18,7 @@ protected function tearDown(): void parent::tearDown(); } - private static function arrayData(): array + private function arrayData(): array { return [ 'id' => 1133, @@ -97,15 +97,15 @@ private static function arrayData(): array public function test_check_return_data_type(): void { - $result = WorldHeritageDetailFactory::build(self::arrayData()); + $result = WorldHeritageDetailFactory::build($this->arrayData()); $this->assertInstanceOf(WorldHeritageDto::class, $result); } public function test_check_return_data_value(): void { - $result = WorldHeritageDetailFactory::build(self::arrayData()); - $input = self::arrayData(); + $result = WorldHeritageDetailFactory::build($this->arrayData()); + $input = $this->arrayData(); $this->assertSame($input['id'], $result->getId()); $this->assertSame($input['official_name'], $result->getOfficialName()); diff --git a/src/app/Packages/Features/QueryUseCases/Tests/Dto/WorldHeritageDtoSummaryFactoryTest.php b/src/app/Packages/Features/QueryUseCases/Tests/Dto/WorldHeritageDtoSummaryFactoryTest.php index 80e5177..5de2346 100644 --- a/src/app/Packages/Features/QueryUseCases/Tests/Dto/WorldHeritageDtoSummaryFactoryTest.php +++ b/src/app/Packages/Features/QueryUseCases/Tests/Dto/WorldHeritageDtoSummaryFactoryTest.php @@ -10,7 +10,7 @@ class WorldHeritageDtoSummaryFactoryTest extends TestCase { public function test_build_returns_dto_no_country_value(): void { - $result = WorldHeritageSummaryFactory::build(self::arrayDataNoStateParty()); + $result = WorldHeritageSummaryFactory::build($this->arrayDataNoStateParty()); $this->assertInstanceOf(WorldHeritageDto::class, $result); } @@ -24,7 +24,7 @@ public function test_build_returns_dto_with_much_countries(): void public function test_build_returns_dto_with_no_country_values(): void { - $input = self::arrayDataNoStateParty(); + $input = $this->arrayDataNoStateParty(); $dto = WorldHeritageSummaryFactory::build($input); $this->assertSame($input['id'], $dto->getId()); @@ -99,13 +99,19 @@ private function assertNullOrZeroEquivalent( private function normalizeNullableFloat(float|int|string|null $v): ?float { - if ($v === null) return null; + if ($v === null) { + return null; + } // 数値文字列も許容(DB/配列が文字列で来るケース対策) if (is_string($v)) { $s = trim($v); - if ($s === '') return null; - if (!is_numeric($s)) return null; + if ($s === '') { + return null; + } + if (!is_numeric($s)) { + return null; + } return (float) $s; } @@ -189,7 +195,7 @@ private static function expectedTransnationalMeta(): array return $meta; } - private static function arrayDataNoStateParty(): array + private function arrayDataNoStateParty(): array { return [ 'id' => 148, diff --git a/src/app/Packages/Features/QueryUseCases/Tests/ImageDtoCollectionTest.php b/src/app/Packages/Features/QueryUseCases/Tests/ImageDtoCollectionTest.php index d01478c..7f818b9 100644 --- a/src/app/Packages/Features/QueryUseCases/Tests/ImageDtoCollectionTest.php +++ b/src/app/Packages/Features/QueryUseCases/Tests/ImageDtoCollectionTest.php @@ -18,7 +18,7 @@ protected function tearDown(): void parent::tearDown(); } - private static function arrayMultiData(): array + private function arrayMultiData(): array { return [ [ @@ -45,7 +45,7 @@ public function test_image_dto_collection_check_type(): void { $collection = new ImageDtoCollection(); - foreach (self::arrayMultiData() as $data) { + foreach ($this->arrayMultiData() as $data) { $dto = new ImageDto( $data['id'], $data['url'], @@ -62,7 +62,7 @@ public function test_check_image_collection_value(): void { $collection = new ImageDtoCollection(); - foreach (self::arrayMultiData() as $data) { + foreach ($this->arrayMultiData() as $data) { $dto = new ImageDto( $data['id'], $data['url'], @@ -75,10 +75,10 @@ public function test_check_image_collection_value(): void $this->assertCount(3, $collection->toArray()); foreach ($collection->toArray() as $index => $item) { - $this->assertEquals(self::arrayMultiData()[$index]['id'], $item['id']); - $this->assertEquals(self::arrayMultiData()[$index]['url'], $item['url']); - $this->assertEquals(self::arrayMultiData()[$index]['sortOrder'], $item['sort_order']); - $this->assertEquals(self::arrayMultiData()[$index]['isPrimary'], $item['is_primary']); + $this->assertEquals($this->arrayMultiData()[$index]['id'], $item['id']); + $this->assertEquals($this->arrayMultiData()[$index]['url'], $item['url']); + $this->assertEquals($this->arrayMultiData()[$index]['sortOrder'], $item['sort_order']); + $this->assertEquals($this->arrayMultiData()[$index]['isPrimary'], $item['is_primary']); } } } \ No newline at end of file diff --git a/src/app/Packages/Features/QueryUseCases/Tests/ImageDtoTest.php b/src/app/Packages/Features/QueryUseCases/Tests/ImageDtoTest.php index 68c883e..3804609 100644 --- a/src/app/Packages/Features/QueryUseCases/Tests/ImageDtoTest.php +++ b/src/app/Packages/Features/QueryUseCases/Tests/ImageDtoTest.php @@ -17,7 +17,7 @@ protected function tearDown(): void parent::tearDown(); } - private static function arrayData(): array + private function arrayData(): array { return [ 'id' => 9, @@ -30,10 +30,10 @@ private static function arrayData(): array public function test_image_dto_check_type(): void { $dto = new ImageDto( - self::arrayData()['id'], - self::arrayData()['url'], - self::arrayData()['sortOrder'], - self::arrayData()['isPrimary'], + $this->arrayData()['id'], + $this->arrayData()['url'], + $this->arrayData()['sortOrder'], + $this->arrayData()['isPrimary'], ); $this->assertInstanceOf(ImageDto::class, $dto); @@ -42,15 +42,15 @@ public function test_image_dto_check_type(): void public function test_image_dto_check_value(): void { $dto = new ImageDto( - self::arrayData()['id'], - self::arrayData()['url'], - self::arrayData()['sortOrder'], - self::arrayData()['isPrimary'], + $this->arrayData()['id'], + $this->arrayData()['url'], + $this->arrayData()['sortOrder'], + $this->arrayData()['isPrimary'], ); - $this->assertSame(self::arrayData()['id'], $dto->getId()); - $this->assertSame(self::arrayData()['url'], $dto->getUrl()); - $this->assertSame(self::arrayData()['sortOrder'], $dto->getSortOrder()); - $this->assertSame(self::arrayData()['isPrimary'], $dto->getIsPrimary()); + $this->assertSame($this->arrayData()['id'], $dto->getId()); + $this->assertSame($this->arrayData()['url'], $dto->getUrl()); + $this->assertSame($this->arrayData()['sortOrder'], $dto->getSortOrder()); + $this->assertSame($this->arrayData()['isPrimary'], $dto->getIsPrimary()); } } \ No newline at end of file diff --git a/src/app/Packages/Features/QueryUseCases/Tests/ListQuery/UpdateWorldHeritageListQueryCollectionFactoryTest.php b/src/app/Packages/Features/QueryUseCases/Tests/ListQuery/UpdateWorldHeritageListQueryCollectionFactoryTest.php index bcbecf7..d77eab4 100644 --- a/src/app/Packages/Features/QueryUseCases/Tests/ListQuery/UpdateWorldHeritageListQueryCollectionFactoryTest.php +++ b/src/app/Packages/Features/QueryUseCases/Tests/ListQuery/UpdateWorldHeritageListQueryCollectionFactoryTest.php @@ -161,7 +161,7 @@ private function requestData(): array ]; } - private static function wrongData(): array + private function wrongData(): array { return [ [ @@ -270,6 +270,6 @@ public function test_check_list_query_value(): void public function test_wrong_data(): void { $this->expectException(DomainException::class); - UpdateWorldHeritageListQueryCollectionFactory::build(self::wrongData()); + UpdateWorldHeritageListQueryCollectionFactory::build($this->wrongData()); } } \ No newline at end of file diff --git a/src/app/Packages/Features/QueryUseCases/Tests/UseCase/GetWorldHeritageByIdUseCaseTest.php b/src/app/Packages/Features/QueryUseCases/Tests/UseCase/GetWorldHeritageByIdUseCaseTest.php index b1f9a39..f1d1c63 100644 --- a/src/app/Packages/Features/QueryUseCases/Tests/UseCase/GetWorldHeritageByIdUseCaseTest.php +++ b/src/app/Packages/Features/QueryUseCases/Tests/UseCase/GetWorldHeritageByIdUseCaseTest.php @@ -51,34 +51,34 @@ private function mockQueryService(): WorldHeritageQueryServiceInterface $queryService ->shouldReceive('getHeritageById') ->andReturn(new WorldHeritageDto( - self::arrayData()['id'], - self::arrayData()['official_name'], - self::arrayData()['name'], - self::arrayData()['country'], - self::arrayData()['country_name_jp'] ?? null, - self::arrayData()['region'], - self::arrayData()['category'], - self::arrayData()['year_inscribed'], - self::arrayData()['latitude'], - self::arrayData()['longitude'], - self::arrayData()['is_endangered'], - self::arrayData()['heritage_name_jp'] ?? null, - self::arrayData()['state_party'], - self::arrayData()['criteria'], - self::arrayData()['area_hectares'], - self::arrayData()['buffer_zone_hectares'], - self::arrayData()['short_description'], + $this->arrayData()['id'], + $this->arrayData()['official_name'], + $this->arrayData()['name'], + $this->arrayData()['country'], + $this->arrayData()['country_name_jp'] ?? null, + $this->arrayData()['region'], + $this->arrayData()['category'], + $this->arrayData()['year_inscribed'], + $this->arrayData()['latitude'], + $this->arrayData()['longitude'], + $this->arrayData()['is_endangered'], + $this->arrayData()['heritage_name_jp'] ?? null, + $this->arrayData()['state_party'], + $this->arrayData()['criteria'], + $this->arrayData()['area_hectares'], + $this->arrayData()['buffer_zone_hectares'], + $this->arrayData()['short_description'], null, null, - self::arrayData()['unesco_site_url'], - self::arrayData()['state_party_codes'], - self::arrayData()['state_parties_meta'], + $this->arrayData()['unesco_site_url'], + $this->arrayData()['state_party_codes'], + $this->arrayData()['state_parties_meta'], )); return $queryService; } - private static function arrayData(): array + private function arrayData(): array { return [ 'id' => 1133, @@ -145,7 +145,7 @@ public function test_use_case(): void { $useCase = new GetWorldHeritageByIdUseCase($this->mockQueryService()); - $result = $useCase->handle(self::arrayData()['id']); + $result = $useCase->handle($this->arrayData()['id']); $this->assertInstanceOf(WorldHeritageDto::class, $result); } diff --git a/src/app/Packages/Features/QueryUseCases/Tests/ViewModel/WorldHeritageDetailViewModelFactoryTest.php b/src/app/Packages/Features/QueryUseCases/Tests/ViewModel/WorldHeritageDetailViewModelFactoryTest.php index ef881ae..ce2b87d 100644 --- a/src/app/Packages/Features/QueryUseCases/Tests/ViewModel/WorldHeritageDetailViewModelFactoryTest.php +++ b/src/app/Packages/Features/QueryUseCases/Tests/ViewModel/WorldHeritageDetailViewModelFactoryTest.php @@ -19,7 +19,7 @@ protected function tearDown(): void parent::tearDown(); } - private static function arrayData(): array + private function arrayData(): array { return [ 'id' => 1133, @@ -87,83 +87,83 @@ private function mockDto(): WorldHeritageDto $dto ->shouldReceive('getId') - ->andReturn(self::arrayData()['id']); + ->andReturn($this->arrayData()['id']); $dto ->shouldReceive('getOfficialName') - ->andReturn(self::arrayData()['official_name']); + ->andReturn($this->arrayData()['official_name']); $dto ->shouldReceive('getName') - ->andReturn(self::arrayData()['name']); + ->andReturn($this->arrayData()['name']); $dto ->shouldReceive('getHeritageNameJp') - ->andReturn(self::arrayData()['heritage_name_jp']); + ->andReturn($this->arrayData()['heritage_name_jp']); $dto ->shouldReceive('getCountry') - ->andReturn(self::arrayData()['country']); + ->andReturn($this->arrayData()['country']); $dto ->shouldReceive('getRegion') - ->andReturn(self::arrayData()['region']); + ->andReturn($this->arrayData()['region']); $dto ->shouldReceive('getStateParty') - ->andReturn(self::arrayData()['state_party']); + ->andReturn($this->arrayData()['state_party']); $dto ->shouldReceive('getCategory') - ->andReturn(self::arrayData()['category']); + ->andReturn($this->arrayData()['category']); $dto ->shouldReceive('getCriteria') - ->andReturn(self::arrayData()['criteria']); + ->andReturn($this->arrayData()['criteria']); $dto ->shouldReceive('getYearInscribed') - ->andReturn(self::arrayData()['year_inscribed']); + ->andReturn($this->arrayData()['year_inscribed']); $dto ->shouldReceive('getAreaHectares') - ->andReturn(self::arrayData()['area_hectares']); + ->andReturn($this->arrayData()['area_hectares']); $dto ->shouldReceive('getBufferZoneHectares') - ->andReturn(self::arrayData()['buffer_zone_hectares']); + ->andReturn($this->arrayData()['buffer_zone_hectares']); $dto ->shouldReceive('isEndangered') - ->andReturn(self::arrayData()['is_endangered']); + ->andReturn($this->arrayData()['is_endangered']); $dto ->shouldReceive('getLatitude') - ->andReturn(self::arrayData()['latitude']); + ->andReturn($this->arrayData()['latitude']); $dto ->shouldReceive('getLongitude') - ->andReturn(self::arrayData()['longitude']); + ->andReturn($this->arrayData()['longitude']); $dto ->shouldReceive('getShortDescription') - ->andReturn(self::arrayData()['short_description']); + ->andReturn($this->arrayData()['short_description']); $dto ->shouldReceive('getUnescoSiteUrl') - ->andReturn(self::arrayData()['unesco_site_url']); + ->andReturn($this->arrayData()['unesco_site_url']); $dto ->shouldReceive('getStatePartyCodes') - ->andReturn(self::arrayData()['state_parties']); + ->andReturn($this->arrayData()['state_parties']); $dto ->shouldReceive('getStatePartiesMeta') - ->andReturn(self::arrayData()['state_parties_meta'] ?? []); + ->andReturn($this->arrayData()['state_parties_meta'] ?? []); $dto ->shouldReceive('getImages') - ->andReturn(self::arrayData()['images'] ?? []); + ->andReturn($this->arrayData()['images'] ?? []); return $dto; } @@ -183,7 +183,7 @@ public function test_view_model_check_value(): void $this->mockDto() ); - foreach (self::arrayData() as $key => $value) { + foreach ($this->arrayData() as $key => $value) { if ($key === 'is_endangered') { continue; } elseif ( $key === 'state_parties') { diff --git a/src/app/Packages/Features/QueryUseCases/Tests/ViewModel/WorldHeritageSummaryViewModelFactoryTest.php b/src/app/Packages/Features/QueryUseCases/Tests/ViewModel/WorldHeritageSummaryViewModelFactoryTest.php index 3879e7f..2f111ef 100644 --- a/src/app/Packages/Features/QueryUseCases/Tests/ViewModel/WorldHeritageSummaryViewModelFactoryTest.php +++ b/src/app/Packages/Features/QueryUseCases/Tests/ViewModel/WorldHeritageSummaryViewModelFactoryTest.php @@ -21,7 +21,7 @@ protected function tearDown(): void parent::tearDown(); } - private static function arrayData(): array + private function arrayData(): array { return [ 'id' => 1133, @@ -74,7 +74,7 @@ private function mockDtoCollection(): WorldHeritageDtoCollection $mock = Mockery::mock(WorldHeritageDtoCollection::class); $mock->shouldReceive('toArray') - ->andReturn(self::arrayData()); + ->andReturn($this->arrayData()); return $mock; } @@ -84,70 +84,70 @@ private function mockDto(): WorldHeritageDto $mock = Mockery::mock(WorldHeritageDto::class); $mock->shouldReceive('getId') - ->andReturn(self::arrayData()['id']); + ->andReturn($this->arrayData()['id']); $mock->shouldReceive('getOfficialName') - ->andReturn(self::arrayData()['official_name']); + ->andReturn($this->arrayData()['official_name']); $mock->shouldReceive('getName') - ->andReturn(self::arrayData()['name']); + ->andReturn($this->arrayData()['name']); $mock->shouldReceive('getCountry') - ->andReturn(self::arrayData()['country']); + ->andReturn($this->arrayData()['country']); $mock->shouldReceive('getRegion') - ->andReturn(self::arrayData()['region']); + ->andReturn($this->arrayData()['region']); $mock->shouldReceive('getCategory') - ->andReturn(self::arrayData()['category']); + ->andReturn($this->arrayData()['category']); $mock->shouldReceive('getYearInscribed') - ->andReturn(self::arrayData()['year_inscribed']); + ->andReturn($this->arrayData()['year_inscribed']); $mock->shouldReceive('getLatitude') - ->andReturn(self::arrayData()['latitude']); + ->andReturn($this->arrayData()['latitude']); $mock->shouldReceive('getLongitude') - ->andReturn(self::arrayData()['longitude']); + ->andReturn($this->arrayData()['longitude']); $mock->shouldReceive('isEndangered') - ->andReturn(self::arrayData()['is_endangered']); + ->andReturn($this->arrayData()['is_endangered']); $mock->shouldReceive('getHeritageNameJp') - ->andReturn(self::arrayData()['heritage_name_jp']); + ->andReturn($this->arrayData()['heritage_name_jp']); $mock->shouldReceive('getStateParty') - ->andReturn(self::arrayData()['state_party']); + ->andReturn($this->arrayData()['state_party']); $mock->shouldReceive('getCriteria') - ->andReturn(self::arrayData()['criteria']); + ->andReturn($this->arrayData()['criteria']); $mock->shouldReceive('getUnescoSiteUrl') - ->andReturn(self::arrayData()['unesco_site_url']); + ->andReturn($this->arrayData()['unesco_site_url']); $mock->shouldReceive('getAreaHectares') - ->andReturn(self::arrayData()['area_hectares']); + ->andReturn($this->arrayData()['area_hectares']); $mock->shouldReceive('getBufferZoneHectares') - ->andReturn(self::arrayData()['buffer_zone_hectares']); + ->andReturn($this->arrayData()['buffer_zone_hectares']); $mock->shouldReceive('getShortDescription') - ->andReturn(self::arrayData()['short_description']); + ->andReturn($this->arrayData()['short_description']); $mock->shouldReceive('getStatePartyCodes') - ->andReturn(self::arrayData()['state_parties_codes']); + ->andReturn($this->arrayData()['state_parties_codes']); $mock->shouldReceive('getStatePartiesMeta') - ->andReturn(self::arrayData()['state_parties_meta']); + ->andReturn($this->arrayData()['state_parties_meta']); $mock->shouldReceive('getThumbnailUrl') - ->andReturn(self::arrayData()['thumbnail_url']); + ->andReturn($this->arrayData()['thumbnail_url']); $mock->shouldReceive('getCountryNameJp') - ->andReturn(self::arrayData()['country_name_jp']); + ->andReturn($this->arrayData()['country_name_jp']); $mock->shouldReceive('getPrimaryStatePartyCode') - ->andReturn(self::arrayData()['state_parties_codes'][4]); + ->andReturn($this->arrayData()['state_parties_codes'][4]); $mock->shouldReceive('getImages') ->andReturn([ @@ -181,26 +181,26 @@ public function test_check_view_model_value(): void $resultArray = $result->toArray(); - $this->assertEquals(self::arrayData()['id'], $resultArray['id']); - $this->assertEquals(self::arrayData()['official_name'], $resultArray['official_name']); - $this->assertEquals(self::arrayData()['name'], $resultArray['name']); - $this->assertEquals(self::arrayData()['country'], $resultArray['country']); - $this->assertEquals(self::arrayData()['region'], $resultArray['region']); - $this->assertEquals(self::arrayData()['category'], $resultArray['category']); - $this->assertEquals(self::arrayData()['year_inscribed'], $resultArray['year_inscribed']); - $this->assertEquals(self::arrayData()['latitude'], $resultArray['latitude']); - $this->assertEquals(self::arrayData()['longitude'], $resultArray['longitude']); - $this->assertEquals(self::arrayData()['is_endangered'], $resultArray['is_endangered']); - $this->assertEquals(self::arrayData()['heritage_name_jp'], $resultArray['heritage_name_jp']); - $this->assertEquals(self::arrayData()['state_party'], $resultArray['state_party']); - $this->assertEquals(self::arrayData()['criteria'], $resultArray['criteria']); - $this->assertEquals(self::arrayData()['unesco_site_url'], $resultArray['unesco_site_url']); - $this->assertEquals(self::arrayData()['area_hectares'], $resultArray['area_hectares']); - $this->assertEquals(self::arrayData()['buffer_zone_hectares'], $resultArray['buffer_zone_hectares']); - $this->assertEquals(self::arrayData()['short_description'], $resultArray['short_description']); - $this->assertEquals(self::arrayData()['state_parties_codes'], $resultArray['state_party_codes']); - $this->assertEquals(self::arrayData()['state_parties_meta'], $resultArray['state_parties_meta']); - $this->assertEquals(self::arrayData()['thumbnail_url'], $resultArray['thumbnail_url']); - $this->assertEquals(self::arrayData()['country_name_jp'], $resultArray['country_name_jp']); + $this->assertEquals($this->arrayData()['id'], $resultArray['id']); + $this->assertEquals($this->arrayData()['official_name'], $resultArray['official_name']); + $this->assertEquals($this->arrayData()['name'], $resultArray['name']); + $this->assertEquals($this->arrayData()['country'], $resultArray['country']); + $this->assertEquals($this->arrayData()['region'], $resultArray['region']); + $this->assertEquals($this->arrayData()['category'], $resultArray['category']); + $this->assertEquals($this->arrayData()['year_inscribed'], $resultArray['year_inscribed']); + $this->assertEquals($this->arrayData()['latitude'], $resultArray['latitude']); + $this->assertEquals($this->arrayData()['longitude'], $resultArray['longitude']); + $this->assertEquals($this->arrayData()['is_endangered'], $resultArray['is_endangered']); + $this->assertEquals($this->arrayData()['heritage_name_jp'], $resultArray['heritage_name_jp']); + $this->assertEquals($this->arrayData()['state_party'], $resultArray['state_party']); + $this->assertEquals($this->arrayData()['criteria'], $resultArray['criteria']); + $this->assertEquals($this->arrayData()['unesco_site_url'], $resultArray['unesco_site_url']); + $this->assertEquals($this->arrayData()['area_hectares'], $resultArray['area_hectares']); + $this->assertEquals($this->arrayData()['buffer_zone_hectares'], $resultArray['buffer_zone_hectares']); + $this->assertEquals($this->arrayData()['short_description'], $resultArray['short_description']); + $this->assertEquals($this->arrayData()['state_parties_codes'], $resultArray['state_party_codes']); + $this->assertEquals($this->arrayData()['state_parties_meta'], $resultArray['state_parties_meta']); + $this->assertEquals($this->arrayData()['thumbnail_url'], $resultArray['thumbnail_url']); + $this->assertEquals($this->arrayData()['country_name_jp'], $resultArray['country_name_jp']); } } \ No newline at end of file diff --git a/src/app/Packages/Features/QueryUseCases/Tests/ViewModel/WorldHeritageViewModelCollectionFactoryTest.php b/src/app/Packages/Features/QueryUseCases/Tests/ViewModel/WorldHeritageViewModelCollectionFactoryTest.php index 25885d5..ad97a17 100644 --- a/src/app/Packages/Features/QueryUseCases/Tests/ViewModel/WorldHeritageViewModelCollectionFactoryTest.php +++ b/src/app/Packages/Features/QueryUseCases/Tests/ViewModel/WorldHeritageViewModelCollectionFactoryTest.php @@ -21,7 +21,7 @@ protected function tearDown(): void parent::tearDown(); } - private static function arrayData(): array + private function arrayData(): array { return [ [ @@ -134,7 +134,7 @@ private function mockDtoCollection(): WorldHeritageDtoCollection statePartyCodes: $data['state_party_codes'] ?? ($data['state_parties'] ?? []), statePartiesMeta: $data['state_parties_meta'] ?? [] ); - }, self::arrayData()); + }, $this->arrayData()); return new WorldHeritageDtoCollection(...$dtos); } @@ -159,29 +159,29 @@ public function test_view_model_collection_check_value(): void foreach ($result->toArray() as $key => $value) { - $expectedCodes = self::arrayData()[$key]['state_party_codes'] ?? self::arrayData()[$key]['state_parties'] ?? []; + $expectedCodes = $this->arrayData()[$key]['state_party_codes'] ?? $this->arrayData()[$key]['state_parties'] ?? []; - $this->assertEquals(self::arrayData()[$key]['id'], $value['id']); - $this->assertEquals(self::arrayData()[$key]['official_name'], $value['official_name']); - $this->assertEquals(self::arrayData()[$key]['name'], $value['name']); - $this->assertEquals(self::arrayData()[$key]['heritage_name_jp'], $value['heritage_name_jp']); - $this->assertEquals(self::arrayData()[$key]['country'], $value['country']); - $this->assertEquals(self::arrayData()[$key]['country_name_jp'], $value['country_name_jp']); - $this->assertEquals(self::arrayData()[$key]['region'], $value['region']); - $this->assertEquals(self::arrayData()[$key]['state_party'], $value['state_party']); - $this->assertEquals(self::arrayData()[$key]['category'], $value['category']); - $this->assertEquals(self::arrayData()[$key]['criteria'], $value['criteria']); - $this->assertEquals(self::arrayData()[$key]['year_inscribed'], $value['year_inscribed']); - $this->assertEquals(self::arrayData()[$key]['area_hectares'], $value['area_hectares']); - $this->assertEquals(self::arrayData()[$key]['buffer_zone_hectares'], $value['buffer_zone_hectares']); - $this->assertEquals(self::arrayData()[$key]['is_endangered'], $value['is_endangered']); - $this->assertEquals(self::arrayData()[$key]['latitude'], $value['latitude']); - $this->assertEquals(self::arrayData()[$key]['longitude'], $value['longitude']); - $this->assertEquals(self::arrayData()[$key]['short_description'], $value['short_description']); - $this->assertEquals(self::arrayData()[$key]['thumbnail_url'], $value['thumbnail_url']); + $this->assertEquals($this->arrayData()[$key]['id'], $value['id']); + $this->assertEquals($this->arrayData()[$key]['official_name'], $value['official_name']); + $this->assertEquals($this->arrayData()[$key]['name'], $value['name']); + $this->assertEquals($this->arrayData()[$key]['heritage_name_jp'], $value['heritage_name_jp']); + $this->assertEquals($this->arrayData()[$key]['country'], $value['country']); + $this->assertEquals($this->arrayData()[$key]['country_name_jp'], $value['country_name_jp']); + $this->assertEquals($this->arrayData()[$key]['region'], $value['region']); + $this->assertEquals($this->arrayData()[$key]['state_party'], $value['state_party']); + $this->assertEquals($this->arrayData()[$key]['category'], $value['category']); + $this->assertEquals($this->arrayData()[$key]['criteria'], $value['criteria']); + $this->assertEquals($this->arrayData()[$key]['year_inscribed'], $value['year_inscribed']); + $this->assertEquals($this->arrayData()[$key]['area_hectares'], $value['area_hectares']); + $this->assertEquals($this->arrayData()[$key]['buffer_zone_hectares'], $value['buffer_zone_hectares']); + $this->assertEquals($this->arrayData()[$key]['is_endangered'], $value['is_endangered']); + $this->assertEquals($this->arrayData()[$key]['latitude'], $value['latitude']); + $this->assertEquals($this->arrayData()[$key]['longitude'], $value['longitude']); + $this->assertEquals($this->arrayData()[$key]['short_description'], $value['short_description']); + $this->assertEquals($this->arrayData()[$key]['thumbnail_url'], $value['thumbnail_url']); $this->assertSame($expectedCodes, $value['state_party_codes']); - $this->assertEquals(self::arrayData()[$key]['state_parties_meta'], $value['state_parties_meta']); - $this->assertEquals(self::arrayData()[$key]['unesco_site_url'], $value['unesco_site_url']); + $this->assertEquals($this->arrayData()[$key]['state_parties_meta'], $value['state_parties_meta']); + $this->assertEquals($this->arrayData()[$key]['unesco_site_url'], $value['unesco_site_url']); } } } \ No newline at end of file diff --git a/src/app/Packages/Features/QueryUseCases/UseCase/Image/ImageUploadUseCase.php b/src/app/Packages/Features/QueryUseCases/UseCase/Image/ImageUploadUseCase.php index 1ebb3de..556728b 100644 --- a/src/app/Packages/Features/QueryUseCases/UseCase/Image/ImageUploadUseCase.php +++ b/src/app/Packages/Features/QueryUseCases/UseCase/Image/ImageUploadUseCase.php @@ -48,6 +48,7 @@ public function buildImageCollectionAfterPut(array $confirmed): ImageEntityColle } $images[] = new ImageEntity( id: null, + sortOrder: (int)$row['sort_order'], worldHeritageId: null, disk: 'gcs', path: $key, @@ -55,7 +56,6 @@ public function buildImageCollectionAfterPut(array $confirmed): ImageEntityColle height: null, format: pathinfo($key, PATHINFO_EXTENSION) ?: null, checksum: null, - sortOrder: (int)$row['sort_order'], alt: $row['alt'] ?? null, credit: $row['credit'] ?? null ); diff --git a/src/app/Packages/Features/Tests/GetWorldHeritageByIdTest.php b/src/app/Packages/Features/Tests/GetWorldHeritageByIdTest.php index 95b8756..5092c82 100644 --- a/src/app/Packages/Features/Tests/GetWorldHeritageByIdTest.php +++ b/src/app/Packages/Features/Tests/GetWorldHeritageByIdTest.php @@ -30,7 +30,7 @@ public function search($query, int $currentPage, int $perPage): HeritageSearchRe }; }); - $this->id = self::arrayData()['id']; + $this->id = $this->arrayData()['id']; $seeder = new DatabaseSeeder(); $seeder->run(); @@ -54,7 +54,7 @@ private function refresh(): void } } - private static function arrayData(): array + private function arrayData(): array { return [ 'id' => 1133, @@ -175,7 +175,7 @@ public function test_feature_test_ok(): void $this->assertIsArray($data['images']); - if (!empty($data['images'])) { + if (isset($data['images']) && $data['images'] !== []) { $this->assertArrayHasKey('id', $data['images'][0]); $this->assertArrayHasKey('url', $data['images'][0]); $this->assertArrayHasKey('sort_order', $data['images'][0]); diff --git a/src/app/Providers/AppServiceProvider.php b/src/app/Providers/AppServiceProvider.php index aad23e7..c3847f2 100644 --- a/src/app/Providers/AppServiceProvider.php +++ b/src/app/Providers/AppServiceProvider.php @@ -37,10 +37,12 @@ public function boot(): void { Storage::extend('gcs', function ($app, $config) { $clientConfig = []; - if (!empty($config['project_id'])) + if (!empty($config['project_id'])) { $clientConfig['projectId'] = $config['project_id']; - if (!empty($config['key_file'])) + } + if (!empty($config['key_file'])) { $clientConfig['keyFilePath'] = $config['key_file']; + } $storageClient = new StorageClient($clientConfig); $bucket = $storageClient->bucket($config['bucket']); diff --git a/src/app/Support/CountryCodeNormalizer.php b/src/app/Support/CountryCodeNormalizer.php index b88a555..a85ed88 100644 --- a/src/app/Support/CountryCodeNormalizer.php +++ b/src/app/Support/CountryCodeNormalizer.php @@ -16,7 +16,9 @@ public function toIso3List(array $codesOrNames): array foreach ($codesOrNames as $v) { $raw = trim((string) $v); - if ($raw === '') continue; + if ($raw === '') { + continue; + } $key = strtoupper($raw); diff --git a/src/database/seeders/CountrySeeder.php b/src/database/seeders/CountrySeeder.php index b9ad6c2..82df911 100644 --- a/src/database/seeders/CountrySeeder.php +++ b/src/database/seeders/CountrySeeder.php @@ -130,7 +130,9 @@ public function run(): void foreach ($regionsIso2 as $regionName => $codes2) { foreach ($codes2 as $code2) { $code3 = $iso2to3[$code2] ?? null; - if ($code3) $regionByIso3[$code3] = $regionName; + if ($code3 !== '' && $code3 !== '0') { + $regionByIso3[$code3] = $regionName; + } } } From 0ec7e6c38d3fe72ba63d03fbd540344e44eac128 Mon Sep 17 00:00:00 2001 From: Application-drop-up Date: Mon, 9 Mar 2026 22:14:44 +0900 Subject: [PATCH 4/6] fea: debug --- .github/workflows/server_test.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/server_test.yml b/.github/workflows/server_test.yml index 1171840..714e99d 100644 --- a/.github/workflows/server_test.yml +++ b/.github/workflows/server_test.yml @@ -24,6 +24,12 @@ jobs: coverage: none tools: composer + - name: Debug files + run: | + pwd + ls -la + find . -maxdepth 4 -name composer.json + - name: Install dependencies run: composer install --prefer-dist --no-progress --no-interaction From f447761079879def221cc3c85dc47d6c6c561c78 Mon Sep 17 00:00:00 2001 From: Application-drop-up Date: Tue, 10 Mar 2026 08:00:21 +0900 Subject: [PATCH 5/6] feat: delete CI tests about Mago & Rector --- .github/workflows/mago.yml | 34 --------- .github/workflows/rector.yml | 43 ------------ .github/workflows/server_test.yml | 111 ++++++++++++++++++++++++------ src/composer.json | 12 ++-- 4 files changed, 95 insertions(+), 105 deletions(-) delete mode 100644 .github/workflows/mago.yml delete mode 100644 .github/workflows/rector.yml diff --git a/.github/workflows/mago.yml b/.github/workflows/mago.yml deleted file mode 100644 index 94848b5..0000000 --- a/.github/workflows/mago.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: Mago - -on: - workflow_run: - workflows: ["PHPUnit"] - types: - - completed - -jobs: - mago: - if: ${{ github.event.workflow_run.conclusion == 'success' }} - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - ref: ${{ github.event.workflow_run.head_sha }} - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: "8.2" - coverage: none - tools: composer - - - name: Install dependencies - run: composer install --prefer-dist --no-progress --no-interaction - - - name: Setup Mago - uses: nhedger/setup-mago@v1 - - - name: Run Mago - run: mago analyze --reporting-format=github \ No newline at end of file diff --git a/.github/workflows/rector.yml b/.github/workflows/rector.yml deleted file mode 100644 index 8ce102a..0000000 --- a/.github/workflows/rector.yml +++ /dev/null @@ -1,43 +0,0 @@ -name: Rector - -on: - pull_request: - paths: - - "app/**" - - "bootstrap/**" - - "config/**" - - "database/**" - - "routes/**" - - "tests/**" - - "composer.json" - - "composer.lock" - - "rector.php" - - ".github/workflows/rector.yml" - push: - branches: - - main - - 'feat/*' - - 'fix/*' - - 'hotfix/*' - - 'chore/*' - -jobs: - rector: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: "8.2" - coverage: none - tools: composer - - - name: Install dependencies - run: composer install --prefer-dist --no-progress --no-interaction - - - name: Run Rector dry-run - run: vendor/bin/rector process --dry-run \ No newline at end of file diff --git a/.github/workflows/server_test.yml b/.github/workflows/server_test.yml index 714e99d..2c2229c 100644 --- a/.github/workflows/server_test.yml +++ b/.github/workflows/server_test.yml @@ -1,37 +1,106 @@ -name: PHPUnit +name: Server Test on: - workflow_run: - workflows: ["Rector"] - types: - - completed + pull_request: + types: [opened, synchronize] + paths: + - "src/**/*.php" + - "src/composer.lock" + push: + paths: + - "src/**/*.php" + - "src/composer.lock" + workflow_dispatch: {} jobs: - phpunit: - if: ${{ github.event.workflow_run.conclusion == 'success' }} + laravel: runs-on: ubuntu-latest + timeout-minutes: 11 + strategy: + fail-fast: false + matrix: + php: ['7.4', '8.0', '8.1', '8.2'] + Laravel: ['8.*', '9.*', '10.*'] + + services: + mysql: + image: mysql:8.0 + env: + MYSQL_ROOT_PASSWORD: root + MYSQL_DATABASE: ${{ secrets.DB_DATABASE }} + MYSQL_USER: ${{ secrets.DB_USERNAME }} + MYSQL_PASSWORD: ${{ secrets.DB_PASSWORD }} + TZ: Asia/Tokyo + ports: + - 3306:3306 + options: >- + --health-cmd "mysqladmin ping" + --health-interval 10s + --health-timeout 5s + --health-retries 5 steps: - - name: Checkout - uses: actions/checkout@v4 - with: - ref: ${{ github.event.workflow_run.head_sha }} + - name: Checkout code + uses: actions/checkout@v5 - name: Setup PHP uses: shivammathur/setup-php@v2 with: php-version: "8.2" - coverage: none - tools: composer + tools: composer:v2 - - name: Debug files - run: | - pwd - ls -la - find . -maxdepth 4 -name composer.json + - name: Cache Composer dependencies + uses: actions/cache@v4 + with: + path: ~/.cache/composer + key: ${{ runner.os }}-composer-${{ hashFiles('src/composer.lock') }} - name: Install dependencies - run: composer install --prefer-dist --no-progress --no-interaction + run: | + composer install --prefer-dist --no-progress --no-suggest + composer dump-autoload -o + working-directory: ./src + + - name: Copy .env.ci to .env.testing + run: cp .env.ci .env.testing + working-directory: ./src + + - name: Ensure newline at end of .env.testing + run: printf '\n' >> .env.testing + working-directory: ./src + + - name: Set environment variables + run: | + { + echo "DB_CONNECTION=mysql" + echo "DB_HOST=127.0.0.1" + echo "DB_PORT=${{ secrets.DB_PORT }}" + echo "DB_DATABASE=${{ secrets.DB_DATABASE }}" + echo "DB_USERNAME=${{ secrets.DB_USERNAME }}" + echo "DB_PASSWORD=${{ secrets.DB_PASSWORD }}" + } >> .env.testing + working-directory: ./src + + - name: Generate application key + run: php artisan key:generate --env=testing + working-directory: ./src + env: + APP_ENV: testing + + - name: Cache config and routes + run: | + php artisan config:clear + php artisan config:cache + working-directory: ./src + env: + APP_ENV: testing + + - name: Run migrations + run: php artisan migrate --env=testing + working-directory: ./src + env: + APP_ENV: testing - - name: Run PHPUnit - run: php artisan test \ No newline at end of file + - name: Run tests + run: ./vendor/bin/phpunit --stop-on-failure --testdox + working-directory: ./src \ No newline at end of file diff --git a/src/composer.json b/src/composer.json index e0e2a47..49f6da7 100644 --- a/src/composer.json +++ b/src/composer.json @@ -41,13 +41,11 @@ } }, "scripts": { - "ci:rector": "vendor/bin/rector process --dry-run", - "ci:phpunit": "php artisan test", - "ci:mago": "mago analyze --reporting-format=github", - "ci:quality": [ - "@ci:rector", - "@ci:phpunit", - "@ci:mago" + "mago:analyze": "mago analyze", + "rector:maintenance": "vendor/bin/rector process --config rector-maintenance.php", + "maintenance:weekly": [ + "@mago:analyze", + "@rector:maintenance" ], "post-autoload-dump": [ "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", From 34d3a6970bfb1434f852a2b378241bc8485f378b Mon Sep 17 00:00:00 2001 From: Application-drop-up Date: Tue, 10 Mar 2026 08:00:58 +0900 Subject: [PATCH 6/6] feat: create weekly maintenance CI --- .github/workflows/weekly_maintenance.yml | 88 ++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 .github/workflows/weekly_maintenance.yml diff --git a/.github/workflows/weekly_maintenance.yml b/.github/workflows/weekly_maintenance.yml new file mode 100644 index 0000000..1c6d5a3 --- /dev/null +++ b/.github/workflows/weekly_maintenance.yml @@ -0,0 +1,88 @@ +name: Weekly Maintenance + +on: + schedule: + - cron: "0 22 * * 0" + workflow_dispatch: + +permissions: + contents: write + pull-requests: write + +jobs: + weekly-maintenance: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: main + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: "8.2" + coverage: none + tools: composer + + - name: Install dependencies + run: composer install --prefer-dist --no-progress --no-interaction + + - name: Setup Mago + uses: nhedger/setup-mago@v1 + + - name: Run Mago analyze + run: composer mago:analyze + + - name: Run Rector maintenance config + run: composer rector:maintenance + + - name: Check for changes + id: changes + run: | + if [[ -n "$(git status --porcelain)" ]]; then + echo "changed=true" >> "$GITHUB_OUTPUT" + else + echo "changed=false" >> "$GITHUB_OUTPUT" + fi + + - name: Generate branch name + if: steps.changes.outputs.changed == 'true' + id: branch + run: | + echo "name=chore/weekly-maintenance-$(date +'%Y%m%d')" >> "$GITHUB_OUTPUT" + + - name: Commit changes + if: steps.changes.outputs.changed == 'true' + run: | + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git checkout -b "${{ steps.branch.outputs.name }}" + git add . + git commit -m "chore: apply weekly maintenance fixes" + + - name: Push branch + if: steps.changes.outputs.changed == 'true' + run: | + git push origin "${{ steps.branch.outputs.name }}" + + - name: Create pull request + if: steps.changes.outputs.changed == 'true' + uses: peter-evans/create-pull-request@v7 + with: + branch: ${{ steps.branch.outputs.name }} + title: "chore: weekly maintenance fixes" + body: | + ## Description + This PR contains weekly automated maintenance updates. + + ### Included + - Mago analysis executed + - Rector safe maintenance rules applied + + ## Notes + Please review the changes carefully before merging. + commit-message: "chore: apply weekly maintenance fixes" + base: main + delete-branch: false \ No newline at end of file