From 749f66de3942373bb9232ff32cd45e459bfb1493 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Thu, 26 Apr 2012 15:38:57 +0200 Subject: [PATCH] Adjust PEAR coding standard to our use - do not require some phpdoc tags - do not require PHP version to be specified --- .../Sniffs/Commenting/ClassCommentSniff.php | 6 +-- .../Sniffs/Commenting/FileCommentSniff.php | 37 ++++--------------- .../Commenting/FunctionCommentSniff.php | 2 +- .../Sniffs/Commenting/InlineCommentSniff.php | 2 +- 4 files changed, 12 insertions(+), 35 deletions(-) diff --git a/PMAStandard/Sniffs/Commenting/ClassCommentSniff.php b/PMAStandard/Sniffs/Commenting/ClassCommentSniff.php index 0a6249b70e..51481c60b5 100644 --- a/PMAStandard/Sniffs/Commenting/ClassCommentSniff.php +++ b/PMAStandard/Sniffs/Commenting/ClassCommentSniff.php @@ -18,8 +18,8 @@ if (class_exists('PHP_CodeSniffer_CommentParser_ClassCommentParser', true) === f 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); } @@ -46,7 +46,7 @@ if (class_exists('PEAR_Sniffs_Commenting_FileCommentSniff', true) === false) { * @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 { diff --git a/PMAStandard/Sniffs/Commenting/FileCommentSniff.php b/PMAStandard/Sniffs/Commenting/FileCommentSniff.php index fbef7f3e60..2fbfd4e5c7 100644 --- a/PMAStandard/Sniffs/Commenting/FileCommentSniff.php +++ b/PMAStandard/Sniffs/Commenting/FileCommentSniff.php @@ -26,7 +26,6 @@ if (class_exists('PHP_CodeSniffer_CommentParser_ClassCommentParser', true) === f *
  • There is a blank newline after the short description.
  • *
  • There is a blank newline between the long and short description.
  • *
  • There is a blank newline between the long description and tags.
  • - *
  • A PHP version is specified.
  • *
  • Check the order of the tags.
  • *
  • Check the indentation of each tag.
  • *
  • Check required and optional tags and the format of their content.
  • @@ -42,7 +41,7 @@ if (class_exists('PHP_CodeSniffer_CommentParser_ClassCommentParser', true) === f * @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 { /** @@ -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', ), @@ -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', ), @@ -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', ), @@ -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', ), @@ -311,9 +310,6 @@ class PEAR_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff } } - // Check the PHP Version. - $this->processPHPVersion($commentStart, $commentEnd, $long); - // Check each tag. $this->processTags($commentStart, $commentEnd); }//end if @@ -321,25 +317,6 @@ class PEAR_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff }//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. * @@ -350,7 +327,7 @@ class PEAR_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff */ 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(); @@ -683,7 +660,7 @@ class PEAR_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff } } 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); } diff --git a/PMAStandard/Sniffs/Commenting/FunctionCommentSniff.php b/PMAStandard/Sniffs/Commenting/FunctionCommentSniff.php index 081c05d32b..8852c7700b 100644 --- a/PMAStandard/Sniffs/Commenting/FunctionCommentSniff.php +++ b/PMAStandard/Sniffs/Commenting/FunctionCommentSniff.php @@ -44,7 +44,7 @@ if (class_exists('PHP_CodeSniffer_CommentParser_FunctionCommentParser', true) == * @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 { /** diff --git a/PMAStandard/Sniffs/Commenting/InlineCommentSniff.php b/PMAStandard/Sniffs/Commenting/InlineCommentSniff.php index 3499be80d2..30ad0e0c15 100644 --- a/PMAStandard/Sniffs/Commenting/InlineCommentSniff.php +++ b/PMAStandard/Sniffs/Commenting/InlineCommentSniff.php @@ -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 {