Skip to content

Closes #35: Remove WP Rocket coupling from generic package - #46

Merged
remyperona merged 3 commits into
developfrom
enhancement/35-remove-rocket-coupling
Aug 14, 2026
Merged

Closes #35: Remove WP Rocket coupling from generic package#46
remyperona merged 3 commits into
developfrom
enhancement/35-remove-rocket-coupling

Conversation

@remyperona

Copy link
Copy Markdown
Contributor

🤖 AI-generated — created by an automated pipeline. Review before acting on this.

Closes #35

Description

Removes hard-coded WP Rocket coupling from the package, replacing rocket_get_constant() and rocket_has_constant() helpers with neutral inline defined()/constant() accessors. This allows consumers to use this generic package without inheriting WP Rocket-specific dependencies.

What was done

  • Updated ApiTrait::getApiCredential() to use standard PHP defined()/constant() checks instead of WP Rocket helpers
  • Removed rocket_get_constant() and rocket_has_constant() polyfills from Fixtures/polyfills.php
  • Added unit tests validating the new behavior (5 new tests)
  • Updated README.md documentation
  • Updated PHPStan baseline configuration

How to test

  • Run the unit test suite: phpunit
  • Run static analysis: phpstan analyse and phpcs
  • Verify all 101 unit tests pass (0 failures)
  • Verify PHPStan shows 0 errors
  • Verify PHPCS shows 0 violations

Files changed

  • src/Integration/ApiTrait.php
  • src/Fixtures/polyfills.php
  • phpstan-baseline.neon
  • Tests/Unit/testApiTrait.php
  • README.md

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Affected Features & Quality Assurance Scope

  • Generic API credential resolution
  • Package fixture setup
  • Static analysis baseline

Technical description

The package previously relied on WP Rocket's rocket_get_constant() helper to safely resolve constants. This created an unnecessary coupling to a specific WordPress plugin. The solution uses PHP's native defined() and constant() functions directly, which is more portable and doesn't require external dependencies.

New dependencies

None.

Risks

None identified. This is purely an internal refactoring that maintains backward compatibility for consumers of the package.

…kage

ApiTrait::getApiCredential() now resolves constants with a neutral
defined()/constant() check instead of calling WP Rocket's
rocket_get_constant() helper, and the rocket_get_constant()/
rocket_has_constant() polyfills are removed from Fixtures/polyfills.php
so consumers of this generic package no longer inherit a
rocket_-prefixed coupling.

Closes #35

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
remyperona and others added 2 commits August 14, 2026 14:49
…t suite to standard

Follow-up to the #35 WP Rocket decoupling: removes src/Fixtures/polyfills.php
entirely along with TestCaseTrait::stubPolyfills() and Unit\TestCase's
$stubPolyfills gate, since nothing in the package uses that extension point
anymore. Adds declare(strict_types=1) to every file touched by this change,
brings ApiTrait.php, TestCaseTrait.php, and Unit\TestCase.php into PHPCS scope
(0 violations), and rewrites the ApiTrait unit test as a single
@dataProvider-driven test following the getDefaultVfs() convention, with its
scenarios in Tests/Fixtures/ApiTrait/getApiCredential.php.

Refs #35

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The src/Fixtures directory was removed along with the empty polyfills
file; PHPStan CI failed because the path no longer exists.

Refs #35

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@remyperona
remyperona marked this pull request as ready for review August 14, 2026 19:12
@remyperona
remyperona merged commit 0fa4a85 into develop Aug 14, 2026
9 checks passed
@remyperona
remyperona deleted the enhancement/35-remove-rocket-coupling branch August 14, 2026 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove WP Rocket coupling (rocket_get_constant) from the generic package

1 participant