Skip to content

fix: update Carbon constraint for PHP 8.1 --prefer-lowest compatibility#84

Open
jsirish wants to merge 2 commits into2from
bugfix/carbon-php81-compatibility
Open

fix: update Carbon constraint for PHP 8.1 --prefer-lowest compatibility#84
jsirish wants to merge 2 commits into2from
bugfix/carbon-php81-compatibility

Conversation

@jsirish
Copy link
Member

@jsirish jsirish commented Sep 26, 2025

Problem

CI tests are failing on PHP 8.1 with --prefer-lowest flag due to Carbon dependency constraint conflicts:

Your requirements could not be resolved to an installable set of packages.
Problem 1
- nesbot/carbon[3.0.0, ..., 3.8.0] require php ^8.1.1

Root Cause

  • Current constraint: "nesbot/carbon": "^3.0"
  • Carbon v3.x requires PHP 8.1.1+
  • CI's --prefer-lowest tries to install Carbon 3.0.0 on PHP 8.1.0 environments
  • This creates a version conflict preventing dependency resolution

Solution

Updated composer.json constraint to:

"nesbot/carbon": "^2.73 || ^3.0"

Benefits:

  • Backward Compatible: Carbon v2.73+ supports PHP 8.1-8.4
  • Forward Compatible: Prefers Carbon v3.x on newer PHP versions
  • Same API: Both versions provide identical functionality
  • CI Success: --prefer-lowest can install v2.73 on PHP 8.1

Testing

  • Verified Carbon v2.73+ maintains full API compatibility with v3.x
  • Constraint allows Composer to choose optimal version per environment
  • Resolves CI failures while maintaining modern Carbon features

References

This change allows both Carbon v2.73+ and v3.0+ to fix CI failures
on PHP 8.1 with --prefer-lowest. Carbon v2.73+ supports PHP 8.1-8.4
with the same API as v3.x but without the strict PHP 8.1+ requirement
that prevents --prefer-lowest from working.

- Allows CI --prefer-lowest to install Carbon v2.73 on PHP 8.1
- Maintains preference for Carbon v3.x on newer PHP versions
- Resolves composer dependency resolution conflicts

Fixes composer error: 'Your requirements could not be resolved to an installable set of packages'
Copilot AI review requested due to automatic review settings September 26, 2025 19:55
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 PR fixes CI test failures on PHP 8.1 with --prefer-lowest by updating the Carbon dependency constraint to allow both v2.73+ and v3.0+, resolving version conflicts while maintaining backward and forward compatibility.

  • Updated Carbon constraint from ^3.0 to ^2.73 || ^3.0 to support PHP 8.1.0 environments
  • Ensures CI compatibility with --prefer-lowest flag while preserving modern Carbon features
  • Maintains API compatibility across both Carbon major versions

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

- Missing PHP constraint was causing dependency resolution failures in CI
- PHP ^8.1 requirement ensures compatibility with all SilverStripe 5.x dependencies
- This addresses the 'Your requirements could not be resolved' error on PHP 8.1 --prefer-lowest builds
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

Comments