Skip to content

Refactor: properly handle callable array even when options are missing #1371

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

Draft
wants to merge 11 commits into
base: develop
Choose a base branch
from

Conversation

matteotrubini
Copy link
Contributor

Improved handling for cases where $callable is an array but does not include the $callable['options'] key. In such cases, the default options are preserved and no errors occur.

Also streamlined the normalization logic by explicitly checking for valid entries (!empty())

⚠️ If this logic proves to be correct and stable, it should be applied to the makeTwigFilters() function as well for consistency.
Eventually, both implementations could be unified into a shared helper, as they follow the same logic.

Improved handling for cases where `$callable` is an array but does not include the `$callable['options']` key.
In such cases, the default options are preserved and no errors occur.

Also streamlined the normalization logic by explicitly checking for valid entries (`!empty()`)
@LukeTowers
Copy link
Member

@matteotrubini can you add some test cases for this?

Expanded MarkupManagerTest to cover registration and validation of Twig functions, including handling of options, default options, empty callables, and invalid callables.
@LukeTowers LukeTowers self-requested a review June 24, 2025 14:53
@LukeTowers LukeTowers added the needs review Issues/PRs that require a review from a maintainer label Jun 24, 2025
@matteotrubini
Copy link
Contributor Author

@LukeTowers, once I get your green light, I’ll proceed with makeTwigFilters() as described in the first comment.

@LukeTowers
Copy link
Member

@matteotrubini ideally the options logic that's present everywhere in Winter could be centralized to a helper as much as possible. Should be good to proceed with the makeTwigFilters

@matteotrubini matteotrubini force-pushed the markupmanager-makeTwig-callable branch from ed98069 to 4f88f25 Compare July 13, 2025 11:42
@matteotrubini matteotrubini force-pushed the markupmanager-makeTwig-callable branch from 39e3d0c to 21c9cbd Compare July 13, 2025 14:05
@matteotrubini
Copy link
Contributor Author

I have finished my review and the tests are green. I would squash the commits before marking the PR as ready - what do you think, @LukeTowers?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs review Issues/PRs that require a review from a maintainer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants