Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reference Middleware and Strategy Headers via static keyword instead of self #189

Merged

Conversation

jblz
Copy link
Contributor

@jblz jblz commented Aug 27, 2024

Classes CacheMiddleware & GreedyCacheStrategy are shipped with this package with specific header names set via class constant:

const HEADER_RE_VALIDATION = 'X-Kevinrob-GuzzleCache-ReValidation';
const HEADER_INVALIDATION = 'X-Kevinrob-GuzzleCache-Invalidation';
const HEADER_CACHE_INFO = 'X-Kevinrob-Cache';
const HEADER_CACHE_HIT = 'HIT';
const HEADER_CACHE_MISS = 'MISS';
const HEADER_CACHE_STALE = 'STALE';

const HEADER_TTL = 'X-Kevinrob-GuzzleCache-TTL';

Extending these classes does not currently permit altering those values (unless the functionality altered in this PR are also overridden).

This change updates the references to these class constants to use the static keyword as opposed to self to take advantage of PHP's Late Static Bindings feature.

That way, custom implementations values are prioritized above the defaults for these headers.

I ran the automated test suite and it still passed for me.

Copy link
Owner

@Kevinrob Kevinrob left a comment

Choose a reason for hiding this comment

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

Thanks!

@Kevinrob Kevinrob merged commit c80bed9 into Kevinrob:master Aug 28, 2024
10 checks passed
@jblz jblz deleted the add/late-static-bound-header-constants branch August 28, 2024 13:31
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