Skip to content

Drop the wrong Twig options from sstv_display_with_vat - #15

Open
loevgaard wants to merge 1 commit into
masterfrom
fix/twig-function-options
Open

loevgaard wants to merge 1 commit into
masterfrom
fix/twig-function-options

Conversation

@loevgaard

Copy link
Copy Markdown
Member

sstv_display_with_vat was registered with two options that do not apply to it:

needs_environment => true — Twig therefore compiles the call as ->displayWithVat($this->env), but Runtime::displayWithVat() declares no parameters. This only works because PHP silently ignores surplus arguments to userland functions; the moment the signature gains a parameter it starts receiving the Environment instead of what the caller meant.

is_safe => ['html'] — the function returns a bool. There is no markup to mark as safe, so the option is inert.

Both options are correct on sstv_vat_toggler (it does take the Environment, and it does return rendered HTML) and are left alone there.

No behaviour change — the existing Twig integration fixture still passes.

Addresses a nitpick from #5.

https://claude.ai/code/session_01P9NzuVPQGvaVR97HZFq98a

The function was registered with needs_environment, so Twig passed the
Environment as the first argument to Runtime::displayWithVat(), which declares
no parameters. It only worked because PHP silently ignores surplus arguments to
userland functions.

is_safe was equally wrong: the function returns a bool, so there is no markup
to mark as safe.

Both options remain on sstv_vat_toggler, where they are correct.

Claude-Session: https://claude.ai/code/session_01P9NzuVPQGvaVR97HZFq98a
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.

1 participant