-
-
Notifications
You must be signed in to change notification settings - Fork 89
Closed as not planned
Closed as not planned
Copy link
Labels
Description
Describe the bug
Opening PHP tag must be on a line by itself
Closing PHP tag must be on a line by itself
Code sample
<span data-foo="<?php
echo "hello";
?>">
Custom ruleset
https://github.com/WordPress/WordPress-Coding-Standards
To reproduce
See WP CI in WordPress/wordpress-develop#8335 https://github.com/WordPress/wordpress-develop/actions/runs/13371451585/job/37340655741?pr=8335
Expected behavior
Putting the PHP opening/closing tags on a separate line when used in attributes means that the attribute will include leading/trailing whitespace in output.
Since browsers know this is a common bug, they tend to ignore it, but it means that e.g. href= includes an invalid URL.
For some attributes it might actually break it or have unintended behavior e.g. pattern=, placeholder=
Besides the fact, that newlines aren't allowed in attributes.
Versions (please complete the following information)
I guess 3.11.3 in WP CI
Please confirm
- I have searched the issue list and am not opening a duplicate issue.
- I have read the Contribution Guidelines and this is not a support question.
- I confirm that this bug is a bug in PHP_CodeSniffer and not in one of the external standards.
- I have verified the issue still exists in the
master
branch of PHP_CodeSniffer.