Skip to content

Code Formatting#397

Merged
zigzagdev merged 2 commits intomainfrom
chore/code-format
Mar 30, 2026
Merged

Code Formatting#397
zigzagdev merged 2 commits intomainfrom
chore/code-format

Conversation

@zigzagdev
Copy link
Copy Markdown
Owner

No description provided.

@zigzagdev zigzagdev requested a review from Copilot March 30, 2026 00:13
@zigzagdev zigzagdev self-assigned this Mar 30, 2026
Copy link
Copy Markdown
Owner Author

@zigzagdev zigzagdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

@zigzagdev zigzagdev merged commit f2e95ac into main Mar 30, 2026
27 checks passed
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 : void return types to many closures and convert eligible closures/arrow functions to static.
  • Normalize numeric literals (digit separators) and remove unused imports / redundant PHPDoc blocks.
  • Add a rector.php configuration 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.

Comment on lines 266 to 272
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) {
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines +295 to 296
'country' => $countryRelations->first()->name_en ?? $heritage->country,
'country_name_jp' => $heritage->countries->first()?->name_jp,
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
'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,

Copilot uses AI. Check for mistakes.
Comment on lines +12 to 15
if (!($item instanceof WorldHeritageViewModel)) { continue; }

$this->items[] = $item;
}
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copilot uses AI. Check for mistakes.
}
if (!($file->isFile() && str_ends_with($file->getFilename(), '.json'))) { continue; }

$files[] = $file->getPathname();
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
$files[] = $file->getPathname();
$files[] = $file->getPathname();

Copilot uses AI. Check for mistakes.
Comment on lines 12 to 16
use Tests\TestCase;
use App\Packages\Domains\Ports\SignedUrlPort;
use Mockery;



class GetWorldHeritageByIdTest extends TestCase
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
.env
.env.backup
.env.prod
.env.testing
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Suggested change
.env.testing
.env.testing
.env.prod
.env.backup

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants