Skip to content

Conversation

@DevWolk
Copy link

@DevWolk DevWolk commented Jun 9, 2025

Description

This pull request introduces a comprehensive overhaul of the project's codebase, focused on modernization, quality assurance, and improved developer experience. It addresses technical debt and establishes a solid foundation for future development.

The primary motivation for this extensive update is to elevate the project's code quality, maintainability, and reliability by integrating a modern suite of static analysis tools and applying strict coding standards across the entire codebase. This proactive approach aims to catch bugs earlier, ensure consistency, and simplify the process of contributing to the project.

Key changes include:

  • Integration of a comprehensive static analysis suite: PHPStan, PHP_CodeSniffer, PHPMD, and Rector are now integrated into the development workflow, with corresponding configurations and CI checks.
  • Codebase-wide Strict Typing: declare(strict_types=1); has been applied to all PHP files to enforce stricter type checking.
  • Core Component Refactoring: Significant improvements have been made to:
    • Repositories: Hashed ID decoding and pagination logic have been rewritten for better reliability and clarity.
    • Generators: Code generation logic has been improved, including the introduction of a UIGeneratorTrait to reduce code duplication and the automatic naming of routes.
    • Foundation: Base path and shared path resolution have been made more robust, especially for CI environments.
  • New Features:
    • A WITH_TRANSACTIONS option has been added to Seeders for more efficient database seeding.
    • Custom Rector rules have been added to automate PHPUnit best practices.
  • Dependency & CI Updates: Composer dependencies have been updated, the package name has been changed, and all CI workflows on GitHub Actions have been modernized and expanded.

This pull request does not fix a single issue but rather represents a foundational upgrade for the entire project.

