forked from cakephp/cakephp-codesniffer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First steps to have the old convention working...
- Loading branch information
1 parent
600f6bc
commit 051af93
Showing
76 changed files
with
3,706 additions
and
0 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,69 @@ | ||
<?php | ||
/** | ||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org) | ||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) | ||
* | ||
* Licensed under The MIT License | ||
* For full copyright and license information, please see the LICENSE.txt | ||
* Redistributions of files must retain the above copyright notice. | ||
* | ||
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) | ||
* @link http://pear.php.net/package/PHP_CodeSniffer_CakePHP | ||
* @since CakePHP CodeSniffer 1.0.0 | ||
* @license http://www.opensource.org/licenses/mit-license.php MIT License | ||
*/ | ||
|
||
/** | ||
* Ensures doc block alignments. | ||
*/ | ||
class CiriciOld_Sniffs_Commenting_DocBlockAlignmentSniff implements PHP_CodeSniffer_Sniff | ||
{ | ||
|
||
/** | ||
* Returns an array of tokens this test wants to listen for. | ||
* | ||
* @return array | ||
*/ | ||
public function register() | ||
{ | ||
return array(T_DOC_COMMENT_OPEN_TAG); | ||
} | ||
|
||
/** | ||
* Processes this test, when one of its tokens is encountered. | ||
* | ||
* @param PHP_CodeSniffer_File $phpcsFile The file being scanned. | ||
* @param integer $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(); | ||
$leftWall = array( | ||
T_CLASS, | ||
T_NAMESPACE, | ||
T_INTERFACE, | ||
T_TRAIT, | ||
T_USE | ||
); | ||
$oneIndentation = array( | ||
T_FUNCTION, | ||
T_VARIABLE, | ||
T_CONST | ||
); | ||
$allTokens = array_merge($leftWall, $oneIndentation); | ||
$notFlatFile = $phpcsFile->findNext(T_NAMESPACE, 0); | ||
$next = $phpcsFile->findNext($allTokens, $stackPtr + 1); | ||
|
||
if ($next && $notFlatFile) { | ||
$notWalled = (in_array($tokens[$next]['code'], $leftWall) && $tokens[$stackPtr]['column'] !== 1); | ||
$notIndented = (in_array($tokens[$next]['code'], $oneIndentation) && $tokens[$stackPtr]['column'] !== 5); | ||
if ($notWalled || $notIndented) { | ||
$phpcsFile->addError('Expected docblock to be aligned with code.', $stackPtr, 'NotAllowed'); | ||
} | ||
} | ||
|
||
return; | ||
} | ||
} |
Oops, something went wrong.