Skip to content

Conversation

@zhukaihan
Copy link
Collaborator

Auto load files.
Possible fix for #40.

@zhukaihan zhukaihan requested review from a team, Copilot and tyiuhc October 30, 2025 00:00
Copy link

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 pull request refactors the codebase to use Composer's autoload mechanism for files containing global functions and constants, replacing manual require_once statements throughout the codebase. This modernizes the project structure and aligns with PHP best practices.

  • Removed all manual require_once statements from source and test files
  • Added a files autoload configuration in composer.json to automatically load utility files containing global functions and constants
  • Updated 13 files across test and source directories

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
composer.json Added files autoload configuration to automatically load utility files with global functions and constants
src/Assignment/Assignment.php Removed redundant require_once statements for Util.php and AssignmentService.php
src/Assignment/AssignmentService.php Removed redundant require_once statement for Util.php
src/Assignment/DefaultAssignmentFilter.php Removed redundant require_once statement for AssignmentService.php
src/AmplitudeCookie.php Removed redundant require_once statement for Util.php
src/EvaluationCore/EvaluationEngine.php Removed redundant require_once statement for Util.php
src/Flag/FlagConfigFetcher.php Removed redundant require_once statement for Version.php
src/Flag/FlagConfigService.php Removed redundant require_once statement for Util.php
src/Local/LocalEvaluationClient.php Removed redundant require_once statement for EvaluationCore/Util.php
src/Remote/RemoteEvaluationClient.php Removed redundant require_once statement for Version.php
tests/Assignment/AssignmentFilterTest.php Removed redundant require_once statement for Util.php
tests/EvaluationCore/EvaluateIntegrationTest.php Removed redundant require_once statement for Flag/Util.php
tests/EvaluationCore/SelectTest.php Removed redundant require_once statement for EvaluationCore/Util.php
tests/EvaluationCore/TopologicalSortTest.php Removed redundant require_once statement for EvaluationCore/Util.php

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

@kyeh-amp
Copy link

Ok so after doing a bunch of reading, this looks good after addressing the copilot suggestions. The three constants identified can live in either relevant classes or separate files where appropriate.

@zhukaihan zhukaihan requested a review from Copilot October 30, 2025 19:40
Copy link

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

Copilot reviewed 17 out of 17 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (3)

src/Assignment/Assignment.php:78

  • The constant FLAG_TYPE_MUTUAL_EXCLUSION_GROUP is defined in src/Assignment/AssignmentConstants.php within the same namespace but is not explicitly imported. While it works due to Composer's file autoloading, add use const AmplitudeExperiment\Assignment\FLAG_TYPE_MUTUAL_EXCLUSION_GROUP; at the top of the file for better clarity and maintainability.
            if ($flagType == FLAG_TYPE_MUTUAL_EXCLUSION_GROUP) {

src/Assignment/Assignment.php:93

  • The constant DAY_MILLIS is defined in src/Assignment/AssignmentConstants.php within the same namespace but is not explicitly imported. While it works due to Composer's file autoloading, add use const AmplitudeExperiment\Assignment\DAY_MILLIS; at the top of the file for better clarity and maintainability.
            floor($this->timestamp / DAY_MILLIS);

src/Http/GuzzleHttpClient.php:30

  • The constant GUZZLE_DEFAULTS is defined in src/Http/GuzzleConstants.php within the same namespace but is not explicitly imported. While it works due to Composer's file autoloading, add use const AmplitudeExperiment\Http\GUZZLE_DEFAULTS; at the top of the file for better clarity and maintainability.
        $this->config = array_merge(GUZZLE_DEFAULTS, $config);

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

Copy link

@kyeh-amp kyeh-amp left a comment

Choose a reason for hiding this comment

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

thanks for addressing that 👍

@zhukaihan zhukaihan merged commit 261c313 into main Oct 30, 2025
9 checks passed
github-actions bot pushed a commit that referenced this pull request Oct 30, 2025
# [1.3.0](1.2.5...1.3.0) (2025-10-30)

### Features

* autoload files ([#43](#43)) ([261c313](261c313))
@github-actions
Copy link

🎉 This PR is included in version 1.3.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants