more updates yay
This commit is contained in:
25
vendor/squizlabs/php_codesniffer/src/Standards/Zend/Docs/Debug/CodeAnalyzerStandard.xml
vendored
Normal file
25
vendor/squizlabs/php_codesniffer/src/Standards/Zend/Docs/Debug/CodeAnalyzerStandard.xml
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
<documentation title="Zend Code Analyzer">
|
||||
<standard>
|
||||
<![CDATA[
|
||||
PHP Code should pass the zend code analyzer.
|
||||
]]>
|
||||
</standard>
|
||||
<code_comparison>
|
||||
<code title="Valid: Valid PHP Code.">
|
||||
<![CDATA[
|
||||
function foo($bar, $baz)
|
||||
{
|
||||
return <em>$bar + $baz</em>;
|
||||
}
|
||||
]]>
|
||||
</code>
|
||||
<code title="Invalid: There is an unused function parameter.">
|
||||
<![CDATA[
|
||||
function foo($bar, $baz)
|
||||
{
|
||||
return <em>$bar + 2</em>;
|
||||
}
|
||||
]]>
|
||||
</code>
|
||||
</code_comparison>
|
||||
</documentation>
|
22
vendor/squizlabs/php_codesniffer/src/Standards/Zend/Docs/Files/ClosingTagStandard.xml
vendored
Normal file
22
vendor/squizlabs/php_codesniffer/src/Standards/Zend/Docs/Files/ClosingTagStandard.xml
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
<documentation title="Closing PHP Tags">
|
||||
<standard>
|
||||
<![CDATA[
|
||||
Files should not have closing php tags.
|
||||
]]>
|
||||
</standard>
|
||||
<code_comparison>
|
||||
<code title="Valid: No closing tag at the end of the file.">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$var = 1;
|
||||
]]>
|
||||
</code>
|
||||
<code title="Invalid: A closing php tag is included at the end of the file.">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$var = 1;
|
||||
<em>?></em>
|
||||
]]>
|
||||
</code>
|
||||
</code_comparison>
|
||||
</documentation>
|
@ -0,0 +1,37 @@
|
||||
<documentation title="Variable Names">
|
||||
<standard>
|
||||
<![CDATA[
|
||||
Variable names should be camelCased with the first letter lowercase. Private and protected member variables should begin with an underscore
|
||||
]]>
|
||||
</standard>
|
||||
<code_comparison>
|
||||
<code title="Valid: A multi-word variable uses camel casing.">
|
||||
<![CDATA[
|
||||
<em>$testNumber</em> = 1;
|
||||
]]>
|
||||
</code>
|
||||
<code title="Invalid: A multi-word variable uses underscores and initial capitalization.">
|
||||
<![CDATA[
|
||||
<em>$Test_Number</em> = 1;
|
||||
]]>
|
||||
</code>
|
||||
</code_comparison>
|
||||
<code_comparison>
|
||||
<code title="Valid: A private member variable begins with an underscore.">
|
||||
<![CDATA[
|
||||
class Foo
|
||||
{
|
||||
private $<em>_</em>bar;
|
||||
}
|
||||
]]>
|
||||
</code>
|
||||
<code title="Invalid: A private member variable does not begin with an underscore.">
|
||||
<![CDATA[
|
||||
class Foo
|
||||
{
|
||||
private $bar;
|
||||
}
|
||||
]]>
|
||||
</code>
|
||||
</code_comparison>
|
||||
</documentation>
|
96
vendor/squizlabs/php_codesniffer/src/Standards/Zend/Sniffs/Debug/CodeAnalyzerSniff.php
vendored
Normal file
96
vendor/squizlabs/php_codesniffer/src/Standards/Zend/Sniffs/Debug/CodeAnalyzerSniff.php
vendored
Normal file
@ -0,0 +1,96 @@
|
||||
<?php
|
||||
/**
|
||||
* Runs the Zend Code Analyzer (from Zend Studio) on the file.
|
||||
*
|
||||
* @author Holger Kral <holger.kral@zend.com>
|
||||
* @author Greg Sherwood <gsherwood@squiz.net>
|
||||
* @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600)
|
||||
* @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
|
||||
*/
|
||||
|
||||
namespace PHP_CodeSniffer\Standards\Zend\Sniffs\Debug;
|
||||
|
||||
use PHP_CodeSniffer\Sniffs\Sniff;
|
||||
use PHP_CodeSniffer\Files\File;
|
||||
use PHP_CodeSniffer\Config;
|
||||
use PHP_CodeSniffer\Exceptions\RuntimeException;
|
||||
|
||||
class CodeAnalyzerSniff implements Sniff
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* Returns the token types that this sniff is interested in.
|
||||
*
|
||||
* @return int[]
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
return [T_OPEN_TAG];
|
||||
|
||||
}//end register()
|
||||
|
||||
|
||||
/**
|
||||
* Processes the tokens that this sniff is interested in.
|
||||
*
|
||||
* @param \PHP_CodeSniffer\Files\File $phpcsFile The file where the token was found.
|
||||
* @param int $stackPtr The position in the stack where
|
||||
* the token was found.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function process(File $phpcsFile, $stackPtr)
|
||||
{
|
||||
$analyzerPath = Config::getExecutablePath('zend_ca');
|
||||
if (is_null($analyzerPath) === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
$fileName = $phpcsFile->getFilename();
|
||||
|
||||
// In the command, 2>&1 is important because the code analyzer sends its
|
||||
// findings to stderr. $output normally contains only stdout, so using 2>&1
|
||||
// will pipe even stderr to stdout.
|
||||
$cmd = escapeshellcmd($analyzerPath).' '.escapeshellarg($fileName).' 2>&1';
|
||||
|
||||
// There is the possibility to pass "--ide" as an option to the analyzer.
|
||||
// This would result in an output format which would be easier to parse.
|
||||
// The problem here is that no cleartext error messages are returnwd; only
|
||||
// error-code-labels. So for a start we go for cleartext output.
|
||||
$exitCode = exec($cmd, $output, $retval);
|
||||
|
||||
// Variable $exitCode is the last line of $output if no error occures, on
|
||||
// error it is numeric. Try to handle various error conditions and
|
||||
// provide useful error reporting.
|
||||
if (is_numeric($exitCode) === true && $exitCode > 0) {
|
||||
if (is_array($output) === true) {
|
||||
$msg = join('\n', $output);
|
||||
}
|
||||
|
||||
throw new RuntimeException("Failed invoking ZendCodeAnalyzer, exitcode was [$exitCode], retval was [$retval], output was [$msg]");
|
||||
}
|
||||
|
||||
if (is_array($output) === true) {
|
||||
foreach ($output as $finding) {
|
||||
// The first two lines of analyzer output contain
|
||||
// something like this:
|
||||
// > Zend Code Analyzer 1.2.2
|
||||
// > Analyzing <filename>...
|
||||
// So skip these...
|
||||
$res = preg_match("/^.+\(line ([0-9]+)\):(.+)$/", $finding, $regs);
|
||||
if (empty($regs) === true || $res === false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$phpcsFile->addWarningOnLine(trim($regs[2]), $regs[1], 'ExternalTool');
|
||||
}
|
||||
}
|
||||
|
||||
// Ignore the rest of the file.
|
||||
return ($phpcsFile->numTokens + 1);
|
||||
|
||||
}//end process()
|
||||
|
||||
|
||||
}//end class
|
68
vendor/squizlabs/php_codesniffer/src/Standards/Zend/Sniffs/Files/ClosingTagSniff.php
vendored
Normal file
68
vendor/squizlabs/php_codesniffer/src/Standards/Zend/Sniffs/Files/ClosingTagSniff.php
vendored
Normal file
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
/**
|
||||
* Checks that the file does not end with a closing tag.
|
||||
*
|
||||
* @author Greg Sherwood <gsherwood@squiz.net>
|
||||
* @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600)
|
||||
* @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
|
||||
*/
|
||||
|
||||
namespace PHP_CodeSniffer\Standards\Zend\Sniffs\Files;
|
||||
|
||||
use PHP_CodeSniffer\Sniffs\Sniff;
|
||||
use PHP_CodeSniffer\Files\File;
|
||||
|
||||
class ClosingTagSniff implements Sniff
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* Returns an array of tokens this test wants to listen for.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
return [T_OPEN_TAG];
|
||||
|
||||
}//end register()
|
||||
|
||||
|
||||
/**
|
||||
* Processes this sniff, when one of its tokens is encountered.
|
||||
*
|
||||
* @param \PHP_CodeSniffer\Files\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(File $phpcsFile, $stackPtr)
|
||||
{
|
||||
// Find the last non-empty token.
|
||||
$tokens = $phpcsFile->getTokens();
|
||||
for ($last = ($phpcsFile->numTokens - 1); $last > 0; $last--) {
|
||||
if (trim($tokens[$last]['content']) !== '') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($tokens[$last]['code'] === T_CLOSE_TAG) {
|
||||
$error = 'A closing tag is not permitted at the end of a PHP file';
|
||||
$fix = $phpcsFile->addFixableError($error, $last, 'NotAllowed');
|
||||
if ($fix === true) {
|
||||
$phpcsFile->fixer->replaceToken($last, '');
|
||||
}
|
||||
|
||||
$phpcsFile->recordMetric($stackPtr, 'PHP closing tag at EOF', 'yes');
|
||||
} else {
|
||||
$phpcsFile->recordMetric($stackPtr, 'PHP closing tag at EOF', 'no');
|
||||
}
|
||||
|
||||
// Ignore the rest of the file.
|
||||
return ($phpcsFile->numTokens + 1);
|
||||
|
||||
}//end process()
|
||||
|
||||
|
||||
}//end class
|
@ -0,0 +1,223 @@
|
||||
<?php
|
||||
/**
|
||||
* Checks the naming of variables and member variables.
|
||||
*
|
||||
* @author Greg Sherwood <gsherwood@squiz.net>
|
||||
* @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600)
|
||||
* @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
|
||||
*/
|
||||
|
||||
namespace PHP_CodeSniffer\Standards\Zend\Sniffs\NamingConventions;
|
||||
|
||||
use PHP_CodeSniffer\Sniffs\AbstractVariableSniff;
|
||||
use PHP_CodeSniffer\Util\Common;
|
||||
use PHP_CodeSniffer\Files\File;
|
||||
|
||||
class ValidVariableNameSniff extends AbstractVariableSniff
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* Processes this test, when one of its tokens is encountered.
|
||||
*
|
||||
* @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
|
||||
* @param int $stackPtr The position of the current token in the
|
||||
* stack passed in $tokens.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function processVariable(File $phpcsFile, $stackPtr)
|
||||
{
|
||||
$tokens = $phpcsFile->getTokens();
|
||||
$varName = ltrim($tokens[$stackPtr]['content'], '$');
|
||||
|
||||
$phpReservedVars = [
|
||||
'_SERVER' => true,
|
||||
'_GET' => true,
|
||||
'_POST' => true,
|
||||
'_REQUEST' => true,
|
||||
'_SESSION' => true,
|
||||
'_ENV' => true,
|
||||
'_COOKIE' => true,
|
||||
'_FILES' => true,
|
||||
'GLOBALS' => true,
|
||||
'http_response_header' => true,
|
||||
'HTTP_RAW_POST_DATA' => true,
|
||||
'php_errormsg' => true,
|
||||
];
|
||||
|
||||
// If it's a php reserved var, then its ok.
|
||||
if (isset($phpReservedVars[$varName]) === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
$objOperator = $phpcsFile->findNext([T_WHITESPACE], ($stackPtr + 1), null, true);
|
||||
if ($tokens[$objOperator]['code'] === T_OBJECT_OPERATOR) {
|
||||
// Check to see if we are using a variable from an object.
|
||||
$var = $phpcsFile->findNext([T_WHITESPACE], ($objOperator + 1), null, true);
|
||||
if ($tokens[$var]['code'] === T_STRING) {
|
||||
// Either a var name or a function call, so check for bracket.
|
||||
$bracket = $phpcsFile->findNext([T_WHITESPACE], ($var + 1), null, true);
|
||||
|
||||
if ($tokens[$bracket]['code'] !== T_OPEN_PARENTHESIS) {
|
||||
$objVarName = $tokens[$var]['content'];
|
||||
|
||||
// There is no way for us to know if the var is public or private,
|
||||
// so we have to ignore a leading underscore if there is one and just
|
||||
// check the main part of the variable name.
|
||||
$originalVarName = $objVarName;
|
||||
if (substr($objVarName, 0, 1) === '_') {
|
||||
$objVarName = substr($objVarName, 1);
|
||||
}
|
||||
|
||||
if (Common::isCamelCaps($objVarName, false, true, false) === false) {
|
||||
$error = 'Variable "%s" is not in valid camel caps format';
|
||||
$data = [$originalVarName];
|
||||
$phpcsFile->addError($error, $var, 'NotCamelCaps', $data);
|
||||
} else if (preg_match('|\d|', $objVarName) === 1) {
|
||||
$warning = 'Variable "%s" contains numbers but this is discouraged';
|
||||
$data = [$originalVarName];
|
||||
$phpcsFile->addWarning($warning, $stackPtr, 'ContainsNumbers', $data);
|
||||
}
|
||||
}//end if
|
||||
}//end if
|
||||
}//end if
|
||||
|
||||
// There is no way for us to know if the var is public or private,
|
||||
// so we have to ignore a leading underscore if there is one and just
|
||||
// check the main part of the variable name.
|
||||
$originalVarName = $varName;
|
||||
if (substr($varName, 0, 1) === '_') {
|
||||
$objOperator = $phpcsFile->findPrevious([T_WHITESPACE], ($stackPtr - 1), null, true);
|
||||
if ($tokens[$objOperator]['code'] === T_DOUBLE_COLON) {
|
||||
// The variable lives within a class, and is referenced like
|
||||
// this: MyClass::$_variable, so we don't know its scope.
|
||||
$inClass = true;
|
||||
} else {
|
||||
$inClass = $phpcsFile->hasCondition($stackPtr, [T_CLASS, T_INTERFACE, T_TRAIT]);
|
||||
}
|
||||
|
||||
if ($inClass === true) {
|
||||
$varName = substr($varName, 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (Common::isCamelCaps($varName, false, true, false) === false) {
|
||||
$error = 'Variable "%s" is not in valid camel caps format';
|
||||
$data = [$originalVarName];
|
||||
$phpcsFile->addError($error, $stackPtr, 'NotCamelCaps', $data);
|
||||
} else if (preg_match('|\d|', $varName) === 1) {
|
||||
$warning = 'Variable "%s" contains numbers but this is discouraged';
|
||||
$data = [$originalVarName];
|
||||
$phpcsFile->addWarning($warning, $stackPtr, 'ContainsNumbers', $data);
|
||||
}
|
||||
|
||||
}//end processVariable()
|
||||
|
||||
|
||||
/**
|
||||
* Processes class member variables.
|
||||
*
|
||||
* @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
|
||||
* @param int $stackPtr The position of the current token in the
|
||||
* stack passed in $tokens.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function processMemberVar(File $phpcsFile, $stackPtr)
|
||||
{
|
||||
$tokens = $phpcsFile->getTokens();
|
||||
$varName = ltrim($tokens[$stackPtr]['content'], '$');
|
||||
$memberProps = $phpcsFile->getMemberProperties($stackPtr);
|
||||
if (empty($memberProps) === true) {
|
||||
// Exception encountered.
|
||||
return;
|
||||
}
|
||||
|
||||
$public = ($memberProps['scope'] === 'public');
|
||||
|
||||
if ($public === true) {
|
||||
if (substr($varName, 0, 1) === '_') {
|
||||
$error = 'Public member variable "%s" must not contain a leading underscore';
|
||||
$data = [$varName];
|
||||
$phpcsFile->addError($error, $stackPtr, 'PublicHasUnderscore', $data);
|
||||
}
|
||||
} else {
|
||||
if (substr($varName, 0, 1) !== '_') {
|
||||
$scope = ucfirst($memberProps['scope']);
|
||||
$error = '%s member variable "%s" must contain a leading underscore';
|
||||
$data = [
|
||||
$scope,
|
||||
$varName,
|
||||
];
|
||||
$phpcsFile->addError($error, $stackPtr, 'PrivateNoUnderscore', $data);
|
||||
}
|
||||
}
|
||||
|
||||
// Remove a potential underscore prefix for testing CamelCaps.
|
||||
$varName = ltrim($varName, '_');
|
||||
|
||||
if (Common::isCamelCaps($varName, false, true, false) === false) {
|
||||
$error = 'Member variable "%s" is not in valid camel caps format';
|
||||
$data = [$varName];
|
||||
$phpcsFile->addError($error, $stackPtr, 'MemberVarNotCamelCaps', $data);
|
||||
} else if (preg_match('|\d|', $varName) === 1) {
|
||||
$warning = 'Member variable "%s" contains numbers but this is discouraged';
|
||||
$data = [$varName];
|
||||
$phpcsFile->addWarning($warning, $stackPtr, 'MemberVarContainsNumbers', $data);
|
||||
}
|
||||
|
||||
}//end processMemberVar()
|
||||
|
||||
|
||||
/**
|
||||
* Processes the variable found within a double quoted string.
|
||||
*
|
||||
* @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
|
||||
* @param int $stackPtr The position of the double quoted
|
||||
* string.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function processVariableInString(File $phpcsFile, $stackPtr)
|
||||
{
|
||||
$tokens = $phpcsFile->getTokens();
|
||||
|
||||
$phpReservedVars = [
|
||||
'_SERVER',
|
||||
'_GET',
|
||||
'_POST',
|
||||
'_REQUEST',
|
||||
'_SESSION',
|
||||
'_ENV',
|
||||
'_COOKIE',
|
||||
'_FILES',
|
||||
'GLOBALS',
|
||||
'http_response_header',
|
||||
'HTTP_RAW_POST_DATA',
|
||||
'php_errormsg',
|
||||
];
|
||||
|
||||
if (preg_match_all('|[^\\\]\$([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)|', $tokens[$stackPtr]['content'], $matches) !== 0) {
|
||||
foreach ($matches[1] as $varName) {
|
||||
// If it's a php reserved var, then its ok.
|
||||
if (in_array($varName, $phpReservedVars) === true) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Common::isCamelCaps($varName, false, true, false) === false) {
|
||||
$error = 'Variable "%s" is not in valid camel caps format';
|
||||
$data = [$varName];
|
||||
$phpcsFile->addError($error, $stackPtr, 'StringVarNotCamelCaps', $data);
|
||||
} else if (preg_match('|\d|', $varName) === 1) {
|
||||
$warning = 'Variable "%s" contains numbers but this is discouraged';
|
||||
$data = [$varName];
|
||||
$phpcsFile->addWarning($warning, $stackPtr, 'StringVarContainsNumbers', $data);
|
||||
}
|
||||
}//end foreach
|
||||
}//end if
|
||||
|
||||
}//end processVariableInString()
|
||||
|
||||
|
||||
}//end class
|
6
vendor/squizlabs/php_codesniffer/src/Standards/Zend/Tests/Debug/CodeAnalyzerUnitTest.inc
vendored
Normal file
6
vendor/squizlabs/php_codesniffer/src/Standards/Zend/Tests/Debug/CodeAnalyzerUnitTest.inc
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
function myFunction($variable) {
|
||||
// $variable is unused.
|
||||
echo 'hi';
|
||||
}
|
||||
?>
|
62
vendor/squizlabs/php_codesniffer/src/Standards/Zend/Tests/Debug/CodeAnalyzerUnitTest.php
vendored
Normal file
62
vendor/squizlabs/php_codesniffer/src/Standards/Zend/Tests/Debug/CodeAnalyzerUnitTest.php
vendored
Normal file
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
/**
|
||||
* Unit test class for the CodeAnalyzer sniff.
|
||||
*
|
||||
* @author Greg Sherwood <gsherwood@squiz.net>
|
||||
* @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600)
|
||||
* @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
|
||||
*/
|
||||
|
||||
namespace PHP_CodeSniffer\Standards\Zend\Tests\Debug;
|
||||
|
||||
use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest;
|
||||
use PHP_CodeSniffer\Config;
|
||||
|
||||
class CodeAnalyzerUnitTest extends AbstractSniffUnitTest
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* Should this test be skipped for some reason.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function shouldSkipTest()
|
||||
{
|
||||
$analyzerPath = Config::getExecutablePath('zend_ca');
|
||||
return (is_null($analyzerPath));
|
||||
|
||||
}//end shouldSkipTest()
|
||||
|
||||
|
||||
/**
|
||||
* Returns the lines where errors should occur.
|
||||
*
|
||||
* The key of the array should represent the line number and the value
|
||||
* should represent the number of errors that should occur on that line.
|
||||
*
|
||||
* @return array<int, int>
|
||||
*/
|
||||
public function getErrorList()
|
||||
{
|
||||
return [];
|
||||
|
||||
}//end getErrorList()
|
||||
|
||||
|
||||
/**
|
||||
* Returns the lines where warnings should occur.
|
||||
*
|
||||
* The key of the array should represent the line number and the value
|
||||
* should represent the number of warnings that should occur on that line.
|
||||
*
|
||||
* @return array<int, int>
|
||||
*/
|
||||
public function getWarningList()
|
||||
{
|
||||
return [2 => 1];
|
||||
|
||||
}//end getWarningList()
|
||||
|
||||
|
||||
}//end class
|
12
vendor/squizlabs/php_codesniffer/src/Standards/Zend/Tests/Files/ClosingTagUnitTest.1.inc
vendored
Normal file
12
vendor/squizlabs/php_codesniffer/src/Standards/Zend/Tests/Files/ClosingTagUnitTest.1.inc
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
echo 'hi';
|
||||
|
||||
?>
|
||||
|
||||
<?php
|
||||
|
||||
echo 'bye';
|
||||
|
||||
?>
|
||||
|
3
vendor/squizlabs/php_codesniffer/src/Standards/Zend/Tests/Files/ClosingTagUnitTest.2.inc
vendored
Normal file
3
vendor/squizlabs/php_codesniffer/src/Standards/Zend/Tests/Files/ClosingTagUnitTest.2.inc
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
<div class="clear"></div>
|
||||
<?php include('inc.php'); ?>
|
||||
</div>
|
54
vendor/squizlabs/php_codesniffer/src/Standards/Zend/Tests/Files/ClosingTagUnitTest.php
vendored
Normal file
54
vendor/squizlabs/php_codesniffer/src/Standards/Zend/Tests/Files/ClosingTagUnitTest.php
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/**
|
||||
* Unit test class for the ClosingTag sniff.
|
||||
*
|
||||
* @author Greg Sherwood <gsherwood@squiz.net>
|
||||
* @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600)
|
||||
* @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
|
||||
*/
|
||||
|
||||
namespace PHP_CodeSniffer\Standards\Zend\Tests\Files;
|
||||
|
||||
use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest;
|
||||
|
||||
class ClosingTagUnitTest extends AbstractSniffUnitTest
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* Returns the lines where errors should occur.
|
||||
*
|
||||
* The key of the array should represent the line number and the value
|
||||
* should represent the number of errors that should occur on that line.
|
||||
*
|
||||
* @param string $testFile The name of the file being tested.
|
||||
*
|
||||
* @return array<int, int>
|
||||
*/
|
||||
public function getErrorList($testFile='')
|
||||
{
|
||||
if ($testFile !== 'ClosingTagUnitTest.1.inc') {
|
||||
return [];
|
||||
}
|
||||
|
||||
return [11 => 1];
|
||||
|
||||
}//end getErrorList()
|
||||
|
||||
|
||||
/**
|
||||
* Returns the lines where warnings should occur.
|
||||
*
|
||||
* The key of the array should represent the line number and the value
|
||||
* should represent the number of warnings that should occur on that line.
|
||||
*
|
||||
* @return array<int, int>
|
||||
*/
|
||||
public function getWarningList()
|
||||
{
|
||||
return [];
|
||||
|
||||
}//end getWarningList()
|
||||
|
||||
|
||||
}//end class
|
@ -0,0 +1,110 @@
|
||||
<?php
|
||||
$varName = 'hello';
|
||||
$var_name = 'hello';
|
||||
$varname = 'hello';
|
||||
$_varName = 'hello';
|
||||
$varname2 = 'hello';
|
||||
|
||||
class MyClass
|
||||
{
|
||||
$varName = 'hello';
|
||||
$var_name = 'hello';
|
||||
$varname = 'hello';
|
||||
$_varName = 'hello';
|
||||
$varName2 = 'hello';
|
||||
|
||||
public $varName = 'hello';
|
||||
public $var_name = 'hello';
|
||||
public $varname = 'hello';
|
||||
public $_varName = 'hello';
|
||||
public $varName2 = 'hello';
|
||||
|
||||
protected $_varName = 'hello';
|
||||
protected $_var_name = 'hello';
|
||||
protected $_varname = 'hello';
|
||||
protected $varName = 'hello';
|
||||
protected $_varName2 = 'hello';
|
||||
|
||||
private $_varName = 'hello';
|
||||
private $_var_name = 'hello';
|
||||
private $_varname = 'hello';
|
||||
private $varName = 'hello';
|
||||
private $_varName2 = 'hello';
|
||||
}
|
||||
|
||||
echo $varName;
|
||||
echo $var_name;
|
||||
echo $varname;
|
||||
echo $_varName;
|
||||
echo $varName2;
|
||||
|
||||
echo "Hello $varName";
|
||||
echo "Hello $var_name";
|
||||
echo "Hello $varname";
|
||||
echo "Hello $_varName";
|
||||
echo "Hello $varName2";
|
||||
|
||||
echo 'Hello '.$varName;
|
||||
echo 'Hello '.$var_name;
|
||||
echo 'Hello '.$varname;
|
||||
echo 'Hello '.$_varName;
|
||||
echo 'Hello '.$varName2;
|
||||
|
||||
echo $_SERVER['var_name'];
|
||||
echo $_REQUEST['var_name'];
|
||||
echo $_GET['var_name'];
|
||||
echo $_POST['var_name'];
|
||||
echo $GLOBALS['var_name'];
|
||||
echo $GLOBALS['var_name2'];
|
||||
|
||||
echo MyClass::$varName;
|
||||
echo MyClass::$var_name;
|
||||
echo MyClass::$varname;
|
||||
echo MyClass::$_varName;
|
||||
echo MyClass::$varName2;
|
||||
|
||||
echo $this->varName;
|
||||
echo $this->var_name;
|
||||
echo $this->varname;
|
||||
echo $this->_varName;
|
||||
echo $this->varName2;
|
||||
echo $object->varName;
|
||||
echo $object->var_name;
|
||||
echo $object->varName2;
|
||||
echo $object_name->varname;
|
||||
echo $object_name->_varName;
|
||||
echo $object_name->varName2;
|
||||
|
||||
echo $this->myFunction($one, $two);
|
||||
echo $object->myFunction($one_two, $var2);
|
||||
|
||||
$error = "format is \$GLOBALS['$varName']";
|
||||
$error = "format is \$GLOBALS['$varName2']";
|
||||
|
||||
echo $_SESSION['var_name'];
|
||||
echo $_FILES['var_name'];
|
||||
echo $_ENV['var_name'];
|
||||
echo $_COOKIE['var_name'];
|
||||
echo $_COOKIE['var_name2'];
|
||||
|
||||
$XML = 'hello';
|
||||
$myXML = 'hello';
|
||||
$XMLParser = 'hello';
|
||||
$xmlParser = 'hello';
|
||||
$xmlParser2 = 'hello';
|
||||
|
||||
echo "{$_SERVER['HOSTNAME']} $var_name";
|
||||
|
||||
$someObject->{$name};
|
||||
$someObject->my_function($var_name);
|
||||
|
||||
var_dump($http_response_header);
|
||||
var_dump($HTTP_RAW_POST_DATA);
|
||||
var_dump($php_errormsg);
|
||||
|
||||
interface Base
|
||||
{
|
||||
protected $anonymous;
|
||||
|
||||
public function __construct();
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
<?php
|
||||
/**
|
||||
* Unit test class for the ValidVariableName sniff.
|
||||
*
|
||||
* @author Greg Sherwood <gsherwood@squiz.net>
|
||||
* @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600)
|
||||
* @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
|
||||
*/
|
||||
|
||||
namespace PHP_CodeSniffer\Standards\Zend\Tests\NamingConventions;
|
||||
|
||||
use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest;
|
||||
|
||||
class ValidVariableNameUnitTest extends AbstractSniffUnitTest
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* Returns the lines where errors should occur.
|
||||
*
|
||||
* The key of the array should represent the line number and the value
|
||||
* should represent the number of errors that should occur on that line.
|
||||
*
|
||||
* @return array<int, int>
|
||||
*/
|
||||
public function getErrorList()
|
||||
{
|
||||
return [
|
||||
3 => 1,
|
||||
5 => 1,
|
||||
11 => 1,
|
||||
13 => 1,
|
||||
17 => 1,
|
||||
19 => 1,
|
||||
23 => 1,
|
||||
25 => 1,
|
||||
29 => 1,
|
||||
31 => 1,
|
||||
36 => 1,
|
||||
38 => 1,
|
||||
42 => 1,
|
||||
44 => 1,
|
||||
48 => 1,
|
||||
50 => 1,
|
||||
61 => 1,
|
||||
67 => 1,
|
||||
72 => 1,
|
||||
74 => 1,
|
||||
75 => 1,
|
||||
76 => 1,
|
||||
79 => 1,
|
||||
96 => 1,
|
||||
99 => 1,
|
||||
];
|
||||
|
||||
}//end getErrorList()
|
||||
|
||||
|
||||
/**
|
||||
* Returns the lines where warnings should occur.
|
||||
*
|
||||
* The key of the array should represent the line number and the value
|
||||
* should represent the number of warnings that should occur on that line.
|
||||
*
|
||||
* @return array<int, int>
|
||||
*/
|
||||
public function getWarningList()
|
||||
{
|
||||
return [
|
||||
6 => 1,
|
||||
14 => 1,
|
||||
20 => 1,
|
||||
26 => 1,
|
||||
32 => 1,
|
||||
39 => 1,
|
||||
45 => 1,
|
||||
51 => 1,
|
||||
64 => 1,
|
||||
70 => 1,
|
||||
73 => 1,
|
||||
76 => 1,
|
||||
79 => 1,
|
||||
82 => 1,
|
||||
94 => 1,
|
||||
107 => 1,
|
||||
];
|
||||
|
||||
}//end getWarningList()
|
||||
|
||||
|
||||
}//end class
|
32
vendor/squizlabs/php_codesniffer/src/Standards/Zend/ruleset.xml
vendored
Normal file
32
vendor/squizlabs/php_codesniffer/src/Standards/Zend/ruleset.xml
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
<?xml version="1.0"?>
|
||||
<ruleset name="Zend">
|
||||
<description>A coding standard based on an early Zend Framework coding standard. Note that this standard is out of date.</description>
|
||||
|
||||
<!-- Include some sniffs from all around the place -->
|
||||
<rule ref="Generic.Functions.FunctionCallArgumentSpacing"/>
|
||||
<rule ref="Generic.Functions.OpeningFunctionBraceBsdAllman"/>
|
||||
<rule ref="Generic.PHP.DisallowShortOpenTag"/>
|
||||
<rule ref="Generic.WhiteSpace.DisallowTabIndent"/>
|
||||
<rule ref="PEAR.Classes.ClassDeclaration"/>
|
||||
<rule ref="PEAR.ControlStructures.ControlSignature"/>
|
||||
<rule ref="PEAR.Functions.FunctionCallSignature"/>
|
||||
<rule ref="PEAR.Functions.ValidDefaultValue"/>
|
||||
<rule ref="PEAR.WhiteSpace.ScopeClosingBrace"/>
|
||||
<rule ref="Squiz.Functions.GlobalFunction"/>
|
||||
|
||||
<!-- Lines can be 80 chars long, show errors at 120 chars -->
|
||||
<rule ref="Generic.Files.LineLength">
|
||||
<properties>
|
||||
<property name="lineLimit" value="80"/>
|
||||
<property name="absoluteLineLimit" value="120"/>
|
||||
</properties>
|
||||
</rule>
|
||||
|
||||
<!-- Use Unix newlines -->
|
||||
<rule ref="Generic.Files.LineEndings">
|
||||
<properties>
|
||||
<property name="eolChar" value="\n"/>
|
||||
</properties>
|
||||
</rule>
|
||||
|
||||
</ruleset>
|
Reference in New Issue
Block a user