mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-25 16:44:28 +00:00
PHPCI
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Version 5
|
||||
*
|
||||
* FHComplete
|
||||
*/
|
||||
|
||||
/**
|
||||
* Ensures there is a space after the function keyword for closures.
|
||||
*
|
||||
*/
|
||||
class FHComplete_Sniffs_Functions_ClosureDeclarationSniff implements PHP_CodeSniffer_Sniff {
|
||||
|
||||
public function register()
|
||||
{
|
||||
return array(T_CLOSURE);
|
||||
}
|
||||
|
||||
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
||||
{
|
||||
$tokens = $phpcsFile->getTokens();
|
||||
$spaces = 0;
|
||||
|
||||
if ($tokens[($stackPtr + 1)]['code'] === T_WHITESPACE) {
|
||||
$spaces = strlen($tokens[($stackPtr + 1)]['content']);
|
||||
}
|
||||
|
||||
if ($spaces !== 1) {
|
||||
$error = 'Expected 1 space after closure\'s function keyword; %s found';
|
||||
$data = array($spaces);
|
||||
$phpcsFile->addError($error, $stackPtr, 'SpaceAfterFunction', $data);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Version 5
|
||||
*
|
||||
* FHComplete
|
||||
*/
|
||||
if (class_exists('Squiz_Sniffs_Functions_FunctionDeclarationArgumentSpacingSniff', true) === false) {
|
||||
$error = 'Class Squiz_Sniffs_Functions_FunctionDeclarationArgumentSpacingSniff not found';
|
||||
throw new PHP_CodeSniffer_Exception($error);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures the spacing of function declaration arguments is correct.
|
||||
*
|
||||
*/
|
||||
class FHComplete_Sniffs_Functions_FunctionDeclarationArgumentSpacingSniff extends
|
||||
Squiz_Sniffs_Functions_FunctionDeclarationArgumentSpacingSniff {
|
||||
|
||||
/**
|
||||
* How many spaces should surround the equals signs.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $equalsSpacing = 1;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user