Skip to content

Commit

Permalink
Adjust PEAR coding standard to our use
Browse files Browse the repository at this point in the history
- do not require some phpdoc tags
- do not require PHP version to be specified
  • Loading branch information
nijel committed Apr 26, 2012
1 parent 3571184 commit 749f66d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 35 deletions.
6 changes: 3 additions & 3 deletions PMAStandard/Sniffs/Commenting/ClassCommentSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
throw new PHP_CodeSniffer_Exception($error);
}

if (class_exists('PEAR_Sniffs_Commenting_FileCommentSniff', true) === false) {
$error = 'Class PEAR_Sniffs_Commenting_FileCommentSniff not found';
if (class_exists('PMAStandard_Sniffs_Commenting_FileCommentSniff', true) === false) {
$error = 'Class PMAStandard_Sniffs_Commenting_FileCommentSniff not found';
throw new PHP_CodeSniffer_Exception($error);
}

Expand All @@ -46,7 +46,7 @@
* @version Release: 1.3.3
* @link http://pear.php.net/package/PHP_CodeSniffer
*/
class PEAR_Sniffs_Commenting_ClassCommentSniff extends PEAR_Sniffs_Commenting_FileCommentSniff
class PMAStandard_Sniffs_Commenting_ClassCommentSniff extends PMAStandard_Sniffs_Commenting_FileCommentSniff
{


Expand Down
37 changes: 7 additions & 30 deletions PMAStandard/Sniffs/Commenting/FileCommentSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
* <li>There is a blank newline after the short description.</li>
* <li>There is a blank newline between the long and short description.</li>
* <li>There is a blank newline between the long description and tags.</li>
* <li>A PHP version is specified.</li>
* <li>Check the order of the tags.</li>
* <li>Check the indentation of each tag.</li>
* <li>Check required and optional tags and the format of their content.</li>
Expand All @@ -42,7 +41,7 @@
* @link http://pear.php.net/package/PHP_CodeSniffer
*/

class PEAR_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
class PMAStandard_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
{

/**
Expand All @@ -66,7 +65,7 @@ class PEAR_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
*/
protected $tags = array(
'category' => array(
'required' => true,
'required' => false,
'allow_multiple' => false,
'order_text' => 'precedes @package',
),
Expand All @@ -81,7 +80,7 @@ class PEAR_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
'order_text' => 'follows @package',
),
'author' => array(
'required' => true,
'required' => false,
'allow_multiple' => true,
'order_text' => 'follows @subpackage (if used) or @package',
),
Expand All @@ -91,7 +90,7 @@ class PEAR_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
'order_text' => 'follows @author',
),
'license' => array(
'required' => true,
'required' => false,
'allow_multiple' => false,
'order_text' => 'follows @copyright (if used) or @author',
),
Expand All @@ -101,7 +100,7 @@ class PEAR_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
'order_text' => 'follows @license',
),
'link' => array(
'required' => true,
'required' => false,
'allow_multiple' => true,
'order_text' => 'follows @version',
),
Expand Down Expand Up @@ -311,35 +310,13 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
}
}

// Check the PHP Version.
$this->processPHPVersion($commentStart, $commentEnd, $long);

// Check each tag.
$this->processTags($commentStart, $commentEnd);
}//end if

}//end process()


/**
* Check that the PHP version is specified.
*
* @param int $commentStart Position in the stack where the comment started.
* @param int $commentEnd Position in the stack where the comment ended.
* @param string $commentText The text of the function comment.
*
* @return void
*/
protected function processPHPVersion($commentStart, $commentEnd, $commentText)
{
if (strstr(strtolower($commentText), 'php version') === false) {
$error = 'PHP version not specified';
$this->currentFile->addWarning($error, $commentEnd, 'MissingVersion');
}

}//end processPHPVersion()


/**
* Processes each required or optional tag.
*
Expand All @@ -350,7 +327,7 @@ protected function processPHPVersion($commentStart, $commentEnd, $commentText)
*/
protected function processTags($commentStart, $commentEnd)
{
$docBlock = (get_class($this) === 'PEAR_Sniffs_Commenting_FileCommentSniff') ? 'file' : 'class';
$docBlock = (get_class($this) === 'PMAStandard_Sniffs_Commenting_FileCommentSniff') ? 'file' : 'class';
$foundTags = $this->commentParser->getTagOrders();
$orderIndex = 0;
$indentation = array();
Expand Down Expand Up @@ -683,7 +660,7 @@ protected function processAuthors($commentStart)
}
} else {
$error = 'Content missing for @author tag in %s comment';
$docBlock = (get_class($this) === 'PEAR_Sniffs_Commenting_FileCommentSniff') ? 'file' : 'class';
$docBlock = (get_class($this) === 'PMAStandard_Sniffs_Commenting_FileCommentSniff') ? 'file' : 'class';
$data = array($docBlock);
$this->currentFile->addError($error, $errorPos, 'EmptyAuthors', $data);
}
Expand Down
2 changes: 1 addition & 1 deletion PMAStandard/Sniffs/Commenting/FunctionCommentSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
* @version Release: 1.3.3
* @link http://pear.php.net/package/PHP_CodeSniffer
*/
class PEAR_Sniffs_Commenting_FunctionCommentSniff implements PHP_CodeSniffer_Sniff
class PMAStandard_Sniffs_Commenting_FunctionCommentSniff implements PHP_CodeSniffer_Sniff
{

/**
Expand Down
2 changes: 1 addition & 1 deletion PMAStandard/Sniffs/Commenting/InlineCommentSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* @version Release: 1.3.3
* @link http://pear.php.net/package/PHP_CodeSniffer
*/
class PEAR_Sniffs_Commenting_InlineCommentSniff implements PHP_CodeSniffer_Sniff
class PMAStandard_Sniffs_Commenting_InlineCommentSniff implements PHP_CodeSniffer_Sniff
{


Expand Down

0 comments on commit 749f66d

Please sign in to comment.