Skip to content

Replace global variable with static class property for PHP version cache#2

Merged
aegypius merged 5 commits into
chores/php-8.4from
copilot/sub-pr-1
Jan 15, 2026
Merged

Replace global variable with static class property for PHP version cache#2
aegypius merged 5 commits into
chores/php-8.4from
copilot/sub-pr-1

Conversation

Copilot AI commented Jan 15, 2026

Copy link
Copy Markdown
Contributor

Addresses code review feedback to eliminate global variable usage in PhpProject class.

Changes

  • Replaced global $version with private static string|null $version = null
  • Updated all references to use self::$version
  • Changed isset() to explicit null check (self::$version === null) for proper null detection with initialized properties
class PhpProject
{
    private static string|null $version = null;

    private function php(...): Container {
        if (self::$version === null) {
            // Parse version from composer platform requirements
            self::$version = ...;
        }
        
        return dag()->container()->from(match (self::$version) {
            null => "{$image}:{$variant}",
            default => "{$image}:{self::$version}-{$variant}"
        });
    }
}

Improves testability by containing state within the class scope rather than global namespace.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 4 commits January 15, 2026 08:30
Co-authored-by: aegypius <25710+aegypius@users.noreply.github.com>
Co-authored-by: aegypius <25710+aegypius@users.noreply.github.com>
Co-authored-by: aegypius <25710+aegypius@users.noreply.github.com>
Co-authored-by: aegypius <25710+aegypius@users.noreply.github.com>
Copilot AI changed the title [WIP] Address feedback on default PHP version in dependency update PR Replace global variable with static class property for PHP version cache Jan 15, 2026
Copilot AI requested a review from aegypius January 15, 2026 08:34
@aegypius aegypius marked this pull request as ready for review January 15, 2026 09:01
@aegypius aegypius merged commit 926186a into chores/php-8.4 Jan 15, 2026
@aegypius aegypius deleted the copilot/sub-pr-1 branch January 15, 2026 09:01
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.

2 participants