-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from BrandonDusseau/iss-17-phpcs-3-update
Updates Sniffs to be compatible with PHP_CodeSniffer 3.0 and higher.
- Loading branch information
Showing
12 changed files
with
289 additions
and
228 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
Copyright (c) 2015-2017, Barracuda Networks, Inc. | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
* Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
* Redistributions in binary form must reproduce the above copyright | ||
notice, this list of conditions and the following disclaimer in the | ||
documentation and/or other materials provided with the distribution. | ||
* Neither the name of the <organization> nor the | ||
names of its contributors may be used to endorse or promote products | ||
derived from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY | ||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,26 @@ | ||
<?php | ||
/** | ||
* This sniff prohibits the use of single line multi line comments | ||
* This sniff prohibits the use of single line block comments | ||
* | ||
* PHP version 5 | ||
* | ||
* @category PHP | ||
* @package PHP_CodeSniffer | ||
* @author Ryan Matthews <[email protected]> | ||
* @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence | ||
* @version 1.0.00 | ||
* @link http://pear.php.net/package/PHP_CodeSniffer | ||
* @license BSD License 2.0, see LICENSE file. | ||
* @version 2.0.00 | ||
* @link https://github.com/BarracudaNetworks/Cuda-PHP-Code-Standards/ | ||
*/ | ||
|
||
namespace Barracuda\Sniffs\Commenting; | ||
|
||
use PHP_CodeSniffer\Sniffs\Sniff; | ||
use PHP_CodeSniffer\Files\File; | ||
|
||
/** | ||
* This sniff prohibits the use of Perl style hash comments. | ||
* | ||
* An example of a hash comment is: | ||
* | ||
* <code> | ||
* /* This is a single line multi line comment, which is prohibited. */ | ||
/* $hello = 'hello'; | ||
* </code> | ||
* | ||
* @category PHP | ||
* @package PHP_CodeSniffer | ||
* @author Ryan Matthews <[email protected]> | ||
* @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence | ||
* @version Release: 1.0.00 | ||
* @link http://pear.php.net/package/PHP_CodeSniffer | ||
* Prohibits single line block comments. | ||
*/ | ||
class Barracuda_Sniffs_Commenting_DisallowSingleLineMultiCommentsSniff implements PHP_CodeSniffer_Sniff | ||
class DisallowSingleLineMultiCommentsSniff implements Sniff | ||
{ | ||
|
||
|
||
|
@@ -48,13 +39,12 @@ public function register() | |
/** | ||
* Processes the tokens that this sniff is interested in. | ||
* | ||
* @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. | ||
* @param 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) | ||
public function process(File $phpcsFile, $stackPtr) | ||
{ | ||
$tokens = $phpcsFile->getTokens(); | ||
if (preg_match('/\/\*[^\n]*\*\//', $tokens[$stackPtr]['content'])) | ||
|
@@ -67,4 +57,3 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) | |
}// end process() | ||
} | ||
// end class | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,27 @@ | ||
<?php | ||
|
||
class Barracuda_Sniffs_Commenting_DocCommentSniff implements PHP_CodeSniffer_Sniff | ||
/** | ||
* This sniff controls requirements for PHP doc blocks. | ||
* | ||
* PHP version 5 | ||
* | ||
* @category PHP | ||
* @package PHP_CodeSniffer | ||
* @author Daniel Bergey <[email protected]> | ||
* @license BSD License 2.0, see LICENSE file. | ||
* @version 2.0.00 | ||
* @link https://github.com/BarracudaNetworks/Cuda-PHP-Code-Standards/ | ||
*/ | ||
|
||
namespace Barracuda\Sniffs\Commenting; | ||
|
||
use PHP_CodeSniffer\Sniffs\Sniff; | ||
use PHP_CodeSniffer\Files\File; | ||
use PHP_CodeSniffer\Util\Common; | ||
|
||
/** | ||
* Controls requirements for PHP doc blocks. | ||
*/ | ||
class DocCommentSniff implements Sniff | ||
{ | ||
|
||
/** | ||
|
@@ -71,13 +92,12 @@ public function 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. | ||
* @param 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) | ||
public function process(File $phpcsFile, $stackPtr) | ||
{ | ||
$tokens = $phpcsFile->getTokens(); | ||
|
||
|
@@ -156,14 +176,13 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) | |
/** | ||
* 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. | ||
* @param 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) | ||
protected function processTags(File $phpcsFile, $stackPtr, $commentStart) | ||
{ | ||
$tokens = $phpcsFile->getTokens(); | ||
|
||
|
@@ -255,12 +274,12 @@ protected function processTags(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $comm | |
/** | ||
* Process the category tag. | ||
* | ||
* @param PHP_CodeSniffer_File $phpcsFile The file being scanned. | ||
* @param array $tags The tokens for these tags. | ||
* @param 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) | ||
protected function processCategory(File $phpcsFile, array $tags) | ||
{ | ||
$tokens = $phpcsFile->getTokens(); | ||
foreach ($tags as $tag) { | ||
|
@@ -270,7 +289,7 @@ protected function processCategory(PHP_CodeSniffer_File $phpcsFile, array $tags) | |
} | ||
|
||
$content = $tokens[($tag + 2)]['content']; | ||
if (PHP_CodeSniffer::isUnderscoreName($content) !== true) { | ||
if (Common::isUnderscoreName($content) !== true) { | ||
$newContent = str_replace(' ', '_', $content); | ||
$nameBits = explode('_', $newContent); | ||
$firstBit = array_shift($nameBits); | ||
|
@@ -297,12 +316,12 @@ protected function processCategory(PHP_CodeSniffer_File $phpcsFile, array $tags) | |
/** | ||
* Process the package tag. | ||
* | ||
* @param PHP_CodeSniffer_File $phpcsFile The file being scanned. | ||
* @param array $tags The tokens for these tags. | ||
* @param 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) | ||
protected function processPackage(File $phpcsFile, array $tags) | ||
{ | ||
$tokens = $phpcsFile->getTokens(); | ||
foreach ($tags as $tag) { | ||
|
@@ -312,7 +331,7 @@ protected function processPackage(PHP_CodeSniffer_File $phpcsFile, array $tags) | |
} | ||
|
||
$content = $tokens[($tag + 2)]['content']; | ||
if (PHP_CodeSniffer::isUnderscoreName($content) === true) { | ||
if (Common::isUnderscoreName($content) === true) { | ||
continue; | ||
} | ||
|
||
|
@@ -343,12 +362,12 @@ protected function processPackage(PHP_CodeSniffer_File $phpcsFile, array $tags) | |
/** | ||
* Process the subpackage tag. | ||
* | ||
* @param PHP_CodeSniffer_File $phpcsFile The file being scanned. | ||
* @param array $tags The tokens for these tags. | ||
* @param 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) | ||
protected function processSubpackage(File $phpcsFile, array $tags) | ||
{ | ||
$tokens = $phpcsFile->getTokens(); | ||
foreach ($tags as $tag) { | ||
|
@@ -358,7 +377,7 @@ protected function processSubpackage(PHP_CodeSniffer_File $phpcsFile, array $tag | |
} | ||
|
||
$content = $tokens[($tag + 2)]['content']; | ||
if (PHP_CodeSniffer::isUnderscoreName($content) === true) { | ||
if (Common::isUnderscoreName($content) === true) { | ||
continue; | ||
} | ||
|
||
|
@@ -432,12 +451,12 @@ protected function processCopyrights($errorPos) | |
/** | ||
* Process the license tag. | ||
* | ||
* @param PHP_CodeSniffer_File $phpcsFile The file being scanned. | ||
* @param array $tags The tokens for these tags. | ||
* @param 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) | ||
protected function processLicense(File $phpcsFile, array $tags) | ||
{ | ||
$tokens = $phpcsFile->getTokens(); | ||
foreach ($tags as $tag) { | ||
|
@@ -461,12 +480,12 @@ protected function processLicense(PHP_CodeSniffer_File $phpcsFile, array $tags) | |
/** | ||
* Process the version tag. | ||
* | ||
* @param PHP_CodeSniffer_File $phpcsFile The file being scanned. | ||
* @param array $tags The tokens for these tags. | ||
* @param 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) | ||
protected function processVersion(File $phpcsFile, array $tags) | ||
{ | ||
$tokens = $phpcsFile->getTokens(); | ||
foreach ($tags as $tag) { | ||
|
Oops, something went wrong.