PHP-CS-Fixer:如何删除标题DocBlock注释

时间:2016-10-25 16:18:58

标签: php

我错误地将DocBlock评论添加到了我的文件中:

/**
 * @author      My Name <my@email.com>
 * @copyright   Copyright (C) 2012 - 2015 My App. All rights reserved.
 * @license     Some notes about the license.
 */

但是这个错误,因为我希望标题注释设置如下:

/*
 * This file is part of the My App.
 *
 * Copyright My Name 2012-2016.
 *
 * This code is to consider private and non disclosable to anyone for whatever reason.
 * Every right on this code is reserved.
 *
 * @author My name <my@email.com>
 */

现在,我添加了标题评论using PHP-CS-Fixer,但是现在,我该如何删除旧评论?

1 个答案:

答案 0 :(得分:1)

使用friendsofphp/php-cs-fixer:^2.0.0,可以使用以下配置完全删除标题注释:

$config = PhpCsFixer\Config::create()->setRules([
    'header_comment' => [
        'header' => '',
    ],
]);

请注意我们如何提供空字符串。