Merge branch 'QA_4_6'
This commit is contained in:
commit
c2419ee951
@ -3,7 +3,7 @@ imports:
|
||||
- javascript
|
||||
- php
|
||||
filter:
|
||||
excluded_paths: [libraries/bfShapeFiles/*, PMAStandard/*, js/jquery/*, js/jqplot/*, js/openlayers/*, js/codemirror/*, js/canvg/*, js/tracekit/*, js/sprintf.js]
|
||||
excluded_paths: [libraries/bfShapeFiles/*, js/jquery/*, js/jqplot/*, js/openlayers/*, js/codemirror/*, js/canvg/*, js/tracekit/*, js/sprintf.js]
|
||||
tools:
|
||||
php_code_sniffer:
|
||||
config:
|
||||
|
||||
@ -1,137 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Parses and verifies the doc comments for classes.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_CodeSniffer
|
||||
* @author Greg Sherwood <gsherwood@squiz.net>
|
||||
* @author Marc McIntyre <mmcintyre@squiz.net>
|
||||
* @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
|
||||
* @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
|
||||
* @link http://pear.php.net/package/PHP_CodeSniffer
|
||||
*/
|
||||
|
||||
/**
|
||||
* Parses and verifies the doc comments for classes.
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_CodeSniffer
|
||||
* @author Greg Sherwood <gsherwood@squiz.net>
|
||||
* @author Marc McIntyre <mmcintyre@squiz.net>
|
||||
* @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
|
||||
* @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
|
||||
* @version Release: 2.2.0
|
||||
* @link http://pear.php.net/package/PHP_CodeSniffer
|
||||
*/
|
||||
class PMAStandard_Sniffs_Commenting_ClassCommentSniff extends PMAStandard_Sniffs_Commenting_FileCommentSniff
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* Returns an array of tokens this test wants to listen for.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
return array(
|
||||
T_CLASS,
|
||||
T_INTERFACE,
|
||||
);
|
||||
|
||||
}//end register()
|
||||
|
||||
|
||||
/**
|
||||
* Processes this test, when one of its tokens is encountered.
|
||||
*
|
||||
* @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
||||
* @param int $stackPtr The position of the current token
|
||||
* in the stack passed in $tokens.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
||||
{
|
||||
$this->currentFile = $phpcsFile;
|
||||
|
||||
$tokens = $phpcsFile->getTokens();
|
||||
$type = strtolower($tokens[$stackPtr]['content']);
|
||||
$errorData = array($type);
|
||||
|
||||
$find = PHP_CodeSniffer_Tokens::$methodPrefixes;
|
||||
$find[] = T_WHITESPACE;
|
||||
|
||||
$commentEnd = $phpcsFile->findPrevious($find, ($stackPtr - 1), null, true);
|
||||
if ($tokens[$commentEnd]['code'] !== T_DOC_COMMENT_CLOSE_TAG
|
||||
&& $tokens[$commentEnd]['code'] !== T_COMMENT
|
||||
) {
|
||||
$phpcsFile->addError('Missing class doc comment', $stackPtr, 'Missing');
|
||||
$phpcsFile->recordMetric($stackPtr, 'Class has doc comment', 'no');
|
||||
return;
|
||||
} else {
|
||||
$phpcsFile->recordMetric($stackPtr, 'Class has doc comment', 'yes');
|
||||
}
|
||||
|
||||
// Try and determine if this is a file comment instead of a class comment.
|
||||
// We assume that if this is the first comment after the open PHP tag, then
|
||||
// it is most likely a file comment instead of a class comment.
|
||||
if ($tokens[$commentEnd]['code'] === T_DOC_COMMENT_CLOSE_TAG) {
|
||||
$start = ($tokens[$commentEnd]['comment_opener'] - 1);
|
||||
} else {
|
||||
$start = $phpcsFile->findPrevious(T_COMMENT, ($commentEnd - 1), null, true);
|
||||
}
|
||||
|
||||
$prev = $phpcsFile->findPrevious(T_WHITESPACE, $start, null, true);
|
||||
if ($tokens[$prev]['code'] === T_OPEN_TAG) {
|
||||
$prevOpen = $phpcsFile->findPrevious(T_OPEN_TAG, ($prev - 1));
|
||||
if ($prevOpen === false) {
|
||||
// This is a comment directly after the first open tag,
|
||||
// so probably a file comment.
|
||||
$phpcsFile->addError('Missing class doc comment', $stackPtr, 'Missing');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ($tokens[$commentEnd]['code'] === T_COMMENT) {
|
||||
$phpcsFile->addError('You must use "/**" style comments for a class comment', $stackPtr, 'WrongStyle');
|
||||
return;
|
||||
}
|
||||
|
||||
// Check each tag.
|
||||
$this->processTags($phpcsFile, $stackPtr, $tokens[$commentEnd]['comment_opener']);
|
||||
|
||||
}//end process()
|
||||
|
||||
|
||||
/**
|
||||
* Process the version tag.
|
||||
*
|
||||
* @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
||||
* @param array $tags The tokens for these tags.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function processVersion(PHP_CodeSniffer_File $phpcsFile, array $tags)
|
||||
{
|
||||
$tokens = $phpcsFile->getTokens();
|
||||
foreach ($tags as $tag) {
|
||||
if ($tokens[($tag + 2)]['code'] !== T_DOC_COMMENT_STRING) {
|
||||
// No content.
|
||||
continue;
|
||||
}
|
||||
|
||||
$content = $tokens[($tag + 2)]['content'];
|
||||
if ((strstr($content, 'Release:') === false)) {
|
||||
$error = 'Invalid version "%s" in doc comment; consider "Release: <package_version>" instead';
|
||||
$data = array($content);
|
||||
$phpcsFile->addWarning($error, $tag, 'InvalidVersion', $data);
|
||||
}
|
||||
}
|
||||
|
||||
}//end processVersion()
|
||||
|
||||
|
||||
}//end class
|
||||
@ -1,526 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Parses and verifies the doc comments for files.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_CodeSniffer
|
||||
* @author Greg Sherwood <gsherwood@squiz.net>
|
||||
* @author Marc McIntyre <mmcintyre@squiz.net>
|
||||
* @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
|
||||
* @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
|
||||
* @link http://pear.php.net/package/PHP_CodeSniffer
|
||||
*/
|
||||
|
||||
/**
|
||||
* Parses and verifies the doc comments for files.
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_CodeSniffer
|
||||
* @author Greg Sherwood <gsherwood@squiz.net>
|
||||
* @author Marc McIntyre <mmcintyre@squiz.net>
|
||||
* @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
|
||||
* @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
|
||||
* @version Release: 2.2.0
|
||||
* @link http://pear.php.net/package/PHP_CodeSniffer
|
||||
*/
|
||||
|
||||
class PMAStandard_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
|
||||
{
|
||||
|
||||
/**
|
||||
* Tags in correct order and related info.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $tags = array(
|
||||
'@category' => array(
|
||||
'required' => false,
|
||||
'allow_multiple' => false,
|
||||
),
|
||||
'@package' => array(
|
||||
'required' => true,
|
||||
'allow_multiple' => false,
|
||||
),
|
||||
'@subpackage' => array(
|
||||
'required' => false,
|
||||
'allow_multiple' => false,
|
||||
),
|
||||
'@author' => array(
|
||||
'required' => false,
|
||||
'allow_multiple' => true,
|
||||
),
|
||||
'@copyright' => array(
|
||||
'required' => false,
|
||||
'allow_multiple' => true,
|
||||
),
|
||||
'@license' => array(
|
||||
'required' => false,
|
||||
'allow_multiple' => false,
|
||||
),
|
||||
'@version' => array(
|
||||
'required' => false,
|
||||
'allow_multiple' => false,
|
||||
),
|
||||
'@link' => array(
|
||||
'required' => false,
|
||||
'allow_multiple' => true,
|
||||
),
|
||||
'@see' => array(
|
||||
'required' => false,
|
||||
'allow_multiple' => true,
|
||||
),
|
||||
'@since' => array(
|
||||
'required' => false,
|
||||
'allow_multiple' => false,
|
||||
),
|
||||
'@deprecated' => array(
|
||||
'required' => false,
|
||||
'allow_multiple' => false,
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* Returns an array of tokens this test wants to listen for.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
return array(T_OPEN_TAG);
|
||||
|
||||
}//end register()
|
||||
|
||||
|
||||
/**
|
||||
* Processes this test, when one of its tokens is encountered.
|
||||
*
|
||||
* @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
||||
* @param int $stackPtr The position of the current token
|
||||
* in the stack passed in $tokens.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
||||
{
|
||||
$tokens = $phpcsFile->getTokens();
|
||||
|
||||
// Find the next non whitespace token.
|
||||
$commentStart = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true);
|
||||
|
||||
// Allow declare() statements at the top of the file.
|
||||
if ($tokens[$commentStart]['code'] === T_DECLARE) {
|
||||
$semicolon = $phpcsFile->findNext(T_SEMICOLON, ($commentStart + 1));
|
||||
$commentStart = $phpcsFile->findNext(T_WHITESPACE, ($semicolon + 1), null, true);
|
||||
}
|
||||
|
||||
// Ignore vim header.
|
||||
if ($tokens[$commentStart]['code'] === T_COMMENT) {
|
||||
if (strstr($tokens[$commentStart]['content'], 'vim:') !== false) {
|
||||
$commentStart = $phpcsFile->findNext(
|
||||
T_WHITESPACE,
|
||||
($commentStart + 1),
|
||||
null,
|
||||
true
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$errorToken = ($stackPtr + 1);
|
||||
if (isset($tokens[$errorToken]) === false) {
|
||||
$errorToken--;
|
||||
}
|
||||
|
||||
if ($tokens[$commentStart]['code'] === T_CLOSE_TAG) {
|
||||
// We are only interested if this is the first open tag.
|
||||
return ($phpcsFile->numTokens + 1);
|
||||
} else if ($tokens[$commentStart]['code'] === T_COMMENT) {
|
||||
$error = 'You must use "/**" style comments for a file comment';
|
||||
$phpcsFile->addError($error, $errorToken, 'WrongStyle');
|
||||
$phpcsFile->recordMetric($stackPtr, 'File has doc comment', 'yes');
|
||||
return ($phpcsFile->numTokens + 1);
|
||||
} else if ($commentStart === false
|
||||
|| $tokens[$commentStart]['code'] !== T_DOC_COMMENT_OPEN_TAG
|
||||
) {
|
||||
$phpcsFile->addError('Missing file doc comment', $errorToken, 'Missing');
|
||||
$phpcsFile->recordMetric($stackPtr, 'File has doc comment', 'no');
|
||||
return ($phpcsFile->numTokens + 1);
|
||||
} else {
|
||||
$phpcsFile->recordMetric($stackPtr, 'File has doc comment', 'yes');
|
||||
}
|
||||
|
||||
// Check each tag.
|
||||
$this->processTags($phpcsFile, $stackPtr, $commentStart);
|
||||
|
||||
// Ignore the rest of the file.
|
||||
return ($phpcsFile->numTokens + 1);
|
||||
|
||||
}//end process()
|
||||
|
||||
|
||||
/**
|
||||
* Processes each required or optional tag.
|
||||
*
|
||||
* @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
||||
* @param int $stackPtr The position of the current token
|
||||
* in the stack passed in $tokens.
|
||||
* @param int $commentStart Position in the stack where the comment started.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function processTags(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $commentStart)
|
||||
{
|
||||
$tokens = $phpcsFile->getTokens();
|
||||
|
||||
if (get_class($this) === 'PMAStandard_Sniffs_Commenting_FileCommentSniff') {
|
||||
$docBlock = 'file';
|
||||
} else {
|
||||
$docBlock = 'class';
|
||||
}
|
||||
|
||||
$commentEnd = $tokens[$commentStart]['comment_closer'];
|
||||
|
||||
$foundTags = array();
|
||||
$tagTokens = array();
|
||||
foreach ($tokens[$commentStart]['comment_tags'] as $tag) {
|
||||
$name = $tokens[$tag]['content'];
|
||||
if (isset($this->tags[$name]) === false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($this->tags[$name]['allow_multiple'] === false && isset($tagTokens[$name]) === true) {
|
||||
$error = 'Only one %s tag is allowed in a %s comment';
|
||||
$data = array(
|
||||
$name,
|
||||
$docBlock,
|
||||
);
|
||||
$phpcsFile->addError($error, $tag, 'Duplicate'.ucfirst($name).'Tag', $data);
|
||||
}
|
||||
|
||||
$foundTags[] = $name;
|
||||
$tagTokens[$name][] = $tag;
|
||||
|
||||
$string = $phpcsFile->findNext(T_DOC_COMMENT_STRING, $tag, $commentEnd);
|
||||
if ($string === false || $tokens[$string]['line'] !== $tokens[$tag]['line']) {
|
||||
$error = 'Content missing for %s tag in %s comment';
|
||||
$data = array(
|
||||
$name,
|
||||
$docBlock,
|
||||
);
|
||||
$phpcsFile->addError($error, $tag, 'Empty'.ucfirst($name).'Tag', $data);
|
||||
continue;
|
||||
}
|
||||
}//end foreach
|
||||
|
||||
// Check if the tags are in the correct position.
|
||||
$pos = 0;
|
||||
foreach ($this->tags as $tag => $tagData) {
|
||||
if (isset($tagTokens[$tag]) === false) {
|
||||
if ($tagData['required'] === true) {
|
||||
$error = 'Missing %s tag in %s comment';
|
||||
$data = array(
|
||||
$tag,
|
||||
$docBlock,
|
||||
);
|
||||
$phpcsFile->addError($error, $commentEnd, 'Missing'.ucfirst(substr($tag, 1)).'Tag', $data);
|
||||
}
|
||||
|
||||
continue;
|
||||
} else {
|
||||
$method = 'process'.substr($tag, 1);
|
||||
if (method_exists($this, $method) === true) {
|
||||
// Process each tag if a method is defined.
|
||||
call_user_func(array($this, $method), $phpcsFile, $tagTokens[$tag]);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($foundTags[$pos]) === false) {
|
||||
break;
|
||||
}
|
||||
|
||||
if ($foundTags[$pos] !== $tag) {
|
||||
$error = 'The tag in position %s should be the %s tag';
|
||||
$data = array(
|
||||
($pos + 1),
|
||||
$tag,
|
||||
);
|
||||
$phpcsFile->addError($error, $tokens[$commentStart]['comment_tags'][$pos], ucfirst($tag).'TagOrder', $data);
|
||||
}
|
||||
|
||||
// Account for multiple tags.
|
||||
$pos++;
|
||||
while (isset($foundTags[$pos]) === true && $foundTags[$pos] === $tag) {
|
||||
$pos++;
|
||||
}
|
||||
}//end foreach
|
||||
|
||||
}//end processTags()
|
||||
|
||||
|
||||
/**
|
||||
* Process the category tag.
|
||||
*
|
||||
* @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
||||
* @param array $tags The tokens for these tags.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function processCategory(PHP_CodeSniffer_File $phpcsFile, array $tags)
|
||||
{
|
||||
$tokens = $phpcsFile->getTokens();
|
||||
foreach ($tags as $tag) {
|
||||
if ($tokens[($tag + 2)]['code'] !== T_DOC_COMMENT_STRING) {
|
||||
// No content.
|
||||
continue;
|
||||
}
|
||||
|
||||
$content = $tokens[($tag + 2)]['content'];
|
||||
if (PHP_CodeSniffer::isUnderscoreName($content) !== true) {
|
||||
$newContent = str_replace(' ', '_', $content);
|
||||
$nameBits = explode('_', $newContent);
|
||||
$firstBit = array_shift($nameBits);
|
||||
$newName = ucfirst($firstBit).'_';
|
||||
foreach ($nameBits as $bit) {
|
||||
if ($bit !== '') {
|
||||
$newName .= ucfirst($bit).'_';
|
||||
}
|
||||
}
|
||||
|
||||
$error = 'Category name "%s" is not valid; consider "%s" instead';
|
||||
$validName = trim($newName, '_');
|
||||
$data = array(
|
||||
$content,
|
||||
$validName,
|
||||
);
|
||||
$phpcsFile->addError($error, $tag, 'InvalidCategory', $data);
|
||||
}
|
||||
}//end foreach
|
||||
|
||||
}//end processCategory()
|
||||
|
||||
|
||||
/**
|
||||
* Process the package tag.
|
||||
*
|
||||
* @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
||||
* @param array $tags The tokens for these tags.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function processPackage(PHP_CodeSniffer_File $phpcsFile, array $tags)
|
||||
{
|
||||
$tokens = $phpcsFile->getTokens();
|
||||
foreach ($tags as $tag) {
|
||||
if ($tokens[($tag + 2)]['code'] !== T_DOC_COMMENT_STRING) {
|
||||
// No content.
|
||||
continue;
|
||||
}
|
||||
|
||||
$content = $tokens[($tag + 2)]['content'];
|
||||
if (PHP_CodeSniffer::isUnderscoreName($content) === true) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$newContent = str_replace(' ', '_', $content);
|
||||
$newContent = trim($newContent, '_');
|
||||
$newContent = preg_replace('/[^A-Za-z_]/', '', $newContent);
|
||||
$nameBits = explode('_', $newContent);
|
||||
$firstBit = array_shift($nameBits);
|
||||
$newName = strtoupper($firstBit{0}).substr($firstBit, 1).'_';
|
||||
foreach ($nameBits as $bit) {
|
||||
if ($bit !== '') {
|
||||
$newName .= strtoupper($bit{0}).substr($bit, 1).'_';
|
||||
}
|
||||
}
|
||||
|
||||
$error = 'Package name "%s" is not valid; consider "%s" instead';
|
||||
$validName = trim($newName, '_');
|
||||
$data = array(
|
||||
$content,
|
||||
$validName,
|
||||
);
|
||||
$phpcsFile->addError($error, $tag, 'InvalidPackage', $data);
|
||||
}//end foreach
|
||||
|
||||
}//end processPackage()
|
||||
|
||||
|
||||
/**
|
||||
* Process the subpackage tag.
|
||||
*
|
||||
* @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
||||
* @param array $tags The tokens for these tags.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function processSubpackage(PHP_CodeSniffer_File $phpcsFile, array $tags)
|
||||
{
|
||||
$tokens = $phpcsFile->getTokens();
|
||||
foreach ($tags as $tag) {
|
||||
if ($tokens[($tag + 2)]['code'] !== T_DOC_COMMENT_STRING) {
|
||||
// No content.
|
||||
continue;
|
||||
}
|
||||
|
||||
$content = $tokens[($tag + 2)]['content'];
|
||||
if (PHP_CodeSniffer::isUnderscoreName($content) === true) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$newContent = str_replace(' ', '_', $content);
|
||||
$nameBits = explode('_', $newContent);
|
||||
$firstBit = array_shift($nameBits);
|
||||
$newName = strtoupper($firstBit{0}).substr($firstBit, 1).'_';
|
||||
foreach ($nameBits as $bit) {
|
||||
if ($bit !== '') {
|
||||
$newName .= strtoupper($bit{0}).substr($bit, 1).'_';
|
||||
}
|
||||
}
|
||||
|
||||
$error = 'Subpackage name "%s" is not valid; consider "%s" instead';
|
||||
$validName = trim($newName, '_');
|
||||
$data = array(
|
||||
$content,
|
||||
$validName,
|
||||
);
|
||||
$phpcsFile->addError($error, $tag, 'InvalidSubpackage', $data);
|
||||
}//end foreach
|
||||
|
||||
}//end processSubpackage()
|
||||
|
||||
|
||||
/**
|
||||
* Process the author tag(s) that this header comment has.
|
||||
*
|
||||
* @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
||||
* @param array $tags The tokens for these tags.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function processAuthor(PHP_CodeSniffer_File $phpcsFile, array $tags)
|
||||
{
|
||||
$tokens = $phpcsFile->getTokens();
|
||||
foreach ($tags as $tag) {
|
||||
if ($tokens[($tag + 2)]['code'] !== T_DOC_COMMENT_STRING) {
|
||||
// No content.
|
||||
continue;
|
||||
}
|
||||
|
||||
$content = $tokens[($tag + 2)]['content'];
|
||||
$local = '\da-zA-Z-_+';
|
||||
// Dot character cannot be the first or last character in the local-part.
|
||||
$localMiddle = $local.'.\w';
|
||||
if (preg_match('/^([^<]*)\s+<(['.$local.'](['.$localMiddle.']*['.$local.'])*@[\da-zA-Z][-.\w]*[\da-zA-Z]\.[a-zA-Z]{2,7})>$/', $content) === 0) {
|
||||
$error = 'Content of the @author tag must be in the form "Display Name <username@example.com>"';
|
||||
$phpcsFile->addError($error, $tag, 'InvalidAuthors');
|
||||
}
|
||||
}
|
||||
|
||||
}//end processAuthor()
|
||||
|
||||
|
||||
/**
|
||||
* Process the copyright tags.
|
||||
*
|
||||
* @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
||||
* @param array $tags The tokens for these tags.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function processCopyright(PHP_CodeSniffer_File $phpcsFile, array $tags)
|
||||
{
|
||||
$tokens = $phpcsFile->getTokens();
|
||||
foreach ($tags as $tag) {
|
||||
if ($tokens[($tag + 2)]['code'] !== T_DOC_COMMENT_STRING) {
|
||||
// No content.
|
||||
continue;
|
||||
}
|
||||
|
||||
$content = $tokens[($tag + 2)]['content'];
|
||||
$matches = array();
|
||||
if (preg_match('/^([0-9]{4})((.{1})([0-9]{4}))? (.+)$/', $content, $matches) !== 0) {
|
||||
// Check earliest-latest year order.
|
||||
if ($matches[3] !== '') {
|
||||
if ($matches[3] !== '-') {
|
||||
$error = 'A hyphen must be used between the earliest and latest year';
|
||||
$phpcsFile->addError($error, $tag, 'CopyrightHyphen');
|
||||
}
|
||||
|
||||
if ($matches[4] !== '' && $matches[4] < $matches[1]) {
|
||||
$error = "Invalid year span \"$matches[1]$matches[3]$matches[4]\" found; consider \"$matches[4]-$matches[1]\" instead";
|
||||
$phpcsFile->addWarning($error, $tag, 'InvalidCopyright');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$error = '@copyright tag must contain a year and the name of the copyright holder';
|
||||
$phpcsFile->addError($error, $tag, 'IncompleteCopyright');
|
||||
}
|
||||
}//end foreach
|
||||
|
||||
}//end processCopyright()
|
||||
|
||||
|
||||
/**
|
||||
* Process the license tag.
|
||||
*
|
||||
* @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
||||
* @param array $tags The tokens for these tags.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function processLicense(PHP_CodeSniffer_File $phpcsFile, array $tags)
|
||||
{
|
||||
$tokens = $phpcsFile->getTokens();
|
||||
foreach ($tags as $tag) {
|
||||
if ($tokens[($tag + 2)]['code'] !== T_DOC_COMMENT_STRING) {
|
||||
// No content.
|
||||
continue;
|
||||
}
|
||||
|
||||
$content = $tokens[($tag + 2)]['content'];
|
||||
$matches = array();
|
||||
preg_match('/^([^\s]+)\s+(.*)/', $content, $matches);
|
||||
if (count($matches) !== 3) {
|
||||
$error = '@license tag must contain a URL and a license name';
|
||||
$phpcsFile->addError($error, $tag, 'IncompleteLicense');
|
||||
}
|
||||
}
|
||||
|
||||
}//end processLicense()
|
||||
|
||||
|
||||
/**
|
||||
* Process the version tag.
|
||||
*
|
||||
* @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
||||
* @param array $tags The tokens for these tags.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function processVersion(PHP_CodeSniffer_File $phpcsFile, array $tags)
|
||||
{
|
||||
$tokens = $phpcsFile->getTokens();
|
||||
foreach ($tags as $tag) {
|
||||
if ($tokens[($tag + 2)]['code'] !== T_DOC_COMMENT_STRING) {
|
||||
// No content.
|
||||
continue;
|
||||
}
|
||||
|
||||
$content = $tokens[($tag + 2)]['content'];
|
||||
if (strstr($content, 'CVS:') === false
|
||||
&& strstr($content, 'SVN:') === false
|
||||
&& strstr($content, 'GIT:') === false
|
||||
&& strstr($content, 'HG:') === false
|
||||
) {
|
||||
$error = 'Invalid version "%s" in file comment; consider "CVS: <cvs_id>" or "SVN: <svn_id>" or "GIT: <git_id>" or "HG: <hg_id>" instead';
|
||||
$data = array($content);
|
||||
$phpcsFile->addWarning($error, $tag, 'InvalidVersion', $data);
|
||||
}
|
||||
}
|
||||
|
||||
}//end processVersion()
|
||||
|
||||
|
||||
}//end class
|
||||
@ -1,384 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Parses and verifies the doc comments for functions.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_CodeSniffer
|
||||
* @author Greg Sherwood <gsherwood@squiz.net>
|
||||
* @author Marc McIntyre <mmcintyre@squiz.net>
|
||||
* @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
|
||||
* @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
|
||||
* @link http://pear.php.net/package/PHP_CodeSniffer
|
||||
*/
|
||||
|
||||
/**
|
||||
* Parses and verifies the doc comments for functions.
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_CodeSniffer
|
||||
* @author Greg Sherwood <gsherwood@squiz.net>
|
||||
* @author Marc McIntyre <mmcintyre@squiz.net>
|
||||
* @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
|
||||
* @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
|
||||
* @version Release: 2.2.0
|
||||
* @link http://pear.php.net/package/PHP_CodeSniffer
|
||||
*/
|
||||
class PMAStandard_Sniffs_Commenting_FunctionCommentSniff implements PHP_CodeSniffer_Sniff
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* Returns an array of tokens this test wants to listen for.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
return array(T_FUNCTION);
|
||||
|
||||
}//end register()
|
||||
|
||||
|
||||
/**
|
||||
* Processes this test, when one of its tokens is encountered.
|
||||
*
|
||||
* @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
||||
* @param int $stackPtr The position of the current token
|
||||
* in the stack passed in $tokens.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
||||
{
|
||||
$tokens = $phpcsFile->getTokens();
|
||||
$find = PHP_CodeSniffer_Tokens::$methodPrefixes;
|
||||
$find[] = T_WHITESPACE;
|
||||
|
||||
$commentEnd = $phpcsFile->findPrevious($find, ($stackPtr - 1), null, true);
|
||||
if ($tokens[$commentEnd]['code'] === T_COMMENT) {
|
||||
// Inline comments might just be closing comments for
|
||||
// control structures or functions instead of function comments
|
||||
// using the wrong comment type. If there is other code on the line,
|
||||
// assume they relate to that code.
|
||||
$prev = $phpcsFile->findPrevious($find, ($commentEnd - 1), null, true);
|
||||
if ($prev !== false && $tokens[$prev]['line'] === $tokens[$commentEnd]['line']) {
|
||||
$commentEnd = $prev;
|
||||
}
|
||||
}
|
||||
|
||||
if ($tokens[$commentEnd]['code'] !== T_DOC_COMMENT_CLOSE_TAG
|
||||
&& $tokens[$commentEnd]['code'] !== T_COMMENT
|
||||
) {
|
||||
$phpcsFile->addError('Missing function doc comment', $stackPtr, 'Missing');
|
||||
$phpcsFile->recordMetric($stackPtr, 'Function has doc comment', 'no');
|
||||
return;
|
||||
} else {
|
||||
$phpcsFile->recordMetric($stackPtr, 'Function has doc comment', 'yes');
|
||||
}
|
||||
|
||||
if ($tokens[$commentEnd]['code'] === T_COMMENT) {
|
||||
$phpcsFile->addError('You must use "/**" style comments for a function comment', $stackPtr, 'WrongStyle');
|
||||
return;
|
||||
}
|
||||
|
||||
if ($tokens[$commentEnd]['line'] !== ($tokens[$stackPtr]['line'] - 1)) {
|
||||
$error = 'There must be no blank lines after the function comment';
|
||||
$phpcsFile->addError($error, $commentEnd, 'SpacingAfter');
|
||||
}
|
||||
|
||||
$commentStart = $tokens[$commentEnd]['comment_opener'];
|
||||
foreach ($tokens[$commentStart]['comment_tags'] as $tag) {
|
||||
if ($tokens[$tag]['content'] === '@see') {
|
||||
// Make sure the tag isn't empty.
|
||||
$string = $phpcsFile->findNext(T_DOC_COMMENT_STRING, $tag, $commentEnd);
|
||||
if ($string === false || $tokens[$string]['line'] !== $tokens[$tag]['line']) {
|
||||
$error = 'Content missing for @see tag in function comment';
|
||||
$phpcsFile->addError($error, $tag, 'EmptySees');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->processReturn($phpcsFile, $stackPtr, $commentStart);
|
||||
$this->processThrows($phpcsFile, $stackPtr, $commentStart);
|
||||
$this->processParams($phpcsFile, $stackPtr, $commentStart);
|
||||
|
||||
}//end process()
|
||||
|
||||
|
||||
/**
|
||||
* Process the return comment of this function comment.
|
||||
*
|
||||
* @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
||||
* @param int $stackPtr The position of the current token
|
||||
* in the stack passed in $tokens.
|
||||
* @param int $commentStart The position in the stack where the comment started.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function processReturn(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $commentStart)
|
||||
{
|
||||
$tokens = $phpcsFile->getTokens();
|
||||
|
||||
// Skip constructor and destructor.
|
||||
$methodName = $phpcsFile->getDeclarationName($stackPtr);
|
||||
$isSpecialMethod = ($methodName === '__construct' || $methodName === '__destruct');
|
||||
|
||||
$return = null;
|
||||
foreach ($tokens[$commentStart]['comment_tags'] as $tag) {
|
||||
if ($tokens[$tag]['content'] === '@return') {
|
||||
if ($return !== null) {
|
||||
$error = 'Only 1 @return tag is allowed in a function comment';
|
||||
$phpcsFile->addError($error, $tag, 'DuplicateReturn');
|
||||
return;
|
||||
}
|
||||
|
||||
$return = $tag;
|
||||
}
|
||||
}
|
||||
|
||||
if ($isSpecialMethod === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($return !== null) {
|
||||
$content = $tokens[($return + 2)]['content'];
|
||||
if (empty($content) === true || $tokens[($return + 2)]['code'] !== T_DOC_COMMENT_STRING) {
|
||||
$error = 'Return type missing for @return tag in function comment';
|
||||
$phpcsFile->addError($error, $return, 'MissingReturnType');
|
||||
}
|
||||
} else {
|
||||
$error = 'Missing @return tag in function comment';
|
||||
$phpcsFile->addError($error, $tokens[$commentStart]['comment_closer'], 'MissingReturn');
|
||||
}//end if
|
||||
|
||||
}//end processReturn()
|
||||
|
||||
|
||||
/**
|
||||
* Process any throw tags that this function comment has.
|
||||
*
|
||||
* @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
||||
* @param int $stackPtr The position of the current token
|
||||
* in the stack passed in $tokens.
|
||||
* @param int $commentStart The position in the stack where the comment started.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function processThrows(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $commentStart)
|
||||
{
|
||||
$tokens = $phpcsFile->getTokens();
|
||||
|
||||
$throws = array();
|
||||
foreach ($tokens[$commentStart]['comment_tags'] as $tag) {
|
||||
if ($tokens[$tag]['content'] !== '@throws') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$exception = null;
|
||||
$comment = null;
|
||||
if ($tokens[($tag + 2)]['code'] === T_DOC_COMMENT_STRING) {
|
||||
$matches = array();
|
||||
preg_match('/([^\s]+)(?:\s+(.*))?/', $tokens[($tag + 2)]['content'], $matches);
|
||||
$exception = $matches[1];
|
||||
if (isset($matches[2]) === true) {
|
||||
$comment = $matches[2];
|
||||
}
|
||||
}
|
||||
|
||||
if ($exception === null) {
|
||||
$error = 'Exception type missing for @throws tag in function comment';
|
||||
$phpcsFile->addError($error, $tag, 'InvalidThrows');
|
||||
}
|
||||
}//end foreach
|
||||
|
||||
}//end processThrows()
|
||||
|
||||
|
||||
/**
|
||||
* Process the function parameter comments.
|
||||
*
|
||||
* @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
|
||||
* @param int $stackPtr The position of the current token
|
||||
* in the stack passed in $tokens.
|
||||
* @param int $commentStart The position in the stack where the comment started.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function processParams(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $commentStart)
|
||||
{
|
||||
$tokens = $phpcsFile->getTokens();
|
||||
|
||||
$params = array();
|
||||
$maxType = 0;
|
||||
$maxVar = 0;
|
||||
foreach ($tokens[$commentStart]['comment_tags'] as $pos => $tag) {
|
||||
if ($tokens[$tag]['content'] !== '@param') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$type = '';
|
||||
$typeSpace = 0;
|
||||
$var = '';
|
||||
$varSpace = 0;
|
||||
$comment = '';
|
||||
if ($tokens[($tag + 2)]['code'] === T_DOC_COMMENT_STRING) {
|
||||
$matches = array();
|
||||
preg_match('/([^$&]+)(?:((?:\$|&)[^\s]+)(?:(\s+)(.*))?)?/', $tokens[($tag + 2)]['content'], $matches);
|
||||
$typeLen = strlen($matches[1]);
|
||||
$type = trim($matches[1]);
|
||||
$typeSpace = ($typeLen - strlen($type));
|
||||
$typeLen = strlen($type);
|
||||
if ($typeLen > $maxType) {
|
||||
$maxType = $typeLen;
|
||||
}
|
||||
|
||||
if (isset($matches[2]) === true) {
|
||||
$var = $matches[2];
|
||||
$varLen = strlen($var);
|
||||
if ($varLen > $maxVar) {
|
||||
$maxVar = $varLen;
|
||||
}
|
||||
|
||||
if (isset($matches[4]) === true) {
|
||||
$varSpace = strlen($matches[3]);
|
||||
$comment = $matches[4];
|
||||
|
||||
// Any strings until the next tag belong to this comment.
|
||||
if (isset($tokens[$commentStart]['comment_tags'][($pos + 1)]) === true) {
|
||||
$end = $tokens[$commentStart]['comment_tags'][($pos + 1)];
|
||||
} else {
|
||||
$end = $tokens[$commentStart]['comment_closer'];
|
||||
}
|
||||
|
||||
for ($i = ($tag + 3); $i < $end; $i++) {
|
||||
if ($tokens[$i]['code'] === T_DOC_COMMENT_STRING) {
|
||||
$comment .= ' '.$tokens[$i]['content'];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$error = 'Missing parameter comment';
|
||||
$phpcsFile->addError($error, $tag, 'MissingParamComment');
|
||||
}
|
||||
} else {
|
||||
$error = 'Missing parameter name';
|
||||
$phpcsFile->addError($error, $tag, 'MissingParamName');
|
||||
}//end if
|
||||
} else {
|
||||
$error = 'Missing parameter type';
|
||||
$phpcsFile->addError($error, $tag, 'MissingParamType');
|
||||
}//end if
|
||||
|
||||
$params[] = array(
|
||||
'tag' => $tag,
|
||||
'type' => $type,
|
||||
'var' => $var,
|
||||
'comment' => $comment,
|
||||
'type_space' => $typeSpace,
|
||||
'var_space' => $varSpace,
|
||||
);
|
||||
}//end foreach
|
||||
|
||||
$realParams = $phpcsFile->getMethodParameters($stackPtr);
|
||||
$foundParams = array();
|
||||
foreach ($params as $pos => $param) {
|
||||
if ($param['var'] === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$foundParams[] = $param['var'];
|
||||
|
||||
// Check number of spaces after the type.
|
||||
$spaces = ($maxType - strlen($param['type']) + 1);
|
||||
if ($param['type_space'] !== $spaces) {
|
||||
$error = 'Expected %s spaces after parameter type; %s found';
|
||||
$data = array(
|
||||
$spaces,
|
||||
$param['type_space'],
|
||||
);
|
||||
|
||||
$fix = $phpcsFile->addFixableError($error, $param['tag'], 'SpacingAfterParamType', $data);
|
||||
if ($fix === true) {
|
||||
$content = $param['type'];
|
||||
$content .= str_repeat(' ', $spaces);
|
||||
$content .= $param['var'];
|
||||
$content .= str_repeat(' ', $param['var_space']);
|
||||
$content .= $param['comment'];
|
||||
$phpcsFile->fixer->replaceToken(($param['tag'] + 2), $content);
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure the param name is correct.
|
||||
if (isset($realParams[$pos]) === true) {
|
||||
// PMAStandard tweak for pass by reference variable:
|
||||
// Variable should have '&' in doc comment
|
||||
if ($realParams[$pos]['pass_by_reference'] === true) {
|
||||
$realParams[$pos]['name'] = '&' . $realParams[$pos]['name'];
|
||||
}
|
||||
$realName = $realParams[$pos]['name'];
|
||||
if ($realName !== $param['var']) {
|
||||
$code = 'ParamNameNoMatch';
|
||||
$data = array(
|
||||
$param['var'],
|
||||
$realName,
|
||||
);
|
||||
|
||||
$error = 'Doc comment for parameter %s does not match ';
|
||||
if (strtolower($param['var']) === strtolower($realName)) {
|
||||
$error .= 'case of ';
|
||||
$code = 'ParamNameNoCaseMatch';
|
||||
}
|
||||
|
||||
$error .= 'actual variable name %s';
|
||||
|
||||
$phpcsFile->addError($error, $param['tag'], $code, $data);
|
||||
}
|
||||
} else if (substr($param['var'], -4) !== ',...') {
|
||||
// We must have an extra parameter comment.
|
||||
$error = 'Superfluous parameter comment';
|
||||
$phpcsFile->addError($error, $param['tag'], 'ExtraParamComment');
|
||||
}//end if
|
||||
|
||||
if ($param['comment'] === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check number of spaces after the var name.
|
||||
$spaces = ($maxVar - strlen($param['var']) + 1);
|
||||
if ($param['var_space'] !== $spaces) {
|
||||
$error = 'Expected %s spaces after parameter name; %s found';
|
||||
$data = array(
|
||||
$spaces,
|
||||
$param['var_space'],
|
||||
);
|
||||
|
||||
$fix = $phpcsFile->addFixableError($error, $param['tag'], 'SpacingAfterParamName', $data);
|
||||
if ($fix === true) {
|
||||
$content = $param['type'];
|
||||
$content .= str_repeat(' ', $param['type_space']);
|
||||
$content .= $param['var'];
|
||||
$content .= str_repeat(' ', $spaces);
|
||||
$content .= $param['comment'];
|
||||
$phpcsFile->fixer->replaceToken(($param['tag'] + 2), $content);
|
||||
}
|
||||
}
|
||||
}//end foreach
|
||||
|
||||
$realNames = array();
|
||||
foreach ($realParams as $realParam) {
|
||||
$realNames[] = $realParam['name'];
|
||||
}
|
||||
|
||||
// Report missing comments.
|
||||
$diff = array_diff($realNames, $foundParams);
|
||||
foreach ($diff as $neededParam) {
|
||||
$error = 'Doc comment for parameter "%s" missing';
|
||||
$data = array($neededParam);
|
||||
$phpcsFile->addError($error, $commentStart, 'MissingParamTag', $data);
|
||||
}
|
||||
|
||||
}//end processParams()
|
||||
|
||||
|
||||
}//end class
|
||||
@ -1,78 +0,0 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Class for a sniff to oblige whitespaces before and after a concatenation operator
|
||||
*
|
||||
* This Sniff check if a whitespace is missing before or after any concatenation
|
||||
* operator.
|
||||
* The concatenation operator is identified by the PHP token T_STRING_CONCAT
|
||||
* The whitespace is identified by the PHP token T_WHITESPACE
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_CodeSniffer
|
||||
* @since September, the 12th 2013
|
||||
*/
|
||||
|
||||
/// {{{ PMAStandard_Sniffs_Files_SpacesAroundConcatSniff
|
||||
/**
|
||||
* Sniff to oblige whitespaces before and after a concatenation operator
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_CodeSniffer
|
||||
* @name SpacesAroundConcatSniff
|
||||
* @version Release: 1.0
|
||||
*/
|
||||
class PMAStandard_Sniffs_Files_SpacesAroundConcatSniff implements PHP_CodeSniffer_Sniff
|
||||
{
|
||||
|
||||
// {{{ register()
|
||||
|
||||
/**
|
||||
* Returns the token types that this sniff is interested in.
|
||||
*
|
||||
* @name register
|
||||
* @access public
|
||||
* @see PHP_CodeSniffer_Sniff::register()
|
||||
*
|
||||
* @return array(int)
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
return array(T_STRING_CONCAT);
|
||||
|
||||
}//end register()
|
||||
|
||||
// }}}
|
||||
// {{{ process()
|
||||
|
||||
/**
|
||||
* Processes the tokens that this sniff is interested in.
|
||||
*
|
||||
* @name process
|
||||
* @access public
|
||||
* @see PHP_CodeSniffer_Sniff::process()
|
||||
* @param PHP_CodeSniffer_File $phpcsFile The file where the token was found.
|
||||
* @param int $stackPtr The position in the stack where the token was found.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
||||
{
|
||||
$tokens = $phpcsFile->getTokens();
|
||||
if ($tokens[$stackPtr-1]['type'] !== 'T_WHITESPACE') {
|
||||
$warning = 'Whitespace is expected before any concat operator "."';
|
||||
$phpcsFile->addWarning($warning, $stackPtr, 'Found');
|
||||
}
|
||||
if ($tokens[$stackPtr+1]['type'] !== 'T_WHITESPACE') {
|
||||
$warning = 'Whitespace is expected after any concat operator "."';
|
||||
$phpcsFile->addWarning($warning, $stackPtr, 'Found');
|
||||
}
|
||||
}//end process()
|
||||
|
||||
// }}}
|
||||
|
||||
}//end class
|
||||
|
||||
// }}}
|
||||
@ -1,10 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<ruleset name="phpMyAdmin Standard">
|
||||
<!-- http://pear.php.net/manual/en/package.php.php-codesniffer.annotated-ruleset.php -->
|
||||
<description>phpMyAdmin custom coding standard</description>
|
||||
|
||||
<rule ref="PSR1" />
|
||||
<rule ref="Generic.Metrics.NestingLevel" />
|
||||
<!-- There MUST NOT be trailing whitespace at the end of lines. -->
|
||||
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace" />
|
||||
</ruleset>
|
||||
14
build.xml
14
build.xml
@ -55,7 +55,7 @@
|
||||
<arg line="${source_comma_sep}
|
||||
xml
|
||||
codesize,design,naming,unusedcode
|
||||
--exclude test,build,bfShapeFiles,PMAStandard,vendor
|
||||
--exclude test,build,bfShapeFiles,vendor
|
||||
--reportfile '${basedir}/build/logs/pmd.xml'" />
|
||||
</exec>
|
||||
</target>
|
||||
@ -64,7 +64,6 @@
|
||||
<exec executable="phpcpd">
|
||||
<arg line="--log-pmd '${basedir}/build/logs/pmd-cpd.xml'
|
||||
--exclude test
|
||||
--exclude PMAStandard
|
||||
--exclude build
|
||||
--exclude vendor
|
||||
--exclude libraries/bfShapeFiles
|
||||
@ -76,7 +75,6 @@
|
||||
<exec executable="phploc">
|
||||
<arg line="--log-csv '${basedir}/build/logs/phploc.csv'
|
||||
--exclude test
|
||||
--exclude PMAStandard
|
||||
--exclude build
|
||||
--exclude vendor
|
||||
--exclude libraries/bfShapeFiles
|
||||
@ -84,10 +82,16 @@
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<target name="phpcs" description="Generate checkstyle.xml using PHP_CodeSniffer excluding third party libraries">
|
||||
<target name="phpcs-config" description="PHPCS configuration tweaking">
|
||||
<exec executable="phpcs">
|
||||
<arg line="--config-set installed_paths ${basedir}/vendor/phpmyadmin/coding-standard" />
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<target name="phpcs" description="Generate checkstyle.xml using PHP_CodeSniffer excluding third party libraries" depends="phpcs-config">
|
||||
<exec executable="phpcs">
|
||||
<arg line="
|
||||
--ignore=*/vendor/*,*/canvg/*,*/codemirror/*,*/openlayers/*,*/jquery/*,*/jqplot/*,*/build/*,*/bfShapeFiles/*,*/PMAStandard/*
|
||||
--ignore=*/vendor/*,*/canvg/*,*/codemirror/*,*/openlayers/*,*/jquery/*,*/jqplot/*,*/build/*,*/bfShapeFiles/*
|
||||
--report=checkstyle
|
||||
--extensions=php
|
||||
--report-file='${basedir}/build/logs/checkstyle.xml'
|
||||
|
||||
@ -47,6 +47,7 @@
|
||||
"phpunit/phpunit": "~4.1",
|
||||
"codacy/coverage": "dev-master",
|
||||
"phpunit/phpunit-selenium": "~1.2",
|
||||
"phpmyadmin/coding-standard": ">=0.1.0",
|
||||
"squizlabs/php_codesniffer": "2.*"
|
||||
},
|
||||
"repositories": [
|
||||
|
||||
@ -47,8 +47,6 @@
|
||||
<directory>test/</directory>
|
||||
<!-- we don't care about coverage of embedded libraries -->
|
||||
<directory suffix=".php">libraries/bfShapeFiles</directory>
|
||||
<!-- code sniffer checker -->
|
||||
<directory suffix=".php">PMAStandard</directory>
|
||||
<!-- examples for users -->
|
||||
<directory suffix=".php">examples</directory>
|
||||
<!-- maintenance scripts -->
|
||||
|
||||
Loading…
Reference in New Issue
Block a user