Squiz.PHP.EmbeddedPhp.ContentAfterEnd and DOCTYPE
Author: kkmuffmeCreated Jan 24, 2023Updated Mar 9, 2026
Describe the bug
Code sample
?><!DOCTYPE html>Custom ruleset
<?xml version="1.0"?>
<ruleset name="My Custom Standard">
<description>If you are using a custom ruleset, please enter it here.</description>
<rule ref="Squiz.PHP.EmbeddedPhp.ContentAfterEnd"/>
</ruleset>To reproduce Steps to reproduce the behavior:
- Create a file called
test.phpwith the code sample above... - Run
phpcbf test.php ... - phpcbf created invalid HTML
?>
<!DOCTYPE html>Expected behavior There is no space allowed before the DOCTYPE tag - any space before the DOCTYPE will cause browsers to run quirks mode.
Versions (please complete the following information):
- OS: Centos 8
- PHP: 7.4
- PHPCS: master
- Standard: custom
Source: squizlabs/PHP_CodeSniffer