$ php -v
PHP 7.1.2 (cli) (built: Feb 15 2017 08:01:35) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
with Xdebug v2.5.1, Copyright (c) 2002-2017, by Derick Rethans
```
$ php-cs-fixer -V
PHP CS Fixer version 2.1.1 by Fabien Potencier and Dariusz Ruminski (e0e33ce)
I have
'declare_strict_types' => true,
and
'header_comment' => ['header' => $header, 'separate' => 'none'],
in my `.php_cs` and
```php
<?php
/*
* This file is part of foo
*
* (c) Sebastian Bergmann <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace SebastianBergmann\Foo;
class Bar
{
// ...
is transformed into
<?php
/*
* This file is part of foo
*
* (c) Sebastian Bergmann <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
/*
* This file is part of foo
*
* (c) Sebastian Bergmann <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\Foo;
class Bar
{
// ...
Hi,
Sorry you got hit by this issue. There is a bit of talk about here;
https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/2058
https://github.com/FriendsOfPHP/PHP-CS-Fixer/issues/2062
Unfortunately nobody found the time to fix this yet.
@sebastianbergmann, maybe you want to help with that ?
I was hit by this issue. If you need to remove the header from a PHP file between the opening tag and the namespace declaration, you can use this command:
find src -name '*.php' | xargs -L 1 sed -i '' '/^..php/,/^namespace .*;/{//!d;}'
thanks @marcw for the pointer,
sadly we didn't get around fixing this within the fixer yet...
I added https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/4883 but I don't know the cs fixer code or token system very well. I tried it in our project and it seems to work.
Closing in favor of #3467.