Dependencies:
This change introduces several new require-dev dependencies for static analysis and code quality tooling. It does not add any new runtime dependencies.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Refactor (refactoring a current feature, method, etc...)
  • Code Coverage (adding/removing/updating/refactoring tests)
  • New feature (non-breaking change which adds functionality)
  • Remove feature (non-breaking change which removes functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

BREAKING CHANGE DETAILS:

  1. Strict Types: The global enforcement of declare(strict_types=1); may cause issues in downstream projects that relied on PHP's loose type coercion.
  2. PHP Version: The minimum required PHP version has been raised to 8.2.
  3. Repository Search: The refactoring of the search query decoding logic in repositories might alter behavior for consumers who were crafting complex search strings manually.

DevWolk added 3 commits June 9, 2025 15:03
…n, and generator enhancements;

feat: added PHPStan configuration and workflow;
feat: added PHP_CodeSniffer configuration and workflow;
feat: added PHPMD configuration, baseline, and updated workflow;
feat: added Rector configuration and workflow
feat: added Composer Unused configuration and composer-quality workflow
feat: added Composer security audit workflow
style: applied declare(strict_types=1) across codebase
feat: introduced UIGeneratorTrait for UI component generation
feat: added custom Rector rules for PHPUnit assertions and mock objects
feat(Seeder): added WITH_TRANSACTIONS option for seeder execution
feat(Generator): added example state method to factory stub
feat(Generator): automatically name routes in generated route stubs
feat(Generator): standardized date formatting for Seeder and Migration filenames
feat(Generator): Covers the FORMAT_TIME constant and getDate() helper in Migration/Seeder generators
refactor: updated Hashed ID decoding logic in Repositories, Covers the rewrite of decodeSearchQueryString and related helpers in Repository.php
refactor: improved pagination handling and limit setting in Repositories, Covers changes to setPaginationLimit, wantsToSkipPagination, canSkipPagination in Repository.php
refactor: updated Response class to use Symfony HTTP status constants
refactor(Generator): updated string and parameter handling in Generator core. Covers changes to removeSpecialChars, getInput, checkParameterOr methods and removal of \Safe\ prefixes for preg_replace
refactor(Generator): updated various generator stubs and commands logic
refactor(User): moved model casts to dedicated casts() method
refactor: standardized exception catching to \Throwable. Covers changes in CreateBookTask.php and Repository.php (create method)
refactor(Foundation): updated glob usage in Configuration classes. Covers ApplicationBuilder.php and Apiato.php changing from \Safe\glob to glob
refactor(Routing): improved API version resolution and prefixing. Covers changes in src/Foundation/Configuration/Routing.php
fix(Action): ensured correct return type for transactional run closure
fix(Generator): ensured correct parameter type hints in Generator class methods. Specifically for checkParameterOrAsk if the default value change was a fix
fix(Generator): ensure relations are unloaded in generated 'create' event stubs
fix(MacroServiceProvider): ensure correct this context for Config::unset macro
fix(Foundation): improved base path and shared path resolution in Apiato class. Covers inferBasePath and sharedPath logic changes
fix(Http): corrected RequestRelation method signatures and type hints. Covers return type change of isValidRelationOf and closure type hint
chore: updated composer.json package name to dan-wolf-at/apiato-core
chore: updated composer.json dependencies and script configurations
chore: removed legacy static analysis configurations (PHPStan.dist, Psalm, old PHPMD)
chore: updated GitHub Actions test matrix and CI workflow configurations. Covers general updates to tests.yaml, phpmd.yaml and matrix_includes.json not related to adding new tools
fix: update minimum PHP version to 8.2 in Rector classes and adjust related messages;
feat: updated PHP CodeSniffer and Rector configurations;
Copy link
Contributor

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 implements a comprehensive codebase modernization by enforcing strict typing across all PHP files, integrating static analysis tools (PHPStan, PHP_CodeSniffer, PHPMD, Rector), and refactoring core components for improved reliability and maintainability. The changes establish stricter coding standards and reduce technical debt throughout the project.

Key Changes:

  • Added declare(strict_types=1); to all PHP files for stricter type checking
  • Refactored repository search query decoding logic and pagination handling
  • Enhanced code generators with new UIGeneratorTrait and automatic route naming
  • Updated test files to use static assertions and improved type hints

Reviewed Changes

Copilot reviewed 299 out of 392 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
workbench/app/Containers/MySection/Author/* Added strict types declaration to route files, helpers, events, seeders, and actions
workbench/app/Containers/Identity/User/* Added strict types, modernized casts to method format, updated factory to use fake() helper, added parameter types to migrations
tests/* Added strict types across all test files, improved closure type hints, renamed variables for clarity, added return types
src/Support/* Added strict types, improved type hints with null
src/Http/* Added strict types, moved methods for better organization, added exception documentation, improved null checks
src/Generator/* Added strict types, removed FormatterTrait, added UIGeneratorTrait, improved type safety and return types throughout
src/Foundation/* Added strict types, improved configuration class organization, refactored seeder transaction handling

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1 to +9
<?php
declare(strict_types=1);
?>
<h1>
This is a fake mail view for testing purposes.
</h1>
<?php
Copy link

Copilot AI Oct 25, 2025

Choose a reason for hiding this comment

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

Adding PHP strict types declaration to a Blade template file is unusual and unnecessary. Blade templates are primarily for HTML markup with minimal PHP logic. The strict_types declaration should only be in pure PHP files. Additionally, the closing <?php tag on line 9 appears incomplete or unnecessary.

Suggested change
<?php
declare(strict_types=1);
?>
<h1>
This is a fake mail view for testing purposes.
</h1>
<?php
<h1>
This is a fake mail view for testing purposes.
</h1>

Copilot uses AI. Check for mistakes.
Comment on lines +27 to 32
public function name(): self
{
return $this->state(fn (array $attributes): array => [
'name' => fake()->name(),
]);
}
Copy link

Copilot AI Oct 25, 2025

Choose a reason for hiding this comment

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

The name() method in the factory stub duplicates the default 'name' field from the definition() method. This creates redundant state methods that don't add value. Consider removing this method or making it demonstrate a different state pattern.

Suggested change
public function name(): self
{
return $this->state(fn (array $attributes): array => [
'name' => fake()->name(),
]);
}

Copilot uses AI. Check for mistakes.
* @var Seeder $this
*/
collect($classes)->each(fn (string $class) => $class::WITH_TRANSACTIONS
? DB::transaction(fn (string $class) => $this->call($class))
Copy link

Copilot AI Oct 25, 2025

Choose a reason for hiding this comment

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

The closure parameter shadows the outer $class variable. The inner closure fn (string $class) on line 22 should be fn () => since it doesn't use the parameter and would incorrectly reference a different variable. This will cause the wrong class to be called within the transaction.

Suggested change
? DB::transaction(fn (string $class) => $this->call($class))
? DB::transaction(fn () => $this->call($class))

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant