Skip to content

Allow installing in PHP 8.2#5

Merged
AlexSkrypnyk merged 1 commit intomainfrom
feature/php8.2
Nov 18, 2025
Merged

Allow installing in PHP 8.2#5
AlexSkrypnyk merged 1 commit intomainfrom
feature/php8.2

Conversation

@AlexSkrypnyk
Copy link
Copy Markdown
Member

@AlexSkrypnyk AlexSkrypnyk commented Nov 18, 2025

Summary by CodeRabbit

  • Chores
    • Added support for PHP 8.2 and lowered the minimum PHP requirement to 8.2.
    • Adjusted CI to run tests on PHP 8.2 and to change install/test steps and coverage uploads depending on PHP version.
    • Downgraded development PHPUnit constraint and updated related CI steps.
    • No user-facing behavior changes.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Nov 18, 2025

📝 Walkthrough

Walkthrough

Added PHP 8.2 support: lowered composer PHP requirement to >=8.2 and expanded the GitHub Actions matrix to include 8.2 with conditional install/test/coverage steps; removed a string type from one public constant declaration in a sniff file.

Changes

Cohort / File(s) Summary
CI Workflow Configuration
.github/workflows/test-php.yml
Added PHP 8.2 to the matrix. Made the install step a multi-line script and added a conditional pre-install composer require --dev phpunit/phpunit:^11 --no-update for php-version == 8.2. Test step runs composer test for 8.2 and composer test-coverage for others. Coverage artifact upload and Codecov upload steps are skipped for 8.2.
Project Manifest
composer.json
Lowered "require"."php" from ">=8.3" to ">=8.2".
Sniffs
src/DrevOps/Sniffs/NamingConventions/LocalVariableSnakeCaseSniff.php, src/DrevOps/Sniffs/NamingConventions/ParameterSnakeCaseSniff.php
LocalVariableSnakeCaseSniff.php: removed the string type hint from the public constant declaration CODE_VARIABLE_NOT_SNAKE_CASE. ParameterSnakeCaseSniff.php: no behavioral changes.

Sequence Diagram(s)

sequenceDiagram
  participant GH as GitHub Actions
  participant JR as Runner
  participant C as Composer
  participant P as PHPUnit
  participant CV as Coverage/Artifacts

  Note right of GH: matrix includes 8.2, 8.3, 8.4, 8.5
  GH->>JR: start job (php-version)
  alt php-version == 8.2
    JR->>C: composer require --dev phpunit/phpunit:^11 --no-update
    JR->>C: composer install (matrix-conditioned flags)
    JR->>P: composer test
    JR->>CV: (skip coverage artifact & Codecov upload)
  else php-version != 8.2
    JR->>C: composer install (matrix-conditioned flags)
    JR->>P: composer test-coverage
    JR->>CV: upload coverage artifact
    JR->>CV: upload to Codecov
  end
  P-->>JR: test results
  JR-->>GH: job complete
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Verify CI YAML conditionals (matrix variable names, if/else conditions, indentation in multi-line run block).
  • Confirm PHPUnit pre-install and version (^11) for 8.2 behaves as intended.
  • Ensure lowering PHP requirement to >=8.2 is safe (search for 8.3+ language features).
  • Quick check of the constant type hint removal in LocalVariableSnakeCaseSniff.php.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Allow installing in PHP 8.2' directly and clearly describes the main change: extending PHP version support to include PHP 8.2.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/php8.2

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b1c238d and 63cad76.

📒 Files selected for processing (2)
  • .github/workflows/test-php.yml (2 hunks)
  • composer.json (1 hunks)
🔇 Additional comments (2)
composer.json (1)

20-20: LGTM: Minimum PHP version correctly lowered to 8.2.

The change aligns with the PR objective and enables installation on PHP 8.2 systems. Note that the require-dev section still specifies PHPUnit 12, which requires PHP 8.3+, but this is correctly handled in the test workflow (which conditionally downgrades to PHPUnit 11 for PHP 8.2 testing).

.github/workflows/test-php.yml (1)

25-25: LGTM: PHP 8.2 added to test matrix.

The matrix now includes PHP 8.2 as the minimum tested version, aligning with the lowered requirement in composer.json.

Comment on lines 44 to +49
- name: Install dependencies
run: composer install ${{ matrix.php-versions == '8.5' && '--ignore-platform-reqs' || '' }}
run: |
if [ "${{ matrix.php-versions }}" == "8.2" ]; then
composer require --dev phpunit/phpunit:^11 --no-update
fi
composer install ${{ matrix.php-versions == '8.5' && '--ignore-platform-reqs' || '' }}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Add clarifying comment explaining the PHP 8.2 + PHPUnit version handling.

The conditional PHPUnit 11 requirement for PHP 8.2 is necessary because PHPUnit 12 requires PHP 8.3+, while PHPUnit 11 requires PHP 8.2+. The implementation is correct, but a comment explaining this constraint mismatch would help future maintainers understand why the workaround is needed.

Consider adding an inline comment like this:

      - name: Install dependencies
        run: |
+         # PHPUnit 12 requires PHP 8.3+, so we downgrade to PHPUnit 11 for PHP 8.2 testing
          if [ "${{ matrix.php-versions }}" == "8.2" ]; then
            composer require --dev phpunit/phpunit:^11 --no-update
          fi
          composer install ${{ matrix.php-versions == '8.5' && '--ignore-platform-reqs' || '' }}

This makes the version constraint rationale clear at a glance.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Install dependencies
run: composer install ${{ matrix.php-versions == '8.5' && '--ignore-platform-reqs' || '' }}
run: |
if [ "${{ matrix.php-versions }}" == "8.2" ]; then
composer require --dev phpunit/phpunit:^11 --no-update
fi
composer install ${{ matrix.php-versions == '8.5' && '--ignore-platform-reqs' || '' }}
- name: Install dependencies
run: |
# PHPUnit 12 requires PHP 8.3+, so we downgrade to PHPUnit 11 for PHP 8.2 testing
if [ "${{ matrix.php-versions }}" == "8.2" ]; then
composer require --dev phpunit/phpunit:^11 --no-update
fi
composer install ${{ matrix.php-versions == '8.5' && '--ignore-platform-reqs' || '' }}
🤖 Prompt for AI Agents
In .github/workflows/test-php.yml around lines 44 to 49, add a brief inline
comment above the conditional composer require line explaining that PHPUnit 12
requires PHP 8.3+, so for the PHP 8.2 matrix entry we explicitly require
phpunit/phpunit:^11 to ensure compatibility; optionally also add a short note on
the following composer install line about using --ignore-platform-reqs for the
PHP 8.5 job to clarify that it bypasses platform checks.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Nov 18, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (b1c238d) to head (c88fea8).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff            @@
##              main        #5   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            3         3           
  Lines          164       164           
=========================================
  Hits           164       164           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@AlexSkrypnyk AlexSkrypnyk changed the title Allow installing in PHP8.2 Allow installing in PHP 8.2 Nov 18, 2025
@AlexSkrypnyk AlexSkrypnyk merged commit be92eb7 into main Nov 18, 2025
4 of 5 checks passed
@AlexSkrypnyk AlexSkrypnyk deleted the feature/php8.2 branch November 18, 2025 01:43
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
.github/workflows/test-php.yml (1)

44-49: PHPUnit version handling is correct.

The conditional installation of PHPUnit 11 for PHP 8.2 is necessary and correctly implemented, as PHPUnit 12 requires PHP 8.3+. A previous review comment already suggested adding a clarifying comment to explain this version constraint.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cde3948 and c88fea8.

📒 Files selected for processing (4)
  • .github/workflows/test-php.yml (5 hunks)
  • composer.json (1 hunks)
  • src/DrevOps/Sniffs/NamingConventions/LocalVariableSnakeCaseSniff.php (1 hunks)
  • src/DrevOps/Sniffs/NamingConventions/ParameterSnakeCaseSniff.php (1 hunks)
🔇 Additional comments (5)
src/DrevOps/Sniffs/NamingConventions/ParameterSnakeCaseSniff.php (1)

21-21: LGTM! Consistent with PHP 8.2 compatibility requirements.

The removal of the string type hint from this constant is correct and necessary for PHP 8.2 support, as typed class constants were introduced in PHP 8.3. This change is consistent with the identical modification in LocalVariableSnakeCaseSniff.php.

Note: The AI summary incorrectly states "No observable changes to public/exported declarations" when the type hint was actually removed from the public constant.

src/DrevOps/Sniffs/NamingConventions/LocalVariableSnakeCaseSniff.php (1)

20-20: LGTM! Correct removal of typed constant for PHP 8.2 compatibility.

The removal of the string type hint from this constant is necessary for PHP 8.2 support, as typed class constants were introduced in PHP 8.3. This change is consistent with the identical modification in ParameterSnakeCaseSniff.php.

.github/workflows/test-php.yml (2)

25-25: LGTM! PHP 8.2 correctly added to test matrix.

The addition of PHP 8.2 to the test matrix aligns with the PR objectives and ensures the package is tested across all supported PHP versions.


71-71: LGTM! Coverage upload conditions are consistent.

The conditional logic to skip coverage uploads for PHP 8.2 is consistent with skipping coverage collection in the test step. The implementation correctly uses the same condition pattern across all three upload steps.

Also applies to: 80-80, 89-89

composer.json (1)

20-20: PHP version requirement change is valid and all dependencies support PHP 8.2.

Verification confirms that squizlabs/php_codesniffer (^3.10), phpstan/phpstan (^2), and rector/rector (^2) all support PHP 8.2+. The change to >=8.2 is appropriate and introduces no compatibility issues.

Comment on lines 60 to +66
- name: Run tests
run: composer test-coverage
run: |
if [ "${{ matrix.php-versions }}" != "8.2" ]; then
composer test-coverage
else
composer test
fi
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Clarify rationale for skipping coverage on PHP 8.2.

The conditional logic skips coverage collection for PHP 8.2. Is this intentional to reduce CI time, or is there a technical limitation with PHPUnit 11 or the coverage tooling?

Given that Codecov reports 100% coverage and all tests pass, this might be acceptable. However, documenting the rationale would help future maintainers understand this decision.

Consider adding a comment explaining why coverage is skipped for PHP 8.2:

      - name: Run tests
        run: |
+         # Skip coverage for PHP 8.2 to reduce CI time (coverage is collected on other PHP versions)
          if [ "${{ matrix.php-versions }}" != "8.2" ]; then
            composer test-coverage
          else
            composer test
          fi
        continue-on-error: ${{ vars.CI_TEST_IGNORE_FAILURE == '1' }}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Run tests
run: composer test-coverage
run: |
if [ "${{ matrix.php-versions }}" != "8.2" ]; then
composer test-coverage
else
composer test
fi
- name: Run tests
run: |
# Skip coverage for PHP 8.2 to reduce CI time (coverage is collected on other PHP versions)
if [ "${{ matrix.php-versions }}" != "8.2" ]; then
composer test-coverage
else
composer test
fi
🤖 Prompt for AI Agents
.github/workflows/test-php.yml lines 60-66: the workflow conditionally skips
coverage for PHP 8.2 but has no explanation; add a brief inline comment above or
beside the conditional explaining the rationale (e.g., to reduce CI time on the
latest matrix entry, or due to a known PHPUnit 11/coverage-tooling
incompatibility) and, if applicable, include a link to an issue or ticket that
documents the technical limitation and note whether skipping is temporary.

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