- Issue created by @nico.b
Under some circumstances, phpcbf produces some incorrect results when using CRLF line endings with the current (and also some older) version(s) of Coder when running phpcbf on a file.
- Create a file with the following content (with CRLF line breaks):
<?php
/**
* Implements hook_theme().
*/
function example_theme($existing, $type, $theme, $path): array {
return [];
}
- Run phpcbf on the file (with "Drupal" coding standard).
- phpcbf produces the following result:
<?php
/**
* @file
* @file
* @file
* .*/
/**
* Implements hook_theme(). *
*/ example_theme($existing, $type, $theme, $path): array {
return [];
}
- With LF line endings, the result is produced as expected.
I have also attached a (minimal) setup (including config) that causes the issue for me:
- Unzip the directory
- Run "composer install" in the directory
- Run "./vendor/bin/phpcbf .\example_broken.php" → This produces the incorrect result.
- Run "./vendor/bin/phpcbf .\example_works.php" → This produces the expected result.
The only diff between the two files should be the line endings.
At some point while testing, I also had a version with CRLF endings where phpcbf ran into some infinite loop and then aborted because of this (while it again worked fine with LF endings). I was not able to reproduce this anymore though, so I am not sure under which exact conditions this happens.
There was also a similar issue with line endings in the past, I don't know if they may be related: https://www.drupal.org/project/coder/issues/3307937 🐛 phpcbf fails with "Uninitialized string offset" on CRLF line endings Fixed
tbd
- Fix
Active
8.3
Coder Sniffer