Open herndlm opened 5 months ago
The following PHP HTML template code causes a false positive via DisallowYodaComparison:
DisallowYodaComparison
<input type="radio" <?= $disabledInputs ? 'disabled' : '' ?> <?= $policy === Policy::PUBLIC->value ? 'checked' : '' ?> value="<?= esc_attr(Policy::PUBLIC->value) ?>">
even more interesting though maybe, if I try to auto-fix this I end up with the following which is syntactically very different:
<input type="radio" <?= $disabledInputs ? 'disabled' : Policy::PUBLIC->value === '' ?> <?= $policy ? 'checked' : '' ?> value="<?= esc_attr(Policy::PUBLIC->value) ?>">
it looks like the 2 independent ternaries are somehow influencing each other. adding a semicolon after the first ternary or not using the <?= short tag but use echo() instead seems to work around it.
<?=
echo()
Our sniffs are not tested for PHP templates. I'm ok to merge PR that will fix it but we will not try to fix it ourself.
The following PHP HTML template code causes a false positive via
DisallowYodaComparison
:even more interesting though maybe, if I try to auto-fix this I end up with the following which is syntactically very different:
it looks like the 2 independent ternaries are somehow influencing each other. adding a semicolon after the first ternary or not using the
<?=
short tag but useecho()
instead seems to work around it.