Php-cs-fixer: Feature Request: Copyright header configuration in header_comment

Created on 7 Dec 2016  路  7Comments  路  Source: FriendsOfPHP/PHP-CS-Fixer

Because copyright headers should be pinned to the year a file was created, header_comment quickly becomes impractical, as the copyright year can be different depending on the file. Excluding the copyright year is not an option for everyone.

It would be great to have options like this:

return PhpCsFixer\Config::create()
    ->setRules([
        'header_comment' => [
            'ignore_copyright' => true,
            'default_copyright' => 'Copyright Brent Shaffer ' . date('Y')
        ]
    ]);

// or...

return PhpCsFixer\Config::create()
    ->setRules([
        'header_comment' => [
            'copyright' => [
                'ignore' => true,
                'default' => 'Copyright Brent Shaffer ' . date('Y')
            ]
        ]
    ])

Thoughts?

kinfeature request

Most helpful comment

:-1: for Levenshtein , if there is a typo in one file I want to have it fixed
:+1: for pattern matching

All 7 comments

if you want to keep a year in file header why not keep it up to date for all files?

@keradus because Copyright headers should reflect the year the file was added, not the current year.

why is that? created-current, as one didnt throw copyrights away
like 2015-2016

I feel like newer files should not have a previous copyright year.

To not copy-paste discussion let me hijack the thread and move forward discussion into https://github.com/GoogleCloudPlatform/php-docs-samples/pull/263#discussion_r90998582 ;)

Maybe we could try a diff. approach. How about only replacing a header with the configured header if the current header is different more than a configurable Levenshtein distance?

:-1: for Levenshtein , if there is a typo in one file I want to have it fixed
:+1: for pattern matching

Was this page helpful?
0 / 5 - 0 ratings