Skip to content

refactor(doctrine): reference date filters constants from interface #2057

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

Conversation

vinceAmstoutz
Copy link
Contributor

This PR refactors references to constants by switching from child to parent class references.

When child classes use constants defined in the base class (\ApiPlatform\Doctrine\Common\Filter\DateFilterInterface), they inherit these constants directly from the parent. This approach enhances reusability and maintainability, ensuring that standardized values like INCLUDE_NULL_BEFORE_AND_AFTER and other date-filtering constants are accessed directly from the source.

This simplifies future modifications to constants and reduces the risk of inconsistencies across classes implementing or extending date-filtering behavior.

Phpstorm also warns it:

Constant from base class '\ApiPlatform\Doctrine\Common\Filter\DateFilterInterface' referenced via child class

…ent interface

Switched to using parent class constants directly in child classes for date-filtering strategies. Enhances code maintainability and consistency by centralizing constant values in the base interface (`DateFilterInterface`).
@vinceAmstoutz
Copy link
Contributor Author

We also have this in the Filters documentation for the OrderFilter, if it's okay in this PR, I'll create a PR for the OrderFilter as well @soyuka @dunglas.

@soyuka soyuka changed the title refactor(doctrine-filters): reference date filters constants from parent interface refactor(doctrine): reference date filters constants from interface Nov 14, 2024
@soyuka soyuka merged commit c2149d0 into api-platform:4.0 Nov 14, 2024
1 check passed
@vinceAmstoutz vinceAmstoutz deleted the fix-doctrine-date-filter-interface-constants branch November 14, 2024 15:17
vinceAmstoutz added a commit to vinceAmstoutz/api-platform-docs that referenced this pull request Nov 21, 2024
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.

3 participants