Skip to content

Fix SimpleEquation operator handling and filter error source resolution - #35

Merged
ericges merged 5 commits into
mainfrom
fix/simple-equation-exception
Sep 7, 2026
Merged

ericges merged 5 commits into
mainfrom
fix/simple-equation-exception

Conversation

@ericges

@ericges ericges commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes two exceptions that could surface when using SimpleEquationElement / the equation engine mod, completes the operator coverage of the element, and cleans up how a filter's error source is resolved.

Changes

SimpleEquationMod — operator resolution

The mod passed $options['operator'] straight through to SimpleEquationElement::define(), which expects a SqlEquationOperator. When the mod is invoked with a raw operator string (i.e. without the OptionsResolver normalizer having run on the options), this ended in a TypeError. The operator is now resolved via SqlEquationOperator::match() inside __invoke(), with an explicit InvalidArgumentException when it cannot be matched.

SimpleEquationElement — missing IN / NOT_IN arms

Both operators exist in SqlEquationOperator but had no expression mapping, so they silently fell into the default => null arm and the filter was rejected as unsupported. They now map to $qb->expr()->in() / notIn().

That made the match exhaustive over all enum cases, so PHPStan flagged the last arm as an always-true comparison. The default => null arm is kept as a runtime safety net for operators added to the enum later and the error is ignored inline (@phpstan-ignore match.alwaysTrue); since reportUnmatchedIgnoredErrors is on, the annotation cannot rot — it becomes an error itself once the default arm is reachable again.

Filter error source handling

FilterModel::getFilterIdentifier() returned a bare id, and each caller prefixed it with a hardcoded tl_flare_filter.id=. It now returns the fully qualified %table%.id=%id% itself, derived from static::$strTable.

That lets both call sites collapse to a single null-safe expression, which also fixes a real bug: FilterExecutor::createCallbackException() dereferenced a possibly-null data source while building the exception for another error, masking the original failure. Inlined filters (no data source) now report filter inlined as their source in both FilterExecutor and InteractiveProjector.

Also adds the missing trailing newline to the touched files.

Notes

No test suite exists in this repo, so the changes were verified by reading through the call paths; make phpstan is clean.

Adding IN/NOT_IN made the operator match exhaustive, so PHPStan flagged the
last enum arm as an always-true comparison and the trailing default arm as
redundant. Keep the default arm as a runtime safety net for operators added
to the enum later and ignore the error inline.
@ericges ericges changed the title Fix SimpleEquation operator handling and null data source in FilterException Fix SimpleEquation operator handling and filter error source resolution Sep 7, 2026
@ericges
ericges merged commit a1b3cc3 into main Sep 7, 2026
15 checks passed
@ericges
ericges deleted the fix/simple-equation-exception branch September 7, 2026 13:28
ericges added a commit that referenced this pull request Sep 7, 2026
The fix from #35 added these arms to `SimpleEquationElement::__invoke()` on
`main`. This branch had already moved that `match` into
`SimpleEquationFilterType::buildQuery()`, so the rebase dropped them.
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