如何根据 GNU/GPL 来源正确评论 PHP 文件

How to propertly comment a PHP file based on GNU/GPL source

我的问题很简单。我有一个基于另一个使用 GNU/GPL 2.0 许可证交付的应用程序的应用程序(简而言之:更改代码,我将使用相同的许可证和新名称交付)。我的 php 文件头应该如何使一切正常(不要破坏 GNU/GPL 2.0 许可证)。例子会很棒。

这是一个很好的例子:

/**
 * @package     GovArticle.Administrator
 * @subpackage  com_govarticle.layouts
 * @author      Artur Stępień (artur@example.pl)
 * @copyright   (C) 2005 - 2015 Open Source Matters. All rights reserved.
 * @copyright   (C) 2015 - Fundacja PCJ Otwarte Źródła
 * @license     http://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html   
 * @link        http://dostepny.joomla.pl
 * 
 * Based on com_content layouts from Joomla!
 */

(基于pear.php.net sample file

@copyrights是为了标明谁拥有原代码的版权。也可以有不止一个 @author 标签来显示谁是原始来源的作者(在我的例子中没有原始作者,只有版权标记)。

GNU/GPL 2.0 不需要特定的文档样式,但是 recommends that you include something like the following text in every source file:

This file is part of Foobar.

Foobar is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Foobar is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Foobar. If not, see http://www.gnu.org/licenses/.

您可能不需要在每个文件中都添加如此长的通知,请参阅 Copyright notices/disclaimers in source files,您展示的内容可能就足够了。

如果您希望使用标准方式记录您的代码,您可以使用 phpDocumentor (phpDoc)

PEAR has a good sample file 如何记录您的代码。

编辑:如果您在自己的程序中使用第三方 GPL 代码,您还应该注明原作者,请参阅下面的 Flosculus 评论。