Conversation
There was a problem hiding this comment.
Pull request overview
This PR primarily applies automated code formatting/refactoring across the PHP codebase and introduces a Rector configuration to standardize future refactors.
Changes:
- Add explicit
: voidreturn types to many closures and convert eligible closures/arrow functions tostatic. - Normalize numeric literals (digit separators) and remove unused imports / redundant PHPDoc blocks.
- Add a
rector.phpconfiguration and adjust miscellaneous project config files (including.gitignore).
Reviewed changes
Copilot reviewed 53 out of 53 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/routes/console.php | Add : void to Artisan command closure |
| src/routes/api.php | Add : void to route group closure |
| src/rector.php | Add Rector configuration + target paths |
| src/bootstrap/app.php | Add : void to framework configuration closures |
| src/app/Support/StudyRegionResolver.php | Remove redundant PHPDoc blocks |
| src/app/Packages/Features/Tests/SearchWorldHeritagesTest.php | Remove unused import / spacing tweak |
| src/app/Packages/Features/Tests/GetWorldHeritagesTest.php | Use static function in test binding + numeric separators |
| src/app/Packages/Features/Tests/GetWorldHeritageByIdTest.php | Remove unused imports + numeric separators |
| src/app/Packages/Features/Tests/GetCountEachRegionTest.php | Use static function in test binding |
| src/app/Packages/Features/QueryUseCases/ViewModel/WorldHeritageViewModelCollection.php | Refactor constructor loop + static fn |
| src/app/Packages/Features/QueryUseCases/UseCase/GetWorldHeritagesUseCase.php | Remove unused import |
| src/app/Packages/Features/QueryUseCases/UseCase/GetCountEachRegionUseCase.php | Use static fn in array_map |
| src/app/Packages/Features/QueryUseCases/Tests/ViewModel/WorldHeritageViewModelCollectionFactoryTest.php | Numeric separators + static function |
| src/app/Packages/Features/QueryUseCases/Tests/ViewModel/WorldHeritageSummaryViewModelFactoryTest.php | Numeric separators |
| src/app/Packages/Features/QueryUseCases/Tests/ViewModel/WorldHeritageDetailViewModelFactoryTest.php | Numeric separators |
| src/app/Packages/Features/QueryUseCases/Tests/UseCase/SearchWorldHeritagesWithAlgoliaUseCaseTest.php | Convert closures to static |
| src/app/Packages/Features/QueryUseCases/Tests/UseCase/GetWorldHeritagesUseCaseTest.php | Remove unused import |
| src/app/Packages/Features/QueryUseCases/Tests/UseCase/GetWorldHeritageByIdUseCaseTest.php | Remove unused imports + numeric separators |
| src/app/Packages/Features/QueryUseCases/Tests/GetWorldHeritageByIdDtoTest.php | Numeric separators |
| src/app/Packages/Features/QueryUseCases/Tests/Dto/WorldHeritageDtoSummaryFactoryTest.php | Numeric separators (floats/coords) |
| src/app/Packages/Features/QueryUseCases/Tests/Dto/WorldHeritageDtoDetailFactoryTest.php | Numeric separators |
| src/app/Packages/Features/QueryUseCases/Tests/Dto/WorldHeritageDtoCollectionTest.php | static fn + numeric separators |
| src/app/Packages/Features/QueryUseCases/QueryServiceInterface/WorldHeritageQueryServiceInterface.php | Remove unused imports / whitespace |
| src/app/Packages/Features/QueryUseCases/ListQuery/WorldHeritageListQuery.php | Use static fn in array_filter |
| src/app/Packages/Features/QueryUseCases/ListQuery/UpdateWorldHeritageListQueryCollection.php | Remove redundant import + static fn |
| src/app/Packages/Features/QueryUseCases/ListQuery/CreateWorldHeritageListQueryCollection.php | Use static fn in array_map |
| src/app/Packages/Features/QueryUseCases/Factory/ViewModel/WorldHeritageViewModelCollectionFactory.php | Use static fn in array_map |
| src/app/Packages/Features/QueryUseCases/Factory/ViewModel/WorldHeritageDetailViewModelFactory.php | Remove unused imports / whitespace |
| src/app/Packages/Features/QueryUseCases/Dto/WorldHeritageDtoCollection.php | Use static closures in mapping |
| src/app/Packages/Features/QueryUseCases/Dto/WorldHeritageDto.php | Use static fn in array_filter |
| src/app/Packages/Features/Controller/WorldHeritageController.php | Use static fn in array_map |
| src/app/Packages/Domains/WorldHeritageReadQueryService.php | Use typed static relation callbacks + static fn |
| src/app/Packages/Domains/WorldHeritageQueryService.php | Convert callbacks to static + small refactors (incl. ??=) |
| src/app/Packages/Domains/WorldHeritageEntity.php | Convert filters to static |
| src/app/Packages/Domains/Test/WorldHeritageEntityTest.php | Add @covers + numeric separators |
| src/app/Packages/Domains/Test/WorldHeritageEntityCollectionTest.php | Convert closures to static |
| src/app/Packages/Domains/Test/QueryService/WorldHeritageReadQueryService_findTest.php | Numeric separators |
| src/app/Packages/Domains/Test/QueryService/WorldHeritageQueryService_searchHeritagesTest.php | Use static fn mappings |
| src/app/Packages/Domains/Test/QueryService/WorldHeritageQueryService_getByIdTest.php | Use static function in test binding + numeric separators |
| src/app/Packages/Domains/Test/QueryService/WorldHeritageQueryService_getAllHeritagesTest.php | Use static function in test binding |
| src/app/Packages/Domains/Test/QueryService/WorldHeritageQueryService_countEachRegionTest.php | Numeric separators (coords) + static bindings |
| src/app/Packages/Domains/StudyRegion/ExceptionalStudyRegions.php | Remove redundant PHPDoc blocks |
| src/app/Packages/Domains/Infra/CountryResolver.php | Replace comment text (JP → EN) |
| src/app/Packages/Domains/Adapter/AlgoliaWorldHeritageSearchAdapter.php | Convert closures to static |
| src/app/Enums/Region.php | Remove enum (appears unused) |
| src/app/Console/Commands/WorldHeritageBuild.php | Convert array_filter callback to static fn |
| src/app/Console/Commands/SplitWorldHeritageJson.php | Use 0o777 + static closure |
| src/app/Console/Commands/ImportWorldHeritageSiteImagesFromJson.php | Refactor loop with continue + formatting changes |
| src/app/Console/Commands/ImportWorldHeritageJapaneseNameFromJson.php | Use static fn + 0o777 |
| src/app/Console/Commands/DumpWorldHeritageSiteJapaneseName.php | String interpolation tweak + static fn |
| src/app/Console/Commands/DumpUnescoWorldHeritageJson.php | Convert normalization closures to static |
| src/app/Console/Commands/AlgoliaImportWorldHeritages.php | Typed relation callbacks + closure refactors |
| src/.gitignore | Stop ignoring .env.backup / .env.prod |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if ($statePartyCodeCollection->count() === 1) { | ||
| $onlyStateParty = $statePartyCodeCollection->first(); | ||
| $primaryCountry = $countryRelations->first( | ||
| fn($country) => strtoupper($country->state_party_code) === $onlyStateParty, | ||
| static fn($country) => strtoupper($country->state_party_code) === $onlyStateParty, | ||
| ); | ||
| $statePartyName = $primaryCountry?->name_en ?? $heritage->country ?? null; | ||
| $statePartyName = $primaryCountry->name_en ?? $heritage->country ?? null; | ||
| } elseif ($statePartyCodeCollection->count() > 1) { |
There was a problem hiding this comment.
In buildWorldHeritagePayload(), $primaryCountry is the result of Collection::first() and can still be null; accessing $primaryCountry->name_en will then trigger a fatal error. Use the nullsafe operator (or an explicit null check) before reading name_en so the fallback to $heritage->country can work safely.
| 'country' => $countryRelations->first()->name_en ?? $heritage->country, | ||
| 'country_name_jp' => $heritage->countries->first()?->name_jp, |
There was a problem hiding this comment.
This line calls $countryRelations->first()->name_en, but first() returns null for an empty countries relation; the subsequent property access will fatal. Use $countryRelations->first()?->name_en (or guard for an empty collection) to preserve the intended fallback to $heritage->country.
| 'country' => $countryRelations->first()->name_en ?? $heritage->country, | |
| 'country_name_jp' => $heritage->countries->first()?->name_jp, | |
| 'country' => $countryRelations->first()?->name_en ?? $heritage->country, | |
| 'country_name_jp' => $countryRelations->first()?->name_jp, |
| if (!($item instanceof WorldHeritageViewModel)) { continue; } | ||
|
|
||
| $this->items[] = $item; | ||
| } |
There was a problem hiding this comment.
The new loop body has inconsistent indentation: $this->items[] = $item; is no longer indented under the foreach/if block, which makes the code hard to read and likely violates the project's formatting rules. Re-indent this statement (and consider expanding the if { continue; } to a multi-line block for consistency).
| } | ||
| if (!($file->isFile() && str_ends_with($file->getFilename(), '.json'))) { continue; } | ||
|
|
||
| $files[] = $file->getPathname(); |
There was a problem hiding this comment.
The foreach loop was rewritten into a one-line if { continue; } and the $files[] = ... line lost indentation, reducing readability and likely failing formatting checks. Please reformat this block so the assignment is properly indented under the loop.
| $files[] = $file->getPathname(); | |
| $files[] = $file->getPathname(); |
| use Tests\TestCase; | ||
| use App\Packages\Domains\Ports\SignedUrlPort; | ||
| use Mockery; | ||
|
|
||
|
|
||
|
|
||
| class GetWorldHeritageByIdTest extends TestCase |
There was a problem hiding this comment.
There are multiple consecutive blank lines between the last import and the class declaration, which is inconsistent with typical file formatting in this repo and makes diffs noisier. Consider collapsing this to a single blank line.
| .env | ||
| .env.backup | ||
| .env.prod | ||
| .env.testing |
There was a problem hiding this comment.
Removing .env.prod and .env.backup from .gitignore makes it easier to accidentally commit environment-specific secrets/config files. If the intent is only formatting, consider keeping these entries ignored (or documenting why they should be tracked).
| .env.testing | |
| .env.testing | |
| .env.prod | |
| .env.backup |
No description provided.