-
-
Notifications
You must be signed in to change notification settings - Fork 523
Closed
Labels
Description
Bug Description
Using phpcbf on a .php file with many opening and closing php tags both inline and multiline breaks the file completely. The result has < ? php with the spaces and missing closing tags.
Minimal Code Snippet
The issue happens when running this command:
phpcbf --standard=Wordpress-Core myfile.php... over a file containing this code:
<?php
if (have_rows('page_block')): ?>
<?php while (have_rows('page_block')):
the_row(); ?>
<?php if (get_row_layout() == 'my_block'): ?>
<?php include get_theme_file_path(
'my_block.php'
); ?>
<?php endif; ?>
<?php endwhile; ?>
<?php endif; ?>The file was auto-fixed via phpcbf to:
<?php
if ( have_rows( 'page_block' ) ) : ?>
<?php
while ( have_rows( 'page_block' ) ) :
the_row();
?>
<?php
if ( get_row_layout() == 'my_block' ) :
< ? php
include get_theme_file_path(
'my_block.php'
);
?>
<?php endif; ?>
<?php endwhile; ?>
<?php
endif;... while I expected the code to be fixed to:
<?php
if ( have_rows( 'page_block' ) ) {
while ( have_rows( 'page_block' ) ) {
the_row();
if ( get_row_layout() == 'my_block' ) {
include get_theme_file_path('/theme_extra/theme_blocks/page/timer_suppliers_block.php');
}
}
}Error Code
Custom ruleset
Environment
| Question | Answer |
|---|---|
| PHP version | 8.0.19 |
| PHP_CodeSniffer version | 3.7.1 |
| WPCS version | dev |
| WPCS install type | composer local |
| IDE (if relevant) | - |
Additional Context (optional)
Tested Against develop branch?
- I have verified the issue still exists in the
developbranch of WPCS.