diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/CLI.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/CLI.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/CLI.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/CLI.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,746 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -if (is_file(dirname(__FILE__).'/../CodeSniffer.php') === true) { - include_once dirname(__FILE__).'/../CodeSniffer.php'; -} else { - include_once 'PHP/CodeSniffer.php'; -} - -/** - * A class to process command line phpcs scripts. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PHP_CodeSniffer_CLI -{ - - /** - * An array of all values specified on the command line. - * - * @var array - */ - protected $values = array(); - - /** - * The minimum severity level errors must have to be displayed. - * - * @var bool - */ - public $errorSeverity = 0; - - /** - * The minimum severity level warnings must have to be displayed. - * - * @var bool - */ - public $warningSeverity = 0; - - - /** - * Exits if the minimum requirements of PHP_CodSniffer are not met. - * - * @return array - */ - public function checkRequirements() - { - // Check the PHP version. - if (version_compare(PHP_VERSION, '5.1.2') === -1) { - echo 'ERROR: PHP_CodeSniffer requires PHP version 5.1.2 or greater.'.PHP_EOL; - exit(2); - } - - if (extension_loaded('tokenizer') === false) { - echo 'ERROR: PHP_CodeSniffer requires the tokenizer extension to be enabled.'.PHP_EOL; - exit(2); - } - - }//end checkRequirements() - - - /** - * Get a list of default values for all possible command line arguments. - * - * @return array - */ - public function getDefaults() - { - // The default values for config settings. - $defaults['files'] = array(); - $defaults['standard'] = null; - $defaults['verbosity'] = 0; - $defaults['interactive'] = false; - $defaults['local'] = false; - $defaults['showSources'] = false; - $defaults['extensions'] = array(); - $defaults['sniffs'] = array(); - $defaults['ignored'] = array(); - $defaults['reportFile'] = null; - $defaults['generator'] = ''; - $defaults['reports'] = array(); - $defaults['errorSeverity'] = null; - $defaults['warningSeverity'] = null; - - $reportFormat = PHP_CodeSniffer::getConfigData('report_format'); - if ($reportFormat !== null) { - $defaults['reports'][$reportFormat] = null; - } - - $tabWidth = PHP_CodeSniffer::getConfigData('tab_width'); - if ($tabWidth === null) { - $defaults['tabWidth'] = 0; - } else { - $defaults['tabWidth'] = (int) $tabWidth; - } - - $encoding = PHP_CodeSniffer::getConfigData('encoding'); - if ($encoding === null) { - $defaults['encoding'] = 'iso-8859-1'; - } else { - $defaults['encoding'] = strtolower($encoding); - } - - $severity = PHP_CodeSniffer::getConfigData('severity'); - if ($severity !== null) { - $defaults['errorSeverity'] = (int) $severity; - $defaults['warningSeverity'] = (int) $severity; - } - - $severity = PHP_CodeSniffer::getConfigData('error_severity'); - if ($severity !== null) { - $defaults['errorSeverity'] = (int) $severity; - } - - $severity = PHP_CodeSniffer::getConfigData('warning_severity'); - if ($severity !== null) { - $defaults['warningSeverity'] = (int) $severity; - } - - $showWarnings = PHP_CodeSniffer::getConfigData('show_warnings'); - if ($showWarnings !== null) { - $showWarnings = (bool) $showWarnings; - if ($showWarnings === false) { - $defaults['warningSeverity'] = 0; - } - } - - $reportWidth = PHP_CodeSniffer::getConfigData('report_width'); - if ($reportWidth === null) { - $defaults['reportWidth'] = 80; - } else { - $defaults['reportWidth'] = (int) $reportWidth; - } - - $showProgress = PHP_CodeSniffer::getConfigData('show_progress'); - if ($showProgress === null) { - $defaults['showProgress'] = false; - } else { - $defaults['showProgress'] = (bool) $showProgress; - } - - return $defaults; - - }//end getDefaults() - - - /** - * Process the command line arguments and returns the values. - * - * @return array - */ - public function getCommandLineValues() - { - if (empty($this->values) === false) { - return $this->values; - } - - $values = $this->getDefaults(); - - for ($i = 1; $i < $_SERVER['argc']; $i++) { - $arg = $_SERVER['argv'][$i]; - if ($arg === '') { - continue; - } - - if ($arg{0} === '-') { - if ($arg === '-' || $arg === '--') { - // Empty argument, ignore it. - continue; - } - - if ($arg{1} === '-') { - $values - = $this->processLongArgument(substr($arg, 2), $i, $values); - } else { - $switches = str_split($arg); - foreach ($switches as $switch) { - if ($switch === '-') { - continue; - } - - $values = $this->processShortArgument($switch, $i, $values); - } - } - } else { - $values = $this->processUnknownArgument($arg, $i, $values); - }//end if - }//end for - - $this->values = $values; - return $values; - - }//end getCommandLineValues() - - - /** - * Processes a short (-e) command line argument. - * - * @param string $arg The command line argument. - * @param int $pos The position of the argument on the command line. - * @param array $values An array of values determined from CLI args. - * - * @return array The updated CLI values. - * @see getCommandLineValues() - */ - public function processShortArgument($arg, $pos, $values) - { - switch ($arg) { - case 'h': - case '?': - $this->printUsage(); - exit(0); - break; - case 'i' : - $this->printInstalledStandards(); - exit(0); - break; - case 'v' : - $values['verbosity']++; - break; - case 'l' : - $values['local'] = true; - break; - case 's' : - $values['showSources'] = true; - break; - case 'a' : - $values['interactive'] = true; - break; - case 'p' : - $values['showProgress'] = true; - break; - case 'd' : - $ini = explode('=', $_SERVER['argv'][($pos + 1)]); - $_SERVER['argv'][($pos + 1)] = ''; - if (isset($ini[1]) === true) { - ini_set($ini[0], $ini[1]); - } else { - ini_set($ini[0], true); - } - - break; - case 'n' : - $values['warningSeverity'] = 0; - break; - case 'w' : - $values['warningSeverity'] = null; - break; - default: - $values = $this->processUnknownArgument('-'.$arg, $pos, $values); - }//end switch - - return $values; - - }//end processShortArgument() - - - /** - * Processes a long (--example) command line argument. - * - * @param string $arg The command line argument. - * @param int $pos The position of the argument on the command line. - * @param array $values An array of values determined from CLI args. - * - * @return array The updated CLI values. - * @see getCommandLineValues() - */ - public function processLongArgument($arg, $pos, $values) - { - switch ($arg) { - case 'help': - $this->printUsage(); - exit(0); - break; - case 'version': - echo 'PHP_CodeSniffer version 1.3.4 (stable) '; - echo 'by Squiz Pty Ltd. (http://www.squiz.net)'.PHP_EOL; - exit(0); - break; - case 'config-set': - $key = $_SERVER['argv'][($pos + 1)]; - $value = $_SERVER['argv'][($pos + 2)]; - PHP_CodeSniffer::setConfigData($key, $value); - exit(0); - break; - case 'config-delete': - $key = $_SERVER['argv'][($pos + 1)]; - PHP_CodeSniffer::setConfigData($key, null); - exit(0); - break; - case 'config-show': - $data = PHP_CodeSniffer::getAllConfigData(); - print_r($data); - exit(0); - break; - default: - if (substr($arg, 0, 7) === 'sniffs=') { - $values['sniffs'] = array(); - - $sniffs = substr($arg, 7); - $sniffs = explode(',', $sniffs); - - // Convert the sniffs to class names. - foreach ($sniffs as $sniff) { - $parts = explode('.', $sniff); - $values['sniffs'][] = $parts[0].'_Sniffs_'.$parts[1].'_'.$parts[2].'Sniff'; - } - } else if (substr($arg, 0, 12) === 'report-file=') { - $values['reportFile'] = realpath(substr($arg, 12)); - - // It may not exist and return false instead. - if ($values['reportFile'] === false) { - $values['reportFile'] = substr($arg, 12); - } - - if (is_dir($values['reportFile']) === true) { - echo 'ERROR: The specified report file path "'.$values['reportFile'].'" is a directory.'.PHP_EOL.PHP_EOL; - $this->printUsage(); - exit(2); - } - - $dir = dirname($values['reportFile']); - if (is_dir($dir) === false) { - echo 'ERROR: The specified report file path "'.$values['reportFile'].'" points to a non-existent directory.'.PHP_EOL.PHP_EOL; - $this->printUsage(); - exit(2); - } - } else if (substr($arg, 0, 13) === 'report-width=') { - $values['reportWidth'] = (int) substr($arg, 13); - } else if (substr($arg, 0, 7) === 'report=' - || substr($arg, 0, 7) === 'report-' - ) { - if ($arg[6] === '-') { - // This is a report with file output. - $split = strpos($arg, '='); - if ($split === false) { - $report = substr($arg, 7); - $output = null; - } else { - - $report = substr($arg, 7, ($split - 7)); - $output = substr($arg, ($split + 1)); - if ($output === false) { - $output = null; - } - } - } else { - // This is a single report. - $report = substr($arg, 7); - $output = null; - } - - $validReports = array( - 'full', - 'xml', - 'checkstyle', - 'csv', - 'emacs', - 'source', - 'summary', - 'svnblame', - 'gitblame', - 'hgblame', - ); - - if (in_array($report, $validReports) === false) { - echo 'ERROR: Report type "'.$report.'" not known.'.PHP_EOL; - exit(2); - } - - $values['reports'][$report] = $output; - } else if (substr($arg, 0, 9) === 'standard=') { - $values['standard'] = substr($arg, 9); - } else if (substr($arg, 0, 11) === 'extensions=') { - $values['extensions'] = explode(',', substr($arg, 11)); - } else if (substr($arg, 0, 9) === 'severity=') { - $values['errorSeverity'] = (int) substr($arg, 9); - $values['warningSeverity'] = $values['errorSeverity']; - } else if (substr($arg, 0, 15) === 'error-severity=') { - $values['errorSeverity'] = (int) substr($arg, 15); - } else if (substr($arg, 0, 17) === 'warning-severity=') { - $values['warningSeverity'] = (int) substr($arg, 17); - } else if (substr($arg, 0, 7) === 'ignore=') { - // Split the ignore string on commas, unless the comma is escaped - // using 1 or 3 slashes (\, or \\\,). - $values['ignored'] = preg_split( - '/(?<=(?processUnknownArgument('--'.$arg, $pos, $values); - }//end if - - break; - }//end switch - - return $values; - - }//end processLongArgument() - - - /** - * Processes an unknown command line argument. - * - * Assumes all unknown arguments are files and folders to check. - * - * @param string $arg The command line argument. - * @param int $pos The position of the argument on the command line. - * @param array $values An array of values determined from CLI args. - * - * @return array The updated CLI values. - * @see getCommandLineValues() - */ - public function processUnknownArgument($arg, $pos, $values) - { - // We don't know about any additional switches; just files. - if ($arg{0} === '-') { - echo 'ERROR: option "'.$arg.'" not known.'.PHP_EOL.PHP_EOL; - $this->printUsage(); - exit(2); - } - - $file = realpath($arg); - if (file_exists($file) === false) { - echo 'ERROR: The file "'.$arg.'" does not exist.'.PHP_EOL.PHP_EOL; - $this->printUsage(); - exit(2); - } else { - $values['files'][] = $file; - } - - return $values; - - }//end processUnknownArgument() - - - /** - * Runs PHP_CodeSniffer over files and directories. - * - * @param array $values An array of values determined from CLI args. - * - * @return int The number of error and warning messages shown. - * @see getCommandLineValues() - */ - public function process($values=array()) - { - if (empty($values) === true) { - $values = $this->getCommandLineValues(); - } - - if ($values['generator'] !== '') { - $phpcs = new PHP_CodeSniffer($values['verbosity']); - $phpcs->generateDocs( - $values['standard'], - $values['files'], - $values['generator'] - ); - exit(0); - } - - $fileContents = ''; - if (empty($values['files']) === true) { - // Check if they passing in the file contents. - $handle = fopen('php://stdin', 'r'); - $fileContents = stream_get_contents($handle); - fclose($handle); - - if ($fileContents === '') { - // No files and no content passed in. - echo 'ERROR: You must supply at least one file or directory to process.'.PHP_EOL.PHP_EOL; - $this->printUsage(); - exit(2); - } - } - - $values['standard'] = $this->validateStandard($values['standard']); - if (PHP_CodeSniffer::isInstalledStandard($values['standard']) === false) { - // They didn't select a valid coding standard, so help them - // out by letting them know which standards are installed. - echo 'ERROR: the "'.$values['standard'].'" coding standard is not installed. '; - $this->printInstalledStandards(); - exit(2); - } - - $phpcs = new PHP_CodeSniffer( - $values['verbosity'], - $values['tabWidth'], - $values['encoding'], - $values['interactive'] - ); - - // Set file extensions if they were specified. Otherwise, - // let PHP_CodeSniffer decide on the defaults. - if (empty($values['extensions']) === false) { - $phpcs->setAllowedFileExtensions($values['extensions']); - } - - // Set ignore patterns if they were specified. - if (empty($values['ignored']) === false) { - $phpcs->setIgnorePatterns($values['ignored']); - } - - // Set some convenience member vars. - if ($values['errorSeverity'] === null) { - $this->errorSeverity = PHPCS_DEFAULT_ERROR_SEV; - } else { - $this->errorSeverity = $values['errorSeverity']; - } - - if ($values['warningSeverity'] === null) { - $this->warningSeverity = PHPCS_DEFAULT_WARN_SEV; - } else { - $this->warningSeverity = $values['warningSeverity']; - } - - $phpcs->setCli($this); - - $phpcs->process( - $values['files'], - $values['standard'], - $values['sniffs'], - $values['local'] - ); - - if ($fileContents !== '') { - $phpcs->processFile('STDIN', $fileContents); - } - - return $this->printErrorReport( - $phpcs, - $values['reports'], - $values['showSources'], - $values['reportFile'], - $values['reportWidth'] - ); - - }//end process() - - - /** - * Prints the error report for the run. - * - * Note that this function may actually print multiple reports - * as the user may have specified a number of output formats. - * - * @param PHP_CodeSniffer $phpcs The PHP_CodeSniffer object containing - * the errors. - * @param array $reports A list of reports to print. - * @param bool $showSources TRUE if report should show error sources - * (not used by all reports). - * @param string $reportFile A default file to log report output to. - * @param int $reportWidth How wide the screen reports should be. - * - * @return int The number of error and warning messages shown. - */ - public function printErrorReport( - PHP_CodeSniffer $phpcs, - $reports, - $showSources, - $reportFile, - $reportWidth - ) { - $reporting = new PHP_CodeSniffer_Reporting(); - $filesViolations = $phpcs->getFilesErrors(); - - if (empty($reports) === true) { - $reports['full'] = $reportFile; - } - - $errors = 0; - $toScreen = false; - - foreach ($reports as $report => $output) { - if ($output === null) { - $output = $reportFile; - } - - if ($reportFile === null) { - $toScreen = true; - } - - // We don't add errors here because the number of - // errors reported by each report type will always be the - // same, so we really just need 1 number. - $errors = $reporting->printReport( - $report, - $filesViolations, - $showSources, - $output, - $reportWidth - ); - } - - // Only print PHP_Timer output if no reports were - // printed to the screen so we don't put additional output - // in something like an XML report. If we are printing to screen, - // the report types would have already worked out who should - // print the timer info. - if ($toScreen === false - && PHP_CODESNIFFER_INTERACTIVE === false - && class_exists('PHP_Timer', false) === true - ) { - echo PHP_Timer::resourceUsage().PHP_EOL.PHP_EOL; - } - - // They should all return the same value, so it - // doesn't matter which return value we end up using. - return $errors; - - }//end printErrorReport() - - - /** - * Convert the passed standard into a valid standard. - * - * Checks things like default values and case. - * - * @param string $standard The standard to validate. - * - * @return string - */ - public function validateStandard($standard) - { - if ($standard === null) { - // They did not supply a standard to use. - // Try to get the default from the config system. - $standard = PHP_CodeSniffer::getConfigData('default_standard'); - if ($standard === null) { - $standard = 'PEAR'; - } - } - - // Check if the standard name is valid. If not, check that the case - // was not entered incorrectly. - if (PHP_CodeSniffer::isInstalledStandard($standard) === false) { - $installedStandards = PHP_CodeSniffer::getInstalledStandards(); - foreach ($installedStandards as $validStandard) { - if (strtolower($standard) === strtolower($validStandard)) { - $standard = $validStandard; - break; - } - } - } - - return $standard; - - }//end validateStandard() - - - /** - * Prints out the usage information for this script. - * - * @return void - */ - public function printUsage() - { - echo 'Usage: phpcs [-nwlsapvi] [-d key[=value]]'.PHP_EOL; - echo ' [--report=] [--report-file=] [--report-=] ...'.PHP_EOL; - echo ' [--report-width=] [--generator=] [--tab-width=]'.PHP_EOL; - echo ' [--severity=] [--error-severity=] [--warning-severity=]'.PHP_EOL; - echo ' [--config-set key value] [--config-delete key] [--config-show]'.PHP_EOL; - echo ' [--standard=] [--sniffs=] [--encoding=]'.PHP_EOL; - echo ' [--extensions=] [--ignore=] ...'.PHP_EOL; - echo ' -n Do not print warnings (shortcut for --warning-severity=0)'.PHP_EOL; - echo ' -w Print both warnings and errors (on by default)'.PHP_EOL; - echo ' -l Local directory only, no recursion'.PHP_EOL; - echo ' -s Show sniff codes in all reports'.PHP_EOL; - echo ' -a Run interactively'.PHP_EOL; - echo ' -p Show progress of the run'.PHP_EOL; - echo ' -v[v][v] Print verbose output'.PHP_EOL; - echo ' -i Show a list of installed coding standards'.PHP_EOL; - echo ' -d Set the [key] php.ini value to [value] or [true] if value is omitted'.PHP_EOL; - echo ' --help Print this help message'.PHP_EOL; - echo ' --version Print version information'.PHP_EOL; - echo ' One or more files and/or directories to check'.PHP_EOL; - echo ' A comma separated list of file extensions to check'.PHP_EOL; - echo ' (only valid if checking a directory)'.PHP_EOL; - echo ' A comma separated list of patterns to ignore files and directories'.PHP_EOL; - echo ' The encoding of the files being checked (default is iso-8859-1)'.PHP_EOL; - echo ' A comma separated list of sniff codes to limit the check to'.PHP_EOL; - echo ' (all sniffs must be part of the specified standard)'.PHP_EOL; - echo ' The minimum severity required to display an error or warning'.PHP_EOL; - echo ' The name or path of the coding standard to use'.PHP_EOL; - echo ' The number of spaces each tab represents'.PHP_EOL; - echo ' The name of a doc generator to use'.PHP_EOL; - echo ' (forces doc generation instead of checking)'.PHP_EOL; - echo ' Print either the "full", "xml", "checkstyle", "csv", "emacs"'.PHP_EOL; - echo ' "source", "summary", "svnblame", "gitblame" or "hgblame" report'.PHP_EOL; - echo ' (the "full" report is printed by default)'.PHP_EOL; - echo ' Write the report to the specified file path'.PHP_EOL; - echo ' How many columns wide screen reports should be printed'.PHP_EOL; - - }//end printUsage() - - - /** - * Prints out a list of installed coding standards. - * - * @return void - */ - public function printInstalledStandards() - { - $installedStandards = PHP_CodeSniffer::getInstalledStandards(); - $numStandards = count($installedStandards); - - if ($numStandards === 0) { - echo 'No coding standards are installed.'.PHP_EOL; - } else { - $lastStandard = array_pop($installedStandards); - if ($numStandards === 1) { - echo "The only coding standard installed is $lastStandard".PHP_EOL; - } else { - $standardList = implode(', ', $installedStandards); - $standardList .= ' and '.$lastStandard; - echo 'The installed coding standards are '.$standardList.PHP_EOL; - } - } - - }//end printInstalledStandards() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/CommentParser/AbstractDocElement.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/CommentParser/AbstractDocElement.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/CommentParser/AbstractDocElement.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/CommentParser/AbstractDocElement.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,353 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -if (interface_exists('PHP_CodeSniffer_CommentParser_DocElement', true) === false) { - $error = 'Interface PHP_CodeSniffer_CommentParser_DocElement not found'; - throw new PHP_CodeSniffer_Exception($error); -} - -/** - * A class to handle most of the parsing operations of a doc comment element. - * - * Extending classes should implement the getSubElements method to return - * a list of elements that the doc comment element contains, in the order that - * they appear in the element. For example a function parameter element has a - * type, a variable name and a comment. It should therefore implement the method - * as follows: - * - * - * protected function getSubElements() - * { - * return array( - * 'type', - * 'variable', - * 'comment', - * ); - * } - * - * - * The processSubElement will be called for each of the sub elements to allow - * the extending class to process them. So for the parameter element we would - * have: - * - * - * protected function processSubElement($name, $content, $whitespaceBefore) - * { - * if ($name === 'type') { - * echo 'The name of the variable was '.$content; - * } - * // Process other tags. - * } - * - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -abstract class PHP_CodeSniffer_CommentParser_AbstractDocElement implements PHP_CodeSniffer_CommentParser_DocElement -{ - - /** - * The element previous to this element. - * - * @var PHP_CodeSniffer_CommentParser_DocElement - */ - protected $previousElement = null; - - /** - * The element proceeding this element. - * - * @var PHP_CodeSniffer_CommentParser_DocElement - */ - protected $nextElement = null; - - /** - * The whitespace the occurs after this element and its sub elements. - * - * @var string - */ - protected $afterWhitespace = ''; - - /** - * The tokens that comprise this element. - * - * @var array(string) - */ - protected $tokens = array(); - - /** - * The file this element is in. - * - * @var array(string) - */ - protected $phpcsFile = null; - - /** - * The tag that this element represents (omiting the @ symbol). - * - * @var string - */ - protected $tag = ''; - - - /** - * Constructs a Doc Element. - * - * @param PHP_CodeSniffer_CommentParser_DocElement $previousElement The element - * that ocurred - * before this. - * @param array $tokens The tokens of - * this element. - * @param string $tag The doc - * element tag - * this element - * represents. - * @param PHP_CodeSniffer_File $phpcsFile The file that - * this element - * is in. - * - * @throws Exception If $previousElement in not a DocElement or if - * getSubElements() does not return an array. - */ - public function __construct( - $previousElement, - array $tokens, - $tag, - PHP_CodeSniffer_File $phpcsFile - ) { - if ($previousElement !== null - && ($previousElement instanceof PHP_CodeSniffer_CommentParser_DocElement) === false - ) { - $error = '$previousElement must be an instance of DocElement'; - throw new Exception($error); - } - - $this->phpcsFile = $phpcsFile; - - $this->previousElement = $previousElement; - if ($previousElement !== null) { - $this->previousElement->nextElement = $this; - } - - $this->tag = $tag; - $this->tokens = $tokens; - - $subElements = $this->getSubElements(); - - if (is_array($subElements) === false) { - throw new Exception('getSubElements() must return an array'); - } - - $whitespace = ''; - $currElem = 0; - $lastElement = ''; - $lastElementWhitespace = null; - $numSubElements = count($subElements); - - foreach ($this->tokens as $token) { - if (trim($token) === '') { - $whitespace .= $token; - } else { - if ($currElem < ($numSubElements - 1)) { - $element = $subElements[$currElem]; - $this->processSubElement($element, $token, $whitespace); - $whitespace = ''; - $currElem++; - } else { - if ($lastElementWhitespace === null) { - $lastElementWhitespace = $whitespace; - } - - $lastElement .= $whitespace.$token; - $whitespace = ''; - } - } - }//end foreach - - $lastElement = ltrim($lastElement); - $lastElementName = $subElements[($numSubElements - 1)]; - - // Process the last element in this tag. - $this->processSubElement( - $lastElementName, - $lastElement, - $lastElementWhitespace - ); - - $this->afterWhitespace = $whitespace; - - }//end __construct() - - - /** - * Returns the element that exists before this. - * - * @return PHP_CodeSniffer_CommentParser_DocElement - */ - public function getPreviousElement() - { - return $this->previousElement; - - }//end getPreviousElement() - - - /** - * Returns the element that exists after this. - * - * @return PHP_CodeSniffer_CommentParser_DocElement - */ - public function getNextElement() - { - return $this->nextElement; - - }//end getNextElement() - - - /** - * Returns the whitespace that exists before this element. - * - * @return string - */ - public function getWhitespaceBefore() - { - if ($this->previousElement !== null) { - return $this->previousElement->getWhitespaceAfter(); - } - - return ''; - - }//end getWhitespaceBefore() - - - /** - * Returns the whitespace that exists after this element. - * - * @return string - */ - public function getWhitespaceAfter() - { - return $this->afterWhitespace; - - }//end getWhitespaceAfter() - - - /** - * Returns the order that this element appears in the comment. - * - * @return int - */ - public function getOrder() - { - if ($this->previousElement === null) { - return 1; - } else { - return ($this->previousElement->getOrder() + 1); - } - - }//end getOrder() - - - /** - * Returns the tag that this element represents, ommiting the @ symbol. - * - * @return string - */ - public function getTag() - { - return $this->tag; - - }//end getTag() - - - /** - * Returns the raw content of this element, ommiting the tag. - * - * @return string - */ - public function getRawContent() - { - return implode('', $this->tokens); - - }//end getRawContent() - - - /** - * Returns the comment tokens. - * - * @return array - */ - public function getTokens() - { - return $this->tokens; - - }//end getTokens() - - - /** - * Returns the line in which this element first occured. - * - * @return int - */ - public function getLine() - { - if ($this->previousElement === null) { - // First element is on line one. - return 1; - } else { - $previousContent = $this->previousElement->getRawContent(); - $previousLine = $this->previousElement->getLine(); - - return ($previousLine + substr_count($previousContent, $this->phpcsFile->eolChar)); - } - - }//end getLine() - - - /** - * Returns the sub element names that make up this element in the order they - * appear in the element. - * - * @return array(string) - * @see processSubElement() - */ - abstract protected function getSubElements(); - - - /** - * Called to process each sub element as sepcified in the return value - * of getSubElements(). - * - * @param string $name The name of the element to process. - * @param string $content The content of the the element. - * @param string $whitespaceBefore The whitespace found before this element. - * - * @return void - * @see getSubElements() - */ - abstract protected function processSubElement( - $name, - $content, - $whitespaceBefore - ); - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/CommentParser/AbstractParser.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/CommentParser/AbstractParser.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/CommentParser/AbstractParser.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/CommentParser/AbstractParser.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,684 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -if (class_exists('PHP_CodeSniffer_CommentParser_SingleElement', true) === false) { - $error = 'Class PHP_CodeSniffer_CommentParser_SingleElement not found'; - throw new PHP_CodeSniffer_Exception($error); -} - -if (class_exists('PHP_CodeSniffer_CommentParser_CommentElement', true) === false) { - $error = 'Class PHP_CodeSniffer_CommentParser_CommentElement not found'; - throw new PHP_CodeSniffer_Exception($error); -} - -if (class_exists('PHP_CodeSniffer_CommentParser_ParserException', true) === false) { - $error = 'Class PHP_CodeSniffer_CommentParser_ParserException not found'; - throw new PHP_CodeSniffer_Exception($error); -} - -/** - * Parses doc comments. - * - * This abstract parser handles the following tags: - * - *
    - *
  • The short description and the long description
  • - *
  • @see
  • - *
  • @link
  • - *
  • @deprecated
  • - *
  • @since
  • - *
- * - * Extending classes should implement the getAllowedTags() method to return the - * tags that they wish to process, ommiting the tags that this base class - * processes. When one of these tags in encountered, the process<tag_name> - * method is called on that class. For example, if a parser's getAllowedTags() - * method returns \@param as one of its tags, the processParam method will be - * called so that the parser can process such a tag. - * - * The method is passed the tokens that comprise this tag. The tokens array - * includes the whitespace that exists between the tokens, as seperate tokens. - * It's up to the method to create a element that implements the DocElement - * interface, which should be returned. The AbstractDocElement class is a helper - * class that can be used to handle most of the parsing of the tokens into their - * individual sub elements. It requires that you construct it with the element - * previous to the element currently being processed, which can be acquired - * with the protected $previousElement class member of this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -abstract class PHP_CodeSniffer_CommentParser_AbstractParser -{ - - /** - * The comment element that appears in the doc comment. - * - * @var PHP_CodeSniffer_CommentParser_CommentElement - */ - protected $comment = null; - - /** - * The string content of the comment. - * - * @var string - */ - protected $commentString = ''; - - /** - * The file that the comment exists in. - * - * @var PHP_CodeSniffer_File - */ - protected $phpcsFile = null; - - /** - * The word tokens that appear in the comment. - * - * Whitespace tokens also appear in this stack, but are separate tokens - * from words. - * - * @var array(string) - */ - protected $words = array(); - - /** - * An array of all tags found in the comment. - * - * @var array(string) - */ - protected $foundTags = array(); - - /** - * The previous doc element that was processed. - * - * null if the current element being processed is the first element in the - * doc comment. - * - * @var PHP_CodeSniffer_CommentParser_DocElement - */ - protected $previousElement = null; - - /** - * A list of see elements that appear in this doc comment. - * - * @var array(PHP_CodeSniffer_CommentParser_SingleElement) - */ - protected $sees = array(); - - /** - * A list of see elements that appear in this doc comment. - * - * @var array(PHP_CodeSniffer_CommentParser_SingleElement) - */ - protected $deprecated = null; - - /** - * A list of see elements that appear in this doc comment. - * - * @var array(PHP_CodeSniffer_CommentParser_SingleElement) - */ - protected $links = array(); - - /** - * A element to represent \@since tags. - * - * @var PHP_CodeSniffer_CommentParser_SingleElement - */ - protected $since = null; - - /** - * True if the comment has been parsed. - * - * @var boolean - */ - private $_hasParsed = false; - - /** - * The tags that this class can process. - * - * @var array(string) - */ - private static $_tags = array( - 'see' => false, - 'link' => false, - 'deprecated' => true, - 'since' => true, - ); - - /** - * An array of unknown tags. - * - * @var array(string) - */ - public $unknown = array(); - - /** - * The order of tags. - * - * @var array(string) - */ - public $orders = array(); - - - /** - * Constructs a Doc Comment Parser. - * - * @param string $comment The comment to parse. - * @param PHP_CodeSniffer_File $phpcsFile The file that this comment is in. - */ - public function __construct($comment, PHP_CodeSniffer_File $phpcsFile) - { - $this->commentString = $comment; - $this->phpcsFile = $phpcsFile; - - }//end __construct() - - - /** - * Initiates the parsing of the doc comment. - * - * @return void - * @throws PHP_CodeSniffer_CommentParser_ParserException If the parser finds a - * problem with the - * comment. - */ - public function parse() - { - if ($this->_hasParsed === false) { - $this->_parse($this->commentString); - } - - }//end parse() - - - /** - * Parse the comment. - * - * @param string $comment The doc comment to parse. - * - * @return void - * @see _parseWords() - */ - private function _parse($comment) - { - // Firstly, remove the comment tags and any stars from the left side. - $lines = explode($this->phpcsFile->eolChar, $comment); - foreach ($lines as &$line) { - $line = trim($line); - - if ($line !== '') { - if (substr($line, 0, 3) === '/**') { - $line = substr($line, 3); - } else if (substr($line, -2, 2) === '*/') { - $line = substr($line, 0, -2); - } else if ($line{0} === '*') { - $line = substr($line, 1); - } - - // Add the words to the stack, preserving newlines. Other parsers - // might be interested in the spaces between words, so tokenize - // spaces as well as separate tokens. - $flags = (PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); - $words = preg_split( - '|(\s+)|', - $line.$this->phpcsFile->eolChar, - -1, - $flags - ); - - $this->words = array_merge($this->words, $words); - }//end if - }//end foreach - - $this->_parseWords(); - - }//end _parse() - - - /** - * Parses each word within the doc comment. - * - * @return void - * @see _parse() - * @throws PHP_CodeSniffer_CommentParser_ParserException If more than the allowed - * number of occurances of - * a tag is found. - */ - private function _parseWords() - { - $allowedTags = (self::$_tags + $this->getAllowedTags()); - $allowedTagNames = array_keys($allowedTags); - $prevTagPos = false; - $wordWasEmpty = true; - - foreach ($this->words as $wordPos => $word) { - if (trim($word) !== '') { - $wordWasEmpty = false; - } - - if ($word{0} === '@') { - $tag = substr($word, 1); - - // Filter out @ tags in the comment description. - // A real comment tag should have whitespace and a newline before it. - if (isset($this->words[($wordPos - 1)]) === false - || trim($this->words[($wordPos - 1)]) !== '' - ) { - continue; - } - - if (isset($this->words[($wordPos - 2)]) === false - || $this->words[($wordPos - 2)] !== $this->phpcsFile->eolChar - ) { - continue; - } - - $this->foundTags[] = array( - 'tag' => $tag, - 'line' => $this->getLine($wordPos), - 'pos' => $wordPos, - ); - - if ($prevTagPos !== false) { - // There was a tag before this so let's process it. - $prevTag = substr($this->words[$prevTagPos], 1); - $this->parseTag($prevTag, $prevTagPos, ($wordPos - 1)); - } else { - // There must have been a comment before this tag, so - // let's process that. - $this->parseTag('comment', 0, ($wordPos - 1)); - } - - $prevTagPos = $wordPos; - - if (in_array($tag, $allowedTagNames) === false) { - // This is not a tag that we process, but let's check to - // see if it is a tag we know about. If we don't know about it, - // we add it to a list of unknown tags. - $knownTags = array( - 'abstract', - 'access', - 'example', - 'filesource', - 'global', - 'ignore', - 'internal', - 'name', - 'static', - 'staticvar', - 'todo', - 'tutorial', - 'uses', - 'package_version@', - ); - - if (in_array($tag, $knownTags) === false) { - $this->unknown[] = array( - 'tag' => $tag, - 'line' => $this->getLine($wordPos), - 'pos' => $wordPos, - ); - } - }//end if - }//end if - }//end foreach - - // Only process this tag if there was something to process. - if ($wordWasEmpty === false) { - if ($prevTagPos === false) { - // There must only be a comment in this doc comment. - $this->parseTag('comment', 0, count($this->words)); - } else { - // Process the last tag element. - $prevTag = substr($this->words[$prevTagPos], 1); - $numWords = count($this->words); - $endPos = $numWords; - - if ($prevTag === 'package' || $prevTag === 'subpackage') { - // These are single-word tags, so anything after a newline - // is really a comment. - for ($endPos = $prevTagPos; $endPos < $numWords; $endPos++) { - if (strpos($this->words[$endPos], $this->phpcsFile->eolChar) !== false) { - break; - } - } - } - - $this->parseTag($prevTag, $prevTagPos, $endPos); - - if ($endPos !== $numWords) { - // Process the final comment, if it is not empty. - $tokens = array_slice($this->words, ($endPos + 1), $numWords); - $content = implode('', $tokens); - if (trim($content) !== '') { - $this->parseTag('comment', ($endPos + 1), $numWords); - } - } - }//end if - }//end if - - }//end _parseWords() - - - /** - * Returns the line that the token exists on in the doc comment. - * - * @param int $tokenPos The position in the words stack to find the line - * number for. - * - * @return int - */ - protected function getLine($tokenPos) - { - $newlines = 0; - for ($i = 0; $i < $tokenPos; $i++) { - $newlines += substr_count($this->phpcsFile->eolChar, $this->words[$i]); - } - - return $newlines; - - }//end getLine() - - - /** - * Parses see tag element within the doc comment. - * - * @param array(string) $tokens The word tokens that comprise this element. - * - * @return DocElement The element that represents this see comment. - */ - protected function parseSee($tokens) - { - $see = new PHP_CodeSniffer_CommentParser_SingleElement( - $this->previousElement, - $tokens, - 'see', - $this->phpcsFile - ); - - $this->sees[] = $see; - return $see; - - }//end parseSee() - - - /** - * Parses the comment element that appears at the top of the doc comment. - * - * @param array(string) $tokens The word tokens that comprise tihs element. - * - * @return DocElement The element that represents this comment element. - */ - protected function parseComment($tokens) - { - $this->comment = new PHP_CodeSniffer_CommentParser_CommentElement( - $this->previousElement, - $tokens, - $this->phpcsFile - ); - - return $this->comment; - - }//end parseComment() - - - /** - * Parses \@deprecated tags. - * - * @param array(string) $tokens The word tokens that comprise tihs element. - * - * @return DocElement The element that represents this deprecated tag. - */ - protected function parseDeprecated($tokens) - { - $this->deprecated = new PHP_CodeSniffer_CommentParser_SingleElement( - $this->previousElement, - $tokens, - 'deprecated', - $this->phpcsFile - ); - - return $this->deprecated; - - }//end parseDeprecated() - - - /** - * Parses \@since tags. - * - * @param array(string) $tokens The word tokens that comprise this element. - * - * @return SingleElement The element that represents this since tag. - */ - protected function parseSince($tokens) - { - $this->since = new PHP_CodeSniffer_CommentParser_SingleElement( - $this->previousElement, - $tokens, - 'since', - $this->phpcsFile - ); - - return $this->since; - - }//end parseSince() - - - /** - * Parses \@link tags. - * - * @param array(string) $tokens The word tokens that comprise this element. - * - * @return SingleElement The element that represents this link tag. - */ - protected function parseLink($tokens) - { - $link = new PHP_CodeSniffer_CommentParser_SingleElement( - $this->previousElement, - $tokens, - 'link', - $this->phpcsFile - ); - - $this->links[] = $link; - return $link; - - }//end parseLink() - - - /** - * Returns the see elements that appear in this doc comment. - * - * @return array(SingleElement) - */ - public function getSees() - { - return $this->sees; - - }//end getSees() - - - /** - * Returns the comment element that appears at the top of this doc comment. - * - * @return CommentElement - */ - public function getComment() - { - return $this->comment; - - }//end getComment() - - - /** - * Returns the word list. - * - * @return array - */ - public function getWords() - { - return $this->words; - - }//end getWords() - - - /** - * Returns the list of found tags. - * - * @return array - */ - public function getTags() - { - return $this->foundTags; - - }//end getTags() - - - /** - * Returns the link elements found in this comment. - * - * Returns an empty array if no links are found in the comment. - * - * @return array(SingleElement) - */ - public function getLinks() - { - return $this->links; - - }//end getLinks() - - - /** - * Returns the deprecated element found in this comment. - * - * Returns null if no element exists in the comment. - * - * @return SingleElement - */ - public function getDeprecated() - { - return $this->deprecated; - - }//end getDeprecated() - - - /** - * Returns the since element found in this comment. - * - * Returns null if no element exists in the comment. - * - * @return SingleElement - */ - public function getSince() - { - return $this->since; - - }//end getSince() - - - /** - * Parses the specified tag. - * - * @param string $tag The tag name to parse (omitting the @ sybmol from - * the tag) - * @param int $start The position in the word tokens where this element - * started. - * @param int $end The position in the word tokens where this element - * ended. - * - * @return void - * @throws Exception If the process method for the tag cannot be found. - */ - protected function parseTag($tag, $start, $end) - { - $tokens = array_slice($this->words, ($start + 1), ($end - $start)); - - $allowedTags = (self::$_tags + $this->getAllowedTags()); - $allowedTagNames = array_keys($allowedTags); - if ($tag === 'comment' || in_array($tag, $allowedTagNames) === true) { - $method = 'parse'.$tag; - if (method_exists($this, $method) === false) { - $error = 'Method '.$method.' must be implemented to process '.$tag.' tags'; - throw new Exception($error); - } - - $this->previousElement = $this->$method($tokens); - } else { - $this->previousElement = new PHP_CodeSniffer_CommentParser_SingleElement( - $this->previousElement, - $tokens, - $tag, - $this->phpcsFile - ); - } - - $this->orders[] = $tag; - - if ($this->previousElement === null - || ($this->previousElement instanceof PHP_CodeSniffer_CommentParser_DocElement) === false - ) { - throw new Exception('Parse method must return a DocElement'); - } - - }//end parseTag() - - - /** - * Returns a list of tags that this comment parser allows for it's comment. - * - * Each tag should indicate if only one entry of this tag can exist in the - * comment by specifying true as the array value, or false if more than one - * is allowed. Each tag should ommit the @ symbol. Only tags other than - * the standard tags should be returned. - * - * @return array(string => boolean) - */ - protected abstract function getAllowedTags(); - - - /** - * Returns the tag orders (index => tagName). - * - * @return array - */ - public function getTagOrders() - { - return $this->orders; - - }//end getTagOrders() - - - /** - * Returns the unknown tags. - * - * @return array - */ - public function getUnknown() - { - return $this->unknown; - - }//end getUnknown() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/CommentParser/ClassCommentParser.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/CommentParser/ClassCommentParser.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/CommentParser/ClassCommentParser.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/CommentParser/ClassCommentParser.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,341 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -if (class_exists('PHP_CodeSniffer_CommentParser_AbstractParser', true) === false) { - $error = 'Class PHP_CodeSniffer_CommentParser_AbstractParser not found'; - throw new PHP_CodeSniffer_Exception($error); -} - -/** - * Parses Class doc comments. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PHP_CodeSniffer_CommentParser_ClassCommentParser extends PHP_CodeSniffer_CommentParser_AbstractParser -{ - - /** - * The package element of this class. - * - * @var SingleElement - */ - private $_package = null; - - /** - * The subpackage element of this class. - * - * @var SingleElement - */ - private $_subpackage = null; - - /** - * The version element of this class. - * - * @var SingleElement - */ - private $_version = null; - - /** - * The category element of this class. - * - * @var SingleElement - */ - private $_category = null; - - /** - * The copyright elements of this class. - * - * @var array(SingleElement) - */ - private $_copyrights = array(); - - /** - * The licence element of this class. - * - * @var PairElement - */ - private $_license = null; - - /** - * The author elements of this class. - * - * @var array(SingleElement) - */ - private $_authors = array(); - - - /** - * Returns the allowed tags withing a class comment. - * - * @return array(string => int) - */ - protected function getAllowedTags() - { - return array( - 'category' => false, - 'package' => true, - 'subpackage' => true, - 'author' => false, - 'copyright' => true, - 'license' => false, - 'version' => true, - ); - - }//end getAllowedTags() - - - /** - * Parses the license tag of this class comment. - * - * @param array $tokens The tokens that comprise this tag. - * - * @return PHP_CodeSniffer_CommentParser_PairElement - */ - protected function parseLicense($tokens) - { - $this->_license = new PHP_CodeSniffer_CommentParser_PairElement( - $this->previousElement, - $tokens, - 'license', - $this->phpcsFile - ); - - return $this->_license; - - }//end parseLicense() - - - /** - * Parses the copyright tags of this class comment. - * - * @param array $tokens The tokens that comprise this tag. - * - * @return PHP_CodeSniffer_CommentParser_SingleElement - */ - protected function parseCopyright($tokens) - { - $copyright = new PHP_CodeSniffer_CommentParser_SingleElement( - $this->previousElement, - $tokens, - 'copyright', - $this->phpcsFile - ); - - $this->_copyrights[] = $copyright; - return $copyright; - - }//end parseCopyright() - - - /** - * Parses the category tag of this class comment. - * - * @param array $tokens The tokens that comprise this tag. - * - * @return PHP_CodeSniffer_CommentParser_SingleElement - */ - protected function parseCategory($tokens) - { - $this->_category = new PHP_CodeSniffer_CommentParser_SingleElement( - $this->previousElement, - $tokens, - 'category', - $this->phpcsFile - ); - - return $this->_category; - - }//end parseCategory() - - - /** - * Parses the author tag of this class comment. - * - * @param array $tokens The tokens that comprise this tag. - * - * @return array(PHP_CodeSniffer_CommentParser_SingleElement) - */ - protected function parseAuthor($tokens) - { - $author = new PHP_CodeSniffer_CommentParser_SingleElement( - $this->previousElement, - $tokens, - 'author', - $this->phpcsFile - ); - - $this->_authors[] = $author; - return $author; - - }//end parseAuthor() - - - /** - * Parses the version tag of this class comment. - * - * @param array $tokens The tokens that comprise this tag. - * - * @return PHP_CodeSniffer_CommentParser_SingleElement - */ - protected function parseVersion($tokens) - { - $this->_version = new PHP_CodeSniffer_CommentParser_SingleElement( - $this->previousElement, - $tokens, - 'version', - $this->phpcsFile - ); - - return $this->_version; - - }//end parseVersion() - - - /** - * Parses the package tag found in this test. - * - * @param array $tokens The tokens that comprise this var. - * - * @return PHP_CodeSniffer_CommentParser_SingleElement - */ - protected function parsePackage($tokens) - { - $this->_package = new PHP_CodeSniffer_CommentParser_SingleElement( - $this->previousElement, - $tokens, - 'package', - $this->phpcsFile - ); - - return $this->_package; - - }//end parsePackage() - - - /** - * Parses the package tag found in this test. - * - * @param array $tokens The tokens that comprise this var. - * - * @return PHP_CodeSniffer_CommentParser_SingleElement - */ - protected function parseSubpackage($tokens) - { - $this->_subpackage = new PHP_CodeSniffer_CommentParser_SingleElement( - $this->previousElement, - $tokens, - 'subpackage', - $this->phpcsFile - ); - - return $this->_subpackage; - - }//end parseSubpackage() - - - /** - * Returns the authors of this class comment. - * - * @return array(PHP_CodeSniffer_CommentParser_SingleElement) - */ - public function getAuthors() - { - return $this->_authors; - - }//end getAuthors() - - - /** - * Returns the version of this class comment. - * - * @return PHP_CodeSniffer_CommentParser_SingleElement - */ - public function getVersion() - { - return $this->_version; - - }//end getVersion() - - - /** - * Returns the license of this class comment. - * - * @return PHP_CodeSniffer_CommentParser_PairElement - */ - public function getLicense() - { - return $this->_license; - - }//end getLicense() - - - /** - * Returns the copyrights of this class comment. - * - * @return PHP_CodeSniffer_CommentParser_SingleElement - */ - public function getCopyrights() - { - return $this->_copyrights; - - }//end getCopyrights() - - - /** - * Returns the category of this class comment. - * - * @return PHP_CodeSniffer_CommentParser_SingleElement - */ - public function getCategory() - { - return $this->_category; - - }//end getCategory() - - - /** - * Returns the package that this class belongs to. - * - * @return PHP_CodeSniffer_CommentParser_SingleElement - */ - public function getPackage() - { - return $this->_package; - - }//end getPackage() - - - /** - * Returns the subpackage that this class belongs to. - * - * @return PHP_CodeSniffer_CommentParser_SingleElement - */ - public function getSubpackage() - { - return $this->_subpackage; - - }//end getSubpackage() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/CommentParser/CommentElement.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/CommentParser/CommentElement.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/CommentParser/CommentElement.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/CommentParser/CommentElement.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,245 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -if (class_exists('PHP_CodeSniffer_CommentParser_SingleElement', true) === false) { - $error = 'Class PHP_CodeSniffer_CommentParser_SingleElement not found'; - throw new PHP_CodeSniffer_Exception($error); -} - -/** - * A class to represent Comments of a doc comment. - * - * Comments are in the following format. - * - * /** <--this is the start of the comment. - * * This is a short comment description - * * - * * This is a long comment description - * * <-- this is the end of the comment - * * @return something - * {@/} - * - * - * Note that the sentence before two newlines is assumed - * the short comment description. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PHP_CodeSniffer_CommentParser_CommentElement extends PHP_CodeSniffer_CommentParser_SingleElement -{ - - - /** - * Constructs a PHP_CodeSniffer_CommentParser_CommentElement. - * - * @param PHP_CodeSniffer_CommentParser_DocElemement $previousElement The element - * that - * appears - * before this - * element. - * @param array $tokens The tokens - * that make - * up this - * element. - * @param PHP_CodeSniffer_File $phpcsFile The file - * that this - * element is - * in. - */ - public function __construct( - $previousElement, - $tokens, - PHP_CodeSniffer_File $phpcsFile - ) { - parent::__construct($previousElement, $tokens, 'comment', $phpcsFile); - - }//end __construct() - - - /** - * Returns the short comment description. - * - * @return string - * @see getLongComment() - */ - public function getShortComment() - { - $pos = $this->_getShortCommentEndPos(); - if ($pos === -1) { - return ''; - } - - return implode('', array_slice($this->tokens, 0, ($pos + 1))); - - }//end getShortComment() - - - /** - * Returns the last token position of the short comment description. - * - * @return int The last token position of the short comment description - * @see _getLongCommentStartPos() - */ - private function _getShortCommentEndPos() - { - $found = false; - $whiteSpace = array( - ' ', - "\t", - ); - - foreach ($this->tokens as $pos => $token) { - $token = str_replace($whiteSpace, '', $token); - if ($token === $this->phpcsFile->eolChar) { - if ($found === false) { - // Include newlines before short description. - continue; - } else { - if (isset($this->tokens[($pos + 1)]) === true) { - if ($this->tokens[($pos + 1)] === $this->phpcsFile->eolChar) { - return ($pos - 1); - } - } else { - return $pos; - } - } - } else { - $found = true; - } - }//end foreach - - return (count($this->tokens) - 1); - - }//end _getShortCommentEndPos() - - - /** - * Returns the long comment description. - * - * @return string - * @see getShortComment - */ - public function getLongComment() - { - $start = $this->_getLongCommentStartPos(); - if ($start === -1) { - return ''; - } - - return implode('', array_slice($this->tokens, $start)); - - }//end getLongComment() - - - /** - * Returns the start position of the long comment description. - * - * Returns -1 if there is no long comment. - * - * @return int The start position of the long comment description. - * @see _getShortCommentEndPos() - */ - private function _getLongCommentStartPos() - { - $pos = ($this->_getShortCommentEndPos() + 1); - if ($pos === (count($this->tokens) - 1)) { - return -1; - } - - $count = count($this->tokens); - for ($i = $pos; $i < $count; $i++) { - $content = trim($this->tokens[$i]); - if ($content !== '') { - if ($content{0} === '@') { - return -1; - } - - return $i; - } - } - - return -1; - - }//end _getLongCommentStartPos() - - - /** - * Returns the whitespace that exists between - * the short and the long comment description. - * - * @return string - */ - public function getWhiteSpaceBetween() - { - $endShort = ($this->_getShortCommentEndPos() + 1); - $startLong = ($this->_getLongCommentStartPos() - 1); - if ($startLong === -1) { - return ''; - } - - return implode( - '', - array_slice($this->tokens, $endShort, ($startLong - $endShort)) - ); - - }//end getWhiteSpaceBetween() - - - /** - * Returns the number of newlines that exist before the tags. - * - * @return int - */ - public function getNewlineAfter() - { - $long = $this->getLongComment(); - if ($long !== '') { - $long = rtrim($long, ' '); - $long = strrev($long); - $newlines = strspn($long, $this->phpcsFile->eolChar); - } else { - $endShort = ($this->_getShortCommentEndPos() + 1); - $after = implode('', array_slice($this->tokens, $endShort)); - $after = trim($after, ' '); - $newlines = strspn($after, $this->phpcsFile->eolChar); - } - - return ($newlines / strlen($this->phpcsFile->eolChar)); - - }//end getNewlineAfter() - - - /** - * Returns true if there is no comment. - * - * @return boolean - */ - public function isEmpty() - { - return (trim($this->getContent()) === ''); - - }//end isEmpty() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/CommentParser/DocElement.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/CommentParser/DocElement.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/CommentParser/DocElement.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/CommentParser/DocElement.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,104 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * A DocElement represents a logical element within a Doc Comment. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -interface PHP_CodeSniffer_CommentParser_DocElement -{ - - - /** - * Returns the name of the tag this element represents, omitting the @ symbol. - * - * @return string - */ - public function getTag(); - - - /** - * Returns the whitespace that exists before this element. - * - * @return string - * @see getWhitespaceAfter() - */ - public function getWhitespaceBefore(); - - - /** - * Returns the whitespace that exists after this element. - * - * @return string - * @see getWhitespaceBefore() - */ - public function getWhitespaceAfter(); - - - /** - * Returns the order that this element appears in the doc comment. - * - * The first element in the comment should have an order of 1. - * - * @return int - */ - public function getOrder(); - - - /** - * Returns the element that appears before this element. - * - * @return PHP_CodeSniffer_CommentParser_DocElement - * @see getNextElement() - */ - public function getPreviousElement(); - - - /** - * Returns the element that appears after this element. - * - * @return PHP_CodeSniffer_CommentParser_DocElement - * @see getPreviousElement() - */ - public function getNextElement(); - - - /** - * Returns the line that this element started on. - * - * @return int - */ - public function getLine(); - - - /** - * Returns the raw content of this element, ommiting the tag. - * - * @return string - */ - public function getRawContent(); - - -}//end interface - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/CommentParser/FunctionCommentParser.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/CommentParser/FunctionCommentParser.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/CommentParser/FunctionCommentParser.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/CommentParser/FunctionCommentParser.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,212 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -if (class_exists('PHP_CodeSniffer_CommentParser_AbstractParser', true) === false) { - $error = 'Class PHP_CodeSniffer_CommentParser_AbstractParser not found'; - throw new PHP_CodeSniffer_Exception($error); -} - -if (class_exists('PHP_CodeSniffer_CommentParser_ParameterElement', true) === false) { - $error = 'Class PHP_CodeSniffer_CommentParser_ParameterElement not found'; - throw new PHP_CodeSniffer_Exception($error); -} - -if (class_exists('PHP_CodeSniffer_CommentParser_PairElement', true) === false) { - $error = 'Class PHP_CodeSniffer_CommentParser_PairElement not found'; - throw new PHP_CodeSniffer_Exception($error); -} - -if (class_exists('PHP_CodeSniffer_CommentParser_SingleElement', true) === false) { - $error = 'Class PHP_CodeSniffer_CommentParser_SingleElement not found'; - throw new PHP_CodeSniffer_Exception($error); -} - -/** - * Parses function doc comments. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PHP_CodeSniffer_CommentParser_FunctionCommentParser extends PHP_CodeSniffer_CommentParser_AbstractParser -{ - - /** - * The parameter elements within this function comment. - * - * @var array(PHP_CodeSniffer_CommentParser_ParameterElement) - */ - private $_params = array(); - - /** - * The return element in this function comment. - * - * @var PHP_CodeSniffer_CommentParser_PairElement. - */ - private $_return = null; - - /** - * The throws element list for this function comment. - * - * @var array(PHP_CodeSniffer_CommentParser_PairElement) - */ - private $_throws = array(); - - - /** - * Constructs a PHP_CodeSniffer_CommentParser_FunctionCommentParser. - * - * @param string $comment The comment to parse. - * @param PHP_CodeSniffer_File $phpcsFile The file that this comment is in. - */ - public function __construct($comment, PHP_CodeSniffer_File $phpcsFile) - { - parent::__construct($comment, $phpcsFile); - - }//end __construct() - - - /** - * Parses parameter elements. - * - * @param array(string) $tokens The tokens that conmpise this sub element. - * - * @return PHP_CodeSniffer_CommentParser_ParameterElement - */ - protected function parseParam($tokens) - { - $param = new PHP_CodeSniffer_CommentParser_ParameterElement( - $this->previousElement, - $tokens, - $this->phpcsFile - ); - - $this->_params[] = $param; - return $param; - - }//end parseParam() - - - /** - * Parses return elements. - * - * @param array(string) $tokens The tokens that conmpise this sub element. - * - * @return PHP_CodeSniffer_CommentParser_PairElement - */ - protected function parseReturn($tokens) - { - $return = new PHP_CodeSniffer_CommentParser_PairElement( - $this->previousElement, - $tokens, - 'return', - $this->phpcsFile - ); - - $this->_return = $return; - return $return; - - }//end parseReturn() - - - /** - * Parses throws elements. - * - * @param array(string) $tokens The tokens that conmpise this sub element. - * - * @return PHP_CodeSniffer_CommentParser_PairElement - */ - protected function parseThrows($tokens) - { - $throws = new PHP_CodeSniffer_CommentParser_PairElement( - $this->previousElement, - $tokens, - 'throws', - $this->phpcsFile - ); - - $this->_throws[] = $throws; - return $throws; - - }//end parseThrows() - - - /** - * Returns the parameter elements that this function comment contains. - * - * Returns an empty array if no parameter elements are contained within - * this function comment. - * - * @return array(PHP_CodeSniffer_CommentParser_ParameterElement) - */ - public function getParams() - { - return $this->_params; - - }//end getParams() - - - /** - * Returns the return element in this fucntion comment. - * - * Returns null if no return element exists in the comment. - * - * @return PHP_CodeSniffer_CommentParser_PairElement - */ - public function getReturn() - { - return $this->_return; - - }//end getReturn() - - - /** - * Returns the throws elements in this fucntion comment. - * - * Returns empty array if no throws elements in the comment. - * - * @return array(PHP_CodeSniffer_CommentParser_PairElement) - */ - public function getThrows() - { - return $this->_throws; - - }//end getThrows() - - - /** - * Returns the allowed tags that can exist in a function comment. - * - * @return array(string => boolean) - */ - protected function getAllowedTags() - { - return array( - 'param' => false, - 'return' => true, - 'throws' => false, - ); - - }//end getAllowedTags() - - -}//end class - -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/CommentParser/MemberCommentParser.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/CommentParser/MemberCommentParser.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/CommentParser/MemberCommentParser.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/CommentParser/MemberCommentParser.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,91 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -if (class_exists('PHP_CodeSniffer_CommentParser_ClassCommentParser', true) === false) { - $error = 'Class PHP_CodeSniffer_CommentParser_ClassCommentParser not found'; - throw new PHP_CodeSniffer_Exception($error); -} - -/** - * Parses class member comments. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PHP_CodeSniffer_CommentParser_MemberCommentParser extends PHP_CodeSniffer_CommentParser_ClassCommentParser -{ - - /** - * Represents a \@var tag in a member comment. - * - * @var PHP_CodeSniffer_CommentParser_SingleElement - */ - private $_var = null; - - - /** - * Parses Var tags. - * - * @param array $tokens The tokens that represent this tag. - * - * @return PHP_CodeSniffer_CommentParser_SingleElement - */ - protected function parseVar($tokens) - { - $this->_var = new PHP_CodeSniffer_CommentParser_SingleElement( - $this->previousElement, - $tokens, - 'var', - $this->phpcsFile - ); - - return $this->_var; - - }//end parseVar() - - - /** - * Returns the var tag found in the member comment. - * - * @return PHP_CodeSniffer_CommentParser_PairElement - */ - public function getVar() - { - return $this->_var; - - }//end getVar() - - - /** - * Returns the allowed tags for this parser. - * - * @return array - */ - protected function getAllowedTags() - { - return array('var' => true); - - }//end getAllowedTags() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/CommentParser/PairElement.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/CommentParser/PairElement.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/CommentParser/PairElement.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/CommentParser/PairElement.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,171 +0,0 @@ - comment format. - * - * PHP version 5 - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -if (class_exists('PHP_CodeSniffer_CommentParser_AbstractDocElement', true) === false) { - $error = 'Class PHP_CodeSniffer_CommentParser_AbstractDocElement not found'; - throw new PHP_CodeSniffer_Exception($error); -} - -/** - * A class to represent elements that have a value => comment format. - * - * An example of a pair element tag is the \@throws as it has an exception type - * and a comment on the circumstance of when the exception is thrown. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PHP_CodeSniffer_CommentParser_PairElement extends PHP_CodeSniffer_CommentParser_AbstractDocElement -{ - - /** - * The value of the tag. - * - * @var string - */ - private $_value = ''; - - /** - * The comment of the tag. - * - * @var string - */ - private $_comment = ''; - - /** - * The whitespace that exists before the value elem. - * - * @var string - */ - private $_valueWhitespace = ''; - - /** - * The whitespace that exists before the comment elem. - * - * @var string - */ - private $_commentWhitespace = ''; - - - /** - * Constructs a PHP_CodeSniffer_CommentParser_PairElement doc tag. - * - * @param PHP_CodeSniffer_CommentParser_DocElement $previousElement The element - * before this - * one. - * @param array $tokens The tokens - * that comprise - * this element. - * @param string $tag The tag that - * this element - * represents. - * @param PHP_CodeSniffer_File $phpcsFile The file that - * this element - * is in. - */ - public function __construct( - $previousElement, - $tokens, - $tag, - PHP_CodeSniffer_File $phpcsFile - ) { - parent::__construct($previousElement, $tokens, $tag, $phpcsFile); - - }//end __construct() - - - /** - * Returns the element names that this tag is comprised of, in the order - * that they appear in the tag. - * - * @return array(string) - * @see processSubElement() - */ - protected function getSubElements() - { - return array( - 'value', - 'comment', - ); - - }//end getSubElements() - - - /** - * Processes the sub element with the specified name. - * - * @param string $name The name of the sub element to process. - * @param string $content The content of this sub element. - * @param string $whitespaceBefore The whitespace that exists before the - * sub element. - * - * @return void - * @see getSubElements() - */ - protected function processSubElement($name, $content, $whitespaceBefore) - { - $element = '_'.$name; - $whitespace = $element.'Whitespace'; - $this->$element = $content; - $this->$whitespace = $whitespaceBefore; - - }//end processSubElement() - - - /** - * Returns the value of the tag. - * - * @return string - */ - public function getValue() - { - return $this->_value; - - }//end getValue() - - - /** - * Returns the comment associated with the value of this tag. - * - * @return string - */ - public function getComment() - { - return $this->_comment; - - }//end getComment() - - - /** - * Returns the witespace before the content of this tag. - * - * @return string - */ - public function getWhitespaceBeforeValue() - { - return $this->_valueWhitespace; - - }//end getWhitespaceBeforeValue() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/CommentParser/ParameterElement.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/CommentParser/ParameterElement.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/CommentParser/ParameterElement.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/CommentParser/ParameterElement.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,334 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -if (class_exists('PHP_CodeSniffer_CommentParser_AbstractDocElement', true) === false) { - $error = 'Class PHP_CodeSniffer_CommentParser_AbstractDocElement not found'; - throw new PHP_CodeSniffer_Exception($error); -} - -/** - * A class to represent param tags within a function comment. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PHP_CodeSniffer_CommentParser_ParameterElement extends PHP_CodeSniffer_CommentParser_AbstractDocElement -{ - - /** - * The variable name of this parameter name, including the $ sign. - * - * @var string - */ - private $_varName = ''; - - /** - * The comment of this parameter tag. - * - * @var string - */ - private $_comment = ''; - - /** - * The variable type of this parameter tag. - * - * @var string - */ - private $_type = ''; - - /** - * The whitespace that exists before the variable name. - * - * @var string - */ - private $_varNameWhitespace = ''; - - /** - * The whitespace that exists before the comment. - * - * @var string - */ - private $_commentWhitespace = null; - - /** - * The whitespace that exists before the variable type. - * - * @var string - */ - private $_typeWhitespace = ''; - - - /** - * Constructs a PHP_CodeSniffer_CommentParser_ParameterElement. - * - * @param PHP_CodeSniffer_CommentParser_DocElement $previousElement The element - * previous to - * this one. - * @param array $tokens The tokens - * that make up - * this element. - * @param PHP_CodeSniffer_File $phpcsFile The file that - * this element - * is in. - */ - public function __construct( - $previousElement, - $tokens, - PHP_CodeSniffer_File $phpcsFile - ) { - parent::__construct($previousElement, $tokens, 'param', $phpcsFile); - - // Handle special variable type: array(x => y). - $type = strtolower($this->_type); - if ($this->_varName === '=>' && strpos($type, 'array(') !== false) { - $rawContent = $this->getRawContent(); - $matches = array(); - $pattern = '/^(\s+)(array\(.*\))(\s+)(\$\S*)(\s+)(.*)/i'; - if (preg_match($pattern, $rawContent, $matches) !== 0) { - // Process the sub elements correctly for this special case. - if (count($matches) === 7) { - $this->processSubElement('type', $matches[2], $matches[1]); - $this->processSubElement('varName', $matches[4], $matches[3]); - $this->processSubElement('comment', $matches[6], $matches[5]); - } - } - } - - }//end __construct() - - - /** - * Returns the element names that this tag is comprised of, in the order - * that they appear in the tag. - * - * @return array(string) - * @see processSubElement() - */ - protected function getSubElements() - { - return array( - 'type', - 'varName', - 'comment', - ); - - }//end getSubElements() - - - /** - * Processes the sub element with the specified name. - * - * @param string $name The name of the sub element to process. - * @param string $content The content of this sub element. - * @param string $beforeWhitespace The whitespace that exists before the - * sub element. - * - * @return void - * @see getSubElements() - */ - protected function processSubElement($name, $content, $beforeWhitespace) - { - $element = '_'.$name; - $whitespace = $element.'Whitespace'; - $this->$element = $content; - $this->$whitespace = $beforeWhitespace; - - }//end processSubElement() - - - /** - * Returns the variable name that this parameter tag represents. - * - * @return string - */ - public function getVarName() - { - return $this->_varName; - - }//end getVarName() - - - /** - * Returns the variable type that this string represents. - * - * @return string - */ - public function getType() - { - return $this->_type; - - }//end getType() - - - /** - * Returns the comment of this comment for this parameter. - * - * @return string - */ - public function getComment() - { - return $this->_comment; - - }//end getComment() - - - /** - * Returns the whitespace before the variable type. - * - * @return stirng - * @see getWhiteSpaceBeforeVarName() - * @see getWhiteSpaceBeforeComment() - */ - public function getWhiteSpaceBeforeType() - { - return $this->_typeWhitespace; - - }//end getWhiteSpaceBeforeType() - - - /** - * Returns the whitespace before the variable name. - * - * @return string - * @see getWhiteSpaceBeforeComment() - * @see getWhiteSpaceBeforeType() - */ - public function getWhiteSpaceBeforeVarName() - { - return $this->_varNameWhitespace; - - }//end getWhiteSpaceBeforeVarName() - - - /** - * Returns the whitespace before the comment. - * - * @return string - * @see getWhiteSpaceBeforeVarName() - * @see getWhiteSpaceBeforeType() - */ - public function getWhiteSpaceBeforeComment() - { - return $this->_commentWhitespace; - - }//end getWhiteSpaceBeforeComment() - - - /** - * Returns the postition of this parameter are it appears in the comment. - * - * This method differs from getOrder as it is only relative to method - * parameters. - * - * @return int - */ - public function getPosition() - { - if (($this->getPreviousElement() instanceof PHP_CodeSniffer_CommentParser_ParameterElement) === false) { - return 1; - } else { - return ($this->getPreviousElement()->getPosition() + 1); - } - - }//end getPosition() - - - /** - * Returns true if this parameter's variable aligns with the other's. - * - * @param PHP_CodeSniffer_CommentParser_ParameterElement $other The other param - * to check - * alignment with. - * - * @return boolean - */ - public function alignsVariableWith( - PHP_CodeSniffer_CommentParser_ParameterElement $other - ) { - // Format is: - // @param type $variable Comment. - // @param <-a-><---b----> - // Compares the index before param variable. - $otherVar = (strlen($other->_type) + strlen($other->_varNameWhitespace)); - $thisVar = (strlen($this->_type) + strlen($this->_varNameWhitespace)); - if ($otherVar !== $thisVar) { - return false; - } - - return true; - - }//end alignsVariableWith() - - - /** - * Returns true if this parameter's comment aligns with the other's. - * - * @param PHP_CodeSniffer_CommentParser_ParameterElement $other The other param - * to check - * alignment with. - * - * @return boolean - */ - public function alignsCommentWith( - PHP_CodeSniffer_CommentParser_ParameterElement $other - ) { - // Compares the index before param comment. - $otherComment - = (strlen($other->_varName) + strlen($other->_commentWhitespace)); - $thisComment - = (strlen($this->_varName) + strlen($this->_commentWhitespace)); - - if ($otherComment !== $thisComment) { - return false; - } - - return true; - - }//end alignsCommentWith() - - - /** - * Returns true if this parameter aligns with the other paramter. - * - * @param PHP_CodeSniffer_CommentParser_ParameterElement $other The other param - * to check - * alignment with. - * - * @return boolean - */ - public function alignsWith(PHP_CodeSniffer_CommentParser_ParameterElement $other) - { - if ($this->alignsVariableWith($other) === false) { - return false; - } - - if ($this->alignsCommentWith($other) === false) { - return false; - } - - return true; - - }//end alignsWith() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/CommentParser/ParserException.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/CommentParser/ParserException.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/CommentParser/ParserException.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/CommentParser/ParserException.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,71 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * An exception to be thrown when a DocCommentParser finds an anomilty in a - * doc comment. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PHP_CodeSniffer_CommentParser_ParserException extends Exception -{ - - /** - * The line where the exception occured, in relation to the doc comment. - * - * @var int - */ - private $_line = 0; - - - /** - * Constructs a DocCommentParserException. - * - * @param string $message The message of the exception. - * @param int $line The position in comment where the error occured. - * A position of 0 indicates that the error occured - * at the opening line of the doc comment. - */ - public function __construct($message, $line) - { - parent::__construct($message); - $this->_line = $line; - - }//end __construct() - - - /** - * Returns the line number within the comment where the exception occured. - * - * @return int - */ - public function getLineWithinComment() - { - return $this->_line; - - }//end getLineWithinComment() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/CommentParser/SingleElement.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/CommentParser/SingleElement.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/CommentParser/SingleElement.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/CommentParser/SingleElement.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,171 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -if (class_exists('PHP_CodeSniffer_CommentParser_AbstractDocElement', true) === false) { - $error = 'Class PHP_CodeSniffer_CommentParser_AbstractDocElement not found'; - throw new PHP_CodeSniffer_Exception($error); -} - -/** - * A class to represent single element doc tags. - * - * A single element doc tag contains only one value after the tag itself. An - * example would be the \@package tag. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PHP_CodeSniffer_CommentParser_SingleElement extends PHP_CodeSniffer_CommentParser_AbstractDocElement -{ - - /** - * The content that exists after the tag. - * - * @var string - * @see getContent() - */ - protected $content = ''; - - /** - * The whitespace that exists before the content. - * - * @var string - * @see getWhitespaceBeforeContent() - */ - protected $contentWhitespace = ''; - - - /** - * Constructs a SingleElement doc tag. - * - * @param PHP_CodeSniffer_CommentParser_DocElement $previousElement The element - * before this - * one. - * @param array $tokens The tokens - * that comprise - * this element. - * @param string $tag The tag that - * this element - * represents. - * @param PHP_CodeSniffer_File $phpcsFile The file that - * this element - * is in. - */ - public function __construct( - $previousElement, - $tokens, - $tag, - PHP_CodeSniffer_File $phpcsFile - ) { - parent::__construct($previousElement, $tokens, $tag, $phpcsFile); - - }//end __construct() - - - /** - * Returns the element names that this tag is comprised of, in the order - * that they appear in the tag. - * - * @return array(string) - * @see processSubElement() - */ - protected function getSubElements() - { - return array('content'); - - }//end getSubElements() - - - /** - * Processes the sub element with the specified name. - * - * @param string $name The name of the sub element to process. - * @param string $content The content of this sub element. - * @param string $whitespaceBefore The whitespace that exists before the - * sub element. - * - * @return void - * @see getSubElements() - */ - protected function processSubElement($name, $content, $whitespaceBefore) - { - $this->content = $content; - $this->contentWhitespace = $whitespaceBefore; - - }//end processSubElement() - - - /** - * Returns the content of this tag. - * - * @return string - */ - public function getContent() - { - return $this->content; - - }//end getContent() - - - /** - * Returns the witespace before the content of this tag. - * - * @return string - */ - public function getWhitespaceBeforeContent() - { - return $this->contentWhitespace; - - }//end getWhitespaceBeforeContent() - - - /** - * Processes a content check for single doc element. - * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $commentStart The line number where - * the error occurs. - * @param string $docBlock Whether this is a file or - * class comment doc. - * - * @return void - */ - public function process( - PHP_CodeSniffer_File $phpcsFile, - $commentStart, - $docBlock - ) { - if ($this->content === '') { - $errorPos = ($commentStart + $this->getLine()); - $error = 'Content missing for %s tag in %s comment'; - $data = array( - $this->tag, - $docBlock, - ); - $phpcsFile->addError($error, $errorPos, 'EmptyTagContent', $data); - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/DocGenerators/Generator.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/DocGenerators/Generator.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/DocGenerators/Generator.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/DocGenerators/Generator.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,197 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * The base class for all PHP_CodeSniffer documentation generators. - * - * Documentation generators are used to print documentation about code sniffs - * in a standard. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PHP_CodeSniffer_DocGenerators_Generator -{ - - /** - * The name of the coding standard we are generating docs for. - * - * @var string - */ - private $_standard = ''; - - /** - * An array of sniffs that we are limiting the generated docs to. - * - * If this array is empty, docs are generated for all sniffs in the - * supplied coding standard. - * - * @var string - */ - private $_sniffs = array(); - - - /** - * Constructs a PHP_CodeSniffer_DocGenerators_Generator object. - * - * @param string $standard The name of the coding standard to generate - * docs for. - * @param array $sniffs An array of sniffs that we are limiting the - * generated docs to. - * - * @see generate() - */ - public function __construct($standard, array $sniffs=array()) - { - $this->_standard = $standard; - $this->_sniffs = $sniffs; - - }//end __construct() - - - /** - * Retrieves the title of the sniff from the DOMNode supplied. - * - * @param DOMNode $doc The DOMNode object for the sniff. - * It represents the "documentation" tag in the XML - * standard file. - * - * @return string - */ - protected function getTitle(DOMNode $doc) - { - return $doc->getAttribute('title'); - - }//end getTitle() - - - /** - * Retrieves the name of the standard we are generating docs for. - * - * @return string - */ - protected function getStandard() - { - return $this->_standard; - - }//end getStandard() - - - /** - * Generates the documentation for a standard. - * - * It's probably wise for doc generators to override this method so they - * have control over how the docs are produced. Otherwise, the processSniff - * method should be overridden to output content for each sniff. - * - * @return void - * @see processSniff() - */ - public function generate() - { - $standardFiles = $this->getStandardFiles(); - - foreach ($standardFiles as $standard) { - $doc = new DOMDocument(); - $doc->load($standard); - $documentation = $doc->getElementsByTagName('documentation')->item(0); - $this->processSniff($documentation); - } - - }//end generate() - - - /** - * Returns a list of paths to XML standard files for all sniffs in a standard. - * - * Any sniffs that do not have an XML standard file are obviously not included - * in the returned array. If documentation is only being generated for some - * sniffs (ie. $this->_sniffs is not empty) then all others sniffs will - * be filtered from the results as well. - * - * @return array(string) - */ - protected function getStandardFiles() - { - if (is_dir($this->_standard) === true) { - // This is a custom standard. - $standardDir = $this->_standard; - $standard = basename($this->_standard); - } else { - $standardDir - = realpath(dirname(__FILE__).'/../Standards/'.$this->_standard); - - $standard = $this->_standard; - } - - $phpcs = new PHP_CodeSniffer(); - $sniffs = $phpcs->getSniffFiles($standardDir, $standard); - - $standardFiles = array(); - foreach ($sniffs as $sniff) { - if (empty($this->_sniffs) === false) { - // We are limiting the docs to certain sniffs only, so filter - // out any unwanted sniffs. - $sniffName = substr($sniff, (strrpos($sniff, '/') + 1)); - $sniffName = substr($sniffName, 0, -9); - if (in_array($sniffName, $this->_sniffs) === false) { - continue; - } - } - - $standardFile = str_replace( - DIRECTORY_SEPARATOR.'Sniffs'.DIRECTORY_SEPARATOR, - DIRECTORY_SEPARATOR.'Docs'.DIRECTORY_SEPARATOR, - $sniff - ); - $standardFile = str_replace('Sniff.php', 'Standard.xml', $standardFile); - - if (is_file($standardFile) === true) { - $standardFiles[] = $standardFile; - } - }//end foreach - - return $standardFiles; - - }//end getStandardFiles() - - - /** - * Process the documentation for a single sniff. - * - * Doc generators should override this function to produce output. - * - * @param DOMNode $doc The DOMNode object for the sniff. - * It represents the "documentation" tag in the XML - * standard file. - * - * @return void - * @see generate() - */ - protected function processSniff(DOMNode $doc) - { - - }//end processSniff() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/DocGenerators/HTML.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/DocGenerators/HTML.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/DocGenerators/HTML.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/DocGenerators/HTML.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,292 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -if (class_exists('PHP_CodeSniffer_DocGenerators_Generator', true) === false) { - throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_DocGenerators_Generator not found'); -} - -/** - * A doc generator that outputs documentation in one big HTML file. - * - * Output is in one large HTML file and is designed for you to style with - * your own stylesheet. It contains a table of contents at the top with anchors - * to each sniff. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PHP_CodeSniffer_DocGenerators_HTML extends PHP_CodeSniffer_DocGenerators_Generator -{ - - - /** - * Generates the documentation for a standard. - * - * @return void - * @see processSniff() - */ - public function generate() - { - ob_start(); - $this->printHeader(); - - $standardFiles = $this->getStandardFiles(); - $this->printToc($standardFiles); - - foreach ($standardFiles as $standard) { - $doc = new DOMDocument(); - $doc->load($standard); - $documentation = $doc->getElementsByTagName('documentation')->item(0); - $this->processSniff($documentation); - } - - $this->printFooter(); - - $content = ob_get_contents(); - ob_end_clean(); - - echo $content; - - }//end generate() - - - /** - * Print the header of the HTML page. - * - * @return void - */ - protected function printHeader() - { - $standard = $this->getStandard(); - echo ''.PHP_EOL; - echo ' '.PHP_EOL; - echo " $standard Coding Standards".PHP_EOL; - echo ' '.PHP_EOL; - echo ' '.PHP_EOL; - echo ' '.PHP_EOL; - echo "

$standard Coding Standards

".PHP_EOL; - - }//end printHeader() - - - /** - * Print the table of contents for the standard. - * - * The TOC is just an unordered list of bookmarks to sniffs on the page. - * - * @param array $standardFiles An array of paths to the XML standard files. - * - * @return void - */ - protected function printToc($standardFiles) - { - echo '

Table of Contents

'.PHP_EOL; - echo '
    '.PHP_EOL; - - foreach ($standardFiles as $standard) { - $doc = new DOMDocument(); - $doc->load($standard); - $documentation = $doc->getElementsByTagName('documentation')->item(0); - $title = $this->getTitle($documentation); - echo '
  • $title
  • ".PHP_EOL; - } - - echo '
'.PHP_EOL; - - }//end printToc() - - - /** - * Print the footer of the HTML page. - * - * @return void - */ - protected function printFooter() - { - // Turn off strict errors so we don't get timezone warnings if people - // don't have their timezone set. - error_reporting(E_ALL); - echo '
'; - echo 'Documentation generated on '.date('r'); - echo ' by PHP_CodeSniffer 1.3.4'; - echo '
'.PHP_EOL; - error_reporting(E_ALL | E_STRICT); - - echo ' '.PHP_EOL; - echo ''.PHP_EOL; - - }//end printFooter() - - - /** - * Process the documentation for a single sniff. - * - * @param DOMNode $doc The DOMNode object for the sniff. - * It represents the "documentation" tag in the XML - * standard file. - * - * @return void - */ - public function processSniff(DOMNode $doc) - { - $title = $this->getTitle($doc); - echo ' '.PHP_EOL; - echo "

$title

".PHP_EOL; - - foreach ($doc->childNodes as $node) { - if ($node->nodeName === 'standard') { - $this->printTextBlock($node); - } else if ($node->nodeName === 'code_comparison') { - $this->printCodeComparisonBlock($node); - } - } - - }//end processSniff() - - - /** - * Print a text block found in a standard. - * - * @param DOMNode $node The DOMNode object for the text block. - * - * @return void - */ - protected function printTextBlock($node) - { - $content = trim($node->nodeValue); - $content = htmlspecialchars($content); - - // Allow em tags only. - $content = str_replace('<em>', '', $content); - $content = str_replace('</em>', '', $content); - - echo "

$content

".PHP_EOL; - - }//end printTextBlock() - - - /** - * Print a code comparison block found in a standard. - * - * @param DOMNode $node The DOMNode object for the code comparison block. - * - * @return void - */ - protected function printCodeComparisonBlock($node) - { - $codeBlocks = $node->getElementsByTagName('code'); - - $firstTitle = $codeBlocks->item(0)->getAttribute('title'); - $first = trim($codeBlocks->item(0)->nodeValue); - $first = str_replace("\n", '
', $first); - $first = str_replace(' ', ' ', $first); - $first = str_replace('', '', $first); - $first = str_replace('', '', $first); - - $secondTitle = $codeBlocks->item(1)->getAttribute('title'); - $second = trim($codeBlocks->item(1)->nodeValue); - $second = str_replace("\n", '
', $second); - $second = str_replace(' ', ' ', $second); - $second = str_replace('', '', $second); - $second = str_replace('', '', $second); - - echo ' '.PHP_EOL; - echo ' '.PHP_EOL; - echo " ".PHP_EOL; - echo " ".PHP_EOL; - echo ' '.PHP_EOL; - echo ' '.PHP_EOL; - echo " ".PHP_EOL; - echo " ".PHP_EOL; - echo ' '.PHP_EOL; - echo '
$firstTitle$secondTitle
$first$second
'.PHP_EOL; - - }//end printCodeComparisonBlock() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/DocGenerators/Text.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/DocGenerators/Text.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/DocGenerators/Text.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/DocGenerators/Text.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,267 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -if (class_exists('PHP_CodeSniffer_DocGenerators_Generator', true) === false) { - throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_DocGenerators_Generator not found'); -} - -/** - * A doc generator that outputs text-based documentation. - * - * Output is designed to be displayed in a terminal and is wrapped to 100 characters. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PHP_CodeSniffer_DocGenerators_Text extends PHP_CodeSniffer_DocGenerators_Generator -{ - - - /** - * Process the documentation for a single sniff. - * - * @param DOMNode $doc The DOMNode object for the sniff. - * It represents the "documentation" tag in the XML - * standard file. - * - * @return void - */ - public function processSniff(DOMNode $doc) - { - $this->printTitle($doc); - - foreach ($doc->childNodes as $node) { - if ($node->nodeName === 'standard') { - $this->printTextBlock($node); - } else if ($node->nodeName === 'code_comparison') { - $this->printCodeComparisonBlock($node); - } - } - - }//end processSniff() - - - /** - * Prints the title area for a single sniff. - * - * @param DOMNode $doc The DOMNode object for the sniff. - * It represents the "documentation" tag in the XML - * standard file. - * - * @return void - */ - protected function printTitle(DOMNode $doc) - { - $title = $this->getTitle($doc); - $standard = $this->getStandard(); - - echo PHP_EOL; - echo str_repeat('-', (strlen("$standard CODING STANDARD: $title") + 4)); - echo strtoupper(PHP_EOL."| $standard CODING STANDARD: $title |".PHP_EOL); - echo str_repeat('-', (strlen("$standard CODING STANDARD: $title") + 4)); - echo PHP_EOL.PHP_EOL; - - }//end printTitle() - - - /** - * Print a text block found in a standard. - * - * @param DOMNode $node The DOMNode object for the text block. - * - * @return void - */ - protected function printTextBlock($node) - { - $text = trim($node->nodeValue); - $text = str_replace('', '*', $text); - $text = str_replace('', '*', $text); - - $lines = array(); - $tempLine = ''; - $words = explode(' ', $text); - - foreach ($words as $word) { - if (strlen($tempLine.$word) >= 99) { - if (strlen($tempLine.$word) === 99) { - // Adding the extra space will push us to the edge - // so we are done. - $lines[] = $tempLine.$word; - $tempLine = ''; - } else if (strlen($tempLine.$word) === 100) { - // We are already at the edge, so we are done. - $lines[] = $tempLine.$word; - $tempLine = ''; - } else { - $lines[] = rtrim($tempLine); - $tempLine = $word.' '; - } - } else { - $tempLine .= $word.' '; - } - }//end foreach - - if ($tempLine !== '') { - $lines[] = rtrim($tempLine); - } - - echo implode(PHP_EOL, $lines).PHP_EOL.PHP_EOL; - - }//end printTextBlock() - - - /** - * Print a code comparison block found in a standard. - * - * @param DOMNode $node The DOMNode object for the code comparison block. - * - * @return void - */ - protected function printCodeComparisonBlock($node) - { - $codeBlocks = $node->getElementsByTagName('code'); - $first = trim($codeBlocks->item(0)->nodeValue); - $firstTitle = $codeBlocks->item(0)->getAttribute('title'); - - $firstTitleLines = array(); - $tempTitle = ''; - $words = explode(' ', $firstTitle); - - foreach ($words as $word) { - if (strlen($tempTitle.$word) >= 45) { - if (strlen($tempTitle.$word) === 45) { - // Adding the extra space will push us to the edge - // so we are done. - $firstTitleLines[] = $tempTitle.$word; - $tempTitle = ''; - } else if (strlen($tempTitle.$word) === 46) { - // We are already at the edge, so we are done. - $firstTitleLines[] = $tempTitle.$word; - $tempTitle = ''; - } else { - $firstTitleLines[] = $tempTitle; - $tempTitle = $word; - } - } else { - $tempTitle .= $word.' '; - } - }//end foreach - - if ($tempTitle !== '') { - $firstTitleLines[] = $tempTitle; - } - - $first = str_replace('', '', $first); - $first = str_replace('', '', $first); - $firstLines = explode("\n", $first); - - $second = trim($codeBlocks->item(1)->nodeValue); - $secondTitle = $codeBlocks->item(1)->getAttribute('title'); - - $secondTitleLines = array(); - $tempTitle = ''; - $words = explode(' ', $secondTitle); - - foreach ($words as $word) { - if (strlen($tempTitle.$word) >= 45) { - if (strlen($tempTitle.$word) === 45) { - // Adding the extra space will push us to the edge - // so we are done. - $secondTitleLines[] = $tempTitle.$word; - $tempTitle = ''; - } else if (strlen($tempTitle.$word) === 46) { - // We are already at the edge, so we are done. - $secondTitleLines[] = $tempTitle.$word; - $tempTitle = ''; - } else { - $secondTitleLines[] = $tempTitle; - $tempTitle = $word; - } - } else { - $tempTitle .= $word.' '; - } - }//end foreach - - if ($tempTitle !== '') { - $secondTitleLines[] = $tempTitle; - } - - $second = str_replace('', '', $second); - $second = str_replace('', '', $second); - $secondLines = explode("\n", $second); - - $maxCodeLines = max(count($firstLines), count($secondLines)); - $maxTitleLines = max(count($firstTitleLines), count($secondTitleLines)); - - echo str_repeat('-', 41); - echo ' CODE COMPARISON '; - echo str_repeat('-', 42).PHP_EOL; - - for ($i = 0; $i < $maxTitleLines; $i++) { - if (isset($firstTitleLines[$i]) === true) { - $firstLineText = $firstTitleLines[$i]; - } else { - $firstLineText = ''; - } - - if (isset($secondTitleLines[$i]) === true) { - $secondLineText = $secondTitleLines[$i]; - } else { - $secondLineText = ''; - } - - echo '| '; - echo $firstLineText.str_repeat(' ', (46 - strlen($firstLineText))); - echo ' | '; - echo $secondLineText.str_repeat(' ', (47 - strlen($secondLineText))); - echo ' |'.PHP_EOL; - }//end for - - echo str_repeat('-', 100).PHP_EOL; - - for ($i = 0; $i < $maxCodeLines; $i++) { - if (isset($firstLines[$i]) === true) { - $firstLineText = $firstLines[$i]; - } else { - $firstLineText = ''; - } - - if (isset($secondLines[$i]) === true) { - $secondLineText = $secondLines[$i]; - } else { - $secondLineText = ''; - } - - echo '| '; - echo $firstLineText.str_repeat(' ', (47 - strlen($firstLineText))); - echo '| '; - echo $secondLineText.str_repeat(' ', (48 - strlen($secondLineText))); - echo '|'.PHP_EOL; - }//end for - - echo str_repeat('-', 100).PHP_EOL.PHP_EOL; - - }//end printCodeComparisonBlock() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Exception.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Exception.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Exception.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Exception.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * An exception thrown by PHP_CodeSniffer when it encounters an unrecoverable error. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PHP_CodeSniffer_Exception extends Exception -{ - -}//end class - -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/File.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/File.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/File.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/File.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,2769 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * A PHP_CodeSniffer_File object represents a PHP source file and the tokens - * associated with it. - * - * It provides a means for traversing the token stack, along with - * other token related operations. If a PHP_CodeSniffer_Sniff finds and error or - * warning within a PHP_CodeSniffer_File, you can raise an error using the - * addError() or addWarning() methods. - * - * Token Information - * - * Each token within the stack contains information about itself: - * - * - * array( - * 'code' => 301, // the token type code (see token_get_all()) - * 'content' => 'if', // the token content - * 'type' => 'T_IF', // the token name - * 'line' => 56, // the line number when the token is located - * 'column' => 12, // the column in the line where this token - * // starts (starts from 1) - * 'level' => 2 // the depth a token is within the scopes open - * 'conditions' => array( // a list of scope condition token - * // positions => codes that - * 2 => 50, // openened the scopes that this token exists - * 9 => 353, // in (see conditional tokens section below) - * ), - * ); - * - * - * Conditional Tokens - * - * In addition to the standard token fields, conditions contain information to - * determine where their scope begins and ends: - * - * - * array( - * 'scope_condition' => 38, // the token position of the condition - * 'scope_opener' => 41, // the token position that started the scope - * 'scope_closer' => 70, // the token position that ended the scope - * ); - * - * - * The condition, the scope opener and the scope closer each contain this - * information. - * - * Parenthesis Tokens - * - * Each parenthesis token (T_OPEN_PARENTHESIS and T_CLOSE_PARENTHESIS) has a - * reference to their opening and closing parenthesis, one being itself, the - * other being its oposite. - * - * - * array( - * 'parenthesis_opener' => 34, - * 'parenthesis_closer' => 40, - * ); - * - * - * Some tokens can "own" a set of parethesis. For example a T_FUNCTION token - * has parenthesis around its argument list. These tokens also have the - * parenthesis_opener and and parenthesis_closer indicies. Not all parethesis - * have owners, for example parenthesis used for arithmetic operations and - * function calls. The parenthesis tokens that have an owner have the following - * auxilery array indicies. - * - * - * array( - * 'parenthesis_opener' => 34, - * 'parenthesis_closer' => 40, - * 'parenthesis_owner' => 33, - * ); - * - * - * Each token within a set of parenthesis also has an array indicy - * 'nested_parenthesis' which is an array of the - * left parenthesis => right parenthesis token positions. - * - * - * 'nested_parentheisis' => array( - * 12 => 15 - * 11 => 14 - * ); - * - * - * Extended Tokens - * - * PHP_CodeSniffer extends and augments some of the tokens created by - * token_get_all(). A full list of these tokens can be seen in the - * Tokens.php file. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PHP_CodeSniffer_File -{ - - /** - * The absolute path to the file associated with this object. - * - * @var string - */ - private $_file = ''; - - /** - * The EOL character this file uses. - * - * @var string - */ - public $eolChar = ''; - - /** - * The PHP_CodeSniffer object controlling this run. - * - * @var PHP_CodeSniffer - */ - public $phpcs = null; - - /** - * The tokenizer being used for this file. - * - * @var object - */ - public $tokenizer = null; - - /** - * The tokenizer being used for this file. - * - * @var string - */ - public $tokenizerType = 'PHP'; - - /** - * The number of tokens in this file. - * - * Stored here to save calling count() everywhere. - * - * @var int - */ - public $numTokens = 0; - - /** - * The tokens stack map. - * - * Note that the tokens in this array differ in format to the tokens - * produced by token_get_all(). Tokens are initially produced with - * token_get_all(), then augmented so that it's easier to process them. - * - * @var array() - * @see Tokens.php - */ - private $_tokens = array(); - - /** - * The errors raised from PHP_CodeSniffer_Sniffs. - * - * @var array() - * @see getErrors() - */ - private $_errors = array(); - - /** - * The warnings raised form PHP_CodeSniffer_Sniffs. - * - * @var array() - * @see getWarnings() - */ - private $_warnings = array(); - - /** - * And array of lines being ignored by PHP_CodeSniffer. - * - * @var array() - */ - private $_ignoredLines = array(); - - /** - * The total number of errors raised. - * - * @var int - */ - private $_errorCount = 0; - - /** - * The total number of warnings raised. - * - * @var int - */ - private $_warningCount = 0; - - /** - * An array of sniffs listening to this file's processing. - * - * @var array(PHP_CodeSniffer_Sniff) - */ - private $_listeners = array(); - - /** - * The class name of the sniff currently processing the file. - * - * @var string - */ - private $_activeListener = ''; - - /** - * An array of sniffs being processed and how long they took. - * - * @var array() - */ - private $_listenerTimes = array(); - - /** - * An array of extensions mapping to the tokenizer to use. - * - * This value gets set by PHP_CodeSniffer when the object is created. - * - * @var array - */ - protected $tokenizers = array(); - - /** - * An array of rules from the ruleset.xml file. - * - * This value gets set by PHP_CodeSniffer when the object is created. - * It may be empty, indicating that the ruleset does not override - * any of the default sniff settings. - * - * @var array - */ - protected $ruleset = array(); - - - /** - * Constructs a PHP_CodeSniffer_File. - * - * @param string $file The absolute path to the file to process. - * @param array(string) $listeners The initial listeners listening - * to processing of this file. - * @param array $tokenizers An array of extensions mapping - * to the tokenizer to use. - * @param array $ruleset An array of rules from the - * ruleset.xml file. - * @param PHP_CodeSniffer $phpcs The PHP_CodeSniffer object controlling - * this run. - * - * @throws PHP_CodeSniffer_Exception If the register() method does - * not return an array. - */ - public function __construct( - $file, - array $listeners, - array $tokenizers, - array $ruleset, - PHP_CodeSniffer $phpcs - ) { - $this->_file = trim($file); - $this->_listeners = $listeners; - $this->tokenizers = $tokenizers; - $this->ruleset = $ruleset; - $this->phpcs = $phpcs; - - }//end __construct() - - - /** - * Sets the name of the currently active sniff. - * - * @param string $activeListener The class name of the current sniff. - * - * @return void - */ - public function setActiveListener($activeListener) - { - $this->_activeListener = $activeListener; - - }//end setActiveListener() - - - /** - * Adds a listener to the token stack that listens to the specific tokens. - * - * When PHP_CodeSniffer encounters on the the tokens specified in $tokens, it - * invokes the process method of the sniff. - * - * @param PHP_CodeSniffer_Sniff $listener The listener to add to the - * listener stack. - * @param array(int) $tokens The token types the listener wishes to - * listen to. - * - * @return void - */ - public function addTokenListener(PHP_CodeSniffer_Sniff $listener, array $tokens) - { - foreach ($tokens as $token) { - if (isset($this->_listeners[$token]) === false) { - $this->_listeners[$token] = array(); - } - - if (in_array($listener, $this->_listeners[$token], true) === false) { - $this->_listeners[$token][] = $listener; - } - } - - }//end addTokenListener() - - - /** - * Removes a listener from listening from the specified tokens. - * - * @param PHP_CodeSniffer_Sniff $listener The listener to remove from the - * listener stack. - * @param array(int) $tokens The token types the listener wishes to - * stop listen to. - * - * @return void - */ - public function removeTokenListener( - PHP_CodeSniffer_Sniff $listener, - array $tokens - ) { - foreach ($tokens as $token) { - if (isset($this->_listeners[$token]) === false) { - continue; - } - - if (in_array($listener, $this->_listeners[$token]) === true) { - foreach ($this->_listeners[$token] as $pos => $value) { - if ($value === $listener) { - unset($this->_listeners[$token][$pos]); - } - } - } - } - - }//end removeTokenListener() - - - /** - * Returns the token stack for this file. - * - * @return array() - */ - public function getTokens() - { - return $this->_tokens; - - }//end getTokens() - - - /** - * Starts the stack traversal and tells listeners when tokens are found. - * - * @param string $contents The contents to parse. If NULL, the content - * is taken from the file system. - * - * @return void - */ - public function start($contents=null) - { - $this->_parse($contents); - - if (PHP_CODESNIFFER_VERBOSITY > 2) { - echo "\t*** START TOKEN PROCESSING ***".PHP_EOL; - } - - $foundCode = false; - $ignoring = false; - - // Foreach of the listeners that have registered to listen for this - // token, get them to process it. - foreach ($this->_tokens as $stackPtr => $token) { - // Check for ignored lines. - if ($token['code'] === T_COMMENT) { - if (strpos($token['content'], '@codingStandardsIgnoreStart') !== false) { - $ignoring = true; - } else if (strpos($token['content'], '@codingStandardsIgnoreEnd') !== false) { - $ignoring = false; - // Ignore this comment too. - $this->_ignoredLines[$token['line']] = true; - } else if (strpos($token['content'], '@codingStandardsIgnoreFile') !== false) { - // Ignoring the whole file, just a little late. - $this->_errors = array(); - $this->_warnings = array(); - $this->_errorCount = 0; - $this->_warningCount = 0; - return; - } - } - - if ($ignoring === true) { - $this->_ignoredLines[$token['line']] = true; - continue; - } - - if (PHP_CODESNIFFER_VERBOSITY > 2) { - $type = $token['type']; - $content = str_replace($this->eolChar, '\n', $token['content']); - echo "\t\tProcess token $stackPtr: $type => $content".PHP_EOL; - } - - $tokenType = $token['code']; - if ($tokenType !== T_INLINE_HTML) { - $foundCode = true; - } - - if (isset($this->_listeners[$tokenType]) === true) { - foreach ($this->_listeners[$tokenType] as $listener) { - // Make sure this sniff supports the tokenizer - // we are currently using. - $class = get_class($listener); - $vars = get_class_vars($class); - if (isset($vars['supportedTokenizers']) === true) { - if (in_array($this->tokenizerType, $vars['supportedTokenizers']) === false) { - continue; - } - } else { - // The default supported tokenizer is PHP. - if ($this->tokenizerType !== 'PHP') { - continue; - } - } - - // If the file path matches one of our ignore patterns, skip it. - $parts = explode('_', $class); - if (isset($parts[3]) === true) { - $source = $parts[0].'.'.$parts[2].'.'.substr($parts[3], 0, -5); - $patterns = $this->phpcs->getIgnorePatterns($source); - foreach ($patterns as $pattern) { - $replacements = array( - '\\,' => ',', - '*' => '.*', - ); - - $pattern = strtr($pattern, $replacements); - if (preg_match("|{$pattern}|i", $this->_file) === 1) { - continue(2); - } - } - } - - $this->setActiveListener($class); - - if (PHP_CODESNIFFER_VERBOSITY > 2) { - $startTime = microtime(true); - echo "\t\t\tProcessing ".$this->_activeListener.'... '; - } - - $listener->process($this, $stackPtr); - - if (PHP_CODESNIFFER_VERBOSITY > 2) { - $timeTaken = (microtime(true) - $startTime); - if (isset($this->_listenerTimes[$this->_activeListener]) === false) { - $this->_listenerTimes[$this->_activeListener] = 0; - } - - $this->_listenerTimes[$this->_activeListener] += $timeTaken; - - $timeTaken = round(($timeTaken), 4); - echo "DONE in $timeTaken seconds".PHP_EOL; - } - - $this->_activeListener = ''; - }//end foreach - }//end if - }//end foreach - - // Remove errors and warnings for ignored lines. - foreach ($this->_ignoredLines as $line => $ignore) { - if (isset($this->_errors[$line]) === true) { - foreach ($this->_errors[$line] as $col => $errors) { - $this->_errorCount -= count($errors); - } - - unset($this->_errors[$line]); - } - - if (isset($this->_warnings[$line]) === true) { - foreach ($this->_warnings[$line] as $col => $warnings) { - $this->_warningCount -= count($warnings); - } - - unset($this->_warnings[$line]); - } - } - - // If short open tags are off but the file being checked uses - // short open tags, the whole content will be inline HTML - // and nothing will be checked. So try and handle this case. - if ($foundCode === false) { - $shortTags = (bool) ini_get('short_open_tag'); - if ($shortTags === false) { - $error = 'No PHP code was found in this file and short open tags are not allowed by this install of PHP. This file may be using short open tags but PHP does not allow them.'; - $this->addWarning($error, null, 'Internal.NoCodeFound'); - } - } - - if (PHP_CODESNIFFER_VERBOSITY > 2) { - echo "\t*** END TOKEN PROCESSING ***".PHP_EOL; - } - - if (PHP_CODESNIFFER_VERBOSITY > 2) { - echo "\t*** START SNIFF PROCESSING REPORT ***".PHP_EOL; - - asort($this->_listenerTimes, SORT_NUMERIC); - $this->_listenerTimes = array_reverse($this->_listenerTimes, true); - foreach ($this->_listenerTimes as $listener => $timeTaken) { - echo "\t$listener: ".round(($timeTaken), 4).' secs'.PHP_EOL; - } - - echo "\t*** END SNIFF PROCESSING REPORT ***".PHP_EOL; - } - - }//end start() - - - /** - * Remove vars stored in this sniff that are no longer required. - * - * @return void - */ - public function cleanUp() - { - $this->_tokens = null; - $this->_listeners = null; - - }//end cleanUp() - - - /** - * Tokenizes the file and preapres it for the test run. - * - * @param string $contents The contents to parse. If NULL, the content - * is taken from the file system. - * - * @return void - */ - private function _parse($contents=null) - { - try { - $this->eolChar = self::detectLineEndings($this->_file, $contents); - } catch (PHP_CodeSniffer_Exception $e) { - $this->addWarning($e->getMessage(), null, 'Internal.DetectLineEndings'); - return; - } - - // Determine the tokenizer from the file extension. - $fileParts = explode('.', $this->_file); - $extension = array_pop($fileParts); - if (isset($this->tokenizers[$extension]) === true) { - $tokenizerClass = 'PHP_CodeSniffer_Tokenizers_'.$this->tokenizers[$extension]; - $this->tokenizerType = $this->tokenizers[$extension]; - } else { - // Revert to default. - $tokenizerClass = 'PHP_CodeSniffer_Tokenizers_'.$this->tokenizerType; - } - - $tokenizer = new $tokenizerClass(); - $this->tokenizer = $tokenizer; - - if ($contents === null) { - $contents = file_get_contents($this->_file); - } - - $this->_tokens = self::tokenizeString($contents, $tokenizer, $this->eolChar); - $this->numTokens = count($this->_tokens); - - if (PHP_CODESNIFFER_VERBOSITY > 0) { - if ($this->numTokens === 0) { - $numLines = 0; - } else { - $numLines = $this->_tokens[($this->numTokens - 1)]['line']; - } - - echo "[$this->numTokens tokens in $numLines lines]... "; - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo PHP_EOL; - } - } - - }//end _parse() - - - /** - * Opens a file and detects the EOL character being used. - * - * @param string $file The full path to the file. - * @param string $contents The contents to parse. If NULL, the content - * is taken from the file system. - * - * @return string - * @throws PHP_CodeSniffer_Exception If $file could not be opened. - */ - public static function detectLineEndings($file, $contents=null) - { - if ($contents === null) { - // Determine the newline character being used in this file. - // Will be either \r, \r\n or \n. - if (is_readable($file) === false) { - $error = 'Error opening file; file no longer exists or you do not have access to read the file'; - throw new PHP_CodeSniffer_Exception($error); - } else { - $handle = fopen($file, 'r'); - if ($handle === false) { - $error = 'Error opening file; could not auto-detect line endings'; - throw new PHP_CodeSniffer_Exception($error); - } - } - - $firstLine = fgets($handle); - fclose($handle); - - $eolChar = substr($firstLine, -1); - if ($eolChar === "\n") { - $secondLastChar = substr($firstLine, -2, 1); - if ($secondLastChar === "\r") { - $eolChar = "\r\n"; - } - } else if ($eolChar !== "\r") { - // Must not be an EOL char at the end of the line. - // Probably a one-line file, so assume \n as it really - // doesn't matter considering there are no newlines. - $eolChar = "\n"; - } - } else { - if (preg_match("/\r\n?|\n/", $contents, $matches) !== 1) { - // Assuming there are no newlines. - $eolChar = "\n"; - } else { - $eolChar = $matches[0]; - } - }//end if - - return $eolChar; - - }//end detectLineEndings() - - - /** - * Adds an error to the error stack. - * - * @param string $error The error message. - * @param int $stackPtr The stack position where the error occured. - * @param string $code A violation code unique to the sniff message. - * @param array $data Replacements for the error message. - * @param int $severity The severity level for this error. A value of - * will be converted into the default severity level. - * - * @return void - */ - public function addError($error, $stackPtr, $code='', $data=array(), $severity=0) - { - // Don't bother doing any processing if errors are just going to - // be hidden in the reports anyway. - if ($this->phpcs->cli->errorSeverity === 0) { - return; - } - - // Work out which sniff generated the error. - if (substr($code, 0, 9) === 'Internal.') { - // Any internal message. - $sniff = $code; - } else { - $parts = explode('_', $this->_activeListener); - if (isset($parts[3]) === true) { - $sniff = $parts[0].'.'.$parts[2].'.'.$parts[3]; - - // Remove "Sniff" from the end. - $sniff = substr($sniff, 0, -5); - } else { - $sniff = 'unknownSniff'; - } - - if ($code !== '') { - $sniff .= '.'.$code; - } - } - - // Make sure we are interested in this severity level. - if (isset($this->ruleset[$sniff]['severity']) === true) { - $severity = $this->ruleset[$sniff]['severity']; - } else if ($severity === 0) { - $severity = PHPCS_DEFAULT_ERROR_SEV; - } - - if ($this->phpcs->cli->errorSeverity > $severity) { - return; - } - - // Make sure we are not ignoring this file. - $patterns = $this->phpcs->getIgnorePatterns($sniff); - foreach ($patterns as $pattern) { - $replacements = array( - '\\,' => ',', - '*' => '.*', - ); - - $pattern = strtr($pattern, $replacements); - if (preg_match("|{$pattern}|i", $this->_file) === 1) { - return; - } - } - - // Work out the warning message. - if (isset($this->ruleset[$sniff]['message']) === true) { - $error = $this->ruleset[$sniff]['message']; - } - - if (empty($data) === true) { - $message = $error; - } else { - $message = vsprintf($error, $data); - } - - if ($stackPtr === null) { - $lineNum = 1; - $column = 1; - } else { - $lineNum = $this->_tokens[$stackPtr]['line']; - $column = $this->_tokens[$stackPtr]['column']; - } - - if (isset($this->_errors[$lineNum]) === false) { - $this->_errors[$lineNum] = array(); - } - - if (isset($this->_errors[$lineNum][$column]) === false) { - $this->_errors[$lineNum][$column] = array(); - } - - $this->_errors[$lineNum][$column][] = array( - 'message' => $message, - 'source' => $sniff, - 'severity' => $severity, - ); - $this->_errorCount++; - - }//end addError() - - - /** - * Adds an warning to the warning stack. - * - * @param string $warning The error message. - * @param int $stackPtr The stack position where the error occured. - * @param string $code A violation code unique to the sniff message. - * @param array $data Replacements for the warning message. - * @param int $severity The severity level for this warning. A value of - * will be converted into the default severity level. - * - * @return void - */ - public function addWarning($warning, $stackPtr, $code='', $data=array(), $severity=0) - { - // Don't bother doing any processing if warnings are just going to - // be hidden in the reports anyway. - if ($this->phpcs->cli->warningSeverity === 0) { - return; - } - - // Work out which sniff generated the warning. - if (substr($code, 0, 9) === 'Internal.') { - // Any internal message. - $sniff = $code; - } else { - $parts = explode('_', $this->_activeListener); - if (isset($parts[3]) === true) { - $sniff = $parts[0].'.'.$parts[2].'.'.$parts[3]; - - // Remove "Sniff" from the end. - $sniff = substr($sniff, 0, -5); - } else { - $sniff = 'unknownSniff'; - } - - if ($code !== '') { - $sniff .= '.'.$code; - } - } - - // Make sure we are interested in this severity level. - if (isset($this->ruleset[$sniff]['severity']) === true) { - $severity = $this->ruleset[$sniff]['severity']; - } else if ($severity === 0) { - $severity = PHPCS_DEFAULT_WARN_SEV; - } - - if ($this->phpcs->cli->warningSeverity > $severity) { - return; - } - - // Make sure we are not ignoring this file. - $patterns = $this->phpcs->getIgnorePatterns($sniff); - foreach ($patterns as $pattern) { - $replacements = array( - '\\,' => ',', - '*' => '.*', - ); - - $pattern = strtr($pattern, $replacements); - if (preg_match("|{$pattern}|i", $this->_file) === 1) { - return; - } - } - - // Work out the warning message. - if (isset($this->ruleset[$sniff]['message']) === true) { - $warning = $this->ruleset[$sniff]['message']; - } - - if (empty($data) === true) { - $message = $warning; - } else { - $message = vsprintf($warning, $data); - } - - if ($stackPtr === null) { - $lineNum = 1; - $column = 1; - } else { - $lineNum = $this->_tokens[$stackPtr]['line']; - $column = $this->_tokens[$stackPtr]['column']; - } - - if (isset($this->_warnings[$lineNum]) === false) { - $this->_warnings[$lineNum] = array(); - } - - if (isset($this->_warnings[$lineNum][$column]) === false) { - $this->_warnings[$lineNum][$column] = array(); - } - - $this->_warnings[$lineNum][$column][] = array( - 'message' => $message, - 'source' => $sniff, - 'severity' => $severity, - ); - $this->_warningCount++; - - }//end addWarning() - - - /** - * Returns the number of errors raised. - * - * @return int - */ - public function getErrorCount() - { - return $this->_errorCount; - - }//end getErrorCount() - - - /** - * Returns the number of warnings raised. - * - * @return int - */ - public function getWarningCount() - { - return $this->_warningCount; - - }//end getWarningCount() - - - /** - * Returns the list of ignored lines. - * - * @return array - */ - public function getIgnoredLines() - { - return $this->_ignoredLines; - - }//end getIgnoredLines() - - - /** - * Returns the errors raised from processing this file. - * - * @return array - */ - public function getErrors() - { - return $this->_errors; - - }//end getErrors() - - - /** - * Returns the warnings raised from processing this file. - * - * @return array - */ - public function getWarnings() - { - return $this->_warnings; - - }//end getWarnings() - - - /** - * Returns the absolute filename of this file. - * - * @return string - */ - public function getFilename() - { - return $this->_file; - - }//end getFilename() - - - /** - * Creates an array of tokens when given some PHP code. - * - * Starts by using token_get_all() but does a lot of extra processing - * to insert information about the context of the token. - * - * @param string $string The string to tokenize. - * @param object $tokenizer A tokenizer class to use to tokenize the string. - * @param string $eolChar The EOL character to use for splitting strings. - * - * @return array - */ - public static function tokenizeString($string, $tokenizer, $eolChar='\n') - { - $tokens = $tokenizer->tokenizeString($string, $eolChar); - - self::_createLineMap($tokens, $tokenizer, $eolChar); - self::_createBracketMap($tokens, $tokenizer, $eolChar); - self::_createParenthesisMap($tokens, $tokenizer, $eolChar); - self::_createParenthesisNestingMap($tokens, $tokenizer, $eolChar); - self::_createScopeMap($tokens, $tokenizer, $eolChar); - - // If we know the width of each tab, convert tabs - // into spaces so sniffs can use one method of checking. - if (PHP_CODESNIFFER_TAB_WIDTH > 0) { - self::_convertTabs($tokens, $tokenizer, $eolChar); - } - - // Column map requires the line map to be complete. - self::_createColumnMap($tokens, $tokenizer, $eolChar); - self::_createLevelMap($tokens, $tokenizer, $eolChar); - - // Allow the tokenizer to do additional processing if required. - $tokenizer->processAdditional($tokens, $eolChar); - - return $tokens; - - }//end tokenizeString() - - - /** - * Creates a map of tokens => line numbers for each token. - * - * @param array &$tokens The array of tokens to process. - * @param object $tokenizer The tokenizer being used to process this file. - * @param string $eolChar The EOL character to use for splitting strings. - * - * @return void - */ - private static function _createLineMap(&$tokens, $tokenizer, $eolChar) - { - $lineNumber = 1; - $count = count($tokens); - - for ($i = 0; $i < $count; $i++) { - $tokens[$i]['line'] = $lineNumber; - if ($tokens[$i]['content'] === '') { - continue; - } - - $lineNumber += substr_count($tokens[$i]['content'], $eolChar); - } - - }//end _createLineMap() - - - /** - * Converts tabs into spaces. - * - * Each tab can represent between 1 and $width spaces, so - * this cannot be a straight string replace. - * - * @param array &$tokens The array of tokens to process. - * @param object $tokenizer The tokenizer being used to process this file. - * @param string $eolChar The EOL character to use for splitting strings. - * - * @return void - */ - private static function _convertTabs(&$tokens, $tokenizer, $eolChar) - { - $currColumn = 1; - $count = count($tokens); - - for ($i = 0; $i < $count; $i++) { - $tokenContent = $tokens[$i]['content']; - - if (strpos($tokenContent, "\t") === false) { - // There are no tabs in this content. - $currColumn += (strlen($tokenContent) - 1); - } else { - // We need to determine the length of each tab. - $tabs = preg_split( - "|(\t)|", - $tokenContent, - -1, - PREG_SPLIT_DELIM_CAPTURE - ); - - $tabNum = 0; - $adjustedTab = false; - $tabsToSpaces = array(); - $newContent = ''; - - foreach ($tabs as $content) { - if ($content === '') { - continue; - } - - if (strpos($content, "\t") === false) { - // This piece of content is not a tab. - $currColumn += strlen($content); - $newContent .= $content; - } else { - $lastCurrColumn = $currColumn; - $tabNum++; - - // Move the pointer to the next tab stop. - if (($currColumn % PHP_CODESNIFFER_TAB_WIDTH) === 0) { - // This is the first tab, and we are already at a - // tab stop, so this tab counts as a single space. - $currColumn++; - $adjustedTab = true; - } else { - $currColumn++; - while (($currColumn % PHP_CODESNIFFER_TAB_WIDTH) != 0) { - $currColumn++; - } - - $currColumn++; - } - - $length = ($currColumn - $lastCurrColumn); - $newContent .= str_repeat(' ', $length); - }//end if - }//end foreach - - if ($tabNum === 1 && $adjustedTab === true) { - $currColumn--; - } - - $tokens[$i]['content'] = $newContent; - }//end if - - if (isset($tokens[($i + 1)]['line']) === true - && $tokens[($i + 1)]['line'] !== $tokens[$i]['line'] - ) { - $currColumn = 1; - } else { - $currColumn++; - } - }//end for - - }//end _convertTabs() - - - /** - * Creates a column map. - * - * The column map indicates where the token started on the line where it - * exists. - * - * @param array &$tokens The array of tokens to process. - * @param object $tokenizer The tokenizer being used to process this file. - * @param string $eolChar The EOL character to use for splitting strings. - * - * @return void - */ - private static function _createColumnMap(&$tokens, $tokenizer, $eolChar) - { - $currColumn = 1; - $count = count($tokens); - - for ($i = 0; $i < $count; $i++) { - $tokens[$i]['column'] = $currColumn; - if (isset($tokens[($i + 1)]['line']) === true - && $tokens[($i + 1)]['line'] !== $tokens[$i]['line'] - ) { - $currColumn = 1; - } else { - $currColumn += strlen($tokens[$i]['content']); - } - } - - }//end _createColumnMap() - - - /** - * Creates a map for opening and closing of square brackets. - * - * Each bracket token (T_OPEN_SQUARE_BRACKET and T_CLOSE_SQUARE_BRACKET) - * has a reference to their opening and closing bracket - * (bracket_opener and bracket_closer). - * - * @param array &$tokens The array of tokens to process. - * @param object $tokenizer The tokenizer being used to process this file. - * @param string $eolChar The EOL character to use for splitting strings. - * - * @return void - */ - private static function _createBracketMap(&$tokens, $tokenizer, $eolChar) - { - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t*** START BRACKET MAP ***".PHP_EOL; - } - - $squareOpeners = array(); - $curlyOpeners = array(); - $numTokens = count($tokens); - - for ($i = 0; $i < $numTokens; $i++) { - switch ($tokens[$i]['code']) { - case T_OPEN_SQUARE_BRACKET: - $squareOpeners[] = $i; - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo str_repeat("\t", count($squareOpeners)); - echo str_repeat("\t", count($curlyOpeners)); - echo "=> Found square bracket opener at $i".PHP_EOL; - } - - break; - case T_OPEN_CURLY_BRACKET: - if (isset($tokens[$i]['scope_closer']) === false) { - $curlyOpeners[] = $i; - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo str_repeat("\t", count($squareOpeners)); - echo str_repeat("\t", count($curlyOpeners)); - echo "=> Found curly bracket opener at $i".PHP_EOL; - } - } - break; - case T_CLOSE_SQUARE_BRACKET: - if (empty($squareOpeners) === false) { - $opener = array_pop($squareOpeners); - $tokens[$i]['bracket_opener'] = $opener; - $tokens[$i]['bracket_closer'] = $i; - $tokens[$opener]['bracket_opener'] = $opener; - $tokens[$opener]['bracket_closer'] = $i; - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo str_repeat("\t", count($squareOpeners)); - echo str_repeat("\t", count($curlyOpeners)); - echo "\t=> Found square bracket closer at $i for $opener".PHP_EOL; - } - } - break; - case T_CLOSE_CURLY_BRACKET: - if (empty($curlyOpeners) === false - && isset($tokens[$i]['scope_opener']) === false - ) { - $opener = array_pop($curlyOpeners); - $tokens[$i]['bracket_opener'] = $opener; - $tokens[$i]['bracket_closer'] = $i; - $tokens[$opener]['bracket_opener'] = $opener; - $tokens[$opener]['bracket_closer'] = $i; - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo str_repeat("\t", count($squareOpeners)); - echo str_repeat("\t", count($curlyOpeners)); - echo "\t=> Found curly bracket closer at $i for $opener".PHP_EOL; - } - } - break; - default: - continue; - }//end switch - }//end for - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t*** END BRACKET MAP ***".PHP_EOL; - } - - }//end _createBracketMap() - - - /** - * Creates a map for opening and closing of parenthesis. - * - * Each parenthesis token (T_OPEN_PARENTHESIS and T_CLOSE_PARENTHESIS) has a - * reference to their opening and closing parenthesis (parenthesis_opener - * and parenthesis_closer). - * - * @param array &$tokens The array of tokens to process. - * @param object $tokenizer The tokenizer being used to process this file. - * @param string $eolChar The EOL character to use for splitting strings. - * - * @return void - */ - private static function _createParenthesisMap(&$tokens, $tokenizer, $eolChar) - { - $openers = array(); - $numTokens = count($tokens); - $openOwner = null; - - for ($i = 0; $i < $numTokens; $i++) { - if (in_array($tokens[$i]['code'], PHP_CodeSniffer_Tokens::$parenthesisOpeners) === true) { - $tokens[$i]['parenthesis_opener'] = null; - $tokens[$i]['parenthesis_closer'] = null; - $tokens[$i]['parenthesis_owner'] = $i; - $openOwner = $i; - } else if ($tokens[$i]['code'] === T_OPEN_PARENTHESIS) { - $openers[] = $i; - $tokens[$i]['parenthesis_opener'] = $i; - if ($openOwner !== null) { - $tokens[$openOwner]['parenthesis_opener'] = $i; - $tokens[$i]['parenthesis_owner'] = $openOwner; - $openOwner = null; - } - } else if ($tokens[$i]['code'] === T_CLOSE_PARENTHESIS) { - // Did we set an owner for this set of parenthesis? - $numOpeners = count($openers); - if ($numOpeners !== 0) { - $opener = array_pop($openers); - if (isset($tokens[$opener]['parenthesis_owner']) === true) { - $owner = $tokens[$opener]['parenthesis_owner']; - - $tokens[$owner]['parenthesis_closer'] = $i; - $tokens[$i]['parenthesis_owner'] = $owner; - } - - $tokens[$i]['parenthesis_opener'] = $opener; - $tokens[$i]['parenthesis_closer'] = $i; - $tokens[$opener]['parenthesis_closer'] = $i; - } - }//end if - }//end for - - }//end _createParenthesisMap() - - - /** - * Creates a map for the parenthesis tokens that surround other tokens. - * - * @param array &$tokens The array of tokens to process. - * @param object $tokenizer The tokenizer being used to process this file. - * @param string $eolChar The EOL character to use for splitting strings. - * - * @return void - */ - private static function _createParenthesisNestingMap( - &$tokens, - $tokenizer, - $eolChar - ) { - $numTokens = count($tokens); - $map = array(); - for ($i = 0; $i < $numTokens; $i++) { - if (isset($tokens[$i]['parenthesis_opener']) === true - && $i === $tokens[$i]['parenthesis_opener'] - ) { - if (empty($map) === false) { - $tokens[$i]['nested_parenthesis'] = $map; - } - - if (isset($tokens[$i]['parenthesis_closer']) === true) { - $map[$tokens[$i]['parenthesis_opener']] - = $tokens[$i]['parenthesis_closer']; - } - } else if (isset($tokens[$i]['parenthesis_closer']) === true - && $i === $tokens[$i]['parenthesis_closer'] - ) { - array_pop($map); - if (empty($map) === false) { - $tokens[$i]['nested_parenthesis'] = $map; - } - } else { - if (empty($map) === false) { - $tokens[$i]['nested_parenthesis'] = $map; - } - }//end if - }//end for - - }//end _createParenthesisNestingMap() - - - /** - * Creates a scope map of tokens that open scopes. - * - * @param array &$tokens The array of tokens to process. - * @param object $tokenizer The tokenizer being used to process this file. - * @param string $eolChar The EOL character to use for splitting strings. - * - * @return void - * @see _recurseScopeMap() - */ - private static function _createScopeMap(&$tokens, $tokenizer, $eolChar) - { - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t*** START SCOPE MAP ***".PHP_EOL; - } - - $numTokens = count($tokens); - for ($i = 0; $i < $numTokens; $i++) { - // Check to see if the current token starts a new scope. - if (isset($tokenizer->scopeOpeners[$tokens[$i]['code']]) === true) { - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $type = $tokens[$i]['type']; - $content = str_replace($eolChar, '\n', $tokens[$i]['content']); - echo "\tStart scope map at $i: $type => $content".PHP_EOL; - } - - $i = self::_recurseScopeMap( - $tokens, - $numTokens, - $tokenizer, - $eolChar, - $i - ); - } - }//end for - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t*** END SCOPE MAP ***".PHP_EOL; - } - - }//end _createScopeMap() - - - /** - * Recurses though the scope openers to build a scope map. - * - * @param array &$tokens The array of tokens to process. - * @param int $numTokens The size of the tokens array. - * @param object $tokenizer The tokenizer being used to process this file. - * @param string $eolChar The EOL character to use for splitting strings. - * @param int $stackPtr The position in the stack of the token that - * opened the scope (eg. an IF token or FOR token). - * @param int $depth How many scope levels down we are. - * @param int &$ignore How many curly braces we are ignoring. - * - * @return int The position in the stack that closed the scope. - */ - private static function _recurseScopeMap( - &$tokens, - $numTokens, - $tokenizer, - $eolChar, - $stackPtr, - $depth=1, - &$ignore=0 - ) { - $opener = null; - $currType = $tokens[$stackPtr]['code']; - $startLine = $tokens[$stackPtr]['line']; - - // We will need this to restore the value if we end up - // returning a token ID that causes our calling function to go back - // over already ignored braces. - $originalIgnore = $ignore; - - // If the start token for this scope opener is the same as - // the scope token, we have already found our opener. - if (in_array($currType, $tokenizer->scopeOpeners[$currType]['start']) === true) { - $opener = $stackPtr; - } - - for ($i = ($stackPtr + 1); $i < $numTokens; $i++) { - $tokenType = $tokens[$i]['code']; - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $type = $tokens[$i]['type']; - $content = str_replace($eolChar, '\n', $tokens[$i]['content']); - echo str_repeat("\t", $depth); - echo "Process token $i ["; - if ($opener !== null) { - echo "opener:$opener;"; - } - - if ($ignore > 0) { - echo "ignore=$ignore;"; - } - - echo "]: $type => $content".PHP_EOL; - } - - // Is this an opening condition ? - if (isset($tokenizer->scopeOpeners[$tokenType]) === true) { - if ($opener === null) { - // Found another opening condition but still haven't - // found our opener, so we are never going to find one. - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $type = $tokens[$stackPtr]['type']; - echo str_repeat("\t", $depth); - echo "=> Couldn't find scope opener for $stackPtr ($type), bailing".PHP_EOL; - } - - return $stackPtr; - } - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo str_repeat("\t", $depth); - echo '* token is an opening condition *'.PHP_EOL; - } - - $isShared - = ($tokenizer->scopeOpeners[$tokenType]['shared'] === true); - - if (isset($tokens[$i]['scope_condition']) === true) { - // We've been here before. - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo str_repeat("\t", $depth); - echo '* already processed, skipping *'.PHP_EOL; - } - - if ($isShared === false - && isset($tokens[$i]['scope_closer']) === true - ) { - $i = $tokens[$i]['scope_closer']; - } - - continue; - } else if ($currType === $tokenType - && $isShared === false - && $opener === null - ) { - // We haven't yet found our opener, but we have found another - // scope opener which is the same type as us, and we don't - // share openers, so we will never find one. - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo str_repeat("\t", $depth); - echo '* it was another token\'s opener, bailing *'.PHP_EOL; - } - - return $stackPtr; - } else { - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo str_repeat("\t", $depth); - echo '* searching for opener *'.PHP_EOL; - } - - if (in_array(T_CLOSE_CURLY_BRACKET, $tokenizer->scopeOpeners[$tokenType]['end']) === true) { - $oldIgnore = $ignore; - $ignore = 0; - } - - $i = self::_recurseScopeMap( - $tokens, - $numTokens, - $tokenizer, - $eolChar, - $i, - ($depth + 1), - $ignore - ); - - if (in_array(T_CLOSE_CURLY_BRACKET, $tokenizer->scopeOpeners[$tokenType]['end']) === true) { - $ignore = $oldIgnore; - } - }//end if - }//end if - - if (in_array($tokenType, $tokenizer->scopeOpeners[$currType]['start']) === true - && $opener === null - ) { - if ($tokenType === T_OPEN_CURLY_BRACKET) { - // Make sure this is actually an opener and not a - // string offset (e.g., $var{0}). - for ($x = ($i - 1); $x > 0; $x--) { - if (in_array($tokens[$x]['code'], PHP_CodeSniffer_Tokens::$emptyTokens) === true) { - continue; - } else { - // If the first non-whitespace/comment token is a - // variable or object operator then this is an opener - // for a string offset and not a scope. - if ($tokens[$x]['code'] === T_VARIABLE - || $tokens[$x]['code'] === T_OBJECT_OPERATOR - ) { - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo str_repeat("\t", $depth); - echo '* ignoring curly brace *'.PHP_EOL; - } - - $ignore++; - }//end if - - break; - }//end if - }//end for - }//end if - - if ($ignore === 0) { - // We found the opening scope token for $currType. - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $type = $tokens[$stackPtr]['type']; - echo str_repeat("\t", $depth); - echo "=> Found scope opener for $stackPtr ($type)".PHP_EOL; - } - - $opener = $i; - } - } else if (in_array($tokenType, $tokenizer->scopeOpeners[$currType]['end']) === true - && $opener !== null - ) { - if ($ignore > 0 && $tokenType === T_CLOSE_CURLY_BRACKET) { - // The last opening bracket must have been for a string - // offset or alike, so let's ignore it. - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo str_repeat("\t", $depth); - echo '* finished ignoring curly brace *'.PHP_EOL; - } - - $ignore--; - } else { - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $type = $tokens[$stackPtr]['type']; - echo str_repeat("\t", $depth); - echo "=> Found scope closer for $stackPtr ($type)".PHP_EOL; - } - - foreach (array($stackPtr, $opener, $i) as $token) { - $tokens[$token]['scope_condition'] = $stackPtr; - $tokens[$token]['scope_opener'] = $opener; - $tokens[$token]['scope_closer'] = $i; - } - - if ($tokenizer->scopeOpeners[$tokens[$stackPtr]['code']]['shared'] === true) { - // As we are going back to where we started originally, restore - // the ignore value back to its original value. - $ignore = $originalIgnore; - return $opener; - } else { - return $i; - } - }//end if - } else if ($tokenType === T_OPEN_PARENTHESIS) { - if (isset($tokens[$i]['parenthesis_owner']) === true) { - $owner = $tokens[$i]['parenthesis_owner']; - if (in_array($tokens[$owner]['code'], PHP_CodeSniffer_Tokens::$scopeOpeners) === true - && isset($tokens[$i]['parenthesis_closer']) === true - ) { - // If we get into here, then we opened a parenthesis for - // a scope (eg. an if or else if). We can just skip to - // the closing parenthesis. - $i = $tokens[$i]['parenthesis_closer']; - - // Update the start of the line so that when we check to see - // if the closing parenthesis is more than 3 lines away from - // the statement, we check from the closing parenthesis. - $startLine - = $tokens[$tokens[$i]['parenthesis_closer']]['line']; - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo str_repeat("\t", $depth); - echo '* skipping parenthesis *'.PHP_EOL; - } - } - }//end if - } else if ($tokenType === T_OPEN_CURLY_BRACKET && $opener !== null) { - // We opened something that we don't have a scope opener for. - // Examples of this are curly brackets for string offsets etc. - // We want to ignore this so that we don't have an invalid scope - // map. - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo str_repeat("\t", $depth); - echo '* ignoring curly brace *'.PHP_EOL; - } - - $ignore++; - } else if ($opener === null - && isset($tokenizer->scopeOpeners[$currType]) === true - ) { - // If we still haven't found the opener after 3 lines, - // we're not going to find it, unless we know it requires - // an opener (in which case we better keep looking) or the last - // token was empty (in which case we'll just confirm there is - // more code in this file and not just a big comment). - if ($tokens[$i]['line'] >= ($startLine + 3) - && in_array($tokens[($i - 1)]['code'], PHP_CodeSniffer_Tokens::$emptyTokens) === false - ) { - if ($tokenizer->scopeOpeners[$currType]['strict'] === true) { - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $type = $tokens[$stackPtr]['type']; - $lines = ($tokens[$i]['line'] - $startLine); - echo str_repeat("\t", $depth); - echo "=> Still looking for $stackPtr ($type) scope opener after $lines lines".PHP_EOL; - } - } else { - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $type = $tokens[$stackPtr]['type']; - echo str_repeat("\t", $depth); - echo "=> Couldn't find scope opener for $stackPtr ($type), bailing".PHP_EOL; - } - - return $stackPtr; - } - } - } else if ($opener !== null - && $tokenType !== T_BREAK - && in_array($tokenType, $tokenizer->endScopeTokens) === true - ) { - if (isset($tokens[$i]['scope_condition']) === false) { - if ($ignore > 0) { - // We found the end token for the opener we were ignoring. - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo str_repeat("\t", $depth); - echo '* finished ignoring curly brace *'.PHP_EOL; - } - - $ignore--; - } else { - // We found a token that closes the scope but it doesn't - // have a condition, so it belongs to another token and - // our token doesn't have a closer, so pretend this is - // the closer. - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $type = $tokens[$stackPtr]['type']; - echo str_repeat("\t", $depth); - echo "=> Found (unexpected) scope closer for $stackPtr ($type)".PHP_EOL; - } - - foreach (array($stackPtr, $opener) as $token) { - $tokens[$token]['scope_condition'] = $stackPtr; - $tokens[$token]['scope_opener'] = $opener; - $tokens[$token]['scope_closer'] = $i; - } - - return ($i - 1); - }//end if - }//end if - }//end if - }//end for - - return $stackPtr; - - }//end _recurseScopeMap() - - - /** - * Constructs the level map. - * - * The level map adds a 'level' indice to each token which indicates the - * depth that a token within a set of scope blocks. It also adds a - * 'condition' indice which is an array of the scope conditions that opened - * each of the scopes - position 0 being the first scope opener. - * - * @param array &$tokens The array of tokens to process. - * @param object $tokenizer The tokenizer being used to process this file. - * @param string $eolChar The EOL character to use for splitting strings. - * - * @return void - */ - private static function _createLevelMap(&$tokens, $tokenizer, $eolChar) - { - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t*** START LEVEL MAP ***".PHP_EOL; - } - - $numTokens = count($tokens); - $level = 0; - $conditions = array(); - $lastOpener = null; - $openers = array(); - - for ($i = 0; $i < $numTokens; $i++) { - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $type = $tokens[$i]['type']; - $line = $tokens[$i]['line']; - $content = str_replace($eolChar, '\n', $tokens[$i]['content']); - echo str_repeat("\t", ($level + 1)); - echo "Process token $i on line $line [lvl:$level;"; - if (empty($conditions) !== true) { - $condString = 'conds;'; - foreach ($conditions as $condition) { - $condString .= token_name($condition).','; - } - - echo rtrim($condString, ',').';'; - } - - echo "]: $type => $content".PHP_EOL; - } - - $tokens[$i]['level'] = $level; - $tokens[$i]['conditions'] = $conditions; - - if (isset($tokens[$i]['scope_condition']) === true) { - // Check to see if this token opened the scope. - if ($tokens[$i]['scope_opener'] === $i) { - $stackPtr = $tokens[$i]['scope_condition']; - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $type = $tokens[$stackPtr]['type']; - echo str_repeat("\t", ($level + 1)); - echo "=> Found scope opener for $stackPtr ($type)".PHP_EOL; - } - - $stackPtr = $tokens[$i]['scope_condition']; - - // If we find a scope opener that has a shared closer, - // then we need to go back over the condition map that we - // just created and fix ourselves as we just added some - // conditions where there was none. This happens for T_CASE - // statements that are using the same break statement. - if ($lastOpener !== null && $tokens[$lastOpener]['scope_closer'] === $tokens[$i]['scope_closer']) { - // This opener shares its closer with the previous opener, - // but we still need to check if the two openers share their - // closer with each other directly (like CASE and DEFAULT) - // or if they are just sharing because one doesn't have a - // closer (like CASE with no BREAK using a SWITCHes closer). - $thisType = $tokens[$tokens[$i]['scope_condition']]['code']; - $opener = $tokens[$lastOpener]['scope_condition']; - - $isShared = in_array( - $tokens[$opener]['code'], - $tokenizer->scopeOpeners[$thisType]['with'] - ); - - $sameEnd = ($tokenizer->scopeOpeners[$thisType]['end'][0] === $tokenizer->scopeOpeners[$tokens[$opener]['code']]['end'][0]); - if ($isShared === true && $sameEnd === true) { - $badToken = $opener; - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $type = $tokens[$badToken]['type']; - echo str_repeat("\t", ($level + 1)); - echo "* shared closer, cleaning up $badToken ($type) *".PHP_EOL; - } - - for ($x = $tokens[$i]['scope_condition']; $x <= $i; $x++) { - $oldConditions = $tokens[$x]['conditions']; - $oldLevel = $tokens[$x]['level']; - $tokens[$x]['level']--; - unset($tokens[$x]['conditions'][$badToken]); - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $type = $tokens[$x]['type']; - $oldConds = ''; - foreach ($oldConditions as $condition) { - $oldConds .= token_name($condition).','; - } - - $oldConds = rtrim($oldConds, ','); - - $newConds = ''; - foreach ($tokens[$x]['conditions'] as $condition) { - $newConds .= token_name($condition).','; - } - - $newConds = rtrim($newConds, ','); - - $newLevel = $tokens[$x]['level']; - echo str_repeat("\t", ($level + 1)); - echo "* cleaned $x ($type) *".PHP_EOL; - echo str_repeat("\t", ($level + 2)); - echo "=> level changed from $oldLevel to $newLevel".PHP_EOL; - echo str_repeat("\t", ($level + 2)); - echo "=> conditions changed from $oldConds to $newConds".PHP_EOL; - }//end if - }//end for - - unset($conditions[$badToken]); - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $type = $tokens[$badToken]['type']; - echo str_repeat("\t", ($level + 1)); - echo "* token $badToken ($type) removed from conditions array *".PHP_EOL; - } - - unset ($openers[$lastOpener]); - - $level--; - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo str_repeat("\t", ($level + 2)); - echo '* level decreased *'.PHP_EOL; - } - }//end if - }//end if - - $level++; - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo str_repeat("\t", ($level + 1)); - echo '* level increased *'.PHP_EOL; - } - - $conditions[$stackPtr] = $tokens[$stackPtr]['code']; - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $type = $tokens[$stackPtr]['type']; - echo str_repeat("\t", ($level + 1)); - echo "* token $stackPtr ($type) added to conditions array *".PHP_EOL; - } - - $lastOpener = $tokens[$i]['scope_opener']; - if ($lastOpener !== null) { - $openers[$lastOpener] = $lastOpener; - } - } else if ($tokens[$i]['scope_closer'] === $i) { - foreach (array_reverse($openers) as $opener) { - if ($tokens[$opener]['scope_closer'] === $i) { - $oldOpener = array_pop($openers); - if (empty($openers) === false) { - $lastOpener = array_pop($openers); - $openers[$lastOpener] = $lastOpener; - } else { - $lastOpener = null; - } - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $type = $tokens[$oldOpener]['type']; - echo str_repeat("\t", ($level + 1)); - echo "=> Found scope closer for $oldOpener ($type)".PHP_EOL; - } - - $oldCondition = array_pop($conditions); - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo str_repeat("\t", ($level + 1)); - echo '* token '.token_name($oldCondition).' removed from conditions array *'.PHP_EOL; - } - - // Make sure this closer actually belongs to us. - // Either the condition also has to think this is the - // closer, or it has to allow sharing with us. - $condition - = $tokens[$tokens[$i]['scope_condition']]['code']; - if ($condition !== $oldCondition) { - if (in_array($condition, $tokenizer->scopeOpeners[$oldCondition]['with']) === false) { - $badToken = $tokens[$oldOpener]['scope_condition']; - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $type = token_name($oldCondition); - echo str_repeat("\t", ($level + 1)); - echo "* scope closer was bad, cleaning up $badToken ($type) *".PHP_EOL; - } - - for ($x = ($oldOpener + 1); $x <= $i; $x++) { - $oldConditions = $tokens[$x]['conditions']; - $oldLevel = $tokens[$x]['level']; - $tokens[$x]['level']--; - unset($tokens[$x]['conditions'][$badToken]); - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $type = $tokens[$x]['type']; - $oldConds = ''; - foreach ($oldConditions as $condition) { - $oldConds .= token_name($condition).','; - } - - $oldConds = rtrim($oldConds, ','); - - $newConds = ''; - foreach ($tokens[$x]['conditions'] as $condition) { - $newConds .= token_name($condition).','; - } - - $newConds = rtrim($newConds, ','); - - $newLevel = $tokens[$x]['level']; - echo str_repeat("\t", ($level + 1)); - echo "* cleaned $x ($type) *".PHP_EOL; - echo str_repeat("\t", ($level + 2)); - echo "=> level changed from $oldLevel to $newLevel".PHP_EOL; - echo str_repeat("\t", ($level + 2)); - echo "=> conditions changed from $oldConds to $newConds".PHP_EOL; - }//end if - }//end for - }//end if - }//end if - - $level--; - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo str_repeat("\t", ($level + 2)); - echo '* level decreased *'.PHP_EOL; - } - - $tokens[$i]['level'] = $level; - $tokens[$i]['conditions'] = $conditions; - }//end if - }//end foreach - }//end if - }//end if - }//end for - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t*** END LEVEL MAP ***".PHP_EOL; - } - - }//end _createLevelMap() - - - /** - * Returns the declaration names for T_CLASS, T_INTERFACE and T_FUNCTION tokens. - * - * @param int $stackPtr The position of the declaration token which - * declared the class, interface or function. - * - * @return string|null The name of the class, interface or function. - * or NULL if the function is a closure. - * @throws PHP_CodeSniffer_Exception If the specified token is not of type - * T_FUNCTION, T_CLASS or T_INTERFACE. - */ - public function getDeclarationName($stackPtr) - { - $tokenCode = $this->_tokens[$stackPtr]['code']; - if ($tokenCode !== T_FUNCTION - && $tokenCode !== T_CLASS - && $tokenCode !== T_INTERFACE - ) { - throw new PHP_CodeSniffer_Exception('Token type is not T_FUNCTION, T_CLASS OR T_INTERFACE'); - } - - if ($tokenCode === T_FUNCTION - && $this->isAnonymousFunction($stackPtr) === true - ) { - return null; - } - - $token = $this->findNext(T_STRING, $stackPtr); - return $this->_tokens[$token]['content']; - - }//end getDeclarationName() - - - /** - * Check if the token at the specified position is a anonymus function. - * - * @param int $stackPtr The position of the declaration token which - * declared the class, interface or function. - * - * @return boolean - * @throws PHP_CodeSniffer_Exception If the specified token is not of type - * T_FUNCTION - */ - public function isAnonymousFunction($stackPtr) - { - $tokenCode = $this->_tokens[$stackPtr]['code']; - if ($tokenCode !== T_FUNCTION) { - throw new PHP_CodeSniffer_Exception('Token type is not T_FUNCTION'); - } - - if (isset($this->_tokens[$stackPtr]['parenthesis_opener']) === false) { - // Something is not right with this function. - return false; - } - - $name = $this->findNext(T_STRING, ($stackPtr + 1)); - if ($name === false) { - // No name found. - return true; - } - - $open = $this->_tokens[$stackPtr]['parenthesis_opener']; - if ($name > $open) { - return true; - } - - return false; - - }//end isAnonymousFunction() - - - /** - * Returns the method parameters for the specified T_FUNCTION token. - * - * Each parameter is in the following format: - * - * - * 0 => array( - * 'name' => '$var', // The variable name. - * 'pass_by_reference' => false, // Passed by reference. - * 'type_hint' => string, // Type hint for array or custom type - * ) - * - * - * Parameters with default values have and additional array indice of - * 'default' with the value of the default as a string. - * - * @param int $stackPtr The position in the stack of the T_FUNCTION token - * to acquire the parameters for. - * - * @return array() - * @throws PHP_CodeSniffer_Exception If the specified $stackPtr is not of - * type T_FUNCTION. - */ - public function getMethodParameters($stackPtr) - { - if ($this->_tokens[$stackPtr]['code'] !== T_FUNCTION) { - throw new PHP_CodeSniffer_Exception('$stackPtr must be of type T_FUNCTION'); - } - - $opener = $this->_tokens[$stackPtr]['parenthesis_opener']; - $closer = $this->_tokens[$stackPtr]['parenthesis_closer']; - - $vars = array(); - $currVar = null; - $defaultStart = null; - $paramCount = 0; - $passByReference = false; - $typeHint = ''; - - for ($i = ($opener + 1); $i <= $closer; $i++) { - // Check to see if this token has a parenthesis opener. If it does - // its likely to be an array, which might have arguments in it, which - // we cause problems in our parsing below, so lets just skip to the - // end of it. - if (isset($this->_tokens[$i]['parenthesis_opener']) === true) { - // Don't do this if it's the close parenthesis for the method. - if ($i !== $this->_tokens[$i]['parenthesis_closer']) { - $i = ($this->_tokens[$i]['parenthesis_closer'] + 1); - } - } - - switch ($this->_tokens[$i]['code']) { - case T_BITWISE_AND: - $passByReference = true; - break; - case T_VARIABLE: - $currVar = $i; - break; - case T_ARRAY_HINT: - $typeHint = $this->_tokens[$i]['content']; - break; - case T_STRING: - // This is a string, so it may be a type hint, but it could - // also be a constant used as a default value. - $prevComma = $this->findPrevious(T_COMMA, $i, $opener); - if ($prevComma !== false) { - $nextEquals = $this->findNext(T_EQUAL, $prevComma, $i); - if ($nextEquals !== false) { - break; - } - } - - if ($defaultStart === null) { - $typeHint .= $this->_tokens[$i]['content']; - } - - break; - case T_NS_SEPARATOR: - // Part of a type hint or default value. - if ($defaultStart === null) { - $typeHint .= $this->_tokens[$i]['content']; - } - - break; - case T_CLOSE_PARENTHESIS: - case T_COMMA: - // If it's null, then there must be no parameters for this - // method. - if ($currVar === null) { - continue; - } - - $vars[$paramCount] = array(); - $vars[$paramCount]['name'] = $this->_tokens[$currVar]['content']; - - if ($defaultStart !== null) { - $vars[$paramCount]['default'] - = $this->getTokensAsString( - $defaultStart, - ($i - $defaultStart) - ); - } - - $vars[$paramCount]['pass_by_reference'] = $passByReference; - $vars[$paramCount]['type_hint'] = $typeHint; - - // Reset the vars, as we are about to process the next parameter. - $defaultStart = null; - $passByReference = false; - $typeHint = ''; - - $paramCount++; - break; - case T_EQUAL: - $defaultStart = ($i + 1); - break; - }//end switch - }//end for - - return $vars; - - }//end getMethodParameters() - - - /** - * Returns the visibility and implementation properies of a method. - * - * The format of the array is: - * - * array( - * 'scope' => 'public', // public private or protected - * 'scope_specified' => true, // true is scope keyword was found. - * 'is_abstract' => false, // true if the abstract keyword was found. - * 'is_final' => false, // true if the final keyword was found. - * 'is_static' => false, // true if the static keyword was found. - * 'is_closure' => false, // true if no name is found. - * ); - * - * - * @param int $stackPtr The position in the stack of the T_FUNCTION token to - * acquire the properties for. - * - * @return array - * @throws PHP_CodeSniffer_Exception If the specified position is not a - * T_FUNCTION token. - */ - public function getMethodProperties($stackPtr) - { - if ($this->_tokens[$stackPtr]['code'] !== T_FUNCTION) { - throw new PHP_CodeSniffer_Exception('$stackPtr must be of type T_FUNCTION'); - } - - $valid = array( - T_PUBLIC, - T_PRIVATE, - T_PROTECTED, - T_STATIC, - T_FINAL, - T_ABSTRACT, - T_WHITESPACE, - T_COMMENT, - T_DOC_COMMENT, - ); - - $scope = 'public'; - $scopeSpecified = false; - $isAbstract = false; - $isFinal = false; - $isStatic = false; - $isClosure = $this->isAnonymousFunction($stackPtr); - - for ($i = ($stackPtr - 1); $i > 0; $i--) { - if (in_array($this->_tokens[$i]['code'], $valid) === false) { - break; - } - - switch ($this->_tokens[$i]['code']) { - case T_PUBLIC: - $scope = 'public'; - $scopeSpecified = true; - break; - case T_PRIVATE: - $scope = 'private'; - $scopeSpecified = true; - break; - case T_PROTECTED: - $scope = 'protected'; - $scopeSpecified = true; - break; - case T_ABSTRACT: - $isAbstract = true; - break; - case T_FINAL: - $isFinal = true; - break; - case T_STATIC: - $isStatic = true; - break; - }//end switch - }//end for - - return array( - 'scope' => $scope, - 'scope_specified' => $scopeSpecified, - 'is_abstract' => $isAbstract, - 'is_final' => $isFinal, - 'is_static' => $isStatic, - 'is_closure' => $isClosure, - ); - - }//end getMethodProperties() - - - /** - * Returns the visibility and implementation properies of the class member - * variable found at the specified position in the stack. - * - * The format of the array is: - * - * - * array( - * 'scope' => 'public', // public private or protected - * 'is_static' => false, // true if the static keyword was found. - * ); - * - * - * @param int $stackPtr The position in the stack of the T_VARIABLE token to - * acquire the properties for. - * - * @return array - * @throws PHP_CodeSniffer_Exception If the specified position is not a - * T_VARIABLE token, or if the position is not - * a class member variable. - */ - public function getMemberProperties($stackPtr) - { - if ($this->_tokens[$stackPtr]['code'] !== T_VARIABLE) { - throw new PHP_CodeSniffer_Exception('$stackPtr must be of type T_VARIABLE'); - } - - $conditions = array_keys($this->_tokens[$stackPtr]['conditions']); - $ptr = array_pop($conditions); - if (isset($this->_tokens[$ptr]) === false - || $this->_tokens[$ptr]['code'] !== T_CLASS - ) { - if (isset($this->_tokens[$ptr]) === true - && $this->_tokens[$ptr]['code'] === T_INTERFACE - ) { - // T_VARIABLEs in interfaces can actually be method arguments - // but they wont be seen as being inside the method because there - // are no scope openers and closers for abstract methods. If it is in - // parentheses, we can be pretty sure it is a method argument. - if (isset($this->_tokens[$stackPtr]['nested_parenthesis']) === false - || empty($this->_tokens[$stackPtr]['nested_parenthesis']) === true - ) { - $error = 'Possible parse error: interfaces may not include member vars'; - $this->addWarning($error, $stackPtr, 'Internal.ParseError.InterfaceHasMemberVar'); - return array(); - } - } else { - throw new PHP_CodeSniffer_Exception('$stackPtr is not a class member var'); - } - } - - $valid = array( - T_PUBLIC, - T_PRIVATE, - T_PROTECTED, - T_STATIC, - T_WHITESPACE, - T_COMMENT, - T_DOC_COMMENT, - ); - - $scope = 'public'; - $scopeSpecified = false; - $isStatic = false; - - for ($i = ($stackPtr - 1); $i > 0; $i--) { - if (in_array($this->_tokens[$i]['code'], $valid) === false) { - break; - } - - switch ($this->_tokens[$i]['code']) { - case T_PUBLIC: - $scope = 'public'; - $scopeSpecified = true; - break; - case T_PRIVATE: - $scope = 'private'; - $scopeSpecified = true; - break; - case T_PROTECTED: - $scope = 'protected'; - $scopeSpecified = true; - break; - case T_STATIC: - $isStatic = true; - break; - } - }//end for - - return array( - 'scope' => $scope, - 'scope_specified' => $scopeSpecified, - 'is_static' => $isStatic, - ); - - }//end getMemberProperties() - - - /** - * Returns the visibility and implementation properies of a class. - * - * The format of the array is: - * - * array( - * 'is_abstract' => false, // true if the abstract keyword was found. - * 'is_final' => false, // true if the final keyword was found. - * ); - * - * - * @param int $stackPtr The position in the stack of the T_CLASS token to - * acquire the properties for. - * - * @return array - * @throws PHP_CodeSniffer_Exception If the specified position is not a - * T_CLASS token. - */ - public function getClassProperties($stackPtr) - { - if ($this->_tokens[$stackPtr]['code'] !== T_CLASS) { - throw new PHP_CodeSniffer_Exception('$stackPtr must be of type T_CLASS'); - } - - $valid = array( - T_FINAL, - T_ABSTRACT, - T_WHITESPACE, - T_COMMENT, - T_DOC_COMMENT, - ); - - $isAbstract = false; - $isFinal = false; - - for ($i = ($stackPtr - 1); $i > 0; $i--) { - if (in_array($this->_tokens[$i]['code'], $valid) === false) { - break; - } - - switch ($this->_tokens[$i]['code']) { - case T_ABSTRACT: - $isAbstract = true; - break; - - case T_FINAL: - $isFinal = true; - break; - } - }//end for - - return array( - 'is_abstract' => $isAbstract, - 'is_final' => $isFinal, - ); - - }//end getClassProperties() - - - /** - * Determine if the passed token is a reference operator. - * - * Returns true if the specified token position represents a reference. - * Returns false if the token represents a bitwise operator. - * - * @param int $stackPtr The position of the T_BITWISE_AND token. - * - * @return boolean - */ - public function isReference($stackPtr) - { - if ($this->_tokens[$stackPtr]['code'] !== T_BITWISE_AND) { - return false; - } - - $tokenBefore = $this->findPrevious( - PHP_CodeSniffer_Tokens::$emptyTokens, - ($stackPtr - 1), - null, - true - ); - - if ($this->_tokens[$tokenBefore]['code'] === T_FUNCTION) { - // Function returns a reference. - return true; - } - - if ($this->_tokens[$tokenBefore]['code'] === T_DOUBLE_ARROW) { - // Inside a foreach loop, this is a reference. - return true; - } - - if ($this->_tokens[$tokenBefore]['code'] === T_AS) { - // Inside a foreach loop, this is a reference. - return true; - } - - if (in_array($this->_tokens[$tokenBefore]['code'], PHP_CodeSniffer_Tokens::$assignmentTokens) === true) { - // This is directly after an assignment. It's a reference. Even if - // it is part of an operation, the other tests will handle it. - return true; - } - - if (isset($this->_tokens[$stackPtr]['nested_parenthesis']) === true) { - $brackets = $this->_tokens[$stackPtr]['nested_parenthesis']; - $lastBracket = array_pop($brackets); - if (isset($this->_tokens[$lastBracket]['parenthesis_owner']) === true) { - $owner = $this->_tokens[$this->_tokens[$lastBracket]['parenthesis_owner']]; - if ($owner['code'] === T_FUNCTION - || $owner['code'] === T_CLOSURE - || $owner['code'] === T_ARRAY - ) { - // Inside a function or array declaration, this is a reference. - return true; - } - } else { - $prev = $this->findPrevious( - array(T_WHITESPACE), - ($this->_tokens[$lastBracket]['parenthesis_opener'] - 1), - null, - true - ); - - if ($prev !== false && $this->_tokens[$prev]['code'] === T_USE) { - return true; - } - } - } - - $tokenAfter = $this->findNext( - PHP_CodeSniffer_Tokens::$emptyTokens, - ($stackPtr + 1), - null, - true - ); - - if ($this->_tokens[$tokenAfter]['code'] === T_VARIABLE - && ($this->_tokens[$tokenBefore]['code'] === T_OPEN_PARENTHESIS - || $this->_tokens[$tokenBefore]['code'] === T_COMMA) - ) { - return true; - } - - return false; - - }//end isReference() - - - /** - * Returns the content of the tokens from the specified start position in - * the token stack for the specified legnth. - * - * @param int $start The position to start from in the token stack. - * @param int $length The length of tokens to traverse from the start pos. - * - * @return string The token contents. - */ - public function getTokensAsString($start, $length) - { - $str = ''; - $end = ($start + $length); - if ($end > $this->numTokens) { - $end = $this->numTokens; - } - - for ($i = $start; $i < $end; $i++) { - $str .= $this->_tokens[$i]['content']; - } - - return $str; - - }//end getTokensAsString() - - - /** - * Returns the position of the next specified token(s). - * - * If a value is specified, the next token of the specified type(s) - * containing the specified value will be returned. - * - * Returns false if no token can be found. - * - * @param int|array $types The type(s) of tokens to search for. - * @param int $start The position to start searching from in the - * token stack. - * @param int $end The end position to fail if no token is found. - * if not specified or null, end will default to - * the start of the token stack. - * @param bool $exclude If true, find the next token that are NOT of - * the types specified in $types. - * @param string $value The value that the token(s) must be equal to. - * If value is ommited, tokens with any value will - * be returned. - * @param bool $local If true, tokens outside the current statement - * will not be cheked. IE. checking will stop - * at the next semi-colon found. - * - * @return int | bool - * @see findNext() - */ - public function findPrevious( - $types, - $start, - $end=null, - $exclude=false, - $value=null, - $local=false - ) { - $types = (array) $types; - - if ($end === null) { - $end = 0; - } - - for ($i = $start; $i >= $end; $i--) { - $found = (bool) $exclude; - foreach ($types as $type) { - if ($this->_tokens[$i]['code'] === $type) { - $found = !$exclude; - break; - } - } - - if ($found === true) { - if ($value === null) { - return $i; - } else if ($this->_tokens[$i]['content'] === $value) { - return $i; - } - } - - if ($local === true && $this->_tokens[$i]['code'] === T_SEMICOLON) { - break; - } - }//end for - - return false; - - }//end findPrevious() - - - /** - * Returns the position of the next specified token(s). - * - * If a value is specified, the next token of the specified type(s) - * containing the specified value will be returned. - * - * Returns false if no token can be found. - * - * @param int|array $types The type(s) of tokens to search for. - * @param int $start The position to start searching from in the - * token stack. - * @param int $end The end position to fail if no token is found. - * if not specified or null, end will default to - * the end of the token stack. - * @param bool $exclude If true, find the next token that is NOT of - * a type specified in $types. - * @param string $value The value that the token(s) must be equal to. - * If value is ommited, tokens with any value will - * be returned. - * @param bool $local If true, tokens outside the current statement - * will not be checked. i.e., checking will stop - * at the next semi-colon found. - * - * @return int | bool - * @see findPrevious() - */ - public function findNext( - $types, - $start, - $end=null, - $exclude=false, - $value=null, - $local=false - ) { - $types = (array) $types; - - if ($end === null || $end > $this->numTokens) { - $end = $this->numTokens; - } - - for ($i = $start; $i < $end; $i++) { - $found = (bool) $exclude; - foreach ($types as $type) { - if ($this->_tokens[$i]['code'] === $type) { - $found = !$exclude; - break; - } - } - - if ($found === true) { - if ($value === null) { - return $i; - } else if ($this->_tokens[$i]['content'] === $value) { - return $i; - } - } - - if ($local === true && $this->_tokens[$i]['code'] === T_SEMICOLON) { - break; - } - }//end for - - return false; - - }//end findNext() - - - /** - * Returns the position of the first token on a line, matching given type. - * - * Returns false if no token can be found. - * - * @param int|array $types The type(s) of tokens to search for. - * @param int $start The position to start searching from in the - * token stack. The first token matching on - * this line before this token will be returned. - * @param bool $exclude If true, find the token that is NOT of - * the types specified in $types. - * @param string $value The value that the token must be equal to. - * If value is ommited, tokens with any value will - * be returned. - * - * @return int | bool - */ - public function findFirstOnLine($types, $start, $exclude=false, $value=null) - { - if (is_array($types) === false) { - $types = array($types); - } - - $foundToken = false; - - for ($i = $start; $i >= 0; $i--) { - if ($this->_tokens[$i]['line'] < $this->_tokens[$start]['line']) { - break; - } - - $found = $exclude; - foreach ($types as $type) { - if ($exclude === false) { - if ($this->_tokens[$i]['code'] === $type) { - $found = true; - break; - } - } else { - if ($this->_tokens[$i]['code'] === $type) { - $found = false; - break; - } - } - } - - if ($found === true) { - if ($value === null) { - $foundToken = $i; - } else if ($this->_tokens[$i]['content'] === $value) { - $foundToken = $i; - } - } - }//end for - - return $foundToken; - - }//end findFirstOnLine() - - - /** - * Determine if the passed token has a condition of one of the passed types. - * - * @param int $stackPtr The position of the token we are checking. - * @param int|array $types The type(s) of tokens to search for. - * - * @return boolean - */ - public function hasCondition($stackPtr, $types) - { - // Check for the existence of the token. - if (isset($this->_tokens[$stackPtr]) === false) { - return false; - } - - // Make sure the token has conditions. - if (isset($this->_tokens[$stackPtr]['conditions']) === false) { - return false; - } - - $types = (array) $types; - $conditions = $this->_tokens[$stackPtr]['conditions']; - - foreach ($types as $type) { - if (in_array($type, $conditions) === true) { - // We found a token with the required type. - return true; - } - } - - return false; - - }//end hasCondition() - - - /** - * Return the position of the condition for the passed token. - * - * Returns FALSE if the token does not have the condition. - * - * @param int $stackPtr The position of the token we are checking. - * @param int $type The type of token to search for. - * - * @return int - */ - public function getCondition($stackPtr, $type) - { - // Check for the existence of the token. - if (isset($this->_tokens[$stackPtr]) === false) { - return false; - } - - // Make sure the token has conditions. - if (isset($this->_tokens[$stackPtr]['conditions']) === false) { - return false; - } - - $conditions = $this->_tokens[$stackPtr]['conditions']; - foreach ($conditions as $token => $condition) { - if ($condition === $type) { - return $token; - } - } - - return false; - - }//end getCondition() - - - /** - * Returns the name of the class that the specified class extends. - * - * Returns FALSE on error or if there is no extended class name. - * - * @param int $stackPtr The stack position of the class. - * - * @return string - */ - public function findExtendedClassName($stackPtr) - { - // Check for the existence of the token. - if (isset($this->_tokens[$stackPtr]) === false) { - return false; - } - - if ($this->_tokens[$stackPtr]['code'] !== T_CLASS) { - return false; - } - - if (isset($this->_tokens[$stackPtr]['scope_closer']) === false) { - return false; - } - - $classCloserIndex = $this->_tokens[$stackPtr]['scope_closer']; - $extendsIndex = $this->findNext(T_EXTENDS, $stackPtr, $classCloserIndex); - if (false === $extendsIndex) { - return false; - } - - $stringIndex = $this->findNext(T_STRING, $extendsIndex, $classCloserIndex); - if (false === $stringIndex) { - return false; - } - - return $this->_tokens[$stringIndex]['content']; - - }//end findExtendedClassName() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/MultiFileSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/MultiFileSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/MultiFileSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/MultiFileSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Represents a PHP_CodeSniffer multi-file sniff for sniffing coding standards. - * - * A multi-file sniff is called after all files have been checked using the - * regular sniffs. The process() method is passed an array of PHP_CodeSniffer_File - * objects, one for each file checked during the script run. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -interface PHP_CodeSniffer_MultiFileSniff -{ - - - /** - * Called once per script run to allow for processing of this sniff. - * - * @param array(PHP_CodeSniffer_File) $files The PHP_CodeSniffer files processed - * during the script run. - * - * @return void - */ - public function process(array $files); - - -}//end interface - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Report.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Report.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Report.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Report.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,54 +0,0 @@ - - * @author Greg Sherwood - * @copyright 2009 SQLI - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Represents a PHP_CodeSniffer report. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Gabriele Santini - * @author Greg Sherwood - * @copyright 2009 SQLI - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -interface PHP_CodeSniffer_Report -{ - - - /** - * Generate the actual report. - * - * @param array $report Prepared report. - * @param boolean $showSources Show sources? - * @param int $width Maximum allowed lne width. - * @param boolean $toScreen Is the report being printed to screen? - * - * @return string - */ - public function generate( - $report, - $showSources=false, - $width=80, - $toScreen=true - ); - - -}//end interface - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Reporting.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Reporting.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Reporting.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Reporting.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,231 +0,0 @@ - - * @author Greg Sherwood - * @copyright 2009 SQLI - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -if (is_file(dirname(__FILE__).'/../CodeSniffer.php') === true) { - include_once dirname(__FILE__).'/../CodeSniffer.php'; -} else { - include_once 'PHP/CodeSniffer.php'; -} - -/** - * A class to manage reporting. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Gabriele Santini - * @author Greg Sherwood - * @copyright 2009 SQLI - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PHP_CodeSniffer_Reporting -{ - - - /** - * Produce the appropriate report object based on $type parameter. - * - * @param string $type Demanded report type. - * - * @return PHP_CodeSniffer_Report - * @throws PHP_CodeSniffer_Exception If report is not available. - */ - public function factory($type) - { - $type = ucfirst($type); - $filename = $type.'.php'; - $reportClassName = 'PHP_CodeSniffer_Reports_'.$type; - if (class_exists($reportClassName, true) === false) { - throw new PHP_CodeSniffer_Exception('Report type "'.$type.'" not found.'); - } - - $reportClass = new $reportClassName(); - if (false === ($reportClass instanceof PHP_CodeSniffer_Report)) { - throw new PHP_CodeSniffer_Exception('Class "'.$reportClassName.'" must implement the "PHP_CodeSniffer_Report" interface.'); - } - - return $reportClass; - - }//end factory() - - - /** - * Actually generates the report. - * - * @param string $report Report type. - * @param array $filesViolations Collected violations. - * @param boolean $showSources Show sources? - * @param string $reportFile Report file to generate. - * @param integer $reportWidth Report max width. - * - * @return integer - */ - public function printReport( - $report, - $filesViolations, - $showSources, - $reportFile='', - $reportWidth=80 - ) { - if ($reportFile !== null) { - $reportDir = dirname($reportFile); - if ($reportDir === '.') { - // Passed report file is a filename in the current directory. - $reportFile = PHPCS_CWD.'/'.basename($reportFile); - } else { - $reportDir = realpath(PHPCS_CWD.'/'.$reportDir); - if ($reportDir !== false) { - // Report file path is relative. - $reportFile = $reportDir.'/'.basename($reportFile); - } - } - } - - $reportClass = self::factory($report); - $reportData = $this->prepare($filesViolations); - - $toScreen = true; - if ($reportFile !== null) { - $toScreen = false; - ob_start(); - } - - $numErrors = $reportClass->generate($reportData, $showSources, $reportWidth, $toScreen); - - if ($reportFile !== null) { - $generatedReport = ob_get_contents(); - if (PHP_CODESNIFFER_VERBOSITY > 0) { - ob_end_flush(); - } else { - ob_end_clean(); - } - - $generatedReport = trim($generatedReport); - file_put_contents($reportFile, $generatedReport.PHP_EOL); - } - - return $numErrors; - - }//end printReport() - - - /** - * Pre-process and package violations for all files. - * - * Used by error reports to get a packaged list of all errors in each file. - * - * @param array $filesViolations List of found violations. - * - * @return array - */ - public function prepare(array $filesViolations) - { - $report = array( - 'totals' => array( - 'warnings' => 0, - 'errors' => 0, - ), - 'files' => array(), - ); - - foreach ($filesViolations as $filename => $fileViolations) { - $warnings = $fileViolations['warnings']; - $errors = $fileViolations['errors']; - $numWarnings = $fileViolations['numWarnings']; - $numErrors = $fileViolations['numErrors']; - - $report['files'][$filename] = array( - 'errors' => 0, - 'warnings' => 0, - 'messages' => array(), - ); - - if ($numErrors === 0 && $numWarnings === 0) { - // Prefect score! - continue; - } - - $report['files'][$filename]['errors'] = $numErrors; - $report['files'][$filename]['warnings'] = $numWarnings; - - $report['totals']['errors'] += $numErrors; - $report['totals']['warnings'] += $numWarnings; - - // Merge errors and warnings. - foreach ($errors as $line => $lineErrors) { - foreach ($lineErrors as $column => $colErrors) { - $newErrors = array(); - foreach ($colErrors as $data) { - $newErrors[] = array( - 'message' => $data['message'], - 'source' => $data['source'], - 'severity' => $data['severity'], - 'type' => 'ERROR', - ); - }//end foreach - - $errors[$line][$column] = $newErrors; - }//end foreach - - ksort($errors[$line]); - }//end foreach - - foreach ($warnings as $line => $lineWarnings) { - foreach ($lineWarnings as $column => $colWarnings) { - $newWarnings = array(); - foreach ($colWarnings as $data) { - $newWarnings[] = array( - 'message' => $data['message'], - 'source' => $data['source'], - 'severity' => $data['severity'], - 'type' => 'WARNING', - ); - }//end foreach - - if (isset($errors[$line]) === false) { - $errors[$line] = array(); - } - - if (isset($errors[$line][$column]) === true) { - $errors[$line][$column] = array_merge( - $newWarnings, - $errors[$line][$column] - ); - } else { - $errors[$line][$column] = $newWarnings; - } - }//end foreach - - ksort($errors[$line]); - }//end foreach - - ksort($errors); - - $report['files'][$filename]['messages'] = $errors; - }//end foreach - - ksort($report['files']); - - return $report; - - }//end prepare() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Reports/Checkstyle.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Reports/Checkstyle.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Reports/Checkstyle.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Reports/Checkstyle.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,104 +0,0 @@ - - * @author Greg Sherwood - * @copyright 2009 SQLI - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Checkstyle report for PHP_CodeSniffer. - * - * PHP version 5 - * - * @category PHP - * @package PHP_CodeSniffer - * @author Gabriele Santini - * @author Greg Sherwood - * @copyright 2009 SQLI - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PHP_CodeSniffer_Reports_Checkstyle implements PHP_CodeSniffer_Report -{ - - - /** - * Prints all violations for processed files, in a Checkstyle format. - * - * Violations are grouped by file. - * - * @param array $report Prepared report. - * @param boolean $showSources Show sources? - * @param int $width Maximum allowed lne width. - * @param boolean $toScreen Is the report being printed to screen? - * - * @return string - */ - public function generate( - $report, - $showSources=false, - $width=80, - $toScreen=true - ) { - $out = new XMLWriter; - $out->openMemory(); - $out->setIndent(true); - $out->startDocument('1.0', 'UTF-8'); - $out->startElement('checkstyle'); - $out->writeAttribute('version', '1.3.4'); - - $errorsShown = 0; - foreach ($report['files'] as $filename => $file) { - if (count($file['messages']) === 0) { - continue; - } - - $out->startElement('file'); - $out->writeAttribute('name', $filename); - - foreach ($file['messages'] as $line => $lineErrors) { - foreach ($lineErrors as $column => $colErrors) { - foreach ($colErrors as $error) { - $error['type'] = strtolower($error['type']); - if (PHP_CODESNIFFER_ENCODING !== 'utf-8') { - $error['message'] = iconv(PHP_CODESNIFFER_ENCODING, 'utf-8', $error['message']); - } - - $out->startElement('error'); - $out->writeAttribute('line', $line); - $out->writeAttribute('column', $column); - $out->writeAttribute('severity', $error['type']); - $out->writeAttribute('message', $error['message']); - $out->writeAttribute('source', $error['source']); - $out->endElement(); - - $errorsShown++; - } - } - }//end foreach - - $out->endElement(); - }//end foreach - - $out->endElement(); - echo $out->flush(); - - return $errorsShown; - - }//end generate() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Reports/Csv.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Reports/Csv.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Reports/Csv.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Reports/Csv.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,78 +0,0 @@ - - * @author Greg Sherwood - * @copyright 2009 SQLI - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Csv report for PHP_CodeSniffer. - * - * PHP version 5 - * - * @category PHP - * @package PHP_CodeSniffer - * @author Gabriele Santini - * @author Greg Sherwood - * @copyright 2009 SQLI - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PHP_CodeSniffer_Reports_Csv implements PHP_CodeSniffer_Report -{ - - - /** - * Generates a csv report. - * - * @param array $report Prepared report. - * @param boolean $showSources Show sources? - * @param int $width Maximum allowed lne width. - * @param boolean $toScreen Is the report being printed to screen? - * - * @return string - */ - public function generate( - $report, - $showSources=false, - $width=80, - $toScreen=true - ) { - echo 'File,Line,Column,Type,Message,Source,Severity'.PHP_EOL; - - $errorsShown = 0; - foreach ($report['files'] as $filename => $file) { - foreach ($file['messages'] as $line => $lineErrors) { - foreach ($lineErrors as $column => $colErrors) { - foreach ($colErrors as $error) { - $filename = str_replace('"', '\"', $filename); - $message = str_replace('"', '\"', $error['message']); - $type = strtolower($error['type']); - $source = $error['source']; - $severity = $error['severity']; - echo "\"$filename\",$line,$column,$type,\"$message\",$source,$severity".PHP_EOL; - $errorsShown++; - } - } - }//end foreach - }//end foreach - - return $errorsShown; - - }//end generate() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Reports/Emacs.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Reports/Emacs.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Reports/Emacs.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Reports/Emacs.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,78 +0,0 @@ - - * @author Greg Sherwood - * @copyright 2009 SQLI - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Emacs report for PHP_CodeSniffer. - * - * PHP version 5 - * - * @category PHP - * @package PHP_CodeSniffer - * @author Gabriele Santini - * @author Greg Sherwood - * @copyright 2009 SQLI - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PHP_CodeSniffer_Reports_Emacs implements PHP_CodeSniffer_Report -{ - - - /** - * Generates an emacs report. - * - * @param array $report Prepared report. - * @param boolean $showSources Show sources? - * @param int $width Maximum allowed lne width. - * @param boolean $toScreen Is the report being printed to screen? - * - * @return string - */ - public function generate( - $report, - $showSources=false, - $width=80, - $toScreen=true - ) { - $errorsShown = 0; - - foreach ($report['files'] as $filename => $file) { - foreach ($file['messages'] as $line => $lineErrors) { - foreach ($lineErrors as $column => $colErrors) { - foreach ($colErrors as $error) { - $message = $error['message']; - if ($showSources === true) { - $message .= ' ('.$error['source'].')'; - } - - $type = strtolower($error['type']); - echo $filename.':'.$line.':'.$column.': '.$type.' - '.$message.PHP_EOL; - $errorsShown++; - } - } - }//end foreach - }//end foreach - - return $errorsShown; - - }//end generate() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Reports/Full.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Reports/Full.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Reports/Full.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Reports/Full.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,153 +0,0 @@ - - * @author Greg Sherwood - * @copyright 2009 SQLI - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Full report for PHP_CodeSniffer. - * - * PHP version 5 - * - * @category PHP - * @package PHP_CodeSniffer - * @author Gabriele Santini - * @author Greg Sherwood - * @copyright 2009 SQLI - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PHP_CodeSniffer_Reports_Full implements PHP_CodeSniffer_Report -{ - - - /** - * Prints all errors and warnings for each file processed. - * - * Errors and warnings are displayed together, grouped by file. - * - * @param array $report Prepared report. - * @param boolean $showSources Show sources? - * @param int $width Maximum allowed lne width. - * @param boolean $toScreen Is the report being printed to screen? - * - * @return string - */ - public function generate( - $report, - $showSources=false, - $width=80, - $toScreen=true - ) { - $errorsShown = 0; - $width = max($width, 70); - - foreach ($report['files'] as $filename => $file) { - if (empty($file['messages']) === true) { - continue; - } - - echo PHP_EOL.'FILE: '; - if (strlen($filename) <= ($width - 9)) { - echo $filename; - } else { - echo '...'.substr($filename, (strlen($filename) - ($width - 9))); - } - - echo PHP_EOL; - echo str_repeat('-', $width).PHP_EOL; - - echo 'FOUND '.$file['errors'].' ERROR(S) '; - if ($file['warnings'] > 0) { - echo 'AND '.$file['warnings'].' WARNING(S) '; - } - - echo 'AFFECTING '.count($file['messages']).' LINE(S)'.PHP_EOL; - echo str_repeat('-', $width).PHP_EOL; - - // Work out the max line number for formatting. - $maxLine = 0; - foreach ($file['messages'] as $line => $lineErrors) { - if ($line > $maxLine) { - $maxLine = $line; - } - } - - $maxLineLength = strlen($maxLine); - - // The length of the word ERROR or WARNING; used for padding. - if ($file['warnings'] > 0) { - $typeLength = 7; - } else { - $typeLength = 5; - } - - // The padding that all lines will require that are - // printing an error message overflow. - $paddingLine2 = str_repeat(' ', ($maxLineLength + 1)); - $paddingLine2 .= ' | '; - $paddingLine2 .= str_repeat(' ', $typeLength); - $paddingLine2 .= ' | '; - - // The maxium amount of space an error message can use. - $maxErrorSpace = ($width - strlen($paddingLine2) - 1); - - foreach ($file['messages'] as $line => $lineErrors) { - foreach ($lineErrors as $column => $colErrors) { - foreach ($colErrors as $error) { - $message = $error['message']; - if ($showSources === true) { - $message .= ' ('.$error['source'].')'; - } - - // The padding that goes on the front of the line. - $padding = ($maxLineLength - strlen($line)); - $errorMsg = wordwrap( - $message, - $maxErrorSpace, - PHP_EOL.$paddingLine2 - ); - - echo ' '.str_repeat(' ', $padding).$line.' | '.$error['type']; - if ($error['type'] === 'ERROR') { - if ($file['warnings'] > 0) { - echo ' '; - } - } - - echo ' | '.$errorMsg.PHP_EOL; - $errorsShown++; - }//end foreach - }//end foreach - }//end foreach - - echo str_repeat('-', $width).PHP_EOL.PHP_EOL; - }//end foreach - - if ($toScreen === true - && PHP_CODESNIFFER_INTERACTIVE === false - && class_exists('PHP_Timer', false) === true - ) { - echo PHP_Timer::resourceUsage().PHP_EOL.PHP_EOL; - } - - return $errorsShown; - - }//end generate() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Reports/Gitblame.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Reports/Gitblame.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Reports/Gitblame.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Reports/Gitblame.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,133 +0,0 @@ - - * @copyright 2009 SQLI - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Gitblame report for PHP_CodeSniffer. - * - * PHP version 5 - * - * @category PHP - * @package PHP_CodeSniffer - * @author Ben Selby - * @copyright 2009 SQLI - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.2.2 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PHP_CodeSniffer_Reports_Gitblame extends PHP_CodeSniffer_Reports_VersionControl -{ - - /** - * The name of the report we want in the output - * - * @var string - */ - protected $reportName = 'GIT'; - - - /** - * Extract the author from a blame line. - * - * @param string $line Line to parse. - * - * @return mixed string or false if impossible to recover. - */ - protected function getAuthor($line) - { - $blameParts = array(); - $line = preg_replace('|\s+|', ' ', $line); - preg_match( - '|\(.+[0-9]{4}-[0-9]{2}-[0-9]{2}\s+[0-9]+\)|', - $line, - $blameParts - ); - - if (isset($blameParts[0]) === false) { - return false; - } - - $parts = explode(' ', $blameParts[0]); - - if (count($parts) < 2) { - return false; - } - - $parts = array_slice($parts, 0, (count($parts) - 2)); - - return preg_replace('|\(|', '', implode($parts, ' ')); - - }//end getAuthor() - - - /** - * Gets the blame output. - * - * @param string $filename File to blame. - * - * @return array - */ - protected function getBlameContent($filename) - { - $cwd = getcwd(); - - if (PHP_CODESNIFFER_VERBOSITY > 0) { - echo 'Getting GIT blame info for '.basename($filename).'... '; - } - - $fileParts = explode('/', $filename); - $found = false; - $location = ''; - while (empty($fileParts) === false) { - array_pop($fileParts); - $location = implode($fileParts, '/'); - if (is_dir($location.'/.git') === true) { - $found = true; - break; - } - } - - if ($found === true) { - chdir($location); - } else { - echo 'ERROR: Could not locate .git directory '.PHP_EOL.PHP_EOL; - exit(2); - } - - $command = 'git blame --date=short '.$filename; - $handle = popen($command, 'r'); - if ($handle === false) { - echo 'ERROR: Could not execute "'.$command.'"'.PHP_EOL.PHP_EOL; - exit(2); - } - - $rawContent = stream_get_contents($handle); - fclose($handle); - - if (PHP_CODESNIFFER_VERBOSITY > 0) { - echo 'DONE'.PHP_EOL; - } - - $blames = explode("\n", $rawContent); - chdir($cwd); - - return $blames; - - }//end getBlameContent() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Reports/Hgblame.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Reports/Hgblame.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Reports/Hgblame.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Reports/Hgblame.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,134 +0,0 @@ - - * @copyright 2009 SQLI - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Mercurial report for PHP_CodeSniffer. - * - * PHP version 5 - * - * @category PHP - * @package PHP_CodeSniffer - * @author Ben Selby - * @copyright 2009 SQLI - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PHP_CodeSniffer_Reports_Hgblame extends PHP_CodeSniffer_Reports_VersionControl -{ - - /** - * The name of the report we want in the output - * - * @var string - */ - protected $reportName = 'MERCURIAL'; - - - /** - * Extract the author from a blame line. - * - * @param string $line Line to parse. - * - * @return mixed string or false if impossible to recover. - */ - protected function getAuthor($line) - { - $blameParts = array(); - $line = preg_replace('|\s+|', ' ', $line); - - preg_match( - '|(.+[0-9]{2}:[0-9]{2}:[0-9]{2}\s[0-9]{4}\s.[0-9]{4}:)|', - $line, - $blameParts - ); - - if (isset($blameParts[0]) === false) { - return false; - } - - $parts = explode(' ', $blameParts[0]); - - if (count($parts) < 6) { - return false; - } - - $parts = array_slice($parts, 0, (count($parts) - 6)); - - return trim(preg_replace('|<.+>|', '', implode($parts, ' '))); - - }//end getAuthor() - - - /** - * Gets the blame output. - * - * @param string $filename File to blame. - * - * @return array - */ - protected function getBlameContent($filename) - { - $cwd = getcwd(); - - if (PHP_CODESNIFFER_VERBOSITY > 0) { - echo 'Getting MERCURIAL blame info for '.basename($filename).'... '; - } - - $fileParts = explode('/', $filename); - $found = false; - $location = ''; - while (empty($fileParts) === false) { - array_pop($fileParts); - $location = implode($fileParts, '/'); - if (is_dir($location.'/.hg') === true) { - $found = true; - break; - } - } - - if ($found === true) { - chdir($location); - } else { - echo 'ERROR: Could not locate .hg directory '.PHP_EOL.PHP_EOL; - exit(2); - } - - $command = 'hg blame -u -d -v '.$filename; - $handle = popen($command, 'r'); - if ($handle === false) { - echo 'ERROR: Could not execute "'.$command.'"'.PHP_EOL.PHP_EOL; - exit(2); - } - - $rawContent = stream_get_contents($handle); - fclose($handle); - - if (PHP_CODESNIFFER_VERBOSITY > 0) { - echo 'DONE'.PHP_EOL; - } - - $blames = explode("\n", $rawContent); - chdir($cwd); - - return $blames; - - }//end getBlameContent() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Reports/Source.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Reports/Source.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Reports/Source.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Reports/Source.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,202 +0,0 @@ - - * @author Greg Sherwood - * @copyright 2009 SQLI - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Source report for PHP_CodeSniffer. - * - * PHP version 5 - * - * @category PHP - * @package PHP_CodeSniffer - * @author Gabriele Santini - * @author Greg Sherwood - * @copyright 2009 SQLI - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PHP_CodeSniffer_Reports_Source implements PHP_CodeSniffer_Report -{ - - - /** - * Prints the source of all errors and warnings. - * - * @param array $report Prepared report. - * @param boolean $showSources Show sources? - * @param int $width Maximum allowed lne width. - * @param boolean $toScreen Is the report being printed to screen? - * - * @return string - */ - public function generate( - $report, - $showSources=false, - $width=80, - $toScreen=true - ) { - $sources = array(); - $width = max($width, 70); - - $errorsShown = 0; - - foreach ($report['files'] as $filename => $file) { - foreach ($file['messages'] as $line => $lineErrors) { - foreach ($lineErrors as $column => $colErrors) { - foreach ($colErrors as $error) { - $errorsShown++; - - $source = $error['source']; - if (isset($sources[$source]) === false) { - $sources[$source] = 1; - } else { - $sources[$source]++; - } - } - } - } - } - - if ($errorsShown === 0) { - // Nothing to show. - return 0; - } - - asort($sources); - $sources = array_reverse($sources); - - echo PHP_EOL.'PHP CODE SNIFFER VIOLATION SOURCE SUMMARY'.PHP_EOL; - echo str_repeat('-', $width).PHP_EOL; - if ($showSources === true) { - echo 'SOURCE'.str_repeat(' ', ($width - 11)).'COUNT'.PHP_EOL; - echo str_repeat('-', $width).PHP_EOL; - } else { - echo 'STANDARD CATEGORY SNIFF'.str_repeat(' ', ($width - 40)).'COUNT'.PHP_EOL; - echo str_repeat('-', $width).PHP_EOL; - } - - foreach ($sources as $source => $count) { - if ($showSources === true) { - echo $source.str_repeat(' ', ($width - 5 - strlen($source))); - } else { - $parts = explode('.', $source); - - if (strlen($parts[0]) > 8) { - $parts[0] = substr($parts[0], 0, ((strlen($parts[0]) - 8) * -1)); - } - - echo $parts[0].str_repeat(' ', (10 - strlen($parts[0]))); - - $category = $this->makeFriendlyName($parts[1]); - if (strlen($category) > 18) { - $category = substr($category, 0, ((strlen($category) - 18) * -1)); - } - - echo $category.str_repeat(' ', (20 - strlen($category))); - - $sniff = $this->makeFriendlyName($parts[2]); - if (isset($parts[3]) === true) { - $name = $this->makeFriendlyName($parts[3]); - $name[0] = strtolower($name[0]); - $sniff .= ' '.$name; - } - - if (strlen($sniff) > ($width - 37)) { - $sniff = substr($sniff, 0, ($width - 37 - strlen($sniff))); - } - - echo $sniff.str_repeat(' ', ($width - 35 - strlen($sniff))); - }//end if - - echo $count.PHP_EOL; - }//end foreach - - echo str_repeat('-', $width).PHP_EOL; - echo 'A TOTAL OF '.$errorsShown.' SNIFF VIOLATION(S) '; - echo 'WERE FOUND IN '.count($sources).' SOURCE(S)'.PHP_EOL; - echo str_repeat('-', $width).PHP_EOL.PHP_EOL; - - if ($toScreen === true - && PHP_CODESNIFFER_INTERACTIVE === false - && class_exists('PHP_Timer', false) === true - ) { - echo PHP_Timer::resourceUsage().PHP_EOL.PHP_EOL; - } - - return $errorsShown; - - }//end generate() - - - /** - * Converts a camel caps name into a readable string. - * - * @param string $name The camel caps name to convert. - * - * @return string - */ - public function makeFriendlyName($name) - { - $friendlyName = ''; - $length = strlen($name); - - $lastWasUpper = false; - $lastWasNumeric = false; - for ($i = 0; $i < $length; $i++) { - if (is_numeric($name[$i]) === true) { - if ($lastWasNumeric === false) { - $friendlyName .= ' '; - } - - $lastWasUpper = false; - $lastWasNumeric = true; - } else { - $lastWasNumeric = false; - - $char = strtolower($name[$i]); - if ($char === $name[$i]) { - // Lowercase. - $lastWasUpper = false; - } else { - // Uppercase. - if ($lastWasUpper === false) { - $friendlyName .= ' '; - $next = $name[($i + 1)]; - if (strtolower($next) === $next) { - // Next char is lowercase so it is a word boundary. - $name[$i] = strtolower($name[$i]); - } - } - - $lastWasUpper = true; - } - }//end if - - $friendlyName .= $name[$i]; - }//end for - - $friendlyName = trim($friendlyName); - $friendlyName[0] = strtoupper($friendlyName[0]); - - return $friendlyName; - - }//end makeFriendlyName() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Reports/Summary.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Reports/Summary.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Reports/Summary.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Reports/Summary.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,132 +0,0 @@ - - * @author Greg Sherwood - * @copyright 2009 SQLI - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Summary report for PHP_CodeSniffer. - * - * PHP version 5 - * - * @category PHP - * @package PHP_CodeSniffer - * @author Gabriele Santini - * @author Greg Sherwood - * @copyright 2009 SQLI - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PHP_CodeSniffer_Reports_Summary implements PHP_CodeSniffer_Report -{ - - - /** - * Generates a summary of errors and warnings for each file processed. - * - * If verbose output is enabled, results are shown for all files, even if - * they have no errors or warnings. If verbose output is disabled, we only - * show files that have at least one warning or error. - * - * @param array $report Prepared report. - * @param boolean $showSources Show sources? - * @param int $width Maximum allowed lne width. - * @param boolean $toScreen Is the report being printed to screen? - * - * @return string - */ - public function generate( - $report, - $showSources=false, - $width=80, - $toScreen=true - ) { - $errorFiles = array(); - $width = max($width, 70); - - foreach ($report['files'] as $filename => $file) { - $numWarnings = $file['warnings']; - $numErrors = $file['errors']; - - // If verbose output is enabled, we show the results for all files, - // but if not, we only show files that had errors or warnings. - if (PHP_CODESNIFFER_VERBOSITY > 0 - || $numErrors > 0 - || $numWarnings > 0 - ) { - $errorFiles[$filename] = array( - 'warnings' => $numWarnings, - 'errors' => $numErrors, - ); - }//end if - }//end foreach - - if (empty($errorFiles) === true) { - // Nothing to print. - return 0; - } - - echo PHP_EOL.'PHP CODE SNIFFER REPORT SUMMARY'.PHP_EOL; - echo str_repeat('-', $width).PHP_EOL; - echo 'FILE'.str_repeat(' ', ($width - 20)).'ERRORS WARNINGS'.PHP_EOL; - echo str_repeat('-', $width).PHP_EOL; - - $totalErrors = 0; - $totalWarnings = 0; - $totalFiles = 0; - - foreach ($errorFiles as $file => $errors) { - $padding = ($width - 18 - strlen($file)); - if ($padding < 0) { - $file = '...'.substr($file, (($padding * -1) + 3)); - $padding = 0; - } - - echo $file.str_repeat(' ', $padding).' '; - echo $errors['errors']; - echo str_repeat(' ', (8 - strlen((string) $errors['errors']))); - echo $errors['warnings']; - echo PHP_EOL; - - $totalFiles++; - }//end foreach - - echo str_repeat('-', $width).PHP_EOL; - echo 'A TOTAL OF '.$report['totals']['errors'].' ERROR(S) '; - echo 'AND '.$report['totals']['warnings'].' WARNING(S) '; - - echo 'WERE FOUND IN '.$totalFiles.' FILE(S)'.PHP_EOL; - echo str_repeat('-', $width).PHP_EOL.PHP_EOL; - - if ($showSources === true) { - $source = new PHP_CodeSniffer_Reports_Source(); - $source->generate($report, $showSources, $width); - } - - if ($toScreen === true - && PHP_CODESNIFFER_INTERACTIVE === false - && class_exists('PHP_Timer', false) === true - ) { - echo PHP_Timer::resourceUsage().PHP_EOL.PHP_EOL; - } - - return ($report['totals']['errors'] + $report['totals']['warnings']); - - }//end generate() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Reports/Svnblame.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Reports/Svnblame.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Reports/Svnblame.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Reports/Svnblame.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,100 +0,0 @@ - - * @author Greg Sherwood - * @copyright 2009 SQLI - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Svnblame report for PHP_CodeSniffer. - * - * PHP version 5 - * - * @category PHP - * @package PHP_CodeSniffer - * @author Gabriele Santini - * @author Greg Sherwood - * @copyright 2009 SQLI - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PHP_CodeSniffer_Reports_Svnblame extends PHP_CodeSniffer_Reports_VersionControl -{ - - /** - * The name of the report we want in the output - * - * @var string - */ - protected $reportName = 'SVN'; - - - /** - * Extract the author from a blame line. - * - * @param string $line Line to parse. - * - * @return mixed string or false if impossible to recover. - */ - protected function getAuthor($line) - { - $blameParts = array(); - preg_match('|\s*([^\s]+)\s+([^\s]+)|', $line, $blameParts); - - if (isset($blameParts[2]) === false) { - return false; - } - - return $blameParts[2]; - - }//end getAuthor() - - - /** - * Gets the blame output. - * - * @param string $filename File to blame. - * - * @return array - */ - protected function getBlameContent($filename) - { - if (PHP_CODESNIFFER_VERBOSITY > 0) { - echo 'Getting SVN blame info for '.basename($filename).'... '; - } - - $command = 'svn blame '.$filename; - $handle = popen($command, 'r'); - if ($handle === false) { - echo 'ERROR: Could not execute "'.$command.'"'.PHP_EOL.PHP_EOL; - exit(2); - } - - $rawContent = stream_get_contents($handle); - fclose($handle); - - if (PHP_CODESNIFFER_VERBOSITY > 0) { - echo 'DONE'.PHP_EOL; - } - - $blames = explode("\n", $rawContent); - - return $blames; - - }//end getBlameContent() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Reports/VersionControl.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Reports/VersionControl.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Reports/VersionControl.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Reports/VersionControl.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,216 +0,0 @@ - - * @copyright 2009 SQLI - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Version control report base class for PHP_CodeSniffer. - * - * PHP version 5 - * - * @category PHP - * @package PHP_CodeSniffer - * @author Ben Selby - * @copyright 2009 SQLI - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.2.2 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -abstract class PHP_CodeSniffer_Reports_VersionControl implements PHP_CodeSniffer_Report -{ - - /** - * The name of the report we want in the output. - * - * @var string - */ - protected $reportName = 'VERSION CONTROL'; - - - /** - * Prints the author of all errors and warnings, as given by "version control blame". - * - * @param array $report Prepared report. - * @param boolean $showSources Show sources? - * @param integer $width Maximum allowed lne width. - * @param boolean $toScreen Is the report being printed to screen? - * - * @return string - */ - public function generate( - $report, - $showSources=false, - $width=80, - $toScreen=true - ) { - $authors = array(); - $praise = array(); - $sources = array(); - $width = max($width, 70); - - $errorsShown = 0; - - foreach ($report['files'] as $filename => $file) { - $blames = $this->getBlameContent($filename); - - foreach ($file['messages'] as $line => $lineErrors) { - $author = $this->getAuthor($blames[($line - 1)]); - if ($author === false) { - continue; - } - - if (isset($authors[$author]) === false) { - $authors[$author] = 0; - $praise[$author] = array( - 'good' => 0, - 'bad' => 0, - ); - } - - $praise[$author]['bad']++; - - foreach ($lineErrors as $column => $colErrors) { - foreach ($colErrors as $error) { - $errorsShown++; - $authors[$author]++; - - if ($showSources === true) { - $source = $error['source']; - if (isset($sources[$author][$source]) === false) { - $sources[$author][$source] = 1; - } else { - $sources[$author][$source]++; - } - } - } - } - - unset($blames[($line - 1)]); - }//end foreach - - // No go through and give the authors some credit for - // all the lines that do not have errors. - foreach ($blames as $line) { - $author = $this->getAuthor($line); - if (false === $author) { - continue; - } - - if (isset($authors[$author]) === false) { - // This author doesn't have any errors. - if (PHP_CODESNIFFER_VERBOSITY === 0) { - continue; - } - - $authors[$author] = 0; - $praise[$author] = array( - 'good' => 0, - 'bad' => 0, - ); - } - - $praise[$author]['good']++; - }//end foreach - }//end foreach - - if ($errorsShown === 0) { - // Nothing to show. - return 0; - } - - arsort($authors); - - echo PHP_EOL.'PHP CODE SNIFFER '.$this->reportName.' BLAME SUMMARY'.PHP_EOL; - echo str_repeat('-', $width).PHP_EOL; - if ($showSources === true) { - echo 'AUTHOR SOURCE'.str_repeat(' ', ($width - 43)).'(Author %) (Overall %) COUNT'.PHP_EOL; - echo str_repeat('-', $width).PHP_EOL; - } else { - echo 'AUTHOR'.str_repeat(' ', ($width - 34)).'(Author %) (Overall %) COUNT'.PHP_EOL; - echo str_repeat('-', $width).PHP_EOL; - } - - foreach ($authors as $author => $count) { - if ($praise[$author]['good'] === 0) { - $percent = 0; - } else { - $total = ($praise[$author]['bad'] + $praise[$author]['good']); - $percent = round(($praise[$author]['bad'] / $total * 100), 2); - } - - $overallPercent = '('.round((($count / $errorsShown) * 100), 2).')'; - $authorPercent = '('.$percent.')'; - $line = str_repeat(' ', (6 - strlen($count))).$count; - $line = str_repeat(' ', (12 - strlen($overallPercent))).$overallPercent.$line; - $line = str_repeat(' ', (11 - strlen($authorPercent))).$authorPercent.$line; - $line = $author.str_repeat(' ', ($width - strlen($author) - strlen($line))).$line; - - echo $line.PHP_EOL; - - if ($showSources === true && isset($sources[$author]) === true) { - $errors = $sources[$author]; - asort($errors); - $errors = array_reverse($errors); - - foreach ($errors as $source => $count) { - if ($source === 'count') { - continue; - } - - $line = str_repeat(' ', (5 - strlen($count))).$count; - echo ' '.$source.str_repeat(' ', ($width - 14 - strlen($source))).$line.PHP_EOL; - } - } - }//end foreach - - echo str_repeat('-', $width).PHP_EOL; - echo 'A TOTAL OF '.$errorsShown.' SNIFF VIOLATION(S) '; - echo 'WERE COMMITTED BY '.count($authors).' AUTHOR(S)'.PHP_EOL; - echo str_repeat('-', $width).PHP_EOL.PHP_EOL; - - if ($toScreen === true - && PHP_CODESNIFFER_INTERACTIVE === false - && class_exists('PHP_Timer', false) === true - ) { - echo PHP_Timer::resourceUsage().PHP_EOL.PHP_EOL; - } - - return $errorsShown; - - }//end generate() - - - /** - * Extract the author from a blame line. - * - * @param string $line Line to parse. - * - * @return mixed string or false if impossible to recover. - */ - abstract protected function getAuthor($line); - - - /** - * Gets the blame output. - * - * @param string $filename File to blame. - * - * @return array - */ - abstract protected function getBlameContent($filename); - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Reports/Xml.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Reports/Xml.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Reports/Xml.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Reports/Xml.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,107 +0,0 @@ - - * @author Greg Sherwood - * @copyright 2009 SQLI - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Xml report for PHP_CodeSniffer. - * - * PHP version 5 - * - * @category PHP - * @package PHP_CodeSniffer - * @author Gabriele Santini - * @author Greg Sherwood - * @copyright 2009 SQLI - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PHP_CodeSniffer_Reports_Xml implements PHP_CodeSniffer_Report -{ - - - /** - * Prints all violations for processed files, in a proprietary XML format. - * - * Errors and warnings are displayed together, grouped by file. - * - * @param array $report Prepared report. - * @param boolean $showSources Show sources? - * @param int $width Maximum allowed lne width. - * @param boolean $toScreen Is the report being printed to screen? - * - * @return string - */ - public function generate( - $report, - $showSources=false, - $width=80, - $toScreen=true - ) { - $out = new XMLWriter; - $out->openMemory(); - $out->setIndent(true); - $out->startDocument('1.0', 'UTF-8'); - $out->startElement('phpcs'); - $out->writeAttribute('version', '1.3.4'); - - $errorsShown = 0; - - foreach ($report['files'] as $filename => $file) { - if (empty($file['messages']) === true) { - continue; - } - - $out->startElement('file'); - $out->writeAttribute('name', $filename); - $out->writeAttribute('errors', $file['errors']); - $out->writeAttribute('warnings', $file['warnings']); - - foreach ($file['messages'] as $line => $lineErrors) { - foreach ($lineErrors as $column => $colErrors) { - foreach ($colErrors as $error) { - $error['type'] = strtolower($error['type']); - if (PHP_CODESNIFFER_ENCODING !== 'utf-8') { - $error['message'] = iconv(PHP_CODESNIFFER_ENCODING, 'utf-8', $error['message']); - } - - $out->startElement($error['type']); - $out->writeAttribute('line', $line); - $out->writeAttribute('column', $column); - $out->writeAttribute('source', $error['source']); - $out->writeAttribute('severity', $error['severity']); - $out->text($error['message']); - $out->endElement(); - - $errorsShown++; - } - } - }//end foreach - - $out->endElement(); - }//end foreach - - $out->endElement(); - echo $out->flush(); - - return $errorsShown; - - }//end generate() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Sniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Sniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Sniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Sniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,93 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Represents a PHP_CodeSniffer sniff for sniffing coding standards. - * - * A sniff registers what token types it wishes to listen for, then, when - * PHP_CodeSniffer encounters that token, the sniff is invoked and passed - * information about where the token was found in the stack, and the - * PHP_CodeSniffer file in which the token was found. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -interface PHP_CodeSniffer_Sniff -{ - - - /** - * Registers the tokens that this sniff wants to listen for. - * - * An example return value for a sniff that wants to listen for whitespace - * and any comments would be: - * - * - * return array( - * T_WHITESPACE, - * T_DOC_COMMENT, - * T_COMMENT, - * ); - * - * - * @return array(int) - * @see Tokens.php - */ - public function register(); - - - /** - * Called when one of the token types that this sniff is listening for - * is found. - * - * The stackPtr variable indicates where in the stack the token was found. - * A sniff can acquire information this token, along with all the other - * tokens within the stack by first acquiring the token stack: - * - * - * $tokens = $phpcsFile->getTokens(); - * echo 'Encountered a '.$tokens[$stackPtr]['type'].' token'; - * echo 'token information: '; - * print_r($tokens[$stackPtr]); - * - * - * If the sniff discovers an anomilty in the code, they can raise an error - * by calling addError() on the PHP_CodeSniffer_File object, specifying an error - * message and the position of the offending token: - * - * - * $phpcsFile->addError('Encountered an error', $stackPtr); - * - * - * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where the - * token was found. - * @param int $stackPtr The position in the PHP_CodeSniffer - * file's token stack where the token - * was found. - * - * @return void - */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr); - - -}//end interface - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/AbstractPatternSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/AbstractPatternSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/AbstractPatternSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/AbstractPatternSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,956 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -if (class_exists('PHP_CodeSniffer_Standards_IncorrectPatternException', true) === false) { - $error = 'Class PHP_CodeSniffer_Standards_IncorrectPatternException not found'; - throw new PHP_CodeSniffer_Exception($error); -} - -/** - * Processes pattern strings and checks that the code conforms to the pattern. - * - * This test essentially checks that code is correctly formatted with whitespace. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -abstract class PHP_CodeSniffer_Standards_AbstractPatternSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * The current file being checked. - * - * @var string - */ - protected $currFile = ''; - - /** - * The parsed patterns array. - * - * @var array - */ - private $_parsedPatterns = array(); - - /** - * Tokens that this sniff wishes to process outside of the patterns. - * - * @var array(int) - * @see registerSupplementary() - * @see processSupplementary() - */ - private $_supplementaryTokens = array(); - - /** - * If true, comments will be ignored if they are found in the code. - * - * @var boolean - */ - private $_ignoreComments = false; - - /** - * Positions in the stack where errors have occured. - * - * @var array() - */ - private $_errorPos = array(); - - - /** - * Constructs a PHP_CodeSniffer_Standards_AbstractPatternSniff. - * - * @param boolean $ignoreComments If true, comments will be ignored. - */ - public function __construct($ignoreComments=false) - { - $this->_ignoreComments = $ignoreComments; - $this->_supplementaryTokens = $this->registerSupplementary(); - - }//end __construct() - - - /** - * Registers the tokens to listen to. - * - * Classes extending AbstractPatternTest should implement the - * getPatterns() method to register the patterns they wish to test. - * - * @return array(int) - * @see process() - */ - public final function register() - { - $listenTypes = array(); - $patterns = $this->getPatterns(); - - foreach ($patterns as $pattern) { - $parsedPattern = $this->_parse($pattern); - - // Find a token position in the pattern that we can use - // for a listener token. - $pos = $this->_getListenerTokenPos($parsedPattern); - $tokenType = $parsedPattern[$pos]['token']; - $listenTypes[] = $tokenType; - - $patternArray = array( - 'listen_pos' => $pos, - 'pattern' => $parsedPattern, - 'pattern_code' => $pattern, - ); - - if (isset($this->_parsedPatterns[$tokenType]) === false) { - $this->_parsedPatterns[$tokenType] = array(); - } - - $this->_parsedPatterns[$tokenType][] = $patternArray; - - }//end foreach - - return array_unique(array_merge($listenTypes, $this->_supplementaryTokens)); - - }//end register() - - - /** - * Returns the token types that the specified pattern is checking for. - * - * Returned array is in the format: - * - * array( - * T_WHITESPACE => 0, // 0 is the position where the T_WHITESPACE token - * // should occur in the pattern. - * ); - * - * - * @param array $pattern The parsed pattern to find the acquire the token - * types from. - * - * @return array(int => int) - */ - private function _getPatternTokenTypes($pattern) - { - $tokenTypes = array(); - foreach ($pattern as $pos => $patternInfo) { - if ($patternInfo['type'] === 'token') { - if (isset($tokenTypes[$patternInfo['token']]) === false) { - $tokenTypes[$patternInfo['token']] = $pos; - } - } - } - - return $tokenTypes; - - }//end _getPatternTokenTypes() - - - /** - * Returns the position in the pattern that this test should register as - * a listener for the pattern. - * - * @param array $pattern The pattern to acquire the listener for. - * - * @return int The postition in the pattern that this test should register - * as the listener. - * @throws PHP_CodeSniffer_Exception If we could not determine a token - * to listen for. - */ - private function _getListenerTokenPos($pattern) - { - $tokenTypes = $this->_getPatternTokenTypes($pattern); - $tokenCodes = array_keys($tokenTypes); - $token = PHP_CodeSniffer_Tokens::getHighestWeightedToken($tokenCodes); - - // If we could not get a token. - if ($token === false) { - $error = 'Could not determine a token to listen for'; - throw new PHP_CodeSniffer_Exception($error); - } - - return $tokenTypes[$token]; - - }//end _getListenerTokenPos() - - - /** - * Processes the test. - * - * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where the - * token occured. - * @param int $stackPtr The postion in the tokens stack - * where the listening token type was - * found. - * - * @return void - * @see register() - */ - public final function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) - { - $file = $phpcsFile->getFilename(); - if ($this->currFile !== $file) { - // We have changed files, so clean up. - $this->_errorPos = array(); - $this->currFile = $file; - } - - $tokens = $phpcsFile->getTokens(); - - if (in_array($tokens[$stackPtr]['code'], $this->_supplementaryTokens) === true) { - $this->processSupplementary($phpcsFile, $stackPtr); - } - - $type = $tokens[$stackPtr]['code']; - - // If the type is not set, then it must have been a token registered - // with registerSupplementary(). - if (isset($this->_parsedPatterns[$type]) === false) { - return; - } - - $allErrors = array(); - - // Loop over each pattern that is listening to the current token type - // that we are processing. - foreach ($this->_parsedPatterns[$type] as $patternInfo) { - // If processPattern returns false, then the pattern that we are - // checking the code with must not be designed to check that code. - $errors = $this->processPattern($patternInfo, $phpcsFile, $stackPtr); - if ($errors === false) { - // The pattern didn't match. - continue; - } else if (empty($errors) === true) { - // The pattern matched, but there were no errors. - break; - } - - foreach ($errors as $stackPtr => $error) { - if (isset($this->_errorPos[$stackPtr]) === false) { - $this->_errorPos[$stackPtr] = true; - $allErrors[$stackPtr] = $error; - } - } - } - - foreach ($allErrors as $stackPtr => $error) { - $phpcsFile->addError($error, $stackPtr); - } - - }//end process() - - - /** - * Processes the pattern and verifies the code at $stackPtr. - * - * @param array $patternInfo Information about the pattern used - * for checking, which includes are - * parsed token representation of the - * pattern. - * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where the - * token occured. - * @param int $stackPtr The postion in the tokens stack where - * the listening token type was found. - * - * @return array(errors) - */ - protected function processPattern( - $patternInfo, - PHP_CodeSniffer_File $phpcsFile, - $stackPtr - ) { - $tokens = $phpcsFile->getTokens(); - $pattern = $patternInfo['pattern']; - $patternCode = $patternInfo['pattern_code']; - $errors = array(); - $found = ''; - - $ignoreTokens = array(T_WHITESPACE); - if ($this->_ignoreComments === true) { - $ignoreTokens - = array_merge($ignoreTokens, PHP_CodeSniffer_Tokens::$commentTokens); - } - - $origStackPtr = $stackPtr; - $hasError = false; - - if ($patternInfo['listen_pos'] > 0) { - $stackPtr--; - - for ($i = ($patternInfo['listen_pos'] - 1); $i >= 0; $i--) { - if ($pattern[$i]['type'] === 'token') { - if ($pattern[$i]['token'] === T_WHITESPACE) { - if ($tokens[$stackPtr]['code'] === T_WHITESPACE) { - $found = $tokens[$stackPtr]['content'].$found; - } - - // Only check the size of the whitespace if this is not - // the first token. We don't care about the size of - // leading whitespace, just that there is some. - if ($i !== 0) { - if ($tokens[$stackPtr]['content'] !== $pattern[$i]['value']) { - $hasError = true; - } - } - } else { - // Check to see if this important token is the same as the - // previous important token in the pattern. If it is not, - // then the pattern cannot be for this piece of code. - $prev = $phpcsFile->findPrevious( - $ignoreTokens, - $stackPtr, - null, - true - ); - - if ($prev === false - || $tokens[$prev]['code'] !== $pattern[$i]['token'] - ) { - return false; - } - - // If we skipped past some whitespace tokens, then add them - // to the found string. - $tokenContent = $phpcsFile->getTokensAsString( - ($prev + 1), - ($stackPtr - $prev - 1) - ); - - $found = $tokens[$prev]['content'].$tokenContent.$found; - - if (isset($pattern[($i - 1)]) === true - && $pattern[($i - 1)]['type'] === 'skip' - ) { - $stackPtr = $prev; - } else { - $stackPtr = ($prev - 1); - } - }//end if - } else if ($pattern[$i]['type'] === 'skip') { - // Skip to next piece of relevant code. - if ($pattern[$i]['to'] === 'parenthesis_closer') { - $to = 'parenthesis_opener'; - } else { - $to = 'scope_opener'; - } - - // Find the previous opener. - $next = $phpcsFile->findPrevious( - $ignoreTokens, - $stackPtr, - null, - true - ); - - if ($next === false || isset($tokens[$next][$to]) === false) { - // If there was not opener, then we must be - // using the wrong pattern. - return false; - } - - if ($to === 'parenthesis_opener') { - $found = '{'.$found; - } else { - $found = '('.$found; - } - - $found = '...'.$found; - - // Skip to the opening token. - $stackPtr = ($tokens[$next][$to] - 1); - } else if ($pattern[$i]['type'] === 'string') { - $found = 'abc'; - } else if ($pattern[$i]['type'] === 'newline') { - if ($this->_ignoreComments === true - && in_array($tokens[$stackPtr]['code'], PHP_CodeSniffer_Tokens::$commentTokens) === true - ) { - $startComment = $phpcsFile->findPrevious( - PHP_CodeSniffer_Tokens::$commentTokens, - ($stackPtr - 1), - null, - true - ); - - if ($tokens[$startComment]['line'] !== $tokens[($startComment + 1)]['line']) { - $startComment++; - } - - $tokenContent = $phpcsFile->getTokensAsString( - $startComment, - ($stackPtr - $startComment + 1) - ); - - $found = $tokenContent.$found; - $stackPtr = ($startComment - 1); - } - - if ($tokens[$stackPtr]['code'] === T_WHITESPACE) { - if ($tokens[$stackPtr]['content'] !== $phpcsFile->eolChar) { - $found = $tokens[$stackPtr]['content'].$found; - - // This may just be an indent that comes after a newline - // so check the token before to make sure. If it is a newline, we - // can ignore the error here. - if ($tokens[($stackPtr - 1)]['content'] !== $phpcsFile->eolChar) { - $hasError = true; - } else { - $stackPtr--; - } - } else { - $found = 'EOL'.$found; - } - } else { - $found = $tokens[$stackPtr]['content'].$found; - $hasError = true; - } - - if ($hasError === false && $pattern[($i - 1)]['type'] !== 'newline') { - // Make sure they only have 1 newline. - $prev = $phpcsFile->findPrevious($ignoreTokens, ($stackPtr - 1), null, true); - if ($prev !== false && $tokens[$prev]['line'] !== $tokens[$stackPtr]['line']) { - $hasError = true; - } - } - }//end if - }//end for - }//end if - - $stackPtr = $origStackPtr; - $lastAddedStackPtr = null; - $patternLen = count($pattern); - - for ($i = $patternInfo['listen_pos']; $i < $patternLen; $i++) { - if ($pattern[$i]['type'] === 'token') { - if ($pattern[$i]['token'] === T_WHITESPACE) { - if ($this->_ignoreComments === true) { - // If we are ignoring comments, check to see if this current - // token is a comment. If so skip it. - if (in_array($tokens[$stackPtr]['code'], PHP_CodeSniffer_Tokens::$commentTokens) === true) { - continue; - } - - // If the next token is a comment, the we need to skip the - // current token as we should allow a space before a - // comment for readability. - if (in_array($tokens[($stackPtr + 1)]['code'], PHP_CodeSniffer_Tokens::$commentTokens) === true) { - continue; - } - } - - $tokenContent = ''; - if ($tokens[$stackPtr]['code'] === T_WHITESPACE) { - if (isset($pattern[($i + 1)]) === false) { - // This is the last token in the pattern, so just compare - // the next token of content. - $tokenContent = $tokens[$stackPtr]['content']; - } else { - // Get all the whitespace to the next token. - $next = $phpcsFile->findNext( - PHP_CodeSniffer_Tokens::$emptyTokens, - $stackPtr, - null, - true - ); - - $tokenContent = $phpcsFile->getTokensAsString( - $stackPtr, - ($next - $stackPtr) - ); - - $lastAddedStackPtr = $stackPtr; - $stackPtr = $next; - } - - if ($stackPtr !== $lastAddedStackPtr) { - $found .= $tokenContent; - } - } else { - if ($stackPtr !== $lastAddedStackPtr) { - $found .= $tokens[$stackPtr]['content']; - $lastAddedStackPtr = $stackPtr; - } - }//end if - - if (isset($pattern[($i + 1)]) === true - && $pattern[($i + 1)]['type'] === 'skip' - ) { - // The next token is a skip token, so we just need to make - // sure the whitespace we found has *at least* the - // whitespace required. - if (strpos($tokenContent, $pattern[$i]['value']) !== 0) { - $hasError = true; - } - } else { - if ($tokenContent !== $pattern[$i]['value']) { - $hasError = true; - } - } - } else { - // Check to see if this important token is the same as the - // next important token in the pattern. If it is not, then - // the pattern cannot be for this piece of code. - $next = $phpcsFile->findNext( - $ignoreTokens, - $stackPtr, - null, - true - ); - - if ($next === false - || $tokens[$next]['code'] !== $pattern[$i]['token'] - ) { - // The next important token did not match the pattern. - return false; - } - - if ($lastAddedStackPtr !== null) { - if (($tokens[$next]['code'] === T_OPEN_CURLY_BRACKET - || $tokens[$next]['code'] === T_CLOSE_CURLY_BRACKET) - && isset($tokens[$next]['scope_condition']) === true - && $tokens[$next]['scope_condition'] > $lastAddedStackPtr - ) { - // This is a brace, but the owner of it is after the current - // token, which means it does not belong to any token in - // our pattern. This means the pattern is not for us. - return false; - } - - if (($tokens[$next]['code'] === T_OPEN_PARENTHESIS - || $tokens[$next]['code'] === T_CLOSE_PARENTHESIS) - && isset($tokens[$next]['parenthesis_owner']) === true - && $tokens[$next]['parenthesis_owner'] > $lastAddedStackPtr - ) { - // This is a bracket, but the owner of it is after the current - // token, which means it does not belong to any token in - // our pattern. This means the pattern is not for us. - return false; - } - }//end if - - // If we skipped past some whitespace tokens, then add them - // to the found string. - if (($next - $stackPtr) > 0) { - $hasComment = false; - for ($j = $stackPtr; $j < $next; $j++) { - $found .= $tokens[$j]['content']; - if (in_array($tokens[$j]['code'], PHP_CodeSniffer_Tokens::$commentTokens) === true) { - $hasComment = true; - } - } - - // If we are not ignoring comments, this additional - // whitespace or comment is not allowed. If we are - // ignoring comments, there needs to be at least one - // comment for this to be allowed. - if ($this->_ignoreComments === false - || ($this->_ignoreComments === true - && $hasComment === false) - ) { - $hasError = true; - } - - // Even when ignoring comments, we are not allowed to include - // newlines without the pattern specifying them, so - // everything should be on the same line. - if ($tokens[$next]['line'] !== $tokens[$stackPtr]['line']) { - $hasError = true; - } - }//end if - - if ($next !== $lastAddedStackPtr) { - $found .= $tokens[$next]['content']; - $lastAddedStackPtr = $next; - } - - if (isset($pattern[($i + 1)]) === true - && $pattern[($i + 1)]['type'] === 'skip' - ) { - $stackPtr = $next; - } else { - $stackPtr = ($next + 1); - } - }//end if - } else if ($pattern[$i]['type'] === 'skip') { - if ($pattern[$i]['to'] === 'unknown') { - $next = $phpcsFile->findNext( - $pattern[($i + 1)]['token'], - $stackPtr - ); - - if ($next === false) { - // Couldn't find the next token, sowe we must - // be using the wrong pattern. - return false; - } - - $found .= '...'; - $stackPtr = $next; - } else { - // Find the previous opener. - $next = $phpcsFile->findPrevious( - PHP_CodeSniffer_Tokens::$blockOpeners, - $stackPtr - ); - - if ($next === false - || isset($tokens[$next][$pattern[$i]['to']]) === false - ) { - // If there was not opener, then we must - // be using the wrong pattern. - return false; - } - - $found .= '...'; - if ($pattern[$i]['to'] === 'parenthesis_closer') { - $found .= ')'; - } else { - $found .= '}'; - } - - // Skip to the closing token. - $stackPtr = ($tokens[$next][$pattern[$i]['to']] + 1); - }//end if - } else if ($pattern[$i]['type'] === 'string') { - if ($tokens[$stackPtr]['code'] !== T_STRING) { - $hasError = true; - } - - if ($stackPtr !== $lastAddedStackPtr) { - $found .= 'abc'; - $lastAddedStackPtr = $stackPtr; - } - - $stackPtr++; - } else if ($pattern[$i]['type'] === 'newline') { - // Find the next token that contains a newline character. - $newline = 0; - for ($j = $stackPtr; $j < $phpcsFile->numTokens; $j++) { - if (strpos($tokens[$j]['content'], $phpcsFile->eolChar) !== false) { - $newline = $j; - break; - } - } - - if ($newline === 0) { - // We didn't find a newline character in the rest of the file. - $next = ($phpcsFile->numTokens - 1); - $hasError = true; - } else { - if ($this->_ignoreComments === false) { - // The newline character cannot be part of a comment. - if (in_array($tokens[$newline]['code'], PHP_CodeSniffer_Tokens::$commentTokens) === true) { - $hasError = true; - } - } - - if ($newline === $stackPtr) { - $next = ($stackPtr + 1); - } else { - // Check that there were no significant tokens that we - // skipped over to find our newline character. - $next = $phpcsFile->findNext( - $ignoreTokens, - $stackPtr, - null, - true - ); - - if ($next < $newline) { - // We skipped a non-ignored token. - $hasError = true; - } else { - $next = ($newline + 1); - } - } - }//end if - - if ($stackPtr !== $lastAddedStackPtr) { - $found .= $phpcsFile->getTokensAsString( - $stackPtr, - ($next - $stackPtr) - ); - - $diff = ($next - $stackPtr); - $lastAddedStackPtr = ($next - 1); - } - - $stackPtr = $next; - }//end if - }//end for - - if ($hasError === true) { - $error = $this->prepareError($found, $patternCode); - $errors[$origStackPtr] = $error; - } - - return $errors; - - }//end processPattern() - - - /** - * Prepares an error for the specified patternCode. - * - * @param string $found The actual found string in the code. - * @param string $patternCode The expected pattern code. - * - * @return string The error message. - */ - protected function prepareError($found, $patternCode) - { - $found = str_replace("\r\n", '\n', $found); - $found = str_replace("\n", '\n', $found); - $found = str_replace("\r", '\n', $found); - $found = str_replace('EOL', '\n', $found); - $expected = str_replace('EOL', '\n', $patternCode); - - $error = "Expected \"$expected\"; found \"$found\""; - - return $error; - - }//end prepareError() - - - /** - * Returns the patterns that should be checked. - * - * @return array(string) - */ - protected abstract function getPatterns(); - - - /** - * Registers any supplementary tokens that this test might wish to process. - * - * A sniff may wish to register supplementary tests when it wishes to group - * an arbitary validation that cannot be performed using a pattern, with - * other pattern tests. - * - * @return array(int) - * @see processSupplementary() - */ - protected function registerSupplementary() - { - return array(); - - }//end registerSupplementary() - - - /** - * Processes any tokens registered with registerSupplementary(). - * - * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where to - * process the skip. - * @param int $stackPtr The position in the tokens stack to - * process. - * - * @return void - * @see registerSupplementary() - */ - protected function processSupplementary( - PHP_CodeSniffer_File $phpcsFile, - $stackPtr - ) { - return; - - }//end processSupplementary() - - - /** - * Parses a pattern string into an array of pattern steps. - * - * @param string $pattern The pattern to parse. - * - * @return array The parsed pattern array. - * @see _createSkipPattern() - * @see _createTokenPattern() - */ - private function _parse($pattern) - { - $patterns = array(); - $length = strlen($pattern); - $lastToken = 0; - $firstToken = 0; - - for ($i = 0; $i < $length; $i++) { - - $specialPattern = false; - $isLastChar = ($i === ($length - 1)); - $oldFirstToken = $firstToken; - - if (substr($pattern, $i, 3) === '...') { - // It's a skip pattern. The skip pattern requires the - // content of the token in the "from" position and the token - // to skip to. - $specialPattern = $this->_createSkipPattern($pattern, ($i - 1)); - $lastToken = ($i - $firstToken); - $firstToken = ($i + 3); - $i = ($i + 2); - - if ($specialPattern['to'] !== 'unknown') { - $firstToken++; - } - } else if (substr($pattern, $i, 3) === 'abc') { - $specialPattern = array('type' => 'string'); - $lastToken = ($i - $firstToken); - $firstToken = ($i + 3); - $i = ($i + 2); - } else if (substr($pattern, $i, 3) === 'EOL') { - $specialPattern = array('type' => 'newline'); - $lastToken = ($i - $firstToken); - $firstToken = ($i + 3); - $i = ($i + 2); - } - - if ($specialPattern !== false || $isLastChar === true) { - // If we are at the end of the string, don't worry about a limit. - if ($isLastChar === true) { - // Get the string from the end of the last skip pattern, if any, - // to the end of the pattern string. - $str = substr($pattern, $oldFirstToken); - } else { - // Get the string from the end of the last special pattern, - // if any, to the start of this special pattern. - if ($lastToken === 0) { - // Note that if the last special token was zero characters ago, - // there will be nothing to process so we can skip this bit. - // This happens if you have something like: EOL... in your pattern. - $str = ''; - } else { - $str = substr($pattern, $oldFirstToken, $lastToken); - } - } - - if ($str !== '') { - $tokenPatterns = $this->_createTokenPattern($str); - foreach ($tokenPatterns as $tokenPattern) { - $patterns[] = $tokenPattern; - } - } - - // Make sure we don't skip the last token. - if ($isLastChar === false && $i === ($length - 1)) { - $i--; - } - }//end if - - // Add the skip pattern *after* we have processed - // all the tokens from the end of the last skip pattern - // to the start of this skip pattern. - if ($specialPattern !== false) { - $patterns[] = $specialPattern; - } - }//end for - - return $patterns; - - }//end _parse() - - - /** - * Creates a skip pattern. - * - * @param string $pattern The pattern being parsed. - * @param string $from The token content that the skip pattern starts from. - * - * @return array The pattern step. - * @see _createTokenPattern() - * @see _parse() - */ - private function _createSkipPattern($pattern, $from) - { - $skip = array('type' => 'skip'); - - $nestedParenthesis = 0; - $nestedBraces = 0; - for ($start = $from; $start >= 0; $start--) { - switch ($pattern[$start]) { - case '(': - if ($nestedParenthesis === 0) { - $skip['to'] = 'parenthesis_closer'; - } - - $nestedParenthesis--; - break; - case '{': - if ($nestedBraces === 0) { - $skip['to'] = 'scope_closer'; - } - - $nestedBraces--; - break; - case '}': - $nestedBraces++; - break; - case ')': - $nestedParenthesis++; - break; - } - - if (isset($skip['to']) === true) { - break; - } - } - - if (isset($skip['to']) === false) { - $skip['to'] = 'unknown'; - } - - return $skip; - - }//end _createSkipPattern() - - - /** - * Creates a token pattern. - * - * @param string $str The tokens string that the pattern should match. - * - * @return array The pattern step. - * @see _createSkipPattern() - * @see _parse() - */ - private function _createTokenPattern($str) - { - // Don't add a space after the closing php tag as it will add a new - // whitespace token. - $tokens = token_get_all(''); - - // Remove the 'token', - 'token' => $patternInfo['code'], - 'value' => $patternInfo['content'], - ); - } - - return $patterns; - - }//end _createTokenPattern() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/AbstractScopeSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/AbstractScopeSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/AbstractScopeSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/AbstractScopeSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,202 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * An AbstractScopeTest allows for tests that extend from this class to - * listen for tokens within a particluar scope. - * - * Below is a test that listens to methods that exist only within classes: - * - * class ClassScopeTest extends PHP_CodeSniffer_Standards_AbstractScopeSniff - * { - * public function __construct() - * { - * parent::__construct(array(T_CLASS), array(T_FUNCTION)); - * } - * - * protected function processTokenWithinScope(PHP_CodeSniffer_File $phpcsFile, $) - * { - * $className = $phpcsFile->getDeclarationName($currScope); - * echo 'encountered a method within class '.$className; - * } - * } - * - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -abstract class PHP_CodeSniffer_Standards_AbstractScopeSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * The token types that this test wishes to listen to within the scope. - * - * @var array() - */ - private $_tokens = array(); - - /** - * The type of scope opener tokens that this test wishes to listen to. - * - * @var string - */ - private $_scopeTokens = array(); - - /** - * True if this test should fire on tokens outside of the scope. - * - * @var boolean - */ - private $_listenOutside = false; - - - /** - * Constructs a new AbstractScopeTest. - * - * @param array $scopeTokens The type of scope the test wishes to listen to. - * @param array $tokens The tokens that the test wishes to listen to - * within the scope. - * @param boolean $listenOutside If true this test will also alert the - * extending class when a token is found outside - * the scope, by calling the - * processTokenOutideScope method. - * - * @see PHP_CodeSniffer.getValidScopeTokeners() - * @throws PHP_CodeSniffer_Exception If the specified tokens array is empty. - */ - public function __construct( - array $scopeTokens, - array $tokens, - $listenOutside=false - ) { - if (empty($scopeTokens) === true) { - $error = 'The scope tokens list cannot be empty'; - throw new PHP_CodeSniffer_Exception($error); - } - - if (empty($tokens) === true) { - $error = 'The tokens list cannot be empty'; - throw new PHP_CodeSniffer_Exception($error); - } - - $invalidScopeTokens = array_intersect($scopeTokens, $tokens); - if (empty($invalidScopeTokens) === false) { - $invalid = implode(', ', $invalidScopeTokens); - $error = "Scope tokens [$invalid] cant be in the tokens array"; - throw new PHP_CodeSniffer_Exception($error); - } - - $this->_listenOutside = $listenOutside; - $this->_scopeTokens = $scopeTokens; - $this->_tokens = $tokens; - - }//end __construct() - - - /** - * The method that is called to register the tokens this test wishes to - * listen to. - * - * DO NOT OVERRIDE THIS METHOD. Use the constructor of this class to register - * for the desired tokens and scope. - * - * @return array(int) - * @see __constructor() - */ - public final function register() - { - return $this->_tokens; - - }//end register() - - - /** - * Processes the tokens that this test is listening for. - * - * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found. - * @param int $stackPtr The position in the stack where this - * token was found. - * - * @return void - * @see processTokenWithinScope() - */ - public final function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - - $foundScope = false; - foreach ($tokens[$stackPtr]['conditions'] as $scope => $code) { - if (in_array($code, $this->_scopeTokens) === true) { - $this->processTokenWithinScope($phpcsFile, $stackPtr, $scope); - $foundScope = true; - } - } - - if ($this->_listenOutside === true && $foundScope === false) { - $this->processTokenOutsideScope($phpcsFile, $stackPtr); - } - - }//end process() - - - /** - * Processes a token that is found within the scope that this test is - * listening to. - * - * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found. - * @param int $stackPtr The position in the stack where this - * token was found. - * @param int $currScope The position in the tokens array that - * opened the scope that this test is - * listening for. - * - * @return void - */ - protected abstract function processTokenWithinScope( - PHP_CodeSniffer_File $phpcsFile, - $stackPtr, - $currScope - ); - - - /** - * Processes a token that is found within the scope that this test is - * listening to. - * - * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found. - * @param int $stackPtr The position in the stack where this - * token was found. - * - * @return void - */ - protected function processTokenOutsideScope( - PHP_CodeSniffer_File $phpcsFile, - $stackPtr - ) { - return; - - }//end processTokenOutsideScope() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/AbstractVariableSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/AbstractVariableSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/AbstractVariableSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/AbstractVariableSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,245 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -if (class_exists('PHP_CodeSniffer_Standards_AbstractScopeSniff', true) === false) { - $error = 'Class PHP_CodeSniffer_Standards_AbstractScopeSniff not found'; - throw new PHP_CodeSniffer_Exception($error); -} - -/** - * A class to find T_VARIABLE tokens. - * - * This class can distingush between normal T_VARIABLE tokens, and those tokens - * that represent class members. If a class member is encountered, then then - * processMemberVar method is called so the extending class can process it. If - * the token is found to be a normal T_VARIABLE token, then processVariable is - * called. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -abstract class PHP_CodeSniffer_Standards_AbstractVariableSniff extends PHP_CodeSniffer_Standards_AbstractScopeSniff -{ - - /** - * The end token of the current function that we are in. - * - * @var int - */ - private $_endFunction = -1; - - /** - * true if a function is currently open. - * - * @var boolean - */ - private $_functionOpen = false; - - /** - * The current PHP_CodeSniffer file that we are processing. - * - * @var PHP_CodeSniffer_File - */ - protected $currentFile = null; - - - /** - * Constructs an AbstractVariableTest. - */ - public function __construct() - { - $scopes = array( - T_CLASS, - T_INTERFACE, - ); - - $listen = array( - T_FUNCTION, - T_VARIABLE, - T_DOUBLE_QUOTED_STRING, - T_HEREDOC, - ); - - parent::__construct($scopes, $listen, true); - - }//end __construct() - - - /** - * Processes the token in the specified PHP_CodeSniffer_File. - * - * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where this - * token was found. - * @param int $stackPtr The position where the token was found. - * @param array $currScope The current scope opener token. - * - * @return void - */ - protected final function processTokenWithinScope( - PHP_CodeSniffer_File $phpcsFile, - $stackPtr, - $currScope - ) { - if ($this->currentFile !== $phpcsFile) { - $this->currentFile = $phpcsFile; - $this->_functionOpen = false; - $this->_endFunction = -1; - } - - $tokens = $phpcsFile->getTokens(); - - if ($stackPtr > $this->_endFunction) { - $this->_functionOpen = false; - } - - if ($tokens[$stackPtr]['code'] === T_FUNCTION - && $this->_functionOpen === false - ) { - $this->_functionOpen = true; - - $methodProps = $phpcsFile->getMethodProperties($stackPtr); - - // If the function is abstract, or is in an interface, - // then set the end of the function to it's closing semicolon. - if ($methodProps['is_abstract'] === true - || $tokens[$currScope]['code'] === T_INTERFACE - ) { - $this->_endFunction - = $phpcsFile->findNext(array(T_SEMICOLON), $stackPtr); - } else { - if (isset($tokens[$stackPtr]['scope_closer']) === false) { - $error = 'Possible parse error: non-abstract method defined as abstract'; - $phpcsFile->addWarning($error, $stackPtr); - return; - } - - $this->_endFunction = $tokens[$stackPtr]['scope_closer']; - } - } - - if ($tokens[$stackPtr]['code'] === T_DOUBLE_QUOTED_STRING - || $tokens[$stackPtr]['code'] === T_HEREDOC - ) { - // Check to see if this string has a variable in it. - $pattern = '|(?processVariableInString($phpcsFile, $stackPtr); - } - - return; - } - - if ($this->_functionOpen === true) { - if ($tokens[$stackPtr]['code'] === T_VARIABLE) { - $this->processVariable($phpcsFile, $stackPtr); - } - } else { - // What if we assign a member variable to another? - // ie. private $_count = $this->_otherCount + 1;. - $this->processMemberVar($phpcsFile, $stackPtr); - } - - }//end processTokenWithinScope() - - - /** - * Processes the token outside the scope in the file. - * - * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where this - * token was found. - * @param int $stackPtr The position where the token was found. - * - * @return void - */ - protected final function processTokenOutsideScope( - PHP_CodeSniffer_File $phpcsFile, - $stackPtr - ) { - $tokens = $phpcsFile->getTokens(); - // These variables are not member vars. - if ($tokens[$stackPtr]['code'] === T_VARIABLE) { - $this->processVariable($phpcsFile, $stackPtr); - } else if ($tokens[$stackPtr]['code'] === T_DOUBLE_QUOTED_STRING - || $tokens[$stackPtr]['code'] === T_HEREDOC - ) { - // Check to see if this string has a variable in it. - $pattern = '|(?processVariableInString($phpcsFile, $stackPtr); - } - } - - }//end processTokenOutsideScope() - - - /** - * Called to process class member vars. - * - * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where this - * token was found. - * @param int $stackPtr The position where the token was found. - * - * @return void - */ - abstract protected function processMemberVar( - PHP_CodeSniffer_File $phpcsFile, - $stackPtr - ); - - - /** - * Called to process normal member vars. - * - * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where this - * token was found. - * @param int $stackPtr The position where the token was found. - * - * @return void - */ - abstract protected function processVariable( - PHP_CodeSniffer_File $phpcsFile, - $stackPtr - ); - - - /** - * Called to process variables found in duoble quoted strings or heredocs. - * - * Note that there may be more than one variable in the string, which will - * result only in one call for the string or one call per line for heredocs. - * - * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where this - * token was found. - * @param int $stackPtr The position where the double quoted - * string was found. - * - * @return void - */ - abstract protected function processVariableInString( - PHP_CodeSniffer_File - $phpcsFile, - $stackPtr - ); - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Docs/Files/LineLengthStandard.xml php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Docs/Files/LineLengthStandard.xml --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Docs/Files/LineLengthStandard.xml 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Docs/Files/LineLengthStandard.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,7 +0,0 @@ - - - - - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Docs/Formatting/MultipleStatementAlignmentStandard.xml php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Docs/Formatting/MultipleStatementAlignmentStandard.xml --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Docs/Formatting/MultipleStatementAlignmentStandard.xml 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Docs/Formatting/MultipleStatementAlignmentStandard.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,56 +0,0 @@ - - - - - - - = (1 + 2); -$veryLongVarName = 'string'; -$var = foo($bar, $baz, $quux); - ]]> - - - = (1 + 2); -$veryLongVarName = 'string'; -$var = foo($bar, $baz, $quux); - ]]> - - - - - - - - += 1; -$veryLongVarName = 1; - ]]> - - - += 1; -$veryLongVarName = 1; - ]]> - - - - - = 1; -$veryLongVarName -= 1; - ]]> - - - = 1; -$veryLongVarName -= 1; - ]]> - - - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Docs/Functions/OpeningFunctionBraceBsdAllmanStandard.xml php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Docs/Functions/OpeningFunctionBraceBsdAllmanStandard.xml --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Docs/Functions/OpeningFunctionBraceBsdAllmanStandard.xml 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Docs/Functions/OpeningFunctionBraceBsdAllmanStandard.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ - - - - - - - { - ... -} - ]]> - - - { - ... -} - ]]> - - - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Docs/Functions/OpeningFunctionBraceKernighanRitchieStandard.xml php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Docs/Functions/OpeningFunctionBraceKernighanRitchieStandard.xml --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Docs/Functions/OpeningFunctionBraceKernighanRitchieStandard.xml 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Docs/Functions/OpeningFunctionBraceKernighanRitchieStandard.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ - - - - - - - { - ... -} - ]]> - - - { - ... -} - ]]> - - - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Docs/NamingConventions/UpperCaseConstantNameStandard.xml php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Docs/NamingConventions/UpperCaseConstantNameStandard.xml --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Docs/NamingConventions/UpperCaseConstantNameStandard.xml 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Docs/NamingConventions/UpperCaseConstantNameStandard.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ - - - - - - - FOO_CONSTANT', 'foo'); - -class FooClass -{ - const FOO_CONSTANT = 'foo'; -} - ]]> - - - Foo_Constant', 'foo'); - -class FooClass -{ - const foo_constant = 'foo'; -} - ]]> - - - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Docs/PHP/DisallowShortOpenTagStandard.xml php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Docs/PHP/DisallowShortOpenTagStandard.xml --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Docs/PHP/DisallowShortOpenTagStandard.xml 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Docs/PHP/DisallowShortOpenTagStandard.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,7 +0,0 @@ - - - to delimit PHP code, not the shorthand. This is the most portable way to include PHP code on differing operating systems and setups. - ]]> - - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Docs/PHP/LowerCaseConstantStandard.xml php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Docs/PHP/LowerCaseConstantStandard.xml --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Docs/PHP/LowerCaseConstantStandard.xml 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Docs/PHP/LowerCaseConstantStandard.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ - - - true, false and null constants must always be lowercase. - ]]> - - - - false || $var === null) { - $var = true; -} - ]]> - - - FALSE || $var === NULL) { - $var = TRUE; -} - ]]> - - - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Docs/PHP/UpperCaseConstantStandard.xml php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Docs/PHP/UpperCaseConstantStandard.xml --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Docs/PHP/UpperCaseConstantStandard.xml 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Docs/PHP/UpperCaseConstantStandard.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ - - - true, false and null constants must always be uppercase. - ]]> - - - - FALSE || $var === NULL) { - $var = TRUE; -} - ]]> - - - false || $var === null) { - $var = true; -} - ]]> - - - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Classes/DuplicateClassNameSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Classes/DuplicateClassNameSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Classes/DuplicateClassNameSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Classes/DuplicateClassNameSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,97 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Reports errors if the same class or interface name is used in multiple files. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Sniffs_Classes_DuplicateClassNameSniff implements PHP_CodeSniffer_MultiFileSniff -{ - - - /** - * Called once per script run to allow for processing of this sniff. - * - * @param array(PHP_CodeSniffer_File) $files The PHP_CodeSniffer files processed - * during the script run. - * - * @return void - */ - public function process(array $files) - { - $foundClasses = array(); - - foreach ($files as $phpcsFile) { - $tokens = $phpcsFile->getTokens(); - - $namespace = ''; - $stackPtr = $phpcsFile->findNext(array(T_CLASS, T_INTERFACE, T_NAMESPACE), 0); - while ($stackPtr !== false) { - // Keep track of what namespace we are in. - if ($tokens[$stackPtr]['code'] === T_NAMESPACE) { - $nsEnd = $phpcsFile->findNext( - array(T_NS_SEPARATOR, T_STRING, T_WHITESPACE), - ($stackPtr + 1), - null, - true - ); - - $namespace = trim($phpcsFile->getTokensAsString(($stackPtr + 1), ($nsEnd - $stackPtr - 1))); - $stackPtr = $nsEnd; - } else { - $nameToken = $phpcsFile->findNext(T_STRING, $stackPtr); - $name = $tokens[$nameToken]['content']; - if ($namespace !== '') { - $name = $namespace.'\\'.$name; - } - - $compareName = strtolower($name); - if (isset($foundClasses[$compareName]) === true) { - $type = strtolower($tokens[$stackPtr]['content']); - $file = $foundClasses[$compareName]['file']; - $line = $foundClasses[$compareName]['line']; - $error = 'Duplicate %s name "%s" found; first defined in %s on line %s'; - $data = array( - $type, - $name, - $file, - $line, - ); - $phpcsFile->addWarning($error, $stackPtr, 'Found', $data); - } else { - $foundClasses[$compareName] = array( - 'file' => $phpcsFile->getFilename(), - 'line' => $tokens[$stackPtr]['line'], - ); - } - } - - $stackPtr = $phpcsFile->findNext(array(T_CLASS, T_INTERFACE, T_NAMESPACE), ($stackPtr + 1)); - }//end while - - }//end foreach - - }//end process() - - -}//end class - -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/EmptyStatementSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/EmptyStatementSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/EmptyStatementSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/EmptyStatementSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,128 +0,0 @@ - - * @author Manuel Pichler - * @copyright 2007-2008 Manuel Pichler. All rights reserved. - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * This sniff class detected empty statement. - * - * This sniff implements the common algorithm for empty statement body detection. - * A body is considered as empty if it is completely empty or it only contains - * whitespace characters and|or comments. - * - * - * stmt { - * // foo - * } - * stmt (conditions) { - * // foo - * } - * - * - * Statements covered by this sniff are catch, do, else, - * elsif, for, foreach, if, switch, try - * and while. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Manuel Pichler - * @copyright 2007-2008 Manuel Pichler. All rights reserved. - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Sniffs_CodeAnalysis_EmptyStatementSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * List of block tokens that this sniff covers. - * - * The key of this hash identifies the required token while the boolean - * value says mark an error or mark a warning. - * - * @var array - */ - protected $checkedTokens = array( - T_CATCH => true, - T_DO => false, - T_ELSE => false, - T_ELSEIF => false, - T_FOR => false, - T_FOREACH => false, - T_IF => false, - T_SWITCH => false, - T_TRY => false, - T_WHILE => false, - ); - - - /** - * Registers the tokens that this sniff wants to listen for. - * - * @return array(integer) - */ - public function register() - { - return array_keys($this->checkedTokens); - - }//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(); - $token = $tokens[$stackPtr]; - - // Skip for-statements without body. - if (isset($token['scope_opener']) === false) { - return; - } - - $next = ++$token['scope_opener']; - $end = --$token['scope_closer']; - - $emptyBody = true; - for (; $next <= $end; ++$next) { - if (in_array($tokens[$next]['code'], PHP_CodeSniffer_Tokens::$emptyTokens) === false) { - $emptyBody = false; - break; - } - } - - if ($emptyBody === true) { - // Get token identifier. - $name = $phpcsFile->getTokensAsString($stackPtr, 1); - $error = 'Empty %s statement detected'; - $data = array(strtoupper($name)); - if ($this->checkedTokens[$token['code']] === true) { - $phpcsFile->addError($error, $stackPtr, 'NotAllowed', $data); - } else { - $phpcsFile->addWarning($error, $stackPtr, 'NotAllowedWarning', $data); - } - } - - }//end process() - - -}//end class - -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/ForLoopShouldBeWhileLoopSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/ForLoopShouldBeWhileLoopSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/ForLoopShouldBeWhileLoopSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/ForLoopShouldBeWhileLoopSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,100 +0,0 @@ - - * @author Manuel Pichler - * @copyright 2007-2008 Manuel Pichler. All rights reserved. - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Detects for-loops that can be simplified to a while-loop. - * - * This rule is based on the PMD rule catalog. Detects for-loops that can be - * simplified as a while-loop. - * - * - * class Foo - * { - * public function bar($x) - * { - * for (;true;) true; // No Init or Update part, may as well be: while (true) - * } - * } - * - * - * @category PHP - * @package PHP_CodeSniffer - * @author Manuel Pichler - * @copyright 2007-2008 Manuel Pichler. All rights reserved. - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Sniffs_CodeAnalysis_ForLoopShouldBeWhileLoopSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * Registers the tokens that this sniff wants to listen for. - * - * @return array(integer) - */ - public function register() - { - return array(T_FOR); - - }//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(); - $token = $tokens[$stackPtr]; - - // Skip invalid statement. - if (isset($token['parenthesis_opener']) === false) { - return; - } - - $next = ++$token['parenthesis_opener']; - $end = --$token['parenthesis_closer']; - - $parts = array(0, 0, 0); - $index = 0; - - for (; $next <= $end; ++$next) { - $code = $tokens[$next]['code']; - if ($code === T_SEMICOLON) { - ++$index; - } else if (in_array($code, PHP_CodeSniffer_Tokens::$emptyTokens) === false) { - ++$parts[$index]; - } - } - - if ($parts[0] === 0 && $parts[2] === 0 && $parts[1] > 0) { - $error = 'This FOR loop can be simplified to a WHILE loop'; - $phpcsFile->addWarning($error, $stackPtr, 'CanSimplify'); - } - - }//end process() - - -}//end class - -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/ForLoopWithTestFunctionCallSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/ForLoopWithTestFunctionCallSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/ForLoopWithTestFunctionCallSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/ForLoopWithTestFunctionCallSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,113 +0,0 @@ - - * @author Manuel Pichler - * @copyright 2007-2008 Manuel Pichler. All rights reserved. - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Detects for-loops that use a function call in the test expression. - * - * This rule is based on the PMD rule catalog. Detects for-loops that use a - * function call in the test expression. - * - * - * class Foo - * { - * public function bar($x) - * { - * $a = array(1, 2, 3, 4); - * for ($i = 0; $i < count($a); $i++) { - * $a[$i] *= $i; - * } - * } - * } - * - * - * @category PHP - * @package PHP_CodeSniffer - * @author Manuel Pichler - * @copyright 2007-2008 Manuel Pichler. All rights reserved. - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Sniffs_CodeAnalysis_ForLoopWithTestFunctionCallSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * Registers the tokens that this sniff wants to listen for. - * - * @return array(integer) - */ - public function register() - { - return array(T_FOR); - - }//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(); - $token = $tokens[$stackPtr]; - - // Skip invalid statement. - if (isset($token['parenthesis_opener']) === false) { - return; - } - - $next = ++$token['parenthesis_opener']; - $end = --$token['parenthesis_closer']; - - $position = 0; - - for (; $next <= $end; ++$next) { - $code = $tokens[$next]['code']; - if ($code === T_SEMICOLON) { - ++$position; - } - - if ($position < 1) { - continue; - } else if ($position > 1) { - break; - } else if ($code !== T_VARIABLE && $code !== T_STRING) { - continue; - } - - // Find next non empty token, if it is a open curly brace we have a - // function call. - $index = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($next + 1), null, true); - - if ($tokens[$index]['code'] === T_OPEN_PARENTHESIS) { - $error = 'Avoid function calls in a FOR loop test part'; - $phpcsFile->addWarning($error, $stackPtr, 'NotAllowed'); - break; - } - }//end for - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/JumbledIncrementerSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/JumbledIncrementerSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/JumbledIncrementerSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/JumbledIncrementerSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,148 +0,0 @@ - - * @author Manuel Pichler - * @copyright 2007-2008 Manuel Pichler. All rights reserved. - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Detects incrementer jumbling in for loops. - * - * This rule is based on the PMD rule catalog. The jumbling incrementer sniff - * detects the usage of one and the same incrementer into an outer and an inner - * loop. Even it is intended this is confusing code. - * - * - * class Foo - * { - * public function bar($x) - * { - * for ($i = 0; $i < 10; $i++) - * { - * for ($k = 0; $k < 20; $i++) - * { - * echo 'Hello'; - * } - * } - * } - * } - * - * - * @category PHP - * @package PHP_CodeSniffer - * @author Manuel Pichler - * @copyright 2007-2008 Manuel Pichler. All rights reserved. - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Sniffs_CodeAnalysis_JumbledIncrementerSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * Registers the tokens that this sniff wants to listen for. - * - * @return array(integer) - */ - public function register() - { - return array(T_FOR); - - }//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(); - $token = $tokens[$stackPtr]; - - // Skip for-loop without body. - if (isset($token['scope_opener']) === false) { - return; - } - - // Find incrementors for outer loop. - $outer = $this->findIncrementers($tokens, $token); - - // Skip if empty. - if (count($outer) === 0) { - return; - } - - // Find nested for loops. - $start = ++$token['scope_opener']; - $end = --$token['scope_closer']; - - for (; $start <= $end; ++$start) { - if ($tokens[$start]['code'] !== T_FOR) { - continue; - } - - $inner = $this->findIncrementers($tokens, $tokens[$start]); - $diff = array_intersect($outer, $inner); - - if (count($diff) !== 0) { - $error = 'Loop incrementor (%s) jumbling with inner loop'; - $data = array(join(', ', $diff)); - $phpcsFile->addWarning($error, $stackPtr, 'Found', $data); - } - } - - }//end process() - - - /** - * Get all used variables in the incrementer part of a for statement. - * - * @param array(integer=>array) $tokens Array with all code sniffer tokens. - * @param array(string=>mixed) $token Current for loop token - * - * @return array(string) List of all found incrementer variables. - */ - protected function findIncrementers(array $tokens, array $token) - { - // Skip invalid statement. - if (isset($token['parenthesis_opener']) === false) { - return array(); - } - - $start = ++$token['parenthesis_opener']; - $end = --$token['parenthesis_closer']; - - $incrementers = array(); - $semicolons = 0; - for ($next = $start; $next <= $end; ++$next) { - $code = $tokens[$next]['code']; - if ($code === T_SEMICOLON) { - ++$semicolons; - } else if ($semicolons === 2 && $code === T_VARIABLE) { - $incrementers[] = $tokens[$next]['content']; - } - } - - return $incrementers; - - }//end findIncrementers() - - -}//end class - -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/UnconditionalIfStatementSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/UnconditionalIfStatementSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/UnconditionalIfStatementSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/UnconditionalIfStatementSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,106 +0,0 @@ - - * @author Manuel Pichler - * @copyright 2007-2008 Manuel Pichler. All rights reserved. - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Detects unconditional if- and elseif-statements. - * - * This rule is based on the PMD rule catalog. The Unconditional If Statment - * sniff detects statement conditions that are only set to one of the constant - * values true or false - * - * - * class Foo - * { - * public function close() - * { - * if (true) - * { - * // ... - * } - * } - * } - * - * - * @category PHP - * @package PHP_CodeSniffer - * @author Manuel Pichler - * @copyright 2007-2008 Manuel Pichler. All rights reserved. - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Sniffs_CodeAnalysis_UnconditionalIfStatementSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * Registers the tokens that this sniff wants to listen for. - * - * @return array(integer) - */ - public function register() - { - return array( - T_IF, - T_ELSEIF, - ); - - }//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(); - $token = $tokens[$stackPtr]; - - // Skip for-loop without body. - if (isset($token['parenthesis_opener']) === false) { - return; - } - - $next = ++$token['parenthesis_opener']; - $end = --$token['parenthesis_closer']; - - $goodCondition = false; - for (; $next <= $end; ++$next) { - $code = $tokens[$next]['code']; - - if (in_array($code, PHP_CodeSniffer_Tokens::$emptyTokens) === true) { - continue; - } else if ($code !== T_TRUE && $code !== T_FALSE) { - $goodCondition = true; - } - } - - if ($goodCondition === false) { - $error = 'Avoid IF statements that are always true or false'; - $phpcsFile->addWarning($error, $stackPtr, 'Found'); - } - - }//end process() - - -}//end class - -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/UnnecessaryFinalModifierSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/UnnecessaryFinalModifierSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/UnnecessaryFinalModifierSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/UnnecessaryFinalModifierSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,98 +0,0 @@ - - * @author Manuel Pichler - * @copyright 2007-2008 Manuel Pichler. All rights reserved. - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Detects unnecessary final modifiers inside of final classes. - * - * This rule is based on the PMD rule catalog. The Unnecessary Final Modifier - * sniff detects the use of the final modifier inside of a final class which - * is unnecessary. - * - * - * final class Foo - * { - * public final function bar() - * { - * } - * } - * - * - * @category PHP - * @package PHP_CodeSniffer - * @author Manuel Pichler - * @copyright 2007-2008 Manuel Pichler. All rights reserved. - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Sniffs_CodeAnalysis_UnnecessaryFinalModifierSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * Registers the tokens that this sniff wants to listen for. - * - * @return array(integer) - */ - public function register() - { - return array(T_CLASS); - - }//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(); - $token = $tokens[$stackPtr]; - - // Skip for-statements without body. - if (isset($token['scope_opener']) === false) { - return; - } - - // Fetch previous token. - $prev = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true); - - // Skip for non final class. - if ($prev === false || $tokens[$prev]['code'] !== T_FINAL) { - return; - } - - $next = ++$token['scope_opener']; - $end = --$token['scope_closer']; - - for (; $next <= $end; ++$next) { - if ($tokens[$next]['code'] === T_FINAL) { - $error = 'Unnecessary FINAL modifier in FINAL class'; - $phpcsFile->addWarning($error, $next, 'Found'); - } - } - - }//end process() - - -}//end class - -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,169 +0,0 @@ - - * @author Manuel Pichler - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Checks the for unused function parameters. - * - * This sniff checks that all function parameters are used in the function body. - * One exception is made for empty function bodies or function bodies that only - * contain comments. This could be usefull for the classes that implement an - * interface that defines multiple methods but the implementation only needs some - * of them. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Manuel Pichler - * @author Greg Sherwood - * @copyright 2007-2008 Manuel Pichler. All rights reserved. - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Sniffs_CodeAnalysis_UnusedFunctionParameterSniff 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(); - $token = $tokens[$stackPtr]; - - // Skip broken function declarations. - if (isset($token['scope_opener']) === false || isset($token['parenthesis_opener']) === false) { - return; - } - - $params = array(); - foreach ($phpcsFile->getMethodParameters($stackPtr) as $param) { - $params[$param['name']] = $stackPtr; - } - - $next = ++$token['scope_opener']; - $end = --$token['scope_closer']; - - $foundContent = false; - - for (; $next <= $end; ++$next) { - $token = $tokens[$next]; - $code = $token['code']; - - // Ignorable tokens. - if (in_array($code, PHP_CodeSniffer_Tokens::$emptyTokens) === true) { - continue; - } - - if ($foundContent === false) { - // A throw statement as the first content indicates an interface method. - if ($code === T_THROW) { - return; - } - - // A return statement as the first content indicates an interface method. - if ($code === T_RETURN) { - $tmp = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($next + 1), null, true); - if ($tmp === false) { - return; - } - - // There is a return. - if ($tokens[$tmp]['code'] === T_SEMICOLON) { - return; - } - - $tmp = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($tmp + 1), null, true); - if ($tmp !== false && $tokens[$tmp]['code'] === T_SEMICOLON) { - // There is a return . - return; - } - }//end if - }//end if - - $foundContent = true; - - if ($code === T_VARIABLE && isset($params[$token['content']]) === true) { - unset($params[$token['content']]); - } else if ($code === T_DOUBLE_QUOTED_STRING - || $code === T_START_HEREDOC - || $code === T_START_NOWDOC - ) { - // Tokenize strings that can contain variables. - // Make sure the string is re-joined if it occurs over multiple lines. - $validTokens = array( - T_HEREDOC, - T_NOWDOC, - T_END_HEREDOC, - T_END_NOWDOC, - T_DOUBLE_QUOTED_STRING, - ); - $validTokens = array_merge($validTokens, PHP_CodeSniffer_Tokens::$emptyTokens); - - $content = $token['content']; - for ($i = ($next + 1); $i <= $end; $i++) { - if (in_array($tokens[$i]['code'], $validTokens) === true) { - $content .= $tokens[$i]['content']; - $next++; - } else { - break; - } - } - - $stringTokens = token_get_all(sprintf('', $content)); - foreach ($stringTokens as $stringToken) { - if (is_array($stringToken) === false || $stringToken[0] !== T_VARIABLE ) { - continue; - } - - if (isset($params[$stringToken[1]]) === true) { - unset($params[$stringToken[1]]); - } - } - }//end if - }//end for - - if ($foundContent === true && count($params) > 0) { - foreach ($params as $paramName => $position) { - $error = 'The method parameter %s is never used'; - $data = array($paramName); - $phpcsFile->addWarning($error, $position, 'Found', $data); - } - } - - }//end process() - - -}//end class - -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/UselessOverridingMethodSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/UselessOverridingMethodSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/UselessOverridingMethodSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/UselessOverridingMethodSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,180 +0,0 @@ - - * @author Manuel Pichler - * @copyright 2007-2008 Manuel Pichler. All rights reserved. - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Detects unnecessary overriden methods that simply call their parent. - * - * This rule is based on the PMD rule catalog. The Useless Overriding Method - * sniff detects the use of methods that only call their parent classes's method - * with the same name and arguments. These methods are not required. - * - * - * class FooBar { - * public function __construct($a, $b) { - * parent::__construct($a, $b); - * } - * } - * - * - * @category PHP - * @package PHP_CodeSniffer - * @author Manuel Pichler - * @copyright 2007-2008 Manuel Pichler. All rights reserved. - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Sniffs_CodeAnalysis_UselessOverridingMethodSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * Registers the tokens that this sniff wants to listen for. - * - * @return array(integer) - */ - 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(); - $token = $tokens[$stackPtr]; - - // Skip function without body. - if (isset($token['scope_opener']) === false) { - return; - } - - // Get function name. - $methodName = $phpcsFile->getDeclarationName($stackPtr); - - // Get all parameters from method signature. - $signature = array(); - foreach ($phpcsFile->getMethodParameters($stackPtr) as $param) { - $signature[] = $param['name']; - } - - $next = ++$token['scope_opener']; - $end = --$token['scope_closer']; - - for (; $next <= $end; ++$next) { - $code = $tokens[$next]['code']; - - if (in_array($code, PHP_CodeSniffer_Tokens::$emptyTokens) === true) { - continue; - } else if ($code === T_RETURN) { - continue; - } - - break; - } - - // Any token except 'parent' indicates correct code. - if ($tokens[$next]['code'] !== T_PARENT) { - return; - } - - // Find next non empty token index, should be double colon. - $next = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($next + 1), null, true); - - // Skip for invalid code. - if ($next === false || $tokens[$next]['code'] !== T_DOUBLE_COLON) { - return; - } - - // Find next non empty token index, should be the function name. - $next = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($next + 1), null, true); - - // Skip for invalid code or other method. - if ($next === false || $tokens[$next]['content'] !== $methodName) { - return; - } - - // Find next non empty token index, should be the open parenthesis. - $next = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($next + 1), null, true); - - // Skip for invalid code. - if ($next === false || $tokens[$next]['code'] !== T_OPEN_PARENTHESIS) { - return; - } - - $validParameterTypes = array( - T_VARIABLE, - T_LNUMBER, - T_CONSTANT_ENCAPSED_STRING, - ); - - $parameters = array(''); - $parenthesisCount = 1; - $count = count($tokens); - for (++$next; $next < $count; ++$next) { - $code = $tokens[$next]['code']; - - if ($code === T_OPEN_PARENTHESIS) { - ++$parenthesisCount; - } else if ($code === T_CLOSE_PARENTHESIS) { - --$parenthesisCount; - } else if ($parenthesisCount === 1 && $code === T_COMMA) { - $parameters[] = ''; - } else if (in_array($code, PHP_CodeSniffer_Tokens::$emptyTokens) === false) { - $parameters[(count($parameters) - 1)] .= $tokens[$next]['content']; - } - - if ($parenthesisCount === 0) { - break; - } - }//end for - - $next = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($next + 1), null, true); - if ($next === false || $tokens[$next]['code'] !== T_SEMICOLON) { - return; - } - - // Check rest of the scope. - for (++$next; $next <= $end; ++$next) { - $code = $tokens[$next]['code']; - // Skip for any other content. - if (in_array($code, PHP_CodeSniffer_Tokens::$emptyTokens) === false) { - return; - } - } - - $parameters = array_map('trim', $parameters); - $parameters = array_filter($parameters); - - if (count($parameters) === count($signature) && $parameters === $signature) { - $phpcsFile->addWarning('Useless method overriding detected', $stackPtr, 'Found'); - } - - }//end process() - - -}//end class - -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Commenting/FixmeSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Commenting/FixmeSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Commenting/FixmeSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Commenting/FixmeSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,92 +0,0 @@ - - * @author Sam Graham - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Generic_Sniffs_Commenting_FixmeSniff. - * - * Warns about FIXME comments. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Sam Graham - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Sniffs_Commenting_FixmeSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - ); - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return PHP_CodeSniffer_Tokens::$commentTokens; - - }//end register() - - - /** - * Processes this sniff, 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(); - - $content = $tokens[$stackPtr]['content']; - $matches = array(); - if (preg_match('|[^a-z]+fixme[^a-z]+(.*)|i', $content, $matches) !== 0) { - // Clear whitespace and some common characters not required at - // the end of a fixme message to make the error more informative. - $type = 'CommentFound'; - $fixmeMessage = trim($matches[1]); - $fixmeMessage = trim($fixmeMessage, '[]().'); - $error = 'Comment refers to a FIXME task'; - $data = array($fixmeMessage); - if ($fixmeMessage !== '') { - $type = 'TaskFound'; - $error .= ' "%s"'; - } - - $phpcsFile->addError($error, $stackPtr, $type, $data); - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Commenting/TodoSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Commenting/TodoSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Commenting/TodoSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Commenting/TodoSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,90 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Generic_Sniffs_Commenting_TodoSniff. - * - * Warns about TODO comments. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Sniffs_Commenting_TodoSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - ); - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return PHP_CodeSniffer_Tokens::$commentTokens; - - }//end register() - - - /** - * Processes this sniff, 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(); - - $content = $tokens[$stackPtr]['content']; - $matches = Array(); - if (preg_match('|[^a-z]+todo[^a-z]+(.*)|i', $content, $matches) !== 0) { - // Clear whitespace and some common characters not required at - // the end of a to-do message to make the warning more informative. - $type = 'CommentFound'; - $todoMessage = trim($matches[1]); - $todoMessage = trim($todoMessage, '[]().'); - $error = 'Comment refers to a TODO task'; - $data = array($todoMessage); - if ($todoMessage !== '') { - $type = 'TaskFound'; - $error .= ' "%s"'; - } - - $phpcsFile->addWarning($error, $stackPtr, $type, $data); - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,120 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Generic_Sniffs_ControlStructures_InlineControlStructureSniff. - * - * Verifies that inline control statements are not present. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Sniffs_ControlStructures_InlineControlStructureSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - ); - - /** - * If true, an error will be thrown; otherwise a warning. - * - * @var bool - */ - public $error = true; - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array( - T_IF, - T_ELSE, - T_FOREACH, - T_WHILE, - T_DO, - T_SWITCH, - T_FOR, - ); - - }//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(); - - if (isset($tokens[$stackPtr]['scope_opener']) === false) { - // Ignore the ELSE in ELSE IF. We'll process the IF part later. - if (($tokens[$stackPtr]['code'] === T_ELSE) && ($tokens[($stackPtr + 2)]['code'] === T_IF)) { - return; - } - - if ($tokens[$stackPtr]['code'] === T_WHILE) { - // This could be from a DO WHILE, which doesn't have an opening brace. - $lastContent = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); - if ($tokens[$lastContent]['code'] === T_CLOSE_CURLY_BRACKET) { - $brace = $tokens[$lastContent]; - if (isset($brace['scope_condition']) === true) { - $condition = $tokens[$brace['scope_condition']]; - if ($condition['code'] === T_DO) { - return; - } - } - } - } - - // This is a control structure without an opening brace, - // so it is an inline statement. - if ($this->error === true) { - $phpcsFile->addError('Inline control structures are not allowed', $stackPtr, 'NotAllowed'); - } else { - $phpcsFile->addWarning('Inline control structures are discouraged', $stackPtr, 'Discouraged'); - } - - return; - }//end if - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Debug/ClosureLinterSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Debug/ClosureLinterSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Debug/ClosureLinterSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Debug/ClosureLinterSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,139 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Generic_Sniffs_Debug_ClosureLinterSniff. - * - * Runs gjslint on the file. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Sniffs_Debug_ClosureLinterSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * A list of error codes that should show errors. - * - * All other error codes will show warnings. - * - * @var int - */ - public $errorCodes = array(); - - /** - * A list of error codes to ignore. - * - * @var int - */ - public $ignoreCodes = array(); - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = array('JS'); - - - /** - * Returns the token types that this sniff is interested in. - * - * @return array(int) - */ - public function register() - { - return array(T_OPEN_TAG); - - }//end 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. - * - * @return void - * @throws PHP_CodeSniffer_Exception If jslint.js could not be run - */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) - { - $fileName = $phpcsFile->getFilename(); - - $lintPath = PHP_CodeSniffer::getConfigData('gjslint_path'); - if ($lintPath === null) { - return; - } - - $cmd = "$lintPath --nosummary --notime --unix_mode \"$fileName\""; - $msg = exec($cmd, $output, $retval); - - if (is_array($output) === false) { - return; - } - - $tokens = $phpcsFile->getTokens(); - - foreach ($output as $finding) { - $matches = array(); - $numMatches = preg_match('/^(.*):([0-9]+):\(.*?([0-9]+)\)(.*)$/', $finding, $matches); - if ($numMatches === 0) { - continue; - } - - // Skip error codes we are ignoring. - $code = $matches[3]; - if (in_array($code, $this->ignoreCodes) === true) { - continue; - } - - $line = (int) $matches[2]; - $error = trim($matches[4]); - - // Find the token at the start of the line. - $lineToken = null; - foreach ($tokens as $ptr => $info) { - if ($info['line'] === $line) { - $lineToken = $ptr; - break; - } - } - - if ($lineToken !== null) { - $message = 'gjslint says: (%s) %s'; - $data = array( - $code, - $error, - ); - if (in_array($code, $this->errorCodes) === true) { - $phpcsFile->addError($message, $lineToken, 'ExternalToolError', $data); - } else { - $phpcsFile->addWarning($message, $lineToken, 'ExternalTool', $data); - } - } - }//end foreach - - }//end process() - - -}//end class - -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Debug/JSHintSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Debug/JSHintSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Debug/JSHintSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Debug/JSHintSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,109 +0,0 @@ - - * @author Alexander Wei§ - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Generic_Sniffs_Debug_JSHintSniff. - * - * Runs jshint.js on the file. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Alexander Wei§ - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Sniffs_Debug_JSHintSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = array('JS'); - - - /** - * Returns the token types that this sniff is interested in. - * - * @return array(int) - */ - public function register() - { - return array(T_OPEN_TAG); - - }//end 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. - * - * @return void - * @throws PHP_CodeSniffer_Exception If jshint.js could not be run - */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) - { - $fileName = $phpcsFile->getFilename(); - - $rhinoPath = PHP_CodeSniffer::getConfigData('rhino_path'); - $jshintPath = PHP_CodeSniffer::getConfigData('jshint_path'); - if ($rhinoPath === null || $jshintPath === null) { - return; - } - - $cmd = "$rhinoPath \"$jshintPath\" \"$fileName\""; - $msg = exec($cmd, $output, $retval); - - if (is_array($output) === true) { - $tokens = $phpcsFile->getTokens(); - - foreach ($output as $finding) { - $matches = array(); - $numMatches = preg_match('/^(.+)\(.+:([0-9]+).*:[0-9]+\)$/', $finding, $matches); - if ($numMatches === 0) { - continue; - } - - $line = (int) $matches[2]; - $message = 'jshint says: '.trim($matches[1]); - - // Find the token at the start of the line. - $lineToken = null; - foreach ($tokens as $ptr => $info) { - if ($info['line'] === $line) { - $lineToken = $ptr; - break; - } - } - - if ($lineToken !== null) { - $phpcsFile->addWarning($message, $lineToken, 'ExternalTool'); - } - }//end foreach - }//end if - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Files/ByteOrderMarkSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Files/ByteOrderMarkSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Files/ByteOrderMarkSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Files/ByteOrderMarkSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,93 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Generic_Sniffs_Files_ByteOrderMarkSniff. - * - * A simple sniff for detecting BOMs that may corrupt application work. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Piotr Karas - * @author Greg Sherwood - * @copyright 2010-2011 mediaSELF Sp. z o.o. - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - * @see http://en.wikipedia.org/wiki/Byte_order_mark - */ -class Generic_Sniffs_Files_ByteOrderMarkSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * List of supported BOM definitions. - * - * Use encoding names as keys and hex BOM representations as values. - * - * @var array - */ - public $bomDefinitions = array( - 'UTF-8' => 'efbbbf', - 'UTF-16 (BE)' => 'feff', - 'UTF-16 (LE)' => 'fffe', - ); - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array(T_INLINE_HTML); - - }//end register() - - - /** - * Processes this sniff, 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 ) - { - // The BOM will be the very first token in the file. - if ($stackPtr !== 0) { - return; - } - - $tokens = $phpcsFile->getTokens(); - - foreach ($this->bomDefinitions as $bomName => $expectedBomHex) { - $bomByteLength = (strlen($expectedBomHex) / 2); - $htmlBomHex = bin2hex(substr($tokens[$stackPtr]['content'], 0, $bomByteLength)); - if ($htmlBomHex === $expectedBomHex) { - $errorData = array($bomName); - $error = 'File contains %s byte order mark, which may corrupt your application'; - $phpcsFile->addError($error, $stackPtr, 'Found', $errorData); - break; - } - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Files/LineEndingsSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Files/LineEndingsSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Files/LineEndingsSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Files/LineEndingsSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,103 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Generic_Sniffs_Files_LineEndingsSniff. - * - * Checks that end of line characters are correct. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Sniffs_Files_LineEndingsSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - 'CSS', - ); - - /** - * The valid EOL character. - * - * @var string - */ - public $eolChar = '\n'; - - - /** - * 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 sniff, 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) - { - // We are only interested if this is the first open tag. - if ($stackPtr !== 0) { - if ($phpcsFile->findPrevious(T_OPEN_TAG, ($stackPtr - 1)) !== false) { - return; - } - } - - $found = $phpcsFile->eolChar; - $found = str_replace("\n", '\n', $found); - $found = str_replace("\r", '\r', $found); - - if ($found !== $this->eolChar) { - $error = 'End of line character is invalid; expected "%s" but found "%s"'; - $expected = $this->eolChar; - $expected = str_replace("\n", '\n', $expected); - $expected = str_replace("\r", '\r', $expected); - $data = array( - $expected, - $found, - ); - $phpcsFile->addError($error, $stackPtr, 'InvalidEOLChar', $data); - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Files/LineLengthSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Files/LineLengthSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Files/LineLengthSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Files/LineLengthSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,161 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Generic_Sniffs_Files_LineLengthSniff. - * - * Checks all lines in the file, and throws warnings if they are over 80 - * characters in length and errors if they are over 100. Both these - * figures can be changed by extending this sniff in your own standard. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Sniffs_Files_LineLengthSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * The limit that the length of a line should not exceed. - * - * @var int - */ - public $lineLimit = 80; - - /** - * The limit that the length of a line must not exceed. - * - * Set to zero (0) to disable. - * - * @var int - */ - public $absoluteLineLimit = 100; - - - /** - * 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 void - */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - - // Make sure this is the first open tag. - $previousOpenTag = $phpcsFile->findPrevious(T_OPEN_TAG, ($stackPtr - 1)); - if ($previousOpenTag !== false) { - return; - } - - $tokenCount = 0; - $currentLineContent = ''; - $currentLine = 1; - - $trim = (strlen($phpcsFile->eolChar) * -1); - for (; $tokenCount < $phpcsFile->numTokens; $tokenCount++) { - if ($tokens[$tokenCount]['line'] === $currentLine) { - $currentLineContent .= $tokens[$tokenCount]['content']; - } else { - $currentLineContent = substr($currentLineContent, 0, $trim); - $this->checkLineLength($phpcsFile, ($tokenCount - 1), $currentLineContent); - $currentLineContent = $tokens[$tokenCount]['content']; - $currentLine++; - } - } - - $currentLineContent = substr($currentLineContent, 0, $trim); - $this->checkLineLength($phpcsFile, ($tokenCount - 1), $currentLineContent); - - }//end process() - - - /** - * Checks if a line is too long. - * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The token at the end of the line. - * @param string $lineContent The content of the line. - * - * @return void - */ - protected function checkLineLength(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $lineContent) - { - // If the content is a CVS or SVN id in a version tag, or it is - // a license tag with a name and URL, there is nothing the - // developer can do to shorten the line, so don't throw errors. - if (preg_match('|@version[^\$]+\$Id|', $lineContent) !== 0) { - return; - } - - if (preg_match('|@license|', $lineContent) !== 0) { - return; - } - - if (PHP_CODESNIFFER_ENCODING !== 'iso-8859-1') { - // Not using the detault encoding, so take a bit more care. - $lineLength = iconv_strlen($lineContent, PHP_CODESNIFFER_ENCODING); - if ($lineLength === false) { - // String contained invalid characters, so revert to default. - $lineLength = strlen($lineContent); - } - } else { - $lineLength = strlen($lineContent); - } - - if ($this->absoluteLineLimit > 0 - && $lineLength > $this->absoluteLineLimit - ) { - $data = array( - $this->absoluteLineLimit, - $lineLength, - ); - - $error = 'Line exceeds maximum limit of %s characters; contains %s characters'; - $phpcsFile->addError($error, $stackPtr, 'MaxExceeded', $data); - } else if ($lineLength > $this->lineLimit) { - $data = array( - $this->lineLimit, - $lineLength, - ); - - $warning = 'Line exceeds %s characters; contains %s characters'; - $phpcsFile->addWarning($warning, $stackPtr, 'TooLong', $data); - } - }//end checkLineLength() - - -}//end class - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Formatting/DisallowMultipleStatementsSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Formatting/DisallowMultipleStatementsSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Formatting/DisallowMultipleStatementsSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Formatting/DisallowMultipleStatementsSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,88 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Generic_Sniffs_Formatting_DisallowMultipleStatementsSniff. - * - * Ensures each statement is on a line by itself. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Sniffs_Formatting_DisallowMultipleStatementsSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array(T_SEMICOLON); - - }//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(); - - $prev = $phpcsFile->findPrevious(T_SEMICOLON, ($stackPtr - 1)); - if ($prev === false) { - return; - } - - // Ignore multiple statements in a FOR condition. - if (isset($tokens[$stackPtr]['nested_parenthesis']) === true) { - foreach ($tokens[$stackPtr]['nested_parenthesis'] as $bracket) { - if (isset($tokens[$bracket]['parenthesis_owner']) === false) { - // Probably a closure sitting inside a function call. - continue; - } - - $owner = $tokens[$bracket]['parenthesis_owner']; - if ($tokens[$owner]['code'] === T_FOR) { - return; - } - } - } - - if ($tokens[$prev]['line'] === $tokens[$stackPtr]['line']) { - $error = 'Each PHP statement must be on a line by itself'; - $phpcsFile->addError($error, $stackPtr, 'SameLine'); - return; - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,304 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Generic_Sniffs_Formatting_MultipleStatementAlignmentSniff. - * - * Checks alignment of assignments. If there are multiple adjacent assignments, - * it will check that the equals signs of each assignment are aligned. It will - * display a warning to advise that the signs should be aligned. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Sniffs_Formatting_MultipleStatementAlignmentSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - ); - - /** - * If true, an error will be thrown; otherwise a warning. - * - * @var bool - */ - public $error = false; - - /** - * The maximum amount of padding before the alignment is ignored. - * - * If the amount of padding required to align this assignment with the - * surrounding assignments exceeds this number, the assignment will be - * ignored and no errors or warnings will be thrown. - * - * @var int - */ - public $maxPadding = 1000; - - /** - * If true, multi-line assignments are not checked. - * - * @var int - */ - public $ignoreMultiLine = false; - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return PHP_CodeSniffer_Tokens::$assignmentTokens; - - }//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(); - - // Ignore assignments used in a condition, like an IF or FOR. - if (isset($tokens[$stackPtr]['nested_parenthesis']) === true) { - foreach ($tokens[$stackPtr]['nested_parenthesis'] as $start => $end) { - if (isset($tokens[$start]['parenthesis_owner']) === true) { - return; - } - } - } - - /* - By this stage, it is known that there is an assignment on this line. - We only want to process the block once we reach the last assignment, - so we need to determine if there are more to follow. - */ - - // The assignment may span over multiple lines, so look for the - // end of the assignment so we can check assignment blocks correctly. - $lineEnd = $phpcsFile->findNext(T_SEMICOLON, ($stackPtr + 1)); - - $nextAssign = $phpcsFile->findNext( - PHP_CodeSniffer_Tokens::$assignmentTokens, - ($lineEnd + 1) - ); - - if ($nextAssign !== false) { - $isAssign = true; - if ($tokens[$nextAssign]['line'] === ($tokens[$lineEnd]['line'] + 1)) { - // Assignment may be in the same block as this one. Just make sure - // it is not used in a condition, like an IF or FOR. - if (isset($tokens[$nextAssign]['nested_parenthesis']) === true) { - foreach ($tokens[$nextAssign]['nested_parenthesis'] as $start => $end) { - if (isset($tokens[$start]['parenthesis_owner']) === true) { - // Not an assignment. - $isAssign = false; - break; - } - } - } - - if ($isAssign === true) { - return; - } - } - } - - // Getting here means that this is the last in a block of statements. - $assignments = array(); - $assignments[] = $stackPtr; - $prevAssignment = $stackPtr; - $lastLine = $tokens[$stackPtr]['line']; - - while (($prevAssignment = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$assignmentTokens, ($prevAssignment - 1))) !== false) { - - // We are not interested in double arrows as they assign values inside - // arrays and loops and do not use the same indentation rules. - if ($tokens[$prevAssignment]['code'] === T_DOUBLE_ARROW) { - continue; - } - - // The assignment's end token must be on the line directly - // above the current one to be in the same assignment block. - $lineEnd = $phpcsFile->findNext(T_SEMICOLON, ($prevAssignment + 1)); - - // And the end token must actually belong to this assignment. - $nextOpener = $phpcsFile->findNext( - PHP_CodeSniffer_Tokens::$scopeOpeners, - ($prevAssignment + 1) - ); - - if ($nextOpener !== false && $nextOpener < $lineEnd) { - break; - } - - if ($tokens[$lineEnd]['line'] !== ($lastLine - 1)) { - break; - } - - // Make sure it is not assigned inside a condition (eg. IF, FOR). - if (isset($tokens[$prevAssignment]['nested_parenthesis']) === true) { - foreach ($tokens[$prevAssignment]['nested_parenthesis'] as $start => $end) { - if (isset($tokens[$start]['parenthesis_owner']) === true) { - break(2); - } - } - } - - $assignments[] = $prevAssignment; - $lastLine = $tokens[$prevAssignment]['line']; - }//end while - - $assignmentData = array(); - $maxAssignmentLength = 0; - $maxVariableLength = 0; - - foreach ($assignments as $assignment) { - $prev = $phpcsFile->findPrevious( - PHP_CodeSniffer_Tokens::$emptyTokens, - ($assignment - 1), - null, - true - ); - - $endColumn = $tokens[($prev + 1)]['column']; - - if ($maxVariableLength < $endColumn) { - $maxVariableLength = $endColumn; - } - - if ($maxAssignmentLength < strlen($tokens[$assignment]['content'])) { - $maxAssignmentLength = strlen($tokens[$assignment]['content']); - } - - $assignmentData[$assignment] - = array( - 'variable_length' => $endColumn, - 'assignment_length' => strlen($tokens[$assignment]['content']), - ); - }//end foreach - - foreach ($assignmentData as $assignment => $data) { - if ($data['assignment_length'] === $maxAssignmentLength) { - if ($data['variable_length'] === $maxVariableLength) { - // The assignment is the longest possible, so the column that - // everything has to align to is based on it. - $column = ($maxVariableLength + 1); - break; - } else { - // The assignment token is the longest out of all of the - // assignments, but the variable name is not, so the column - // the start at can go back more to cover the space - // between the variable name and the assigment operator. - $column = ($maxVariableLength - ($maxAssignmentLength - 1) + 1); - } - } - } - - // Determine the actual position that each equals sign should be in. - foreach ($assignments as $assignment) { - // Actual column takes into account the length of the assignment operator. - $actualColumn = ($column + $maxAssignmentLength - strlen($tokens[$assignment]['content'])); - if ($tokens[$assignment]['column'] !== $actualColumn) { - $prev = $phpcsFile->findPrevious( - PHP_CodeSniffer_Tokens::$emptyTokens, - ($assignment - 1), - null, - true - ); - - $expected = ($actualColumn - $tokens[($prev + 1)]['column']); - - if ($tokens[$assignment]['line'] !== $tokens[$prev]['line']) { - // Instead of working out how many spaces there are - // across new lines, the error message becomes more - // generic below. - $found = null; - } else { - $found = ($tokens[$assignment]['column'] - $tokens[($prev + 1)]['column']); - } - - // If the expected number of spaces for alignment exceeds the - // maxPadding rule, we just check for a single space as no - // alignment is required. - if ($expected > $this->maxPadding) { - if ($found === 1) { - continue; - } else { - $expected = 1; - } - } - - // Skip multi-line assignments if required. - if ($found === null && $this->ignoreMultiLine === true) { - continue; - } - - $expected .= ($expected === 1) ? ' space' : ' spaces'; - if ($found === null) { - $found = 'a new line'; - } else { - $found .= ($found === 1) ? ' space' : ' spaces'; - } - - if (count($assignments) === 1) { - $type = 'Incorrect'; - $error = 'Equals sign not aligned correctly; expected %s but found %s'; - } else { - $type = 'NotSame'; - $error = 'Equals sign not aligned with surrounding assignments; expected %s but found %s'; - } - - $errorData = array( - $expected, - $found, - ); - - if ($this->error === true) { - $phpcsFile->addError($error, $assignment, $type, $errorData); - } else { - $phpcsFile->addWarning($error, $assignment, $type.'Warning', $errorData); - } - }//end if - }//end foreach - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Formatting/NoSpaceAfterCastSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Formatting/NoSpaceAfterCastSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Formatting/NoSpaceAfterCastSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Formatting/NoSpaceAfterCastSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,69 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Generic_Sniffs_Formatting_NoSpaceAfterCastSniff. - * - * Ensures there is no space after cast tokens. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Sniffs_Formatting_NoSpaceAfterCastSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return PHP_CodeSniffer_Tokens::$castTokens; - - }//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(); - - if ($tokens[($stackPtr + 1)]['code'] === T_WHITESPACE) { - $error = 'A cast statement must not be followed by a space'; - $phpcsFile->addError($error, $stackPtr, 'SpaceFound'); - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Formatting/SpaceAfterCastSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Formatting/SpaceAfterCastSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Formatting/SpaceAfterCastSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Formatting/SpaceAfterCastSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,75 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Generic_Sniffs_Formatting_SpaceAfterCastSniff. - * - * Ensures there is a single space after cast tokens. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Sniffs_Formatting_SpaceAfterCastSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return PHP_CodeSniffer_Tokens::$castTokens; - - }//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(); - - if ($tokens[($stackPtr + 1)]['code'] !== T_WHITESPACE) { - $error = 'A cast statement must be followed by a single space'; - $phpcsFile->addError($error, $stackPtr, 'NoSpace'); - return; - } - - if ($tokens[($stackPtr + 1)]['content'] !== ' ') { - $error = 'A cast statement must be followed by a single space'; - $phpcsFile->addError($error, $stackPtr, 'TooMuchSpace'); - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Functions/CallTimePassByReferenceSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Functions/CallTimePassByReferenceSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Functions/CallTimePassByReferenceSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Functions/CallTimePassByReferenceSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,148 +0,0 @@ - - * @copyright 2009 Florian Grandel - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Generic_Sniffs_Functions_CallTimePassByReferenceSniff. - * - * Ensures that variables are not passed by reference when calling a function. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Florian Grandel - * @copyright 2009 Florian Grandel - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Sniffs_Functions_CallTimePassByReferenceSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array(T_STRING); - - }//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(); - - // Skip tokens that are the names of functions or classes - // within their definitions. For example: function myFunction... - // "myFunction" is T_STRING but we should skip because it is not a - // function or method *call*. - $functionName = $stackPtr; - $findTokens = array_merge( - PHP_CodeSniffer_Tokens::$emptyTokens, - array(T_BITWISE_AND) - ); - - $functionKeyword = $phpcsFile->findPrevious( - $findTokens, - ($stackPtr - 1), - null, - true - ); - - if ($tokens[$functionKeyword]['code'] === T_FUNCTION - || $tokens[$functionKeyword]['code'] === T_CLASS - ) { - return; - } - - // If the next non-whitespace token after the function or method call - // is not an opening parenthesis then it cant really be a *call*. - $openBracket = $phpcsFile->findNext( - PHP_CodeSniffer_Tokens::$emptyTokens, - ($functionName + 1), - null, - true - ); - - if ($tokens[$openBracket]['code'] !== T_OPEN_PARENTHESIS) { - return; - } - - $closeBracket = $tokens[$openBracket]['parenthesis_closer']; - - $nextSeparator = $openBracket; - while (($nextSeparator = $phpcsFile->findNext(T_VARIABLE, ($nextSeparator + 1), $closeBracket)) !== false) { - // Make sure the variable belongs directly to this function call - // and is not inside a nested function call or array. - $brackets = $tokens[$nextSeparator]['nested_parenthesis']; - $lastBracket = array_pop($brackets); - if ($lastBracket !== $closeBracket) { - continue; - } - - // Checking this: $value = my_function(...[*]$arg...). - $tokenBefore = $phpcsFile->findPrevious( - PHP_CodeSniffer_Tokens::$emptyTokens, - ($nextSeparator - 1), - null, - true - ); - - if ($tokens[$tokenBefore]['code'] === T_BITWISE_AND) { - // Checking this: $value = my_function(...[*]&$arg...). - $tokenBefore = $phpcsFile->findPrevious( - PHP_CodeSniffer_Tokens::$emptyTokens, - ($tokenBefore - 1), - null, - true - ); - - // We have to exclude all uses of T_BITWISE_AND that are not - // references. We use a blacklist approach as we prefer false - // positives to not identifiying a pass-by-reference call at all. - // The blacklist may not yet be complete. - switch ($tokens[$tokenBefore]['code']) { - case T_VARIABLE: - case T_CLOSE_PARENTHESIS: - // In these cases T_BITWISE_AND represents - // the bitwise and operator. - continue; - break; - - default: - // T_BITWISE_AND represents a pass-by-reference. - $error = 'Call-time pass-by-reference calls are prohibited'; - $phpcsFile->addError($error, $tokenBefore, 'NotAllowed'); - break; - } - }//end if - }//end while - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Functions/FunctionCallArgumentSpacingSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Functions/FunctionCallArgumentSpacingSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Functions/FunctionCallArgumentSpacingSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Functions/FunctionCallArgumentSpacingSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,141 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Generic_Sniffs_Functions_FunctionCallArgumentSpacingSniff. - * - * Checks that calls to methods and functions are spaced correctly. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Sniffs_Functions_FunctionCallArgumentSpacingSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array(T_STRING); - - }//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(); - - // Skip tokens that are the names of functions or classes - // within their definitions. For example: - // function myFunction... - // "myFunction" is T_STRING but we should skip because it is not a - // function or method *call*. - $functionName = $stackPtr; - $ignoreTokens = PHP_CodeSniffer_Tokens::$emptyTokens; - $ignoreTokens[] = T_BITWISE_AND; - $functionKeyword = $phpcsFile->findPrevious($ignoreTokens, ($stackPtr - 1), null, true); - if ($tokens[$functionKeyword]['code'] === T_FUNCTION || $tokens[$functionKeyword]['code'] === T_CLASS) { - return; - } - - // If the next non-whitespace token after the function or method call - // is not an opening parenthesis then it cant really be a *call*. - $openBracket = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($functionName + 1), null, true); - if ($tokens[$openBracket]['code'] !== T_OPEN_PARENTHESIS) { - return; - } - - $closeBracket = $tokens[$openBracket]['parenthesis_closer']; - - $nextSeperator = $openBracket; - while (($nextSeperator = $phpcsFile->findNext(array(T_COMMA, T_VARIABLE, T_CLOSURE), ($nextSeperator + 1), $closeBracket)) !== false) { - if ($tokens[$nextSeperator]['code'] === T_CLOSURE) { - $nextSeperator = $tokens[$nextSeperator]['scope_closer']; - continue; - } - - // Make sure the comma or variable belongs directly to this function call, - // and is not inside a nested function call or array. - $brackets = $tokens[$nextSeperator]['nested_parenthesis']; - $lastBracket = array_pop($brackets); - if ($lastBracket !== $closeBracket) { - continue; - } - - if ($tokens[$nextSeperator]['code'] === T_COMMA) { - if ($tokens[($nextSeperator - 1)]['code'] === T_WHITESPACE) { - $error = 'Space found before comma in function call'; - $phpcsFile->addError($error, $stackPtr, 'SpaceBeforeComma'); - } - - if ($tokens[($nextSeperator + 1)]['code'] !== T_WHITESPACE) { - $error = 'No space found after comma in function call'; - $phpcsFile->addError($error, $stackPtr, 'NoSpaceAfterComma'); - } else { - // If there is a newline in the space, then the must be formatting - // each argument on a newline, which is valid, so ignore it. - if (strpos($tokens[($nextSeperator + 1)]['content'], $phpcsFile->eolChar) === false) { - $space = strlen($tokens[($nextSeperator + 1)]['content']); - if ($space > 1) { - $error = 'Expected 1 space after comma in function call; %s found'; - $data = array($space); - $phpcsFile->addError($error, $stackPtr, 'TooMuchSpaceAfterComma', $data); - } - } - } - } else { - // Token is a variable. - $nextToken = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($nextSeperator + 1), $closeBracket, true); - if ($nextToken !== false) { - if ($tokens[$nextToken]['code'] === T_EQUAL) { - if (($tokens[($nextToken - 1)]['code']) !== T_WHITESPACE) { - $error = 'Expected 1 space before = sign of default value'; - $phpcsFile->addError($error, $stackPtr, 'NoSpaceBeforeEquals'); - } - - if ($tokens[($nextToken + 1)]['code'] !== T_WHITESPACE) { - $error = 'Expected 1 space after = sign of default value'; - $phpcsFile->addError($error, $stackPtr, 'NoSpaceAfterEquals'); - } - } - } - }//end if - }//end while - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceBsdAllmanSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceBsdAllmanSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceBsdAllmanSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceBsdAllmanSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,121 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Generic_Sniffs_Functions_OpeningFunctionBraceBsdAllmanSniff. - * - * Checks that the opening brace of a function is on the line after the - * function declaration. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Sniffs_Functions_OpeningFunctionBraceBsdAllmanSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * Registers the tokens that this sniff wants to listen for. - * - * @return void - */ - 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(); - - if (isset($tokens[$stackPtr]['scope_opener']) === false) { - return; - } - - $openingBrace = $tokens[$stackPtr]['scope_opener']; - - // The end of the function occurs at the end of the argument list. Its - // like this because some people like to break long function declarations - // over multiple lines. - $functionLine = $tokens[$tokens[$stackPtr]['parenthesis_closer']]['line']; - $braceLine = $tokens[$openingBrace]['line']; - - $lineDifference = ($braceLine - $functionLine); - - if ($lineDifference === 0) { - $error = 'Opening brace should be on a new line'; - $phpcsFile->addError($error, $openingBrace, 'BraceOnSameLine'); - return; - } - - if ($lineDifference > 1) { - $error = 'Opening brace should be on the line after the declaration; found %s blank line(s)'; - $data = array(($lineDifference - 1)); - $phpcsFile->addError($error, $openingBrace, 'BraceSpacing', $data); - return; - } - - // We need to actually find the first piece of content on this line, - // as if this is a method with tokens before it (public, static etc) - // or an if with an else before it, then we need to start the scope - // checking from there, rather than the current token. - $lineStart = $stackPtr; - while (($lineStart = $phpcsFile->findPrevious(array(T_WHITESPACE), ($lineStart - 1), null, false)) !== false) { - if (strpos($tokens[$lineStart]['content'], $phpcsFile->eolChar) !== false) { - break; - } - } - - // We found a new line, now go forward and find the first non-whitespace - // token. - $lineStart = $phpcsFile->findNext(array(T_WHITESPACE), $lineStart, null, true); - - // The opening brace is on the correct line, now it needs to be - // checked to be correctly indented. - $startColumn = $tokens[$lineStart]['column']; - $braceIndent = $tokens[$openingBrace]['column']; - - if ($braceIndent !== $startColumn) { - $error = 'Opening brace indented incorrectly; expected %s spaces, found %s'; - $data = array( - ($startColumn - 1), - ($braceIndent - 1), - ); - $phpcsFile->addError($error, $openingBrace, 'BraceIndent', $data); - } - - }//end process() - - -}//end class - -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,109 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Generic_Sniffs_Functions_OpeningFunctionBraceKernighanRitchieSniff. - * - * Checks that the opening brace of a function is on the same line - * as the function declaration. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Sniffs_Functions_OpeningFunctionBraceKernighanRitchieSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * Registers the tokens that this sniff wants to listen for. - * - * @return void - */ - 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(); - - if (isset($tokens[$stackPtr]['scope_opener']) === false) { - return; - } - - $openingBrace = $tokens[$stackPtr]['scope_opener']; - - // The end of the function occurs at the end of the argument list. Its - // like this because some people like to break long function declarations - // over multiple lines. - $functionLine = $tokens[$tokens[$stackPtr]['parenthesis_closer']]['line']; - $braceLine = $tokens[$openingBrace]['line']; - - $lineDifference = ($braceLine - $functionLine); - - if ($lineDifference > 0) { - $error = 'Opening brace should be on the same line as the declaration'; - $phpcsFile->addError($error, $openingBrace, 'BraceOnNewLine'); - return; - } - - // Checks that the closing parenthesis and the opening brace are - // separated by a whitespace character. - $closerColumn = $tokens[$tokens[$stackPtr]['parenthesis_closer']]['column']; - $braceColumn = $tokens[$openingBrace]['column']; - - $columnDifference = ($braceColumn - $closerColumn); - - if ($columnDifference !== 2) { - $error = 'Expected 1 space between the closing parenthesis and the opening brace; found %s'; - $data = array(($columnDifference - 1)); - $phpcsFile->addError($error, $openingBrace, 'SpaceBeforeBrace', $data); - return; - } - - // Check that a tab was not used instead of a space. - $spaceTokenPtr = ($tokens[$stackPtr]['parenthesis_closer'] + 1); - $spaceContent = $tokens[$spaceTokenPtr]['content']; - if ($spaceContent !== ' ') { - $error = 'Expected a single space character between closing parenthesis and opening brace; found %s'; - $data = array($spaceContent); - $phpcsFile->addError($error, $openingBrace, 'SpaceBeforeBrace', $data); - return; - } - - }//end process() - - -}//end class - -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Metrics/CyclomaticComplexitySniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Metrics/CyclomaticComplexitySniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Metrics/CyclomaticComplexitySniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Metrics/CyclomaticComplexitySniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,131 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Checks the cyclomatic complexity (McCabe) for functions. - * - * The cyclomatic complexity (also called McCabe code metrics) - * indicates the complexity within a function by counting - * the different paths the function includes. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Johann-Peter Hartmann - * @author Greg Sherwood - * @copyright 2007 Mayflower GmbH - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Sniffs_Metrics_CyclomaticComplexitySniff implements PHP_CodeSniffer_Sniff -{ - - /** - * A complexity higher than this value will throw a warning. - * - * @var int - */ - public $complexity = 10; - - /** - * A complexity higer than this value will throw an error. - * - * @var int - */ - public $absoluteComplexity = 20; - - - /** - * 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) - { - $this->currentFile = $phpcsFile; - - $tokens = $phpcsFile->getTokens(); - - // Ignore abstract methods. - if (isset($tokens[$stackPtr]['scope_opener']) === false) { - return; - } - - // Detect start and end of this function definition. - $start = $tokens[$stackPtr]['scope_opener']; - $end = $tokens[$stackPtr]['scope_closer']; - - // Predicate nodes for PHP. - $find = array( - 'T_CASE', - 'T_DEFAULT', - 'T_CATCH', - 'T_IF', - 'T_FOR', - 'T_FOREACH', - 'T_WHILE', - 'T_DO', - 'T_ELSEIF', - ); - - $complexity = 1; - - // Iterate from start to end and count predicate nodes. - for ($i = ($start + 1); $i < $end; $i++) { - if (in_array($tokens[$i]['type'], $find) === true) { - $complexity++; - } - } - - if ($complexity > $this->absoluteComplexity) { - $error = 'Function\'s cyclomatic complexity (%s) exceeds allowed maximum of %s'; - $data = array( - $complexity, - $this->absoluteComplexity, - ); - $phpcsFile->addError($error, $stackPtr, 'MaxExceeded', $data); - } else if ($complexity > $this->complexity) { - $warning = 'Function\'s cyclomatic complexity (%s) exceeds %s; consider refactoring the function'; - $data = array( - $complexity, - $this->complexity, - ); - $phpcsFile->addWarning($warning, $stackPtr, 'TooHigh', $data); - } - - return; - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Metrics/NestingLevelSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Metrics/NestingLevelSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Metrics/NestingLevelSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Metrics/NestingLevelSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,114 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Checks the nesting level for methods. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Johann-Peter Hartmann - * @author Greg Sherwood - * @copyright 2007 Mayflower GmbH - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Sniffs_Metrics_NestingLevelSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * A nesting level than this value will throw a warning. - * - * @var int - */ - public $nestingLevel = 5; - - /** - * A nesting level than this value will throw an error. - * - * @var int - */ - public $absoluteNestingLevel = 10; - - - /** - * 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(); - - // Ignore abstract methods. - if (isset($tokens[$stackPtr]['scope_opener']) === false) { - return; - } - - // Detect start and end of this function definition. - $start = $tokens[$stackPtr]['scope_opener']; - $end = $tokens[$stackPtr]['scope_closer']; - - $nestingLevel = 0; - - // Find the maximum nesting level of any token in the function. - for ($i = ($start + 1); $i < $end; $i++) { - $level = $tokens[$i]['level']; - if ($nestingLevel < $level) { - $nestingLevel = $level; - } - } - - // We subtract the nesting level of the function itself. - $nestingLevel = ($nestingLevel - $tokens[$stackPtr]['level'] - 1); - - if ($nestingLevel > $this->absoluteNestingLevel) { - $error = 'Function\'s nesting level (%s) exceeds allowed maximum of %s'; - $data = array( - $nestingLevel, - $this->absoluteNestingLevel, - ); - $phpcsFile->addError($error, $stackPtr, 'MaxExceeded', $data); - } else if ($nestingLevel > $this->nestingLevel) { - $warning = 'Function\'s nesting level (%s) exceeds %s; consider refactoring the function'; - $data = array( - $nestingLevel, - $this->nestingLevel, - ); - $phpcsFile->addWarning($warning, $stackPtr, 'TooHigh', $data); - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/NamingConventions/ConstructorNameSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/NamingConventions/ConstructorNameSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/NamingConventions/ConstructorNameSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/NamingConventions/ConstructorNameSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,101 +0,0 @@ - - * @author Leif Wickland - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -if (class_exists('PHP_CodeSniffer_Standards_AbstractScopeSniff', true) === false) { - $error = 'Class PHP_CodeSniffer_Standards_AbstractScopeSniff not found'; - throw new PHP_CodeSniffer_Exception($error); -} - -/** - * Generic_Sniffs_NamingConventions_ConstructorNameSniff. - * - * Favor PHP 5 constructor syntax, which uses "function __construct()". - * Avoid PHP 4 constructor syntax, which uses "function ClassName()". - * - * @category PHP - * @package PHP_CodeSniffer - * @author Leif Wickland - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Sniffs_NamingConventions_ConstructorNameSniff extends PHP_CodeSniffer_Standards_AbstractScopeSniff -{ - - - /** - * Constructs the test with the tokens it wishes to listen for. - * - * @return void - */ - public function __construct() - { - parent::__construct(array(T_CLASS, T_INTERFACE), array(T_FUNCTION), true); - - }//end __construct() - - - /** - * Processes this test when one of its tokens is encountered. - * - * @param PHP_CodeSniffer_File $phpcsFile The current file being scanned. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. - * @param int $currScope A pointer to the start of the scope. - * - * @return void - */ - protected function processTokenWithinScope( - PHP_CodeSniffer_File $phpcsFile, - $stackPtr, - $currScope - ) { - $className = $phpcsFile->getDeclarationName($currScope); - $methodName = $phpcsFile->getDeclarationName($stackPtr); - - if (strcasecmp($methodName, $className) === 0) { - $error = 'PHP4 style constructors are not allowed; use "__construct()" instead'; - $phpcsFile->addError($error, $stackPtr, 'OldStyle'); - } else if (strcasecmp($methodName, '__construct') !== 0) { - // Not a constructor. - return; - } - - $tokens = $phpcsFile->getTokens(); - - $parentClassName = $phpcsFile->findExtendedClassName($currScope); - if ($parentClassName === false) { - return; - } - - $endFunctionIndex = $tokens[$stackPtr]['scope_closer']; - $startIndex = $stackPtr; - while ($doubleColonIndex = $phpcsFile->findNext(array(T_DOUBLE_COLON), $startIndex, $endFunctionIndex)) { - if ($tokens[($doubleColonIndex + 1)]['code'] === T_STRING - && $tokens[($doubleColonIndex + 1)]['content'] === $parentClassName - ) { - $error = 'PHP4 style calls to parent constructors are not allowed; use "parent::__construct()" instead'; - $phpcsFile->addError($error, ($doubleColonIndex + 1), 'OldStyleCall'); - } - - $startIndex = ($doubleColonIndex + 1); - } - - }//end processTokenWithinScope() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,207 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Generic_Sniffs_NamingConventions_UpperCaseConstantNameSniff. - * - * Ensures that constant names are all uppercase. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Sniffs_NamingConventions_UpperCaseConstantNameSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array(T_STRING); - - }//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(); - $constName = $tokens[$stackPtr]['content']; - - // If this token is in a heredoc, ignore it. - if ($phpcsFile->hasCondition($stackPtr, T_START_HEREDOC) === true) { - return; - } - - // Special case for PHPUnit. - if ($constName === 'PHPUnit_MAIN_METHOD') { - return; - } - - // If the next non-whitespace token after this token - // is not an opening parenthesis then it is not a function call. - $openBracket = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); - if ($tokens[$openBracket]['code'] !== T_OPEN_PARENTHESIS) { - $functionKeyword = $phpcsFile->findPrevious(array(T_WHITESPACE, T_COMMA, T_COMMENT, T_STRING, T_NS_SEPARATOR), ($stackPtr - 1), null, true); - - $declarations = array( - T_FUNCTION, - T_CLASS, - T_INTERFACE, - T_TRAIT, - T_IMPLEMENTS, - T_EXTENDS, - T_INSTANCEOF, - T_NEW, - T_NAMESPACE, - T_USE, - T_AS, - T_GOTO, - ); - - if (in_array($tokens[$functionKeyword]['code'], $declarations) === true) { - // This is just a declaration; no constants here. - return; - } - - if ($tokens[$functionKeyword]['code'] === T_CONST) { - // This is a class constant. - if (strtoupper($constName) !== $constName) { - $error = 'Class constants must be uppercase; expected %s but found %s'; - $data = array( - strtoupper($constName), - $constName, - ); - $phpcsFile->addError($error, $stackPtr, 'ClassConstantNotUpperCase', $data); - } - - return; - } - - // Is this a class name? - $nextPtr = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); - if ($tokens[$nextPtr]['code'] === T_DOUBLE_COLON) { - return; - } - - // Is this a namespace name? - if ($tokens[$nextPtr]['code'] === T_NS_SEPARATOR) { - return; - } - - // Is this a type hint? - if ($tokens[$nextPtr]['code'] === T_VARIABLE - || $phpcsFile->isReference($nextPtr) === true - ) { - return; - } - - // Is this a member var name? - $prevPtr = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); - if ($tokens[$prevPtr]['code'] === T_OBJECT_OPERATOR) { - return; - } - - // Is this a namespace name? - if ($tokens[$prevPtr]['code'] === T_NS_SEPARATOR) { - return; - } - - // Is this an instance of declare() - $prevPtrDeclare = $phpcsFile->findPrevious(array(T_WHITESPACE, T_OPEN_PARENTHESIS), ($stackPtr - 1), null, true); - if ($tokens[$prevPtrDeclare]['code'] === T_DECLARE) { - return; - } - - // Is this a goto label target? - if ($tokens[$nextPtr]['code'] === T_COLON) { - if (in_array($tokens[$prevPtr]['code'], array(T_SEMICOLON, T_OPEN_CURLY_BRACKET, T_COLON), true)) { - return; - } - } - - // This is a real constant. - if (strtoupper($constName) !== $constName) { - $error = 'Constants must be uppercase; expected %s but found %s'; - $data = array( - strtoupper($constName), - $constName, - ); - $phpcsFile->addError($error, $stackPtr, 'ConstantNotUpperCase', $data); - } - - } else if (strtolower($constName) === 'define' || strtolower($constName) === 'constant') { - - /* - This may be a "define" or "constant" function call. - */ - - // Make sure this is not a method call. - $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); - if ($tokens[$prev]['code'] === T_OBJECT_OPERATOR - || $tokens[$prev]['code'] === T_DOUBLE_COLON - ) { - return; - } - - // The next non-whitespace token must be the constant name. - $constPtr = $phpcsFile->findNext(T_WHITESPACE, ($openBracket + 1), null, true); - if ($tokens[$constPtr]['code'] !== T_CONSTANT_ENCAPSED_STRING) { - return; - } - - $constName = $tokens[$constPtr]['content']; - - // Check for constants like self::CONSTANT. - $prefix = ''; - $splitPos = strpos($constName, '::'); - if ($splitPos !== false) { - $prefix = substr($constName, 0, ($splitPos + 2)); - $constName = substr($constName, ($splitPos + 2)); - } - - if (strtoupper($constName) !== $constName) { - $error = 'Constants must be uppercase; expected %s but found %s'; - $data = array( - $prefix.strtoupper($constName), - $prefix.$constName, - ); - $phpcsFile->addError($error, $stackPtr, 'ConstantNotUpperCase', $data); - } - }//end if - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/PHP/DeprecatedFunctionsSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/PHP/DeprecatedFunctionsSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/PHP/DeprecatedFunctionsSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/PHP/DeprecatedFunctionsSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,94 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Generic_Sniffs_PHP_DeprecatedFunctionsSniff. - * - * Discourages the use of deprecated functions that are kept in PHP for - * compatibility with older versions. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Sebastian Bergmann - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Sniffs_PHP_DeprecatedFunctionsSniff extends Generic_Sniffs_PHP_ForbiddenFunctionsSniff -{ - - /** - * A list of forbidden functions with their alternatives. - * - * The value is NULL if no alternative exists. IE, the - * function should just not be used. - * - * @var array(string => string|null) - */ - protected $forbiddenFunctions = array(); - - - /** - * Constructor. - * - * Uses the Reflection API to get a list of deprecated functions. - */ - public function __construct() - { - $functions = get_defined_functions(); - - foreach ($functions['internal'] as $functionName) { - $function = new ReflectionFunction($functionName); - - if ($function->isDeprecated() === true) { - $this->forbiddenFunctions[$functionName] = null; - } - } - - }//end __construct() - - - /** - * Generates the error or wanrning for this sniff. - * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the forbidden function - * in the token array. - * @param string $function The name of the forbidden function. - * @param string $pattern The pattern used for the match. - * - * @return void - */ - protected function addError($phpcsFile, $stackPtr, $function, $pattern=null) - { - $data = array($function); - $error = 'Function %s() has been deprecated'; - $type = 'Deprecated'; - - if ($this->error === true) { - $phpcsFile->addError($error, $stackPtr, $type, $data); - } else { - $phpcsFile->addWarning($error, $stackPtr, $type, $data); - } - - }//end addError() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/PHP/DisallowShortOpenTagSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/PHP/DisallowShortOpenTagSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/PHP/DisallowShortOpenTagSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/PHP/DisallowShortOpenTagSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,85 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Generic_Sniffs_PHP_DisallowShortOpenTagSniff. - * - * Makes sure that shorthand PHP open tags are not used. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Sniffs_PHP_DisallowShortOpenTagSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array( - T_OPEN_TAG, - T_OPEN_TAG_WITH_ECHO, - ); - - }//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(); - $openTag = $tokens[$stackPtr]; - - if ($openTag['content'] === 'addError($error, $stackPtr, 'Found', $data); - } - - if ($openTag['code'] === T_OPEN_TAG_WITH_ECHO) { - $nextVar = $tokens[$phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr + 1), null, true)]; - $error = 'Short PHP opening tag used with echo; expected "addError($error, $stackPtr, 'EchoFound', $data); - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/PHP/ForbiddenFunctionsSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/PHP/ForbiddenFunctionsSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/PHP/ForbiddenFunctionsSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/PHP/ForbiddenFunctionsSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,191 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Generic_Sniffs_PHP_ForbiddenFunctionsSniff. - * - * Discourages the use of alias functions that are kept in PHP for compatibility - * with older versions. Can be used to forbid the use of any function. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Sniffs_PHP_ForbiddenFunctionsSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * A list of forbidden functions with their alternatives. - * - * The value is NULL if no alternative exists. IE, the - * function should just not be used. - * - * @var array(string => string|null) - */ - protected $forbiddenFunctions = array( - 'sizeof' => 'count', - 'delete' => 'unset', - ); - - /** - * A cache of forbidden function names, for faster lookups. - * - * @var array(string) - */ - protected $forbiddenFunctionNames = array(); - - /** - * If true, forbidden functions will be considered regular expressions. - * - * @var bool - */ - protected $patternMatch = false; - - /** - * If true, an error will be thrown; otherwise a warning. - * - * @var bool - */ - public $error = true; - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - // Everyone has had a chance to figure out what forbidden functions - // they want to check for, so now we can cache out the list. - $this->forbiddenFunctionNames = array_keys($this->forbiddenFunctions); - - if ($this->patternMatch === true) { - foreach ($this->forbiddenFunctionNames as $i => $name) { - $this->forbiddenFunctionNames[$i] = '/'.$name.'/i'; - } - } - - return array(T_STRING); - - }//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(); - - $ignore = array( - T_DOUBLE_COLON, - T_OBJECT_OPERATOR, - T_FUNCTION, - T_CONST, - ); - - $prevToken = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); - if (in_array($tokens[$prevToken]['code'], $ignore) === true) { - // Not a call to a PHP function. - return; - } - - $function = strtolower($tokens[$stackPtr]['content']); - $pattern = null; - - if ($this->patternMatch === true) { - $count = 0; - $pattern = preg_replace( - $this->forbiddenFunctionNames, - $this->forbiddenFunctionNames, - $function, - 1, - $count - ); - - if ($count === 0) { - return; - } - - // Remove the pattern delimiters and modifier. - $pattern = substr($pattern, 1, -2); - } else { - if (in_array($function, $this->forbiddenFunctionNames) === false) { - return; - } - } - - $this->addError($phpcsFile, $stackPtr, $function, $pattern); - - }//end process() - - - /** - * Generates the error or wanrning for this sniff. - * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the forbidden function - * in the token array. - * @param string $function The name of the forbidden function. - * @param string $pattern The pattern used for the match. - * - * @return void - */ - protected function addError($phpcsFile, $stackPtr, $function, $pattern=null) - { - $data = array($function); - $error = 'The use of function %s() is '; - if ($this->error === true) { - $type = 'Found'; - $error .= 'forbidden'; - } else { - $type = 'Discouraged'; - $error .= 'discouraged'; - } - - if ($pattern === null) { - $pattern = $function; - } - - if ($this->forbiddenFunctions[$pattern] !== null) { - $type .= 'WithAlternative'; - $data[] = $this->forbiddenFunctions[$pattern]; - $error .= '; use %s() instead'; - } - - if ($this->error === true) { - $phpcsFile->addError($error, $stackPtr, $type, $data); - } else { - $phpcsFile->addWarning($error, $stackPtr, $type, $data); - } - - }//end addError() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/PHP/LowerCaseConstantSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/PHP/LowerCaseConstantSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/PHP/LowerCaseConstantSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/PHP/LowerCaseConstantSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,93 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Generic_Sniffs_PHP_LowerCaseConstantSniff. - * - * Checks that all uses of true, false and null are lowerrcase. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Sniffs_PHP_LowerCaseConstantSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - ); - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array( - T_TRUE, - T_FALSE, - T_NULL, - ); - - }//end register() - - - /** - * Processes this sniff, 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(); - - // Is this a member var name? - $prevPtr = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); - if ($tokens[$prevPtr]['code'] === T_OBJECT_OPERATOR) { - return; - } - - $keyword = $tokens[$stackPtr]['content']; - if (strtolower($keyword) !== $keyword) { - $error = 'TRUE, FALSE and NULL must be lowercase; expected "%s" but found "%s"'; - $data = array( - strtolower($keyword), - $keyword, - ); - $phpcsFile->addError($error, $stackPtr, 'Found', $data); - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/PHP/NoSilencedErrorsSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/PHP/NoSilencedErrorsSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/PHP/NoSilencedErrorsSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/PHP/NoSilencedErrorsSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,81 +0,0 @@ - - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Generic_Sniffs_PHP_NoSilencedErrorsSniff. - * - * Throws an error or warning when any code prefixed with an asperand is encountered. - * - * - * if (@in_array($array, $needle)) - * { - * doSomething(); - * } - * - * - * @category PHP - * @package PHP_CodeSniffer - * @author Andy Brockhurst - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Sniffs_PHP_NoSilencedErrorsSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * If true, an error will be thrown; otherwise a warning. - * - * @var bool - */ - public $error = false; - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array(T_ASPERAND); - - }//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) - { - $error = 'Silencing errors is forbidden'; - if ($this->error === true) { - $error = 'Silencing errors is forbidden'; - $phpcsFile->addError($error, $stackPtr, 'Forbidden'); - } else { - $error = 'Silencing errors is discouraged'; - $phpcsFile->addWarning($error, $stackPtr, 'Discouraged'); - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/PHP/UpperCaseConstantSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/PHP/UpperCaseConstantSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/PHP/UpperCaseConstantSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/PHP/UpperCaseConstantSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,84 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Generic_Sniffs_PHP_UpperCaseConstantSniff. - * - * Checks that all uses of TRUE, FALSE and NULL are uppercase. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Sniffs_PHP_UpperCaseConstantSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array( - T_TRUE, - T_FALSE, - T_NULL, - ); - - }//end register() - - - /** - * Processes this sniff, 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(); - - // Is this a member var name? - $prevPtr = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); - if ($tokens[$prevPtr]['code'] === T_OBJECT_OPERATOR) { - return; - } - - $keyword = $tokens[$stackPtr]['content']; - if (strtoupper($keyword) !== $keyword) { - $error = 'TRUE, FALSE and NULL must be uppercase; expected "%s" but found "%s"'; - $data = array( - strtoupper($keyword), - $keyword, - ); - $phpcsFile->addError($error, $stackPtr, 'Found', $data); - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Strings/UnnecessaryStringConcatSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Strings/UnnecessaryStringConcatSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Strings/UnnecessaryStringConcatSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/Strings/UnnecessaryStringConcatSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,125 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Generic_Sniffs_Strings_UnnecessaryStringConcatSniff. - * - * Checks that two strings are not concatenated together; suggests - * using one string instead. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Sniffs_Strings_UnnecessaryStringConcatSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - ); - - /** - * If true, an error will be thrown; otherwise a warning. - * - * @var bool - */ - public $error = true; - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array( - T_STRING_CONCAT, - T_PLUS, - ); - - }//end register() - - - /** - * Processes this sniff, 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) - { - // Work out which type of file this is for. - $tokens = $phpcsFile->getTokens(); - if ($tokens[$stackPtr]['code'] === T_STRING_CONCAT) { - if ($phpcsFile->tokenizerType === 'JS') { - return; - } - } else { - if ($phpcsFile->tokenizerType === 'PHP') { - return; - } - } - - $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); - $next = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); - if ($prev === false || $next === false) { - return; - } - - $stringTokens = PHP_CodeSniffer_Tokens::$stringTokens; - if (in_array($tokens[$prev]['code'], $stringTokens) === true - && in_array($tokens[$next]['code'], $stringTokens) === true - ) { - if ($tokens[$prev]['content'][0] === $tokens[$next]['content'][0]) { - // Before we throw an error for PHP, allow strings to be - // combined if they would have < and ? next to each other because - // this trick is sometimes required in PHP strings. - if ($phpcsFile->tokenizerType === 'PHP') { - $prevChar = substr($tokens[$prev]['content'], -2, 1); - $nextChar = $tokens[$next]['content'][1]; - $combined = $prevChar.$nextChar; - if ($combined === '?'.'>' || $combined === '<'.'?') { - return; - } - } - - $error = 'String concat is not required here; use a single string instead'; - if ($this->error === true) { - $phpcsFile->addError($error, $stackPtr, 'Found'); - } else { - $phpcsFile->addWarning($error, $stackPtr, 'Found'); - } - } - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/VersionControl/SubversionPropertiesSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/VersionControl/SubversionPropertiesSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/VersionControl/SubversionPropertiesSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/VersionControl/SubversionPropertiesSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,206 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Generic_Sniffs_VersionControl_SubversionPropertiesSniff. - * - * Tests that the correct Subversion properties are set. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Jack Bates - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Sniffs_VersionControl_SubversionPropertiesSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * The Subversion properties that should be set. - * - * Key of array is the SVN property and the value is the - * exact value the property should have or NULL if the - * property should just be set but the value is not fixed. - * - * @var array - */ - protected $properties = array( - 'svn:keywords' => 'Author Id Revision', - 'svn:eol-style' => 'native', - ); - - - /** - * 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 void - */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - - // Make sure this is the first PHP open tag so we don't process the - // same file twice. - $prevOpenTag = $phpcsFile->findPrevious(T_OPEN_TAG, ($stackPtr - 1)); - if ($prevOpenTag !== false) { - return; - } - - $path = $phpcsFile->getFileName(); - $properties = $this->getProperties($path); - if ($properties === null) { - // Not under version control. - return; - } - - $properties += $this->properties; - foreach ($properties as $key => $value) { - if (isset($properties[$key]) === true - && isset($this->properties[$key]) === false - ) { - $error = 'Unexpected Subversion property "%s" = "%s"'; - $data = array( - $key, - $properties[$key], - ); - $phpcsFile->addError($error, $stackPtr, 'Unexpected', $data); - continue; - } - - if (isset($properties[$key]) === false - && isset($this->properties[$key]) === true - ) { - $error = 'Missing Subversion property "%s" = "%s"'; - $data = array( - $key, - $this->properties[$key], - ); - $phpcsFile->addError($error, $stackPtr, 'Missing', $data); - continue; - } - - if ($properties[$key] !== null - && $properties[$key] !== $this->properties[$key] - ) { - $error = 'Subversion property "%s" = "%s" does not match "%s"'; - $data = array( - $key, - $properties[$key], - $this->properties[$key], - ); - $phpcsFile->addError($error, $stackPtr, 'NoMatch', $data); - } - }//end foreach - - }//end process() - - - /** - * Returns the Subversion properties which are actually set on a path. - * - * Returns NULL if the file is not under version control. - * - * @param string $path The path to return Subversion properties on. - * - * @return array - * @throws PHP_CodeSniffer_Exception If Subversion properties file could - * not be opened. - */ - protected function getProperties($path) - { - $properties = array(); - - $paths = array(); - $paths[] = dirname($path).'/.svn/props/'.basename($path).'.svn-work'; - $paths[] = dirname($path).'/.svn/prop-base/'.basename($path).'.svn-base'; - - $foundPath = false; - foreach ($paths as $path) { - if (file_exists($path) === true) { - $foundPath = true; - - $handle = fopen($path, 'r'); - if ($handle === false) { - $error = 'Error opening file; could not get Subversion properties'; - throw new PHP_CodeSniffer_Exception($error); - } - - while (feof($handle) === false) { - // Read a key length line. Might be END, though. - $buffer = trim(fgets($handle)); - - // Check for the end of the hash. - if ($buffer === 'END') { - break; - } - - // Now read that much into a buffer. - $key = fread($handle, substr($buffer, 2)); - - // Suck up extra newline after key data. - fgetc($handle); - - // Read a value length line. - $buffer = trim(fgets($handle)); - - // Now read that much into a buffer. - $length = substr($buffer, 2); - if ($length === '0') { - // Length of value is ZERO characters, so - // value is actually empty. - $value = ''; - } else { - $value = fread($handle, $length); - } - - // Suck up extra newline after value data. - fgetc($handle); - - $properties[$key] = $value; - }//end while - - fclose($handle); - }//end if - }//end foreach - - if ($foundPath === false) { - return null; - } - - return $properties; - - }//end getProperties() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/WhiteSpace/DisallowTabIndentSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/WhiteSpace/DisallowTabIndentSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/WhiteSpace/DisallowTabIndentSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/WhiteSpace/DisallowTabIndentSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,86 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Generic_Sniffs_WhiteSpace_DisallowTabIndentSniff. - * - * Throws errors if tabs are used for indentation. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Sniffs_WhiteSpace_DisallowTabIndentSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - 'CSS', - ); - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array(T_WHITESPACE); - - }//end register() - - - /** - * Processes this test, when one of its tokens is encountered. - * - * @param PHP_CodeSniffer_File $phpcsFile All the tokens found in the document. - * @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(); - - // Make sure this is whitespace used for indentation. - $line = $tokens[$stackPtr]['line']; - if ($stackPtr > 0 && $tokens[($stackPtr - 1)]['line'] === $line) { - return; - } - - if (strpos($tokens[$stackPtr]['content'], "\t") !== false) { - $error = 'Spaces must be used to indent lines; tabs are not allowed'; - $phpcsFile->addError($error, $stackPtr, 'TabsUsed'); - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,371 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Generic_Sniffs_Whitespace_ScopeIndentSniff. - * - * Checks that control structures are structured correctly, and their content - * is indented correctly. This sniff will throw errors if tabs are used - * for indentation rather than spaces. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Sniffs_WhiteSpace_ScopeIndentSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * The number of spaces code should be indented. - * - * @var int - */ - public $indent = 4; - - /** - * Does the indent need to be exactly right. - * - * If TRUE, indent needs to be exactly $indent spaces. If FALSE, - * indent needs to be at least $indent spaces (but can be more). - * - * @var bool - */ - public $exact = false; - - /** - * Any scope openers that should not cause an indent. - * - * @var array(int) - */ - protected $nonIndentingScopes = array(); - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return PHP_CodeSniffer_Tokens::$scopeOpeners; - - }//end register() - - - /** - * Processes this test, when one of its tokens is encountered. - * - * @param PHP_CodeSniffer_File $phpcsFile All the tokens found in the document. - * @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(); - - // If this is an inline condition (ie. there is no scope opener), then - // return, as this is not a new scope. - if (isset($tokens[$stackPtr]['scope_opener']) === false) { - return; - } - - if ($tokens[$stackPtr]['code'] === T_ELSE) { - $next = $phpcsFile->findNext( - PHP_CodeSniffer_Tokens::$emptyTokens, - ($stackPtr + 1), - null, - true - ); - - // We will handle the T_IF token in another call to process. - if ($tokens[$next]['code'] === T_IF) { - return; - } - } - - // Find the first token on this line. - $firstToken = $stackPtr; - for ($i = $stackPtr; $i >= 0; $i--) { - // Record the first code token on the line. - if (in_array($tokens[$i]['code'], PHP_CodeSniffer_Tokens::$emptyTokens) === false) { - $firstToken = $i; - } - - // It's the start of the line, so we've found our first php token. - if ($tokens[$i]['column'] === 1) { - break; - } - } - - // Based on the conditions that surround this token, determine the - // indent that we expect this current content to be. - $expectedIndent = $this->calculateExpectedIndent($tokens, $firstToken); - - // Don't process the first token if it is a closure because they have - // different indentation rules as they are often used as function arguments - // for multi-line function calls. But continue to process the content of the - // closure because it should be indented as normal. - if ($tokens[$firstToken]['code'] !== T_CLOSURE - && $tokens[$firstToken]['column'] !== $expectedIndent - ) { - $error = 'Line indented incorrectly; expected %s spaces, found %s'; - $data = array( - ($expectedIndent - 1), - ($tokens[$firstToken]['column'] - 1), - ); - $phpcsFile->addError($error, $stackPtr, 'Incorrect', $data); - } - - $scopeOpener = $tokens[$stackPtr]['scope_opener']; - $scopeCloser = $tokens[$stackPtr]['scope_closer']; - - // Some scopes are expected not to have indents. - if (in_array($tokens[$firstToken]['code'], $this->nonIndentingScopes) === false) { - $indent = ($expectedIndent + $this->indent); - } else { - $indent = $expectedIndent; - } - - $newline = false; - $commentOpen = false; - $inHereDoc = false; - - // Only loop over the content between the opening and closing brace, not - // the braces themselves. - for ($i = ($scopeOpener + 1); $i < $scopeCloser; $i++) { - - // If this token is another scope, skip it as it will be handled by - // another call to this sniff. - if (in_array($tokens[$i]['code'], PHP_CodeSniffer_Tokens::$scopeOpeners) === true) { - if (isset($tokens[$i]['scope_opener']) === true) { - $i = $tokens[$i]['scope_closer']; - - // If the scope closer is followed by a semi-colon, the semi-colon is part - // of the closer and should also be ignored. This most commonly happens with - // CASE statements that end with "break;", where we don't want to stop - // ignoring at the break, but rather at the semi-colon. - $nextToken = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($i + 1), null, true); - if ($tokens[$nextToken]['code'] === T_SEMICOLON) { - $i = $nextToken; - } - } else { - // If this token does not have a scope_opener indice, then - // it's probably an inline scope, so let's skip to the next - // semicolon. Inline scopes include inline if's, abstract - // methods etc. - $nextToken = $phpcsFile->findNext(T_SEMICOLON, $i, $scopeCloser); - if ($nextToken !== false) { - $i = $nextToken; - } - } - - continue; - }//end if - - // If this is a HEREDOC then we need to ignore it as the - // whitespace before the contents within the HEREDOC are - // considered part of the content. - if ($tokens[$i]['code'] === T_START_HEREDOC - || $tokens[$i]['code'] === T_START_NOWDOC - ) { - $inHereDoc = true; - continue; - } else if ($inHereDoc === true) { - if ($tokens[$i]['code'] === T_END_HEREDOC - || $tokens[$i]['code'] === T_END_NOWDOC - ) { - $inHereDoc = false; - } - - continue; - } - - if ($tokens[$i]['column'] === 1) { - // We started a newline. - $newline = true; - } - - if ($newline === true && $tokens[$i]['code'] !== T_WHITESPACE) { - // If we started a newline and we find a token that is not - // whitespace, then this must be the first token on the line that - // must be indented. - $newline = false; - $firstToken = $i; - - $column = $tokens[$firstToken]['column']; - - // Special case for non-PHP code. - if ($tokens[$firstToken]['code'] === T_INLINE_HTML) { - $trimmedContentLength - = strlen(ltrim($tokens[$firstToken]['content'])); - if ($trimmedContentLength === 0) { - continue; - } - - $contentLength = strlen($tokens[$firstToken]['content']); - $column = ($contentLength - $trimmedContentLength + 1); - } - - // Check to see if this constant string spans multiple lines. - // If so, then make sure that the strings on lines other than the - // first line are indented appropriately, based on their whitespace. - if (in_array($tokens[$firstToken]['code'], PHP_CodeSniffer_Tokens::$stringTokens) === true) { - if (in_array($tokens[($firstToken - 1)]['code'], PHP_CodeSniffer_Tokens::$stringTokens) === true) { - // If we find a string that directly follows another string - // then its just a string that spans multiple lines, so we - // don't need to check for indenting. - continue; - } - } - - // This is a special condition for T_DOC_COMMENT and C-style - // comments, which contain whitespace between each line. - if (in_array($tokens[$firstToken]['code'], PHP_CodeSniffer_Tokens::$commentTokens) === true) { - $content = trim($tokens[$firstToken]['content']); - if (preg_match('|^/\*|', $content) !== 0) { - // Check to see if the end of the comment is on the same line - // as the start of the comment. If it is, then we don't - // have to worry about opening a comment. - if (preg_match('|\*/$|', $content) === 0) { - // We don't have to calculate the column for the - // start of the comment as there is a whitespace - // token before it. - $commentOpen = true; - } - } else if ($commentOpen === true) { - if ($content === '') { - // We are in a comment, but this line has nothing on it - // so let's skip it. - continue; - } - - $contentLength = strlen($tokens[$firstToken]['content']); - $trimmedContentLength - = strlen(ltrim($tokens[$firstToken]['content'])); - - $column = ($contentLength - $trimmedContentLength + 1); - if (preg_match('|\*/$|', $content) !== 0) { - $commentOpen = false; - } - - // We are in a comment, so the indent does not have to - // be exact. The important thing is that the comment opens - // at the correct column and nothing sits closer to the left - // than that opening column. - if ($column > $indent) { - continue; - } - }//end if - }//end if - - // The token at the start of the line, needs to have its' column - // greater than the relative indent we set above. If it is less, - // an error should be shown. - if ($column !== $indent) { - if ($this->exact === true || $column < $indent) { - $type = 'IncorrectExact'; - $error = 'Line indented incorrectly; expected '; - if ($this->exact === false) { - $error .= 'at least '; - $type = 'Incorrect'; - } - - $error .= '%s spaces, found %s'; - $data = array( - ($indent - 1), - ($column - 1), - ); - $phpcsFile->addError($error, $firstToken, $type, $data); - } - }//end if - }//end if - }//end for - - }//end process() - - - /** - * Calculates the expected indent of a token. - * - * Returns the column at which the token should be indented to, so 1 means - * that the token should not be indented at all. - * - * @param array $tokens The stack of tokens for this file. - * @param int $stackPtr The position of the token to get indent for. - * - * @return int - */ - protected function calculateExpectedIndent(array $tokens, $stackPtr) - { - $conditionStack = array(); - - $inParenthesis = false; - if (isset($tokens[$stackPtr]['nested_parenthesis']) === true - && empty($tokens[$stackPtr]['nested_parenthesis']) === false - ) { - $inParenthesis = true; - } - - // Empty conditions array (top level structure). - if (empty($tokens[$stackPtr]['conditions']) === true) { - if ($inParenthesis === true) { - // Wrapped in parenthesis means it is probably in a - // function call (like a closure) so we have to assume indent - // is correct here and someone else will check it more - // carefully in another sniff. - return $tokens[$stackPtr]['column']; - } else { - return 1; - } - } - - $indent = 0; - - $tokenConditions = $tokens[$stackPtr]['conditions']; - foreach ($tokenConditions as $id => $condition) { - // If it's an indenting scope ie. it's not in our array of - // scopes that don't indent, increase indent. - if (in_array($condition, $this->nonIndentingScopes) === false) { - if ($condition === T_CLOSURE && $inParenthesis === true) { - // Closures cause problems with indents when they are - // used as function arguments because the code inside them - // is not technically inside the function yet, so the indent - // is always off by one. So instead, use the - // indent of the closure as the base value. - $indent = ($tokens[$id]['column'] - 1); - } - - $indent += $this->indent; - } - } - - // Increase by 1 to indiciate that the code should start at a specific column. - // E.g., code indented 4 spaces should start at column 5. - $indent++; - return $indent; - - }//end calculateExpectedIndent() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Classes/DuplicateClassNameUnitTest.1.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Classes/DuplicateClassNameUnitTest.1.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Classes/DuplicateClassNameUnitTest.1.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Classes/DuplicateClassNameUnitTest.1.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ - \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Classes/DuplicateClassNameUnitTest.2.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Classes/DuplicateClassNameUnitTest.2.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Classes/DuplicateClassNameUnitTest.2.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Classes/DuplicateClassNameUnitTest.2.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,4 +0,0 @@ - \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Classes/DuplicateClassNameUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Classes/DuplicateClassNameUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Classes/DuplicateClassNameUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Classes/DuplicateClassNameUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,89 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the DuplicateClassName multi-file sniff. - * - * A multi-file sniff unit test checks a .1.inc and a .2.inc file for expected violations - * of a single coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Tests_Classes_DuplicateClassNameUnitTest 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 array(); - - }//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. - * - * @param string $testFile The name of the file being tested. - * - * @return array(int => int) - */ - public function getWarningList($testFile='') - { - switch ($testFile) { - case 'DuplicateClassNameUnitTest.1.inc': - return array( - 6 => 1, - 7 => 1, - ); - break; - case 'DuplicateClassNameUnitTest.2.inc': - return array( - 2 => 1, - 3 => 1, - ); - break; - case 'DuplicateClassNameUnitTest.5.inc': - return array( - 3 => 1, - 7 => 1, - ); - break; - default: - return array(); - break; - }//end switch - - }//end getWarningList() - - -}//end class - -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/EmptyStatementUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/EmptyStatementUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/EmptyStatementUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/EmptyStatementUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,72 +0,0 @@ -getTraceAsString(); - } -} - -try { - throw Exception('Error...'); -} catch (Exception $e) {} - -try { - throw Exception('Error...'); -} catch (Exception $e) { - // TODO: Handle this exception later :-) -} - -if (true) {} elseif (false) {} \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/EmptyStatementUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/EmptyStatementUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/EmptyStatementUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/EmptyStatementUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,81 +0,0 @@ - - * @author Manuel Pichler - * @copyright 2007-2008 Manuel Pichler. All rights reserved. - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the EmptyStatement sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Manuel Pichler - * @copyright 2007-2008 Manuel Pichler. All rights reserved. - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Tests_CodeAnalysis_EmptyStatementUnitTest 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 array( - 64 => 1, - 68 => 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 array( - 3 => 1, - 15 => 1, - 17 => 1, - 19 => 1, - 30 => 1, - 35 => 1, - 41 => 1, - 47 => 1, - 52 => 1, - 55 => 1, - 72 => 2, - ); - - }//end getWarningList() - - -}//end class - -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/ForLoopShouldBeWhileLoopUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/ForLoopShouldBeWhileLoopUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/ForLoopShouldBeWhileLoopUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/ForLoopShouldBeWhileLoopUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -valid();) { - $it->next(); -} - -for (;(($it1->valid() && $foo) || (!$it2->value && ($bar || false)));/*Could be ingored*/) { - $it1->next(); - $it2->next(); -} \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/ForLoopShouldBeWhileLoopUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/ForLoopShouldBeWhileLoopUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/ForLoopShouldBeWhileLoopUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/ForLoopShouldBeWhileLoopUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,69 +0,0 @@ - - * @author Manuel Pichler - * @copyright 2007-2008 Manuel Pichler. All rights reserved. - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the ForLoopShouldBeWhileLoop sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Manuel Pichler - * @copyright 2007-2008 Manuel Pichler. All rights reserved. - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Tests_CodeAnalysis_ForLoopShouldBeWhileLoopUnitTest 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 array(); - - }//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 array( - 6 => 1, - 10 => 1, - ); - - }//end getWarningList() - - -}//end class - -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -rewind(); $it->valid(); $it->next()) { - echo $it->current(); -} \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,69 +0,0 @@ - - * @author Manuel Pichler - * @copyright 2007-2008 Manuel Pichler. All rights reserved. - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the ForLoopWithTestFunctionCall sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Manuel Pichler - * @copyright 2007-2008 Manuel Pichler. All rights reserved. - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Tests_CodeAnalysis_ForLoopWithTestFunctionCallUnitTest 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 array(); - - }//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 array( - 4 => 1, - 13 => 1, - ); - - }//end getWarningList() - - -}//end class - -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/JumbledIncrementerUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/JumbledIncrementerUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/JumbledIncrementerUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/JumbledIncrementerUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ - 3; $i++) { - - } - } -} - -for ($i = 0; $i < 20; $i++) { - for ($j = 0; $j < 5; $j += 2) { - for ($k = 0; $k > 3; $k++) { - - } - } -} - -for ($i = 0; $i < 20; $i++) { - for ($j = 0; $j < 5; $j += 2) { - for ($k = 0; $k > 3; $j++) { - - } - } -} \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/JumbledIncrementerUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/JumbledIncrementerUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/JumbledIncrementerUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/JumbledIncrementerUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,70 +0,0 @@ - - * @author Manuel Pichler - * @copyright 2007-2008 Manuel Pichler. All rights reserved. - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the JumbledIncrementer sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Manuel Pichler - * @copyright 2007-2008 Manuel Pichler. All rights reserved. - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Tests_CodeAnalysis_JumbledIncrementerUnitTest 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 array(); - - }//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 array( - 3 => 2, - 4 => 1, - 20 => 1, - ); - - }//end getWarningList() - - -}//end class - -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/UnconditionalIfStatementUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/UnconditionalIfStatementUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/UnconditionalIfStatementUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/UnconditionalIfStatementUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ - - * @author Manuel Pichler - * @copyright 2007-2008 Manuel Pichler. All rights reserved. - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the UnconditionalIfStatement sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Manuel Pichler - * @copyright 2007-2008 Manuel Pichler. All rights reserved. - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Tests_CodeAnalysis_UnconditionalIfStatementUnitTest 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 array(); - - }//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 array( - 3 => 1, - 5 => 1, - 7 => 1, - ); - - }//end getWarningList() - - -}//end class - -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/UnnecessaryFinalModifierUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/UnnecessaryFinalModifierUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/UnnecessaryFinalModifierUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/UnnecessaryFinalModifierUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ - - * @author Manuel Pichler - * @copyright 2007-2008 Manuel Pichler. All rights reserved. - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the UnnecessaryFinalModifier sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Manuel Pichler - * @copyright 2007-2008 Manuel Pichler. All rights reserved. - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Tests_CodeAnalysis_UnnecessaryFinalModifierUnitTest 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 array(); - - }//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 array( - 11 => 1, - 14 => 1, - 17 => 1, - ); - - }//end getWarningList() - - -}//end class - -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,66 +0,0 @@ - -$parameter -HTML; -} - -print foo( 'PARAMETER' ); -print "\n"; \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,69 +0,0 @@ - - * @author Manuel Pichler - * @copyright 2007-2008 Manuel Pichler. All rights reserved. - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the UnusedFunctionParameter sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Manuel Pichler - * @copyright 2007-2008 Manuel Pichler. All rights reserved. - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Tests_CodeAnalysis_UnusedFunctionParameterUnitTest 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 array(); - - }//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 array( - 3 => 1, - 7 => 1, - ); - - }//end getWarningList() - - -}//end class - -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/UselessOverridingMethodUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/UselessOverridingMethodUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/UselessOverridingMethodUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/UselessOverridingMethodUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ - - * @author Manuel Pichler - * @copyright 2007-2008 Manuel Pichler. All rights reserved. - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the UselessOverridingMethod sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Manuel Pichler - * @copyright 2007-2008 Manuel Pichler. All rights reserved. - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Tests_CodeAnalysis_UselessOverridingMethodUnitTest 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 array(); - - }//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 array( - 4 => 1, - 16 => 1, - ); - - }//end getWarningList() - - -}//end class - -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Commenting/FixmeUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Commenting/FixmeUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Commenting/FixmeUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Commenting/FixmeUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Commenting/FixmeUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Commenting/FixmeUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Commenting/FixmeUnitTest.js 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Commenting/FixmeUnitTest.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Commenting/FixmeUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Commenting/FixmeUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Commenting/FixmeUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Commenting/FixmeUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,99 +0,0 @@ - - * @author Marc McIntyre - * @author Sam Graham - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the Fixme sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @author Sam Graham - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Tests_Commenting_FixmeUnitTest 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='FixmeUnitTest.inc') - { - switch ($testFile) { - case 'FixmeUnitTest.inc': - return array( - 3 => 1, - 7 => 1, - 10 => 1, - 13 => 1, - 16 => 1, - 18 => 1, - 21 => 1, - ); - break; - case 'FixmeUnitTest.js': - return array( - 3 => 1, - 7 => 1, - 10 => 1, - 13 => 1, - 16 => 1, - 18 => 1, - 21 => 1, - ); - break; - default: - return array(); - break; - }//end switch - - }//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. - * - * @param string $testFile The name of the file being tested. - * - * @return array(int => int) - */ - public function getWarningList($testFile='FixmeUnitTest.inc') - { - return array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Commenting/TodoUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Commenting/TodoUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Commenting/TodoUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Commenting/TodoUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Commenting/TodoUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Commenting/TodoUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Commenting/TodoUnitTest.js 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Commenting/TodoUnitTest.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Commenting/TodoUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Commenting/TodoUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Commenting/TodoUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Commenting/TodoUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,97 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the Todo sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Tests_Commenting_TodoUnitTest 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='TodoUnitTest.inc') - { - return array(); - - }//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. - * - * @param string $testFile The name of the file being tested. - * - * @return array(int => int) - */ - public function getWarningList($testFile='TodoUnitTest.inc') - { - switch ($testFile) { - case 'TodoUnitTest.inc': - return array( - 3 => 1, - 7 => 1, - 10 => 1, - 13 => 1, - 16 => 1, - 18 => 1, - 21 => 1, - ); - break; - case 'TodoUnitTest.js': - return array( - 3 => 1, - 7 => 1, - 10 => 1, - 13 => 1, - 16 => 1, - 18 => 1, - 21 => 1, - ); - break; - default: - return array(); - break; - }//end switch - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ - 0; $i--) echo 'hello'; - -while ($something) echo 'hello'; - -do { - $i--; -} while ($something); - -if(true) - $someObject->{$name}; - -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.js 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ - 0; $i--) echo 'hello'; - -while ($something) echo 'hello'; - -do { - $i--; -} while ($something); - -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,93 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the InlineControlStructure sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Tests_ControlStructures_InlineControlStructureUnitTest 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='InlineControlStructureUnitTest.inc') - { - switch ($testFile) { - case 'InlineControlStructureUnitTest.inc': - return array( - 3 => 1, - 7 => 1, - 11 => 1, - 13 => 1, - 15 => 1, - 17 => 1, - 23 => 1, - ); - break; - case 'InlineControlStructureUnitTest.js': - return array( - 3 => 1, - 7 => 1, - 11 => 1, - 13 => 1, - 15 => 1, - ); - break; - default: - return array(); - break; - }//end switch - - }//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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,3 +0,0 @@ - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,67 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the ByteOrderMark sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Tests_Files_ByteOrderMarkUnitTest 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 array( - 1 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Files/LineEndingsUnitTest.css php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Files/LineEndingsUnitTest.css --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Files/LineEndingsUnitTest.css 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Files/LineEndingsUnitTest.css 1970-01-01 00:00:00.000000000 +0000 @@ -1,3 +0,0 @@ -#login-container { - margin-left: -225px; -} diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Files/LineEndingsUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Files/LineEndingsUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Files/LineEndingsUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Files/LineEndingsUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,7 +0,0 @@ - - - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Files/LineEndingsUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Files/LineEndingsUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Files/LineEndingsUnitTest.js 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Files/LineEndingsUnitTest.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -alert('hi'); -alert('hi'); diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Files/LineEndingsUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Files/LineEndingsUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Files/LineEndingsUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Files/LineEndingsUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,69 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the LineEndings sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Tests_Files_LineEndingsUnitTest 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 array( - 1 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Files/LineLengthUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Files/LineLengthUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Files/LineLengthUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Files/LineLengthUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,54 +0,0 @@ - -Hellob> - - - - - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the LineLength sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Tests_Files_LineLengthUnitTest 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 array( - 31 => 1, - 34 => 1, - 54 => 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 array( - 9 => 1, - 15 => 1, - 21 => 1, - 24 => 1, - 29 => 1, - 37 => 1, - ); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Formatting/DisallowMultipleStatementsUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Formatting/DisallowMultipleStatementsUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Formatting/DisallowMultipleStatementsUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Formatting/DisallowMultipleStatementsUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -wizardid = 10; $this->paint(); echo 'x'; -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Formatting/DisallowMultipleStatementsUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Formatting/DisallowMultipleStatementsUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Formatting/DisallowMultipleStatementsUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Formatting/DisallowMultipleStatementsUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,72 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the DisallowMultipleStatements sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Tests_Formatting_DisallowMultipleStatementsUnitTest 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 array( - 2 => 1, - 6 => 1, - 7 => 1, - 8 => 2, - ); - - }//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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,203 +0,0 @@ -findPrevious(); -$commentEnd = $this->_phpcsFile; -$expected .= '...'; - -// Invalid -$this->okButton = new Button(); -$content = new MyClass(); - - -$GLOBALS['_PEAR_ERRORSTACK_SINGLETON'] = array(); - -class MyClass -{ - const MODE_DEBUG = 'debug'; - const MODE_DEBUG2 = 'debug'; - - $array[$test] = 'anything'; - $var = 'anything'; - - const MODE_DEBUG2 = 'debug'; - $array[$test] = 'anything'; - $var = 'anything'; - $array[($test + 1)] = 'anything'; - $array[($blah + (10 - $test))] = 'anything'; -} - -function myFunction($var=true) -{ - if ($strict === true) { - $length = strlen($string); - $lastCharWasCaps = ($classFormat === false) ? false : true; - - for ($i = 1; $i < $length; $i++) { - $isCaps = (strtoupper($string{$i}) === $string{$i}) ? true : false; - if ($isCaps === true && $lastCharWasCaps === true) { - return false; - } - - $lastCharWasCaps = $isCaps; - } - } -} - -// Valid -for ($i = 0; $i < 10; $i += 2) { - $i = ($i - 1); -} - -// Invalid -foreach ($files as $file) { - $saves[$file] = array(); - $contents = stripslashes(file_get_contents($file)); - list($assetid, $time, $content) = explode("\n", $contents); - $saves[$file]['assetid'] = $assetid; -} - -$i = ($i - 10); -$ip = ($i - 10); -for ($i = 0; $i < 10; $i += 2) { - $i = ($i - 10); -} - -// Valid -$variable = 12; -$var = a_very(long_line('that', 'contains'), - a_bunch('of long', 'parameters'), - 'that_need to be aligned with the equal sign'); -$var2 = 12; - -// Valid -$variable = 12; -$var = 'a very long line of text that contains ' - .$someVar - .' and some other stuff that is too long to fit on one line'; -$var2 = 12; - -// Invalid -$variable = 12; -$var = a_very(long_line('that', 'contains'), - a_bunch('of long', 'parameters'), - 'that_need to be aligned with the equal sign'); -$var2 = 12; - -// Invalid -$variable = 12; -$var = 'a very long line of text that contains ' - .$someVar - .' and some other stuff that is too long to fit on one line'; -$var2 = 12; - -// Valid -$variable = 12; -$var .= 'a very long line of text that contains ' - .$someVar - .' and some other stuff that is too long to fit on one line'; -$var2 = 12; - -// Valid -$variable += 12; -$var .= 'a very long line of text that contains ' - .$someVar - .' and some other stuff that is too long to fit on one line'; -$var2 = 12; - -// Invalid -$variable = 12; -$var .= 'a very long line of text that contains ' - .$someVar - .' and some other stuff that is too long to fit on one line'; -$var2 = 12; - -// Valid -$error = false; -while (list($h, $f) = each($handle)) { - $error = true; -} - -// Valid -$value = false; -function blah ($value = true) { - $value = false; - if ($value === true) { - $value = false; - } -} - -if (TRUE) { - $args = array('foo' => 'foo'); - $res = 'bar'; -} -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.js 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,93 +0,0 @@ - - -// Valid -var1 = 'var1'; -var10 = 'var1'; -var100 = 'var1'; -var1000 = 'var1'; - -// Invalid -var1 = 'var1'; -var10 = 'var1'; -var100 = 'var1'; -var1000 = 'var1'; - -// Valid -var1 = 'var1'; -var10 = 'var1'; - -var100 = 'var1'; -var1000 = 'var1'; - -// Invalid -var1 = 'var1'; -var10 = 'var1'; - -var100 = 'var1'; -var1000 = 'var1'; - -// Valid -var1 += 'var1'; -var10 += 'var1'; -var100 += 'var1'; -var1000 += 'var1'; - -// Invalid -var1 += 'var1'; -var10 += 'var1'; -var100 += 'var1'; -var1000 += 'var1'; - -// Valid -var1 = 'var1'; -var10 += 'var1'; -var100 = 'var1'; -var1000 += 'var1'; - -// Invalid -var1 = 'var1'; -var10 += 'var1'; -var100 = 'var1'; -var1000 += 'var1'; - -// Valid -var1 += 'var1'; -var10 += 'var1'; - -var100 += 'var1'; -var1000 += 'var1'; - -// Invalid -var1 += 'var1'; -var10 += 'var1'; - -var100 += 'var1'; -var1000 += 'var1'; - -// Valid -var test = 100; - -// InValid -var test = 100; - -commentStart = phpcsFile.findPrevious(); -commentEnd = this._phpcsFile; -expected += '...'; - -// Invalid -this.okButton = {}; -content = {}; - -var buttonid = [this.id, '-positionFormats-add'].join(''); -var buttonWidget = WidgetStore.get(buttonid); -var spinButtonid = [this.id, '-positionFormats-spinButton'].join(''); -var spinButtonWidget = WidgetStore.get(spinButtonid); -var position = spinButtonWidget.getValue(); -var posForamatsList = WidgetStore.get([self.id, '-positionFormats-list'].join('')); - -dfx.stripTags = function(content, allowedTags) -{ - var match; - var re = 'blah'; -}; - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,134 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the MultipleStatementAlignment sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Tests_Formatting_MultipleStatementAlignmentUnitTest 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 array(); - - }//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. - * - * @param string $testFile The name of the file being tested. - * - * @return array(int => int) - */ - public function getWarningList($testFile='MultipleStatementAlignmentUnitTest.inc') - { - switch ($testFile) { - case 'MultipleStatementAlignmentUnitTest.inc': - return array( - 11 => 1, - 12 => 1, - 23 => 1, - 24 => 1, - 26 => 1, - 27 => 1, - 37 => 1, - 38 => 1, - 48 => 1, - 50 => 1, - 61 => 1, - 62 => 1, - 64 => 1, - 65 => 1, - 71 => 1, - 78 => 1, - 79 => 1, - 86 => 1, - 92 => 1, - 93 => 1, - 94 => 1, - 95 => 1, - 123 => 1, - 124 => 1, - 126 => 1, - 129 => 1, - 154 => 1, - 161 => 1, - 178 => 1, - 179 => 1, - 182 => 1, - ); - break; - case 'MultipleStatementAlignmentUnitTest.js': - return array( - 11 => 1, - 12 => 1, - 23 => 1, - 24 => 1, - 26 => 1, - 27 => 1, - 37 => 1, - 38 => 1, - 48 => 1, - 50 => 1, - 61 => 1, - 62 => 1, - 64 => 1, - 65 => 1, - 71 => 1, - 78 => 1, - 79 => 1, - 81 => 1, - 82 => 1, - 83 => 1, - 85 => 1, - 86 => 1, - ); - break; - default: - return array(); - break; - } - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Formatting/NoSpaceAfterCastUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Formatting/NoSpaceAfterCastUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Formatting/NoSpaceAfterCastUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Formatting/NoSpaceAfterCastUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Formatting/NoSpaceAfterCastUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Formatting/NoSpaceAfterCastUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Formatting/NoSpaceAfterCastUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Formatting/NoSpaceAfterCastUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,90 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the NoSpaceAfterCast sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Tests_Formatting_NoSpaceAfterCastUnitTest 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 array( - 3 => 1, - 5 => 1, - 7 => 1, - 9 => 1, - 11 => 1, - 13 => 1, - 15 => 1, - 17 => 1, - 19 => 1, - 21 => 1, - 23 => 1, - 25 => 1, - 27 => 1, - 29 => 1, - 31 => 1, - 33 => 1, - 35 => 1, - 37 => 1, - 39 => 1, - 41 => 1, - 43 => 1, - 45 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Formatting/SpaceAfterCastUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Formatting/SpaceAfterCastUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Formatting/SpaceAfterCastUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Formatting/SpaceAfterCastUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Formatting/SpaceAfterCastUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Formatting/SpaceAfterCastUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Formatting/SpaceAfterCastUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Formatting/SpaceAfterCastUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,90 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the SpaceAfterCast sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Tests_Formatting_SpaceAfterCastUnitTest 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 array( - 4 => 1, - 5 => 1, - 8 => 1, - 9 => 1, - 12 => 1, - 13 => 1, - 16 => 1, - 17 => 1, - 20 => 1, - 21 => 1, - 24 => 1, - 25 => 1, - 28 => 1, - 29 => 1, - 32 => 1, - 33 => 1, - 36 => 1, - 37 => 1, - 40 => 1, - 41 => 1, - 44 => 1, - 45 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Functions/CallTimePassByReferenceUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Functions/CallTimePassByReferenceUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Functions/CallTimePassByReferenceUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Functions/CallTimePassByReferenceUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -myfunc(&$myvar); -$this->myfunc($myvar); - -myclass::myfunc(&$myvar); -myclass::myfunc($myvar); - -while(testfunc($var1, &$var2, $var3, &$var4) === false) { -} -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Functions/CallTimePassByReferenceUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Functions/CallTimePassByReferenceUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Functions/CallTimePassByReferenceUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Functions/CallTimePassByReferenceUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,72 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the CallTimePassByReference sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Tests_Functions_CallTimePassByReferenceUnitTest 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 array( - 9 => 1, - 12 => 1, - 15 => 1, - 18 => 2, - ); - - }//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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,68 +0,0 @@ -getArray($one, $two,$three),$this->arrayMap); -$this->error($obj->getCode(),$obj->getMessage(),$obj->getFile(),$obj->getLine()); - -make_foo($string /*the string*/ , true /*test*/); -make_foo($string/*the string*/ , /*test*/ true); -make_foo($string /*the string*/, /*test*/ true); - -class MyClass { - function myFunction() { - blah($foo, "{{$config['host']}}", "{$config}", "hi there{}{}{{{}{}{}}"); - } -} - -// Function definition, not function call, so should be ignored -function &myFunction($arg1=1,$arg2=2) -{ -} - -return array_udiff( - $foo, - $bar, - function($a, $b) { - $foo='bar'; - return $foo; - } -); -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,79 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the FunctionCallArgumentSpacing sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Tests_Functions_FunctionCallArgumentSpacingUnitTest 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 array( - 5 => 1, - 6 => 1, - 7 => 2, - 8 => 1, - 11 => 2, - 12 => 2, - 13 => 3, - 42 => 3, - 43 => 3, - 45 => 1, - 46 => 2, - ); - - }//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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Functions/OpeningFunctionBraceBsdAllmanUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Functions/OpeningFunctionBraceBsdAllmanUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Functions/OpeningFunctionBraceBsdAllmanUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Functions/OpeningFunctionBraceBsdAllmanUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,157 +0,0 @@ - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Functions/OpeningFunctionBraceBsdAllmanUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Functions/OpeningFunctionBraceBsdAllmanUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Functions/OpeningFunctionBraceBsdAllmanUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Functions/OpeningFunctionBraceBsdAllmanUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,87 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the OpeningFunctionBraceBsdAllman sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Tests_Functions_OpeningFunctionBraceBsdAllmanUnitTest 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 array( - 4 => 1, - 13 => 1, - 19 => 1, - 24 => 1, - 30 => 1, - 40 => 1, - 44 => 1, - 50 => 1, - 55 => 1, - 67 => 1, - 78 => 1, - 85 => 1, - 91 => 1, - 98 => 1, - 110 => 1, - 115 => 1, - 122 => 1, - 128 => 1, - 155 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,117 +0,0 @@ - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,81 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the OpeningFunctionBraceKernighanRitchie sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Tests_Functions_OpeningFunctionBraceKernighanRitchieUnitTest 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 array( - 9 => 1, - 13 => 1, - 17 => 1, - 29 => 1, - 33 => 1, - 37 => 1, - 53 => 1, - 58 => 1, - 63 => 1, - 77 => 1, - 82 => 1, - 87 => 1, - 104 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Metrics/CyclomaticComplexityUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Metrics/CyclomaticComplexityUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Metrics/CyclomaticComplexityUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Metrics/CyclomaticComplexityUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,160 +0,0 @@ - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Metrics/CyclomaticComplexityUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Metrics/CyclomaticComplexityUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Metrics/CyclomaticComplexityUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Metrics/CyclomaticComplexityUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,72 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the CyclomaticComplexity sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Tests_Metrics_CyclomaticComplexityUnitTest 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 array( - 116 => 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 array( - 45 => 1, - 72 => 1, - ); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Metrics/NestingLevelUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Metrics/NestingLevelUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Metrics/NestingLevelUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Metrics/NestingLevelUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,102 +0,0 @@ - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Metrics/NestingLevelUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Metrics/NestingLevelUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Metrics/NestingLevelUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Metrics/NestingLevelUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,72 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the NestingLevel sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Tests_Metrics_NestingLevelUnitTest 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 array( - 73 => 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 array( - 27 => 1, - 46 => 1, - ); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ - \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,70 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the ConstructorName sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Tests_NamingConventions_ConstructorNameUnitTest 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 array( - 5 => 1, - 6 => 1, - 11 => 1, - 20 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,126 +0,0 @@ -define('bar'); -$foo->getBar()->define('foo'); - -// This is allowed as it is required for PHPUnit. -if (PHPUnit_MAIN_METHOD == 'PHP_Shell_AllTests::main') { - PHP_Shell_AllTests::main(); -} - -class ConstTest { - const TESTER = '1'; - public function __construct() { - echo constant('self::TESTER'); - echo constant('self::tester'); - } -} - -class A { - public static function constant($x) {} -} - -A::constant('anything-not-in-uppercase'); - -// goto -goto gotolabel; - -gototarget1: - -function ConstTest() { - gototarget2: -} - -switch($foo) -{ - case $bar: - gototarget3: -} - - -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,79 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the ValidConstantName sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Tests_NamingConventions_UpperCaseConstantNameUnitTest 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 array( - 8 => 1, - 10 => 1, - 15 => 1, - 25 => 1, - 26 => 1, - 27 => 1, - 28 => 1, - 29 => 1, - 32 => 1, - 35 => 1, - 100 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/PHP/DisallowShortOpenTagUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/PHP/DisallowShortOpenTagUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/PHP/DisallowShortOpenTagUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/PHP/DisallowShortOpenTagUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,6 +0,0 @@ -
- -Some content here. - - -
diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/PHP/DisallowShortOpenTagUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/PHP/DisallowShortOpenTagUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/PHP/DisallowShortOpenTagUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/PHP/DisallowShortOpenTagUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,81 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the DisallowShortOpenTag sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Tests_PHP_DisallowShortOpenTagUnitTest 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() - { - $option = (boolean) ini_get('short_open_tag'); - if ($option === true) { - return array( - 4 => 1, - 5 => 1, - ); - } else if (version_compare(PHP_VERSION, '5.4.0RC1') >= 0) { - // Shorthand echo is always available from PHP 5.4.0 but needed the - // short_open_tag ini var to be set for versions before this. - return array( - 4 => 1, - ); - } - - return array(); - - }//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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/PHP/ForbiddenFunctionsUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/PHP/ForbiddenFunctionsUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/PHP/ForbiddenFunctionsUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/PHP/ForbiddenFunctionsUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -sizeof($array); -$size = $class->count($array); -$class->delete($filepath); -$class->unset($filepath); - -function delete() {} -function unset() {} -function sizeof() {} -function count() {} -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/PHP/ForbiddenFunctionsUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/PHP/ForbiddenFunctionsUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/PHP/ForbiddenFunctionsUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/PHP/ForbiddenFunctionsUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,70 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the ForbiddenFunctions sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Tests_PHP_ForbiddenFunctionsUnitTest 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 array( - 2 => 1, - 4 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -NULL = 7; - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.js 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -if (variable === true) { } -if (variable === TRUE) { } -if (variable === True) { } -variable = True; - -if (variable === false) { } -if (variable === FALSE) { } -if (variable === False) { } -variable = false; - -if (variable === null) { } -if (variable === NULL) { } -if (variable === Null) { } -variable = NULL; diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,101 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the LowerCaseConstant sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Tests_PHP_LowerCaseConstantUnitTest 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='LowerCaseConstantUnitTest.inc') - { - switch ($testFile) { - case 'LowerCaseConstantUnitTest.inc': - return array( - 7 => 1, - 10 => 1, - 15 => 1, - 16 => 1, - 23 => 1, - 26 => 1, - 31 => 1, - 32 => 1, - 39 => 1, - 42 => 1, - 47 => 1, - 48 => 1, - ); - break; - case 'LowerCaseConstantUnitTest.js': - return array( - 2 => 1, - 3 => 1, - 4 => 1, - 7 => 1, - 8 => 1, - 12 => 1, - 13 => 1, - 14 => 1, - ); - break; - default: - return array(); - break; - } - - }//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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/PHP/NoSilencedErrorsUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/PHP/NoSilencedErrorsUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/PHP/NoSilencedErrorsUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/PHP/NoSilencedErrorsUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/PHP/NoSilencedErrorsUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/PHP/NoSilencedErrorsUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/PHP/NoSilencedErrorsUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/PHP/NoSilencedErrorsUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,67 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the NoSilencedErrors sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Tests_PHP_NoSilencedErrorsUnitTest 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 array(); - - }//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 array( - 5 => 1, - ); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/PHP/UpperCaseConstantUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/PHP/UpperCaseConstantUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/PHP/UpperCaseConstantUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/PHP/UpperCaseConstantUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -null = 7; - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/PHP/UpperCaseConstantUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/PHP/UpperCaseConstantUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/PHP/UpperCaseConstantUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/PHP/UpperCaseConstantUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,80 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the UpperCaseConstant sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Tests_PHP_UpperCaseConstantUnitTest 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 array( - 7 => 1, - 10 => 1, - 15 => 1, - 16 => 1, - 23 => 1, - 26 => 1, - 31 => 1, - 32 => 1, - 39 => 1, - 42 => 1, - 47 => 1, - 48 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -'; -$code = '<'.'?php '; -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.js 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -var x = 'My ' + 'string'; -var x = 'My ' + 1234; -var x = 'My ' + y + ' test'; - -this.errors['test'] = x; -this.errors['test' + 10] = x; -this.errors['test' + y] = x; -this.errors['test' + 'blah'] = x; -this.errors[y] = x; -this.errors[y + z] = x; -this.errors[y + z + 'My' + 'String'] = x; diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,86 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the UnnecessaryStringConcat sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Tests_Strings_UnnecessaryStringConcatUnitTest 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='UnnecessaryStringConcatUnitTest.inc') - { - switch ($testFile) { - case 'UnnecessaryStringConcatUnitTest.inc': - return array( - 2 => 1, - 6 => 1, - 9 => 1, - 12 => 1, - ); - break; - case 'UnnecessaryStringConcatUnitTest.js': - return array( - 1 => 1, - 8 => 1, - 11 => 1, - ); - break; - default: - return array(); - break; - } - - }//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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.css php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.css --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.css 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.css 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -#login-container { - margin-left: -225px; - width: 450px; -} - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.js 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -var x = { - abc: 1, - zyz: 2, - abc: 5, - mno: { - abc: 4 - }, - abc: 5 -} diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,91 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the DisallowTabIndent sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Tests_WhiteSpace_DisallowTabIndentUnitTest 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='DisallowTabIndentUnitTest.inc') - { - switch ($testFile) { - case 'DisallowTabIndentUnitTest.inc': - return array( - 5 => 1, - 9 => 1, - 15 => 1, - ); - break; - case 'DisallowTabIndentUnitTest.js': - return array( - 3 => 1, - 6 => 1, - ); - break; - case 'DisallowTabIndentUnitTest.css': - return array( - 2 => 1, - ); - break; - default: - return array(); - break; - }//end switch - - }//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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,413 +0,0 @@ -hello(); // error here - } - - function hello() // error here - { // no error here as brackets can be put anywhere in the pear standard - echo 'hello'; - } - - function hello2() - { - if (TRUE) { // error here - echo 'hello'; // no error here as its more than 4 spaces. - } else { - echo 'bye'; // error here - } - - while (TRUE) { - echo 'hello'; // error here - }// no error here as its handled by another test. - - do { // error here - echo 'hello'; // error here - } while (TRUE); // no error here as its aligned with the do. - }// no error here as its handled by another test. - - function hello3() - { - switch ($hello) { - case 'hello': - break; - } - } - -} - -?> -
-
-
-validate()) {
-    $safe = $form->getSubmitValues();
-}
-?>
-
-open(); // error here - } - - public function open() - { - // Some inline stuff that shouldn't error - if (TRUE) echo 'hello'; - foreach ($tokens as $token) echo $token; - } - - /** - * This is a comment 1. - * This is a comment 2. - * This is a comment 3. - * This is a comment 4. - */ - public function close() - { - // All ok. - if (TRUE) { - if (TRUE) { - } else if (FALSE) { - foreach ($tokens as $token) { - switch ($token) { - case '1': - case '2': - if (true) { - if (false) { - if (false) { - if (false) { - echo 'hello'; - } - } - } - } - break; - case '5': - break; - } - do { - while (true) { - foreach ($tokens as $token) { - for ($i = 0; $i < $token; $i++) { - echo 'hello'; - } - } - } - } while (true); - } - } - } - } - - /* - This is another c style comment 1. - This is another c style comment 2. - This is another c style comment 3. - This is another c style comment 4. - This is another c style comment 5. - */ - - /* - * - * - * - */ - - /** - */ - - /* - This comment has a newline in it. - - */ - - public function read() - { - echo 'hello'; - - // no errors below. - $array = array( - 'this', - 'that' => array( - 'hello', - 'hello again' => array( - 'hello', - ), - ), - ); - } -} - -abstract class Test3 -{ - public function parse() - { - - foreach ($t as $ndx => $token) { - if (is_array($token)) { - echo 'here'; - } else { - $ts[] = array("token" => $token, "value" => ''); - - $last = count($ts) - 1; - - switch ($token) { - case '(': - - if ($last >= 3 && - $ts[0]['token'] != T_CLASS && - $ts[$last - 2]['token'] == T_OBJECT_OPERATOR && - $ts[$last - 3]['token'] == T_VARIABLE ) { - - - if (true) { - echo 'hello'; - } - } - array_push($braces, $token); - break; - } - } - } - } -} - -public function test() -{ - $o = << - - - - doSomething( - function () { - echo 123; - } - ); - } -} - -some_function( - function() { - $a = 403; - if ($a === 404) { - $a = 403; - } - } -); - -some_function( - function() { - $a = 403; - if ($a === 404) { - $a = 403; - } - } -); - -$myFunction = function() { - $a = 403; - if ($a === 404) { - $a = 403; - } -} - -class Whatever -{ - protected $_protectedArray = array( - 'normalString' => 'That email address is already in use!', - 'offendingString' => <<<'STRING' -Each line of this string is always said to be at column 0, - no matter how many spaces are placed - at the beginning of each line -and the ending STRING on the next line is reported as having to be indented. -STRING - ); -} -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,92 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the ScopeIndent sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Generic_Tests_WhiteSpace_ScopeIndentUnitTest 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 array( - 7 => 1, - 10 => 1, - 17 => 1, - 20 => 1, - 24 => 1, - 27 => 1, - 28 => 1, - 58 => 1, - 123 => 1, - 126 => 1, - 224 => 1, - 225 => 1, - 279 => 1, - 280 => 1, - 281 => 1, - 282 => 1, - 283 => 1, - 284 => 1, - 311 => 1, - 336 => 1, - 349 => 1, - 380 => 1, - 387 => 1, - 397 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/ruleset.xml php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/ruleset.xml --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/ruleset.xml 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/ruleset.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,4 +0,0 @@ - - - A collection of generic sniffs. This standard is not designed to be used to check code. - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/IncorrectPatternException.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/IncorrectPatternException.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/IncorrectPatternException.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/IncorrectPatternException.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * An exception thrown if the pattern being processed is not supposed to be - * validating the code in question. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PHP_CodeSniffer_Standards_IncorrectPatternException extends Exception -{ - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Sniffs/CSS/BrowserSpecificStylesSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Sniffs/CSS/BrowserSpecificStylesSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Sniffs/CSS/BrowserSpecificStylesSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Sniffs/CSS/BrowserSpecificStylesSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,102 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * MySource_Sniffs_CSS_BrowserSpecificStylesSniff. - * - * Ensure that browser-specific styles are not used. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class MySource_Sniffs_CSS_BrowserSpecificStylesSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = array('CSS'); - - /** - * A list of specific stylsheet suffixes we allow. - * - * These stylsheets contain browser specific styles - * so this sniff ignore them files in the form: - * *_moz.css and *_ie7.css etc. - * - * @var array - */ - protected $specificStylesheets = array( - 'moz', - 'ie', - 'ie7', - 'ie8', - 'webkit', - ); - - - /** - * Returns the token types that this sniff is interested in. - * - * @return array(int) - */ - public function register() - { - return array(T_STYLE); - - }//end 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. - * - * @return void - */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) - { - // Ignore files with browser-specific suffixes. - $filename = $phpcsFile->getFilename(); - $breakChar = strrpos($filename, '_'); - if ($breakChar !== false && substr($filename, -4) === '.css') { - $specific = substr($filename, ($breakChar + 1), -4); - if (in_array($specific, $this->specificStylesheets) === true) { - return; - } - } - - $tokens = $phpcsFile->getTokens(); - $content = $tokens[$stackPtr]['content']; - - if ($content{0} === '-') { - $error = 'Browser-specific styles are not allowed'; - $phpcsFile->addError($error, $stackPtr, 'ForbiddenStyle'); - } - - }//end process() - - -}//end class - -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Sniffs/Channels/ChannelExceptionSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Sniffs/Channels/ChannelExceptionSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Sniffs/Channels/ChannelExceptionSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Sniffs/Channels/ChannelExceptionSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,76 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Ensures that all action classes throw ChannelExceptions only. - * - * @category PHP - * @package PHP_CodeSniffer_MySource - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class MySource_Sniffs_Channels_ChannelExceptionSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array(T_THROW); - - }//end register() - - - /** - * Processes this sniff, 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) - { - $fileName = strtolower($phpcsFile->getFilename()); - $matches = array(); - if (preg_match('|/systems/(.*)/([^/]+)?actions.inc$|', $fileName, $matches) === 0) { - // This is not an actions.inc file. - return; - } - - $tokens = $phpcsFile->getTokens(); - - $exception = $phpcsFile->findNext(array(T_STRING, T_VARIABLE), ($stackPtr + 1)); - $exceptionName = $tokens[$exception]['content']; - - if ($exceptionName !== 'ChannelException') { - $data = array($exceptionName); - $error = 'Channel actions can only throw ChannelException; found "%s"'; - $phpcsFile->addError($error, $exception, 'WrongExceptionType', $data); - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Sniffs/Channels/DisallowSelfActionsSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Sniffs/Channels/DisallowSelfActionsSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Sniffs/Channels/DisallowSelfActionsSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Sniffs/Channels/DisallowSelfActionsSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,131 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Ensures that self is not used to call public method in action classes. - * - * @category PHP - * @package PHP_CodeSniffer_MySource - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class MySource_Sniffs_Channels_DisallowSelfActionsSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array(T_CLASS); - - }//end register() - - - /** - * Processes this sniff, 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(); - - // We are not interested in abstract classes. - $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); - if ($prev !== false && $tokens[$prev]['code'] === T_ABSTRACT) { - return; - } - - // We are only interested in Action classes. - $classNameToken = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); - $className = $tokens[$classNameToken]['content']; - if (substr($className, -7) !== 'Actions') { - return; - } - - $foundFunctions = array(); - $foundCalls = array(); - - // Find all static method calls in the form self::method() in the class. - $classEnd = $tokens[$stackPtr]['scope_closer']; - for ($i = ($classNameToken + 1); $i < $classEnd; $i++) { - if ($tokens[$i]['code'] !== T_DOUBLE_COLON) { - if ($tokens[$i]['code'] === T_FUNCTION) { - // Cache the function information. - $funcName = $phpcsFile->findNext(T_STRING, ($i + 1)); - $funcScope = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$scopeModifiers, ($i - 1)); - - $foundFunctions[$tokens[$funcName]['content']] = strtolower($tokens[$funcScope]['content']); - } - - continue; - } - - $prevToken = $phpcsFile->findPrevious(T_WHITESPACE, ($i - 1), null, true); - if ($tokens[$prevToken]['content'] !== 'self') { - continue; - } - - $funcNameToken = $phpcsFile->findNext(T_WHITESPACE, ($i + 1), null, true); - if ($tokens[$funcNameToken]['code'] === T_VARIABLE) { - // We are only interested in function calls. - continue; - } - - $funcName = $tokens[$funcNameToken]['content']; - - // We've found the function, now we need to find it and see if it is - // public, private or protected. If it starts with an underscore we - // can assume it is private. - if ($funcName{0} === '_') { - continue; - } - - $foundCalls[$i] = $funcName; - }//end for - - $errorClassName = substr($className, 0, -7); - - foreach ($foundCalls as $token => $funcName) { - if (isset($foundFunctions[$funcName]) === false) { - // Function was not in this class, might have come from the parent. - // Either way, we can't really check this. - continue; - } else if ($foundFunctions[$funcName] === 'public') { - $error = 'Static calls to public methods in Action classes must not use the self keyword; use %s::%s() instead'; - $data = array( - $errorClassName, - $funcName, - ); - $phpcsFile->addError($error, $token, 'Found', $data); - } - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Sniffs/Channels/IncludeSystemSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Sniffs/Channels/IncludeSystemSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Sniffs/Channels/IncludeSystemSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Sniffs/Channels/IncludeSystemSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,329 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -if (class_exists('PHP_CodeSniffer_Standards_AbstractScopeSniff', true) === false) { - $error = 'Class PHP_CodeSniffer_Standards_AbstractScopeSniff not found'; - throw new PHP_CodeSniffer_Exception($error); -} - -/** - * Ensures that systems, asset types and libs are included before they are used. - * - * @category PHP - * @package PHP_CodeSniffer_MySource - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class MySource_Sniffs_Channels_IncludeSystemSniff extends PHP_CodeSniffer_Standards_AbstractScopeSniff -{ - - /** - * A list of classes that don't need to be included. - * - * @var array(string) - */ - private $_ignore = array( - 'self', - 'parent', - 'channels', - 'basesystem', - 'dal', - 'init', - 'pdo', - 'util', - 'ziparchive', - 'phpunit_framework_assert', - 'abstractmysourceunittest', - 'abstractdatacleanunittest', - 'exception', - 'abstractwidgetwidgettype', - 'domdocument', - ); - - - /** - * Constructs a Squiz_Sniffs_Scope_MethodScopeSniff. - */ - public function __construct() - { - parent::__construct(array(T_FUNCTION), array(T_DOUBLE_COLON, T_EXTENDS), true); - - }//end __construct() - - - /** - * Processes the function tokens within the class. - * - * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found. - * @param integer $stackPtr The position where the token was found. - * @param integer $currScope The current scope opener token. - * - * @return void - */ - protected function processTokenWithinScope( - PHP_CodeSniffer_File $phpcsFile, - $stackPtr, - $currScope - ) { - $tokens = $phpcsFile->getTokens(); - - // Determine the name of the class that the static function - // is being called on. - $classNameToken = $phpcsFile->findPrevious( - T_WHITESPACE, - ($stackPtr - 1), - null, - true - ); - - $className = $tokens[$classNameToken]['content']; - if (in_array(strtolower($className), $this->_ignore) === true) { - return; - } - - $includedClasses = array(); - - $fileName = strtolower($phpcsFile->getFilename()); - $matches = array(); - if (preg_match('|/systems/(.*)/([^/]+)?actions.inc$|', $fileName, $matches) !== 0) { - // This is an actions file, which means we don't - // have to include the system in which it exists. - $includedClasses[] = $matches[2]; - - // Or a system it implements. - $class = $phpcsFile->getCondition($stackPtr, T_CLASS); - $implements = $phpcsFile->findNext(T_IMPLEMENTS, $class, ($class + 10)); - if ($implements !== false) { - $implementsClass = $phpcsFile->findNext(T_STRING, $implements); - $implementsClassName = strtolower($tokens[$implementsClass]['content']); - if (substr($implementsClassName, -7) === 'actions') { - $includedClasses[] = substr($implementsClassName, 0, -7); - } - } - } - - // Go searching for includeSystem and includeAsset calls within this - // function, or the inclusion of .inc files, which - // would be library files. - for ($i = ($currScope + 1); $i < $stackPtr; $i++) { - $name = $this->getIncludedClassFromToken($phpcsFile, $tokens, $i); - if ($name !== false) { - $includedClasses[] = $name; - // Special case for Widgets cause they are, well, special. - } else if (strtolower($tokens[$i]['content']) === 'includewidget') { - $typeName = $phpcsFile->findNext(T_CONSTANT_ENCAPSED_STRING, ($i + 1)); - $typeName = trim($tokens[$typeName]['content'], " '"); - $includedClasses[] = strtolower($typeName).'widgettype'; - } - } - - // Now go searching for includeSystem, includeAsset or require/include - // calls outside our scope. If we are in a class, look outside the - // class. If we are not, look outside the function. - $condPtr = $currScope; - if ($phpcsFile->hasCondition($stackPtr, T_CLASS) === true) { - foreach ($tokens[$stackPtr]['conditions'] as $condPtr => $condType) { - if ($condType === T_CLASS) { - break; - } - } - } - - for ($i = 0; $i < $condPtr; $i++) { - // Skip other scopes. - if (isset($tokens[$i]['scope_closer']) === true) { - $i = $tokens[$i]['scope_closer']; - continue; - } - - $name = $this->getIncludedClassFromToken($phpcsFile, $tokens, $i); - if ($name !== false) { - $includedClasses[] = $name; - } - }//end for - - // If we are in a testing class, we might have also included - // some systems and classes in our setUp() method. - $setupFunction = null; - if ($phpcsFile->hasCondition($stackPtr, T_CLASS) === true) { - foreach ($tokens[$stackPtr]['conditions'] as $condPtr => $condType) { - if ($condType === T_CLASS) { - // Is this is a testing class? - $name = $phpcsFile->findNext(T_STRING, $condPtr); - $name = $tokens[$name]['content']; - if (substr($name, -8) === 'UnitTest') { - // Look for a method called setUp(). - $end = $tokens[$condPtr]['scope_closer']; - $function = $phpcsFile->findNext(T_FUNCTION, ($condPtr + 1), $end); - while ($function !== false) { - $name = $phpcsFile->findNext(T_STRING, $function); - if ($tokens[$name]['content'] === 'setUp') { - $setupFunction = $function; - break; - } - - $function = $phpcsFile->findNext(T_FUNCTION, ($function + 1), $end); - } - } - } - }//end foreach - }//end if - - if ($setupFunction !== null) { - $start = ($tokens[$setupFunction]['scope_opener'] + 1); - $end = $tokens[$setupFunction]['scope_closer']; - for ($i = $start; $i < $end; $i++) { - $name = $this->getIncludedClassFromToken($phpcsFile, $tokens, $i); - if ($name !== false) { - $includedClasses[] = $name; - } - } - }//end if - - if (in_array(strtolower($className), $includedClasses) === false) { - $error = 'Static method called on non-included class or system "%s"; include system with Channels::includeSystem() or include class with require_once'; - $data = array($className); - $phpcsFile->addError($error, $stackPtr, 'NotIncludedCall', $data); - } - - }//end processTokenWithinScope() - - - /** - * Processes a token within the scope that this test is listening to. - * - * @param PHP_CodeSniffer_File $phpcsFile The file where the token was found. - * @param int $stackPtr The position in the stack where - * this token was found. - * - * @return void - */ - protected function processTokenOutsideScope(PHP_CodeSniffer_File $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - - if ($tokens[$stackPtr]['code'] === T_EXTENDS) { - // Find the class name. - $classNameToken = $phpcsFile->findNext(T_STRING, ($stackPtr + 1)); - $className = $tokens[$classNameToken]['content']; - } else { - // Determine the name of the class that the static function - // is being called on. - $classNameToken = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); - $className = $tokens[$classNameToken]['content']; - } - - // Some systems are always available. - if (in_array(strtolower($className), $this->_ignore) === true) { - return; - } - - $includedClasses = array(); - - $fileName = strtolower($phpcsFile->getFilename()); - $matches = array(); - if (preg_match('|/systems/([^/]+)/([^/]+)?actions.inc$|', $fileName, $matches) !== 0) { - // This is an actions file, which means we don't - // have to include the system in which it exists - // We know the system from the path. - $includedClasses[] = $matches[1]; - } - - // Go searching for includeSystem, includeAsset or require/include - // calls outside our scope. - for ($i = 0; $i < $stackPtr; $i++) { - // Skip classes and functions as will we never get - // into their scopes when including this file, although - // we have a chance of getting into IF's, WHILE's etc. - $ignoreTokens = array( - T_CLASS, - T_INTERFACE, - T_FUNCTION, - ); - - if (in_array($tokens[$i]['code'], $ignoreTokens) === true - && isset($tokens[$i]['scope_closer']) === true - ) { - $i = $tokens[$i]['scope_closer']; - continue; - } - - $name = $this->getIncludedClassFromToken($phpcsFile, $tokens, $i); - if ($name !== false) { - $includedClasses[] = $name; - // Special case for Widgets cause they are, well, special. - } else if (strtolower($tokens[$i]['content']) === 'includewidget') { - $typeName = $phpcsFile->findNext(T_CONSTANT_ENCAPSED_STRING, ($i + 1)); - $typeName = trim($tokens[$typeName]['content'], " '"); - $includedClasses[] = strtolower($typeName).'widgettype'; - } - }//end for - - if (in_array(strtolower($className), $includedClasses) === false) { - if ($tokens[$stackPtr]['code'] === T_EXTENDS) { - $error = 'Class extends non-included class or system "%s"; include system with Channels::includeSystem() or include class with require_once'; - $data = array($className); - $phpcsFile->addError($error, $stackPtr, 'NotIncludedExtends', $data); - } else { - $error = 'Static method called on non-included class or system "%s"; include system with Channels::includeSystem() or include class with require_once'; - $data = array($className); - $phpcsFile->addError($error, $stackPtr, 'NotIncludedCall', $data); - } - } - - }//end processTokenOutsideScope() - - - /** - * Determines the included class name from given token. - * - * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found. - * @param array $tokens The array of file tokens. - * @param int $stackPtr The position in the tokens array of the - * potentially included class. - * - * @return string - */ - protected function getIncludedClassFromToken( - PHP_CodeSniffer_File $phpcsFile, - array $tokens, - $stackPtr - ) { - if (strtolower($tokens[$stackPtr]['content']) === 'includesystem') { - $systemName = $phpcsFile->findNext(T_CONSTANT_ENCAPSED_STRING, ($stackPtr + 1)); - $systemName = trim($tokens[$systemName]['content'], " '"); - return strtolower($systemName); - } else if (strtolower($tokens[$stackPtr]['content']) === 'includeasset') { - $typeName = $phpcsFile->findNext(T_CONSTANT_ENCAPSED_STRING, ($stackPtr + 1)); - $typeName = trim($tokens[$typeName]['content'], " '"); - return strtolower($typeName).'assettype'; - } else if (in_array($tokens[$stackPtr]['code'], PHP_CodeSniffer_Tokens::$includeTokens) === true) { - $filePath = $phpcsFile->findNext(T_CONSTANT_ENCAPSED_STRING, ($stackPtr + 1)); - $filePath = $tokens[$filePath]['content']; - $filePath = trim($filePath, " '"); - $filePath = basename($filePath, '.inc'); - return strtolower($filePath); - } - - return false; - - }//end getIncludedClassFromToken() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Sniffs/Channels/UnusedSystemSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Sniffs/Channels/UnusedSystemSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Sniffs/Channels/UnusedSystemSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Sniffs/Channels/UnusedSystemSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,157 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Ensures that systems and asset types are used if they are included. - * - * @category PHP - * @package PHP_CodeSniffer_MySource - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class MySource_Sniffs_Channels_UnusedSystemSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array(T_DOUBLE_COLON); - - }//end register() - - - /** - * Processes this sniff, 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(); - - // Check if this is a call to includeSystem, includeAsset or includeWidget. - $methodName = strtolower($tokens[($stackPtr + 1)]['content']); - if (in_array($methodName, array('includesystem', 'includeasset', 'includewidget')) === true) { - $systemName = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 3), null, true); - if ($systemName === false || $tokens[$systemName]['code'] !== T_CONSTANT_ENCAPSED_STRING) { - // Must be using a variable instead of a specific system name. - // We can't accurately check that. - return; - } - - $systemName = trim($tokens[$systemName]['content'], " '"); - } else { - return; - } - - if ($methodName === 'includeasset') { - $systemName .= 'assettype'; - } else if ($methodName === 'includewidget') { - $systemName .= 'widgettype'; - } - - $systemName = strtolower($systemName); - - // Now check if this system is used anywhere in this scope. - $level = $tokens[$stackPtr]['level']; - for ($i = ($stackPtr + 1); $i < $phpcsFile->numTokens; $i++) { - if ($tokens[$i]['level'] < $level) { - // We have gone out of scope. - // If the original include was inside an IF statement that - // is checking if the system exists, check the outer scope - // as well. - if ($tokens[$stackPtr]['level'] === $level) { - // We are still in the base level, so this is the first - // time we have got here. - $conditions = array_keys($tokens[$stackPtr]['conditions']); - if (empty($conditions) === false) { - $cond = array_pop($conditions); - if ($tokens[$cond]['code'] === T_IF) { - $i = $tokens[$cond]['scope_closer']; - $level--; - continue; - } - } - } - - break; - }//end if - - $validTokens = array( - T_DOUBLE_COLON, - T_EXTENDS, - T_IMPLEMENTS, - ); - - if (in_array($tokens[$i]['code'], $validTokens) === false) { - continue; - } - - switch ($tokens[$i]['code']) { - case T_DOUBLE_COLON: - $usedName = strtolower($tokens[($i - 1)]['content']); - if ($usedName === $systemName) { - // The included system was used, so it is fine. - return; - } - - break; - case T_EXTENDS: - $classNameToken = $phpcsFile->findNext(T_STRING, ($i + 1)); - $className = strtolower($tokens[$classNameToken]['content']); - if ($className === $systemName) { - // The included system was used, so it is fine. - return; - } - - break; - case T_IMPLEMENTS: - $endImplements = $phpcsFile->findNext(array(T_EXTENDS, T_OPEN_CURLY_BRACKET), ($i + 1)); - for ($x = ($i + 1); $x < $endImplements; $x++) { - if ($tokens[$x]['code'] === T_STRING) { - $className = strtolower($tokens[$x]['content']); - if ($className === $systemName) { - // The included system was used, so it is fine. - return; - } - } - } - - break; - }//end switch - }//end for - - // If we get to here, the system was not use. - $error = 'Included system "%s" is never used'; - $data = array($systemName); - $phpcsFile->addError($error, $stackPtr, 'Found', $data); - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Sniffs/Commenting/FunctionCommentSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Sniffs/Commenting/FunctionCommentSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Sniffs/Commenting/FunctionCommentSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Sniffs/Commenting/FunctionCommentSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,134 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -if (class_exists('Squiz_Sniffs_Commenting_FunctionCommentSniff', true) === false) { - $error = 'Class Squiz_Sniffs_Commenting_FunctionCommentSniff not found'; - throw new PHP_CodeSniffer_Exception($error); -} - -/** - * Parses and verifies the doc comments for functions. - * - * Same as the Squiz standard, but adds support for API tags. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class MySource_Sniffs_Commenting_FunctionCommentSniff extends Squiz_Sniffs_Commenting_FunctionCommentSniff -{ - - - /** - * Process a list of unknown tags. - * - * @param int $commentStart The position in the stack where the comment started. - * @param int $commentEnd The position in the stack where the comment ended. - * - * @return void - */ - protected function processUnknownTags($commentStart, $commentEnd) - { - $unknownTags = $this->commentParser->getUnknown(); - $words = $this->commentParser->getWords(); - $hasApiTag = false; - $apiLength = 3; - foreach ($unknownTags as $errorTag) { - $pos = $errorTag['pos']; - if ($errorTag['tag'] === 'api') { - if ($hasApiTag === true) { - // We've come across an API tag already, which means - // we were not the first tag in the API list. - $error = 'The @api tag must come first in the @api tag list in a function comment'; - $this->currentFile->addError($error, ($commentStart + $errorTag['line']), 'ApiNotFirst'); - } - - $hasApiTag = true; - - // There needs to be a blank line before the @api tag. - // So expect a single space before the tag, then 2 newlines before - // that, then some content. - if (trim($words[($pos - 2)]) !== '' - || strpos($words[($pos - 2)], $this->currentFile->eolChar) === false - || strpos($words[($pos - 3)], $this->currentFile->eolChar) === false - || trim($words[($pos - 4)]) === '' - ) { - $error = 'There must be one blank line before the @api tag in a function comment'; - $this->currentFile->addError($error, ($commentStart + $errorTag['line']), 'ApiSpacing'); - } - } else if (substr($errorTag['tag'], 0, 4) === 'api-') { - $hasApiTag = true; - - $tagLength = strlen($errorTag['tag']); - if ($tagLength > $apiLength) { - $apiLength = $tagLength; - } - - if (trim($words[($pos - 2)]) !== '' - || strpos($words[($pos - 2)], $this->currentFile->eolChar) === false - || trim($words[($pos - 3)]) === '' - ) { - $error = 'There must be no blank line before the @%s tag in a function comment'; - $data = array($errorTag['tag']); - $this->currentFile->addError($error, ($commentStart + $errorTag['line']), 'ApiTagSpacing', $data); - } - } else { - $error = '@%s tag is not allowed in function comment'; - $data = array($errorTag['tag']); - $this->currentFile->addWarning($error, ($commentStart + $errorTag['line']), 'TagNotAllowed', $data); - }//end if - }//end foreach - - if ($hasApiTag === true) { - // API tags must be the last tags in a function comment. - $order = $this->commentParser->getTagOrders(); - $lastTag = array_pop($order); - if ($lastTag !== 'api' - && substr($lastTag, 0, 4) !== 'api-' - ) { - $error = 'The @api tags must be the last tags in a function comment'; - $this->currentFile->addError($error, $commentEnd, 'ApiNotLast'); - } - - // Check API tag indenting. - foreach ($unknownTags as $errorTag) { - if ($errorTag['tag'] === 'api' - || substr($errorTag['tag'], 0, 4) === 'api-' - ) { - $expected = ($apiLength - strlen($errorTag['tag']) + 1); - $found = strlen($words[($errorTag['pos'] + 1)]); - if ($found !== $expected) { - $error = '@%s tag indented incorrectly; expected %s spaces but found %s'; - $data = array( - $errorTag['tag'], - $expected, - $found, - ); - $this->currentFile->addError($error, ($commentStart + $errorTag['line']), 'ApiTagIndent', $data); - } - } - } - }//end if - - }//end processUnknownTags() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Sniffs/Debug/DebugCodeSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Sniffs/Debug/DebugCodeSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Sniffs/Debug/DebugCodeSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Sniffs/Debug/DebugCodeSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,68 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Warns about the use of debug code. - * - * @category PHP - * @package PHP_CodeSniffer_MySource - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class MySource_Sniffs_Debug_DebugCodeSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array(T_DOUBLE_COLON); - - }//end register() - - - /** - * Processes this sniff, 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(); - - $className = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); - if (strtolower($tokens[$className]['content']) === 'debug') { - $method = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); - $error = 'Call to debug function Debug::%s() must be removed'; - $data = array($tokens[$method]['content']); - $phpcsFile->addError($error, $stackPtr, 'Found', $data); - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Sniffs/Debug/FirebugConsoleSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Sniffs/Debug/FirebugConsoleSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Sniffs/Debug/FirebugConsoleSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Sniffs/Debug/FirebugConsoleSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,77 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Ensures that console is not used for function or var names. - * - * @category PHP - * @package PHP_CodeSniffer_MySource - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class MySource_Sniffs_Debug_FirebugConsoleSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = array('JS'); - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array( - T_STRING, - T_PROPERTY, - T_LABEL, - T_OBJECT, - ); - - }//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(); - - if (strtolower($tokens[$stackPtr]['content']) === 'console') { - $error = 'Variables, functions and labels must not be named "console"; name may conflict with Firebug internal variable'; - $phpcsFile->addError($error, $stackPtr, 'ConflictFound'); - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Sniffs/Objects/AssignThisSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Sniffs/Objects/AssignThisSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Sniffs/Objects/AssignThisSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Sniffs/Objects/AssignThisSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,94 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Ensures this is not assigned to any other var but self. - * - * @category PHP - * @package PHP_CodeSniffer_MySource - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class MySource_Sniffs_Objects_AssignThisSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = array('JS'); - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array(T_THIS); - - }//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(); - - // Ignore this.something and other uses of "this" that are not - // direct assignments. - $next = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); - if ($tokens[$next]['code'] !== T_SEMICOLON) { - if ($tokens[$next]['line'] === $tokens[$stackPtr]['line']) { - return; - } - } - - // Something must be assigned to "this". - $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); - if ($tokens[$prev]['code'] !== T_EQUAL) { - return; - } - - // A variable needs to be assigned to "this". - $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($prev - 1), null, true); - if ($tokens[$prev]['code'] !== T_STRING) { - return; - } - - // We can only assign "this" to a var called "self". - if ($tokens[$prev]['content'] !== 'self' && $tokens[$prev]['content'] !== '_self') { - $error = 'Keyword "this" can only be assigned to a variable called "self" or "_self"'; - $phpcsFile->addError($error, $prev, 'NotSelf'); - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Sniffs/Objects/CreateWidgetTypeCallbackSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Sniffs/Objects/CreateWidgetTypeCallbackSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Sniffs/Objects/CreateWidgetTypeCallbackSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Sniffs/Objects/CreateWidgetTypeCallbackSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,228 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Ensures the create() method of widget types properly uses callbacks. - * - * @category PHP - * @package PHP_CodeSniffer_MySource - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class MySource_Sniffs_Objects_CreateWidgetTypeCallbackSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = array('JS'); - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array(T_OBJECT); - - }//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(); - - $className = $tokens[$stackPtr]['content']; - if (substr(strtolower($className), -10) !== 'widgettype') { - return; - } - - // Search for a create method. - $start = ($tokens[$stackPtr]['scope_opener'] + 1); - $end = ($tokens[$stackPtr]['scope_closer'] - 1); - $create = $phpcsFile->findNext(T_PROPERTY, $start, $end, null, 'create'); - if ($create === false) { - return; - } - - $function = $phpcsFile->findNext(array(T_WHITESPACE, T_COLON), ($create + 1), null, true); - if ($tokens[$function]['code'] !== T_FUNCTION) { - continue; - } - - $start = ($tokens[$function]['scope_opener'] + 1); - $end = ($tokens[$function]['scope_closer'] - 1); - - // Check that the first argument is called "callback". - $arg = $phpcsFile->findNext(T_WHITESPACE, ($tokens[$function]['parenthesis_opener'] + 1), null, true); - if ($tokens[$arg]['content'] !== 'callback') { - $error = 'The first argument of the create() method of a widget type must be called "callback"'; - $phpcsFile->addError($error, $arg, 'FirstArgNotCallback'); - } - - /* - Look for return statements within the function. They cannot return - anything and must be preceeded by the callback.call() line. The - callback itself must contain "self" or "this" as the first argument - and there needs to be a call to the callback function somewhere - in the create method. All calls to the callback function must be - followed by a return statement or the end of the method. - */ - - $foundCallback = false; - $passedCallback = false; - $nestedFunction = null; - for ($i = $start; $i <= $end; $i++) { - // Keep track of nested functions. - if ($nestedFunction !== null) { - if ($i === $nestedFunction) { - $nestedFunction = null; - continue; - } - } else if ($tokens[$i]['code'] === T_FUNCTION - && isset($tokens[$i]['scope_closer']) === true - ) { - $nestedFunction = $tokens[$i]['scope_closer']; - continue; - } - - if ($nestedFunction === null && $tokens[$i]['code'] === T_RETURN) { - // Make sure return statements are not returning anything. - if ($tokens[($i + 1)]['code'] !== T_SEMICOLON) { - $error = 'The create() method of a widget type must not return a value'; - $phpcsFile->addError($error, $i, 'ReturnValue'); - } - - continue; - } else if ($tokens[$i]['code'] !== T_STRING - || $tokens[$i]['content'] !== 'callback' - ) { - continue; - } - - // If this is the form "callback.call(" then it is a call - // to the callback function. - if ($tokens[($i + 1)]['code'] !== T_OBJECT_OPERATOR - || $tokens[($i + 2)]['content'] !== 'call' - || $tokens[($i + 3)]['code'] !== T_OPEN_PARENTHESIS - ) { - // One last chance; this might be the callback function - // being passed to another function, like this - // "this.init(something, callback, something)". - if (isset($tokens[$i]['nested_parenthesis']) === false) { - continue; - } - - // Just make sure those brackets dont belong to anyone, - // like an IF or FOR statement. - foreach ($tokens[$i]['nested_parenthesis'] as $bracket) { - if (isset($tokens[$bracket]['parenthesis_owner']) === true) { - continue(2); - } - } - - // Note that we use this endBracket down further when checking - // for a RETURN statement. - $endBracket = end($tokens[$i]['nested_parenthesis']); - $bracket = key($tokens[$i]['nested_parenthesis']); - - $prev = $phpcsFile->findPrevious( - PHP_CodeSniffer_Tokens::$emptyTokens, - ($bracket - 1), - null, - true - ); - - if ($tokens[$prev]['code'] !== T_STRING) { - // This is not a function passing the callback. - continue; - } - - $passedCallback = true; - }//end if - - $foundCallback = true; - - if ($passedCallback === false) { - // The first argument must be "this" or "self". - $arg = $phpcsFile->findNext(T_WHITESPACE, ($i + 4), null, true); - if ($tokens[$arg]['content'] !== 'this' - && $tokens[$arg]['content'] !== 'self' - ) { - $error = 'The first argument passed to the callback function must be "this" or "self"'; - $phpcsFile->addError($error, $arg, 'FirstArgNotSelf'); - } - } - - // Now it must be followed by a return statement or the end of the function. - if ($passedCallback === false) { - $endBracket = $tokens[($i + 3)]['parenthesis_closer']; - } - - for ($next = $endBracket; $next <= $end; $next++) { - // Skip whitespace so we find the next content after the call. - if (in_array($tokens[$next]['code'], PHP_CodeSniffer_Tokens::$emptyTokens) === true) { - continue; - } - - // Skip closing braces like END IF because it is not executable code. - if ($tokens[$next]['code'] === T_CLOSE_CURLY_BRACKET) { - continue; - } - - // We don't care about anything on the current line, like a - // semicolon. It doesn't matter if there are other statements on the - // line because another sniff will check for those. - if ($tokens[$next]['line'] === $tokens[$endBracket]['line']) { - continue; - } - - break; - } - - if ($next !== $tokens[$function]['scope_closer'] - && $tokens[$next]['code'] !== T_RETURN - ) { - $error = 'The call to the callback function must be followed by a return statement if it is not the last statement in the create() method'; - $phpcsFile->addError($error, $i, 'NoReturn'); - } - }//end for - - if ($foundCallback === false) { - $error = 'The create() method of a widget type must call the callback function'; - $phpcsFile->addError($error, $create, 'CallbackNotCalled'); - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Sniffs/Objects/DisallowNewWidgetSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Sniffs/Objects/DisallowNewWidgetSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Sniffs/Objects/DisallowNewWidgetSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Sniffs/Objects/DisallowNewWidgetSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,72 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Ensures that widgets are not manually created. - * - * @category PHP - * @package PHP_CodeSniffer_MySource - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class MySource_Sniffs_Objects_DisallowNewWidgetSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array(T_NEW); - - }//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(); - - $className = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); - if ($tokens[$className]['code'] !== T_STRING) { - return; - } - - if (substr(strtolower($tokens[$className]['content']), -10) === 'widgettype') { - $widgetType = substr($tokens[$className]['content'], 0, -10); - $error = 'Manual creation of widget objects is banned; use Widget::getWidget(\'%s\'); instead'; - $data = array($widgetType); - $phpcsFile->addError($error, $stackPtr, 'Found', $data); - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Sniffs/PHP/EvalObjectFactorySniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Sniffs/PHP/EvalObjectFactorySniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Sniffs/PHP/EvalObjectFactorySniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Sniffs/PHP/EvalObjectFactorySniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,126 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Ensures that eval() is not used to create objects. - * - * @category PHP - * @package PHP_CodeSniffer_MySource - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class MySource_Sniffs_PHP_EvalObjectFactorySniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array(T_EVAL); - - }//end register() - - - /** - * Processes this sniff, 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(); - - /* - We need to find all strings that will be in the eval - to determine if the "new" keyword is being used. - */ - - $openBracket = $phpcsFile->findNext(T_OPEN_PARENTHESIS, ($stackPtr + 1)); - $closeBracket = $tokens[$openBracket]['parenthesis_closer']; - - $strings = array(); - $vars = array(); - - for ($i = ($openBracket + 1); $i < $closeBracket; $i++) { - if (in_array($tokens[$i]['code'], PHP_CodeSniffer_Tokens::$stringTokens) === true) { - $strings[$i] = $tokens[$i]['content']; - } else if ($tokens[$i]['code'] === T_VARIABLE) { - $vars[$i] = $tokens[$i]['content']; - } - } - - /* - We now have some variables that we need to expand into - the strings that were assigned to them, if any. - */ - - foreach ($vars as $varPtr => $varName) { - while (($prev = $phpcsFile->findPrevious(T_VARIABLE, ($varPtr - 1))) !== false) { - // Make sure this is an assignment of the variable. That means - // it will be the first thing on the line. - $prevContent = $phpcsFile->findPrevious(T_WHITESPACE, ($prev - 1), null, true); - if ($tokens[$prevContent]['line'] === $tokens[$prev]['line']) { - $varPtr = $prevContent; - continue; - } - - if ($tokens[$prev]['content'] !== $varName) { - // This variable has a different name. - $varPtr = $prevContent; - continue; - } - - // We found one. - break; - }//end while - - if ($prev !== false) { - // Find all strings on the line. - $lineEnd = $phpcsFile->findNext(T_SEMICOLON, ($prev + 1)); - for ($i = ($prev + 1); $i < $lineEnd; $i++) { - if (in_array($tokens[$i]['code'], PHP_CodeSniffer_Tokens::$stringTokens) === true) { - $strings[$i] = $tokens[$i]['content']; - } - } - } - }//end foreach - - foreach ($strings as $string) { - // If the string has "new" in it, it is not allowed. - // We don't bother checking if the word "new" is echo'd - // because that is unlikely to happen. We assume the use - // of "new" is for object instantiation. - if (strstr($string, ' new ') !== false) { - $error = 'Do not use eval() to create objects dynamically; use reflection instead'; - $phpcsFile->addWarning($error, $stackPtr, 'Found'); - } - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Sniffs/PHP/GetRequestDataSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Sniffs/PHP/GetRequestDataSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Sniffs/PHP/GetRequestDataSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Sniffs/PHP/GetRequestDataSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,119 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Ensures that getRequestData() is used to access super globals. - * - * @category PHP - * @package PHP_CodeSniffer_MySource - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class MySource_Sniffs_PHP_GetRequestDataSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array(T_VARIABLE); - - }//end register() - - - /** - * Processes this sniff, 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(); - - $varName = $tokens[$stackPtr]['content']; - if ($varName !== '$_REQUEST' - && $varName !== '$_GET' - && $varName !== '$_POST' - && $varName !== '$_FILES' - ) { - return; - } - - // The only place these super globals can be accessed directly is - // in the getRequestData() method of the Security class. - $inClass = false; - foreach ($tokens[$stackPtr]['conditions'] as $i => $type) { - if ($tokens[$i]['code'] === T_CLASS) { - $className = $phpcsFile->findNext(T_STRING, $i); - $className = $tokens[$className]['content']; - if (strtolower($className) === 'security') { - $inClass = true; - } else { - // We don't have nested classes. - break; - } - } else if ($inClass === true && $tokens[$i]['code'] === T_FUNCTION) { - $funcName = $phpcsFile->findNext(T_STRING, $i); - $funcName = $tokens[$funcName]['content']; - if (strtolower($funcName) === 'getrequestdata') { - // This is valid. - return; - } else { - // We don't have nested functions. - break; - } - }//end if - }//end foreach - - // If we get to here, the super global was used incorrectly. - // First find out how it is being used. - $globalName = strtolower(substr($varName, 2)); - $usedVar = ''; - - $openBracket = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); - if ($tokens[$openBracket]['code'] === T_OPEN_SQUARE_BRACKET) { - $closeBracket = $tokens[$openBracket]['bracket_closer']; - $usedVar = $phpcsFile->getTokensAsString(($openBracket + 1), ($closeBracket - $openBracket - 1)); - } - - $type = 'SuperglobalAccessed'; - $error = 'The %s super global must not be accessed directly; use Security::getRequestData('; - $data = array($varName); - if ($usedVar !== '') { - $type .= 'WithVar'; - $error .= '%s, \'%s\''; - $data[] = $usedVar; - $data[] = $globalName; - } - - $error .= ') instead'; - $phpcsFile->addError($error, $stackPtr, $type, $data); - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Sniffs/PHP/ReturnFunctionValueSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Sniffs/PHP/ReturnFunctionValueSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Sniffs/PHP/ReturnFunctionValueSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Sniffs/PHP/ReturnFunctionValueSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,76 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Warns when function values are returned directly. - * - * @category PHP - * @package PHP_CodeSniffer_MySource - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class MySource_Sniffs_PHP_ReturnFunctionValueSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array(T_RETURN); - - }//end register() - - - /** - * Processes this sniff, 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(); - - $functionName = $phpcsFile->findNext(T_STRING, ($stackPtr + 1), null, false, null, true); - - while ($functionName !== false) { - // Check if this is really a function. - $bracket = $phpcsFile->findNext(T_WHITESPACE, ($functionName + 1), null, true); - if ($tokens[$bracket]['code'] !== T_OPEN_PARENTHESIS) { - // Not a function call. - $functionName = $phpcsFile->findNext(T_STRING, ($functionName + 1), null, false, null, true); - continue; - } - - $error = 'The result of a function call should be assigned to a variable before being returned'; - $phpcsFile->addWarning($error, $stackPtr, 'NotAssigned'); - break; - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Sniffs/Strings/JoinStringsSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Sniffs/Strings/JoinStringsSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Sniffs/Strings/JoinStringsSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Sniffs/Strings/JoinStringsSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,88 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Ensures that strings are not joined using array.join(). - * - * @category PHP - * @package PHP_CodeSniffer_MySource - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class MySource_Sniffs_Strings_JoinStringsSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = array('JS'); - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array(T_STRING); - - }//end register() - - - /** - * 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(); - - if ($tokens[$stackPtr]['content'] !== 'join') { - return; - } - - $prev = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true); - if ($tokens[$prev]['code'] !== T_OBJECT_OPERATOR) { - return; - } - - $prev = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($prev - 1), null, true); - if ($tokens[$prev]['code'] === T_CLOSE_SQUARE_BRACKET) { - $opener = $tokens[$prev]['bracket_opener']; - if ($tokens[($opener - 1)]['code'] !== T_STRING) { - // This means the array is declared inline, like x = [a,b,c].join() - // and not elsewhere, like x = y[a].join() - // The first is not allowed while the second is. - $error = 'Joining strings using inline arrays is not allowed; use the + operator instead'; - $phpcsFile->addError($error, $stackPtr, 'ArrayNotAllowed'); - } - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/CSS/BrowserSpecificStylesUnitTest.css php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/CSS/BrowserSpecificStylesUnitTest.css --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/CSS/BrowserSpecificStylesUnitTest.css 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/CSS/BrowserSpecificStylesUnitTest.css 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -.SettingsTabPaneWidgetType-tab-mid { - background: transparent url(tab_inact_mid.png) repeat-x; - line-height: -25px; - cursor: pointer; - -moz-user-select: none; -} - -.AssetLineageWidgetType-item { - float: left; - list-style: none; - height: 22px; - cursor: pointer; -} diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/CSS/BrowserSpecificStylesUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/CSS/BrowserSpecificStylesUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/CSS/BrowserSpecificStylesUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/CSS/BrowserSpecificStylesUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,66 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the BrowserSpecificStyles sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class MySource_Tests_CSS_BrowserSpecificStylesUnitTest 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 array( - 5 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Channels/DisallowSelfActionsUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Channels/DisallowSelfActionsUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Channels/DisallowSelfActionsUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Channels/DisallowSelfActionsUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Channels/DisallowSelfActionsUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Channels/DisallowSelfActionsUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Channels/DisallowSelfActionsUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Channels/DisallowSelfActionsUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,69 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the DisallowSelfActionsUnitTest sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer_MySource - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class MySource_Tests_Channels_DisallowSelfActionsUnitTest 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 array( - 12 => 1, - 26 => 1, - 27 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Channels/IncludeSystemUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Channels/IncludeSystemUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Channels/IncludeSystemUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Channels/IncludeSystemUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,107 +0,0 @@ -fetch(PDO::FETCH_NUM) -BaseSystem::getDataDir(); -Util::getArrayIndex(array(), ''); - - -Channels::includeSystem('Widget'); -Widget::includeWidget('AbstractContainer'); -class MyWidget extends AbstractContainerWidgetType {} -class MyOtherWidget extends BookWidgetType {} - -$zip = new ZipArchive(); -$res = $zip->open($path, ZipArchive::CREATE); - -class AssetListingUnitTest extends AbstractMySourceUnitTest -{ - function setUp() { - parent::setUp(); - Channels::includeSystem('MySystem2'); - include_once 'Libs/FileSystem.inc'; - } - - function two() { - $siteid = MySystem2::getCurrentSiteId(); - $parserFiles = FileSystem::listDirectory(); - } - - function three() { - $siteid = MySystem3::getCurrentSiteId(); - $parserFiles = FileSystem::listDirectory(); - } -} - -if (Channels::systemExists('Log') === TRUE) { - Channels::includeSystem('Log'); -} else { - return; -} - -Log::addProjectLog('metadata.field.update', $msg); - -function two() { - Widget::includeWidget('CacheAdminScreen'); - $barChart = CacheAdminScreenWidgetType::constructBarchart($data); -} - -$adjustDialog->setOrientation(AbstractWidgetWidgetType::CENTER); -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Channels/IncludeSystemUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Channels/IncludeSystemUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Channels/IncludeSystemUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Channels/IncludeSystemUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,77 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the IncludeSystem sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer_MySource - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class MySource_Tests_Channels_IncludeSystemUnitTest 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 array( - 9 => 1, - 14 => 1, - 24 => 1, - 27 => 1, - 28 => 1, - 31 => 1, - 36 => 1, - 41 => 1, - 60 => 1, - 69 => 1, - 88 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Channels/UnusedSystemUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Channels/UnusedSystemUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Channels/UnusedSystemUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Channels/UnusedSystemUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,67 +0,0 @@ - \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Channels/UnusedSystemUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Channels/UnusedSystemUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Channels/UnusedSystemUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Channels/UnusedSystemUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,72 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the UnusedSystem sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer_MySource - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class MySource_Tests_Channels_UnusedSystemUnitTest 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 array( - 2 => 1, - 5 => 1, - 8 => 1, - 24 => 1, - 34 => 1, - 54 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Commenting/FunctionCommentUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Commenting/FunctionCommentUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Commenting/FunctionCommentUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Commenting/FunctionCommentUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,101 +0,0 @@ - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Commenting/FunctionCommentUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Commenting/FunctionCommentUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Commenting/FunctionCommentUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Commenting/FunctionCommentUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,74 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for FunctionCommentSniff. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class MySource_Tests_Commenting_FunctionCommentUnitTest 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 array( - 28 => 1, - 36 => 1, - 37 => 2, - 49 => 1, - 58 => 1, - 65 => 1, - 77 => 1, - 79 => 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 array( - 67 => 1, - 68 => 1, - ); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Debug/DebugCodeUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Debug/DebugCodeUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Debug/DebugCodeUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Debug/DebugCodeUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,4 +0,0 @@ - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Debug/DebugCodeUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Debug/DebugCodeUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Debug/DebugCodeUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Debug/DebugCodeUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,68 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the DebugCode sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer_MySource - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class MySource_Tests_Debug_DebugCodeUnitTest 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 array( - 2 => 1, - 3 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Debug/FirebugConsoleUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Debug/FirebugConsoleUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Debug/FirebugConsoleUnitTest.js 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Debug/FirebugConsoleUnitTest.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -console.info(); -console.warn(); -console.test(); -con.sole(); -var console = { - console: 'string'; -}; -function console() {} \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Debug/FirebugConsoleUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Debug/FirebugConsoleUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Debug/FirebugConsoleUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Debug/FirebugConsoleUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,78 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the FirebugConsole sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer_MySource - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class MySource_Tests_Debug_FirebugConsoleUnitTest 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='FirebugConsoleUnitTest.js') - { - if ($testFile !== 'FirebugConsoleUnitTest.js') { - return array(); - } - - return array( - 1 => 1, - 2 => 1, - 3 => 1, - 5 => 1, - 6 => 1, - 8 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Objects/AssignThisUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Objects/AssignThisUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Objects/AssignThisUnitTest.js 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Objects/AssignThisUnitTest.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -var self = this; -buttonWidget.addClickEvent(function() { - self.addDynamicSouce(); -}); - -var x = self; -var y = this; - -var test = ''; -if (true) { - test = this -} - -var itemid = this.items[i].getAttribute('itemid'); - -for (var x = this; y < 10; y++) { - var x = this + 1; -} - -var _self = this; \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Objects/AssignThisUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Objects/AssignThisUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Objects/AssignThisUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Objects/AssignThisUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,75 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the AssignThis sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer_MySource - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class MySource_Tests_Objects_AssignThisUnitTest 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='AssignThisUnitTest.js') - { - if ($testFile !== 'AssignThisUnitTest.js') { - return array(); - } - - return array( - 7 => 1, - 11 => 1, - 16 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Objects/CreateWidgetTypeCallbackUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Objects/CreateWidgetTypeCallbackUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Objects/CreateWidgetTypeCallbackUnitTest.js 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Objects/CreateWidgetTypeCallbackUnitTest.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,186 +0,0 @@ -SampleWidgetType.prototype = { - - create: function(callback) - { - if (x === 1) { - return; - } - - if (y === 1) { - callback.call(this); - // A comment here to explain the return is okay. - return; - } - - if (a === 1) { - // Cant return value even after calling callback. - callback.call(this); - return something; - } - - if (a === 1) { - // Need to pass self or this to callback function. - callback.call(a); - } - - callback.call(self); - - var self = this; - this.createChildren(null, function() { - callback.call(self, div); - }); - - // Never good to return a vaue. - return something; - - callback.call(self); - } - -}; - -AnotherSampleWidgetType.prototype = { - - create: function(input) - { - return; - } - - getSomething: function(input) - { - return 1; - } - -}; - - -NoCreateWidgetType.prototype = { - - getSomething: function(input) - { - return; - } - -}; - - -SomeRandom.prototype = { - - create: function(input) - { - return; - } - -}; - -SampleWidgetType.prototype = { - - create: function(callback) - { - if (a === 1) { - // This is ok because it is the last statement, - // even though it is conditional. - callback.call(self); - } - - } - -}; - -SampleWidgetType.prototype = { - - create: function(callback) - { - var something = callback; - - } - -}; - -SampleWidgetType.prototype = { - - create: function(callback) - { - // Also valid because we are passing the callback to - // someone else to call. - if (y === 1) { - this.something(callback); - return; - } - - this.init(callback); - - } - -}; - -SampleWidgetType.prototype = { - - create: function(callback) - { - // Also valid because we are passing the callback to - // someone else to call. - if (y === 1) { - this.something(callback); - } - - this.init(callback); - - } - -}; - -SampleWidgetType.prototype = { - - create: function(callback) - { - if (a === 1) { - // This is ok because it is the last statement, - // even though it is conditional. - this.something(callback); - } - - } - -}; - - -SampleWidgetType.prototype = { - - create: function(callback) - { - if (dfx.isFn(callback) === true) { - callback.call(this, cont); - return; - } - } - -}; - - -SampleWidgetType.prototype = { - - create: function(callback) - { - dfx.foreach(items, function(item) { - return true; - }); - - if (dfx.isFn(callback) === true) { - callback.call(this); - } - } - -}; - -SampleWidgetType.prototype = { - - create: function(callback) - { - var self = this; - this.createChildren(null, function() { - callback.call(self, div); - return; - }); - } - -}; \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Objects/CreateWidgetTypeCallbackUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Objects/CreateWidgetTypeCallbackUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Objects/CreateWidgetTypeCallbackUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Objects/CreateWidgetTypeCallbackUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,80 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the CreateWidgetTypeCallback sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer_MySource - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class MySource_Tests_Objects_CreateWidgetTypeCallbackUnitTest 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='CreateWidgetTypeCallbackUnitTest.js') - { - if ($testFile !== 'CreateWidgetTypeCallbackUnitTest.js') { - return array(); - } - - return array( - 18 => 1, - 23 => 2, - 26 => 1, - 30 => 1, - 34 => 1, - 43 => 2, - 91 => 1, - 123 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Objects/DisallowNewWidgetUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Objects/DisallowNewWidgetUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Objects/DisallowNewWidgetUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Objects/DisallowNewWidgetUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,6 +0,0 @@ - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Objects/DisallowNewWidgetUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Objects/DisallowNewWidgetUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Objects/DisallowNewWidgetUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Objects/DisallowNewWidgetUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,67 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the DisallowNewWidget sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer_MySource - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class MySource_Tests_Objects_DisallowNewWidgetUnitTest 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 array( - 4 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/PHP/EvalObjectFactoryUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/PHP/EvalObjectFactoryUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/PHP/EvalObjectFactoryUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/PHP/EvalObjectFactoryUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ - \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/PHP/EvalObjectFactoryUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/PHP/EvalObjectFactoryUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/PHP/EvalObjectFactoryUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/PHP/EvalObjectFactoryUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,69 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the EvalObjectFactory sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer_MySource - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class MySource_Tests_PHP_EvalObjectFactoryUnitTest 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 array(); - - }//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 array( - 4 => 1, - 12 => 1, - 21 => 1, - ); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/PHP/GetRequestDataUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/PHP/GetRequestDataUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/PHP/GetRequestDataUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/PHP/GetRequestDataUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ - \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/PHP/GetRequestDataUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/PHP/GetRequestDataUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/PHP/GetRequestDataUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/PHP/GetRequestDataUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,73 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the GetRequestData sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer_MySource - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class MySource_Tests_PHP_GetRequestDataUnitTest 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 array( - 2 => 1, - 5 => 1, - 8 => 1, - 21 => 1, - 26 => 1, - 27 => 1, - 28 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/PHP/ReturnFunctionValueUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/PHP/ReturnFunctionValueUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/PHP/ReturnFunctionValueUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/PHP/ReturnFunctionValueUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -myFunction(); -return $obj->variable; -return MyClass::VARIABLE; -return $variable; -return ($var + 1); -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/PHP/ReturnFunctionValueUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/PHP/ReturnFunctionValueUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/PHP/ReturnFunctionValueUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/PHP/ReturnFunctionValueUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,69 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the ReturnFunctionValue sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer_MySource - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class MySource_Tests_PHP_ReturnFunctionValueUnitTest 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 array(); - - }//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 array( - 2 => 1, - 3 => 1, - 4 => 1, - ); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Strings/JoinStringsUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Strings/JoinStringsUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Strings/JoinStringsUnitTest.js 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Strings/JoinStringsUnitTest.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -one = (1 + 2); -two = (one + 2); -two = (one + one); -three = ('1' + 2); - -four = ['1', two].join(); -four = ['1', two].join(''); -four = ['1', [one, two].join(',')].join(' '); -four = ['1', [one, two].join()].join(' '); -four = ['1', [one, two].join()].join(); - -five = 'string' + ['1', [one, two].join()].join() + 'string'; - -six = myArray.join(' '); -six = [arrayOne, arrayTwo].join(); - -// This is fine because the array is not created inline. -var x = 'x' + test[x].join('p') + 't'; \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Strings/JoinStringsUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Strings/JoinStringsUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Strings/JoinStringsUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/Tests/Strings/JoinStringsUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,79 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the JoinStrings sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer_MySource - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class MySource_Tests_Strings_JoinStringsUnitTest 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='JoinStringsUnitTest.js') - { - if ($testFile !== 'JoinStringsUnitTest.js') { - return array(); - } - - return array( - 6 => 1, - 7 => 1, - 8 => 2, - 9 => 2, - 10 => 2, - 12 => 2, - 15 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/ruleset.xml php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/ruleset.xml --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/ruleset.xml 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/MySource/ruleset.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ - - - The MySource coding standard builds on the Squiz coding standard. Currently used for MySource Mini development. - - */Tests/* - */Oven/* - */data/* - DALConf.inc - - - - - - - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Docs/Files/IncludingFileStandard.xml php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Docs/Files/IncludingFileStandard.xml --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Docs/Files/IncludingFileStandard.xml 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Docs/Files/IncludingFileStandard.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ - - - require_once. Anywhere you are conditionally including a class file (for example, factory methods), use include_once. Either of these will ensure that class files are included only once. They share the same file list, so you don't need to worry about mixing them - a file included with require_once will not be included again by include_once. - ]]> - - - include_once and require_once are statements, not functions. Parentheses should not surround the subject filename. - ]]> - - - - - - - ('PHP/CodeSniffer.php'); - ]]> - - - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Docs/Files/LineLengthStandard.xml php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Docs/Files/LineLengthStandard.xml --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Docs/Files/LineLengthStandard.xml 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Docs/Files/LineLengthStandard.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,7 +0,0 @@ - - - - - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Docs/Functions/FunctionCallSignatureStandard.xml php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Docs/Functions/FunctionCallSignatureStandard.xml --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Docs/Functions/FunctionCallSignatureStandard.xml 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Docs/Functions/FunctionCallSignatureStandard.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ - - - - - - - - - - ( $bar, $baz, $quux ) ; - ]]> - - - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Docs/Functions/ValidDefaultValueStandard.xml php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Docs/Functions/ValidDefaultValueStandard.xml --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Docs/Functions/ValidDefaultValueStandard.xml 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Docs/Functions/ValidDefaultValueStandard.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ - - - - - - - $persistent = false) -{ - ... -} - ]]> - - - $persistent = false, $dsn) -{ - ... -} - ]]> - - - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Docs/NamingConventions/ValidClassNameStandard.xml php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Docs/NamingConventions/ValidClassNameStandard.xml --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Docs/NamingConventions/ValidClassNameStandard.xml 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Docs/NamingConventions/ValidClassNameStandard.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ - - - - - - - - - - - - - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Docs/NamingConventions/ValidFunctionNameStandard.xml php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Docs/NamingConventions/ValidFunctionNameStandard.xml --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Docs/NamingConventions/ValidFunctionNameStandard.xml 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Docs/NamingConventions/ValidFunctionNameStandard.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ - - - - - - - - - - - - - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/Classes/ClassDeclarationSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/Classes/ClassDeclarationSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/Classes/ClassDeclarationSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/Classes/ClassDeclarationSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,125 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Class Declaration Test. - * - * Checks the declaration of the class is correct. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PEAR_Sniffs_Classes_ClassDeclarationSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * The number of spaces code should be indented. - * - * @var int - */ - public $indent = 4; - - - /** - * 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 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(); - $errorData = array($tokens[$stackPtr]['content']); - - if (isset($tokens[$stackPtr]['scope_opener']) === false) { - $error = 'Possible parse error: %s missing opening or closing brace'; - $phpcsFile->addWarning($error, $stackPtr, 'MissingBrace', $errorData); - return; - } - - $curlyBrace = $tokens[$stackPtr]['scope_opener']; - $lastContent = $phpcsFile->findPrevious(T_WHITESPACE, ($curlyBrace - 1), $stackPtr, true); - $classLine = $tokens[$lastContent]['line']; - $braceLine = $tokens[$curlyBrace]['line']; - if ($braceLine === $classLine) { - $error = 'Opening brace of a %s must be on the line after the definition'; - $phpcsFile->addError($error, $curlyBrace, 'OpenBraceNewLine', $errorData); - return; - } else if ($braceLine > ($classLine + 1)) { - $error = 'Opening brace of a %s must be on the line following the %s declaration; found %s line(s)'; - $data = array( - $tokens[$stackPtr]['content'], - $tokens[$stackPtr]['content'], - ($braceLine - $classLine - 1), - ); - $phpcsFile->addError($error, $curlyBrace, 'OpenBraceWrongLine', $data); - return; - } - - if ($tokens[($curlyBrace + 1)]['content'] !== $phpcsFile->eolChar) { - $error = 'Opening %s brace must be on a line by itself'; - $phpcsFile->addError($error, $curlyBrace, 'OpenBraceNotAlone', $errorData); - } - - if ($tokens[($curlyBrace - 1)]['code'] === T_WHITESPACE) { - $prevContent = $tokens[($curlyBrace - 1)]['content']; - if ($prevContent === $phpcsFile->eolChar) { - $spaces = 0; - } else { - $blankSpace = substr($prevContent, strpos($prevContent, $phpcsFile->eolChar)); - $spaces = strlen($blankSpace); - } - - $expected = ($tokens[$stackPtr]['level'] * $this->indent); - if ($spaces !== $expected) { - $error = 'Expected %s spaces before opening brace; %s found'; - $data = array( - $expected, - $spaces, - ); - $phpcsFile->addError($error, $curlyBrace, 'SpaceBeforeBrace', $data); - } - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/Commenting/ClassCommentSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/Commenting/ClassCommentSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/Commenting/ClassCommentSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/Commenting/ClassCommentSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,233 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -if (class_exists('PHP_CodeSniffer_CommentParser_ClassCommentParser', true) === false) { - $error = 'Class PHP_CodeSniffer_CommentParser_ClassCommentParser not found'; - throw new PHP_CodeSniffer_Exception($error); -} - -if (class_exists('PEAR_Sniffs_Commenting_FileCommentSniff', true) === false) { - $error = 'Class PEAR_Sniffs_Commenting_FileCommentSniff not found'; - throw new PHP_CodeSniffer_Exception($error); -} - -/** - * Parses and verifies the doc comments for classes. - * - * Verifies that : - *
    - *
  • A doc comment exists.
  • - *
  • There is a blank newline after the short description.
  • - *
  • There is a blank newline between the long and short description.
  • - *
  • There is a blank newline between the long description and tags.
  • - *
  • Check the order of the tags.
  • - *
  • Check the indentation of each tag.
  • - *
  • Check required and optional tags and the format of their content.
  • - *
- * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PEAR_Sniffs_Commenting_ClassCommentSniff extends PEAR_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 = array( - T_ABSTRACT, - T_WHITESPACE, - T_FINAL, - ); - - // Extract the class comment docblock. - $commentEnd = $phpcsFile->findPrevious($find, ($stackPtr - 1), null, true); - - if ($commentEnd !== false && $tokens[$commentEnd]['code'] === T_COMMENT) { - $error = 'You must use "/**" style comments for a %s comment'; - $phpcsFile->addError($error, $stackPtr, 'WrongStyle', $errorData); - return; - } else if ($commentEnd === false - || $tokens[$commentEnd]['code'] !== T_DOC_COMMENT - ) { - $phpcsFile->addError('Missing %s doc comment', $stackPtr, 'Missing', $errorData); - return; - } - - $commentStart = ($phpcsFile->findPrevious(T_DOC_COMMENT, ($commentEnd - 1), null, true) + 1); - $commentNext = $phpcsFile->findPrevious(T_WHITESPACE, ($commentEnd + 1), $stackPtr, false, $phpcsFile->eolChar); - - // Distinguish file and class comment. - $prevClassToken = $phpcsFile->findPrevious(T_CLASS, ($stackPtr - 1)); - if ($prevClassToken === false) { - // This is the first class token in this file, need extra checks. - $prevNonComment = $phpcsFile->findPrevious(T_DOC_COMMENT, ($commentStart - 1), null, true); - if ($prevNonComment !== false) { - $prevComment = $phpcsFile->findPrevious(T_DOC_COMMENT, ($prevNonComment - 1)); - if ($prevComment === false) { - // There is only 1 doc comment between open tag and class token. - $newlineToken = $phpcsFile->findNext(T_WHITESPACE, ($commentEnd + 1), $stackPtr, false, $phpcsFile->eolChar); - if ($newlineToken !== false) { - $newlineToken = $phpcsFile->findNext( - T_WHITESPACE, - ($newlineToken + 1), - $stackPtr, - false, - $phpcsFile->eolChar - ); - - if ($newlineToken !== false) { - // Blank line between the class and the doc block. - // The doc block is most likely a file comment. - $error = 'Missing %s doc comment'; - $phpcsFile->addError($error, ($stackPtr + 1), 'Missing', $errorData); - return; - } - }//end if - }//end if - }//end if - }//end if - - $comment = $phpcsFile->getTokensAsString( - $commentStart, - ($commentEnd - $commentStart + 1) - ); - - // Parse the class comment.docblock. - try { - $this->commentParser = new PHP_CodeSniffer_CommentParser_ClassCommentParser($comment, $phpcsFile); - $this->commentParser->parse(); - } catch (PHP_CodeSniffer_CommentParser_ParserException $e) { - $line = ($e->getLineWithinComment() + $commentStart); - $phpcsFile->addError($e->getMessage(), $line, 'FailedParse'); - return; - } - - $comment = $this->commentParser->getComment(); - if (is_null($comment) === true) { - $error = 'Doc comment is empty for %s'; - $phpcsFile->addError($error, $commentStart, 'Empty', $errorData); - return; - } - - // No extra newline before short description. - $short = $comment->getShortComment(); - $newlineCount = 0; - $newlineSpan = strspn($short, $phpcsFile->eolChar); - if ($short !== '' && $newlineSpan > 0) { - $error = 'Extra newline(s) found before %s comment short description'; - $phpcsFile->addError($error, ($commentStart + 1), 'SpacingBeforeShort', $errorData); - } - - $newlineCount = (substr_count($short, $phpcsFile->eolChar) + 1); - - // Exactly one blank line between short and long description. - $long = $comment->getLongComment(); - if (empty($long) === false) { - $between = $comment->getWhiteSpaceBetween(); - $newlineBetween = substr_count($between, $phpcsFile->eolChar); - if ($newlineBetween !== 2) { - $error = 'There must be exactly one blank line between descriptions in %s comments'; - $phpcsFile->addError($error, ($commentStart + $newlineCount + 1), 'SpacingAfterShort', $errorData); - } - - $newlineCount += $newlineBetween; - } - - // Exactly one blank line before tags. - $tags = $this->commentParser->getTagOrders(); - if (count($tags) > 1) { - $newlineSpan = $comment->getNewlineAfter(); - if ($newlineSpan !== 2) { - $error = 'There must be exactly one blank line before the tags in %s comments'; - if ($long !== '') { - $newlineCount += (substr_count($long, $phpcsFile->eolChar) - $newlineSpan + 1); - } - - $phpcsFile->addError($error, ($commentStart + $newlineCount), 'SpacingBeforeTags', $errorData); - $short = rtrim($short, $phpcsFile->eolChar.' '); - } - } - - // Check each tag. - $this->processTags($commentStart, $commentEnd); - - }//end process() - - - /** - * Process the version tag. - * - * @param int $errorPos The line number where the error occurs. - * - * @return void - */ - protected function processVersion($errorPos) - { - $version = $this->commentParser->getVersion(); - if ($version !== null) { - $content = $version->getContent(); - $matches = array(); - if (empty($content) === true) { - $error = 'Content missing for @version tag in doc comment'; - $this->currentFile->addError($error, $errorPos, 'EmptyVersion'); - } else if ((strstr($content, 'Release:') === false)) { - $error = 'Invalid version "%s" in doc comment; consider "Release: " instead'; - $data = array($content); - $this->currentFile->addWarning($error, $errorPos, 'InvalidVersion', $data); - } - } - - }//end processVersion() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/Commenting/FileCommentSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/Commenting/FileCommentSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/Commenting/FileCommentSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/Commenting/FileCommentSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,791 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -if (class_exists('PHP_CodeSniffer_CommentParser_ClassCommentParser', true) === false) { - throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_CommentParser_ClassCommentParser not found'); -} - -/** - * Parses and verifies the doc comments for files. - * - * Verifies that : - *
    - *
  • A doc comment exists.
  • - *
  • There is a blank newline after the short description.
  • - *
  • There is a blank newline between the long and short description.
  • - *
  • There is a blank newline between the long description and tags.
  • - *
  • A PHP version is specified.
  • - *
  • Check the order of the tags.
  • - *
  • Check the indentation of each tag.
  • - *
  • Check required and optional tags and the format of their content.
  • - *
- * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -class PEAR_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * The header comment parser for the current file. - * - * @var PHP_CodeSniffer_Comment_Parser_ClassCommentParser - */ - protected $commentParser = null; - - /** - * The current PHP_CodeSniffer_File object we are processing. - * - * @var PHP_CodeSniffer_File - */ - protected $currentFile = null; - - /** - * Tags in correct order and related info. - * - * @var array - */ - protected $tags = array( - 'category' => array( - 'required' => true, - 'allow_multiple' => false, - 'order_text' => 'precedes @package', - ), - 'package' => array( - 'required' => true, - 'allow_multiple' => false, - 'order_text' => 'follows @category', - ), - 'subpackage' => array( - 'required' => false, - 'allow_multiple' => false, - 'order_text' => 'follows @package', - ), - 'author' => array( - 'required' => true, - 'allow_multiple' => true, - 'order_text' => 'follows @subpackage (if used) or @package', - ), - 'copyright' => array( - 'required' => false, - 'allow_multiple' => true, - 'order_text' => 'follows @author', - ), - 'license' => array( - 'required' => true, - 'allow_multiple' => false, - 'order_text' => 'follows @copyright (if used) or @author', - ), - 'version' => array( - 'required' => false, - 'allow_multiple' => false, - 'order_text' => 'follows @license', - ), - 'link' => array( - 'required' => true, - 'allow_multiple' => true, - 'order_text' => 'follows @version', - ), - 'see' => array( - 'required' => false, - 'allow_multiple' => true, - 'order_text' => 'follows @link', - ), - 'since' => array( - 'required' => false, - 'allow_multiple' => false, - 'order_text' => 'follows @see (if used) or @link', - ), - 'deprecated' => array( - 'required' => false, - 'allow_multiple' => false, - 'order_text' => 'follows @since (if used) or @see (if used) or @link', - ), - ); - - - /** - * 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 void - */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) - { - $this->currentFile = $phpcsFile; - - // We are only interested if this is the first open tag. - if ($stackPtr !== 0) { - if ($phpcsFile->findPrevious(T_OPEN_TAG, ($stackPtr - 1)) !== false) { - return; - } - } - - $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; - } else if ($tokens[$commentStart]['code'] === T_COMMENT) { - $error = 'You must use "/**" style comments for a file comment'; - $phpcsFile->addError($error, $errorToken, 'WrongStyle'); - return; - } else if ($commentStart === false - || $tokens[$commentStart]['code'] !== T_DOC_COMMENT - ) { - $phpcsFile->addError('Missing file doc comment', $errorToken, 'Missing'); - return; - } else { - - // Extract the header comment docblock. - $commentEnd = $phpcsFile->findNext( - T_DOC_COMMENT, - ($commentStart + 1), - null, - true - ); - - $commentEnd--; - - // Check if there is only 1 doc comment between the - // open tag and class token. - $nextToken = array( - T_ABSTRACT, - T_CLASS, - T_FUNCTION, - T_DOC_COMMENT, - ); - - $commentNext = $phpcsFile->findNext($nextToken, ($commentEnd + 1)); - if ($commentNext !== false - && $tokens[$commentNext]['code'] !== T_DOC_COMMENT - ) { - // Found a class token right after comment doc block. - $newlineToken = $phpcsFile->findNext( - T_WHITESPACE, - ($commentEnd + 1), - $commentNext, - false, - $phpcsFile->eolChar - ); - - if ($newlineToken !== false) { - $newlineToken = $phpcsFile->findNext( - T_WHITESPACE, - ($newlineToken + 1), - $commentNext, - false, - $phpcsFile->eolChar - ); - - if ($newlineToken === false) { - // No blank line between the class token and the doc block. - // The doc block is most likely a class comment. - $error = 'Missing file doc comment'; - $phpcsFile->addError($error, $errorToken, 'Missing'); - return; - } - } - }//end if - - $comment = $phpcsFile->getTokensAsString( - $commentStart, - ($commentEnd - $commentStart + 1) - ); - - // Parse the header comment docblock. - try { - $this->commentParser = new PHP_CodeSniffer_CommentParser_ClassCommentParser($comment, $phpcsFile); - $this->commentParser->parse(); - } catch (PHP_CodeSniffer_CommentParser_ParserException $e) { - $line = ($e->getLineWithinComment() + $commentStart); - $phpcsFile->addError($e->getMessage(), $line, 'FailedParse'); - return; - } - - $comment = $this->commentParser->getComment(); - if (is_null($comment) === true) { - $error = 'File doc comment is empty'; - $phpcsFile->addError($error, $commentStart, 'Empty'); - return; - } - - // No extra newline before short description. - $short = $comment->getShortComment(); - $newlineCount = 0; - $newlineSpan = strspn($short, $phpcsFile->eolChar); - if ($short !== '' && $newlineSpan > 0) { - $error = 'Extra newline(s) found before file comment short description'; - $phpcsFile->addError($error, ($commentStart + 1), 'SpacingBefore'); - } - - $newlineCount = (substr_count($short, $phpcsFile->eolChar) + 1); - - // Exactly one blank line between short and long description. - $long = $comment->getLongComment(); - if (empty($long) === false) { - $between = $comment->getWhiteSpaceBetween(); - $newlineBetween = substr_count($between, $phpcsFile->eolChar); - if ($newlineBetween !== 2) { - $error = 'There must be exactly one blank line between descriptions in file comment'; - $phpcsFile->addError($error, ($commentStart + $newlineCount + 1), 'DescriptionSpacing'); - } - - $newlineCount += $newlineBetween; - } - - // Exactly one blank line before tags. - $tags = $this->commentParser->getTagOrders(); - if (count($tags) > 1) { - $newlineSpan = $comment->getNewlineAfter(); - if ($newlineSpan !== 2) { - $error = 'There must be exactly one blank line before the tags in file comment'; - if ($long !== '') { - $newlineCount += (substr_count($long, $phpcsFile->eolChar) - $newlineSpan + 1); - } - - $phpcsFile->addError($error, ($commentStart + $newlineCount), 'SpacingBeforeTags'); - $short = rtrim($short, $phpcsFile->eolChar.' '); - } - } - - // Check the PHP Version. - $this->processPHPVersion($commentStart, $commentEnd, $long); - - // Check each tag. - $this->processTags($commentStart, $commentEnd); - }//end if - - }//end process() - - - /** - * Check that the PHP version is specified. - * - * @param int $commentStart Position in the stack where the comment started. - * @param int $commentEnd Position in the stack where the comment ended. - * @param string $commentText The text of the function comment. - * - * @return void - */ - protected function processPHPVersion($commentStart, $commentEnd, $commentText) - { - if (strstr(strtolower($commentText), 'php version') === false) { - $error = 'PHP version not specified'; - $this->currentFile->addWarning($error, $commentEnd, 'MissingVersion'); - } - - }//end processPHPVersion() - - - /** - * Processes each required or optional tag. - * - * @param int $commentStart Position in the stack where the comment started. - * @param int $commentEnd Position in the stack where the comment ended. - * - * @return void - */ - protected function processTags($commentStart, $commentEnd) - { - $docBlock = (get_class($this) === 'PEAR_Sniffs_Commenting_FileCommentSniff') ? 'file' : 'class'; - $foundTags = $this->commentParser->getTagOrders(); - $orderIndex = 0; - $indentation = array(); - $longestTag = 0; - $errorPos = 0; - - foreach ($this->tags as $tag => $info) { - - // Required tag missing. - if ($info['required'] === true && in_array($tag, $foundTags) === false) { - $error = 'Missing @%s tag in %s comment'; - $data = array( - $tag, - $docBlock, - ); - $this->currentFile->addError($error, $commentEnd, 'MissingTag', $data); - continue; - } - - // Get the line number for current tag. - $tagName = ucfirst($tag); - if ($info['allow_multiple'] === true) { - $tagName .= 's'; - } - - $getMethod = 'get'.$tagName; - $tagElement = $this->commentParser->$getMethod(); - if (is_null($tagElement) === true || empty($tagElement) === true) { - continue; - } - - $errorPos = $commentStart; - if (is_array($tagElement) === false) { - $errorPos = ($commentStart + $tagElement->getLine()); - } - - // Get the tag order. - $foundIndexes = array_keys($foundTags, $tag); - - if (count($foundIndexes) > 1) { - // Multiple occurance not allowed. - if ($info['allow_multiple'] === false) { - $error = 'Only 1 @%s tag is allowed in a %s comment'; - $data = array( - $tag, - $docBlock, - ); - $this->currentFile->addError($error, $errorPos, 'DuplicateTag', $data); - } else { - // Make sure same tags are grouped together. - $i = 0; - $count = $foundIndexes[0]; - foreach ($foundIndexes as $index) { - if ($index !== $count) { - $errorPosIndex - = ($errorPos + $tagElement[$i]->getLine()); - $error = '@%s tags must be grouped together'; - $data = array($tag); - $this->currentFile->addError($error, $errorPosIndex, 'TagsNotGrouped', $data); - } - - $i++; - $count++; - } - } - }//end if - - // Check tag order. - if ($foundIndexes[0] > $orderIndex) { - $orderIndex = $foundIndexes[0]; - } else { - if (is_array($tagElement) === true && empty($tagElement) === false) { - $errorPos += $tagElement[0]->getLine(); - } - - $error = 'The @%s tag is in the wrong order; the tag %s'; - $data = array( - $tag, - $info['order_text'], - ); - $this->currentFile->addError($error, $errorPos, 'WrongTagOrder', $data); - } - - // Store the indentation for checking. - $len = strlen($tag); - if ($len > $longestTag) { - $longestTag = $len; - } - - if (is_array($tagElement) === true) { - foreach ($tagElement as $key => $element) { - $indentation[] = array( - 'tag' => $tag, - 'space' => $this->getIndentation($tag, $element), - 'line' => $element->getLine(), - ); - } - } else { - $indentation[] = array( - 'tag' => $tag, - 'space' => $this->getIndentation($tag, $tagElement), - ); - } - - $method = 'process'.$tagName; - if (method_exists($this, $method) === true) { - // Process each tag if a method is defined. - call_user_func(array($this, $method), $errorPos); - } else { - if (is_array($tagElement) === true) { - foreach ($tagElement as $key => $element) { - $element->process( - $this->currentFile, - $commentStart, - $docBlock - ); - } - } else { - $tagElement->process( - $this->currentFile, - $commentStart, - $docBlock - ); - } - } - }//end foreach - - foreach ($indentation as $indentInfo) { - if ($indentInfo['space'] !== 0 - && $indentInfo['space'] !== ($longestTag + 1) - ) { - $expected = (($longestTag - strlen($indentInfo['tag'])) + 1); - $space = ($indentInfo['space'] - strlen($indentInfo['tag'])); - $error = '@%s tag comment indented incorrectly; expected %s spaces but found %s'; - $data = array( - $indentInfo['tag'], - $expected, - $space, - ); - - $getTagMethod = 'get'.ucfirst($indentInfo['tag']); - - if ($this->tags[$indentInfo['tag']]['allow_multiple'] === true) { - $line = $indentInfo['line']; - } else { - $tagElem = $this->commentParser->$getTagMethod(); - $line = $tagElem->getLine(); - } - - $this->currentFile->addError($error, ($commentStart + $line), 'TagIndent', $data); - } - } - - }//end processTags() - - - /** - * Get the indentation information of each tag. - * - * @param string $tagName The name of the - * doc comment - * element. - * @param PHP_CodeSniffer_CommentParser_DocElement $tagElement The doc comment - * element. - * - * @return void - */ - protected function getIndentation($tagName, $tagElement) - { - if ($tagElement instanceof PHP_CodeSniffer_CommentParser_SingleElement) { - if ($tagElement->getContent() !== '') { - return (strlen($tagName) + substr_count($tagElement->getWhitespaceBeforeContent(), ' ')); - } - } else if ($tagElement instanceof PHP_CodeSniffer_CommentParser_PairElement) { - if ($tagElement->getValue() !== '') { - return (strlen($tagName) + substr_count($tagElement->getWhitespaceBeforeValue(), ' ')); - } - } - - return 0; - - }//end getIndentation() - - - /** - * Process the category tag. - * - * @param int $errorPos The line number where the error occurs. - * - * @return void - */ - protected function processCategory($errorPos) - { - $category = $this->commentParser->getCategory(); - if ($category !== null) { - $content = $category->getContent(); - if ($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) { - $newName .= ucfirst($bit).'_'; - } - - $error = 'Category name "%s" is not valid; consider "%s" instead'; - $validName = trim($newName, '_'); - $data = array( - $content, - $validName, - ); - $this->currentFile->addError($error, $errorPos, 'InvalidCategory', $data); - } - } else { - $error = '@category tag must contain a name'; - $this->currentFile->addError($error, $errorPos, 'EmptyCategory'); - } - } - - }//end processCategory() - - - /** - * Process the package tag. - * - * @param int $errorPos The line number where the error occurs. - * - * @return void - */ - protected function processPackage($errorPos) - { - $package = $this->commentParser->getPackage(); - if ($package !== null) { - $content = $package->getContent(); - if ($content !== '') { - if (PHP_CodeSniffer::isUnderscoreName($content) !== true) { - $newContent = str_replace(' ', '_', $content); - $nameBits = explode('_', $newContent); - $firstBit = array_shift($nameBits); - $newName = strtoupper($firstBit{0}).substr($firstBit, 1).'_'; - foreach ($nameBits as $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, - ); - $this->currentFile->addError($error, $errorPos, 'InvalidPackage', $data); - } - } else { - $error = '@package tag must contain a name'; - $this->currentFile->addError($error, $errorPos, 'EmptyPackage'); - } - } - - }//end processPackage() - - - /** - * Process the subpackage tag. - * - * @param int $errorPos The line number where the error occurs. - * - * @return void - */ - protected function processSubpackage($errorPos) - { - $package = $this->commentParser->getSubpackage(); - if ($package !== null) { - $content = $package->getContent(); - if ($content !== '') { - if (PHP_CodeSniffer::isUnderscoreName($content) !== true) { - $newContent = str_replace(' ', '_', $content); - $nameBits = explode('_', $newContent); - $firstBit = array_shift($nameBits); - $newName = strtoupper($firstBit{0}).substr($firstBit, 1).'_'; - foreach ($nameBits as $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, - ); - $this->currentFile->addError($error, $errorPos, 'InvalidSubpackage', $data); - } - } else { - $error = '@subpackage tag must contain a name'; - $this->currentFile->addError($error, $errorPos, 'EmptySubpackage'); - } - } - - }//end processSubpackage() - - - /** - * Process the author tag(s) that this header comment has. - * - * This function is different from other _process functions - * as $authors is an array of SingleElements, so we work out - * the errorPos for each element separately - * - * @param int $commentStart The position in the stack where - * the comment started. - * - * @return void - */ - protected function processAuthors($commentStart) - { - $authors = $this->commentParser->getAuthors(); - // Report missing return. - if (empty($authors) === false) { - foreach ($authors as $author) { - $errorPos = ($commentStart + $author->getLine()); - $content = $author->getContent(); - if ($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 "'; - $this->currentFile->addError($error, $errorPos, 'InvalidAuthors'); - } - } else { - $error = 'Content missing for @author tag in %s comment'; - $docBlock = (get_class($this) === 'PEAR_Sniffs_Commenting_FileCommentSniff') ? 'file' : 'class'; - $data = array($docBlock); - $this->currentFile->addError($error, $errorPos, 'EmptyAuthors', $data); - } - } - } - - }//end processAuthors() - - - /** - * Process the copyright tags. - * - * @param int $commentStart The position in the stack where - * the comment started. - * - * @return void - */ - protected function processCopyrights($commentStart) - { - $copyrights = $this->commentParser->getCopyrights(); - foreach ($copyrights as $copyright) { - $errorPos = ($commentStart + $copyright->getLine()); - $content = $copyright->getContent(); - if ($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'; - $this->currentFile->addError($error, $errorPos, '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"; - $this->currentFile->addWarning($error, $errorPos, 'InvalidCopyright'); - } - } - } else { - $error = '@copyright tag must contain a year and the name of the copyright holder'; - $this->currentFile->addError($error, $errorPos, 'EmptyCopyright'); - } - } else { - $error = '@copyright tag must contain a year and the name of the copyright holder'; - $this->currentFile->addError($error, $errorPos, 'EmptyCopyright'); - }//end if - }//end if - - }//end processCopyrights() - - - /** - * Process the license tag. - * - * @param int $errorPos The line number where the error occurs. - * - * @return void - */ - protected function processLicense($errorPos) - { - $license = $this->commentParser->getLicense(); - if ($license !== null) { - $value = $license->getValue(); - $comment = $license->getComment(); - if ($value === '' || $comment === '') { - $error = '@license tag must contain a URL and a license name'; - $this->currentFile->addError($error, $errorPos, 'EmptyLicense'); - } - } - - }//end processLicense() - - - /** - * Process the version tag. - * - * @param int $errorPos The line number where the error occurs. - * - * @return void - */ - protected function processVersion($errorPos) - { - $version = $this->commentParser->getVersion(); - if ($version !== null) { - $content = $version->getContent(); - $matches = array(); - if (empty($content) === true) { - $error = 'Content missing for @version tag in file comment'; - $this->currentFile->addError($error, $errorPos, 'EmptyVersion'); - } else if (strstr($content, 'CVS:') === false - && strstr($content, 'SVN:') === false - && strstr($content, 'GIT:') === false - ) { - $error = 'Invalid version "%s" in file comment; consider "CVS: " or "SVN: " or "GIT: " instead'; - $data = array($content); - $this->currentFile->addWarning($error, $errorPos, 'InvalidVersion', $data); - } - } - - }//end processVersion() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/Commenting/FunctionCommentSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/Commenting/FunctionCommentSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/Commenting/FunctionCommentSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/Commenting/FunctionCommentSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,490 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -if (class_exists('PHP_CodeSniffer_CommentParser_FunctionCommentParser', true) === false) { - throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_CommentParser_FunctionCommentParser not found'); -} - -/** - * Parses and verifies the doc comments for functions. - * - * Verifies that : - *
    - *
  • A comment exists
  • - *
  • There is a blank newline after the short description.
  • - *
  • There is a blank newline between the long and short description.
  • - *
  • There is a blank newline between the long description and tags.
  • - *
  • Parameter names represent those in the method.
  • - *
  • Parameter comments are in the correct order
  • - *
  • Parameter comments are complete
  • - *
  • A space is present before the first and after the last parameter
  • - *
  • A return type exists
  • - *
  • There must be one blank line between body and headline comments.
  • - *
  • Any throw tag must have an exception class.
  • - *
- * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PEAR_Sniffs_Commenting_FunctionCommentSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * The name of the method that we are currently processing. - * - * @var string - */ - private $_methodName = ''; - - /** - * The position in the stack where the fucntion token was found. - * - * @var int - */ - private $_functionToken = null; - - /** - * The position in the stack where the class token was found. - * - * @var int - */ - private $_classToken = null; - - /** - * The function comment parser for the current method. - * - * @var PHP_CodeSniffer_Comment_Parser_FunctionCommentParser - */ - protected $commentParser = null; - - /** - * The current PHP_CodeSniffer_File object we are processing. - * - * @var PHP_CodeSniffer_File - */ - protected $currentFile = null; - - - /** - * 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) - { - $find = array( - T_COMMENT, - T_DOC_COMMENT, - T_CLASS, - T_FUNCTION, - T_OPEN_TAG, - ); - - $commentEnd = $phpcsFile->findPrevious($find, ($stackPtr - 1)); - - if ($commentEnd === false) { - return; - } - - $this->currentFile = $phpcsFile; - $tokens = $phpcsFile->getTokens(); - - // If the token that we found was a class or a function, then this - // function has no doc comment. - $code = $tokens[$commentEnd]['code']; - - if ($code === T_COMMENT) { - $error = 'You must use "/**" style comments for a function comment'; - $phpcsFile->addError($error, $stackPtr, 'WrongStyle'); - return; - } else if ($code !== T_DOC_COMMENT) { - $phpcsFile->addError('Missing function doc comment', $stackPtr, 'Missing'); - return; - } - - // If there is any code between the function keyword and the doc block - // then the doc block is not for us. - $ignore = PHP_CodeSniffer_Tokens::$scopeModifiers; - $ignore[] = T_STATIC; - $ignore[] = T_WHITESPACE; - $ignore[] = T_ABSTRACT; - $ignore[] = T_FINAL; - $prevToken = $phpcsFile->findPrevious($ignore, ($stackPtr - 1), null, true); - if ($prevToken !== $commentEnd) { - $phpcsFile->addError('Missing function doc comment', $stackPtr, 'Missing'); - return; - } - - $this->_functionToken = $stackPtr; - - $this->_classToken = null; - foreach ($tokens[$stackPtr]['conditions'] as $condPtr => $condition) { - if ($condition === T_CLASS || $condition === T_INTERFACE) { - $this->_classToken = $condPtr; - break; - } - } - - // If the first T_OPEN_TAG is right before the comment, it is probably - // a file comment. - $commentStart = ($phpcsFile->findPrevious(T_DOC_COMMENT, ($commentEnd - 1), null, true) + 1); - $prevToken = $phpcsFile->findPrevious(T_WHITESPACE, ($commentStart - 1), null, true); - if ($tokens[$prevToken]['code'] === T_OPEN_TAG) { - // Is this the first open tag? - if ($stackPtr === 0 || $phpcsFile->findPrevious(T_OPEN_TAG, ($prevToken - 1)) === false) { - $phpcsFile->addError('Missing function doc comment', $stackPtr, 'Missing'); - return; - } - } - - $comment = $phpcsFile->getTokensAsString($commentStart, ($commentEnd - $commentStart + 1)); - $this->_methodName = $phpcsFile->getDeclarationName($stackPtr); - - try { - $this->commentParser = new PHP_CodeSniffer_CommentParser_FunctionCommentParser($comment, $phpcsFile); - $this->commentParser->parse(); - } catch (PHP_CodeSniffer_CommentParser_ParserException $e) { - $line = ($e->getLineWithinComment() + $commentStart); - $phpcsFile->addError($e->getMessage(), $line, 'FailedParse'); - return; - } - - $comment = $this->commentParser->getComment(); - if (is_null($comment) === true) { - $error = 'Function doc comment is empty'; - $phpcsFile->addError($error, $commentStart, 'Empty'); - return; - } - - $this->processParams($commentStart); - $this->processReturn($commentStart, $commentEnd); - $this->processThrows($commentStart); - - // No extra newline before short description. - $short = $comment->getShortComment(); - $newlineCount = 0; - $newlineSpan = strspn($short, $phpcsFile->eolChar); - if ($short !== '' && $newlineSpan > 0) { - $error = 'Extra newline(s) found before function comment short description'; - $phpcsFile->addError($error, ($commentStart + 1), 'SpacingBeforeShort'); - } - - $newlineCount = (substr_count($short, $phpcsFile->eolChar) + 1); - - // Exactly one blank line between short and long description. - $long = $comment->getLongComment(); - if (empty($long) === false) { - $between = $comment->getWhiteSpaceBetween(); - $newlineBetween = substr_count($between, $phpcsFile->eolChar); - if ($newlineBetween !== 2) { - $error = 'There must be exactly one blank line between descriptions in function comment'; - $phpcsFile->addError($error, ($commentStart + $newlineCount + 1), 'SpacingAfterShort'); - } - - $newlineCount += $newlineBetween; - } - - // Exactly one blank line before tags. - $params = $this->commentParser->getTagOrders(); - if (count($params) > 1) { - $newlineSpan = $comment->getNewlineAfter(); - if ($newlineSpan !== 2) { - $error = 'There must be exactly one blank line before the tags in function comment'; - if ($long !== '') { - $newlineCount += (substr_count($long, $phpcsFile->eolChar) - $newlineSpan + 1); - } - - $phpcsFile->addError($error, ($commentStart + $newlineCount), 'SpacingBeforeTags'); - $short = rtrim($short, $phpcsFile->eolChar.' '); - } - } - - }//end process() - - - /** - * Process any throw tags that this function comment has. - * - * @param int $commentStart The position in the stack where the - * comment started. - * - * @return void - */ - protected function processThrows($commentStart) - { - if (count($this->commentParser->getThrows()) === 0) { - return; - } - - foreach ($this->commentParser->getThrows() as $throw) { - - $exception = $throw->getValue(); - $errorPos = ($commentStart + $throw->getLine()); - - if ($exception === '') { - $error = '@throws tag must contain the exception class name'; - $this->currentFile->addError($error, $errorPos, 'EmptyThrows'); - } - } - - }//end processThrows() - - - /** - * Process the return comment of this function comment. - * - * @param int $commentStart The position in the stack where the comment started. - * @param int $commentEnd The position in the stack where the comment ended. - * - * @return void - */ - protected function processReturn($commentStart, $commentEnd) - { - // Skip constructor and destructor. - $className = ''; - if ($this->_classToken !== null) { - $className = $this->currentFile->getDeclarationName($this->_classToken); - $className = strtolower(ltrim($className, '_')); - } - - $methodName = strtolower(ltrim($this->_methodName, '_')); - $isSpecialMethod = ($this->_methodName === '__construct' || $this->_methodName === '__destruct'); - - if ($isSpecialMethod === false && $methodName !== $className) { - // Report missing return tag. - if ($this->commentParser->getReturn() === null) { - $error = 'Missing @return tag in function comment'; - $this->currentFile->addError($error, $commentEnd, 'MissingReturn'); - } else if (trim($this->commentParser->getReturn()->getRawContent()) === '') { - $error = '@return tag is empty in function comment'; - $errorPos = ($commentStart + $this->commentParser->getReturn()->getLine()); - $this->currentFile->addError($error, $errorPos, 'EmptyReturn'); - } - } - - }//end processReturn() - - - /** - * Process the function parameter comments. - * - * @param int $commentStart The position in the stack where - * the comment started. - * - * @return void - */ - protected function processParams($commentStart) - { - $realParams = $this->currentFile->getMethodParameters($this->_functionToken); - - $params = $this->commentParser->getParams(); - $foundParams = array(); - - if (empty($params) === false) { - - $lastParm = (count($params) - 1); - if (substr_count($params[$lastParm]->getWhitespaceAfter(), $this->currentFile->eolChar) !== 2) { - $error = 'Last parameter comment requires a blank newline after it'; - $errorPos = ($params[$lastParm]->getLine() + $commentStart); - $this->currentFile->addError($error, $errorPos, 'SpacingAfterParams'); - } - - // Parameters must appear immediately after the comment. - if ($params[0]->getOrder() !== 2) { - $error = 'Parameters must appear immediately after the comment'; - $errorPos = ($params[0]->getLine() + $commentStart); - $this->currentFile->addError($error, $errorPos, 'SpacingBeforeParams'); - } - - $previousParam = null; - $spaceBeforeVar = 10000; - $spaceBeforeComment = 10000; - $longestType = 0; - $longestVar = 0; - - foreach ($params as $param) { - - $paramComment = trim($param->getComment()); - $errorPos = ($param->getLine() + $commentStart); - - // Make sure that there is only one space before the var type. - if ($param->getWhitespaceBeforeType() !== ' ') { - $error = 'Expected 1 space before variable type'; - $this->currentFile->addError($error, $errorPos, 'SpacingBeforeParamType'); - } - - $spaceCount = substr_count($param->getWhitespaceBeforeVarName(), ' '); - if ($spaceCount < $spaceBeforeVar) { - $spaceBeforeVar = $spaceCount; - $longestType = $errorPos; - } - - $spaceCount = substr_count($param->getWhitespaceBeforeComment(), ' '); - - if ($spaceCount < $spaceBeforeComment && $paramComment !== '') { - $spaceBeforeComment = $spaceCount; - $longestVar = $errorPos; - } - - // Make sure they are in the correct order, - // and have the correct name. - $pos = $param->getPosition(); - - $paramName = ($param->getVarName() !== '') ? $param->getVarName() : '[ UNKNOWN ]'; - - if ($previousParam !== null) { - $previousName = ($previousParam->getVarName() !== '') ? $previousParam->getVarName() : 'UNKNOWN'; - - // Check to see if the parameters align properly. - if ($param->alignsVariableWith($previousParam) === false) { - $error = 'The variable names for parameters %s (%s) and %s (%s) do not align'; - $data = array( - $previousName, - ($pos - 1), - $paramName, - $pos, - ); - $this->currentFile->addError($error, $errorPos, 'ParameterNamesNotAligned', $data); - } - - if ($param->alignsCommentWith($previousParam) === false) { - $error = 'The comments for parameters %s (%s) and %s (%s) do not align'; - $data = array( - $previousName, - ($pos - 1), - $paramName, - $pos, - ); - $this->currentFile->addError($error, $errorPos, 'ParameterCommentsNotAligned', $data); - } - }//end if - - // Make sure the names of the parameter comment matches the - // actual parameter. - if (isset($realParams[($pos - 1)]) === true) { - $realName = $realParams[($pos - 1)]['name']; - $foundParams[] = $realName; - - // Append ampersand to name if passing by reference. - if ($realParams[($pos - 1)]['pass_by_reference'] === true) { - $realName = '&'.$realName; - } - - if ($realName !== $paramName) { - $code = 'ParamNameNoMatch'; - $data = array( - $paramName, - $realName, - $pos, - ); - - $error = 'Doc comment for var %s does not match '; - if (strtolower($paramName) === strtolower($realName)) { - $error .= 'case of '; - $code = 'ParamNameNoCaseMatch'; - } - - $error .= 'actual variable name %s at position %s'; - - $this->currentFile->addError($error, $errorPos, $code, $data); - } - } else { - // We must have an extra parameter comment. - $error = 'Superfluous doc comment at position '.$pos; - $this->currentFile->addError($error, $errorPos, 'ExtraParamComment'); - } - - if ($param->getVarName() === '') { - $error = 'Missing parameter name at position '.$pos; - $this->currentFile->addError($error, $errorPos, 'MissingParamName'); - } - - if ($param->getType() === '') { - $error = 'Missing type at position '.$pos; - $this->currentFile->addError($error, $errorPos, 'MissingParamType'); - } - - if ($paramComment === '') { - $error = 'Missing comment for param "%s" at position %s'; - $data = array( - $paramName, - $pos, - ); - $this->currentFile->addError($error, $errorPos, 'MissingParamComment', $data); - } - - $previousParam = $param; - - }//end foreach - - if ($spaceBeforeVar !== 1 && $spaceBeforeVar !== 10000 && $spaceBeforeComment !== 10000) { - $error = 'Expected 1 space after the longest type'; - $this->currentFile->addError($error, $longestType, 'SpacingAfterLongType'); - } - - if ($spaceBeforeComment !== 1 && $spaceBeforeComment !== 10000) { - $error = 'Expected 1 space after the longest variable name'; - $this->currentFile->addError($error, $longestVar, 'SpacingAfterLongName'); - } - - }//end if - - $realNames = array(); - foreach ($realParams as $realParam) { - $realNames[] = $realParam['name']; - } - - // Report and missing comments. - $diff = array_diff($realNames, $foundParams); - foreach ($diff as $neededParam) { - if (count($params) !== 0) { - $errorPos = ($params[(count($params) - 1)]->getLine() + $commentStart); - } else { - $errorPos = $commentStart; - } - - $error = 'Doc comment for "%s" missing'; - $data = array($neededParam); - $this->currentFile->addError($error, $errorPos, 'MissingParamTag', $data); - } - - }//end processParams() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/Commenting/InlineCommentSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/Commenting/InlineCommentSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/Commenting/InlineCommentSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/Commenting/InlineCommentSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,70 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * PHP_CodeSniffer_Sniffs_PEAR_Commenting_InlineCommentSniff. - * - * Checks that no perl-style comments are used. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PEAR_Sniffs_Commenting_InlineCommentSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array(T_COMMENT); - - }//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(); - - if ($tokens[$stackPtr]['content']{0} === '#') { - $error = 'Perl-style comments are not allowed. Use "// Comment."'; - $error .= ' or "/* comment */" instead.'; - $phpcsFile->addError($error, $stackPtr, 'WrongStyle'); - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/ControlStructures/ControlSignatureSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/ControlStructures/ControlSignatureSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/ControlStructures/ControlSignatureSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/ControlStructures/ControlSignatureSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,70 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -if (class_exists('PHP_CodeSniffer_Standards_AbstractPatternSniff', true) === false) { - throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_Standards_AbstractPatternSniff not found'); -} - -/** - * Verifies that control statements conform to their coding standards. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PEAR_Sniffs_ControlStructures_ControlSignatureSniff extends PHP_CodeSniffer_Standards_AbstractPatternSniff -{ - - - /** - * Constructs a PEAR_Sniffs_ControlStructures_ControlSignatureSniff. - */ - public function __construct() - { - parent::__construct(true); - - }//end __construct() - - - /** - * Returns the patterns that this test wishes to verify. - * - * @return array(string) - */ - protected function getPatterns() - { - return array( - 'do {EOL...} while (...);EOL', - 'while (...) {EOL', - 'for (...) {EOL', - 'if (...) {EOL', - 'foreach (...) {EOL', - '} else if (...) {EOL', - '} elseif (...) {EOL', - '} else {EOL', - 'do {EOL', - ); - - }//end getPatterns() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/ControlStructures/MultiLineConditionSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/ControlStructures/MultiLineConditionSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/ControlStructures/MultiLineConditionSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/ControlStructures/MultiLineConditionSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,176 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * PEAR_Sniffs_ControlStructures_MultiLineConditionSniff. - * - * Ensure multi-line IF conditions are defined correctly. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PEAR_Sniffs_ControlStructures_MultiLineConditionSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array(T_IF); - - }//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(); - - // We need to work out how far indented the if statement - // itself is, so we can work out how far to indent conditions. - $statementIndent = 0; - for ($i = ($stackPtr - 1); $i >= 0; $i--) { - if ($tokens[$i]['line'] !== $tokens[$stackPtr]['line']) { - $i++; - break; - } - } - - if ($i >= 0 && $tokens[$i]['code'] === T_WHITESPACE) { - $statementIndent = strlen($tokens[$i]['content']); - } - - // Each line between the parenthesis should be indented 4 spaces - // and start with an operator, unless the line is inside a - // function call, in which case it is ignored. - $openBracket = $tokens[$stackPtr]['parenthesis_opener']; - $closeBracket = $tokens[$stackPtr]['parenthesis_closer']; - $lastLine = $tokens[$openBracket]['line']; - for ($i = ($openBracket + 1); $i < $closeBracket; $i++) { - if ($tokens[$i]['line'] !== $lastLine) { - if ($tokens[$i]['line'] === $tokens[$closeBracket]['line']) { - $next = $phpcsFile->findNext(T_WHITESPACE, $i, null, true); - if ($next !== $closeBracket) { - // Closing bracket is on the same line as a condition. - $error = 'Closing parenthesis of a multi-line IF statement must be on a new line'; - $phpcsFile->addError($error, $i, 'CloseBracketNewLine'); - $expectedIndent = ($statementIndent + 4); - } else { - // Closing brace needs to be indented to the same level - // as the function. - $expectedIndent = $statementIndent; - } - } else { - $expectedIndent = ($statementIndent + 4); - } - - // We changed lines, so this should be a whitespace indent token. - if ($tokens[$i]['code'] !== T_WHITESPACE) { - $foundIndent = 0; - } else { - $foundIndent = strlen($tokens[$i]['content']); - } - - if ($expectedIndent !== $foundIndent) { - $error = 'Multi-line IF statement not indented correctly; expected %s spaces but found %s'; - $data = array( - $expectedIndent, - $foundIndent, - ); - $phpcsFile->addError($error, $i, 'Alignment', $data); - } - - if ($tokens[$i]['line'] !== $tokens[$closeBracket]['line']) { - $next = $phpcsFile->findNext(T_WHITESPACE, $i, null, true); - if (in_array($tokens[$next]['code'], PHP_CodeSniffer_Tokens::$booleanOperators) === false) { - $error = 'Each line in a multi-line IF statement must begin with a boolean operator'; - $phpcsFile->addError($error, $i, 'StartWithBoolean'); - } - } - - $lastLine = $tokens[$i]['line']; - }//end if - - if ($tokens[$i]['code'] === T_STRING) { - $next = $phpcsFile->findNext(T_WHITESPACE, ($i + 1), null, true); - if ($tokens[$next]['code'] === T_OPEN_PARENTHESIS) { - // This is a function call, so skip to the end as they - // have their own indentation rules. - $i = $tokens[$next]['parenthesis_closer']; - $lastLine = $tokens[$i]['line']; - continue; - } - } - }//end for - - // From here on, we are checking the spacing of the opening and closing - // braces. If this IF statement does not use braces, we end here. - if (isset($tokens[$stackPtr]['scope_opener']) === false) { - return; - } - - // The opening brace needs to be one space away from the closing parenthesis. - if ($tokens[($closeBracket + 1)]['code'] !== T_WHITESPACE) { - $length = 0; - } else if ($tokens[($closeBracket + 1)]['content'] === $phpcsFile->eolChar) { - $length = -1; - } else { - $length = strlen($tokens[($closeBracket + 1)]['content']); - } - - if ($length !== 1) { - $data = array($length); - $code = 'SpaceBeforeOpenBrace'; - - $error = 'There must be a single space between the closing parenthesis and the opening brace of a multi-line IF statement; found '; - if ($length === -1) { - $error .= 'newline'; - $code = 'NewlineBeforeOpenBrace'; - } else { - $error .= '%s spaces'; - } - - $phpcsFile->addError($error, ($closeBracket + 1), $code, $data); - } - - // And just in case they do something funny before the brace... - $next = $phpcsFile->findNext(T_WHITESPACE, ($closeBracket + 1), null, true); - if ($next !== false && $tokens[$next]['code'] !== T_OPEN_CURLY_BRACKET) { - $error = 'There must be a single space between the closing parenthesis and the opening brace of a multi-line IF statement'; - $phpcsFile->addError($error, $next, 'NoSpaceBeforeOpenBrace'); - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/Files/IncludingFileSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/Files/IncludingFileSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/Files/IncludingFileSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/Files/IncludingFileSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,137 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * PEAR_Sniffs_Files_IncludingFileSniff. - * - * Checks that the include_once is used in conditional situations, and - * require_once is used elsewhere. Also checks that brackets do not surround - * the file being included. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PEAR_Sniffs_Files_IncludingFileSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * Conditions that should use include_once - * - * @var array(int) - */ - private static $_conditions = array( - T_IF, - T_ELSE, - T_ELSEIF, - T_SWITCH, - ); - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array( - T_INCLUDE_ONCE, - T_REQUIRE_ONCE, - T_REQUIRE, - T_INCLUDE, - ); - - }//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(); - - $nextToken = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr + 1), null, true); - if ($tokens[$nextToken]['code'] === T_OPEN_PARENTHESIS) { - $error = '"%s" is a statement not a function; no parentheses are required'; - $data = array($tokens[$stackPtr]['content']); - $phpcsFile->addError($error, $stackPtr, 'BracketsNotRequired', $data); - } - - $inCondition = (count($tokens[$stackPtr]['conditions']) !== 0) ? true : false; - - // Check to see if this including statement is within the parenthesis - // of a condition. If that's the case then we need to process it as being - // within a condition, as they are checking the return value. - if (isset($tokens[$stackPtr]['nested_parenthesis']) === true) { - foreach ($tokens[$stackPtr]['nested_parenthesis'] as $left => $right) { - if (isset($tokens[$left]['parenthesis_owner']) === true) { - $inCondition = true; - } - } - } - - // Check to see if they are assigning the return value of this - // including call. If they are then they are probably checking it, so - // it's conditional. - $previous = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true); - if (in_array($tokens[$previous]['code'], PHP_CodeSniffer_Tokens::$assignmentTokens) === true) { - // The have assigned the return value to it, so its conditional. - $inCondition = true; - } - - $tokenCode = $tokens[$stackPtr]['code']; - if ($inCondition === true) { - // We are inside a conditional statement. We need an include_once. - if ($tokenCode === T_REQUIRE_ONCE) { - $error = 'File is being conditionally included; '; - $error .= 'use "include_once" instead'; - $phpcsFile->addError($error, $stackPtr, 'UseIncludeOnce'); - } else if ($tokenCode === T_REQUIRE) { - $error = 'File is being conditionally included; '; - $error .= 'use "include" instead'; - $phpcsFile->addError($error, $stackPtr, 'UseInclude'); - } - } else { - // We are unconditionally including, we need a require_once. - if ($tokenCode === T_INCLUDE_ONCE) { - $error = 'File is being unconditionally included; '; - $error .= 'use "require_once" instead'; - $phpcsFile->addError($error, $stackPtr, 'UseRequireOnce'); - } else if ($tokenCode === T_INCLUDE) { - $error = 'File is being unconditionally included; '; - $error .= 'use "require" instead'; - $phpcsFile->addError($error, $stackPtr, 'UseRequire'); - } - }//end if - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/Formatting/MultiLineAssignmentSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/Formatting/MultiLineAssignmentSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/Formatting/MultiLineAssignmentSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/Formatting/MultiLineAssignmentSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,113 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * PEAR_Sniffs_Formatting_MultiLineAssignmentSniff. - * - * If an assignment goes over two lines, ensure the equal sign is indented. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PEAR_Sniffs_Formatting_MultiLineAssignmentSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array(T_EQUAL); - - }//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(); - - // Equal sign can't be the last thing on the line. - $next = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); - if ($next === false) { - // Bad assignment. - return; - } - - if ($tokens[$next]['line'] !== $tokens[$stackPtr]['line']) { - $error = 'Multi-line assignments must have the equal sign on the second line'; - $phpcsFile->addError($error, $stackPtr, 'EqualSignLine'); - return; - } - - // Make sure it is the first thing on the line, otherwise we ignore it. - $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), false, true); - if ($prev === false) { - // Bad assignment. - return; - } - - if ($tokens[$prev]['line'] === $tokens[$stackPtr]['line']) { - return; - } - - // Find the required indent based on the ident of the previous line. - $assignmentIndent = 0; - $prevLine = $tokens[$prev]['line']; - for ($i = ($prev - 1); $i >= 0; $i--) { - if ($tokens[$i]['line'] !== $prevLine) { - $i++; - break; - } - } - - if ($tokens[$i]['code'] === T_WHITESPACE) { - $assignmentIndent = strlen($tokens[$i]['content']); - } - - // Find the actual indent. - $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1)); - - $expectedIndent = ($assignmentIndent + 4); - $foundIndent = strlen($tokens[$prev]['content']); - if ($foundIndent !== $expectedIndent) { - $error = 'Multi-line assignment not indented correctly; expected %s spaces but found %s'; - $data = array( - $expectedIndent, - $foundIndent, - ); - $phpcsFile->addError($error, $stackPtr, 'Indent', $data); - } - - }//end process() - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,266 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * PEAR_Sniffs_Functions_FunctionCallSignatureSniff. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PEAR_Sniffs_Functions_FunctionCallSignatureSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * The number of spaces code should be indented. - * - * @var int - */ - public $indent = 4; - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array(T_STRING); - - }//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 the next non-empty token. - $openBracket = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr + 1), null, true); - - if ($tokens[$openBracket]['code'] !== T_OPEN_PARENTHESIS) { - // Not a function call. - return; - } - - if (isset($tokens[$openBracket]['parenthesis_closer']) === false) { - // Not a function call. - return; - } - - // Find the previous non-empty token. - $search = PHP_CodeSniffer_Tokens::$emptyTokens; - $search[] = T_BITWISE_AND; - $previous = $phpcsFile->findPrevious($search, ($stackPtr - 1), null, true); - if ($tokens[$previous]['code'] === T_FUNCTION) { - // It's a function definition, not a function call. - return; - } - - $closeBracket = $tokens[$openBracket]['parenthesis_closer']; - - if (($stackPtr + 1) !== $openBracket) { - // Checking this: $value = my_function[*](...). - $error = 'Space before opening parenthesis of function call prohibited'; - $phpcsFile->addError($error, $stackPtr, 'SpaceBeforeOpenBracket'); - } - - $next = $phpcsFile->findNext(T_WHITESPACE, ($closeBracket + 1), null, true); - if ($tokens[$next]['code'] === T_SEMICOLON) { - if (in_array($tokens[($closeBracket + 1)]['code'], PHP_CodeSniffer_Tokens::$emptyTokens) === true) { - $error = 'Space after closing parenthesis of function call prohibited'; - $phpcsFile->addError($error, $closeBracket, 'SpaceAfterCloseBracket'); - } - } - - // Check if this is a single line or multi-line function call. - if ($tokens[$openBracket]['line'] === $tokens[$closeBracket]['line']) { - $this->processSingleLineCall($phpcsFile, $stackPtr, $openBracket, $tokens); - } else { - $this->processMultiLineCall($phpcsFile, $stackPtr, $openBracket, $tokens); - } - - }//end process() - - - /** - * Processes single-line calls. - * - * @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 $openBracket The position of the openning bracket - * in the stack passed in $tokens. - * @param array $tokens The stack of tokens that make up - * the file. - * - * @return void - */ - public function processSingleLineCall(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $openBracket, $tokens) - { - if ($tokens[($openBracket + 1)]['code'] === T_WHITESPACE) { - // Checking this: $value = my_function([*]...). - $error = 'Space after opening parenthesis of function call prohibited'; - $phpcsFile->addError($error, $stackPtr, 'SpaceAfterOpenBracket'); - } - - $closer = $tokens[$openBracket]['parenthesis_closer']; - - if ($tokens[($closer - 1)]['code'] === T_WHITESPACE) { - // Checking this: $value = my_function(...[*]). - $between = $phpcsFile->findNext(T_WHITESPACE, ($openBracket + 1), null, true); - - // Only throw an error if there is some content between the parenthesis. - // i.e., Checking for this: $value = my_function(). - // If there is no content, then we would have thrown an error in the - // previous IF statement because it would look like this: - // $value = my_function( ). - if ($between !== $closer) { - $error = 'Space before closing parenthesis of function call prohibited'; - $phpcsFile->addError($error, $closer, 'SpaceBeforeCloseBracket'); - } - } - - }//end processSingleLineCall() - - - /** - * Processes multi-line calls. - * - * @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 $openBracket The position of the openning bracket - * in the stack passed in $tokens. - * @param array $tokens The stack of tokens that make up - * the file. - * - * @return void - */ - public function processMultiLineCall(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $openBracket, $tokens) - { - // We need to work out how far indented the function - // call itself is, so we can work out how far to - // indent the arguments. - $functionIndent = 0; - for ($i = ($stackPtr - 1); $i >= 0; $i--) { - if ($tokens[$i]['line'] !== $tokens[$stackPtr]['line']) { - $i++; - break; - } - } - - if ($tokens[$i]['code'] === T_WHITESPACE) { - $functionIndent = strlen($tokens[$i]['content']); - } - - // Each line between the parenthesis should be indented n spaces. - $closeBracket = $tokens[$openBracket]['parenthesis_closer']; - $lastLine = $tokens[$openBracket]['line']; - for ($i = ($openBracket + 1); $i < $closeBracket; $i++) { - // Skip nested function calls. - if ($tokens[$i]['code'] === T_OPEN_PARENTHESIS) { - $i = $tokens[$i]['parenthesis_closer']; - $lastLine = $tokens[$i]['line']; - continue; - } - - if ($tokens[$i]['line'] !== $lastLine) { - $lastLine = $tokens[$i]['line']; - - // Ignore heredoc indentation. - if (in_array($tokens[$i]['code'], PHP_CodeSniffer_Tokens::$heredocTokens) === true) { - continue; - } - - // Ignore multi-line string indentation. - if (in_array($tokens[$i]['code'], PHP_CodeSniffer_Tokens::$stringTokens) === true) { - if ($tokens[$i]['code'] === $tokens[($i - 1)]['code']) { - continue; - } - } - - // We changed lines, so this should be a whitespace indent token, but first make - // sure it isn't a blank line because we don't need to check indent unless there - // is actually some code to indent. - $nextCode = $phpcsFile->findNext(T_WHITESPACE, ($i + 1), ($closeBracket + 1), true); - if ($tokens[$nextCode]['line'] !== $lastLine) { - $error = 'Empty lines are not allowed in multi-line function calls'; - $phpcsFile->addError($error, $i, 'EmptyLine'); - continue; - } - - if ($nextCode === $closeBracket) { - // Closing brace needs to be indented to the same level - // as the function call. - $expectedIndent = $functionIndent; - } else { - $expectedIndent = ($functionIndent + $this->indent); - } - - if ($tokens[$i]['code'] !== T_WHITESPACE) { - $foundIndent = 0; - } else { - $foundIndent = strlen($tokens[$i]['content']); - } - - if ($expectedIndent !== $foundIndent) { - $error = 'Multi-line function call not indented correctly; expected %s spaces but found %s'; - $data = array( - $expectedIndent, - $foundIndent, - ); - $phpcsFile->addError($error, $i, 'Indent', $data); - } - }//end if - - // Skip the rest of a closure. - if ($tokens[$i]['code'] === T_CLOSURE) { - $i = $tokens[$i]['scope_closer']; - $lastLine = $tokens[$i]['line']; - continue; - } - }//end for - - if ($tokens[($openBracket + 1)]['content'] !== $phpcsFile->eolChar) { - $error = 'Opening parenthesis of a multi-line function call must be the last content on the line'; - $phpcsFile->addError($error, $stackPtr, 'ContentAfterOpenBracket'); - } - - $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($closeBracket - 1), null, true); - if ($tokens[$prev]['line'] === $tokens[$closeBracket]['line']) { - $error = 'Closing parenthesis of a multi-line function call must be on a line by itself'; - $phpcsFile->addError($error, $closeBracket, 'CloseBracketLine'); - } - - }//end processMultiLineCall() - - -}//end class -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,224 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * PEAR_Sniffs_Functions_FunctionDeclarationSniff. - * - * Ensure single and multi-line function declarations are defined correctly. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PEAR_Sniffs_Functions_FunctionDeclarationSniff 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(); - - // Check if this is a single line or multi-line declaration. - $openBracket = $tokens[$stackPtr]['parenthesis_opener']; - $closeBracket = $tokens[$stackPtr]['parenthesis_closer']; - if ($tokens[$openBracket]['line'] === $tokens[$closeBracket]['line']) { - $this->processSingleLineDeclaration($phpcsFile, $stackPtr, $tokens); - } else { - $this->processMultiLineDeclaration($phpcsFile, $stackPtr, $tokens); - } - - }//end process() - - - /** - * Processes single-line declarations. - * - * Just uses the Generic BSD-Allman brace sniff. - * - * @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 array $tokens The stack of tokens that make up - * the file. - * - * @return void - */ - public function processSingleLineDeclaration(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $tokens) - { - if (class_exists('Generic_Sniffs_Functions_OpeningFunctionBraceBsdAllmanSniff', true) === false) { - throw new PHP_CodeSniffer_Exception('Class Generic_Sniffs_Functions_OpeningFunctionBraceBsdAllmanSniff not found'); - } - - $sniff = new Generic_Sniffs_Functions_OpeningFunctionBraceBsdAllmanSniff(); - $sniff->process($phpcsFile, $stackPtr); - - }//end processSingleLineDeclaration() - - - /** - * Processes mutli-line declarations. - * - * @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 array $tokens The stack of tokens that make up - * the file. - * - * @return void - */ - public function processMultiLineDeclaration(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $tokens) - { - // We need to work out how far indented the function - // declaration itself is, so we can work out how far to - // indent parameters. - $functionIndent = 0; - for ($i = ($stackPtr - 1); $i >= 0; $i--) { - if ($tokens[$i]['line'] !== $tokens[$stackPtr]['line']) { - $i++; - break; - } - } - - if ($tokens[$i]['code'] === T_WHITESPACE) { - $functionIndent = strlen($tokens[$i]['content']); - } - - // Each line between the parenthesis should be indented 4 spaces. - $openBracket = $tokens[$stackPtr]['parenthesis_opener']; - $closeBracket = $tokens[$stackPtr]['parenthesis_closer']; - $lastLine = $tokens[$openBracket]['line']; - for ($i = ($openBracket + 1); $i < $closeBracket; $i++) { - if ($tokens[$i]['line'] !== $lastLine) { - if ($tokens[$i]['line'] === $tokens[$closeBracket]['line']) { - // Closing brace needs to be indented to the same level - // as the function. - $expectedIndent = $functionIndent; - } else { - $expectedIndent = ($functionIndent + 4); - } - - // We changed lines, so this should be a whitespace indent token. - if ($tokens[$i]['code'] !== T_WHITESPACE) { - $foundIndent = 0; - } else { - $foundIndent = strlen($tokens[$i]['content']); - } - - if ($expectedIndent !== $foundIndent) { - $error = 'Multi-line function declaration not indented correctly; expected %s spaces but found %s'; - $data = array( - $expectedIndent, - $foundIndent, - ); - $phpcsFile->addError($error, $i, 'Indent', $data); - } - - $lastLine = $tokens[$i]['line']; - }//end if - - if ($tokens[$i]['code'] === T_ARRAY) { - // Skip arrays as they have their own indentation rules. - $i = $tokens[$i]['parenthesis_closer']; - $lastLine = $tokens[$i]['line']; - continue; - } - }//end for - - if (isset($tokens[$stackPtr]['scope_opener']) === true) { - // The openning brace needs to be one space away - // from the closing parenthesis. - $next = $tokens[($closeBracket + 1)]; - if ($next['code'] !== T_WHITESPACE) { - $length = 0; - } else if ($next['content'] === $phpcsFile->eolChar) { - $length = -1; - } else { - $length = strlen($next['content']); - } - - if ($length !== 1) { - $data = array($length); - $code = 'SpaceBeforeOpenBrace'; - - $error = 'There must be a single space between the closing parenthesis and the opening brace of a multi-line function declaration; found '; - if ($length === -1) { - $error .= 'newline'; - $code = 'NewlineBeforeOpenBrace'; - } else { - $error .= '%s spaces'; - } - - $phpcsFile->addError($error, ($closeBracket + 1), $code, $data); - return; - } - - // And just in case they do something funny before the brace... - $next = $phpcsFile->findNext( - T_WHITESPACE, - ($closeBracket + 1), - null, - true - ); - - if ($next !== false && $tokens[$next]['code'] !== T_OPEN_CURLY_BRACKET) { - $error = 'There must be a single space between the closing parenthesis and the opening brace of a multi-line function declaration'; - $phpcsFile->addError($error, $next, 'NoSpaceBeforeOpenBrace'); - } - }//end if - - // The closing parenthesis must be on a new line, even - // when checking abstract function definitions. - $prev = $phpcsFile->findPrevious( - T_WHITESPACE, - ($closeBracket - 1), - null, - true - ); - - if ($tokens[$prev]['line'] === $tokens[$closeBracket]['line']) { - $error = 'The closing parenthesis of a multi-line function declaration must be on a new line'; - $phpcsFile->addError($error, $closeBracket, 'CloseBracketLine'); - } - - }//end processMultiLineDeclaration() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/Functions/ValidDefaultValueSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/Functions/ValidDefaultValueSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/Functions/ValidDefaultValueSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/Functions/ValidDefaultValueSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,108 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * PEAR_Sniffs_Functions_ValidDefaultValueSniff. - * - * A Sniff to ensure that parameters defined for a function that have a default - * value come at the end of the function signature. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PEAR_Sniffs_Functions_ValidDefaultValueSniff 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(); - - $argStart = $tokens[$stackPtr]['parenthesis_opener']; - $argEnd = $tokens[$stackPtr]['parenthesis_closer']; - - // Flag for when we have found a default in our arg list. - // If there is a value without a default after this, it is an error. - $defaultFound = false; - - $nextArg = $argStart; - while (($nextArg = $phpcsFile->findNext(T_VARIABLE, ($nextArg + 1), $argEnd)) !== false) { - $argHasDefault = self::_argHasDefault($phpcsFile, $nextArg); - if (($argHasDefault === false) && ($defaultFound === true)) { - $error = 'Arguments with default values must be at the end of the argument list'; - $phpcsFile->addError($error, $nextArg, 'NotAtEnd'); - return; - } - - if ($argHasDefault === true) { - $defaultFound = true; - } - } - - }//end process() - - - /** - * Returns true if the passed argument has a default value. - * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $argPtr The position of the argument - * in the stack. - * - * @return bool - */ - private static function _argHasDefault(PHP_CodeSniffer_File $phpcsFile, $argPtr) - { - $tokens = $phpcsFile->getTokens(); - $nextToken = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($argPtr + 1), null, true); - if ($tokens[$nextToken]['code'] !== T_EQUAL) { - return false; - } - - return true; - - }//end _argHasDefault() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/NamingConventions/ValidClassNameSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/NamingConventions/ValidClassNameSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/NamingConventions/ValidClassNameSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/NamingConventions/ValidClassNameSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,115 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * PEAR_Sniffs_NamingConventions_ValidClassNameSniff. - * - * Ensures class and interface names start with a capital letter - * and use _ separators. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PEAR_Sniffs_NamingConventions_ValidClassNameSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * 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 current file being processed. - * @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(); - - $className = $phpcsFile->findNext(T_STRING, $stackPtr); - $name = trim($tokens[$className]['content']); - $errorData = array(ucfirst($tokens[$stackPtr]['content'])); - - // Make sure the first letter is a capital. - if (preg_match('|^[A-Z]|', $name) === 0) { - $error = '%s name must begin with a capital letter'; - $phpcsFile->addError($error, $stackPtr, 'StartWithCaptial', $errorData); - } - - // Check that each new word starts with a capital as well, but don't - // check the first word, as it is checked above. - $validName = true; - $nameBits = explode('_', $name); - $firstBit = array_shift($nameBits); - foreach ($nameBits as $bit) { - if ($bit === '' || $bit{0} !== strtoupper($bit{0})) { - $validName = false; - break; - } - } - - if ($validName === false) { - // Strip underscores because they cause the suggested name - // to be incorrect. - $nameBits = explode('_', trim($name, '_')); - $firstBit = array_shift($nameBits); - if ($firstBit === '') { - $error = '%s name is not valid'; - $phpcsFile->addError($error, $stackPtr, 'Invalid', $errorData); - } else { - $newName = strtoupper($firstBit{0}).substr($firstBit, 1).'_'; - foreach ($nameBits as $bit) { - if ($bit !== '') { - $newName .= strtoupper($bit{0}).substr($bit, 1).'_'; - } - } - - $newName = rtrim($newName, '_'); - $error = '%s name is not valid; consider %s instead'; - $data = $errorData; - $data[] = $newName; - $phpcsFile->addError($error, $stackPtr, 'Invalid', $data); - } - }//end if - - }//end process() - - -}//end class - - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/NamingConventions/ValidFunctionNameSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/NamingConventions/ValidFunctionNameSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/NamingConventions/ValidFunctionNameSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/NamingConventions/ValidFunctionNameSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,285 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -if (class_exists('PHP_CodeSniffer_Standards_AbstractScopeSniff', true) === false) { - throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_Standards_AbstractScopeSniff not found'); -} - -/** - * PEAR_Sniffs_NamingConventions_ValidFunctionNameSniff. - * - * Ensures method names are correct depending on whether they are public - * or private, and that functions are named correctly. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PEAR_Sniffs_NamingConventions_ValidFunctionNameSniff extends PHP_CodeSniffer_Standards_AbstractScopeSniff -{ - - /** - * A list of all PHP magic methods. - * - * @var array - */ - protected $magicMethods = array( - 'construct', - 'destruct', - 'call', - 'callStatic', - 'get', - 'set', - 'isset', - 'unset', - 'sleep', - 'wakeup', - 'toString', - 'set_state', - 'clone', - 'invoke', - ); - - /** - * A list of all PHP magic functions. - * - * @var array - */ - protected $magicFunctions = array('autoload'); - - - /** - * Constructs a PEAR_Sniffs_NamingConventions_ValidFunctionNameSniff. - */ - public function __construct() - { - parent::__construct(array(T_CLASS, T_INTERFACE), array(T_FUNCTION), true); - - }//end __construct() - - - /** - * Processes the tokens within the scope. - * - * @param PHP_CodeSniffer_File $phpcsFile The file being processed. - * @param int $stackPtr The position where this token was - * found. - * @param int $currScope The position of the current scope. - * - * @return void - */ - protected function processTokenWithinScope(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $currScope) - { - $methodName = $phpcsFile->getDeclarationName($stackPtr); - if ($methodName === null) { - // Ignore closures. - return; - } - - $className = $phpcsFile->getDeclarationName($currScope); - $errorData = array($className.'::'.$methodName); - - // Is this a magic method. IE. is prefixed with "__". - if (preg_match('|^__|', $methodName) !== 0) { - $magicPart = substr($methodName, 2); - if (in_array($magicPart, $this->magicMethods) === false) { - $error = 'Method name "%s" is invalid; only PHP magic methods should be prefixed with a double underscore'; - - $phpcsFile->addError($error, $stackPtr, 'MethodDoubleUnderscore', $errorData); - } - - return; - } - - // PHP4 constructors are allowed to break our rules. - if ($methodName === $className) { - return; - } - - // PHP4 destructors are allowed to break our rules. - if ($methodName === '_'.$className) { - return; - } - - $methodProps = $phpcsFile->getMethodProperties($stackPtr); - $isPublic = ($methodProps['scope'] === 'private') ? false : true; - $scope = $methodProps['scope']; - $scopeSpecified = $methodProps['scope_specified']; - - // If it's a private method, it must have an underscore on the front. - if ($isPublic === false && $methodName{0} !== '_') { - $error = 'Private method name "%s" must be prefixed with an underscore'; - $phpcsFile->addError($error, $stackPtr, 'PrivateNoUnderscore', $errorData); - return; - } - - // If it's not a private method, it must not have an underscore on the front. - if ($isPublic === true && $scopeSpecified === true && $methodName{0} === '_') { - $error = '%s method name "%s" must not be prefixed with an underscore'; - $data = array( - ucfirst($scope), - $errorData[0], - ); - $phpcsFile->addError($error, $stackPtr, 'PublicUnderscore', $data); - return; - } - - // If the scope was specified on the method, then the method must be - // camel caps and an underscore should be checked for. If it wasn't - // specified, treat it like a public method and remove the underscore - // prefix if there is one because we cant determine if it is private or - // public. - $testMethodName = $methodName; - if ($scopeSpecified === false && $methodName{0} === '_') { - $testMethodName = substr($methodName, 1); - } - - if (PHP_CodeSniffer::isCamelCaps($testMethodName, false, $isPublic, false) === false) { - if ($scopeSpecified === true) { - $error = '%s method name "%s" is not in camel caps format'; - $data = array( - ucfirst($scope), - $errorData[0], - ); - $phpcsFile->addError($error, $stackPtr, 'ScopeNotCamelCaps', $data); - } else { - $error = 'Method name "%s" is not in camel caps format'; - $phpcsFile->addError($error, $stackPtr, 'NotCamelCaps', $errorData); - } - - return; - } - - }//end processTokenWithinScope() - - - /** - * Processes the tokens outside the scope. - * - * @param PHP_CodeSniffer_File $phpcsFile The file being processed. - * @param int $stackPtr The position where this token was - * found. - * - * @return void - */ - protected function processTokenOutsideScope(PHP_CodeSniffer_File $phpcsFile, $stackPtr) - { - $functionName = $phpcsFile->getDeclarationName($stackPtr); - if ($functionName === null) { - // Ignore closures. - return; - } - - $errorData = array($functionName); - - // Is this a magic function. IE. is prefixed with "__". - if (preg_match('|^__|', $functionName) !== 0) { - $magicPart = substr($functionName, 2); - if (in_array($magicPart, $this->magicFunctions) === false) { - $error = 'Function name "%s" is invalid; only PHP magic methods should be prefixed with a double underscore'; - $phpcsFile->addError($error, $stackPtr, 'FunctionDoubleUnderscore', $errorData); - } - - return; - } - - // Function names can be in two parts; the package name and - // the function name. - $packagePart = ''; - $camelCapsPart = ''; - $underscorePos = strrpos($functionName, '_'); - if ($underscorePos === false) { - $camelCapsPart = $functionName; - } else { - $packagePart = substr($functionName, 0, $underscorePos); - $camelCapsPart = substr($functionName, ($underscorePos + 1)); - - // We don't care about _'s on the front. - $packagePart = ltrim($packagePart, '_'); - } - - // If it has a package part, make sure the first letter is a capital. - if ($packagePart !== '') { - if ($functionName{0} === '_') { - $error = 'Function name "%s" is invalid; only private methods should be prefixed with an underscore'; - $phpcsFile->addError($error, $stackPtr, 'FunctionUnderscore', $errorData); - return; - } - - if ($functionName{0} !== strtoupper($functionName{0})) { - $error = 'Function name "%s" is prefixed with a package name but does not begin with a capital letter'; - $phpcsFile->addError($error, $stackPtr, 'FunctionNoCaptial', $errorData); - return; - } - } - - // If it doesn't have a camel caps part, it's not valid. - if (trim($camelCapsPart) === '') { - $error = 'Function name "%s" is not valid; name appears incomplete'; - $phpcsFile->addError($error, $stackPtr, 'FunctionInvalid', $errorData); - return; - } - - $validName = true; - $newPackagePart = $packagePart; - $newCamelCapsPart = $camelCapsPart; - - // Every function must have a camel caps part, so check that first. - if (PHP_CodeSniffer::isCamelCaps($camelCapsPart, false, true, false) === false) { - $validName = false; - $newCamelCapsPart = strtolower($camelCapsPart{0}).substr($camelCapsPart, 1); - } - - if ($packagePart !== '') { - // Check that each new word starts with a capital. - $nameBits = explode('_', $packagePart); - foreach ($nameBits as $bit) { - if ($bit{0} !== strtoupper($bit{0})) { - $newPackagePart = ''; - foreach ($nameBits as $bit) { - $newPackagePart .= strtoupper($bit{0}).substr($bit, 1).'_'; - } - - $validName = false; - break; - } - } - } - - if ($validName === false) { - $newName = rtrim($newPackagePart, '_').'_'.$newCamelCapsPart; - if ($newPackagePart === '') { - $newName = $newCamelCapsPart; - } else { - $newName = rtrim($newPackagePart, '_').'_'.$newCamelCapsPart; - } - - $error = 'Function name "%s" is invalid; consider "%s" instead'; - $data = $errorData; - $data[] = $newName; - $phpcsFile->addError($error, $stackPtr, 'FunctionNameInvalid', $data); - } - - }//end processTokenOutsideScope() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/NamingConventions/ValidVariableNameSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/NamingConventions/ValidVariableNameSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/NamingConventions/ValidVariableNameSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/NamingConventions/ValidVariableNameSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,116 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -if (class_exists('PHP_CodeSniffer_Standards_AbstractVariableSniff', true) === false) { - $error = 'Class PHP_CodeSniffer_Standards_AbstractVariableSniff not found'; - throw new PHP_CodeSniffer_Exception($error); -} - -/** - * PEAR_Sniffs_NamingConventions_ValidVariableNameSniff. - * - * Checks the naming of member variables. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PEAR_Sniffs_NamingConventions_ValidVariableNameSniff extends PHP_CodeSniffer_Standards_AbstractVariableSniff -{ - - - /** - * Processes class member variables. - * - * @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 - */ - protected function processMemberVar(PHP_CodeSniffer_File $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - - $memberProps = $phpcsFile->getMemberProperties($stackPtr); - if (empty($memberProps) === true) { - return; - } - - $memberName = ltrim($tokens[$stackPtr]['content'], '$'); - $isPublic = ($memberProps['scope'] === 'private') ? false : true; - $scope = $memberProps['scope']; - $scopeSpecified = $memberProps['scope_specified']; - - // If it's a private member, it must have an underscore on the front. - if ($isPublic === false && $memberName{0} !== '_') { - $error = 'Private member variable "%s" must be prefixed with an underscore'; - $data = array($memberName); - $phpcsFile->addError($error, $stackPtr, 'PrivateNoUnderscore', $data); - return; - } - - // If it's not a private member, it must not have an underscore on the front. - if ($isPublic === true && $scopeSpecified === true && $memberName{0} === '_') { - $error = '%s member variable "%s" must not be prefixed with an underscore'; - $data = array( - ucfirst($scope), - $memberName, - ); - $phpcsFile->addError($error, $stackPtr, 'PublicUnderscore', $data); - return; - } - - }//end processMemberVar() - - - /** - * Processes normal variables. - * - * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found. - * @param int $stackPtr The position where the token was found. - * - * @return void - */ - protected function processVariable(PHP_CodeSniffer_File $phpcsFile, $stackPtr) - { - // We don't care about normal variables. - return; - - }//end processVariable() - - - /** - * Processes variables in double quoted strings. - * - * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found. - * @param int $stackPtr The position where the token was found. - * - * @return void - */ - protected function processVariableInString(PHP_CodeSniffer_File $phpcsFile, $stackPtr) - { - // We don't care about normal variables. - return; - - }//end processVariableInString() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/WhiteSpace/ObjectOperatorIndentSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/WhiteSpace/ObjectOperatorIndentSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/WhiteSpace/ObjectOperatorIndentSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/WhiteSpace/ObjectOperatorIndentSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,167 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * PEAR_Sniffs_WhiteSpace_ObjectOperatorIndentSniff. - * - * Checks that object operators are indented 4 spaces if they are the first - * thing on a line. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PEAR_Sniffs_WhiteSpace_ObjectOperatorIndentSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array(T_OBJECT_OPERATOR); - - }//end register() - - - /** - * Processes this test, when one of its tokens is encountered. - * - * @param PHP_CodeSniffer_File $phpcsFile All the tokens found in the document. - * @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(); - - // Make sure this is the first object operator in a chain of them. - $varToken = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); - if ($varToken === false || $tokens[$varToken]['code'] !== T_VARIABLE) { - return; - } - - // Make sure this is a chained call. - $next = $phpcsFile->findNext( - T_OBJECT_OPERATOR, - ($stackPtr + 1), - null, - false, - null, - true - ); - - if ($next === false) { - // Not a chained call. - return; - } - - // Determine correct indent. - for ($i = ($varToken - 1); $i >= 0; $i--) { - if ($tokens[$i]['line'] !== $tokens[$varToken]['line']) { - $i++; - break; - } - } - - $requiredIndent = 0; - if ($i >= 0 && $tokens[$i]['code'] === T_WHITESPACE) { - $requiredIndent = strlen($tokens[$i]['content']); - } - - $requiredIndent += 4; - - // Determine the scope of the original object operator. - $origBrackets = null; - if (isset($tokens[$stackPtr]['nested_parenthesis']) === true) { - $origBrackets = $tokens[$stackPtr]['nested_parenthesis']; - } - - $origConditions = null; - if (isset($tokens[$stackPtr]['conditions']) === true) { - $origConditions = $tokens[$stackPtr]['conditions']; - } - - // Check indentation of each object operator in the chain. - // If the first object operator is on a different line than - // the variable, make sure we check its indentation too. - if ($tokens[$stackPtr]['line'] > $tokens[$varToken]['line']) { - $next = $stackPtr; - } - - while ($next !== false) { - // Make sure it is in the same scope, otherwise dont check indent. - $brackets = null; - if (isset($tokens[$next]['nested_parenthesis']) === true) { - $brackets = $tokens[$next]['nested_parenthesis']; - } - - $conditions = null; - if (isset($tokens[$next]['conditions']) === true) { - $conditions = $tokens[$next]['conditions']; - } - - if ($origBrackets === $brackets && $origConditions === $conditions) { - // Make sure it starts a line, otherwise dont check indent. - $indent = $tokens[($next - 1)]; - if ($indent['code'] === T_WHITESPACE) { - if ($indent['line'] === $tokens[$next]['line']) { - $foundIndent = strlen($indent['content']); - } else { - $foundIndent = 0; - } - - if ($foundIndent !== $requiredIndent) { - $error = 'Object operator not indented correctly; expected %s spaces but found %s'; - $data = array( - $requiredIndent, - $foundIndent, - ); - $phpcsFile->addError($error, $next, 'Incorrect', $data); - } - } - - // It cant be the last thing on the line either. - $content = $phpcsFile->findNext(T_WHITESPACE, ($next + 1), null, true); - if ($tokens[$content]['line'] !== $tokens[$next]['line']) { - $error = 'Object operator must be at the start of the line, not the end'; - $phpcsFile->addError($error, $next, 'StartOfLine'); - } - }//end if - - $next = $phpcsFile->findNext( - T_OBJECT_OPERATOR, - ($next + 1), - null, - false, - null, - true - ); - }//end while - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,150 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * PEAR_Sniffs_Whitespace_ScopeClosingBraceSniff. - * - * Checks that the closing braces of scopes are aligned correctly. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PEAR_Sniffs_WhiteSpace_ScopeClosingBraceSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * The number of spaces code should be indented. - * - * @var int - */ - public $indent = 4; - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return PHP_CodeSniffer_Tokens::$scopeOpeners; - - }//end register() - - - /** - * Processes this test, when one of its tokens is encountered. - * - * @param PHP_CodeSniffer_File $phpcsFile All the tokens found in the document. - * @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(); - - // If this is an inline condition (ie. there is no scope opener), then - // return, as this is not a new scope. - if (isset($tokens[$stackPtr]['scope_closer']) === false) { - return; - } - - $scopeStart = $tokens[$stackPtr]['scope_opener']; - $scopeEnd = $tokens[$stackPtr]['scope_closer']; - - // If the scope closer doesn't think it belongs to this scope opener - // then the opener is sharing its closer ith other tokens. We only - // want to process the closer once, so skip this one. - if ($tokens[$scopeEnd]['scope_condition'] !== $stackPtr) { - return; - } - - // We need to actually find the first piece of content on this line, - // because if this is a method with tokens before it (public, static etc) - // or an if with an else before it, then we need to start the scope - // checking from there, rather than the current token. - $lineStart = ($stackPtr - 1); - for ($lineStart; $lineStart > 0; $lineStart--) { - if (strpos($tokens[$lineStart]['content'], $phpcsFile->eolChar) !== false) { - break; - } - } - - // We found a new line, now go forward and find the first non-whitespace - // token. - $lineStart= $phpcsFile->findNext( - array(T_WHITESPACE), - ($lineStart + 1), - null, - true - ); - - $startColumn = $tokens[$lineStart]['column']; - - // Check that the closing brace is on it's own line. - $lastContent = $phpcsFile->findPrevious( - array(T_WHITESPACE), - ($scopeEnd - 1), - $scopeStart, - true - ); - - if ($tokens[$lastContent]['line'] === $tokens[$scopeEnd]['line']) { - $error = 'Closing brace must be on a line by itself'; - $phpcsFile->addError($error, $scopeEnd, 'Line'); - return; - } - - // Check now that the closing brace is lined up correctly. - $braceIndent = $tokens[$scopeEnd]['column']; - $isBreakCloser = ($tokens[$scopeEnd]['code'] === T_BREAK); - if (in_array($tokens[$stackPtr]['code'], array(T_CASE, T_DEFAULT)) === true - && $isBreakCloser === true - ) { - // BREAK statements should be indented n spaces from the - // CASE or DEFAULT statement. - if ($braceIndent !== ($startColumn + $this->indent)) { - $error = 'Break statement indented incorrectly; expected %s spaces, found %s'; - $data = array( - ($startColumn + $this->indent - 1), - ($braceIndent - 1), - ); - $phpcsFile->addError($error, $scopeEnd, 'BreakIdent', $data); - } - } else { - if ($braceIndent !== $startColumn) { - $error = 'Closing brace indented incorrectly; expected %s spaces, found %s'; - $data = array( - ($startColumn - 1), - ($braceIndent - 1), - ); - $phpcsFile->addError($error, $scopeEnd, 'Indent', $data); - } - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/WhiteSpace/ScopeIndentSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/WhiteSpace/ScopeIndentSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/WhiteSpace/ScopeIndentSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Sniffs/WhiteSpace/ScopeIndentSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -if (class_exists('Generic_Sniffs_WhiteSpace_ScopeIndentSniff', true) === false) { - $error = 'Class Generic_Sniffs_WhiteSpace_ScopeIndentSniff not found'; - throw new PHP_CodeSniffer_Exception($error); -} - -/** - * PEAR_Sniffs_Whitespace_ScopeIndentSniff. - * - * Checks that control structures are structured correctly, and their content - * is indented correctly. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PEAR_Sniffs_WhiteSpace_ScopeIndentSniff extends Generic_Sniffs_WhiteSpace_ScopeIndentSniff -{ - - /** - * Any scope openers that should not cause an indent. - * - * @var array(int) - */ - protected $nonIndentingScopes = array(T_SWITCH); - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Classes/ClassDeclarationUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Classes/ClassDeclarationUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Classes/ClassDeclarationUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Classes/ClassDeclarationUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,71 +0,0 @@ - \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Classes/ClassDeclarationUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Classes/ClassDeclarationUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Classes/ClassDeclarationUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Classes/ClassDeclarationUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,75 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the ClassDeclaration sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PEAR_Tests_Classes_ClassDeclarationUnitTest 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 array( - 21 => 1, - 22 => 1, - 23 => 1, - 27 => 1, - 33 => 1, - 38 => 1, - 49 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Commenting/ClassCommentUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Commenting/ClassCommentUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Commenting/ClassCommentUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Commenting/ClassCommentUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,111 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.0 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Extra_Description_Newlines -{ - -}//end class - - -/** - * Sample class comment - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Missing_Newlines_Before_Tags -{ - -}//end class - - -/** - * Simple class comment - * - * @category _wrong_category - * @package PHP_CodeSniffer - * @package ADDITIONAL PACKAGE TAG - * @subpackage SUBPACKAGE TAG - * @author Original Author - * @author Greg Sherwood gsherwood@squiz.net - * @author Mr T - * @author - * @copyright 1997~1994 The PHP Group - * @license http://www.php.net/license/3_0.txt - * @version INVALID VERSION CONTENT - * @see - * @see - * @link sdfsdf - * @see Net_Sample::Net_Sample() - * @see Net_Other - * @deprecated asd - * @unknown Unknown tag - * @since Class available since Release 1.2.0 - */ -class Checking_Tags -{ - class Sub_Class { - - }//end class - - -}//end class - - -/** - * - * - */ -class Empty_Class_Doc -{ - -}//end class - - -/** - * - * - */ -interface Empty_Interface_Doc -{ - -}//end interface -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Commenting/ClassCommentUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Commenting/ClassCommentUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Commenting/ClassCommentUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Commenting/ClassCommentUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,90 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for ClassCommentSniff. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PEAR_Tests_Commenting_ClassCommentUnitTest 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 array( - 4 => 1, - 15 => 1, - 22 => 1, - 25 => 1, - 28 => 1, - 46 => 1, - 51 => 1, - 63 => 1, - 65 => 2, - 66 => 1, - 68 => 2, - 70 => 1, - 71 => 1, - 72 => 1, - 74 => 2, - 75 => 1, - 77 => 1, - 78 => 1, - 79 => 1, - 85 => 1, - 93 => 1, - 103 => 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 array( - 71 => 1, - 73 => 1, - ); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Commenting/FileCommentUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Commenting/FileCommentUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Commenting/FileCommentUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Commenting/FileCommentUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ - -* @author Greg Sherwood gsherwood@squiz.net -* @author Mr T -* @author -* @copyright 1997~1994 The PHP Group -* @copyright 1997~1994 The PHP Group -* @license http://www.php.net/license/3_0.txt -* @see -* @see -* @version INVALID VERSION CONTENT -* @see Net_Sample::Net_Sample() -* @see Net_Other -* @deprecated asd -* @since Class available since Release 1.2.0 -* @summary An unknown summary tag -*/ -?> - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Commenting/FileCommentUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Commenting/FileCommentUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Commenting/FileCommentUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Commenting/FileCommentUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,97 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for FunctionCommentSniff. - * - * Verifies that : - *
    - *
  • A doc comment exists.
  • - *
  • Short description must start with a capital letter and end with a period.
  • - *
  • There must be one blank newline after the short description.
  • - *
  • A PHP version is specified.
  • - *
  • Check the order of the tags.
  • - *
  • Check the indentation of each tag.
  • - *
  • Check required and optional tags and the format of their content.
  • - *
- * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PEAR_Tests_Commenting_FileCommentUnitTest 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 array( - 6 => 1, - 8 => 1, - 21 => 2, - 23 => 2, - 24 => 1, - 26 => 2, - 28 => 1, - 29 => 1, - 30 => 1, - 31 => 1, - 32 => 2, - 33 => 1, - 35 => 1, - 36 => 1, - 37 => 1, - 40 => 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 array( - 29 => 1, - 30 => 1, - 34 => 1, - 40 => 1, - ); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Commenting/FunctionCommentUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Commenting/FunctionCommentUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Commenting/FunctionCommentUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Commenting/FunctionCommentUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,254 +0,0 @@ - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Commenting/FunctionCommentUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Commenting/FunctionCommentUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Commenting/FunctionCommentUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Commenting/FunctionCommentUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,91 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for FunctionCommentSniff. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PEAR_Tests_Commenting_FunctionCommentUnitTest 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 array( - 10 => 1, - 12 => 2, - 13 => 2, - 14 => 1, - 15 => 1, - 28 => 1, - 35 => 1, - 38 => 1, - 41 => 1, - 53 => 1, - 103 => 1, - 109 => 1, - 112 => 1, - 122 => 1, - 123 => 3, - 124 => 3, - 125 => 5, - 126 => 6, - 139 => 1, - 155 => 1, - 165 => 1, - 172 => 1, - 183 => 1, - 193 => 2, - 204 => 1, - 234 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Commenting/InlineCommentUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Commenting/InlineCommentUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Commenting/InlineCommentUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Commenting/InlineCommentUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ - \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Commenting/InlineCommentUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Commenting/InlineCommentUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Commenting/InlineCommentUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Commenting/InlineCommentUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,71 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the InlineComment sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PEAR_Tests_Commenting_InlineCommentUnitTest 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 array( - 15 => 1, - 24 => 1, - 25 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/ControlStructures/ControlSignatureUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/ControlStructures/ControlSignatureUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/ControlStructures/ControlSignatureUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/ControlStructures/ControlSignatureUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,159 +0,0 @@ - 0); - -do -{ - echo $i; -} while ($i > 0); - -do -{ - echo $i; -} -while ($i > 0); - -do { echo $i; } while ($i > 0); - -do{ - echo $i; -}while($i > 0); - - -// while -while ($i < 1) { - echo $i; -} - -while($i < 1){ - echo $i; -} - -while ($i < 1) { echo $i; } - - -// for -for ($i = 1; $i < 1; $i++) { - echo $i; -} - -for($i = 1; $i < 1; $i++){ - echo $i; -} - -for ($i = 1; $i < 1; $i++) { echo $i; } - - -// foreach -foreach ($items as $item) { - echo $item; -} - -foreach($items as $item){ - echo $item; -} - -for ($items as $item) { echo $item; } - - -// if -if ($i == 0) { - $i = 1; -} - -if($i == 0){ - $i = 1; -} - -if ($i == 0) { $i = 1; } - - -// else -if ($i == 0) { - $i = 1; -} else { - $i = 0; -} - -if ($i == 0) { - $i = 1; -}else{ - $i = 0; -} - -if ($i == 0) { $i = 1; } else { $i = 0; } - - -// else -if ($i == 0) { - $i = 1; -} else { - $i = 0; -} - -if ($i == 0) { - $i = 1; -}else{ - $i = 0; -} - -if ($i == 0) { $i = 1; } else { $i = 0; } - - -// else if -if ($i == 0) { - $i = 1; -} else if ($i == 2) { - $i = 0; -} - -if ($i == 0) { - $i = 1; -} elseif ($i == 2) { - $i = 0; -} - -if ($i == 0) { - $i = 1; -}else if($i == 2){ - $i = 0; -} - -if ($i == 0) { - $i = 1; -}elseif($i == 2){ - $i = 0; -} - -if ($i == 0) { $i = 1; } else if ($i == 2) { $i = 0; } -if ($i == 0) { $i = 1; } elseif ($1 == 2) { $i = 0; } - -if ($i == 0) { // this is ok because comments are allowed - $i = 1; -} - -if ($i == 0) {// this is ok because comments are allowed - $i = 1; -} - -if ($i == 0) { /* this is ok because comments are allowed*/ - $i = 1; -} - -if ($i == 0) -{ // this is not ok - $i = 1; -} - -if ($i == 0) /* this is ok */ { -} - -if ($i == 0) { -} -else { -} -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/ControlStructures/ControlSignatureUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/ControlStructures/ControlSignatureUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/ControlStructures/ControlSignatureUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/ControlStructures/ControlSignatureUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,90 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the ControlSignature sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PEAR_Tests_ControlStructures_ControlSignatureUnitTest 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 array( - 9 => 1, - 14 => 1, - 20 => 1, - 22 => 1, - 32 => 1, - 36 => 1, - 44 => 1, - 48 => 1, - 56 => 1, - 60 => 1, - 68 => 1, - 72 => 1, - 84 => 1, - 88 => 2, - 100 => 1, - 104 => 2, - 122 => 2, - 128 => 1, - 132 => 3, - 133 => 2, - 147 => 1, - 157 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/ControlStructures/MultiLineConditionUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/ControlStructures/MultiLineConditionUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/ControlStructures/MultiLineConditionUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/ControlStructures/MultiLineConditionUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,139 +0,0 @@ - -

some text

- \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/ControlStructures/MultiLineConditionUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/ControlStructures/MultiLineConditionUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/ControlStructures/MultiLineConditionUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/ControlStructures/MultiLineConditionUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,85 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the MultiLineCondition sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PEAR_Tests_ControlStructures_MultiLineConditionUnitTest 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 array( - 22 => 1, - 35 => 1, - 40 => 1, - 41 => 1, - 42 => 1, - 43 => 1, - 49 => 1, - 54 => 1, - 58 => 1, - 59 => 1, - 61 => 1, - 88 => 1, - 89 => 1, - 90 => 1, - 96 => 2, - 109 => 2, - 125 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Files/IncludingFileUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Files/IncludingFileUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Files/IncludingFileUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Files/IncludingFileUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,98 +0,0 @@ - -
-Some content goes here.
-
-
- -
-    Some content goes here.
-    
-    
- diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Files/IncludingFileUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Files/IncludingFileUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Files/IncludingFileUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Files/IncludingFileUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,84 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the IncludingFile sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PEAR_Tests_Files_IncludingFileUnitTest 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 array( - 4 => 1, - 5 => 1, - 11 => 1, - 12 => 1, - 16 => 1, - 17 => 1, - 33 => 1, - 34 => 1, - 47 => 1, - 48 => 1, - 64 => 1, - 65 => 1, - 73 => 1, - 74 => 1, - 85 => 1, - 86 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Formatting/MultiLineAssignmentUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Formatting/MultiLineAssignmentUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Formatting/MultiLineAssignmentUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Formatting/MultiLineAssignmentUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -additionalHeaderData[$this->strApplicationName] - = $this->xajax->getJavascript(t3lib_extMgm::siteRelPath('nr_xajax')); - -$GLOBALS['TSFE']->additionalHeaderData[$this->strApplicationName] - = $this->xajax->getJavascript(t3lib_extMgm::siteRelPath('nr_xajax')); - -$GLOBALS['TSFE']->additionalHeaderData[$this->strApplicationName] = - $this->xajax->getJavascript(t3lib_extMgm::siteRelPath('nr_xajax')); - -$GLOBALS['TSFE']->additionalHeaderData[$this->strApplicationName] - = $this->xajax->getJavascript(t3lib_extMgm::siteRelPath('nr_xajax')); -$GLOBALS['TSFE']->additionalHeaderData[$this->strApplicationName] = 'boo' - -$var='string'; - -function getInstalledStandards( - $includeGeneric=false, - $standardsDir='' -) { -} -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Formatting/MultiLineAssignmentUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Formatting/MultiLineAssignmentUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Formatting/MultiLineAssignmentUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Formatting/MultiLineAssignmentUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,69 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the MultiLineAssignment sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PEAR_Tests_Formatting_MultiLineAssignmentUnitTest 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 array( - 3 => 1, - 6 => 1, - 8 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,107 +0,0 @@ - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,87 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the FunctionCallSignature sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PEAR_Tests_Functions_FunctionCallSignatureUnitTest 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 array( - 5 => 1, - 6 => 1, - 7 => 1, - 8 => 1, - 9 => 2, - 10 => 3, - 17 => 1, - 18 => 1, - 31 => 1, - 34 => 1, - 43 => 1, - 57 => 1, - 59 => 1, - 63 => 1, - 64 => 1, - 82 => 1, - 93 => 1, - 100 => 1, - 106 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,74 +0,0 @@ - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,79 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the FunctionDeclaration sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PEAR_Tests_Functions_FunctionDeclarationUnitTest 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 array( - 3 => 1, - 4 => 1, - 5 => 1, - 9 => 1, - 10 => 1, - 11 => 1, - 14 => 1, - 27 => 1, - 44 => 2, - 51 => 1, - 61 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Functions/ValidDefaultValueUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Functions/ValidDefaultValueUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Functions/ValidDefaultValueUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Functions/ValidDefaultValueUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,86 +0,0 @@ - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Functions/ValidDefaultValueUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Functions/ValidDefaultValueUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Functions/ValidDefaultValueUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/Functions/ValidDefaultValueUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,74 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the ValidDefaultValue sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PEAR_Tests_Functions_ValidDefaultValueUnitTest 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 array( - 29 => 1, - 34 => 1, - 39 => 1, - 71 => 1, - 76 => 1, - 81 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/NamingConventions/ValidClassNameUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/NamingConventions/ValidClassNameUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/NamingConventions/ValidClassNameUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/NamingConventions/ValidClassNameUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/NamingConventions/ValidClassNameUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/NamingConventions/ValidClassNameUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/NamingConventions/ValidClassNameUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/NamingConventions/ValidClassNameUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,80 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the ValidClassName sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PEAR_Tests_NamingConventions_ValidClassNameUnitTest 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 array( - 5 => 1, - 7 => 2, - 9 => 1, - 19 => 1, - 24 => 1, - 26 => 2, - 28 => 1, - 38 => 1, - 40 => 2, - 42 => 2, - 44 => 1, - 46 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/NamingConventions/ValidFunctionNameUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/NamingConventions/ValidFunctionNameUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/NamingConventions/ValidFunctionNameUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/NamingConventions/ValidFunctionNameUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,193 +0,0 @@ - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/NamingConventions/ValidFunctionNameUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/NamingConventions/ValidFunctionNameUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/NamingConventions/ValidFunctionNameUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/NamingConventions/ValidFunctionNameUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,176 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the ValidFunctionName sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PEAR_Tests_NamingConventions_ValidFunctionNameUnitTest 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 array( - 11 => 1, - 12 => 1, - 13 => 1, - 14 => 1, - 15 => 1, - 16 => 1, - 17 => 1, - 18 => 1, - 19 => 1, - 20 => 1, - 24 => 1, - 25 => 1, - 26 => 1, - 27 => 1, - 28 => 1, - 29 => 1, - 30 => 1, - 31 => 1, - 32 => 1, - 33 => 1, - 35 => 1, - 36 => 1, - 37 => 1, - 38 => 1, - 39 => 1, - 40 => 1, - 43 => 1, - 44 => 1, - 45 => 1, - 46 => 1, - 50 => 1, - 51 => 1, - 52 => 1, - 53 => 1, - 56 => 1, - 57 => 1, - 58 => 1, - 59 => 1, - 67 => 1, - 68 => 1, - 69 => 1, - 70 => 1, - 71 => 1, - 72 => 1, - 73 => 1, - 74 => 1, - 75 => 1, - 76 => 1, - 80 => 1, - 81 => 1, - 82 => 1, - 83 => 1, - 84 => 1, - 85 => 1, - 86 => 1, - 87 => 1, - 88 => 1, - 89 => 1, - 91 => 1, - 92 => 1, - 93 => 1, - 94 => 1, - 95 => 1, - 96 => 1, - 99 => 1, - 100 => 1, - 101 => 1, - 102 => 1, - 106 => 1, - 107 => 1, - 108 => 1, - 109 => 1, - 112 => 1, - 113 => 1, - 114 => 1, - 115 => 1, - 121 => 1, - 122 => 1, - 123 => 1, - 124 => 1, - 125 => 1, - 126 => 1, - 127 => 1, - 128 => 1, - 129 => 1, - 130 => 1, - 149 => 1, - 151 => 1, - 152 => 1, - 155 => 1, - 156 => 1, - 157 => 1, - 158 => 1, - 159 => 1, - 160 => 1, - 161 => 1, - 162 => 1, - 163 => 1, - 164 => 1, - 165 => 1, - 166 => 1, - 167 => 1, - 169 => 1, - 170 => 1, - 171 => 1, - 173 => 1, - 174 => 1, - 175 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/NamingConventions/ValidVariableNameUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/NamingConventions/ValidVariableNameUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/NamingConventions/ValidVariableNameUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/NamingConventions/ValidVariableNameUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,88 +0,0 @@ -def["POP_{$cc}_A"]}' - and POP_{$cc}_B = -'{$this->def["POP_{$cc}_B"]}')"; - } -} - -class mpgResponse{ - var $term_id; - var $currentTag; - function characterHandler($parser,$data){ - switch($this->currentTag) - { - case "term_id": { - $this->term_id=$data; - break; - } - } - }//end characterHandler -}//end class mpgResponse - -class foo -{ - const bar = << diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/NamingConventions/ValidVariableNameUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/NamingConventions/ValidVariableNameUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/NamingConventions/ValidVariableNameUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/NamingConventions/ValidVariableNameUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,69 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the ValidVariableName sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PEAR_Tests_NamingConventions_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 array( - 12 => 1, - 17 => 1, - 22 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/WhiteSpace/ObjectOperatorIndentUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/WhiteSpace/ObjectOperatorIndentUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/WhiteSpace/ObjectOperatorIndentUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/WhiteSpace/ObjectOperatorIndentUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -someFunction("some", "parameter") -->someOtherFunc(23, 42)-> - someOtherFunc2($one, $two) - - ->someOtherFunc3(23, 42) - ->andAThirdFunction(); - - $someObject->someFunction("some", "parameter") - ->someOtherFunc(23, 42); - -$someObject->someFunction("some", "parameter")->someOtherFunc(23, 42); - -$someObject->someFunction("some", "parameter") - ->someOtherFunc(23, 42); - -func( - $bar->foo() -) - ->bar(); - -func( - $bar->foo() -) - ->bar( - $bar->foo() - ->bar() - ->func() - ); - -$object - ->setBar($foo) - ->setFoo($bar); - -if ($bar) { - $object - ->setBar($foo) - ->setFoo($bar); -} -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/WhiteSpace/ObjectOperatorIndentUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/WhiteSpace/ObjectOperatorIndentUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/WhiteSpace/ObjectOperatorIndentUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/WhiteSpace/ObjectOperatorIndentUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,72 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the ObjectOperatorIndent sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PEAR_Tests_WhiteSpace_ObjectOperatorIndentUnitTest 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 array( - 3 => 2, - 6 => 1, - 15 => 1, - 27 => 1, - 37 => 1, - 38 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/WhiteSpace/ScopeClosingBraceUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/WhiteSpace/ScopeClosingBraceUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/WhiteSpace/ScopeClosingBraceUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/WhiteSpace/ScopeClosingBraceUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,97 +0,0 @@ -{$property} =& new $class_name($this->db_index); - $this->modules[$module] =& $this->{$property}; -} - -foreach ($elements as $element) { - if ($something) { - // Do IF. - } else if ($somethingElse) { - // Do ELSE. - } -} - -switch ($foo) { -case 1: - switch ($bar) { - default: - if ($something) { - echo $string{1}; - } else if ($else) { - switch ($else) { - case 1: - // Do something. - break; - default: - // Do something. - break; - } - } - } -break; -case 2: - // Do something; - break; -} - -switch ($httpResponseCode) { - case 100: - return 'Continue.'; - case 101: - return 'Switching protocols.'; - case 102: - return 'Processing.'; - default: - return 'Unknown'; -} - -switch ($httpResponseCode) { - case 100: - return 'Continue.'; - case 101: - return 'Switching protocols.'; - case 102: - return 'Processing.'; - default: - return 'Unknown'; - break; -} - -switch($i) { -case 1: {} -} -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/WhiteSpace/ScopeClosingBraceUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/WhiteSpace/ScopeClosingBraceUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/WhiteSpace/ScopeClosingBraceUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/WhiteSpace/ScopeClosingBraceUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,75 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the ScopeClosingBrace sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PEAR_Tests_WhiteSpace_ScopeClosingBraceUnitTest 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 array( - 11 => 1, - 13 => 1, - 24 => 1, - 61 => 1, - 65 => 1, - 91 => 1, - 95 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/WhiteSpace/ScopeIndentUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/WhiteSpace/ScopeIndentUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/WhiteSpace/ScopeIndentUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/WhiteSpace/ScopeIndentUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,315 +0,0 @@ -hello(); // error here - } - - function hello() // error here - { // no error here as brackets can be put anywhere in the pear standard - echo 'hello'; - } - - function hello2() - { - if (TRUE) { // error here - echo 'hello'; // no error here as its more than 4 spaces. - } else { - echo 'bye'; // error here - } - - while (TRUE) { - echo 'hello'; // error here - }// no error here as its handled by another test. - - do { // error here - echo 'hello'; // error here - } while (TRUE); // no error here as its aligned with the do. - }// no error here as its handled by another test. - - function hello3() - { - switch ($hello) { - case 'hello': // no error here as switch statements shouldn't be indented ??? - break; - } - } - -} - -?> -
-
-
-validate()) {
-    $safe = $form->getSubmitValues();
-}
-?>
-
-open(); // error here - } - - public function open() - { - // Some inline stuff that shouldn't error - if (TRUE) echo 'hello'; - foreach ($tokens as $token) echo $token; - } - - /** - * This is a comment 1. - * This is a comment 2. - * This is a comment 3. - * This is a comment 4. - */ - public function close() - { - // All ok. - if (TRUE) { - if (TRUE) { - } else if (FALSE) { - foreach ($tokens as $token) { - switch ($token) { - case '1': - case '2': - if (true) { - if (false) { - if (false) { - if (false) { - echo 'hello'; - } - } - } - } - break; - case '5': - break; - } - do { - while (true) { - foreach ($tokens as $token) { - for ($i = 0; $i < $token; $i++) { - echo 'hello'; - } - } - } - } while (true); - } - } - } - } - - /* - This is another c style comment 1. - This is another c style comment 2. - This is another c style comment 3. - This is another c style comment 4. - This is another c style comment 5. - */ - - /* - * - * - * - */ - - /** - */ - - /* - This comment has a newline in it. - - */ - - public function read() - { - echo 'hello'; - - // no errors below. - $array = array( - 'this', - 'that' => array( - 'hello', - 'hello again' => array( - 'hello', - ), - ), - ); - } -} - -abstract class Test3 -{ - public function parse() - { - - foreach ($t as $ndx => $token) { - if (is_array($token)) { - echo 'here'; - } else { - $ts[] = array("token" => $token, "value" => ''); - - $last = count($ts) - 1; - - switch ($token) { - case '(': - - if ($last >= 3 && - $ts[0]['token'] != T_CLASS && - $ts[$last - 2]['token'] == T_OBJECT_OPERATOR && - $ts[$last - 3]['token'] == T_VARIABLE ) { - - - if (true) { - echo 'hello'; - } - } - array_push($braces, $token); - break; - } - } - } - } -} - -public function test() -{ - $o = << diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/WhiteSpace/ScopeIndentUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/WhiteSpace/ScopeIndentUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/WhiteSpace/ScopeIndentUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/Tests/WhiteSpace/ScopeIndentUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,83 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the ScopeIndent sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PEAR_Tests_WhiteSpace_ScopeIndentUnitTest 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 array( - 7 => 1, - 10 => 1, - 17 => 1, - 20 => 1, - 24 => 1, - 27 => 1, - 28 => 1, - 58 => 1, - 123 => 1, - 126 => 1, - 224 => 1, - 225 => 1, - 279 => 1, - 284 => 1, - 311 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/ruleset.xml php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/ruleset.xml --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/ruleset.xml 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PEAR/ruleset.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ - - - The PEAR coding standard. - - - - - - - - - - - - - - - - - - - - - - - - - - 0 - - - - - - - - - - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PHPCS/ruleset.xml php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PHPCS/ruleset.xml --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PHPCS/ruleset.xml 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/PHPCS/ruleset.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ - - - The coding standard for PHP_CodeSniffer itself. - */Tests/* - - - - - - - - - - - - - - - - - - - - 0 - - - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Docs/Arrays/ArrayDeclarationStandard.xml php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Docs/Arrays/ArrayDeclarationStandard.xml --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Docs/Arrays/ArrayDeclarationStandard.xml 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Docs/Arrays/ArrayDeclarationStandard.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,117 +0,0 @@ - - - - - - array keyword must be lowercase. - ]]> - - - - array('val1', 'val2'); - ]]> - - - Array('val1', 'val2'); - ]]> - - - - array keyword. - ]]> - - - - 'key1' => 'value1', - 'key2' => 'value2', - ); - ]]> - - - 'key1' => 'value1', - 'key2' => 'value2', - ); - ]]> - - - - array keyword. The closing parenthesis must be aligned with the start of the array keyword. - ]]> - - - - 'key1' => 'value1', - 'key2' => 'value2', - ); - ]]> - - - 'key1' => 'value1', - 'key2' => 'value2', -); - ]]> - - - - - - - - => 'ValueTen', - 'keyTwenty' => 'ValueTwenty', - ); - ]]> - - - => 'ValueTen', - 'keyTwenty' => 'ValueTwenty', - ); - ]]> - - - - - - - - 'value1', - 'key2' => 'value2', - 'key3' => 'value3', - ); - ]]> - - - 'value1', - 'key2' => 'value2', - 'key3' => 'value3' - ); - ]]> - - - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Arrays/ArrayBracketSpacingSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Arrays/ArrayBracketSpacingSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Arrays/ArrayBracketSpacingSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Arrays/ArrayBracketSpacingSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,97 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_Arrays_ArrayBracketSpacingSniff. - * - * Ensure that there are no spaces around square brackets. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_Arrays_ArrayBracketSpacingSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array( - T_OPEN_SQUARE_BRACKET, - T_CLOSE_SQUARE_BRACKET, - ); - - }//end register() - - - /** - * Processes this sniff, when one of its tokens is encountered. - * - * @param PHP_CodeSniffer_File $phpcsFile The current file being checked. - * @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(); - - // No bracket can have space before them. - $prevType = $tokens[($stackPtr - 1)]['code']; - if (in_array($prevType, PHP_CodeSniffer_Tokens::$emptyTokens) === true) { - $nonSpace = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 2), null, true); - $expected = $tokens[$nonSpace]['content'].$tokens[$stackPtr]['content']; - $found = $phpcsFile->getTokensAsString($nonSpace, ($stackPtr - $nonSpace)).$tokens[$stackPtr]['content']; - $error = 'Space found before square bracket; expected "%s" but found "%s"'; - $data = array( - $expected, - $found, - ); - $phpcsFile->addError($error, $stackPtr, 'SpaceBeforeBracket', $data); - } - - if ($tokens[$stackPtr]['type'] === 'T_OPEN_SQUARE_BRACKET') { - // Open brackets can't have spaces on after them either. - $nextType = $tokens[($stackPtr + 1)]['code']; - if (in_array($nextType, PHP_CodeSniffer_Tokens::$emptyTokens) === true) { - $nonSpace = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr + 2), null, true); - $expected = $tokens[$stackPtr]['content'].$tokens[$nonSpace]['content']; - $found = $phpcsFile->getTokensAsString($stackPtr, ($nonSpace - $stackPtr + 1)); - $error = 'Space found after square bracket; expected "%s" but found "%s"'; - $data = array( - $expected, - $found, - ); - $phpcsFile->addError($error, $stackPtr, 'SpaceAfterBracket', $data); - } - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,513 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * A test to ensure that arrays conform to the array coding standard. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_Arrays_ArrayDeclarationSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array(T_ARRAY); - - }//end register() - - - /** - * Processes this sniff, when one of its tokens is encountered. - * - * @param PHP_CodeSniffer_File $phpcsFile The current file being checked. - * @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(); - - // Array keyword should be lower case. - if (strtolower($tokens[$stackPtr]['content']) !== $tokens[$stackPtr]['content']) { - $error = 'Array keyword should be lower case; expected "array" but found "%s"'; - $data = array($tokens[$stackPtr]['content']); - $phpcsFile->addError($error, $stackPtr, 'NotLowerCase', $data); - } - - $arrayStart = $tokens[$stackPtr]['parenthesis_opener']; - $arrayEnd = $tokens[$arrayStart]['parenthesis_closer']; - $keywordStart = $tokens[$stackPtr]['column']; - - if ($arrayStart != ($stackPtr + 1)) { - $error = 'There must be no space between the Array keyword and the opening parenthesis'; - $phpcsFile->addError($error, $stackPtr, 'SpaceAfterKeyword'); - } - - // Check for empty arrays. - $content = $phpcsFile->findNext(array(T_WHITESPACE), ($arrayStart + 1), ($arrayEnd + 1), true); - if ($content === $arrayEnd) { - // Empty array, but if the brackets aren't together, there's a problem. - if (($arrayEnd - $arrayStart) !== 1) { - $error = 'Empty array declaration must have no space between the parentheses'; - $phpcsFile->addError($error, $stackPtr, 'SpaceInEmptyArray'); - - // We can return here because there is nothing else to check. All code - // below can assume that the array is not empty. - return; - } - } - - if ($tokens[$arrayStart]['line'] === $tokens[$arrayEnd]['line']) { - // Single line array. - // Check if there are multiple values. If so, then it has to be multiple lines - // unless it is contained inside a function call or condition. - $valueCount = 0; - $commas = array(); - for ($i = ($arrayStart + 1); $i < $arrayEnd; $i++) { - // Skip bracketed statements, like function calls. - if ($tokens[$i]['code'] === T_OPEN_PARENTHESIS) { - $i = $tokens[$i]['parenthesis_closer']; - continue; - } - - if ($tokens[$i]['code'] === T_COMMA) { - $valueCount++; - $commas[] = $i; - } - } - - // Now check each of the double arrows (if any). - $nextArrow = $arrayStart; - while (($nextArrow = $phpcsFile->findNext(T_DOUBLE_ARROW, ($nextArrow + 1), $arrayEnd)) !== false) { - if ($tokens[($nextArrow - 1)]['code'] !== T_WHITESPACE) { - $content = $tokens[($nextArrow - 1)]['content']; - $error = 'Expected 1 space between "%s" and double arrow; 0 found'; - $data = array($content); - $phpcsFile->addError($error, $nextArrow, 'NoSpaceBeforeDoubleArrow', $data); - } else { - $spaceLength = strlen($tokens[($nextArrow - 1)]['content']); - if ($spaceLength !== 1) { - $content = $tokens[($nextArrow - 2)]['content']; - $error = 'Expected 1 space between "%s" and double arrow; %s found'; - $data = array( - $content, - $spaceLength, - ); - $phpcsFile->addError($error, $nextArrow, 'SpaceBeforeDoubleArrow', $data); - } - } - - if ($tokens[($nextArrow + 1)]['code'] !== T_WHITESPACE) { - $content = $tokens[($nextArrow + 1)]['content']; - $error = 'Expected 1 space between double arrow and "%s"; 0 found'; - $data = array($content); - $phpcsFile->addError($error, $nextArrow, 'NoSpaceAfterDoubleArrow', $data); - } else { - $spaceLength = strlen($tokens[($nextArrow + 1)]['content']); - if ($spaceLength !== 1) { - $content = $tokens[($nextArrow + 2)]['content']; - $error = 'Expected 1 space between double arrow and "%s"; %s found'; - $data = array( - $content, - $spaceLength, - ); - $phpcsFile->addError($error, $nextArrow, 'SpaceAfterDoubleArrow', $data); - } - } - }//end while - - if ($valueCount > 0) { - $conditionCheck = $phpcsFile->findPrevious(array(T_OPEN_PARENTHESIS, T_SEMICOLON), ($stackPtr - 1), null, false); - - if (($conditionCheck === false) || ($tokens[$conditionCheck]['line'] !== $tokens[$stackPtr]['line'])) { - $error = 'Array with multiple values cannot be declared on a single line'; - $phpcsFile->addError($error, $stackPtr, 'SingleLineNotAllowed'); - return; - } - - // We have a multiple value array that is inside a condition or - // function. Check its spacing is correct. - foreach ($commas as $comma) { - if ($tokens[($comma + 1)]['code'] !== T_WHITESPACE) { - $content = $tokens[($comma + 1)]['content']; - $error = 'Expected 1 space between comma and "%s"; 0 found'; - $data = array($content); - $phpcsFile->addError($error, $comma, 'NoSpaceAfterComma', $data); - } else { - $spaceLength = strlen($tokens[($comma + 1)]['content']); - if ($spaceLength !== 1) { - $content = $tokens[($comma + 2)]['content']; - $error = 'Expected 1 space between comma and "%s"; %s found'; - $data = array( - $content, - $spaceLength, - ); - $phpcsFile->addError($error, $comma, 'SpaceAfterComma', $data); - } - } - - if ($tokens[($comma - 1)]['code'] === T_WHITESPACE) { - $content = $tokens[($comma - 2)]['content']; - $spaceLength = strlen($tokens[($comma - 1)]['content']); - $error = 'Expected 0 spaces between "%s" and comma; %s found'; - $data = array( - $content, - $spaceLength, - ); - $phpcsFile->addError($error, $comma, 'SpaceBeforeComma', $data); - } - }//end foreach - }//end if - - return; - }//end if - - // Check the closing bracket is on a new line. - $lastContent = $phpcsFile->findPrevious(T_WHITESPACE, ($arrayEnd - 1), $arrayStart, true); - if ($tokens[$lastContent]['line'] !== ($tokens[$arrayEnd]['line'] - 1)) { - $error = 'Closing parenthesis of array declaration must be on a new line'; - $phpcsFile->addError($error, $arrayEnd, 'CloseBraceNewLine'); - } else if ($tokens[$arrayEnd]['column'] !== $keywordStart) { - // Check the closing bracket is lined up under the a in array. - $expected = $keywordStart; - $found = $tokens[$arrayEnd]['column']; - $error = 'Closing parenthesis not aligned correctly; expected %s space(s) but found %s'; - $data = array( - $expected, - $found, - ); - $phpcsFile->addError($error, $arrayEnd, 'CloseBraceNotAligned', $data); - } - - $nextToken = $stackPtr; - $lastComma = $stackPtr; - $keyUsed = false; - $singleUsed = false; - $lastToken = ''; - $indices = array(); - $maxLength = 0; - - // Find all the double arrows that reside in this scope. - while (($nextToken = $phpcsFile->findNext(array(T_DOUBLE_ARROW, T_COMMA, T_ARRAY), ($nextToken + 1), $arrayEnd)) !== false) { - $currentEntry = array(); - - if ($tokens[$nextToken]['code'] === T_ARRAY) { - // Let subsequent calls of this test handle nested arrays. - $indices[] = array( - 'value' => $nextToken, - ); - $nextToken = $tokens[$tokens[$nextToken]['parenthesis_opener']]['parenthesis_closer']; - continue; - } - - if ($tokens[$nextToken]['code'] === T_COMMA) { - $stackPtrCount = 0; - if (isset($tokens[$stackPtr]['nested_parenthesis']) === true) { - $stackPtrCount = count($tokens[$stackPtr]['nested_parenthesis']); - } - - if (count($tokens[$nextToken]['nested_parenthesis']) > ($stackPtrCount + 1)) { - // This comma is inside more parenthesis than the ARRAY keyword, - // then there it is actually a comma used to seperate arguments - // in a function call. - continue; - } - - if ($keyUsed === true && $lastToken === T_COMMA) { - $error = 'No key specified for array entry; first entry specifies key'; - $phpcsFile->addError($error, $nextToken, 'NoKeySpecified'); - return; - } - - if ($keyUsed === false) { - if ($tokens[($nextToken - 1)]['code'] === T_WHITESPACE) { - $content = $tokens[($nextToken - 2)]['content']; - $spaceLength = strlen($tokens[($nextToken - 1)]['content']); - $error = 'Expected 0 spaces between "%s" and comma; %s found'; - $data = array( - $content, - $spaceLength, - ); - $phpcsFile->addError($error, $nextToken, 'SpaceBeforeComma', $data); - } - - // Find the value, which will be the first token on the line, - // excluding the leading whitespace. - $valueContent = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($nextToken - 1), null, true); - while ($tokens[$valueContent]['line'] === $tokens[$nextToken]['line']) { - if ($valueContent === $arrayStart) { - // Value must have been on the same line as the array - // parenthesis, so we have reached the start of the value. - break; - } - - $valueContent--; - } - - $valueContent = $phpcsFile->findNext(T_WHITESPACE, ($valueContent + 1), $nextToken, true); - $indices[] = array('value' => $valueContent); - $singleUsed = true; - }//end if - - $lastToken = T_COMMA; - continue; - }//end if - - if ($tokens[$nextToken]['code'] === T_DOUBLE_ARROW) { - if ($singleUsed === true) { - $error = 'Key specified for array entry; first entry has no key'; - $phpcsFile->addError($error, $nextToken, 'KeySpecified'); - return; - } - - $currentEntry['arrow'] = $nextToken; - $keyUsed = true; - - // Find the start of index that uses this double arrow. - $indexEnd = $phpcsFile->findPrevious(T_WHITESPACE, ($nextToken - 1), $arrayStart, true); - $indexStart = $phpcsFile->findPrevious(T_WHITESPACE, $indexEnd, $arrayStart); - - if ($indexStart === false) { - $index = $indexEnd; - } else { - $index = ($indexStart + 1); - } - - $currentEntry['index'] = $index; - $currentEntry['index_content'] = $phpcsFile->getTokensAsString($index, ($indexEnd - $index + 1)); - - $indexLength = strlen($currentEntry['index_content']); - if ($maxLength < $indexLength) { - $maxLength = $indexLength; - } - - // Find the value of this index. - $nextContent = $phpcsFile->findNext(array(T_WHITESPACE), ($nextToken + 1), $arrayEnd, true); - $currentEntry['value'] = $nextContent; - $indices[] = $currentEntry; - $lastToken = T_DOUBLE_ARROW; - }//end if - }//end while - - // Check for mutli-line arrays that should be single-line. - $singleValue = false; - - if (empty($indices) === true) { - $singleValue = true; - } else if (count($indices) === 1) { - if ($lastToken === T_COMMA) { - // There may be another array value without a comma. - $exclude = PHP_CodeSniffer_Tokens::$emptyTokens; - $exclude[] = T_COMMA; - $nextContent = $phpcsFile->findNext($exclude, ($indices[0]['value'] + 1), $arrayEnd, true); - if ($nextContent === false) { - $singleValue = true; - } - } - - if ($singleValue === false && isset($indices[0]['arrow']) === false) { - // A single nested array as a value is fine. - if ($tokens[$indices[0]['value']]['code'] !== T_ARRAY) { - $singleValue === true; - } - } - } - - if ($singleValue === true) { - // Array cannot be empty, so this is a multi-line array with - // a single value. It should be defined on single line. - $error = 'Multi-line array contains a single value; use single-line array instead'; - $phpcsFile->addError($error, $stackPtr, 'MulitLineNotAllowed'); - return; - } - - /* - This section checks for arrays that don't specify keys. - - Arrays such as: - array( - 'aaa', - 'bbb', - 'd', - ); - */ - - if ($keyUsed === false && empty($indices) === false) { - $count = count($indices); - $lastIndex = $indices[($count - 1)]['value']; - - $trailingContent = $phpcsFile->findPrevious(T_WHITESPACE, ($arrayEnd - 1), $lastIndex, true); - if ($tokens[$trailingContent]['code'] !== T_COMMA) { - $error = 'Comma required after last value in array declaration'; - $phpcsFile->addError($error, $trailingContent, 'NoCommaAfterLast'); - } - - foreach ($indices as $value) { - if (empty($value['value']) === true) { - // Array was malformed and we couldn't figure out - // the array value correctly, so we have to ignore it. - // Other parts of this sniff will correct the error. - continue; - } - - if ($tokens[($value['value'] - 1)]['code'] === T_WHITESPACE) { - // A whitespace token before this value means that the value - // was indented and not flush with the opening parenthesis. - if ($tokens[$value['value']]['column'] !== ($keywordStart + 1)) { - $error = 'Array value not aligned correctly; expected %s spaces but found %s'; - $data = array( - ($keywordStart + 1), - $tokens[$value['value']]['column'], - ); - $phpcsFile->addError($error, $value['value'], 'ValueNotAligned', $data); - } - } - } - }//end if - - /* - Below the actual indentation of the array is checked. - Errors will be thrown when a key is not aligned, when - a double arrow is not aligned, and when a value is not - aligned correctly. - If an error is found in one of the above areas, then errors - are not reported for the rest of the line to avoid reporting - spaces and columns incorrectly. Often fixing the first - problem will fix the other 2 anyway. - - For example: - - $a = array( - 'index' => '2', - ); - - In this array, the double arrow is indented too far, but this - will also cause an error in the value's alignment. If the arrow were - to be moved back one space however, then both errors would be fixed. - */ - - $numValues = count($indices); - - $indicesStart = ($keywordStart + 1); - $arrowStart = ($indicesStart + $maxLength + 1); - $valueStart = ($arrowStart + 3); - foreach ($indices as $index) { - if (isset($index['index']) === false) { - // Array value only. - if (($tokens[$index['value']]['line'] === $tokens[$stackPtr]['line']) && ($numValues > 1)) { - $error = 'The first value in a multi-value array must be on a new line'; - $phpcsFile->addError($error, $stackPtr, 'FirstValueNoNewline'); - } - - continue; - } - - if (($tokens[$index['index']]['line'] === $tokens[$stackPtr]['line'])) { - $error = 'The first index in a multi-value array must be on a new line'; - $phpcsFile->addError($error, $stackPtr, 'FirstIndexNoNewline'); - continue; - } - - if ($tokens[$index['index']]['column'] !== $indicesStart) { - $error = 'Array key not aligned correctly; expected %s spaces but found %s'; - $data = array( - ($indicesStart - 1), - ($tokens[$index['index']]['column'] - 1), - ); - $phpcsFile->addError($error, $index['index'], 'KeyNotAligned', $data); - continue; - } - - if ($tokens[$index['arrow']]['column'] !== $arrowStart) { - $expected = ($arrowStart - (strlen($index['index_content']) + $tokens[$index['index']]['column'])); - $found = ($tokens[$index['arrow']]['column'] - (strlen($index['index_content']) + $tokens[$index['index']]['column'])); - - $error = 'Array double arrow not aligned correctly; expected %s space(s) but found %s'; - $data = array( - $expected, - $found, - ); - $phpcsFile->addError($error, $index['arrow'], 'DoubleArrowNotAligned', $data); - continue; - } - - if ($tokens[$index['value']]['column'] !== $valueStart) { - $expected = ($valueStart - (strlen($tokens[$index['arrow']]['content']) + $tokens[$index['arrow']]['column'])); - $found = ($tokens[$index['value']]['column'] - (strlen($tokens[$index['arrow']]['content']) + $tokens[$index['arrow']]['column'])); - - $error = 'Array value not aligned correctly; expected %s space(s) but found %s'; - $data = array( - $expected, - $found, - ); - $phpcsFile->addError($error, $index['arrow'], 'ValueNotAligned', $data); - } - - // Check each line ends in a comma. - if ($tokens[$index['value']]['code'] !== T_ARRAY) { - $nextComma = false; - for ($i = ($index['value'] + 1); $i < $arrayEnd; $i++) { - // Skip bracketed statements, like function calls. - if ($tokens[$i]['code'] === T_OPEN_PARENTHESIS) { - $i = $tokens[$i]['parenthesis_closer']; - continue; - } - - if ($tokens[$i]['code'] === T_COMMA) { - $nextComma = $i; - break; - } - } - - if (($nextComma === false) || ($tokens[$nextComma]['line'] !== $tokens[$index['value']]['line'])) { - $error = 'Each line in an array declaration must end in a comma'; - $phpcsFile->addError($error, $index['value'], 'NoComma'); - } - - // Check that there is no space before the comma. - if ($nextComma !== false && $tokens[($nextComma - 1)]['code'] === T_WHITESPACE) { - $content = $tokens[($nextComma - 2)]['content']; - $spaceLength = strlen($tokens[($nextComma - 1)]['content']); - $error = 'Expected 0 spaces between "%s" and comma; %s found'; - $data = array( - $content, - $spaceLength, - ); - $phpcsFile->addError($error, $nextComma, 'SpaceBeforeComma', $data); - } - } - }//end foreach - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CSS/ClassDefinitionClosingBraceSpaceSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CSS/ClassDefinitionClosingBraceSpaceSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CSS/ClassDefinitionClosingBraceSpaceSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CSS/ClassDefinitionClosingBraceSpaceSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,103 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_CSS_ClassDefinitionClosingBraceSpaceSniff. - * - * Ensure there is a single blank line after the closing brace of a class definition. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_CSS_ClassDefinitionClosingBraceSpaceSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = array('CSS'); - - - /** - * Returns the token types that this sniff is interested in. - * - * @return array(int) - */ - public function register() - { - return array(T_CLOSE_CURLY_BRACKET); - - }//end 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. - * - * @return void - */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - - $next = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); - if ($next === false) { - return; - } - - if ($tokens[$next]['code'] !== T_CLOSE_TAG) { - $found = (($tokens[$next]['line'] - $tokens[$stackPtr]['line']) - 1); - if ($found !== 1) { - $error = 'Expected one blank line after closing brace of class definition; %s found'; - $data = array($found); - $phpcsFile->addError($error, $stackPtr, 'SpacingAfterClose', $data); - } - } - - // Ignore nested style definitions from here on. The spacing before the closing brace - // (a single blank line) will be enforced by the above check, which ensures there is a - // blank line after the last nested class. - $found = $phpcsFile->findPrevious( - T_CLOSE_CURLY_BRACKET, - ($stackPtr - 1), - $tokens[$stackPtr]['bracket_opener'] - ); - if ($found !== false) { - return; - } - - $prev = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true); - if ($prev !== false && $tokens[$prev]['line'] !== ($tokens[$stackPtr]['line'] - 1)) { - $num = ($tokens[$stackPtr]['line'] - $tokens[$prev]['line'] - 1); - $error = 'Expected 0 blank lines before closing brace of class definition; %s found'; - $data = array($num); - $phpcsFile->addError($error, $stackPtr, 'SpacingBeforeClose', $data); - } - - }//end process() - - -}//end class - -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CSS/ClassDefinitionNameSpacingSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CSS/ClassDefinitionNameSpacingSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CSS/ClassDefinitionNameSpacingSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CSS/ClassDefinitionNameSpacingSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,118 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_CSS_ClassDefinitionNameSpacingSniff. - * - * Ensure there are no blank lines between the names of classes/IDs. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_CSS_ClassDefinitionNameSpacingSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = array('CSS'); - - - /** - * Returns the token types that this sniff is interested in. - * - * @return array(int) - */ - public function register() - { - return array(T_OPEN_CURLY_BRACKET); - - }//end 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. - * - * @return void - */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - - // Do not check nested style definitions as, for example, in @media style rules. - $nested = $phpcsFile->findNext(T_OPEN_CURLY_BRACKET, ($stackPtr + 1), $tokens[$stackPtr]['bracket_closer']); - if ($nested !== false) { - return; - } - - // Find the first blank line before this openning brace, unless we get - // to another style definition, comment or the start of the file. - $endTokens = array( - T_OPEN_CURLY_BRACKET, - T_CLOSE_CURLY_BRACKET, - T_COMMENT, - T_DOC_COMMENT, - T_OPEN_TAG, - ); - - $foundContent = false; - $currentLine = $tokens[$stackPtr]['line']; - for ($i = ($stackPtr - 1); $i >= 0; $i--) { - if (in_array($tokens[$i]['code'], $endTokens) === true) { - break; - } - - if ($tokens[$i]['line'] === $currentLine) { - if ($tokens[$i]['code'] !== T_WHITESPACE) { - $foundContent = true; - } - - continue; - } - - // We changed lines. - if ($foundContent === false) { - // Before we throw an error, make sure we are not looking - // at a gap before the style definition. - $prev = $phpcsFile->findPrevious(T_WHITESPACE, $i, null, true); - if ($prev !== false - && in_array($tokens[$prev]['code'], $endTokens) === false - ) { - $error = 'Blank lines are not allowed between class names'; - $phpcsFile->addError($error, ($i + 1), 'BlankLinesFound'); - } - break; - } - - $foundContent = false; - $currentLine = $tokens[$i]['line']; - }//end for - - }//end process() - - -}//end class - -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CSS/ClassDefinitionOpeningBraceSpaceSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CSS/ClassDefinitionOpeningBraceSpaceSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CSS/ClassDefinitionOpeningBraceSpaceSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CSS/ClassDefinitionOpeningBraceSpaceSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,118 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_CSS_ClassDefinitionOpeningBraceSpaceSniff. - * - * Ensure there is a single space before the opening brace in a class definition - * and the content starts on the next line. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_CSS_ClassDefinitionOpeningBraceSpaceSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = array('CSS'); - - - /** - * Returns the token types that this sniff is interested in. - * - * @return array(int) - */ - public function register() - { - return array(T_OPEN_CURLY_BRACKET); - - }//end 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. - * - * @return void - */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - - if ($tokens[($stackPtr - 1)]['code'] !== T_WHITESPACE) { - $error = 'Expected 1 space before opening brace of class definition; 0 found'; - $phpcsFile->addError($error, $stackPtr, 'NoneBefore'); - } else { - $content = $tokens[($stackPtr - 1)]['content']; - if ($content !== ' ') { - $length = strlen($content); - if ($length === 1) { - $length = 'tab'; - } - - $error = 'Expected 1 space before opening brace of class definition; %s found'; - $data = array($length); - $phpcsFile->addError($error, $stackPtr, 'Before', $data); - } - }//end if - - $next = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr + 1), null, true); - if ($next === false) { - return; - } - - // Check for nested class definitions. - $nested = false; - $found = $phpcsFile->findNext( - T_OPEN_CURLY_BRACKET, - ($stackPtr + 1), - $tokens[$stackPtr]['bracket_closer'] - ); - if ($found !== false) { - $nested = true; - } - - $foundLines = ($tokens[$next]['line'] - $tokens[$stackPtr]['line'] - 1); - if ($nested === true) { - if ($foundLines !== 1) { - $error = 'Expected 1 blank line after opening brace of nesting class definition; %s found'; - $data = array($foundLines); - $phpcsFile->addError($error, $stackPtr, 'AfterNesting', $data); - } - } else { - if ($foundLines !== 0) { - $error = 'Expected 0 blank lines after opening brace of class definition; %s found'; - $data = array($foundLines); - $phpcsFile->addError($error, $stackPtr, 'After', $data); - } - } - - }//end process() - - -}//end class - -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CSS/ColonSpacingSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CSS/ColonSpacingSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CSS/ColonSpacingSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CSS/ColonSpacingSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,96 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_CSS_ColonSpacingSniff. - * - * Ensure there is no space before a colon and one space after it. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_CSS_ColonSpacingSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = array('CSS'); - - - /** - * Returns the token types that this sniff is interested in. - * - * @return array(int) - */ - public function register() - { - return array(T_COLON); - - }//end 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. - * - * @return void - */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - - $prev = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true); - if ($tokens[$prev]['code'] !== T_STYLE) { - // The colon is not part of a style definition. - return; - } - - if ($tokens[($stackPtr - 1)]['code'] === T_WHITESPACE) { - $error = 'There must be no space before a colon in a style definition'; - $phpcsFile->addError($error, $stackPtr, 'Before'); - } - - if ($tokens[($stackPtr + 1)]['code'] !== T_WHITESPACE) { - $error = 'Expected 1 space after colon in style definition; 0 found'; - $phpcsFile->addError($error, $stackPtr, 'NoneAfter'); - } else { - $content = $tokens[($stackPtr + 1)]['content']; - if (strpos($content, $phpcsFile->eolChar) === false) { - $length = strlen($content); - if ($length !== 1) { - $error = 'Expected 1 space after colon in style definition; %s found'; - $data = array($length); - $phpcsFile->addError($error, $stackPtr, 'After', $data); - } - } else { - $error = 'Expected 1 space after colon in style definition; newline found'; - $phpcsFile->addError($error, $stackPtr, 'AfterNewline'); - } - }//end if - - }//end process() - -}//end class -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CSS/ColourDefinitionSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CSS/ColourDefinitionSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CSS/ColourDefinitionSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CSS/ColourDefinitionSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,93 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_CSS_ColourDefinitionSniff. - * - * Ensure colours are defined in upper-case and use shortcuts where possible. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_CSS_ColourDefinitionSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = array('CSS'); - - - /** - * Returns the token types that this sniff is interested in. - * - * @return array(int) - */ - public function register() - { - return array(T_COLOUR); - - }//end 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. - * - * @return void - */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - $colour = $tokens[$stackPtr]['content']; - - $expected = strtoupper($colour); - if ($colour !== $expected) { - $error = 'CSS colours must be defined in uppercase; expected %s but found %s'; - $data = array( - $expected, - $colour, - ); - $phpcsFile->addError($error, $stackPtr, 'NotUpper', $data); - } - - // Now check if shorthand can be used. - if (strlen($colour) !== 7) { - return; - } - - if ($colour{1} === $colour{2} && $colour{3} === $colour{4} && $colour{5} === $colour{6}) { - $expected = '#'.$colour{1}.$colour{3}.$colour{5}; - $error = 'CSS colours must use shorthand if available; expected %s but found %s'; - $data = array( - $expected, - $colour, - ); - $phpcsFile->addError($error, $stackPtr, 'Shorthand', $data); - } - - }//end process() - -}//end class -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CSS/DisallowMultipleStyleDefinitionsSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CSS/DisallowMultipleStyleDefinitionsSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CSS/DisallowMultipleStyleDefinitionsSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CSS/DisallowMultipleStyleDefinitionsSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,76 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_CSS_DisallowMultipleStyleDefinitionsSniff. - * - * Ensure that each style definition is on a line by itself. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_CSS_DisallowMultipleStyleDefinitionsSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = array('CSS'); - - - /** - * Returns the token types that this sniff is interested in. - * - * @return array(int) - */ - public function register() - { - return array(T_STYLE); - - }//end 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. - * - * @return void - */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - $next = $phpcsFile->findNext(T_STYLE, ($stackPtr + 1)); - if ($next === false) { - return; - } - - if ($tokens[$next]['line'] === $tokens[$stackPtr]['line']) { - $error = 'Each style definition must be on a line by itself'; - $phpcsFile->addError($error, $next, 'Found'); - } - - }//end process() - -}//end class -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CSS/DuplicateClassDefinitionSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CSS/DuplicateClassDefinitionSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CSS/DuplicateClassDefinitionSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CSS/DuplicateClassDefinitionSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,113 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_CSS_DuplicateClassDefinitionSniff. - * - * Check for duplicate class definitions that can be merged into one. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_CSS_DuplicateClassDefinitionSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = array('CSS'); - - - /** - * Returns the token types that this sniff is interested in. - * - * @return array(int) - */ - public function register() - { - return array(T_OPEN_TAG); - - }//end 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. - * - * @return void - */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - - // Find the content of each class definition name. - $classNames = array(); - $next = $phpcsFile->findNext(T_OPEN_CURLY_BRACKET, ($stackPtr + 1)); - if ($next === false) { - // No class definitions in the file. - return; - } - - $find = array( - T_CLOSE_CURLY_BRACKET, - T_COMMENT, - T_OPEN_TAG, - ); - - while ($next !== false) { - $prev = $phpcsFile->findPrevious($find, ($next - 1)); - - // Create a sorted name for the class so we can compare classes - // even when the individual names are all over the place. - $name = ''; - for ($i = ($prev + 1); $i < $next; $i++) { - $name .= $tokens[$i]['content']; - } - - $name = trim($name); - $name = str_replace("\n", ' ', $name); - $name = preg_replace('|[\s]+|', ' ', $name); - $name = str_replace(', ', ',', $name); - - $names = explode(',', $name); - sort($names); - $name = implode(',', $names); - - if (isset($classNames[$name]) === true) { - $first = $classNames[$name]; - $error = 'Duplicate class definition found; first defined on line %s'; - $data = array($tokens[$first]['line']); - $phpcsFile->addError($error, $next, 'Found', $data); - } else { - $classNames[$name] = $next; - } - - $next = $phpcsFile->findNext(T_OPEN_CURLY_BRACKET, ($next + 1)); - }//end while - - }//end process() - - -}//end class -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CSS/DuplicateStyleDefinitionSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CSS/DuplicateStyleDefinitionSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CSS/DuplicateStyleDefinitionSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CSS/DuplicateStyleDefinitionSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,93 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_CSS_DuplicateStyleDefinitionSniff. - * - * Check for duplicate style definitions in the same class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_CSS_DuplicateStyleDefinitionSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = array('CSS'); - - - /** - * Returns the token types that this sniff is interested in. - * - * @return array(int) - */ - public function register() - { - return array(T_OPEN_CURLY_BRACKET); - - }//end 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. - * - * @return void - */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - - // Find the content of each style definition name. - $end = $tokens[$stackPtr]['bracket_closer']; - $next = $phpcsFile->findNext(T_STYLE, ($stackPtr + 1), $end); - if ($next === false) { - // Class definition is empty. - return; - } - - $styleNames = array(); - - while ($next !== false) { - $name = $tokens[$next]['content']; - if (isset($styleNames[$name]) === true) { - $first = $styleNames[$name]; - $error = 'Duplicate style definition found; first defined on line %s'; - $data = array($tokens[$first]['line']); - $phpcsFile->addError($error, $next, 'Found', $data); - } else { - $styleNames[$name] = $next; - } - - $next = $phpcsFile->findNext(T_STYLE, ($next + 1), $end); - }//end while - - }//end process() - - -}//end class - -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CSS/EmptyClassDefinitionSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CSS/EmptyClassDefinitionSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CSS/EmptyClassDefinitionSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CSS/EmptyClassDefinitionSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,73 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_CSS_EmptyClassDefinitionSniff. - * - * Ensure that class definitions are not empty. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_CSS_EmptyClassDefinitionSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = array('CSS'); - - - /** - * Returns the token types that this sniff is interested in. - * - * @return array(int) - */ - public function register() - { - return array(T_OPEN_CURLY_BRACKET); - - }//end 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. - * - * @return void - */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - $next = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr + 1), null, true); - - if ($next === false || $tokens[$next]['code'] === T_CLOSE_CURLY_BRACKET) { - $error = 'Class definition is empty'; - $phpcsFile->addError($error, $stackPtr, 'Found'); - } - - }//end process() - -}//end class -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CSS/EmptyStyleDefinitionSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CSS/EmptyStyleDefinitionSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CSS/EmptyStyleDefinitionSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CSS/EmptyStyleDefinitionSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,73 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_CSS_EmptyStyleDefinitionSniff. - * - * Ensure that style definitions are not empty. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_CSS_EmptyStyleDefinitionSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = array('CSS'); - - - /** - * Returns the token types that this sniff is interested in. - * - * @return array(int) - */ - public function register() - { - return array(T_STYLE); - - }//end 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. - * - * @return void - */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - $next = $phpcsFile->findNext(array(T_WHITESPACE, T_COLON), ($stackPtr + 1), null, true); - - if ($next === false || $tokens[$next]['code'] === T_SEMICOLON || $tokens[$next]['line'] !== $tokens[$stackPtr]['line']) { - $error = 'Style definition is empty'; - $phpcsFile->addError($error, $stackPtr, 'Found'); - } - - }//end process() - -}//end class -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CSS/IndentationSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CSS/IndentationSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CSS/IndentationSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CSS/IndentationSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,124 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_CSS_IndentationSniff. - * - * Ensures styles are indented 4 spaces. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_CSS_IndentationSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = array('CSS'); - - - /** - * Returns the token types that this sniff is interested in. - * - * @return array(int) - */ - public function register() - { - return array(T_OPEN_TAG); - - }//end 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. - * - * @return void - */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - - $numTokens = (count($tokens) - 2); - $currentLine = 0; - $indentLevel = 0; - $nestingLevel = 0; - for ($i = 1; $i < $numTokens; $i++) { - if ($tokens[$i]['code'] === T_COMMENT) { - // Dont check the indent of comments. - continue; - } - - if ($tokens[$i]['code'] === T_OPEN_CURLY_BRACKET) { - $indentLevel++; - - // Check for nested class definitions. - $found = $phpcsFile->findNext( - T_OPEN_CURLY_BRACKET, - ($i + 1), - $tokens[$i]['bracket_closer'] - ); - if ($found !== false) { - $nestingLevel = $indentLevel; - } - } else if ($tokens[($i + 1)]['code'] === T_CLOSE_CURLY_BRACKET) { - $indentLevel--; - } - - if ($tokens[$i]['line'] === $currentLine) { - continue; - } - - // We started a new line, so check indent. - if ($tokens[$i]['code'] === T_WHITESPACE) { - $content = str_replace($phpcsFile->eolChar, '', $tokens[$i]['content']); - $foundIndent = strlen($content); - } else { - $foundIndent = 0; - } - - $expectedIndent = ($indentLevel * 4); - if ($expectedIndent > 0 && strpos($tokens[$i]['content'], $phpcsFile->eolChar) !== false - ) { - if ($nestingLevel !== $indentLevel) { - $error = 'Blank lines are not allowed in class definitions'; - $phpcsFile->addError($error, $i, 'BlankLine'); - } - } else if ($foundIndent !== $expectedIndent) { - $error = 'Line indented incorrectly; expected %s spaces, found %s'; - $data = array( - $expectedIndent, - $foundIndent, - ); - $phpcsFile->addError($error, $i, 'Incorrect', $data); - } - - $currentLine = $tokens[$i]['line']; - }//end foreach - - }//end process() - -}//end class -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CSS/LowercaseStyleDefinitionSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CSS/LowercaseStyleDefinitionSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CSS/LowercaseStyleDefinitionSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CSS/LowercaseStyleDefinitionSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,83 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_CSS_LowercaseStyleDefinitionSniff. - * - * Ensure that all style definitions are in lowercase. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_CSS_LowercaseStyleDefinitionSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = array('CSS'); - - - /** - * Returns the token types that this sniff is interested in. - * - * @return array(int) - */ - public function register() - { - return array(T_OPEN_CURLY_BRACKET); - - }//end 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. - * - * @return void - */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - $start = ($stackPtr + 1); - $end = ($tokens[$stackPtr]['bracket_closer'] - 1); - - for ($i = $start; $i <= $end; $i++) { - if ($tokens[$i]['code'] === T_STRING || $tokens[$i]['code'] === T_STYLE) { - $expected = strtolower($tokens[$i]['content']); - if ($expected !== $tokens[$i]['content']) { - $error = 'Style definitions must be lowercase; expected %s but found %s'; - $data = array( - $expected, - $tokens[$i]['content'], - ); - $phpcsFile->addError($error, $i, 'FoundUpper', $data); - } - } - } - - }//end process() - -}//end class -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CSS/MissingColonSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CSS/MissingColonSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CSS/MissingColonSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CSS/MissingColonSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,101 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_CSS_MissingColonSniff. - * - * Ensure that all style definitions have a colon. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_CSS_MissingColonSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = array('CSS'); - - - /** - * Returns the token types that this sniff is interested in. - * - * @return array(int) - */ - public function register() - { - return array(T_OPEN_CURLY_BRACKET); - - }//end 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. - * - * @return void - */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - $lastLine = $tokens[$stackPtr]['line']; - $end = $tokens[$stackPtr]['bracket_closer']; - $endLine = $tokens[$end]['line']; - - // Do not check nested style definitions as, for example, in @media style rules. - $nested = $phpcsFile->findNext(T_OPEN_CURLY_BRACKET, ($stackPtr + 1), $end); - if ($nested !== false) { - return; - } - - $foundColon = false; - $foundString = false; - for ($i = ($stackPtr + 1); $i <= $end; $i++) { - if ($tokens[$i]['line'] !== $lastLine) { - // We changed lines. - if ($foundColon === false && $foundString !== false) { - // We didn't find a colon on the previous line. - $error = 'No style definition found on line; check for missing colon'; - $phpcsFile->addError($error, $foundString, 'Found'); - } - - $foundColon = false; - $foundString = false; - $lastLine = $tokens[$i]['line']; - } - - if ($tokens[$i]['code'] === T_STRING) { - $foundString = $i; - } else if ($tokens[$i]['code'] === T_COLON) { - $foundColon = $i; - } - }//end for - - }//end process() - - -}//end class - -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CSS/OpacitySniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CSS/OpacitySniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CSS/OpacitySniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CSS/OpacitySniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,107 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_CSS_OpacitySniff. - * - * Ensure that opacity values start with a 0 if it is not a whole number. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_CSS_OpacitySniff implements PHP_CodeSniffer_Sniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = array('CSS'); - - - /** - * Returns the token types that this sniff is interested in. - * - * @return array(int) - */ - public function register() - { - return array(T_STYLE); - - }//end 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. - * - * @return void - */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - - if ($tokens[$stackPtr]['content'] !== 'opacity') { - return; - } - - $next = $phpcsFile->findNext(array(T_COLON, T_WHITESPACE), ($stackPtr + 1), null, true); - $numbers = array( - T_DNUMBER, - T_LNUMBER, - ); - - if ($next === false || in_array($tokens[$next]['code'], $numbers) === false) { - return; - } - - $value = $tokens[$next]['content']; - if ($tokens[$next]['code'] === T_LNUMBER) { - if ($value !== '0' && $value !== '1') { - $error = 'Opacity values must be between 0 and 1'; - $phpcsFile->addError($error, $next, 'Invalid'); - } - } else { - if (strlen($value) > 3) { - $error = 'Opacity values must have a single value after the decimal point'; - $phpcsFile->addError($error, $next, 'SpacingAfterPoint'); - } else if ($value === '0.0' || $value === '1.0') { - $error = 'Opacity value does not require decimal point; use %s instead'; - $data = array($value{0}); - $phpcsFile->addError($error, $next, 'PointNotRequired', $data); - } else if ($value{0} === '.') { - $error = 'Opacity values must not start with a decimal point; use 0%s instead'; - $data = array($value); - $phpcsFile->addError($error, $next, 'StartWithPoint', $data); - } else if ($value{0} !== '0') { - $error = 'Opacity values must be between 0 and 1'; - $phpcsFile->addError($error, $next, 'Invalid'); - } - }//end if - - }//end process() - - -}//end class - -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CSS/SemicolonSpacingSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CSS/SemicolonSpacingSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CSS/SemicolonSpacingSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CSS/SemicolonSpacingSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,81 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_CSS_SemicolonSpacingSniff. - * - * Ensure each style definition has a semi-colon and it is spaced correctly. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_CSS_SemicolonSpacingSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = array('CSS'); - - - /** - * Returns the token types that this sniff is interested in. - * - * @return array(int) - */ - public function register() - { - return array(T_STYLE); - - }//end 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. - * - * @return void - */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - - $semicolon = $phpcsFile->findNext(T_SEMICOLON, ($stackPtr + 1)); - if ($semicolon === false || $tokens[$semicolon]['line'] !== $tokens[$stackPtr]['line']) { - $error = 'Style definitions must end with a semicolon'; - $phpcsFile->addError($error, $stackPtr, 'NotAtEnd'); - return; - } - - if ($tokens[($semicolon - 1)]['code'] === T_WHITESPACE) { - $length = strlen($tokens[($semicolon - 1)]['content']); - $error = 'Expected 0 spaces before semicolon in style definition; %s found'; - $data = array($length); - $phpcsFile->addError($error, $stackPtr, 'SpaceFound', $data); - } - - }//end process() - -}//end class -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Classes/ClassDeclarationSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Classes/ClassDeclarationSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Classes/ClassDeclarationSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Classes/ClassDeclarationSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,283 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -if (class_exists('PEAR_Sniffs_Classes_ClassDeclarationSniff', true) === false) { - $error = 'Class PEAR_Sniffs_Classes_ClassDeclarationSniff not found'; - throw new PHP_CodeSniffer_Exception($error); -} - -/** - * Class Declaration Test. - * - * Checks the declaration of the class and its inheritance is correct. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_Classes_ClassDeclarationSniff extends PEAR_Sniffs_Classes_ClassDeclarationSniff -{ - - - /** - * 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) - { - // We want all the errors from the PEAR standard, plus some of our own. - parent::process($phpcsFile, $stackPtr); - - $tokens = $phpcsFile->getTokens(); - - /* - Check that this is the only class or interface in the file. - */ - - $nextClass = $phpcsFile->findNext(array(T_CLASS, T_INTERFACE), ($stackPtr + 1)); - - if ($nextClass !== false) { - // We have another, so an error is thrown. - $error = 'Only one interface or class is allowed in a file'; - $phpcsFile->addError($error, $nextClass, 'MultipleClasses'); - } - - /* - Check alignment of the keyword and braces. - */ - - if ($tokens[($stackPtr - 1)]['code'] === T_WHITESPACE) { - $prevContent = $tokens[($stackPtr - 1)]['content']; - if ($prevContent !== $phpcsFile->eolChar) { - $blankSpace = substr($prevContent, strpos($prevContent, $phpcsFile->eolChar)); - $spaces = strlen($blankSpace); - - if (in_array($tokens[($stackPtr - 2)]['code'], array(T_ABSTRACT, T_FINAL)) === false) { - if ($spaces !== 0) { - $type = strtolower($tokens[$stackPtr]['content']); - $error = 'Expected 0 spaces before %s keyword; %s found'; - $data = array( - $type, - $spaces, - ); - $phpcsFile->addError($error, $stackPtr, 'SpaceBeforeKeyword', $data); - } - } else { - if ($spaces !== 1) { - $type = strtolower($tokens[$stackPtr]['content']); - $prevContent = strtolower($tokens[($stackPtr - 2)]['content']); - $error = 'Expected 1 space between %s and %s keywords; %s found'; - $data = array( - $prevContent, - $type, - $spaces, - ); - $phpcsFile->addError($error, $stackPtr, 'SpacesBeforeKeyword', $data); - } - } - } - }//end if - - if (isset($tokens[$stackPtr]['scope_opener']) === false) { - $error = 'Possible parse error: %s missing opening or closing brace'; - $data = array($tokens[$stackPtr]['content']); - $phpcsFile->addWarning($error, $stackPtr, 'MissingBrace', $data); - return; - } - - $closeBrace = $tokens[$stackPtr]['scope_closer']; - if ($tokens[($closeBrace - 1)]['code'] === T_WHITESPACE) { - $prevContent = $tokens[($closeBrace - 1)]['content']; - if ($prevContent !== $phpcsFile->eolChar) { - $blankSpace = substr($prevContent, strpos($prevContent, $phpcsFile->eolChar)); - $spaces = strlen($blankSpace); - if ($spaces !== 0) { - if ($tokens[($closeBrace - 1)]['line'] !== $tokens[$closeBrace]['line']) { - $error = 'Expected 0 spaces before closing brace; newline found'; - $phpcsFile->addError($error, $closeBrace, 'NewLineBeforeCloseBrace'); - } else { - $error = 'Expected 0 spaces before closing brace; %s found'; - $data = array($spaces); - $phpcsFile->addError($error, $closeBrace, 'SpaceBeforeCloseBrace', $data); - } - } - } - } - - // Check that the closing brace has one blank line after it. - $nextContent = $phpcsFile->findNext(array(T_WHITESPACE, T_COMMENT), ($closeBrace + 1), null, true); - if ($nextContent === false) { - // No content found, so we reached the end of the file. - // That means there was no closing tag either. - $error = 'Closing brace of a %s must be followed by a blank line and then a closing PHP tag'; - $data = array($tokens[$stackPtr]['content']); - $phpcsFile->addError($error, $closeBrace, 'EndFileAfterCloseBrace', $data); - } else { - $nextLine = $tokens[$nextContent]['line']; - $braceLine = $tokens[$closeBrace]['line']; - if ($braceLine === $nextLine) { - $error = 'Closing brace of a %s must be followed by a single blank line'; - $data = array($tokens[$stackPtr]['content']); - $phpcsFile->addError($error, $closeBrace, 'NoNewlineAfterCloseBrace', $data); - } else if ($nextLine !== ($braceLine + 2)) { - $difference = ($nextLine - $braceLine - 1); - $error = 'Closing brace of a %s must be followed by a single blank line; found %s'; - $data = array( - $tokens[$stackPtr]['content'], - $difference, - ); - $phpcsFile->addError($error, $closeBrace, 'NewlinesAfterCloseBrace', $data); - } - }//end if - - // Check the closing brace is on it's own line, but allow - // for comments like "//end class". - $nextContent = $phpcsFile->findNext(T_COMMENT, ($closeBrace + 1), null, true); - if ($tokens[$nextContent]['content'] !== $phpcsFile->eolChar && $tokens[$nextContent]['line'] === $tokens[$closeBrace]['line']) { - $type = strtolower($tokens[$stackPtr]['content']); - $error = 'Closing %s brace must be on a line by itself'; - $data = array($tokens[$stackPtr]['content']); - $phpcsFile->addError($error, $closeBrace, 'CloseBraceSameLine', $data); - } - - /* - Check that each of the parent classes or interfaces specified - are spaced correctly. - */ - - // We need to map out each of the possible tokens in the declaration. - $keyword = $stackPtr; - $openingBrace = $tokens[$stackPtr]['scope_opener']; - $className = $phpcsFile->findNext(T_STRING, $stackPtr); - - /* - Now check the spacing of each token. - */ - - $name = strtolower($tokens[$keyword]['content']); - - // Spacing of the keyword. - $gap = $tokens[($stackPtr + 1)]['content']; - if (strlen($gap) !== 1) { - $found = strlen($gap); - $error = 'Expected 1 space between %s keyword and %s name; %s found'; - $data = array( - $name, - $name, - $found, - ); - $phpcsFile->addError($error, $stackPtr, 'SpaceAfterKeyword', $data); - } - - // Check after the name. - $gap = $tokens[($className + 1)]['content']; - if (strlen($gap) !== 1) { - $found = strlen($gap); - $error = 'Expected 1 space after %s name; %s found'; - $data = array( - $name, - $found, - ); - $phpcsFile->addError($error, $stackPtr, 'SpaceAfterName', $data); - } - - // Now check each of the parents. - $parents = array(); - $nextParent = ($className + 1); - while (($nextParent = $phpcsFile->findNext(array(T_STRING, T_IMPLEMENTS), ($nextParent + 1), ($openingBrace - 1))) !== false) { - $parents[] = $nextParent; - } - - $parentCount = count($parents); - - for ($i = 0; $i < $parentCount; $i++) { - if ($tokens[$parents[$i]]['code'] === T_IMPLEMENTS) { - continue; - } - - if ($tokens[($parents[$i] - 1)]['code'] === T_COMMA - || ($tokens[($parents[$i] - 1)]['code'] === T_NS_SEPARATOR - && $tokens[($parents[$i] - 2)]['code'] === T_COMMA) - ) { - $name = $tokens[$parents[$i]]['content']; - $error = 'Expected 1 space before "%s"; 0 found'; - $data = array($name); - $phpcsFile->addError($error, ($nextComma + 1), 'NoSpaceBeforeName', $data); - } else { - $spaceBefore = strlen($tokens[($parents[$i] - 1)]['content']); - if ($spaceBefore !== 1) { - $name = $tokens[$parents[$i]]['content']; - $error = 'Expected 1 space before "%s"; %s found'; - $data = array( - $name, - $spaceBefore, - ); - $phpcsFile->addError($error, $stackPtr, 'SpaceBeforeName', $data); - } - } - - if ($tokens[($parents[$i] + 1)]['code'] !== T_COMMA) { - if ($i !== ($parentCount - 1)) { - // This is not the last parent, and the comma - // is not where we expect it to be. - if ($tokens[($parents[$i] + 2)]['code'] !== T_IMPLEMENTS) { - $found = strlen($tokens[($parents[$i] + 1)]['content']); - $name = $tokens[$parents[$i]]['content']; - $error = 'Expected 0 spaces between "%s" and comma; $%s found'; - $data = array( - $name, - $found, - ); - $phpcsFile->addError($error, $stackPtr, 'SpaceBeforeComma', $data); - } - } - - $nextComma = $phpcsFile->findNext(T_COMMA, $parents[$i]); - } else { - $nextComma = ($parents[$i] + 1); - } - }//end for - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Classes/ClassFileNameSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Classes/ClassFileNameSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Classes/ClassFileNameSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Classes/ClassFileNameSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,81 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_Classes_ClassFileNameSniff. - * - * Tests that the file name and the name of the class contained within the file - * match. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_Classes_ClassFileNameSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * 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) - { - $tokens = $phpcsFile->getTokens(); - $decName = $phpcsFile->findNext(T_STRING, $stackPtr); - $fullPath = basename($phpcsFile->getFilename()); - $fileName = substr($fullPath, 0, strrpos($fullPath, '.')); - - if ($tokens[$decName]['content'] !== $fileName) { - $error = '%s name doesn\'t match filename; expected "%s %s"'; - $data = array( - ucfirst($tokens[$stackPtr]['content']), - $tokens[$stackPtr]['content'], - $fileName, - ); - $phpcsFile->addError($error, $stackPtr, 'NoMatch', $data); - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Classes/DuplicatePropertySniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Classes/DuplicatePropertySniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Classes/DuplicatePropertySniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Classes/DuplicatePropertySniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,100 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_Classes_DuplicatePropertySniff. - * - * Ensures JS classes dont contain duplicate property names. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_Classes_DuplicatePropertySniff implements PHP_CodeSniffer_Sniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = array('JS'); - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array(T_OBJECT); - - }//end register() - - - /** - * Processes this test, when one of its tokens is encountered. - * - * @param PHP_CodeSniffer_File $phpcsFile The current file being processed. - * @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(); - $start = $tokens[$stackPtr]['scope_opener']; - $end = $tokens[$stackPtr]['scope_closer']; - - $properties = array(); - $wantedTokens = array( - T_PROPERTY, - T_OPEN_CURLY_BRACKET, - ); - - $next = $phpcsFile->findNext($wantedTokens, ($start + 1), $end); - while ($next !== false && $next < $end) { - // Skip nested objects. - if ($tokens[$next]['code'] === T_OPEN_CURLY_BRACKET) { - $next = $tokens[$next]['bracket_closer']; - } else { - $propName = $tokens[$next]['content']; - if (isset($properties[$propName]) === true) { - $error = 'Duplicate property definition found for "%s"; previously defined on line %s'; - $data = array( - $propName, - $tokens[$properties[$propName]]['line'], - ); - $phpcsFile->addError($error, $next, 'Found', $data); - } - - $properties[$propName] = $next; - }//end if - - $next = $phpcsFile->findNext($wantedTokens, ($next + 1), $end); - }//end while - - }//end process() - - -}//end class - - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Classes/LowercaseClassKeywordsSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Classes/LowercaseClassKeywordsSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Classes/LowercaseClassKeywordsSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Classes/LowercaseClassKeywordsSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,84 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_Classes_LowercaseClassKeywordsSniff. - * - * Ensures all class keywords are lowercase. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_Classes_LowercaseClassKeywordsSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array( - T_CLASS, - T_INTERFACE, - T_EXTENDS, - T_IMPLEMENTS, - T_ABSTRACT, - T_FINAL, - T_VAR, - T_CONST, - ); - - }//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(); - - $content = $tokens[$stackPtr]['content']; - if ($content !== strtolower($content)) { - $error = '%s keyword must be lowercase; expected "%s" but found "%s"'; - $data = array( - strtoupper($content), - strtolower($content), - $content, - ); - $phpcsFile->addError($error, $stackPtr, 'FoundUppercase', $data); - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Classes/SelfMemberReferenceSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Classes/SelfMemberReferenceSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Classes/SelfMemberReferenceSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Classes/SelfMemberReferenceSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,108 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -if (class_exists('PHP_CodeSniffer_Standards_AbstractScopeSniff', true) === false) { - $error = 'Class PHP_CodeSniffer_Standards_AbstractScopeSniff not found'; - throw new PHP_CodeSniffer_Exception($error); -} - -/** - * Tests self member references. - * - * Verifies that : - *
    - *
  • self:: is used instead of Self::
  • - *
  • self:: is used for local static member reference
  • - *
  • self:: is used instead of self ::
  • - *
- * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_Classes_SelfMemberReferenceSniff extends PHP_CodeSniffer_Standards_AbstractScopeSniff -{ - - - /** - * Constructs a Squiz_Sniffs_Classes_SelfMemberReferenceSniff. - */ - public function __construct() - { - parent::__construct(array(T_CLASS), array(T_DOUBLE_COLON)); - - }//end __construct() - - - /** - * Processes the function tokens within the class. - * - * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found. - * @param int $stackPtr The position where the token was found. - * @param int $currScope The current scope opener token. - * - * @return void - */ - protected function processTokenWithinScope(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $currScope) - { - $tokens = $phpcsFile->getTokens(); - - $className = ($stackPtr - 1); - if ($tokens[$className]['code'] === T_SELF) { - if (strtolower($tokens[$className]['content']) !== $tokens[$className]['content']) { - $error = 'Must use "self::" for local static member reference; found "%s::"'; - $data = array($tokens[$className]['content']); - $phpcsFile->addError($error, $className, 'IncorrectCase', $data); - return; - } - } else if ($tokens[$className]['code'] === T_STRING) { - // Make sure this is another class reference. - $declarationName = $phpcsFile->getDeclarationName($currScope); - if ($declarationName === $tokens[$className]['content']) { - // Class name is the same as the current class, which is not allowed - // except if being used inside a closure. - if ($phpcsFile->hasCondition($stackPtr, T_CLOSURE) === false) { - $error = 'Must use "self::" for local static member reference'; - $phpcsFile->addError($error, $className, 'NotUsed'); - return; - } - } - } - - if ($tokens[($stackPtr - 1)]['code'] === T_WHITESPACE) { - $found = strlen($tokens[($stackPtr - 1)]['content']); - $error = 'Expected 0 spaces before double colon; %s found'; - $data = array($found); - $phpcsFile->addError($error, $className, 'SpaceBefore', $data); - } - - if ($tokens[($stackPtr + 1)]['code'] === T_WHITESPACE) { - $found = strlen($tokens[($stackPtr + 1)]['content']); - $error = 'Expected 0 spaces after double colon; %s found'; - $data = array($found); - $phpcsFile->addError($error, $className, 'SpaceAfter', $data); - } - - }//end processTokenWithinScope() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Classes/ValidClassNameSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Classes/ValidClassNameSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Classes/ValidClassNameSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Classes/ValidClassNameSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,95 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_Classes_ValidClassNameSniff. - * - * Ensures classes are in camel caps, and the first letter is capitalised - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_Classes_ValidClassNameSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * 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 current file being processed. - * @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(); - - if (isset($tokens[$stackPtr]['scope_opener']) === false) { - $error = 'Possible parse error: %s missing opening or closing brace'; - $data = array($tokens[$stackPtr]['content']); - $phpcsFile->addWarning($error, $stackPtr, 'MissingBrace', $data); - return; - } - - // Determine the name of the class or interface. Note that we cannot - // simply look for the first T_STRING because a class name - // starting with the number will be multiple tokens. - $opener = $tokens[$stackPtr]['scope_opener']; - $nameStart = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), $opener, true); - $nameEnd = $phpcsFile->findNext(T_WHITESPACE, $nameStart, $opener); - $name = trim($phpcsFile->getTokensAsString($nameStart, ($nameEnd - $nameStart))); - - // Check for camel caps format. - $valid = PHP_CodeSniffer::isCamelCaps($name, true, true, false); - if ($valid === false) { - $type = ucfirst($tokens[$stackPtr]['content']); - $error = '%s name "%s" is not in camel caps format'; - $data = array( - $type, - $name, - ); - $phpcsFile->addError($error, $stackPtr, 'NotCamelCaps', $data); - } - - }//end process() - - -}//end class - - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CodeAnalysis/EmptyStatementSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CodeAnalysis/EmptyStatementSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CodeAnalysis/EmptyStatementSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/CodeAnalysis/EmptyStatementSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,55 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -if (class_exists('Generic_Sniffs_CodeAnalysis_EmptyStatementSniff', true) === false) { - throw new PHP_CodeSniffer_Exception('Class Generic_Sniffs_CodeAnalysis_EmptyStatementSniff not found'); -} - -/** - * This sniff class detectes empty statement. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_CodeAnalysis_EmptyStatementSniff extends Generic_Sniffs_CodeAnalysis_EmptyStatementSniff -{ - - /** - * List of block tokens that this sniff covers. - * - * The key of this hash identifies the required token while the boolean - * value says mark an error or mark a warning. - * - * @var array - */ - protected $checkedTokens = array( - T_DO => true, - T_ELSE => true, - T_ELSEIF => true, - T_FOR => true, - T_FOREACH => true, - T_IF => true, - T_SWITCH => true, - T_WHILE => true, - ); - -}//end class - -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Commenting/BlockCommentSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Commenting/BlockCommentSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Commenting/BlockCommentSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Commenting/BlockCommentSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,243 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_Commenting_BlockCommentSniff. - * - * Verifies that block comments are used appropriately. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_Commenting_BlockCommentSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array( - T_COMMENT, - T_DOC_COMMENT, - ); - - }//end register() - - - /** - * Processes this test, when one of its tokens is encountered. - * - * @param PHP_CodeSniffer_File $phpcsFile The current 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(); - - // If its an inline comment return. - if (substr($tokens[$stackPtr]['content'], 0, 2) !== '/*') { - return; - } - - // If this is a function/class/interface doc block comment, skip it. - // We are only interested in inline doc block comments. - if ($tokens[$stackPtr]['code'] === T_DOC_COMMENT) { - $nextToken = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr + 1), null, true); - $ignore = array( - T_CLASS, - T_INTERFACE, - T_FUNCTION, - T_PUBLIC, - T_PRIVATE, - T_FINAL, - T_PROTECTED, - T_STATIC, - T_ABSTRACT, - T_CONST, - ); - if (in_array($tokens[$nextToken]['code'], $ignore) === true) { - return; - } - - $prevToken = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true); - if ($tokens[$prevToken]['code'] === T_OPEN_TAG) { - return; - } - }//end if - - $commentLines = array($stackPtr); - $nextComment = $stackPtr; - $lastLine = $tokens[$stackPtr]['line']; - - // Construct the comment into an array. - while (($nextComment = $phpcsFile->findNext($tokens[$stackPtr]['code'], ($nextComment + 1), null, false)) !== false) { - if (($tokens[$nextComment]['line'] - 1) !== $lastLine) { - // Not part of the block. - break; - } - - $lastLine = $tokens[$nextComment]['line']; - $commentLines[] = $nextComment; - } - - if (count($commentLines) <= 2) { - // Small comment. Can't be right. - if (count($commentLines) === 1) { - $error = 'Single line block comment not allowed; use inline ("// text") comment instead'; - $phpcsFile->addError($error, $stackPtr, 'SingleLine'); - return; - } - - if (trim($tokens[$commentLines[1]]['content']) === '*/') { - if (trim($tokens[$stackPtr]['content']) === '/*') { - $error = 'Empty block comment not allowed'; - $phpcsFile->addError($error, $stackPtr, 'Empty'); - return; - } - } - } - - $content = trim($tokens[$stackPtr]['content']); - if ($content !== '/*' && $content !== '/**') { - $error = 'Block comment text must start on a new line'; - $phpcsFile->addError($error, $stackPtr, 'NoNewLine'); - return; - } - - $starColumn = ($tokens[$stackPtr]['column'] + 3); - - // Make sure first line isn't blank. - if (trim($tokens[$commentLines[1]]['content']) === '') { - $error = 'Empty line not allowed at start of comment'; - $phpcsFile->addError($error, $commentLines[1], 'HasEmptyLine'); - } else { - // Check indentation of first line. - $content = $tokens[$commentLines[1]]['content']; - $commentText = ltrim($content); - $leadingSpace = (strlen($content) - strlen($commentText)); - if ($leadingSpace !== $starColumn) { - $expected = $starColumn; - $expected .= ($starColumn === 1) ? ' space' : ' spaces'; - $data = array( - $expected, - $leadingSpace, - ); - - $error = 'First line of comment not aligned correctly; expected %s but found %s'; - $phpcsFile->addError($error, $commentLines[1], 'FirstLineIndent', $data); - } - - if (preg_match('|[A-Z]|', $commentText[0]) === 0) { - $error = 'Block comments must start with a capital letter'; - $phpcsFile->addError($error, $commentLines[1], 'NoCaptial'); - } - } - - // Check that each line of the comment is indented past the star. - foreach ($commentLines as $line) { - $leadingSpace = (strlen($tokens[$line]['content']) - strlen(ltrim($tokens[$line]['content']))); - // First and last lines (comment opener and closer) are handled seperately. - if ($line === $commentLines[(count($commentLines) - 1)] || $line === $commentLines[0]) { - continue; - } - - // First comment line was handled above. - if ($line === $commentLines[1]) { - continue; - } - - // If it's empty, continue. - if (trim($tokens[$line]['content']) === '') { - continue; - } - - if ($leadingSpace < $starColumn) { - $expected = $starColumn; - $expected .= ($starColumn === 1) ? ' space' : ' spaces'; - $data = array( - $expected, - $leadingSpace, - ); - - $error = 'Comment line indented incorrectly; expected at least %s but found %s'; - $phpcsFile->addError($error, $line, 'LineIndent', $data); - } - }//end foreach - - // Finally, test the last line is correct. - $lastIndex = (count($commentLines) - 1); - $content = trim($tokens[$commentLines[$lastIndex]]['content']); - if ($content !== '*/' && $content !== '**/') { - $error = 'Comment closer must be on a new line'; - $phpcsFile->addError($error, $commentLines[$lastIndex]); - } else { - $content = $tokens[$commentLines[$lastIndex]]['content']; - $commentText = ltrim($content); - $leadingSpace = (strlen($content) - strlen($commentText)); - if ($leadingSpace !== ($tokens[$stackPtr]['column'] - 1)) { - $expected = ($tokens[$stackPtr]['column'] - 1); - $expected .= ($expected === 1) ? ' space' : ' spaces'; - $data = array( - $expected, - $leadingSpace, - ); - - $error = 'Last line of comment aligned incorrectly; expected %s but found %s'; - $phpcsFile->addError($error, $commentLines[$lastIndex], 'LastLineIndent', $data); - } - - } - - // Check that the lines before and after this comment are blank. - $contentBefore = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); - if ($tokens[$contentBefore]['code'] === T_OPEN_CURLY_BRACKET) { - if (($tokens[$stackPtr]['line'] - $tokens[$contentBefore]['line']) < 1) { - $error = 'Empty line not required before block comment'; - $phpcsFile->addError($error, $stackPtr, 'HasEmptyLineBefore'); - } - } else { - if (($tokens[$stackPtr]['line'] - $tokens[$contentBefore]['line']) < 2) { - $error = 'Empty line required before block comment'; - $phpcsFile->addError($error, $stackPtr, 'NoEmptyLineBefore'); - } - } - - $commentCloser = $commentLines[$lastIndex]; - $contentAfter = $phpcsFile->findNext(T_WHITESPACE, ($commentCloser + 1), null, true); - if (($tokens[$contentAfter]['line'] - $tokens[$commentCloser]['line']) < 2) { - $error = 'Empty line required after block comment'; - $phpcsFile->addError($error, $commentCloser, 'NoEmptyLineAfter'); - } - - }//end process() - - -}//end class - - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Commenting/ClassCommentSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Commenting/ClassCommentSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Commenting/ClassCommentSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Commenting/ClassCommentSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,255 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -if (class_exists('PHP_CodeSniffer_CommentParser_ClassCommentParser', true) === false) { - throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_CommentParser_ClassCommentParser not found'); -} - -/** - * Parses and verifies the class doc comment. - * - * Verifies that : - *
    - *
  • A class doc comment exists.
  • - *
  • There is exactly one blank line before the class comment.
  • - *
  • Short description ends with a full stop.
  • - *
  • There is a blank line after the short description.
  • - *
  • Each paragraph of the long description ends with a full stop.
  • - *
  • There is a blank line between the description and the tags.
  • - *
  • Check the format of the since tag (x.x.x).
  • - *
- * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_Commenting_ClassCommentSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array(T_CLASS); - - }//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(); - $find = array ( - T_ABSTRACT, - T_WHITESPACE, - T_FINAL, - ); - - // Extract the class comment docblock. - $commentEnd = $phpcsFile->findPrevious($find, ($stackPtr - 1), null, true); - - if ($commentEnd !== false && $tokens[$commentEnd]['code'] === T_COMMENT) { - $phpcsFile->addError('You must use "/**" style comments for a class comment', $stackPtr, 'WrongStyle'); - return; - } else if ($commentEnd === false || $tokens[$commentEnd]['code'] !== T_DOC_COMMENT) { - $phpcsFile->addError('Missing class doc comment', $stackPtr, 'Missing'); - return; - } - - $commentStart = ($phpcsFile->findPrevious(T_DOC_COMMENT, ($commentEnd - 1), null, true) + 1); - $commentNext = $phpcsFile->findPrevious(T_WHITESPACE, ($commentEnd + 1), $stackPtr, false, $phpcsFile->eolChar); - - // Distinguish file and class comment. - $prevClassToken = $phpcsFile->findPrevious(T_CLASS, ($stackPtr - 1)); - if ($prevClassToken === false) { - // This is the first class token in this file, need extra checks. - $prevNonComment = $phpcsFile->findPrevious(T_DOC_COMMENT, ($commentStart - 1), null, true); - if ($prevNonComment !== false) { - $prevComment = $phpcsFile->findPrevious(T_DOC_COMMENT, ($prevNonComment - 1)); - if ($prevComment === false) { - // There is only 1 doc comment between open tag and class token. - $newlineToken = $phpcsFile->findNext(T_WHITESPACE, ($commentEnd + 1), $stackPtr, false, $phpcsFile->eolChar); - if ($newlineToken !== false) { - $newlineToken = $phpcsFile->findNext(T_WHITESPACE, ($newlineToken + 1), $stackPtr, false, $phpcsFile->eolChar); - if ($newlineToken !== false) { - // Blank line between the class and the doc block. - // The doc block is most likely a file comment. - $phpcsFile->addError('Missing class doc comment', ($stackPtr + 1), 'Missing'); - return; - } - }//end if - }//end if - - // Exactly one blank line before the class comment. - $prevTokenEnd = $phpcsFile->findPrevious(T_WHITESPACE, ($commentStart - 1), null, true); - if ($prevTokenEnd !== false) { - $blankLineBefore = 0; - for ($i = ($prevTokenEnd + 1); $i < $commentStart; $i++) { - if ($tokens[$i]['code'] === T_WHITESPACE && $tokens[$i]['content'] === $phpcsFile->eolChar) { - $blankLineBefore++; - } - } - - if ($blankLineBefore !== 2) { - $error = 'There must be exactly one blank line before the class comment'; - $phpcsFile->addError($error, ($commentStart - 1), 'SpacingBefore'); - } - } - - }//end if - }//end if - - $commentString = $phpcsFile->getTokensAsString($commentStart, ($commentEnd - $commentStart + 1)); - - // Parse the class comment docblock. - try { - $this->commentParser = new PHP_CodeSniffer_CommentParser_ClassCommentParser($commentString, $phpcsFile); - $this->commentParser->parse(); - } catch (PHP_CodeSniffer_CommentParser_ParserException $e) { - $line = ($e->getLineWithinComment() + $commentStart); - $phpcsFile->addError($e->getMessage(), $line, 'FailedParse'); - return; - } - - $comment = $this->commentParser->getComment(); - if (is_null($comment) === true) { - $error = 'Class doc comment is empty'; - $phpcsFile->addError($error, $commentStart, 'Empty'); - return; - } - - // The first line of the comment should just be the /** code. - $eolPos = strpos($commentString, $phpcsFile->eolChar); - $firstLine = substr($commentString, 0, $eolPos); - if ($firstLine !== '/**') { - $error = 'The open comment tag must be the only content on the line'; - $phpcsFile->addError($error, $commentStart, 'SpacingAfterOpen'); - } - - // Check for a comment description. - $short = rtrim($comment->getShortComment(), $phpcsFile->eolChar); - if (trim($short) === '') { - $error = 'Missing short description in class doc comment'; - $phpcsFile->addError($error, $commentStart, 'MissingShort'); - return; - } - - // No extra newline before short description. - $newlineCount = 0; - $newlineSpan = strspn($short, $phpcsFile->eolChar); - if ($short !== '' && $newlineSpan > 0) { - $error = 'Extra newline(s) found before class comment short description'; - $phpcsFile->addError($error, ($commentStart + 1), 'SpacingBeforeShort'); - } - - $newlineCount = (substr_count($short, $phpcsFile->eolChar) + 1); - - // Exactly one blank line between short and long description. - $long = $comment->getLongComment(); - if (empty($long) === false) { - $between = $comment->getWhiteSpaceBetween(); - $newlineBetween = substr_count($between, $phpcsFile->eolChar); - if ($newlineBetween !== 2) { - $error = 'There must be exactly one blank line between descriptions in class comment'; - $phpcsFile->addError($error, ($commentStart + $newlineCount + 1), 'SpacingBetween'); - } - - $newlineCount += $newlineBetween; - - $testLong = trim($long); - if (preg_match('|[A-Z]|', $testLong[0]) === 0) { - $error = 'Class comment long description must start with a capital letter'; - $phpcsFile->addError($error, ($commentStart + $newlineCount), 'LongNotCaptial'); - } - } - - // Exactly one blank line before tags. - $tags = $this->commentParser->getTagOrders(); - if (count($tags) > 1) { - $newlineSpan = $comment->getNewlineAfter(); - if ($newlineSpan !== 2) { - $error = 'There must be exactly one blank line before the tags in class comment'; - if ($long !== '') { - $newlineCount += (substr_count($long, $phpcsFile->eolChar) - $newlineSpan + 1); - } - - $phpcsFile->addError($error, ($commentStart + $newlineCount), 'SpacingBeforeTags'); - $short = rtrim($short, $phpcsFile->eolChar.' '); - } - } - - // Short description must be single line and end with a full stop. - $testShort = trim($short); - $lastChar = $testShort[(strlen($testShort) - 1)]; - if (substr_count($testShort, $phpcsFile->eolChar) !== 0) { - $error = 'Class comment short description must be on a single line'; - $phpcsFile->addError($error, ($commentStart + 1), 'ShortSingleLine'); - } - - if (preg_match('|[A-Z]|', $testShort[0]) === 0) { - $error = 'Class comment short description must start with a capital letter'; - $phpcsFile->addError($error, ($commentStart + 1), 'ShortNotCapital'); - } - - if ($lastChar !== '.') { - $error = 'Class comment short description must end with a full stop'; - $phpcsFile->addError($error, ($commentStart + 1), 'ShortFullStop'); - } - - // No tags are allowed in the class comment. - $tags = $this->commentParser->getTags(); - foreach ($tags as $errorTag) { - $error = '@%s tag is not allowed in class comment'; - $data = array($errorTag['tag']); - $phpcsFile->addWarning($error, ($commentStart + $errorTag['line']), 'TagNotAllowed', $data); - } - - // The last content should be a newline and the content before - // that should not be blank. If there is more blank space - // then they have additional blank lines at the end of the comment. - $words = $this->commentParser->getWords(); - $lastPos = (count($words) - 1); - if (trim($words[($lastPos - 1)]) !== '' - || strpos($words[($lastPos - 1)], $this->currentFile->eolChar) === false - || trim($words[($lastPos - 2)]) === '' - ) { - $error = 'Additional blank lines found at end of class comment'; - $this->currentFile->addError($error, $commentEnd, 'SpacingAfter'); - } - - }//end process() - - -}//end class -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Commenting/ClosingDeclarationCommentSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Commenting/ClosingDeclarationCommentSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Commenting/ClosingDeclarationCommentSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Commenting/ClosingDeclarationCommentSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,127 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_Commenting_ClosingDeclarationCommentSniff. - * - * Checks the //end ... comments on classes, interfaces and functions. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_Commenting_ClosingDeclarationCommentSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array( - T_FUNCTION, - 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) - { - $tokens = $phpcsFile->getTokens(); - - if ($tokens[$stackPtr]['code'] === T_FUNCTION) { - - $methodProps = $phpcsFile->getMethodProperties($stackPtr); - - // Abstract methods do not require a closing comment. - if ($methodProps['is_abstract'] === true) { - return; - } - - // Closures do not require a closing comment. - if ($methodProps['is_closure'] === true) { - return; - } - - // If this function is in an interface then we don't require - // a closing comment. - if ($phpcsFile->hasCondition($stackPtr, T_INTERFACE) === true) { - return; - } - - if (isset($tokens[$stackPtr]['scope_closer']) === false) { - $error = 'Possible parse error: non-abstract method defined as abstract'; - $phpcsFile->addWarning($error, $stackPtr, 'Abstract'); - return; - } - - $decName = $phpcsFile->getDeclarationName($stackPtr); - $comment = '//end '.$decName.'()'; - } else if ($tokens[$stackPtr]['code'] === T_CLASS) { - $comment = '//end class'; - } else { - $comment = '//end interface'; - }//end if - - if (isset($tokens[$stackPtr]['scope_closer']) === false) { - $error = 'Possible parse error: %s missing opening or closing brace'; - $data = array($tokens[$stackPtr]['content']); - $phpcsFile->addWarning($error, $stackPtr, 'MissingBrace', $data); - return; - } - - $closingBracket = $tokens[$stackPtr]['scope_closer']; - - if ($closingBracket === null) { - // Possible inline structure. Other tests will handle it. - return; - } - - $error = 'Expected '.$comment; - if (isset($tokens[($closingBracket + 1)]) === false || $tokens[($closingBracket + 1)]['code'] !== T_COMMENT) { - $phpcsFile->addError($error, $closingBracket, 'Missing'); - return; - } - - if (rtrim($tokens[($closingBracket + 1)]['content']) !== $comment) { - $phpcsFile->addError($error, $closingBracket, 'Incorrect'); - return; - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Commenting/DocCommentAlignmentSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Commenting/DocCommentAlignmentSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Commenting/DocCommentAlignmentSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Commenting/DocCommentAlignmentSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,151 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_Commenting_DocCommentAlignmentSniff. - * - * Tests that the stars in a doc comment align correctly. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_Commenting_DocCommentAlignmentSniff 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); - - }//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(); - - // We are only interested in function/class/interface doc block comments. - $nextToken = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr + 1), null, true); - $ignore = array( - T_CLASS, - T_INTERFACE, - T_FUNCTION, - T_PUBLIC, - T_PRIVATE, - T_PROTECTED, - T_STATIC, - T_ABSTRACT, - ); - - if (in_array($tokens[$nextToken]['code'], $ignore) === false) { - // Could be a file comment. - $prevToken = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true); - if ($tokens[$prevToken]['code'] !== T_OPEN_TAG) { - return; - } - } - - // We only want to get the first comment in a block. If there is - // a comment on the line before this one, return. - $docComment = $phpcsFile->findPrevious(T_DOC_COMMENT, ($stackPtr - 1)); - if ($docComment !== false) { - if ($tokens[$docComment]['line'] === ($tokens[$stackPtr]['line'] - 1)) { - return; - } - } - - $comments = array($stackPtr); - $currentComment = $stackPtr; - $lastComment = $stackPtr; - while (($currentComment = $phpcsFile->findNext(T_DOC_COMMENT, ($currentComment + 1))) !== false) { - if ($tokens[$lastComment]['line'] === ($tokens[$currentComment]['line'] - 1)) { - $comments[] = $currentComment; - $lastComment = $currentComment; - } else { - break; - } - } - - // The $comments array now contains pointers to each token in the - // comment block. - $requiredColumn = strpos($tokens[$stackPtr]['content'], '*'); - $requiredColumn += $tokens[$stackPtr]['column']; - - foreach ($comments as $commentPointer) { - // Check the spacing after each asterisk. - $content = $tokens[$commentPointer]['content']; - $firstChar = substr($content, 0, 1); - $lastChar = substr($content, -1); - if ($firstChar !== '/' && $lastChar !== '/') { - $matches = array(); - preg_match('|^(\s+)?\*(\s+)?@|', $content, $matches); - if (empty($matches) === false) { - if (isset($matches[2]) === false) { - $error = 'Expected 1 space between asterisk and tag; 0 found'; - $phpcsFile->addError($error, $commentPointer, 'NoSpaceBeforeTag'); - } else { - $length = strlen($matches[2]); - if ($length !== 1) { - $error = 'Expected 1 space between asterisk and tag; %s found'; - $data = array($length); - $phpcsFile->addError($error, $commentPointer, 'SpaceBeforeTag', $data); - } - } - } - }//end foreach - - // Check the alignment of each asterisk. - $currentColumn = strpos($content, '*'); - $currentColumn += $tokens[$commentPointer]['column']; - - if ($currentColumn === $requiredColumn) { - // Star is aligned correctly. - continue; - } - - $error = 'Expected %s space(s) before asterisk; %s found'; - $data = array( - ($requiredColumn - 1), - ($currentColumn - 1), - ); - $phpcsFile->addError($error, $commentPointer, 'SpaceBeforeAsterisk', $data); - }//end foreach - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Commenting/EmptyCatchCommentSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Commenting/EmptyCatchCommentSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Commenting/EmptyCatchCommentSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Commenting/EmptyCatchCommentSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,73 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_Commenting_EmptyCatchCommentSniff. - * - * Checks for empty Catch clause. Catch clause must at least have comment - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_Commenting_EmptyCatchCommentSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array(T_CATCH); - - }//end register() - - - /** - * Processes this test, when one of its tokens is encountered. - * - * @param PHP_CodeSniffer_File $phpcsFile All the tokens found in the document. - * @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(); - - $scopeStart = $tokens[$stackPtr]['scope_opener']; - $firstContent = $phpcsFile->findNext(T_WHITESPACE, ($scopeStart + 1), $tokens[$stackPtr]['scope_closer'], true); - - if ($firstContent === false) { - $error = 'Empty CATCH statement must have a comment to explain why the exception is not handled'; - $phpcsFile->addError($error, $scopeStart, 'Missing'); - } - - }//end process() - - -}//end class - - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Commenting/FileCommentSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Commenting/FileCommentSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Commenting/FileCommentSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Commenting/FileCommentSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,614 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -if (class_exists('PHP_CodeSniffer_CommentParser_ClassCommentParser', true) === false) { - throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_CommentParser_ClassCommentParser not found'); -} - -/** - * Parses and verifies the file doc comment. - * - * Verifies that : - *
    - *
  • A file doc comment exists.
  • - *
  • There is no blank line between the open tag and the file comment.
  • - *
  • Short description ends with a full stop.
  • - *
  • There is a blank line after the short description.
  • - *
  • Each paragraph of the long description ends with a full stop.
  • - *
  • There is a blank line between the description and the tags.
  • - *
  • Check the order, indentation and content of each tag.
  • - *
  • There is exactly one blank line after the file comment.
  • - *
- * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -class Squiz_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - ); - - /** - * The header comment parser for the current file. - * - * @var PHP_CodeSniffer_Comment_Parser_ClassCommentParser - */ - protected $commentParser = null; - - /** - * The current PHP_CodeSniffer_File object we are processing. - * - * @var PHP_CodeSniffer_File - */ - protected $currentFile = null; - - - /** - * 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 void - */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) - { - $this->currentFile = $phpcsFile; - - // We are only interested if this is the first open tag. - if ($stackPtr !== 0) { - if ($phpcsFile->findPrevious(T_OPEN_TAG, ($stackPtr - 1)) !== false) { - return; - } - } - - $tokens = $phpcsFile->getTokens(); - - $errorToken = ($stackPtr + 1); - if (isset($tokens[$errorToken]) === false) { - $errorToken--; - } - - // Find the next non whitespace token. - $commentStart = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); - - if ($tokens[$commentStart]['code'] === T_CLOSE_TAG) { - // We are only interested if this is the first open tag. - return; - } else if ($tokens[$commentStart]['code'] === T_COMMENT) { - $phpcsFile->addError('You must use "/**" style comments for a file comment', $errorToken, 'WrongStyle'); - return; - } else if ($commentStart === false || $tokens[$commentStart]['code'] !== T_DOC_COMMENT) { - $phpcsFile->addError('Missing file doc comment', $errorToken, 'Missing'); - return; - } - - // Extract the header comment docblock. - $commentEnd = ($phpcsFile->findNext(T_DOC_COMMENT, ($commentStart + 1), null, true) - 1); - - // Check if there is only 1 doc comment between the open tag and class token. - $nextToken = array( - T_ABSTRACT, - T_CLASS, - T_DOC_COMMENT, - ); - - $commentNext = $phpcsFile->findNext($nextToken, ($commentEnd + 1)); - if ($commentNext !== false && $tokens[$commentNext]['code'] !== T_DOC_COMMENT) { - // Found a class token right after comment doc block. - $newlineToken = $phpcsFile->findNext(T_WHITESPACE, ($commentEnd + 1), $commentNext, false, $phpcsFile->eolChar); - if ($newlineToken !== false) { - $newlineToken = $phpcsFile->findNext(T_WHITESPACE, ($newlineToken + 1), $commentNext, false, $phpcsFile->eolChar); - if ($newlineToken === false) { - // No blank line between the class token and the doc block. - // The doc block is most likely a class comment. - $phpcsFile->addError('Missing file doc comment', $errorToken, 'Missing'); - return; - } - } - } - - // No blank line between the open tag and the file comment. - $blankLineBefore = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, false, $phpcsFile->eolChar); - if ($blankLineBefore !== false && $blankLineBefore < $commentStart) { - $error = 'Extra newline found after the open tag'; - $phpcsFile->addError($error, $stackPtr, 'SpacingAfterOpen'); - } - - // Exactly one blank line after the file comment. - $nextTokenStart = $phpcsFile->findNext(T_WHITESPACE, ($commentEnd + 1), null, true); - if ($nextTokenStart !== false) { - $blankLineAfter = 0; - for ($i = ($commentEnd + 1); $i < $nextTokenStart; $i++) { - if ($tokens[$i]['code'] === T_WHITESPACE && $tokens[$i]['content'] === $phpcsFile->eolChar) { - $blankLineAfter++; - } - } - - if ($blankLineAfter !== 2) { - $error = 'There must be exactly one blank line after the file comment'; - $phpcsFile->addError($error, ($commentEnd + 1), 'SpacingAfterComment'); - } - } - - $commentString = $phpcsFile->getTokensAsString($commentStart, ($commentEnd - $commentStart + 1)); - - // Parse the header comment docblock. - try { - $this->commentParser = new PHP_CodeSniffer_CommentParser_ClassCommentParser($commentString, $phpcsFile); - $this->commentParser->parse(); - } catch (PHP_CodeSniffer_CommentParser_ParserException $e) { - $line = ($e->getLineWithinComment() + $commentStart); - $phpcsFile->addError($e->getMessage(), $line, 'Exception'); - return; - } - - $comment = $this->commentParser->getComment(); - if (is_null($comment) === true) { - $error = 'File doc comment is empty'; - $phpcsFile->addError($error, $commentStart, 'Empty'); - return; - } - - // The first line of the comment should just be the /** code. - $eolPos = strpos($commentString, $phpcsFile->eolChar); - $firstLine = substr($commentString, 0, $eolPos); - if ($firstLine !== '/**') { - $error = 'The open comment tag must be the only content on the line'; - $phpcsFile->addError($error, $commentStart, 'ContentAfterOpen'); - } - - // No extra newline before short description. - $short = $comment->getShortComment(); - $newlineCount = 0; - $newlineSpan = strspn($short, $phpcsFile->eolChar); - if ($short !== '' && $newlineSpan > 0) { - $error = 'Extra newline(s) found before file comment short description'; - $phpcsFile->addError($error, ($commentStart + 1), 'SpacingBeforeShort'); - } - - $newlineCount = (substr_count($short, $phpcsFile->eolChar) + 1); - - // Exactly one blank line between short and long description. - $long = $comment->getLongComment(); - if (empty($long) === false) { - $between = $comment->getWhiteSpaceBetween(); - $newlineBetween = substr_count($between, $phpcsFile->eolChar); - if ($newlineBetween !== 2) { - $error = 'There must be exactly one blank line between descriptions in file comment'; - $phpcsFile->addError($error, ($commentStart + $newlineCount + 1), 'SpacingBetween'); - } - - $newlineCount += $newlineBetween; - - $testLong = trim($long); - if (preg_match('|[A-Z]|', $testLong[0]) === 0) { - $error = 'File comment long description must start with a capital letter'; - $phpcsFile->addError($error, ($commentStart + $newlineCount), 'LongNotCaptial'); - } - }//end if - - // Exactly one blank line before tags. - $tags = $this->commentParser->getTagOrders(); - if (count($tags) > 1) { - $newlineSpan = $comment->getNewlineAfter(); - if ($newlineSpan !== 2) { - $error = 'There must be exactly one blank line before the tags in file comment'; - if ($long !== '') { - $newlineCount += (substr_count($long, $phpcsFile->eolChar) - $newlineSpan + 1); - } - - $phpcsFile->addError($error, ($commentStart + $newlineCount), 'SpacingBeforeTags'); - $short = rtrim($short, $phpcsFile->eolChar.' '); - } - } - - // Short description must be single line and end with a full stop. - $testShort = trim($short); - if ($testShort === '') { - $error = 'Missing short description in file comment'; - $phpcsFile->addError($error, ($commentStart + 1), 'MissingShort'); - } else { - $lastChar = $testShort[(strlen($testShort) - 1)]; - if (substr_count($testShort, $phpcsFile->eolChar) !== 0) { - $error = 'File comment short description must be on a single line'; - $phpcsFile->addError($error, ($commentStart + 1), 'ShortSingleLine'); - } - - if (preg_match('|[A-Z]|', $testShort[0]) === 0) { - $error = 'File comment short description must start with a capital letter'; - $phpcsFile->addError($error, ($commentStart + 1), 'ShortNotCapital'); - } - - if ($lastChar !== '.') { - $error = 'File comment short description must end with a full stop'; - $phpcsFile->addError($error, ($commentStart + 1), 'ShortFullStop'); - } - }//end if - - // Check for unknown/deprecated tags. - $unknownTags = $this->commentParser->getUnknown(); - foreach ($unknownTags as $errorTag) { - // Unknown tags are not parsed, do not process further. - $error = '@%s tag is not allowed in file comment'; - $data = array($errorTag['tag']); - $phpcsFile->addWarning($error, ($commentStart + $errorTag['line']), 'TagNotAllowed', $data); - } - - // Check each tag. - $this->processTags($commentStart, $commentEnd); - - // The last content should be a newline and the content before - // that should not be blank. If there is more blank space - // then they have additional blank lines at the end of the comment. - $words = $this->commentParser->getWords(); - $lastPos = (count($words) - 1); - if (trim($words[($lastPos - 1)]) !== '' - || strpos($words[($lastPos - 1)], $this->currentFile->eolChar) === false - || trim($words[($lastPos - 2)]) === '' - ) { - $error = 'Additional blank lines found at end of file comment'; - $this->currentFile->addError($error, $commentEnd, 'SpacingAfter'); - } - - }//end process() - - - /** - * Processes each required or optional tag. - * - * @param int $commentStart The position in the stack where the comment started. - * @param int $commentEnd The position in the stack where the comment ended. - * - * @return void - */ - protected function processTags($commentStart, $commentEnd) - { - // Required tags in correct order. - $tags = array( - 'package' => 'precedes @subpackage', - 'subpackage' => 'follows @package', - 'author' => 'follows @subpackage', - 'copyright' => 'follows @author', - 'license' => 'follows @copyright', - ); - - $foundTags = $this->commentParser->getTagOrders(); - $errorPos = 0; - $orderIndex = 0; - $longestTag = 0; - $indentation = array(); - foreach ($tags as $tag => $orderText) { - - // Required tag missing. - if (in_array($tag, $foundTags) === false) { - $error = 'Missing @%s tag in file comment'; - $data = array($tag); - $this->currentFile->addError($error, $commentEnd, 'MissingTag', $data); - continue; - } - - // Get the line number for current tag. - $tagName = ucfirst($tag); - if ($tagName === 'Author' || $tagName === 'Copyright') { - // These tags are different because they return an array. - $tagName .= 's'; - } - - // Work out the line number for this tag. - $getMethod = 'get'.$tagName; - $tagElement = $this->commentParser->$getMethod(); - if (is_null($tagElement) === true || empty($tagElement) === true) { - continue; - } else if (is_array($tagElement) === true && empty($tagElement) === false) { - $tagElement = $tagElement[0]; - } - - $errorPos = ($commentStart + $tagElement->getLine()); - - // Make sure there is no duplicate tag. - $foundIndexes = array_keys($foundTags, $tag); - if (count($foundIndexes) > 1) { - $error = 'Only 1 @%s tag is allowed in file comment'; - $data = array($tag); - $this->currentFile->addError($error, $errorPos, 'DuplicateTag', $data); - } - - // Check tag order. - if ($foundIndexes[0] > $orderIndex) { - $orderIndex = $foundIndexes[0]; - } else { - $error = 'The @%s tag is in the wrong order; the tag %s'; - $data = array( - $tag, - $orderText, - ); - $this->currentFile->addError($error, $errorPos, 'TagOrder', $data); - } - - // Store the indentation of each tag. - $len = strlen($tag); - if ($len > $longestTag) { - $longestTag = $len; - } - - $indentation[] = array( - 'tag' => $tag, - 'errorPos' => $errorPos, - 'space' => $this->getIndentation($tag, $tagElement), - ); - - $method = 'process'.$tagName; - if (method_exists($this, $method) === true) { - // Process each tag if a method is defined. - call_user_func(array($this, $method), $errorPos); - } else { - $tagElement->process($this->currentFile, $commentStart, 'file'); - } - }//end foreach - - // Check tag indentation. - foreach ($indentation as $indentInfo) { - $tagName = ucfirst($indentInfo['tag']); - if ($tagName === 'Author') { - $tagName .= 's'; - } - - if ($indentInfo['space'] !== 0 && $indentInfo['space'] !== ($longestTag + 1)) { - $expected = ($longestTag - strlen($indentInfo['tag']) + 1); - $space = ($indentInfo['space'] - strlen($indentInfo['tag'])); - $error = '@%s tag comment indented incorrectly; expected %s spaces but found %s'; - $data = array( - $indentInfo['tag'], - $expected, - $space, - ); - $this->currentFile->addError($error, $indentInfo['errorPos'], 'TagIndent', $data); - } - } - - }//end processTags() - - - /** - * Get the indentation information of each tag. - * - * @param string $tagName The name of the doc comment element. - * @param PHP_CodeSniffer_CommentParser_DocElement $tagElement The doc comment element. - * - * @return void - */ - protected function getIndentation($tagName, $tagElement) - { - if ($tagElement instanceof PHP_CodeSniffer_CommentParser_SingleElement) { - if ($tagElement->getContent() !== '') { - return (strlen($tagName) + substr_count($tagElement->getWhitespaceBeforeContent(), ' ')); - } - } else if ($tagElement instanceof PHP_CodeSniffer_CommentParser_PairElement) { - if ($tagElement->getValue() !== '') { - return (strlen($tagName) + substr_count($tagElement->getWhitespaceBeforeValue(), ' ')); - } - } - - return 0; - - }//end getIndentation() - - - /** - * The package name must be camel-cased. - * - * @param int $errorPos The line number where the error occurs. - * - * @return void - */ - protected function processPackage($errorPos) - { - $package = $this->commentParser->getPackage(); - if ($package !== null) { - $content = $package->getContent(); - if (empty($content) === true) { - $error = 'Content missing for @package tag in file comment'; - $this->currentFile->addError($error, $errorPos, 'MissingPackage'); - } else if (PHP_CodeSniffer::isUnderscoreName($content) !== true) { - // Package name must be properly camel-cased. - $nameBits = explode('_', str_replace(' ', '', $content)); - $firstBit = array_shift($nameBits); - $newName = strtoupper($firstBit{0}).substr($firstBit, 1).'_'; - foreach ($nameBits as $bit) { - $newName .= strtoupper($bit{0}).substr($bit, 1).'_'; - } - - $error = 'Package name "%s" is not valid; consider "%s" instead'; - $data = array( - $content, - trim($newName, '_'), - ); - $this->currentFile->addError($error, $errorPos, 'IncorrectPackage', $data); - } else if (strpos($content, 'Squiz') === 0) { - // Package name must not start with Squiz. - $newName = substr($content, 5); - $error = 'Package name "%s" is not valid; consider "%s" instead'; - $data = array( - $content, - $newName, - ); - $this->currentFile->addError($error, $errorPos, 'SquizPackage', $data); - } - } - - }//end processPackage() - - - /** - * The subpackage name must be camel-cased. - * - * @param int $errorPos The line number where the error occurs. - * - * @return void - */ - protected function processSubpackage($errorPos) - { - $subpackage = $this->commentParser->getSubpackage(); - if ($subpackage !== null) { - $content = $subpackage->getContent(); - if (empty($content) === true) { - $error = 'Content missing for @subpackage tag in file comment'; - $this->currentFile->addError($error, $errorPos, 'MissingSubpackage'); - } else if (PHP_CodeSniffer::isUnderscoreName($content) !== true) { - // Subpackage name must be properly camel-cased. - $nameBits = explode('_', $content); - $firstBit = array_shift($nameBits); - $newName = strtoupper($firstBit{0}).substr($firstBit, 1).'_'; - foreach ($nameBits as $bit) { - $newName .= strtoupper($bit{0}).substr($bit, 1).'_'; - } - - $error = 'Subpackage name "%s" is not valid; consider "%s" instead'; - $data = array( - $content, - trim($newName, '_'), - ); - $this->currentFile->addError($error, $errorPos, 'IncorrectSubpackage', $data); - } - } - - }//end processSubpackage() - - - /** - * Author tag must be 'Squiz Pty Ltd '. - * - * @param int $errorPos The line number where the error occurs. - * - * @return void - */ - protected function processAuthors($errorPos) - { - $authors = $this->commentParser->getAuthors(); - if (empty($authors) === false) { - $author = $authors[0]; - $content = $author->getContent(); - if (empty($content) === true) { - $error = 'Content missing for @author tag in file comment'; - $this->currentFile->addError($error, $errorPos, 'MissingAuthor'); - } else if ($content !== 'Squiz Pty Ltd ') { - $error = 'Expected "Squiz Pty Ltd " for author tag'; - $this->currentFile->addError($error, $errorPos, 'IncorrectAuthor'); - } - } - - }//end processAuthors() - - - /** - * Copyright tag must be in the form '2006-YYYY Squiz Pty Ltd (ABN 77 084 670 600)'. - * - * @param int $errorPos The line number where the error occurs. - * - * @return void - */ - protected function processCopyrights($errorPos) - { - $copyrights = $this->commentParser->getCopyrights(); - $copyright = $copyrights[0]; - - if ($copyright !== null) { - $content = $copyright->getContent(); - if (empty($content) === true) { - $error = 'Content missing for @copyright tag in file comment'; - $this->currentFile->addError($error, $errorPos, 'MissingCopyright'); - - } else if (preg_match('/^([0-9]{4})(-[0-9]{4})? (Squiz Pty Ltd \(ACN 084 670 600\))$/', $content) === 0) { - $error = 'Expected "xxxx-xxxx Squiz Pty Ltd (ACN 084 670 600)" for copyright declaration'; - $this->currentFile->addError($error, $errorPos, 'IncorrectCopyright'); - } - } - - }//end processCopyrights() - - - /** - * License tag must be 'http://matrix.squiz.net/licence Squiz.Net Open Source Licence'. - * - * @param int $errorPos The line number where the error occurs. - * - * @return void - */ - protected function processLicense($errorPos) - { - $license = $this->commentParser->getLicense(); - if ($license !== null) { - $url = $license->getValue(); - $content = $license->getComment(); - if (empty($url) === true && empty($content) === true) { - $error = 'Content missing for @license tag in file comment'; - $this->currentFile->addError($error, $errorPos, 'MissingLicense'); - } else { - // Check for license URL. - if (empty($url) === true) { - $error = 'License URL missing for @license tag in file comment'; - $this->currentFile->addError($error, $errorPos, 'MissingLinceseURL'); - } else if ($url !== 'http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt') { - $error = 'Expected "http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt" for license URL'; - $this->currentFile->addError($error, $errorPos, 'IncorrectLicenseURL'); - } - - // Check for license name. - if (empty($content) === true) { - $error = 'License name missing for @license tag in file comment'; - $this->currentFile->addError($error, $errorPos, 'MissingLinceseName'); - } else if ($content !== 'GPLv2') { - $error = 'Expected "GPLv2" for license name'; - $this->currentFile->addError($error, $errorPos, 'IncorrectLicenseName'); - } - }//end if - }//end if - - }//end processLicense() - - -}//end class - - -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,806 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -if (class_exists('PHP_CodeSniffer_CommentParser_FunctionCommentParser', true) === false) { - $error = 'Class PHP_CodeSniffer_CommentParser_FunctionCommentParser not found'; - throw new PHP_CodeSniffer_Exception($error); -} - -/** - * Parses and verifies the doc comments for functions. - * - * Verifies that : - *
    - *
  • A comment exists
  • - *
  • There is a blank newline after the short description
  • - *
  • There is a blank newline between the long and short description
  • - *
  • There is a blank newline between the long description and tags
  • - *
  • Parameter names represent those in the method
  • - *
  • Parameter comments are in the correct order
  • - *
  • Parameter comments are complete
  • - *
  • A type hint is provided for array and custom class
  • - *
  • Type hint matches the actual variable/class type
  • - *
  • A blank line is present before the first and after the last parameter
  • - *
  • A return type exists
  • - *
  • Any throw tag must have a comment
  • - *
  • The tag order and indentation are correct
  • - *
- * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_Commenting_FunctionCommentSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * The name of the method that we are currently processing. - * - * @var string - */ - private $_methodName = ''; - - /** - * The position in the stack where the fucntion token was found. - * - * @var int - */ - private $_functionToken = null; - - /** - * The position in the stack where the class token was found. - * - * @var int - */ - private $_classToken = null; - - /** - * The index of the current tag we are processing. - * - * @var int - */ - private $_tagIndex = 0; - - /** - * The function comment parser for the current method. - * - * @var PHP_CodeSniffer_Comment_Parser_FunctionCommentParser - */ - protected $commentParser = null; - - /** - * The current PHP_CodeSniffer_File object we are processing. - * - * @var PHP_CodeSniffer_File - */ - protected $currentFile = null; - - - /** - * 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) - { - $this->currentFile = $phpcsFile; - - $tokens = $phpcsFile->getTokens(); - - $find = array( - T_COMMENT, - T_DOC_COMMENT, - T_CLASS, - T_FUNCTION, - T_OPEN_TAG, - ); - - $commentEnd = $phpcsFile->findPrevious($find, ($stackPtr - 1)); - - if ($commentEnd === false) { - return; - } - - // If the token that we found was a class or a function, then this - // function has no doc comment. - $code = $tokens[$commentEnd]['code']; - - if ($code === T_COMMENT) { - // The function might actually be missing a comment, and this last comment - // found is just commenting a bit of code on a line. So if it is not the - // only thing on the line, assume we found nothing. - $prevContent = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, $commentEnd); - if ($tokens[$commentEnd]['line'] === $tokens[$commentEnd]['line']) { - $error = 'Missing function doc comment'; - $phpcsFile->addError($error, $stackPtr, 'Missing'); - } else { - $error = 'You must use "/**" style comments for a function comment'; - $phpcsFile->addError($error, $stackPtr, 'WrongStyle'); - } - return; - } else if ($code !== T_DOC_COMMENT) { - $error = 'Missing function doc comment'; - $phpcsFile->addError($error, $stackPtr, 'Missing'); - return; - } - - // If there is any code between the function keyword and the doc block - // then the doc block is not for us. - $ignore = PHP_CodeSniffer_Tokens::$scopeModifiers; - $ignore[] = T_STATIC; - $ignore[] = T_WHITESPACE; - $ignore[] = T_ABSTRACT; - $ignore[] = T_FINAL; - $prevToken = $phpcsFile->findPrevious($ignore, ($stackPtr - 1), null, true); - if ($prevToken !== $commentEnd) { - $phpcsFile->addError('Missing function doc comment', $stackPtr, 'Missing'); - return; - } - - $this->_functionToken = $stackPtr; - - $this->_classToken = null; - foreach ($tokens[$stackPtr]['conditions'] as $condPtr => $condition) { - if ($condition === T_CLASS || $condition === T_INTERFACE) { - $this->_classToken = $condPtr; - break; - } - } - - // Find the first doc comment. - $commentStart = ($phpcsFile->findPrevious(T_DOC_COMMENT, ($commentEnd - 1), null, true) + 1); - $commentString = $phpcsFile->getTokensAsString($commentStart, ($commentEnd - $commentStart + 1)); - $this->_methodName = $phpcsFile->getDeclarationName($stackPtr); - - try { - $this->commentParser = new PHP_CodeSniffer_CommentParser_FunctionCommentParser($commentString, $phpcsFile); - $this->commentParser->parse(); - } catch (PHP_CodeSniffer_CommentParser_ParserException $e) { - $line = ($e->getLineWithinComment() + $commentStart); - $phpcsFile->addError($e->getMessage(), $line, 'FailedParse'); - return; - } - - $comment = $this->commentParser->getComment(); - if (is_null($comment) === true) { - $error = 'Function doc comment is empty'; - $phpcsFile->addError($error, $commentStart, 'Empty'); - return; - } - - // The first line of the comment should just be the /** code. - $eolPos = strpos($commentString, $phpcsFile->eolChar); - $firstLine = substr($commentString, 0, $eolPos); - if ($firstLine !== '/**') { - $error = 'The open comment tag must be the only content on the line'; - $phpcsFile->addError($error, $commentStart, 'ContentAfterOpen'); - } - - $this->processParams($commentStart, $commentEnd); - $this->processSees($commentStart); - $this->processReturn($commentStart, $commentEnd); - $this->processThrows($commentStart); - - // Check for a comment description. - $short = $comment->getShortComment(); - if (trim($short) === '') { - $error = 'Missing short description in function doc comment'; - $phpcsFile->addError($error, $commentStart, 'MissingShort'); - return; - } - - // No extra newline before short description. - $newlineCount = 0; - $newlineSpan = strspn($short, $phpcsFile->eolChar); - if ($short !== '' && $newlineSpan > 0) { - $error = 'Extra newline(s) found before function comment short description'; - $phpcsFile->addError($error, ($commentStart + 1), 'SpacingBeforeShort'); - } - - $newlineCount = (substr_count($short, $phpcsFile->eolChar) + 1); - - // Exactly one blank line between short and long description. - $long = $comment->getLongComment(); - if (empty($long) === false) { - $between = $comment->getWhiteSpaceBetween(); - $newlineBetween = substr_count($between, $phpcsFile->eolChar); - if ($newlineBetween !== 2) { - $error = 'There must be exactly one blank line between descriptions in function comment'; - $phpcsFile->addError($error, ($commentStart + $newlineCount + 1), 'SpacingBetween'); - } - - $newlineCount += $newlineBetween; - - $testLong = trim($long); - if (preg_match('|[A-Z]|', $testLong[0]) === 0) { - $error = 'Function comment long description must start with a capital letter'; - $phpcsFile->addError($error, ($commentStart + $newlineCount), 'LongNotCapital'); - } - }//end if - - // Exactly one blank line before tags. - $params = $this->commentParser->getTagOrders(); - if (count($params) > 1) { - $newlineSpan = $comment->getNewlineAfter(); - if ($newlineSpan !== 2) { - $error = 'There must be exactly one blank line before the tags in function comment'; - if ($long !== '') { - $newlineCount += (substr_count($long, $phpcsFile->eolChar) - $newlineSpan + 1); - } - - $phpcsFile->addError($error, ($commentStart + $newlineCount), 'SpacingBeforeTags'); - $short = rtrim($short, $phpcsFile->eolChar.' '); - } - } - - // Short description must be single line and end with a full stop. - $testShort = trim($short); - $lastChar = $testShort[(strlen($testShort) - 1)]; - if (substr_count($testShort, $phpcsFile->eolChar) !== 0) { - $error = 'Function comment short description must be on a single line'; - $phpcsFile->addError($error, ($commentStart + 1), 'ShortSingleLine'); - } - - if (preg_match('|[A-Z]|', $testShort[0]) === 0) { - $error = 'Function comment short description must start with a capital letter'; - $phpcsFile->addError($error, ($commentStart + 1), 'ShortNotCapital'); - } - - if ($lastChar !== '.') { - $error = 'Function comment short description must end with a full stop'; - $phpcsFile->addError($error, ($commentStart + 1), 'ShortFullStop'); - } - - // Check for unknown/deprecated tags. - $this->processUnknownTags($commentStart, $commentEnd); - - // The last content should be a newline and the content before - // that should not be blank. If there is more blank space - // then they have additional blank lines at the end of the comment. - $words = $this->commentParser->getWords(); - $lastPos = (count($words) - 1); - if (trim($words[($lastPos - 1)]) !== '' - || strpos($words[($lastPos - 1)], $this->currentFile->eolChar) === false - || trim($words[($lastPos - 2)]) === '' - ) { - $error = 'Additional blank lines found at end of function comment'; - $this->currentFile->addError($error, $commentEnd, 'SpacingAfter'); - } - - }//end process() - - - /** - * Process the see tags. - * - * @param int $commentStart The position in the stack where the comment started. - * - * @return void - */ - protected function processSees($commentStart) - { - $sees = $this->commentParser->getSees(); - if (empty($sees) === false) { - $tagOrder = $this->commentParser->getTagOrders(); - $index = array_keys($this->commentParser->getTagOrders(), 'see'); - foreach ($sees as $i => $see) { - $errorPos = ($commentStart + $see->getLine()); - $since = array_keys($tagOrder, 'since'); - if (count($since) === 1 && $this->_tagIndex !== 0) { - $this->_tagIndex++; - if ($index[$i] !== $this->_tagIndex) { - $error = 'The @see tag is in the wrong order; the tag precedes @return'; - $this->currentFile->addError($error, $errorPos, 'SeeOrder'); - } - } - - $content = $see->getContent(); - if (empty($content) === true) { - $error = 'Content missing for @see tag in function comment'; - $this->currentFile->addError($error, $errorPos, 'EmptySee'); - continue; - } - - $spacing = substr_count($see->getWhitespaceBeforeContent(), ' '); - if ($spacing !== 4) { - $error = '@see tag indented incorrectly; expected 4 spaces but found %s'; - $data = array($spacing); - $this->currentFile->addError($error, $errorPos, 'SeeIndent', $data); - } - }//end foreach - }//end if - - }//end processSees() - - - /** - * Process the return comment of this function comment. - * - * @param int $commentStart The position in the stack where the comment started. - * @param int $commentEnd The position in the stack where the comment ended. - * - * @return void - */ - protected function processReturn($commentStart, $commentEnd) - { - // Skip constructor and destructor. - $className = ''; - if ($this->_classToken !== null) { - $className = $this->currentFile->getDeclarationName($this->_classToken); - $className = strtolower(ltrim($className, '_')); - } - - $methodName = strtolower(ltrim($this->_methodName, '_')); - $isSpecialMethod = ($this->_methodName === '__construct' || $this->_methodName === '__destruct'); - $return = $this->commentParser->getReturn(); - - if ($isSpecialMethod === false && $methodName !== $className) { - if ($return !== null) { - $tagOrder = $this->commentParser->getTagOrders(); - $index = array_keys($tagOrder, 'return'); - $errorPos = ($commentStart + $return->getLine()); - $content = trim($return->getRawContent()); - - if (count($index) > 1) { - $error = 'Only 1 @return tag is allowed in function comment'; - $this->currentFile->addError($error, $errorPos, 'DuplicateReturn'); - return; - } - - $since = array_keys($tagOrder, 'since'); - if (count($since) === 1 && $this->_tagIndex !== 0) { - $this->_tagIndex++; - if ($index[0] !== $this->_tagIndex) { - $error = 'The @return tag is in the wrong order; the tag follows @see (if used)'; - $this->currentFile->addError($error, $errorPos, 'ReturnOrder'); - } - } - - if (empty($content) === true) { - $error = 'Return type missing for @return tag in function comment'; - $this->currentFile->addError($error, $errorPos, 'MissingReturnType'); - } else { - // Check return type (can be multiple, separated by '|'). - $typeNames = explode('|', $content); - $suggestedNames = array(); - foreach ($typeNames as $i => $typeName) { - $suggestedName = PHP_CodeSniffer::suggestType($typeName); - if (in_array($suggestedName, $suggestedNames) === false) { - $suggestedNames[] = $suggestedName; - } - } - - $suggestedType = implode('|', $suggestedNames); - if ($content !== $suggestedType) { - $error = 'Function return type "%s" is invalid'; - $data = array($content); - $this->currentFile->addError($error, $errorPos, 'InvalidReturn', $data); - } - - $tokens = $this->currentFile->getTokens(); - - // If the return type is void, make sure there is - // no return statement in the function. - if ($content === 'void') { - if (isset($tokens[$this->_functionToken]['scope_closer']) === true) { - $endToken = $tokens[$this->_functionToken]['scope_closer']; - $returnToken = $this->currentFile->findNext(T_RETURN, $this->_functionToken, $endToken); - if ($returnToken !== false) { - // If the function is not returning anything, just - // exiting, then there is no problem. - $semicolon = $this->currentFile->findNext(T_WHITESPACE, ($returnToken + 1), null, true); - if ($tokens[$semicolon]['code'] !== T_SEMICOLON) { - $error = 'Function return type is void, but function contains return statement'; - $this->currentFile->addError($error, $errorPos, 'InvalidReturnVoid'); - } - } - } - } else if ($content !== 'mixed') { - // If return type is not void, there needs to be a - // returns statement somewhere in the function that - // returns something. - if (isset($tokens[$this->_functionToken]['scope_closer']) === true) { - $endToken = $tokens[$this->_functionToken]['scope_closer']; - $returnToken = $this->currentFile->findNext(T_RETURN, $this->_functionToken, $endToken); - if ($returnToken === false) { - $error = 'Function return type is not void, but function has no return statement'; - $this->currentFile->addError($error, $errorPos, 'InvalidNoReturn'); - } else { - $semicolon = $this->currentFile->findNext(T_WHITESPACE, ($returnToken + 1), null, true); - if ($tokens[$semicolon]['code'] === T_SEMICOLON) { - $error = 'Function return type is not void, but function is returning void here'; - $this->currentFile->addError($error, $returnToken, 'InvalidReturnNotVoid'); - } - } - } - }//end if - - $spacing = substr_count($return->getWhitespaceBeforeValue(), ' '); - if ($spacing !== 1) { - $error = '@return tag indented incorrectly; expected 1 space but found %s'; - $data = array($spacing); - $this->currentFile->addError($error, $errorPos, 'ReturnIndent', $data); - } - }//end if - } else { - $error = 'Missing @return tag in function comment'; - $this->currentFile->addError($error, $commentEnd, 'MissingReturn'); - }//end if - - } else { - // No return tag for constructor and destructor. - if ($return !== null) { - $errorPos = ($commentStart + $return->getLine()); - $error = '@return tag is not required for constructor and destructor'; - $this->currentFile->addError($error, $errorPos, 'ReturnNotRequired'); - } - }//end if - - }//end processReturn() - - - /** - * Process any throw tags that this function comment has. - * - * @param int $commentStart The position in the stack where the comment started. - * - * @return void - */ - protected function processThrows($commentStart) - { - if (count($this->commentParser->getThrows()) === 0) { - return; - } - - $tagOrder = $this->commentParser->getTagOrders(); - $index = array_keys($this->commentParser->getTagOrders(), 'throws'); - - foreach ($this->commentParser->getThrows() as $i => $throw) { - $exception = $throw->getValue(); - $content = trim($throw->getComment()); - $errorPos = ($commentStart + $throw->getLine()); - if (empty($exception) === true) { - $error = 'Exception type and comment missing for @throws tag in function comment'; - $this->currentFile->addError($error, $errorPos, 'InvalidThrows'); - } else if (empty($content) === true) { - $error = 'Comment missing for @throws tag in function comment'; - $this->currentFile->addError($error, $errorPos, 'EmptyThrows'); - } else { - // Starts with a capital letter and ends with a fullstop. - $firstChar = $content{0}; - if (strtoupper($firstChar) !== $firstChar) { - $error = '@throws tag comment must start with a capital letter'; - $this->currentFile->addError($error, $errorPos, 'ThrowsNotCapital'); - } - - $lastChar = $content[(strlen($content) - 1)]; - if ($lastChar !== '.') { - $error = '@throws tag comment must end with a full stop'; - $this->currentFile->addError($error, $errorPos, 'ThrowsNoFullStop'); - } - } - - $since = array_keys($tagOrder, 'since'); - if (count($since) === 1 && $this->_tagIndex !== 0) { - $this->_tagIndex++; - if ($index[$i] !== $this->_tagIndex) { - $error = 'The @throws tag is in the wrong order; the tag follows @return'; - $this->currentFile->addError($error, $errorPos, 'ThrowsOrder'); - } - } - }//end foreach - - }//end processThrows() - - - /** - * Process the function parameter comments. - * - * @param int $commentStart The position in the stack where - * the comment started. - * @param int $commentEnd The position in the stack where - * the comment ended. - * - * @return void - */ - protected function processParams($commentStart, $commentEnd) - { - $realParams = $this->currentFile->getMethodParameters($this->_functionToken); - $params = $this->commentParser->getParams(); - $foundParams = array(); - - if (empty($params) === false) { - - if (substr_count($params[(count($params) - 1)]->getWhitespaceAfter(), $this->currentFile->eolChar) !== 2) { - $error = 'Last parameter comment requires a blank newline after it'; - $errorPos = ($params[(count($params) - 1)]->getLine() + $commentStart); - $this->currentFile->addError($error, $errorPos, 'SpacingAfterParams'); - } - - // Parameters must appear immediately after the comment. - if ($params[0]->getOrder() !== 2) { - $error = 'Parameters must appear immediately after the comment'; - $errorPos = ($params[0]->getLine() + $commentStart); - $this->currentFile->addError($error, $errorPos, 'SpacingBeforeParams'); - } - - $previousParam = null; - $spaceBeforeVar = 10000; - $spaceBeforeComment = 10000; - $longestType = 0; - $longestVar = 0; - - foreach ($params as $param) { - - $paramComment = trim($param->getComment()); - $errorPos = ($param->getLine() + $commentStart); - - // Make sure that there is only one space before the var type. - if ($param->getWhitespaceBeforeType() !== ' ') { - $error = 'Expected 1 space before variable type'; - $this->currentFile->addError($error, $errorPos, 'SpacingBeforeParamType'); - } - - $spaceCount = substr_count($param->getWhitespaceBeforeVarName(), ' '); - if ($spaceCount < $spaceBeforeVar) { - $spaceBeforeVar = $spaceCount; - $longestType = $errorPos; - } - - $spaceCount = substr_count($param->getWhitespaceBeforeComment(), ' '); - - if ($spaceCount < $spaceBeforeComment && $paramComment !== '') { - $spaceBeforeComment = $spaceCount; - $longestVar = $errorPos; - } - - // Make sure they are in the correct order, and have the correct name. - $pos = $param->getPosition(); - $paramName = ($param->getVarName() !== '') ? $param->getVarName() : '[ UNKNOWN ]'; - - if ($previousParam !== null) { - $previousName = ($previousParam->getVarName() !== '') ? $previousParam->getVarName() : 'UNKNOWN'; - - // Check to see if the parameters align properly. - if ($param->alignsVariableWith($previousParam) === false) { - $error = 'The variable names for parameters %s (%s) and %s (%s) do not align'; - $data = array( - $previousName, - ($pos - 1), - $paramName, - $pos, - ); - $this->currentFile->addError($error, $errorPos, 'ParameterNamesNotAligned', $data); - } - - if ($param->alignsCommentWith($previousParam) === false) { - $error = 'The comments for parameters %s (%s) and %s (%s) do not align'; - $data = array( - $previousName, - ($pos - 1), - $paramName, - $pos, - ); - $this->currentFile->addError($error, $errorPos, 'ParameterCommentsNotAligned', $data); - } - } - - // Variable must be one of the supported standard type. - $typeNames = explode('|', $param->getType()); - foreach ($typeNames as $typeName) { - $suggestedName = PHP_CodeSniffer::suggestType($typeName); - if ($typeName !== $suggestedName) { - $error = 'Expected "%s"; found "%s" for %s at position %s'; - $data = array( - $suggestedName, - $typeName, - $paramName, - $pos, - ); - $this->currentFile->addError($error, $errorPos, 'IncorrectParamVarName', $data); - } else if (count($typeNames) === 1) { - // Check type hint for array and custom type. - $suggestedTypeHint = ''; - if (strpos($suggestedName, 'array') !== false) { - $suggestedTypeHint = 'array'; - } else if (in_array($typeName, PHP_CodeSniffer::$allowedTypes) === false) { - $suggestedTypeHint = $suggestedName; - } - - if ($suggestedTypeHint !== '' && isset($realParams[($pos - 1)]) === true) { - $typeHint = $realParams[($pos - 1)]['type_hint']; - if ($typeHint === '') { - $error = 'Type hint "%s" missing for %s at position %s'; - $data = array( - $suggestedTypeHint, - $paramName, - $pos, - ); - $this->currentFile->addError($error, ($commentEnd + 2), 'TypeHintMissing', $data); - } else if ($typeHint !== $suggestedTypeHint) { - $error = 'Expected type hint "%s"; found "%s" for %s at position %s'; - $data = array( - $suggestedTypeHint, - $typeHint, - $paramName, - $pos, - ); - $this->currentFile->addError($error, ($commentEnd + 2), 'IncorrectTypeHint', $data); - } - } else if ($suggestedTypeHint === '' && isset($realParams[($pos - 1)]) === true) { - $typeHint = $realParams[($pos - 1)]['type_hint']; - if ($typeHint !== '') { - $error = 'Unknown type hint "%s" found for %s at position %s'; - $data = array( - $typeHint, - $paramName, - $pos, - ); - $this->currentFile->addError($error, ($commentEnd + 2), 'InvalidTypeHint', $data); - } - } - }//end if - }//end foreach - - // Make sure the names of the parameter comment matches the - // actual parameter. - if (isset($realParams[($pos - 1)]) === true) { - $realName = $realParams[($pos - 1)]['name']; - $foundParams[] = $realName; - - // Append ampersand to name if passing by reference. - if ($realParams[($pos - 1)]['pass_by_reference'] === true) { - $realName = '&'.$realName; - } - - if ($realName !== $paramName) { - $code = 'ParamNameNoMatch'; - $data = array( - $paramName, - $realName, - $pos, - ); - - $error = 'Doc comment for var %s does not match '; - if (strtolower($paramName) === strtolower($realName)) { - $error .= 'case of '; - $code = 'ParamNameNoCaseMatch'; - } - - $error .= 'actual variable name %s at position %s'; - - $this->currentFile->addError($error, $errorPos, $code, $data); - } - } else { - // We must have an extra parameter comment. - $error = 'Superfluous doc comment at position '.$pos; - $this->currentFile->addError($error, $errorPos, 'ExtraParamComment'); - } - - if ($param->getVarName() === '') { - $error = 'Missing parameter name at position '.$pos; - $this->currentFile->addError($error, $errorPos, 'MissingParamName'); - } - - if ($param->getType() === '') { - $error = 'Missing type at position '.$pos; - $this->currentFile->addError($error, $errorPos, 'MissingParamType'); - } - - if ($paramComment === '') { - $error = 'Missing comment for param "%s" at position %s'; - $data = array( - $paramName, - $pos, - ); - $this->currentFile->addError($error, $errorPos, 'MissingParamComment', $data); - } else { - // Param comments must start with a capital letter and - // end with the full stop. - $firstChar = $paramComment{0}; - if (preg_match('|[A-Z]|', $firstChar) === 0) { - $error = 'Param comment must start with a capital letter'; - $this->currentFile->addError($error, $errorPos, 'ParamCommentNotCapital'); - } - - $lastChar = $paramComment[(strlen($paramComment) - 1)]; - if ($lastChar !== '.') { - $error = 'Param comment must end with a full stop'; - $this->currentFile->addError($error, $errorPos, 'ParamCommentFullStop'); - } - } - - $previousParam = $param; - - }//end foreach - - if ($spaceBeforeVar !== 1 && $spaceBeforeVar !== 10000 && $spaceBeforeComment !== 10000) { - $error = 'Expected 1 space after the longest type'; - $this->currentFile->addError($error, $longestType, 'SpacingAfterLongType'); - } - - if ($spaceBeforeComment !== 1 && $spaceBeforeComment !== 10000) { - $error = 'Expected 1 space after the longest variable name'; - $this->currentFile->addError($error, $longestVar, 'SpacingAfterLongName'); - } - - }//end if - - $realNames = array(); - foreach ($realParams as $realParam) { - $realNames[] = $realParam['name']; - } - - // Report missing comments. - $diff = array_diff($realNames, $foundParams); - foreach ($diff as $neededParam) { - if (count($params) !== 0) { - $errorPos = ($params[(count($params) - 1)]->getLine() + $commentStart); - } else { - $errorPos = $commentStart; - } - - $error = 'Doc comment for "%s" missing'; - $data = array($neededParam); - $this->currentFile->addError($error, $errorPos, 'MissingParamTag', $data); - } - - }//end processParams() - - - /** - * Process a list of unknown tags. - * - * @param int $commentStart The position in the stack where the comment started. - * @param int $commentEnd The position in the stack where the comment ended. - * - * @return void - */ - protected function processUnknownTags($commentStart, $commentEnd) - { - $unknownTags = $this->commentParser->getUnknown(); - foreach ($unknownTags as $errorTag) { - $error = '@%s tag is not allowed in function comment'; - $data = array($errorTag['tag']); - $this->currentFile->addWarning($error, ($commentStart + $errorTag['line']), 'TagNotAllowed', $data); - } - - }//end processUnknownTags - - -}//end class - -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Commenting/FunctionCommentThrowTagSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Commenting/FunctionCommentThrowTagSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Commenting/FunctionCommentThrowTagSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Commenting/FunctionCommentThrowTagSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,215 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -if (class_exists('PHP_CodeSniffer_Standards_AbstractScopeSniff', true) === false) { - $error = 'Class PHP_CodeSniffer_Standards_AbstractScopeSniff not found'; - throw new PHP_CodeSniffer_Exception($error); -} - -/** - * Verifies that a @throws tag exists for a function that throws exceptions. - * Verifies the number of @throws tags and the number of throw tokens matches. - * Verifies the exception type. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_Commenting_FunctionCommentThrowTagSniff extends PHP_CodeSniffer_Standards_AbstractScopeSniff -{ - - - /** - * Constructs a Squiz_Sniffs_Commenting_FunctionCommentThrowTagSniff. - */ - public function __construct() - { - parent::__construct(array(T_FUNCTION), array(T_THROW)); - - }//end __construct() - - - /** - * Processes the function tokens within the class. - * - * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found. - * @param int $stackPtr The position where the token was found. - * @param int $currScope The current scope opener token. - * - * @return void - */ - protected function processTokenWithinScope(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $currScope) - { - // Is this the first throw token within the current function scope? - // If so, we have to validate other throw tokens within the same scope. - $previousThrow = $phpcsFile->findPrevious(T_THROW, ($stackPtr - 1), $currScope); - if ($previousThrow !== false) { - return; - } - - $tokens = $phpcsFile->getTokens(); - - $find = array( - T_COMMENT, - T_DOC_COMMENT, - T_CLASS, - T_FUNCTION, - T_OPEN_TAG, - ); - - $commentEnd = $phpcsFile->findPrevious($find, ($currScope - 1)); - - if ($commentEnd === false) { - return; - } - - if ($tokens[$commentEnd]['code'] !== T_DOC_COMMENT) { - // Function doesn't have a comment. Let someone else warn about that. - return; - } - - $commentStart = ($phpcsFile->findPrevious(T_DOC_COMMENT, ($commentEnd - 1), null, true) + 1); - $comment = $phpcsFile->getTokensAsString($commentStart, ($commentEnd - $commentStart + 1)); - - try { - $this->commentParser = new PHP_CodeSniffer_CommentParser_FunctionCommentParser($comment, $phpcsFile); - $this->commentParser->parse(); - } catch (PHP_CodeSniffer_CommentParser_ParserException $e) { - $line = ($e->getLineWithinComment() + $commentStart); - $phpcsFile->addError($e->getMessage(), $line, 'FailedParse'); - return; - } - - // Find the position where the current function scope ends. - $currScopeEnd = 0; - if (isset($tokens[$currScope]['scope_closer']) === true) { - $currScopeEnd = $tokens[$currScope]['scope_closer']; - } - - // Find all the exception type token within the current scope. - $throwTokens = array(); - $currPos = $stackPtr; - if ($currScopeEnd !== 0) { - while ($currPos < $currScopeEnd && $currPos !== false) { - - /* - If we can't find a NEW, we are probably throwing - a variable, so we ignore it, but they still need to - provide at least one @throws tag, even through we - don't know the exception class. - */ - - $nextToken = $phpcsFile->findNext(T_WHITESPACE, ($currPos + 1), null, true); - if ($tokens[$nextToken]['code'] === T_NEW) { - $currException = $phpcsFile->findNext( - array( - T_NS_SEPARATOR, - T_STRING, - ), - $currPos, - $currScopeEnd, - false, - null, - true - ); - - if ($currException !== false) { - $endException = $phpcsFile->findNext( - array( - T_NS_SEPARATOR, - T_STRING, - ), - ($currException + 1), - $currScopeEnd, - true, - null, - true - ); - - if ($endException === false) { - $throwTokens[] = $tokens[$currException]['content']; - } else { - $throwTokens[] = $phpcsFile->getTokensAsString($currException, ($endException - $currException)); - } - }//end if - }//end if - - $currPos = $phpcsFile->findNext(T_THROW, ($currPos + 1), $currScopeEnd); - }//end while - }//end if - - // Only need one @throws tag for each type of exception thrown. - $throwTokens = array_unique($throwTokens); - sort($throwTokens); - - $throws = $this->commentParser->getThrows(); - if (empty($throws) === true) { - $error = 'Missing @throws tag in function comment'; - $phpcsFile->addError($error, $commentEnd, 'Missing'); - } else if (empty($throwTokens) === true) { - // If token count is zero, it means that only variables are being - // thrown, so we need at least one @throws tag (checked above). - // Nothing more to do. - return; - } else { - $throwTags = array(); - $lineNumber = array(); - foreach ($throws as $throw) { - $throwTags[] = $throw->getValue(); - $lineNumber[$throw->getValue()] = $throw->getLine(); - } - - $throwTags = array_unique($throwTags); - sort($throwTags); - - // Make sure @throws tag count matches throw token count. - $tokenCount = count($throwTokens); - $tagCount = count($throwTags); - if ($tokenCount !== $tagCount) { - $error = 'Expected %s @throws tag(s) in function comment; %s found'; - $data = array( - $tokenCount, - $tagCount, - ); - $phpcsFile->addError($error, $commentEnd, 'WrongNumber', $data); - return; - } else { - // Exception type in @throws tag must be thrown in the function. - foreach ($throwTags as $i => $throwTag) { - $errorPos = ($commentStart + $lineNumber[$throwTag]); - if (empty($throwTag) === false && $throwTag !== $throwTokens[$i]) { - $error = 'Expected "%s" but found "%s" for @throws tag exception'; - $data = array( - $throwTokens[$i], - $throwTag, - ); - $phpcsFile->addError($error, $errorPos, 'WrongType', $data); - } - } - } - }//end if - - }//end processTokenWithinScope() - - -}//end class -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Commenting/InlineCommentSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Commenting/InlineCommentSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Commenting/InlineCommentSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Commenting/InlineCommentSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,271 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_Commenting_InlineCommentSniff. - * - * Checks that there is adequate spacing between comments. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_Commenting_InlineCommentSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - ); - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array( - T_COMMENT, - T_DOC_COMMENT, - ); - - }//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(); - - // If this is a function/class/interface doc block comment, skip it. - // We are only interested in inline doc block comments, which are - // not allowed. - if ($tokens[$stackPtr]['code'] === T_DOC_COMMENT) { - $nextToken = $phpcsFile->findNext( - PHP_CodeSniffer_Tokens::$emptyTokens, - ($stackPtr + 1), - null, - true - ); - - $ignore = array( - T_CLASS, - T_INTERFACE, - T_FUNCTION, - T_PUBLIC, - T_PRIVATE, - T_PROTECTED, - T_FINAL, - T_STATIC, - T_ABSTRACT, - T_CONST, - T_OBJECT, - T_PROPERTY, - ); - - if (in_array($tokens[$nextToken]['code'], $ignore) === true) { - return; - } else { - if ($phpcsFile->tokenizerType === 'JS') { - // We allow block comments if a function is being assigned - // to a variable. - $ignore = PHP_CodeSniffer_Tokens::$emptyTokens; - $ignore[] = T_EQUAL; - $ignore[] = T_STRING; - $ignore[] = T_OBJECT_OPERATOR; - $nextToken = $phpcsFile->findNext($ignore, ($nextToken + 1), null, true); - if ($tokens[$nextToken]['code'] === T_FUNCTION) { - return; - } - } - - $prevToken = $phpcsFile->findPrevious( - PHP_CodeSniffer_Tokens::$emptyTokens, - ($stackPtr - 1), - null, - true - ); - - if ($tokens[$prevToken]['code'] === T_OPEN_TAG) { - return; - } - - // Only error once per comment. - if (substr($tokens[$stackPtr]['content'], 0, 3) === '/**') { - $error = 'Inline doc block comments are not allowed; use "/* Comment */" or "// Comment" instead'; - $phpcsFile->addError($error, $stackPtr, 'DocBlock'); - } - }//end if - }//end if - - if ($tokens[$stackPtr]['content']{0} === '#') { - $error = 'Perl-style comments are not allowed; use "// Comment" instead'; - $phpcsFile->addError($error, $stackPtr, 'WrongStyle'); - } - - // We don't want end of block comments. If the last comment is a closing - // curly brace. - $previousContent = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); - if ($tokens[$previousContent]['line'] === $tokens[$stackPtr]['line']) { - if ($tokens[$previousContent]['code'] === T_CLOSE_CURLY_BRACKET) { - return; - } - - // Special case for JS files. - if ($tokens[$previousContent]['code'] === T_COMMA - || $tokens[$previousContent]['code'] === T_SEMICOLON - ) { - $lastContent = $phpcsFile->findPrevious(T_WHITESPACE, ($previousContent - 1), null, true); - if ($tokens[$lastContent]['code'] === T_CLOSE_CURLY_BRACKET) { - return; - } - } - } - - $comment = rtrim($tokens[$stackPtr]['content']); - - // Only want inline comments. - if (substr($comment, 0, 2) !== '//') { - return; - } - - $spaceCount = 0; - for ($i = 2; $i < strlen($comment); $i++) { - if ($comment[$i] !== ' ') { - break; - } - - $spaceCount++; - } - - if ($spaceCount === 0) { - $error = 'No space before comment text; expected "// %s" but found "%s"'; - $data = array( - substr($comment, 2), - $comment, - ); - $phpcsFile->addError($error, $stackPtr, 'NoSpaceBefore', $data); - } - - if ($spaceCount > 1) { - $error = '%s spaces found before inline comment; expected "// %s" but found "%s"'; - $data = array( - $spaceCount, - substr($comment, (2 + $spaceCount)), - $comment, - ); - $phpcsFile->addError($error, $stackPtr, 'SpacingBefore', $data); - } - - - // The below section determines if a comment block is correctly capitalised, - // and ends in a full-stop. It will find the last comment in a block, and - // work its way up. - $nextComment = $phpcsFile->findNext(array(T_COMMENT), ($stackPtr + 1), null, false); - - if (($nextComment !== false) && (($tokens[$nextComment]['line']) === ($tokens[$stackPtr]['line'] + 1))) { - return; - } - - $topComment = $stackPtr; - $lastComment = $stackPtr; - while (($topComment = $phpcsFile->findPrevious(array(T_COMMENT), ($lastComment - 1), null, false)) !== false) { - if ($tokens[$topComment]['line'] !== ($tokens[$lastComment]['line'] - 1)) { - break; - } - - $lastComment = $topComment; - } - - $topComment = $lastComment; - $commentText = ''; - - for ($i = $topComment; $i <= $stackPtr; $i++) { - if ($tokens[$i]['code'] === T_COMMENT) { - $commentText .= trim(substr($tokens[$i]['content'], 2)); - } - } - - if ($commentText === '') { - $error = 'Blank comments are not allowed'; - $phpcsFile->addError($error, $stackPtr, 'Empty'); - return; - } - - if (preg_match('|[A-Z]|', $commentText[0]) === 0) { - $error = 'Inline comments must start with a capital letter'; - $phpcsFile->addError($error, $topComment, 'NotCapital'); - } - - $commentCloser = $commentText[(strlen($commentText) - 1)]; - $acceptedClosers = array( - 'full-stops' => '.', - 'exclamation marks' => '!', - 'or question marks' => '?', - ); - - if (in_array($commentCloser, $acceptedClosers) === false) { - $error = 'Inline comments must end in %s'; - $ender = ''; - foreach ($acceptedClosers as $closerName => $symbol) { - $ender .= ' '.$closerName.','; - } - - $ender = rtrim($ender, ','); - $data = array($ender); - $phpcsFile->addError($error, $stackPtr, 'InvalidEndChar', $data); - } - - // Finally, the line below the last comment cannot be empty. - $start = false; - for ($i = ($stackPtr + 1); $i < $phpcsFile->numTokens; $i++) { - if ($tokens[$i]['line'] === ($tokens[$stackPtr]['line'] + 1)) { - if ($tokens[$i]['code'] !== T_WHITESPACE) { - return; - } - } else if ($tokens[$i]['line'] > ($tokens[$stackPtr]['line'] + 1)) { - break; - } - } - - $error = 'There must be no blank line following an inline comment'; - $phpcsFile->addError($error, $stackPtr, 'SpacingAfter'); - - }//end process() - - -}//end class - - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Commenting/LongConditionClosingCommentSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Commenting/LongConditionClosingCommentSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Commenting/LongConditionClosingCommentSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Commenting/LongConditionClosingCommentSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,191 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_ControlStructures_LongConditionClosingCommentSniff. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_Commenting_LongConditionClosingCommentSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - ); - - /** - * The openers that we are interested in. - * - * @var array(int) - */ - private static $_openers = array( - T_SWITCH, - T_IF, - T_FOR, - T_FOREACH, - T_WHILE, - T_TRY, - T_CASE, - ); - - /** - * The length that a code block must be before - * requiring a closing comment. - * - * @var int - */ - protected $lineLimit = 20; - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array(T_CLOSE_CURLY_BRACKET); - - }//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(); - - if (isset($tokens[$stackPtr]['scope_condition']) === false) { - // No scope condition. It is a function closer. - return; - } - - $startCondition = $tokens[$tokens[$stackPtr]['scope_condition']]; - $startBrace = $tokens[$tokens[$stackPtr]['scope_opener']]; - $endBrace = $tokens[$stackPtr]; - - // We are only interested in some code blocks. - if (in_array($startCondition['code'], self::$_openers) === false) { - return; - } - - if ($startCondition['code'] === T_IF) { - // If this is actually and ELSE IF, skip it as the brace - // will be checked by the original IF. - $else = $phpcsFile->findPrevious(T_WHITESPACE, ($tokens[$stackPtr]['scope_condition'] - 1), null, true); - if ($tokens[$else]['code'] === T_ELSE) { - return; - } - - // IF statements that have an ELSE block need to use - // "end if" rather than "end else" or "end elseif". - do { - $nextToken = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); - if ($tokens[$nextToken]['code'] === T_ELSE || $tokens[$nextToken]['code'] === T_ELSEIF) { - // Check for ELSE IF (2 tokens) as opposed to ELSEIF (1 token). - if ($tokens[$nextToken]['code'] === T_ELSE - && isset($tokens[$nextToken]['scope_closer']) === false - ) { - $nextToken = $phpcsFile->findNext(T_WHITESPACE, ($nextToken + 1), null, true); - if ($tokens[$nextToken]['code'] !== T_IF - || isset($tokens[$nextToken]['scope_closer']) === false - ) { - // Not an ELSE IF or is an inline ELSE IF. - break; - } - } - - // The end brace becomes the ELSE's end brace. - $stackPtr = $tokens[$nextToken]['scope_closer']; - $endBrace = $tokens[$stackPtr]; - } else { - break; - } - } while (isset($tokens[$nextToken]['scope_closer']) === true); - }//end if - - if ($startCondition['code'] === T_TRY) { - // TRY statements need to check until the end of all CATCH statements. - do { - $nextToken = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); - if ($tokens[$nextToken]['code'] === T_CATCH) { - // The end brace becomes the CATCH's end brace. - $stackPtr = $tokens[$nextToken]['scope_closer']; - $endBrace = $tokens[$stackPtr]; - } else { - break; - } - } while (isset($tokens[$nextToken]['scope_closer']) === true); - } - - $lineDifference = ($endBrace['line'] - $startBrace['line']); - - $expected = '//end '.$startCondition['content']; - $comment = $phpcsFile->findNext(array(T_COMMENT), $stackPtr, null, false); - - if (($comment === false) || ($tokens[$comment]['line'] !== $endBrace['line'])) { - if ($lineDifference >= $this->lineLimit) { - $error = 'End comment for long condition not found; expected "%s"'; - $data = array($expected); - $phpcsFile->addError($error, $stackPtr, 'Missing', $data); - } - - return; - } - - if (($comment - $stackPtr) !== 1) { - $error = 'Space found before closing comment; expected "%s"'; - $data = array($expected); - $phpcsFile->addError($error, $stackPtr, 'SpacingBefore', $data); - } - - if (trim($tokens[$comment]['content']) !== $expected) { - $found = trim($tokens[$comment]['content']); - $error = 'Incorrect closing comment; expected "%s" but found "%s"'; - $data = array( - $expected, - $found, - ); - $phpcsFile->addError($error, $stackPtr, 'Invalid', $data); - return; - } - - }//end process() - - -}//end class - - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Commenting/PostStatementCommentSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Commenting/PostStatementCommentSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Commenting/PostStatementCommentSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Commenting/PostStatementCommentSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,103 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_Commenting_PostStatementCommentSniff. - * - * Checks to ensure that there are no comments after statements. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_Commenting_PostStatementCommentSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - ); - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array(T_COMMENT); - - }//end register() - - - /** - * Processes this sniff, 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(); - - if (substr($tokens[$stackPtr]['content'], 0, 2) !== '//') { - return; - } - - $commentLine = $tokens[$stackPtr]['line']; - $lastContent = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); - - if ($tokens[$lastContent]['line'] !== $commentLine) { - return; - } - - if ($tokens[$lastContent]['code'] === T_CLOSE_CURLY_BRACKET) { - return; - } - - // Special case for JS files. - if ($tokens[$lastContent]['code'] === T_COMMA - || $tokens[$lastContent]['code'] === T_SEMICOLON - ) { - $lastContent = $phpcsFile->findPrevious(T_WHITESPACE, ($lastContent - 1), null, true); - if ($tokens[$lastContent]['code'] === T_CLOSE_CURLY_BRACKET) { - return; - } - } - - $error = 'Comments may not appear after statements.'; - $phpcsFile->addError($error, $stackPtr, 'Found'); - - }//end process() - - -}//end class - - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,347 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -if (class_exists('PHP_CodeSniffer_Standards_AbstractVariableSniff', true) === false) { - throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_Standards_AbstractVariableSniff not found'); -} - -if (class_exists('PHP_CodeSniffer_CommentParser_MemberCommentParser', true) === false) { - throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_CommentParser_MemberCommentParser not found'); -} - -/** - * Parses and verifies the variable doc comment. - * - * Verifies that : - *
    - *
  • A variable doc comment exists.
  • - *
  • Short description ends with a full stop.
  • - *
  • There is a blank line after the short description.
  • - *
  • There is a blank line between the description and the tags.
  • - *
  • Check the order, indentation and content of each tag.
  • - *
- * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -class Squiz_Sniffs_Commenting_VariableCommentSniff extends PHP_CodeSniffer_Standards_AbstractVariableSniff -{ - - /** - * The header comment parser for the current file. - * - * @var PHP_CodeSniffer_Comment_Parser_ClassCommentParser - */ - protected $commentParser = null; - - - /** - * Called to process class member vars. - * - * @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 processMemberVar(PHP_CodeSniffer_File $phpcsFile, $stackPtr) - { - $this->currentFile = $phpcsFile; - $tokens = $phpcsFile->getTokens(); - $commentToken = array( - T_COMMENT, - T_DOC_COMMENT, - ); - - // Extract the var comment docblock. - $commentEnd = $phpcsFile->findPrevious($commentToken, ($stackPtr - 3)); - if ($commentEnd !== false && $tokens[$commentEnd]['code'] === T_COMMENT) { - $phpcsFile->addError('You must use "/**" style comments for a variable comment', $stackPtr, 'WrongStyle'); - return; - } else if ($commentEnd === false || $tokens[$commentEnd]['code'] !== T_DOC_COMMENT) { - $phpcsFile->addError('Missing variable doc comment', $stackPtr, 'Missing'); - return; - } else { - // Make sure the comment we have found belongs to us. - $commentFor = $phpcsFile->findNext(array(T_VARIABLE, T_CLASS, T_INTERFACE), ($commentEnd + 1)); - if ($commentFor !== $stackPtr) { - $phpcsFile->addError('Missing variable doc comment', $stackPtr, 'Missing'); - return; - } - } - - $commentStart = ($phpcsFile->findPrevious(T_DOC_COMMENT, ($commentEnd - 1), null, true) + 1); - $commentString = $phpcsFile->getTokensAsString($commentStart, ($commentEnd - $commentStart + 1)); - - // Parse the header comment docblock. - try { - $this->commentParser = new PHP_CodeSniffer_CommentParser_MemberCommentParser($commentString, $phpcsFile); - $this->commentParser->parse(); - } catch (PHP_CodeSniffer_CommentParser_ParserException $e) { - $line = ($e->getLineWithinComment() + $commentStart); - $phpcsFile->addError($e->getMessage(), $line, 'ErrorParsing'); - return; - } - - $comment = $this->commentParser->getComment(); - if (is_null($comment) === true) { - $error = 'Variable doc comment is empty'; - $phpcsFile->addError($error, $commentStart, 'Empty'); - return; - } - - // The first line of the comment should just be the /** code. - $eolPos = strpos($commentString, $phpcsFile->eolChar); - $firstLine = substr($commentString, 0, $eolPos); - if ($firstLine !== '/**') { - $error = 'The open comment tag must be the only content on the line'; - $phpcsFile->addError($error, $commentStart, 'ContentAfterOpen'); - } - - // Check for a comment description. - $short = $comment->getShortComment(); - $long = ''; - if (trim($short) === '') { - $error = 'Missing short description in variable doc comment'; - $phpcsFile->addError($error, $commentStart, 'MissingShort'); - $newlineCount = 1; - } else { - // No extra newline before short description. - $newlineCount = 0; - $newlineSpan = strspn($short, $phpcsFile->eolChar); - if ($short !== '' && $newlineSpan > 0) { - $error = 'Extra newline(s) found before variable comment short description'; - $phpcsFile->addError($error, ($commentStart + 1), 'SpacingBeforeShort'); - } - - $newlineCount = (substr_count($short, $phpcsFile->eolChar) + 1); - - // Exactly one blank line between short and long description. - $long = $comment->getLongComment(); - if (empty($long) === false) { - $between = $comment->getWhiteSpaceBetween(); - $newlineBetween = substr_count($between, $phpcsFile->eolChar); - if ($newlineBetween !== 2) { - $error = 'There must be exactly one blank line between descriptions in variable comment'; - $phpcsFile->addError($error, ($commentStart + $newlineCount + 1), 'SpacingBetween'); - } - - $newlineCount += $newlineBetween; - - $testLong = trim($long); - if (preg_match('|[A-Z]|', $testLong[0]) === 0) { - $error = 'Variable comment long description must start with a capital letter'; - $phpcsFile->addError($error, ($commentStart + $newlineCount), 'LongNotCapital'); - } - }//end if - - // Short description must be single line and end with a full stop. - $testShort = trim($short); - $lastChar = $testShort[(strlen($testShort) - 1)]; - if (substr_count($testShort, $phpcsFile->eolChar) !== 0) { - $error = 'Variable comment short description must be on a single line'; - $phpcsFile->addError($error, ($commentStart + 1), 'ShortSingleLine'); - } - - if (preg_match('|[A-Z]|', $testShort[0]) === 0) { - $error = 'Variable comment short description must start with a capital letter'; - $phpcsFile->addError($error, ($commentStart + 1), 'ShortNotCapital'); - } - - if ($lastChar !== '.') { - $error = 'Variable comment short description must end with a full stop'; - $phpcsFile->addError($error, ($commentStart + 1), 'ShortFullStop'); - } - }//end if - - // Exactly one blank line before tags. - $tags = $this->commentParser->getTagOrders(); - if (count($tags) > 1) { - $newlineSpan = $comment->getNewlineAfter(); - if ($newlineSpan !== 2) { - $error = 'There must be exactly one blank line before the tags in variable comment'; - if ($long !== '') { - $newlineCount += (substr_count($long, $phpcsFile->eolChar) - $newlineSpan + 1); - } - - $phpcsFile->addError($error, ($commentStart + $newlineCount), 'SpacingBeforeTags'); - $short = rtrim($short, $phpcsFile->eolChar.' '); - } - } - - // Check for unknown/deprecated tags. - $unknownTags = $this->commentParser->getUnknown(); - foreach ($unknownTags as $errorTag) { - // Unknown tags are not parsed, do not process further. - $error = '@%s tag is not allowed in variable comment'; - $data = array($errorTag['tag']); - $phpcsFile->addWarning($error, ($commentStart + $errorTag['line']), 'TagNotAllowed', $data); - } - - // Check each tag. - $this->processVar($commentStart, $commentEnd); - $this->processSees($commentStart); - - // The last content should be a newline and the content before - // that should not be blank. If there is more blank space - // then they have additional blank lines at the end of the comment. - $words = $this->commentParser->getWords(); - $lastPos = (count($words) - 1); - if (trim($words[($lastPos - 1)]) !== '' - || strpos($words[($lastPos - 1)], $this->currentFile->eolChar) === false - || trim($words[($lastPos - 2)]) === '' - ) { - $error = 'Additional blank lines found at end of variable comment'; - $this->currentFile->addError($error, $commentEnd, 'SpacingAfter'); - } - - }//end processMemberVar() - - - /** - * Process the var tag. - * - * @param int $commentStart The position in the stack where the comment started. - * @param int $commentEnd The position in the stack where the comment ended. - * - * @return void - */ - protected function processVar($commentStart, $commentEnd) - { - $var = $this->commentParser->getVar(); - - if ($var !== null) { - $errorPos = ($commentStart + $var->getLine()); - $index = array_keys($this->commentParser->getTagOrders(), 'var'); - - if (count($index) > 1) { - $error = 'Only 1 @var tag is allowed in variable comment'; - $this->currentFile->addError($error, $errorPos, 'DuplicateVar'); - return; - } - - if ($index[0] !== 1) { - $error = 'The @var tag must be the first tag in a variable comment'; - $this->currentFile->addError($error, $errorPos, 'VarOrder'); - } - - $content = $var->getContent(); - if (empty($content) === true) { - $error = 'Var type missing for @var tag in variable comment'; - $this->currentFile->addError($error, $errorPos, 'MissingVarType'); - return; - } else { - $suggestedType = PHP_CodeSniffer::suggestType($content); - if ($content !== $suggestedType) { - $error = 'Expected "%s"; found "%s" for @var tag in variable comment'; - $data = array( - $suggestedType, - $content, - ); - $this->currentFile->addError($error, $errorPos, 'IncorrectVarType', $data); - } - } - - $spacing = substr_count($var->getWhitespaceBeforeContent(), ' '); - if ($spacing !== 1) { - $error = '@var tag indented incorrectly; expected 1 space but found %s'; - $data = array($spacing); - $this->currentFile->addError($error, $errorPos, 'VarIndent', $data); - } - } else { - $error = 'Missing @var tag in variable comment'; - $this->currentFile->addError($error, $commentEnd, 'MissingVar'); - }//end if - - }//end processVar() - - - /** - * Process the see tags. - * - * @param int $commentStart The position in the stack where the comment started. - * - * @return void - */ - protected function processSees($commentStart) - { - $sees = $this->commentParser->getSees(); - if (empty($sees) === false) { - foreach ($sees as $see) { - $errorPos = ($commentStart + $see->getLine()); - $content = $see->getContent(); - if (empty($content) === true) { - $error = 'Content missing for @see tag in variable comment'; - $this->currentFile->addError($error, $errorPos, 'EmptySees'); - continue; - } - - $spacing = substr_count($see->getWhitespaceBeforeContent(), ' '); - if ($spacing !== 1) { - $error = '@see tag indented incorrectly; expected 1 spaces but found %s'; - $data = array($spacing); - $this->currentFile->addError($error, $errorPos, 'SeesIndent', $data); - } - } - } - - }//end processSees() - - - /** - * Called to process a normal variable. - * - * Not required for this sniff. - * - * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where this token was found. - * @param int $stackPtr The position where the double quoted - * string was found. - * - * @return void - */ - protected function processVariable(PHP_CodeSniffer_File $phpcsFile, $stackPtr) - { - return; - - }//end processVariable() - - - /** - * Called to process variables found in duoble quoted strings. - * - * Not required for this sniff. - * - * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where this token was found. - * @param int $stackPtr The position where the double quoted - * string was found. - * - * @return void - */ - protected function processVariableInString(PHP_CodeSniffer_File $phpcsFile, $stackPtr) - { - return; - - }//end processVariableInString() - - -}//end class -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/ControlSignatureSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/ControlSignatureSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/ControlSignatureSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/ControlSignatureSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,69 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -if (class_exists('PHP_CodeSniffer_Standards_AbstractPatternSniff', true) === false) { - throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_Standards_AbstractPatternSniff not found'); -} - -/** - * Verifies that control statements conform to their coding standards. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_ControlStructures_ControlSignatureSniff extends PHP_CodeSniffer_Standards_AbstractPatternSniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - ); - - - /** - * Returns the patterns that this test wishes to verify. - * - * @return array(string) - */ - protected function getPatterns() - { - return array( - 'try {EOL...} catch (...) {EOL', - 'do {EOL...} while (...);EOL', - 'while (...) {EOL', - 'for (...) {EOL', - 'if (...) {EOL', - 'foreach (...) {EOL', - '} else if (...) {EOL', - '} else {EOL', - ); - - }//end getPatterns() - - -}//end class - -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/ElseIfDeclarationSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/ElseIfDeclarationSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/ElseIfDeclarationSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/ElseIfDeclarationSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,67 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_ControlStructures_ElseIfDeclarationSniff. - * - * Verifies that there are not elseif statements. The else and the if should - * be separated by a space. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_ControlStructures_ElseIfDeclarationSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array(T_ELSEIF); - - }//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) - { - $error = 'Usage of ELSEIF not allowed; use ELSE IF instead'; - $phpcsFile->addError($error, $stackPtr, 'NotAllowed'); - - }//end process() - - -}//end class - - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/ForEachLoopDeclarationSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/ForEachLoopDeclarationSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/ForEachLoopDeclarationSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/ForEachLoopDeclarationSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,144 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_ControlStructures_ForEachLoopDeclarationSniff. - * - * Verifies that there is a space between each condition of foreach loops. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_ControlStructures_ForEachLoopDeclarationSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array(T_FOREACH); - - }//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(); - - $openingBracket = $phpcsFile->findNext(T_OPEN_PARENTHESIS, $stackPtr); - $closingBracket = $tokens[$openingBracket]['parenthesis_closer']; - - if ($tokens[($openingBracket + 1)]['code'] === T_WHITESPACE) { - $error = 'Space found after opening bracket of FOREACH loop'; - $phpcsFile->addError($error, $stackPtr, 'SpaceAfterOpen'); - } - - if ($tokens[($closingBracket - 1)]['code'] === T_WHITESPACE) { - $error = 'Space found before closing bracket of FOREACH loop'; - $phpcsFile->addError($error, $stackPtr, 'SpaceBeforeClose'); - } - - $asToken = $phpcsFile->findNext(T_AS, $openingBracket); - $content = $tokens[$asToken]['content']; - if ($content !== strtolower($content)) { - $expected = strtolower($content); - $error = 'AS keyword must be lowercase; expected "%s" but found "%s"'; - $data = array( - $expected, - $content, - ); - $phpcsFile->addError($error, $stackPtr, 'AsNotLower', $data); - } - - $doubleArrow = $phpcsFile->findNext(T_DOUBLE_ARROW, $openingBracket, $closingBracket); - - if ($doubleArrow !== false) { - if ($tokens[($doubleArrow - 1)]['code'] !== T_WHITESPACE) { - $error = 'Expected 1 space before "=>"; 0 found'; - $phpcsFile->addError($error, $stackPtr, 'NoSpaceBeforeArrow'); - } else { - if (strlen($tokens[($doubleArrow - 1)]['content']) !== 1) { - $spaces = strlen($tokens[($doubleArrow - 1)]['content']); - $error = 'Expected 1 space before "=>"; %s found'; - $data = array($spaces); - $phpcsFile->addError($error, $stackPtr, 'SpacingBeforeArrow', $data); - } - - } - - if ($tokens[($doubleArrow + 1)]['code'] !== T_WHITESPACE) { - $error = 'Expected 1 space after "=>"; 0 found'; - $phpcsFile->addError($error, $stackPtr, 'NoSpaceAfterArrow'); - } else { - if (strlen($tokens[($doubleArrow + 1)]['content']) !== 1) { - $spaces = strlen($tokens[($doubleArrow + 1)]['content']); - $error = 'Expected 1 space after "=>"; %s found'; - $data = array($spaces); - $phpcsFile->addError($error, $stackPtr, 'SpacingAfterArrow', $data); - } - - } - - }//end if - - if ($tokens[($asToken - 1)]['code'] !== T_WHITESPACE) { - $error = 'Expected 1 space before "as"; 0 found'; - $phpcsFile->addError($error, $stackPtr, 'NoSpaceBeforeAs'); - } else { - if (strlen($tokens[($asToken - 1)]['content']) !== 1) { - $spaces = strlen($tokens[($asToken - 1)]['content']); - $error = 'Expected 1 space before "as"; %s found'; - $data = array($spaces); - $phpcsFile->addError($error, $stackPtr, 'SpacingBeforeAs', $data); - } - } - - if ($tokens[($asToken + 1)]['code'] !== T_WHITESPACE) { - $error = 'Expected 1 space after "as"; 0 found'; - $phpcsFile->addError($error, $stackPtr, 'NoSpaceAfterAs'); - } else { - if (strlen($tokens[($asToken + 1)]['content']) !== 1) { - $spaces = strlen($tokens[($asToken + 1)]['content']); - $error = 'Expected 1 space after "as"; %s found'; - $data = array($spaces); - $phpcsFile->addError($error, $stackPtr, 'SpacingAfterAs', $data); - } - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/ForLoopDeclarationSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/ForLoopDeclarationSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/ForLoopDeclarationSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/ForLoopDeclarationSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,136 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_ControlStructures_ForLoopDeclarationSniff. - * - * Verifies that there is a space between each condition of for loops. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_ControlStructures_ForLoopDeclarationSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - ); - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array(T_FOR); - - }//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(); - - $openingBracket = $phpcsFile->findNext(T_OPEN_PARENTHESIS, $stackPtr); - if ($openingBracket === false) { - $error = 'Possible parse error: no opening parenthesis for FOR keyword'; - $phpcsFile->addWarning($error, $stackPtr, 'NoOpenBracket'); - return; - } - - $closingBracket = $tokens[$openingBracket]['parenthesis_closer']; - - if ($tokens[($openingBracket + 1)]['code'] === T_WHITESPACE) { - $error = 'Space found after opening bracket of FOR loop'; - $phpcsFile->addError($error, $stackPtr, 'SpacingAfterOpen'); - } - - if ($tokens[($closingBracket - 1)]['code'] === T_WHITESPACE) { - $error = 'Space found before closing bracket of FOR loop'; - $phpcsFile->addError($error, $stackPtr, 'SpacingBeforeClose'); - } - - $firstSemicolon = $phpcsFile->findNext(T_SEMICOLON, $openingBracket, $closingBracket); - - // Check whitespace around each of the tokens. - if ($firstSemicolon !== false) { - if ($tokens[($firstSemicolon - 1)]['code'] === T_WHITESPACE) { - $error = 'Space found before first semicolon of FOR loop'; - $phpcsFile->addError($error, $stackPtr, 'SpacingBeforeFirst'); - } - - if ($tokens[($firstSemicolon + 1)]['code'] !== T_WHITESPACE) { - $error = 'Expected 1 space after first semicolon of FOR loop; 0 found'; - $phpcsFile->addError($error, $stackPtr, 'NoSpaceAfterFirst'); - } else { - if (strlen($tokens[($firstSemicolon + 1)]['content']) !== 1) { - $spaces = strlen($tokens[($firstSemicolon + 1)]['content']); - $error = 'Expected 1 space after first semicolon of FOR loop; %s found'; - $data = array($spaces); - $phpcsFile->addError($error, $stackPtr, 'SpacingAfterFirst', $data); - } - } - - $secondSemicolon = $phpcsFile->findNext(T_SEMICOLON, ($firstSemicolon + 1)); - - if ($secondSemicolon !== false) { - if ($tokens[($secondSemicolon - 1)]['code'] === T_WHITESPACE) { - $error = 'Space found before second semicolon of FOR loop'; - $phpcsFile->addError($error, $stackPtr, 'SpacingBeforeSecond'); - } - - if ($tokens[($secondSemicolon + 1)]['code'] !== T_WHITESPACE) { - $error = 'Expected 1 space after second semicolon of FOR loop; 0 found'; - $phpcsFile->addError($error, $stackPtr, 'NoSpaceAfterSecond'); - } else { - if (strlen($tokens[($secondSemicolon + 1)]['content']) !== 1) { - $spaces = strlen($tokens[($firstSemicolon + 1)]['content']); - $error = 'Expected 1 space after second semicolon of FOR loop; %s found'; - $data = array($spaces); - $phpcsFile->addError($error, $stackPtr, 'SpacingAfterSecond', $data); - } - } - }//end if - }//end if - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/InlineIfDeclarationSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/InlineIfDeclarationSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/InlineIfDeclarationSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/InlineIfDeclarationSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,141 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_ControlStructures_InlineIfDeclarationSniff. - * - * Tests the spacing of shorthand IF statements. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_ControlStructures_InlineIfDeclarationSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array(T_INLINE_THEN); - - }//end register() - - - /** - * Processes this sniff, 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 the opening bracket of the inline IF. - for ($i = ($stackPtr - 1); $i > 0; $i--) { - if (isset($tokens[$i]['parenthesis_opener']) === true - && $tokens[$i]['parenthesis_opener'] < $i - ) { - $i = $tokens[$i]['parenthesis_opener']; - continue; - } - - if ($tokens[$i]['code'] === T_OPEN_PARENTHESIS) { - break; - } - } - - if ($i <= 0) { - // Could not find the begining of the statement. Probably not - // wrapped with brackets, so assume it ends with a semicolon. - $statementEnd = $phpcsFile->findNext(T_SEMICOLON, ($stackPtr + 1)); - } else { - $statementEnd = $tokens[$i]['parenthesis_closer']; - } - - // Make sure it's all on the same line. - if ($tokens[$statementEnd]['line'] !== $tokens[$stackPtr]['line']) { - $error = 'Inline shorthand IF statement must be declared on a single line'; - $phpcsFile->addError($error, $stackPtr, 'NotSingleLine'); - return; - } - - // Make sure there are spaces around the question mark. - $contentBefore = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); - $contentAfter = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); - if ($tokens[$contentBefore]['code'] !== T_CLOSE_PARENTHESIS) { - $error = 'Inline shorthand IF statement requires brackets around comparison'; - $phpcsFile->addError($error, $stackPtr, 'NoBrackets'); - return; - } - - $spaceBefore = ($tokens[$stackPtr]['column'] - ($tokens[$contentBefore]['column'] + strlen($tokens[$contentBefore]['content']))); - if ($spaceBefore !== 1) { - $error = 'Inline shorthand IF statement requires 1 space before THEN; %s found'; - $data = array($spaceBefore); - $phpcsFile->addError($error, $stackPtr, 'SpacingBeforeThen', $data); - } - - $spaceAfter = (($tokens[$contentAfter]['column']) - ($tokens[$stackPtr]['column'] + 1)); - if ($spaceAfter !== 1) { - $error = 'Inline shorthand IF statement requires 1 space after THEN; %s found'; - $data = array($spaceAfter); - $phpcsFile->addError($error, $stackPtr, 'SpacingAfterThen', $data); - } - - // If there is an else in this condition, make sure it has correct spacing. - $inlineElse = $phpcsFile->findNext(T_COLON, ($stackPtr + 1), $statementEnd, false); - if ($inlineElse === false) { - // No else condition. - return; - } - - $contentBefore = $phpcsFile->findPrevious(T_WHITESPACE, ($inlineElse - 1), null, true); - $contentAfter = $phpcsFile->findNext(T_WHITESPACE, ($inlineElse + 1), null, true); - - $spaceBefore = ($tokens[$inlineElse]['column'] - ($tokens[$contentBefore]['column'] + strlen($tokens[$contentBefore]['content']))); - if ($spaceBefore !== 1) { - $error = 'Inline shorthand IF statement requires 1 space before ELSE; %s found'; - $data = array($spaceBefore); - $phpcsFile->addError($error, $inlineElse, 'SpacingBeforeElse', $data); - } - - $spaceAfter = (($tokens[$contentAfter]['column']) - ($tokens[$inlineElse]['column'] + 1)); - if ($spaceAfter !== 1) { - $error = 'Inline shorthand IF statement requires 1 space after ELSE; %s found'; - $data = array($spaceAfter); - $phpcsFile->addError($error, $inlineElse, 'SpacingAfterElse', $data); - } - - }//end process() - - -}//end class - - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/LowercaseDeclarationSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/LowercaseDeclarationSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/LowercaseDeclarationSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/LowercaseDeclarationSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,86 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_ControlStructures_LowercaseDeclarationSniff. - * - * Ensures all control structure keywords are lowercase. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_ControlStructures_LowercaseDeclarationSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array( - T_IF, - T_ELSE, - T_ELSEIF, - T_FOREACH, - T_FOR, - T_DO, - T_SWITCH, - T_WHILE, - T_TRY, - T_CATCH, - ); - - }//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(); - - $content = $tokens[$stackPtr]['content']; - if ($content !== strtolower($content)) { - $error = '%s keyword must be lowercase; expected "%s" but found "%s"'; - $data = array( - strtoupper($content), - strtolower($content), - $content, - ); - $phpcsFile->addError($error, $stackPtr, 'FoundUppercase', $data); - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/SwitchDeclarationSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/SwitchDeclarationSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/SwitchDeclarationSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/SwitchDeclarationSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,255 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_ControlStructures_SwitchDeclarationSniff. - * - * Ensures all the breaks and cases are aligned correctly according to their - * parent switch's alignment and enforces other switch formatting. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_ControlStructures_SwitchDeclarationSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - ); - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array(T_SWITCH); - - }//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(); - - // We can't process SWITCH statements unless we know where they start and end. - if (isset($tokens[$stackPtr]['scope_opener']) === false - || isset($tokens[$stackPtr]['scope_closer']) === false - ) { - return; - } - - $switch = $tokens[$stackPtr]; - $nextCase = $stackPtr; - $caseAlignment = ($switch['column'] + 4); - $caseCount = 0; - $foundDefault = false; - - while (($nextCase = $phpcsFile->findNext(array(T_CASE, T_DEFAULT, T_SWITCH), ($nextCase + 1), $switch['scope_closer'])) !== false) { - // Skip nested SWITCH statements; they are handled on their own. - if ($tokens[$nextCase]['code'] === T_SWITCH) { - $nextCase = $tokens[$nextCase]['scope_closer']; - continue; - } - - if ($tokens[$nextCase]['code'] === T_DEFAULT) { - $type = 'Default'; - $foundDefault = true; - } else { - $type = 'Case'; - $caseCount++; - } - - if ($tokens[$nextCase]['content'] !== strtolower($tokens[$nextCase]['content'])) { - $expected = strtolower($tokens[$nextCase]['content']); - $error = strtoupper($type).' keyword must be lowercase; expected "%s" but found "%s"'; - $data = array( - $expected, - $tokens[$nextCase]['content'], - ); - $phpcsFile->addError($error, $nextCase, $type.'NotLower', $data); - } - - if ($tokens[$nextCase]['column'] !== $caseAlignment) { - $error = strtoupper($type).' keyword must be indented 4 spaces from SWITCH keyword'; - $phpcsFile->addError($error, $nextCase, $type.'Indent'); - } - - if ($type === 'Case' - && ($tokens[($nextCase + 1)]['type'] !== 'T_WHITESPACE' - || $tokens[($nextCase + 1)]['content'] !== ' ') - ) { - $error = 'CASE keyword must be followed by a single space'; - $phpcsFile->addError($error, $nextCase, 'SpacingAfterCase'); - } - - $opener = $tokens[$nextCase]['scope_opener']; - if ($tokens[($opener - 1)]['type'] === 'T_WHITESPACE') { - $error = 'There must be no space before the colon in a '.strtoupper($type).' statement'; - $phpcsFile->addError($error, $nextCase, 'SpaceBeforeColon'.$type); - } - - $nextBreak = $tokens[$nextCase]['scope_closer']; - if ($tokens[$nextBreak]['code'] === T_BREAK) { - if ($tokens[$nextBreak]['scope_condition'] === $nextCase) { - // Only need to check a couple of things once, even if the - // break is shared between multiple case statements, or even - // the default case. - if ($tokens[$nextBreak]['column'] !== $caseAlignment) { - $error = 'BREAK statement must be indented 4 spaces from SWITCH keyword'; - $phpcsFile->addError($error, $nextBreak, 'BreakIndent'); - } - - $breakLine = $tokens[$nextBreak]['line']; - $prevLine = 0; - for ($i = ($nextBreak - 1); $i > $stackPtr; $i--) { - if ($tokens[$i]['type'] !== 'T_WHITESPACE') { - $prevLine = $tokens[$i]['line']; - break; - } - } - - if ($prevLine !== ($breakLine - 1)) { - $error = 'Blank lines are not allowed before BREAK statements'; - $phpcsFile->addError($error, $nextBreak, 'SpacingBeforeBreak'); - } - - $breakLine = $tokens[$nextBreak]['line']; - $nextLine = $tokens[$tokens[$stackPtr]['scope_closer']]['line']; - $semicolon = $phpcsFile->findNext(T_SEMICOLON, $nextBreak); - for ($i = ($semicolon + 1); $i < $tokens[$stackPtr]['scope_closer']; $i++) { - if ($tokens[$i]['type'] !== 'T_WHITESPACE') { - $nextLine = $tokens[$i]['line']; - break; - } - } - - if ($type === 'Case') { - // Ensure the BREAK statement is followed by - // a single blank line, or the end switch brace. - if ($nextLine !== ($breakLine + 2) && $i !== $tokens[$stackPtr]['scope_closer']) { - $error = 'BREAK statements must be followed by a single blank line'; - $phpcsFile->addError($error, $nextBreak, 'SpacingAfterBreak'); - } - } else { - // Ensure the BREAK statement is not followed by a blank line. - if ($nextLine !== ($breakLine + 1)) { - $error = 'Blank lines are not allowed after the DEFAULT case\'s BREAK statement'; - $phpcsFile->addError($error, $nextBreak, 'SpacingAfterDefaultBreak'); - } - } - - $caseLine = $tokens[$nextCase]['line']; - $nextLine = $tokens[$nextBreak]['line']; - for ($i = ($opener + 1); $i < $nextBreak; $i++) { - if ($tokens[$i]['type'] !== 'T_WHITESPACE') { - $nextLine = $tokens[$i]['line']; - break; - } - } - - if ($nextLine !== ($caseLine + 1)) { - $error = 'Blank lines are not allowed after '.strtoupper($type).' statements'; - $phpcsFile->addError($error, $nextCase, 'SpacingAfter'.$type); - } - }//end if - - if ($type === 'Case') { - // Ensure empty CASE statements are not allowed. - // They must have some code content in them. A comment is not enough. - $foundContent = false; - for ($i = ($tokens[$nextCase]['scope_opener'] + 1); $i < $nextBreak; $i++) { - if ($tokens[$i]['code'] === T_CASE) { - $i = $tokens[$i]['scope_opener']; - continue; - } - - if (in_array($tokens[$i]['code'], PHP_CodeSniffer_Tokens::$emptyTokens) === false) { - $foundContent = true; - break; - } - } - - if ($foundContent === false) { - $error = 'Empty CASE statements are not allowed'; - $phpcsFile->addError($error, $nextCase, 'EmptyCase'); - } - } else { - // Ensure empty DEFAULT statements are not allowed. - // They must (at least) have a comment describing why - // the default case is being ignored. - $foundContent = false; - for ($i = ($tokens[$nextCase]['scope_opener'] + 1); $i < $nextBreak; $i++) { - if ($tokens[$i]['type'] !== 'T_WHITESPACE') { - $foundContent = true; - break; - } - } - - if ($foundContent === false) { - $error = 'Comment required for empty DEFAULT case'; - $phpcsFile->addError($error, $nextCase, 'EmptyDefault'); - } - }//end if - } else if ($type === 'Default') { - $error = 'DEFAULT case must have a BREAK statement'; - $phpcsFile->addError($error, $nextCase, 'DefaultNoBreak'); - }//end if - }//end while - - if ($foundDefault === false) { - $error = 'All SWITCH statements must contain a DEFAULT case'; - $phpcsFile->addError($error, $stackPtr, 'MissingDefault'); - } - - if ($tokens[$switch['scope_closer']]['column'] !== $switch['column']) { - $error = 'Closing brace of SWITCH statement must be aligned with SWITCH keyword'; - $phpcsFile->addError($error, $switch['scope_closer'], 'CloseBraceAlign'); - } - - if ($caseCount === 0) { - $error = 'SWITCH statements must contain at least one CASE statement'; - $phpcsFile->addError($error, $stackPtr, 'MissingCase'); - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Debug/JSLintSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Debug/JSLintSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Debug/JSLintSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Debug/JSLintSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,107 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_Debug_JSLintSniff. - * - * Runs jslint.js on the file. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_Debug_JSLintSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = array('JS'); - - - /** - * Returns the token types that this sniff is interested in. - * - * @return array(int) - */ - public function register() - { - return array(T_OPEN_TAG); - - }//end 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. - * - * @return void - * @throws PHP_CodeSniffer_Exception If jslint.js could not be run - */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) - { - $fileName = $phpcsFile->getFilename(); - - $rhinoPath = PHP_CodeSniffer::getConfigData('rhino_path'); - $jslintPath = PHP_CodeSniffer::getConfigData('jslint_path'); - if ($rhinoPath === null || $jslintPath === null) { - return; - } - - $cmd = "$rhinoPath \"$jslintPath\" \"$fileName\""; - $msg = exec($cmd, $output, $retval); - - if (is_array($output) === true) { - $tokens = $phpcsFile->getTokens(); - - foreach ($output as $finding) { - $matches = array(); - $numMatches = preg_match('/Lint at line ([0-9]+).*:(.*)$/', $finding, $matches); - if ($numMatches === 0) { - continue; - } - - $line = (int) $matches[1]; - $message = 'jslint says: '.trim($matches[2]); - - // Find the token at the start of the line. - $lineToken = null; - foreach ($tokens as $ptr => $info) { - if ($info['line'] === $line) { - $lineToken = $ptr; - break; - } - } - - if ($lineToken !== null) { - $phpcsFile->addWarning($message, $lineToken, 'ExternalTool'); - } - }//end foreach - }//end if - - }//end process() - - -}//end class - -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Debug/JavaScriptLintSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Debug/JavaScriptLintSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Debug/JavaScriptLintSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Debug/JavaScriptLintSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,110 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_Debug_JavaScriptLintSniff. - * - * Runs JavaScipt Lint on the file. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_Debug_JavaScriptLintSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = array('JS'); - - - /** - * Returns the token types that this sniff is interested in. - * - * @return array(int) - */ - public function register() - { - return array(T_OPEN_TAG); - - }//end 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. - * - * @return void - */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) - { - $fileName = $phpcsFile->getFilename(); - - $jslPath = PHP_CodeSniffer::getConfigData('jsl_path'); - if (is_null($jslPath) === true) { - return; - } - - $cmd = '"'.$jslPath.'" -nologo -nofilelisting -nocontext -nosummary -output-format __LINE__:__ERROR__ -process "'.$fileName.'"'; - $msg = exec($cmd, $output, $retval); - - // $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 ($retval === 2 || $retval === 4) { - if (is_array($output) === true) { - $msg = join('\n', $output); - } - - throw new PHP_CodeSniffer_Exception("Failed invoking JavaScript Lint, retval was [$retval], output was [$msg]"); - } - - - if (is_array($output) === true) { - $tokens = $phpcsFile->getTokens(); - - foreach ($output as $finding) { - $split = strpos($finding, ':'); - $line = substr($finding, 0, $split); - $message = substr($finding, ($split + 1)); - - // Find the token at the start of the line. - $lineToken = null; - foreach ($tokens as $ptr => $info) { - if ($info['line'] == $line) { - $lineToken = $ptr; - break; - } - } - - if ($lineToken !== null) { - $phpcsFile->addWarning(trim($message), $ptr, 'ExternalTool'); - } - }//end foreach - }//end if - - }//end process() - -}//end class -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Files/FileExtensionSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Files/FileExtensionSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Files/FileExtensionSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Files/FileExtensionSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,91 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_Files_FileExtensionSniff. - * - * Tests that the stars in a doc comment align correctly. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_Files_FileExtensionSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * 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 void - */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - - // Make sure this is the first PHP open tag so we don't process - // the same file twice. - $prevOpenTag = $phpcsFile->findPrevious(T_OPEN_TAG, ($stackPtr - 1)); - if ($prevOpenTag !== false) { - return; - } - - $fileName = $phpcsFile->getFileName(); - $extension = substr($fileName, strrpos($fileName, '.')); - $nextClass = $phpcsFile->findNext(array(T_CLASS, T_INTERFACE), $stackPtr); - - if ($extension === '.php') { - if ($nextClass !== false) { - $error = '%s found in ".php" file; use ".inc" extension instead'; - $data = array(ucfirst($tokens[$nextClass]['content'])); - $phpcsFile->addError($error, $stackPtr, 'ClassFound', $data); - } - } else if ($extension === '.inc') { - if ($nextClass === false) { - $error = 'No interface or class found in ".inc" file; use ".php" extension instead'; - $phpcsFile->addError($error, $stackPtr, 'NoClass'); - } - } - - }//end process() - - -}//end class - - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Formatting/OperatorBracketSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Formatting/OperatorBracketSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Formatting/OperatorBracketSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Formatting/OperatorBracketSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,253 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_Formatting_OperationBracketSniff. - * - * Tests that all arithmetic operations are bracketed. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_Formatting_OperatorBracketSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - ); - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return PHP_CodeSniffer_Tokens::$operators; - - }//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(); - - if ($phpcsFile->tokenizerType === 'JS' && $tokens[$stackPtr]['code'] === T_PLUS) { - // JavaScript uses the plus operator for string concatenation as well - // so we cannot accurately determine if it is a string concat or addition. - // So just ignore it. - return; - } - - // If the & is a reference, then we don't want to check for brackets. - if ($tokens[$stackPtr]['code'] === T_BITWISE_AND && $phpcsFile->isReference($stackPtr) === true) { - return; - } - - // There is one instance where brackets aren't needed, which involves - // the minus sign being used to assign a negative number to a variable. - if ($tokens[$stackPtr]['code'] === T_MINUS) { - // Check to see if we are trying to return -n. - $prev = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true); - if ($tokens[$prev]['code'] === T_RETURN) { - return; - } - - $number = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); - if ($tokens[$number]['code'] === T_LNUMBER || $tokens[$number]['code'] === T_DNUMBER) { - $previous = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); - if ($previous !== false) { - $isAssignment = in_array($tokens[$previous]['code'], PHP_CodeSniffer_Tokens::$assignmentTokens); - $isEquality = in_array($tokens[$previous]['code'], PHP_CodeSniffer_Tokens::$equalityTokens); - $isComparison = in_array($tokens[$previous]['code'], PHP_CodeSniffer_Tokens::$comparisonTokens); - if ($isAssignment === true || $isEquality === true || $isComparison === true) { - // This is a negative assignment or comparion. - // We need to check that the minus and the number are - // adjacent. - if (($number - $stackPtr) !== 1) { - $error = 'No space allowed between minus sign and number'; - $phpcsFile->addError($error, $stackPtr, 'SpacingAfterMinus'); - } - - return; - } - } - } - }//end if - - $lastBracket = false; - if (isset($tokens[$stackPtr]['nested_parenthesis']) === true) { - $parenthesis = array_reverse($tokens[$stackPtr]['nested_parenthesis'], true); - foreach ($parenthesis as $bracket => $endBracket) { - $prevToken = $phpcsFile->findPrevious(T_WHITESPACE, ($bracket - 1), null, true); - $prevCode = $tokens[$prevToken]['code']; - - if ($prevCode === T_ISSET) { - // This operation is inside an isset() call, but has - // no bracket of it's own. - break; - } - - if ($prevCode === T_STRING || $prevCode === T_SWITCH) { - // We allow very simple operations to not be bracketed. - // For example, ceil($one / $two). - $allowed = array( - T_VARIABLE, - T_LNUMBER, - T_DNUMBER, - T_STRING, - T_WHITESPACE, - T_THIS, - T_OBJECT_OPERATOR, - T_OPEN_SQUARE_BRACKET, - T_CLOSE_SQUARE_BRACKET, - T_MODULUS, - ); - - for ($prev = ($stackPtr - 1); $prev > $bracket; $prev--) { - if (in_array($tokens[$prev]['code'], $allowed) === true) { - continue; - } - - if ($tokens[$prev]['code'] === T_CLOSE_PARENTHESIS) { - $prev = $tokens[$prev]['parenthesis_opener']; - } else { - break; - } - } - - if ($prev !== $bracket) { - break; - } - - for ($next = ($stackPtr + 1); $next < $endBracket; $next++) { - if (in_array($tokens[$next]['code'], $allowed) === true) { - continue; - } - - if ($tokens[$next]['code'] === T_OPEN_PARENTHESIS) { - $next = $tokens[$next]['parenthesis_closer']; - } else { - break; - } - } - - if ($next !== $endBracket) { - break; - } - }//end if - - if (in_array($prevCode, PHP_CodeSniffer_Tokens::$scopeOpeners) === true) { - // This operation is inside an a control structure like FOREACH - // or IF, but has no bracket of it's own. - // The only control structure allowed to do this is SWITCH. - if ($prevCode !== T_SWITCH) { - break; - } - } - - if ($prevCode === T_OPEN_PARENTHESIS) { - // These are two open parenthesis in a row. If the current - // one doesn't enclose the operator, go to the previous one. - if ($endBracket < $stackPtr) { - continue; - } - } - - $lastBracket = $bracket; - break; - }//end foreach - }//end if - - if ($lastBracket === false) { - // It is not in a bracketed statement at all. - $previousToken = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true, null, true); - if ($previousToken !== false) { - // A list of tokens that indicate that the token is not - // part of an arithmetic operation. - $invalidTokens = array( - T_COMMA, - T_COLON, - T_OPEN_PARENTHESIS, - T_OPEN_SQUARE_BRACKET, - ); - - if (in_array($tokens[$previousToken]['code'], $invalidTokens) === false) { - $error = 'Arithmetic operation must be bracketed'; - $phpcsFile->addError($error, $stackPtr, 'MissingBrackets'); - } - - return; - } - } else if ($tokens[$lastBracket]['parenthesis_closer'] < $stackPtr) { - // There are a set of brackets in front of it that don't include it. - $error = 'Arithmetic operation must be bracketed'; - $phpcsFile->addError($error, $stackPtr, 'MissingBrackets'); - return; - } else { - // We are enclosed in a set of bracket, so the last thing to - // check is that we are not also enclosed in square brackets - // like this: ($array[$index + 1]), which is invalid. - $brackets = array( - T_OPEN_SQUARE_BRACKET, - T_CLOSE_SQUARE_BRACKET, - ); - - $squareBracket = $phpcsFile->findPrevious($brackets, ($stackPtr - 1), $lastBracket); - if ($squareBracket !== false && $tokens[$squareBracket]['code'] === T_OPEN_SQUARE_BRACKET) { - $closeSquareBracket = $phpcsFile->findNext($brackets, ($stackPtr + 1)); - if ($closeSquareBracket !== false && $tokens[$closeSquareBracket]['code'] === T_CLOSE_SQUARE_BRACKET) { - $error = 'Arithmetic operation must be bracketed'; - $phpcsFile->addError($error, $stackPtr, 'MissingBrackets'); - } - } - - return; - }//end if - - $lastAssignment = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$assignmentTokens, $stackPtr, null, false, null, true); - if ($lastAssignment !== false && $lastAssignment > $lastBracket) { - $error = 'Arithmetic operation must be bracketed'; - $phpcsFile->addError($error, $stackPtr, 'MissingBrackets'); - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Functions/FunctionDeclarationArgumentSpacingSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Functions/FunctionDeclarationArgumentSpacingSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Functions/FunctionDeclarationArgumentSpacingSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Functions/FunctionDeclarationArgumentSpacingSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,253 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_Functions_FunctionDeclarationArgumentSpacingSniff. - * - * Checks that arguments in function declarations are spaced correctly. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_Functions_FunctionDeclarationArgumentSpacingSniff 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(); - - $functionName = $phpcsFile->findNext(array(T_STRING), $stackPtr); - $openBracket = $tokens[$stackPtr]['parenthesis_opener']; - $closeBracket = $tokens[$stackPtr]['parenthesis_closer']; - - $multiLine = ($tokens[$openBracket]['line'] !== $tokens[$closeBracket]['line']); - - $nextParam = $openBracket; - $params = array(); - while (($nextParam = $phpcsFile->findNext(T_VARIABLE, ($nextParam + 1), $closeBracket)) !== false) { - - $nextToken = $phpcsFile->findNext(T_WHITESPACE, ($nextParam + 1), ($closeBracket + 1), true); - if ($nextToken === false) { - break; - } - - $nextCode = $tokens[$nextToken]['code']; - - if ($nextCode === T_EQUAL) { - // Check parameter default spacing. - if (($nextToken - $nextParam) > 1) { - $error = 'Expected 0 spaces between argument "%s" and equals sign; %s found'; - $data = array( - $tokens[$nextParam]['content'], - strlen($tokens[($nextParam + 1)]['content']), - ); - $phpcsFile->addError($error, $nextToken, 'SpaceBeforeEquals', $data); - } - - if ($tokens[($nextToken + 1)]['code'] === T_WHITESPACE) { - $error = 'Expected 0 spaces between default value and equals sign for argument "%s"; %s found'; - $data = array( - $tokens[$nextParam]['content'], - strlen($tokens[($nextToken + 1)]['content']), - ); - $phpcsFile->addError($error, $nextToken, 'SpaceAfterDefault', $data); - } - } - - // Find and check the comma (if there is one). - $nextComma = $phpcsFile->findNext(T_COMMA, ($nextParam + 1), $closeBracket); - if ($nextComma !== false) { - // Comma found. - if ($tokens[($nextComma - 1)]['code'] === T_WHITESPACE) { - $error = 'Expected 0 spaces between argument "%s" and comma; %s found'; - $data = array( - $tokens[$nextParam]['content'], - strlen($tokens[($nextComma - 1)]['content']), - ); - $phpcsFile->addError($error, $nextToken, 'SpaceBeforeComma', $data); - } - } - - // Take references into account when expecting the - // location of whitespace. - if ($phpcsFile->isReference(($nextParam - 1)) === true) { - $whitespace = $tokens[($nextParam - 2)]; - } else { - $whitespace = $tokens[($nextParam - 1)]; - } - - if (empty($params) === false) { - // This is not the first argument in the function declaration. - $arg = $tokens[$nextParam]['content']; - - if ($whitespace['code'] === T_WHITESPACE) { - $gap = strlen($whitespace['content']); - - // Before we throw an error, make sure there is no type hint. - $comma = $phpcsFile->findPrevious(T_COMMA, ($nextParam - 1)); - $nextToken = $phpcsFile->findNext(T_WHITESPACE, ($comma + 1), null, true); - if ($phpcsFile->isReference($nextToken) === true) { - $nextToken++; - } - - if ($nextToken !== $nextParam) { - // There was a type hint, so check the spacing between - // the hint and the variable as well. - $hint = $tokens[$nextToken]['content']; - - if ($gap !== 1) { - $error = 'Expected 1 space between type hint and argument "%s"; %s found'; - $data = array( - $arg, - $gap, - ); - $phpcsFile->addError($error, $nextToken, 'SpacingAfterHint', $data); - } - - if ($multiLine === false) { - if ($tokens[($comma + 1)]['code'] !== T_WHITESPACE) { - $error = 'Expected 1 space between comma and type hint "%s"; 0 found'; - $data = array($hint); - $phpcsFile->addError($error, $nextToken, 'NoSapceBeforeHint', $data); - } else { - $gap = strlen($tokens[($comma + 1)]['content']); - if ($gap !== 1) { - $error = 'Expected 1 space between comma and type hint "%s"; %s found'; - $data = array( - $hint, - $gap, - ); - $phpcsFile->addError($error, $nextToken, 'SpacingBeforeHint', $data); - } - } - } - } else if ($multiLine === false && $gap !== 1) { - $error = 'Expected 1 space between comma and argument "%s"; %s found'; - $data = array( - $arg, - $gap, - ); - $phpcsFile->addError($error, $nextToken, 'SpacingBeforeArg', $data); - }//end if - } else { - $error = 'Expected 1 space between comma and argument "%s"; 0 found'; - $data = array($arg); - $phpcsFile->addError($error, $nextToken, 'NoSpaceBeforeArg', $data); - }//end if - } else { - // First argument in function declaration. - if ($whitespace['code'] === T_WHITESPACE) { - $gap = strlen($whitespace['content']); - $arg = $tokens[$nextParam]['content']; - - // Before we throw an error, make sure there is no type hint. - $bracket = $phpcsFile->findPrevious(T_OPEN_PARENTHESIS, ($nextParam - 1)); - $nextToken = $phpcsFile->findNext(T_WHITESPACE, ($bracket + 1), null, true); - if ($phpcsFile->isReference($nextToken) === true) { - $nextToken++; - } - - if ($nextToken !== $nextParam) { - // There was a type hint, so check the spacing between - // the hint and the variable as well. - $hint = $tokens[$nextToken]['content']; - - if ($gap !== 1) { - $error = 'Expected 1 space between type hint and argument "%s"; %s found'; - $data = array( - $arg, - $gap, - ); - $phpcsFile->addError($error, $nextToken, 'SpacingAfterHint', $data); - } - - if ($multiLine === false - && $tokens[($bracket + 1)]['code'] === T_WHITESPACE - ) { - $error = 'Expected 0 spaces between opening bracket and type hint "%s"; %s found'; - $data = array( - $hint, - strlen($tokens[($bracket + 1)]['content']), - ); - $phpcsFile->addError($error, $nextToken, 'SpacingAfterOpenHint', $data); - } - } else if ($multiLine === false) { - $error = 'Expected 0 spaces between opening bracket and argument "%s"; %s found'; - $data = array( - $arg, - $gap, - ); - $phpcsFile->addError($error, $nextToken, 'SpacingAfterOpen', $data); - } - }//end if - }//end if - - $params[] = $nextParam; - - }//end while - - if (empty($params) === true) { - // There are no parameters for this function. - if (($closeBracket - $openBracket) !== 1) { - $error = 'Expected 0 spaces between brackets of function declaration; %s found'; - $data = array(strlen($tokens[($closeBracket - 1)]['content'])); - $phpcsFile->addError($error, $stackPtr, 'SpacingBetween', $data); - } - } else if ($multiLine === false - && $tokens[($closeBracket - 1)]['code'] === T_WHITESPACE - ) { - $lastParam = array_pop($params); - $error = 'Expected 0 spaces between argument "%s" and closing bracket; %s found'; - $data = array( - $tokens[$lastParam]['content'], - strlen($tokens[($closeBracket - 1)]['content']), - ); - $phpcsFile->addError($error, $closeBracket, 'SpacingBeforeClose', $data); - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Functions/FunctionDeclarationSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Functions/FunctionDeclarationSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Functions/FunctionDeclarationSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Functions/FunctionDeclarationSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,55 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -if (class_exists('PHP_CodeSniffer_Standards_AbstractPatternSniff', true) === false) { - throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_Standards_AbstractPatternSniff not found'); -} - -/** - * Squiz_Sniffs_Functions_FunctionDeclarationSniff. - * - * Checks the function declaration is correct. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_Functions_FunctionDeclarationSniff extends PHP_CodeSniffer_Standards_AbstractPatternSniff -{ - - - /** - * Returns an array of patterns to check are correct. - * - * @return array - */ - protected function getPatterns() - { - return array( - 'function abc(...);', - 'abstract function abc(...);', - ); - - }//end getPatterns() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Functions/FunctionDuplicateArgumentSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Functions/FunctionDuplicateArgumentSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Functions/FunctionDuplicateArgumentSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Functions/FunctionDuplicateArgumentSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,81 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_Functions_FunctionDuplicateArgumentSpacingSniff. - * - * Checks that duplicate arguments are not used in function declarations. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_Functions_FunctionDuplicateArgumentSniff 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(); - - $openBracket = $tokens[$stackPtr]['parenthesis_opener']; - $closeBracket = $tokens[$stackPtr]['parenthesis_closer']; - - $foundVariables = array(); - for ($i = ($openBracket + 1); $i < $closeBracket; $i++) { - if ($tokens[$i]['code'] === T_VARIABLE) { - $variable = $tokens[$i]['content']; - if (in_array($variable, $foundVariables) === true) { - $error = 'Variable "%s" appears more than once in function declaration'; - $data = array($variable); - $phpcsFile->addError($error, $i, 'Found', $data); - } else { - $foundVariables[] = $variable; - } - } - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Functions/GlobalFunctionSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Functions/GlobalFunctionSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Functions/GlobalFunctionSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Functions/GlobalFunctionSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,78 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_Functions_GlobalFunctionSniff. - * - * Tests for functions outside of classes. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_Functions_GlobalFunctionSniff 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(); - - if (empty($tokens[$stackPtr]['conditions']) === true) { - $functionName = $phpcsFile->getDeclarationName($stackPtr); - if ($functionName === null) { - return; - } - - // Special exception for __autoload as it needs to be global. - if ($functionName !== '__autoload') { - $error = 'Consider putting global function "%s" in a static class'; - $data = array($functionName); - $phpcsFile->addWarning($error, $stackPtr, 'Found', $data); - } - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Functions/LowercaseFunctionKeywordsSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Functions/LowercaseFunctionKeywordsSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Functions/LowercaseFunctionKeywordsSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Functions/LowercaseFunctionKeywordsSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,81 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_Functions_LowercaseFunctionKeywordsSniff. - * - * Ensures all class keywords are lowercase. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_Functions_LowercaseFunctionKeywordsSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array( - T_FUNCTION, - T_PUBLIC, - T_PRIVATE, - T_PROTECTED, - T_STATIC, - ); - - }//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(); - - $content = $tokens[$stackPtr]['content']; - if ($content !== strtolower($content)) { - $error = '%s keyword must be lowercase; expected "%s" but found "%s"'; - $data = array( - strtoupper($content), - strtolower($content), - $content, - ); - $phpcsFile->addError($error, $stackPtr, 'FoundUppercase', $data); - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Functions/MultiLineFunctionDeclarationSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Functions/MultiLineFunctionDeclarationSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Functions/MultiLineFunctionDeclarationSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Functions/MultiLineFunctionDeclarationSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,94 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -if (class_exists('PEAR_Sniffs_Functions_FunctionDeclarationSniff', true) === false) { - $error = 'Class PEAR_Sniffs_Functions_FunctionDeclarationSniff not found'; - throw new PHP_CodeSniffer_Exception($error); -} - -/** - * Squiz_Sniffs_Functions_MultiLineFunctionDeclarationSniff. - * - * Ensure single and multi-line function declarations are defined correctly. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_Functions_MultiLineFunctionDeclarationSniff extends PEAR_Sniffs_Functions_FunctionDeclarationSniff -{ - - - /** - * Processes mutli-line declarations. - * - * @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 array $tokens The stack of tokens that make up - * the file. - * - * @return void - */ - public function processMultiLineDeclaration(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $tokens) - { - // We do everything the parent sniff does, and a bit more. - parent::processMultiLineDeclaration($phpcsFile, $stackPtr, $tokens); - - $openBracket = $tokens[$stackPtr]['parenthesis_opener']; - $closeBracket = $tokens[$stackPtr]['parenthesis_closer']; - - // The open bracket should be the last thing on the line. - $next = $phpcsFile->findNext(T_WHITESPACE, ($openBracket + 1), null, true); - if ($tokens[$next]['line'] !== ($tokens[$openBracket]['line'] + 1)) { - $error = 'The first parameter of a multi-line function declaration must be on the line after the opening bracket'; - $phpcsFile->addError($error, $next, 'FirstParamSpacing'); - } - - // Each line between the brackets should contain a single parameter. - $lastCommaLine = null; - for ($i = ($openBracket + 1); $i < $closeBracket; $i++) { - // Skip brackets, like arrays, as they can contain commas. - if (isset($tokens[$i]['parenthesis_opener']) === true) { - $i = $tokens[$i]['parenthesis_closer']; - continue; - } - - if ($tokens[$i]['code'] === T_COMMA) { - if ($lastCommaLine !== null && $lastCommaLine === $tokens[$i]['line']) { - $error = 'Multi-line function declarations must define one parameter per line'; - $phpcsFile->addError($error, $i, 'OneParamPerLine'); - } else { - // Comma must be the last thing on the line. - $next = $phpcsFile->findNext(T_WHITESPACE, ($i + 1), null, true); - if ($tokens[$next]['line'] !== ($tokens[$i]['line'] + 1)) { - $error = 'Commas in multi-line function declarations must be the last content on a line'; - $phpcsFile->addError($error, $next, 'ContentAfterComma'); - } - } - - $lastCommaLine = $tokens[$i]['line']; - } - } - - }//end processMultiLineDeclaration() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/NamingConventions/ConstantCaseSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/NamingConventions/ConstantCaseSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/NamingConventions/ConstantCaseSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/NamingConventions/ConstantCaseSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,65 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -if (class_exists('Generic_Sniffs_PHP_LowerCaseConstantSniff', true) === false) { - $error = 'Class Generic_Sniffs_PHP_LowerCaseConstantSniff not found'; - throw new PHP_CodeSniffer_Exception($error); -} - -if (class_exists('Generic_Sniffs_PHP_UpperCaseConstantSniff', true) === false) { - $error = 'Class Generic_Sniffs_PHP_UpperCaseConstantSniff not found'; - throw new PHP_CodeSniffer_Exception($error); -} - -/** - * Squiz_Sniffs_NamingConventions_ConstantCaseSniff. - * - * Ensures TRUE, FALSE and NULL are uppercase for PHP and lowercase for JS. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_NamingConventions_ConstantCaseSniff extends Generic_Sniffs_PHP_LowerCaseConstantSniff -{ - - - /** - * Processes this sniff, 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) - { - if ($phpcsFile->tokenizerType === 'JS') { - parent::process($phpcsFile, $stackPtr); - } else { - $sniff = new Generic_Sniffs_PHP_UpperCaseConstantSniff; - $sniff->process($phpcsFile, $stackPtr); - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/NamingConventions/ValidFunctionNameSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/NamingConventions/ValidFunctionNameSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/NamingConventions/ValidFunctionNameSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/NamingConventions/ValidFunctionNameSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,74 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -if (class_exists('PEAR_Sniffs_NamingConventions_ValidFunctionNameSniff', true) === false) { - throw new PHP_CodeSniffer_Exception('Class PEAR_Sniffs_NamingConventions_ValidFunctionNameSniff not found'); -} - -/** - * Squiz_Sniffs_NamingConventions_ValidFunctionNameSniff. - * - * Ensures method names are correct depending on whether they are public - * or private, and that functions are named correctly. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_NamingConventions_ValidFunctionNameSniff extends PEAR_Sniffs_NamingConventions_ValidFunctionNameSniff -{ - - - /** - * Processes the tokens outside the scope. - * - * @param PHP_CodeSniffer_File $phpcsFile The file being processed. - * @param int $stackPtr The position where this token was - * found. - * - * @return void - */ - protected function processTokenOutsideScope(PHP_CodeSniffer_File $phpcsFile, $stackPtr) - { - $functionName = $phpcsFile->getDeclarationName($stackPtr); - if ($functionName === null) { - return; - } - - $errorData = array($functionName); - - // Does this function claim to be magical? - if (preg_match('|^__|', $functionName) !== 0) { - $error = 'Function name "%s" is invalid; only PHP magic methods should be prefixed with a double underscore'; - $phpcsFile->addError($error, $stackPtr, 'DoubleUnderscore', $errorData); - return; - } - - if (PHP_CodeSniffer::isCamelCaps($functionName, false, true, false) === false) { - $error = 'Function name "%s" is not in camel caps format'; - $phpcsFile->addError($error, $stackPtr, 'NotCamelCaps', $errorData); - } - - }//end processTokenOutsideScope() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/NamingConventions/ValidVariableNameSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/NamingConventions/ValidVariableNameSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/NamingConventions/ValidVariableNameSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/NamingConventions/ValidVariableNameSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,241 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -if (class_exists('PHP_CodeSniffer_Standards_AbstractVariableSniff', true) === false) { - throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_Standards_AbstractVariableSniff not found'); -} - -/** - * Squiz_Sniffs_NamingConventions_ValidVariableNameSniff. - * - * Checks the naming of variables and member variables. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_NamingConventions_ValidVariableNameSniff extends PHP_CodeSniffer_Standards_AbstractVariableSniff -{ - - /** - * Tokens to ignore so that we can find a DOUBLE_COLON. - * - * @var array - */ - private $_ignore = array( - T_WHITESPACE, - T_COMMENT, - ); - - - /** - * 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 - */ - protected function processVariable(PHP_CodeSniffer_File $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - $varName = ltrim($tokens[$stackPtr]['content'], '$'); - - $phpReservedVars = array( - '_SERVER', - '_GET', - '_POST', - '_REQUEST', - '_SESSION', - '_ENV', - '_COOKIE', - '_FILES', - 'GLOBALS', - ); - - // If it's a php reserved var, then its ok. - if (in_array($varName, $phpReservedVars) === true) { - return; - } - - $objOperator = $phpcsFile->findNext(array(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(array(T_WHITESPACE), ($objOperator + 1), null, true); - if ($tokens[$var]['code'] === T_STRING) { - $bracket = $objOperator = $phpcsFile->findNext(array(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 (PHP_CodeSniffer::isCamelCaps($objVarName, false, true, false) === false) { - $error = 'Variable "%s" is not in valid camel caps format'; - $data = array($originalVarName); - $phpcsFile->addError($error, $var, 'NotCamelCaps', $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(array(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, array(T_CLASS, T_INTERFACE)); - } - - if ($inClass === true) { - $varName = substr($varName, 1); - } - } - - if (PHP_CodeSniffer::isCamelCaps($varName, false, true, false) === false) { - $error = 'Variable "%s" is not in valid camel caps format'; - $data = array($originalVarName); - $phpcsFile->addError($error, $stackPtr, 'NotCamelCaps', $data); - } - - }//end processVariable() - - - /** - * Processes class member variables. - * - * @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 - */ - protected function processMemberVar(PHP_CodeSniffer_File $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - - $varName = ltrim($tokens[$stackPtr]['content'], '$'); - $memberProps = $phpcsFile->getMemberProperties($stackPtr); - if (empty($memberProps) === true) { - // Couldn't get any info about this variable, which - // generally means it is invalid or possibly has a parse - // error. Any errors will be reported by the core, so - // we can ignore it. - return; - } - - $public = ($memberProps['scope'] !== 'private'); - $errorData = array($varName); - - if ($public === true) { - if (substr($varName, 0, 1) === '_') { - $error = '%s member variable "%s" must not contain a leading underscore'; - $data = array( - ucfirst($memberProps['scope']), - $errorData[0], - ); - $phpcsFile->addError($error, $stackPtr, 'PublicHasUnderscore', $data); - return; - } - } else { - if (substr($varName, 0, 1) !== '_') { - $error = 'Private member variable "%s" must contain a leading underscore'; - $phpcsFile->addError($error, $stackPtr, 'PrivateNoUnderscore', $errorData); - return; - } - } - - if (PHP_CodeSniffer::isCamelCaps($varName, false, $public, false) === false) { - $error = 'Variable "%s" is not in valid camel caps format'; - $phpcsFile->addError($error, $stackPtr, 'MemberNotCamelCaps', $errorData); - } - - }//end processMemberVar() - - - /** - * Processes the variable found within a double quoted string. - * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the double quoted - * string. - * - * @return void - */ - protected function processVariableInString(PHP_CodeSniffer_File $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - - $phpReservedVars = array( - '_SERVER', - '_GET', - '_POST', - '_REQUEST', - '_SESSION', - '_ENV', - '_COOKIE', - '_FILES', - 'GLOBALS', - ); - 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; - } - - // 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) === '_') { - if ($phpcsFile->hasCondition($stackPtr, array(T_CLASS, T_INTERFACE)) === true) { - $varName = substr($varName, 1); - } - } - - if (PHP_CodeSniffer::isCamelCaps($varName, false, true, false) === false) { - $varName = $matches[0]; - $error = 'Variable "%s" is not in valid camel caps format'; - $data = array($originalVarName); - $phpcsFile->addError($error, $stackPtr, 'StringNotCamelCaps', $data); - - } - } - }//end if - - }//end processVariableInString() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Objects/DisallowObjectStringIndexSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Objects/DisallowObjectStringIndexSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Objects/DisallowObjectStringIndexSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Objects/DisallowObjectStringIndexSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,98 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Ensures that object indexes are written in dot notation. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Sertan Danis - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_Objects_DisallowObjectStringIndexSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = array('JS'); - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array(T_OPEN_SQUARE_BRACKET); - - }//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(); - - // Check if the next non whitespace token is a string. - $index = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); - if ($tokens[$index]['code'] !== T_CONSTANT_ENCAPSED_STRING) { - return; - } - - // Make sure it is the only thing in the square brackets. - $next = $phpcsFile->findNext(T_WHITESPACE, ($index + 1), null, true); - if ($tokens[$next]['code'] !== T_CLOSE_SQUARE_BRACKET) { - return; - } - - // Allow indxes that have dots in them because we can't write - // them in dot notation. - $content = trim($tokens[$index]['content'], '"\' '); - if (strpos($content, '.') !== false) { - return; - } - - // Also ignore reserved words. - if ($content === 'super') { - return; - } - - // Token before the opening square bracket cannot be a var name. - $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); - if ($tokens[$prev]['code'] === T_STRING) { - $error = 'Object indexes must be written in dot notation'; - $phpcsFile->addError($error, $prev, 'Found'); - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Objects/ObjectInstantiationSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Objects/ObjectInstantiationSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Objects/ObjectInstantiationSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Objects/ObjectInstantiationSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,83 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_Objects_ObjectInstantiationSniff. - * - * Ensures objects are assigned to a variable when instantiated. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_Objects_ObjectInstantiationSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * Registers the token types that this sniff wishes to listen to. - * - * @return array - */ - public function register() - { - return array(T_NEW); - - }//end register() - - - /** - * Process the tokens that this sniff is listening for. - * - * @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(); - - $allowedTokens = PHP_CodeSniffer_Tokens::$emptyTokens; - $allowedTokens[] = T_BITWISE_AND; - - $prev = $phpcsFile->findPrevious($allowedTokens, ($stackPtr - 1), null, true); - - $allowedTokens = array( - T_EQUAL, - T_DOUBLE_ARROW, - T_THROW, - T_RETURN, - T_INLINE_THEN, - T_COLON, - ); - - if (in_array($tokens[$prev]['code'], $allowedTokens) === false) { - $error = 'New objects must be assigned to a variable'; - $phpcsFile->addError($error, $stackPtr, 'NotAssigned'); - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Objects/ObjectMemberCommaSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Objects/ObjectMemberCommaSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Objects/ObjectMemberCommaSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Objects/ObjectMemberCommaSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,84 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_Objects_ObjectInstantiationSniff. - * - * Ensures objects are assigned to a variable when instantiated. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_Objects_ObjectMemberCommaSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = array('JS'); - - - /** - * Registers the token types that this sniff wishes to listen to. - * - * @return array - */ - public function register() - { - return array(T_CLOSE_CURLY_BRACKET); - - }//end register() - - - /** - * Process the tokens that this sniff is listening for. - * - * @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(); - - // Only interested in orphaned braces (which are objects) - // and object definitions. - if (isset($tokens[$stackPtr]['scope_condition']) === true) { - $condition = $tokens[$stackPtr]['scope_condition']; - if ($tokens[$condition]['code'] !== T_OBJECT) { - return; - } - } - - $prev = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true); - if ($tokens[$prev]['code'] === T_COMMA) { - $error = 'Last member of object must not be followed by a comma'; - $phpcsFile->addError($error, $prev, 'Missing'); - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Operators/ComparisonOperatorUsageSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Operators/ComparisonOperatorUsageSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Operators/ComparisonOperatorUsageSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Operators/ComparisonOperatorUsageSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,209 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * A Sniff to enforce the use of IDENTICAL type operators rather than EQUAL operators. - * - * The use of === true is enforced over implicit true statements, - * for example: - * - * - * if ($a) - * { - * ... - * } - * - * - * should be: - * - * - * if ($a === true) - * { - * ... - * } - * - * - * It also enforces the use of === false over ! operators. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_Operators_ComparisonOperatorUsageSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - ); - - /** - * A list of valid comparison operators. - * - * @var array - */ - private static $_validOps = array( - T_IS_IDENTICAL, - T_IS_NOT_IDENTICAL, - T_LESS_THAN, - T_GREATER_THAN, - T_IS_GREATER_OR_EQUAL, - T_IS_SMALLER_OR_EQUAL, - T_INSTANCEOF, - ); - - /** - * A list of invalid operators with their alternatives. - * - * @var array(int => string) - */ - private static $_invalidOps = array( - 'PHP' => array( - T_IS_EQUAL => '===', - T_IS_NOT_EQUAL => '!==', - T_BOOLEAN_NOT => '=== FALSE', - ), - 'JS' => array( - T_IS_EQUAL => '===', - T_IS_NOT_EQUAL => '!==', - ), - ); - - - /** - * Registers the token types that this sniff wishes to listen to. - * - * @return array - */ - public function register() - { - return array( - T_IF, - T_INLINE_THEN, - ); - - }//end register() - - - /** - * Process the tokens that this sniff is listening for. - * - * @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(); - $tokenizer = $phpcsFile->tokenizerType; - - if ($tokens[$stackPtr]['code'] === T_INLINE_THEN) { - $end = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true); - if ($tokens[$end]['code'] !== T_CLOSE_PARENTHESIS) { - // This inline IF statement does not have its condition - // bracketed, so we need to guess where it starts. - for ($i = ($end - 1); $i >= 0; $i--) { - if ($tokens[$i]['code'] === T_SEMICOLON) { - // Stop here as we assume it is the end - // of the previous statement. - break; - } else if ($tokens[$i]['code'] === T_OPEN_TAG) { - // Stop here as this is the start of the file. - break; - } else if ($tokens[$i]['code'] === T_CLOSE_CURLY_BRACKET) { - // Stop if this is the closing brace of - // a code block. - if (isset($tokens[$i]['scope_opener']) === true) { - break; - } - } else if ($tokens[$i]['code'] === T_OPEN_CURLY_BRACKET) { - // Stop if this is the opening brace of - // a code block. - if (isset($tokens[$i]['scope_closer']) === true) { - break; - } - } - }//end for - - $start = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($i + 1), null, true); - } else { - $start = $tokens[$end]['parenthesis_opener']; - } - } else { - $start = $tokens[$stackPtr]['parenthesis_opener']; - $end = $tokens[$stackPtr]['parenthesis_closer']; - } - - $requiredOps = 0; - $foundOps = 0; - - for ($i = $start; $i <= $end; $i++) { - $type = $tokens[$i]['code']; - if (in_array($type, array_keys(self::$_invalidOps[$tokenizer])) === true) { - $error = 'Operator %s prohibited; use %s instead'; - $data = array( - $tokens[$i]['content'], - self::$_invalidOps[$tokenizer][$type], - ); - $phpcsFile->addError($error, $i, 'NotAllowed', $data); - $foundOps++; - } else if (in_array($type, self::$_validOps) === true) { - $foundOps++; - } - - if ($phpcsFile->tokenizerType !== 'JS') { - if ($tokens[$i]['code'] === T_BOOLEAN_AND || $tokens[$i]['code'] === T_BOOLEAN_OR) { - $requiredOps++; - - // If we get to here and we have not found the right number of - // comparison operators, then we must have had an implicit - // true operation ie. if ($a) instead of the required - // if ($a === true), so let's add an error. - if ($requiredOps !== $foundOps) { - $error = 'Implicit true comparisons prohibited; use === TRUE instead'; - $phpcsFile->addError($error, $stackPtr, 'ImplicitTrue'); - $foundOps++; - } - } - }//end if - }//end for - - $requiredOps++; - - if ($phpcsFile->tokenizerType !== 'JS') { - if ($foundOps < $requiredOps) { - $error = 'Implicit true comparisons prohibited; use === TRUE instead'; - $phpcsFile->addError($error, $stackPtr, 'ImplicitTrue'); - } - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,234 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_Operators_IncrementDecrementUsageSniff. - * - * Tests that the ++ operators are used when possible and not - * used when it makes the code confusing. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_Operators_IncrementDecrementUsageSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array( - T_EQUAL, - T_PLUS_EQUAL, - T_MINUS_EQUAL, - T_INC, - T_DEC, - ); - - }//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(); - - if ($tokens[$stackPtr]['code'] === T_INC || $tokens[$stackPtr]['code'] === T_DEC) { - $this->processIncDec($phpcsFile, $stackPtr); - } else { - $this->processAssignment($phpcsFile, $stackPtr); - } - - }//end process() - - - /** - * Checks to ensure increment and decrement operators are not confusing. - * - * @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 - */ - protected function processIncDec(PHP_CodeSniffer_File $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - - // Work out where the variable is so we know where to - // start looking for other operators. - if ($tokens[($stackPtr - 1)]['code'] === T_VARIABLE) { - $start = ($stackPtr + 1); - } else { - $start = ($stackPtr + 2); - } - - $next = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $start, null, true); - if ($next === false) { - return; - } - - if (in_array($tokens[$next]['code'], PHP_CodeSniffer_Tokens::$arithmeticTokens) === true) { - $error = 'Increment and decrement operators cannot be used in an arithmetic operation'; - $phpcsFile->addError($error, $stackPtr, 'NotAllowed'); - return; - } - - $prev = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($start - 3), null, true); - if ($prev === false) { - return; - } - - // Check if this is in a string concat. - if ($tokens[$next]['code'] === T_STRING_CONCAT || $tokens[$prev]['code'] === T_STRING_CONCAT) { - $error = 'Increment and decrement operators must be bracketed when used in string concatenation'; - $phpcsFile->addError($error, $stackPtr, 'NoBrackets'); - } - - }//end processIncDec() - - - /** - * Checks to ensure increment and decrement operators are used. - * - * @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 - */ - protected function processAssignment(PHP_CodeSniffer_File $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - - $assignedVar = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); - // Not an assignment, return. - if ($tokens[$assignedVar]['code'] !== T_VARIABLE) { - return; - } - - $statementEnd = $phpcsFile->findNext(array(T_SEMICOLON, T_CLOSE_PARENTHESIS, T_CLOSE_SQUARE_BRACKET, T_CLOSE_CURLY_BRACKET), $stackPtr); - - // If there is anything other than variables, numbers, spaces or operators we need to return. - $noiseTokens = $phpcsFile->findNext(array(T_LNUMBER, T_VARIABLE, T_WHITESPACE, T_PLUS, T_MINUS, T_OPEN_PARENTHESIS), ($stackPtr + 1), $statementEnd, true); - - if ($noiseTokens !== false) { - return; - } - - // If we are already using += or -=, we need to ignore - // the statement if a variable is being used. - if ($tokens[$stackPtr]['code'] !== T_EQUAL) { - $nextVar = $phpcsFile->findNext(T_VARIABLE, ($stackPtr + 1), $statementEnd); - if ($nextVar !== false) { - return; - } - } - - if ($tokens[$stackPtr]['code'] === T_EQUAL) { - $nextVar = ($stackPtr + 1); - $previousVariable = ($stackPtr + 1); - $variableCount = 0; - while (($nextVar = $phpcsFile->findNext(T_VARIABLE, ($nextVar + 1), $statementEnd)) !== false) { - $previousVariable = $nextVar; - $variableCount++; - } - - if ($variableCount !== 1) { - return; - } - - $nextVar = $previousVariable; - if ($tokens[$nextVar]['content'] !== $tokens[$assignedVar]['content']) { - return; - } - } - - // We have only one variable, and it's the same as what is being assigned, - // so we need to check what is being added or subtracted. - $nextNumber = ($stackPtr + 1); - $previousNumber = ($stackPtr + 1); - $numberCount = 0; - while (($nextNumber = $phpcsFile->findNext(array(T_LNUMBER), ($nextNumber + 1), $statementEnd, false)) !== false) { - $previousNumber = $nextNumber; - $numberCount++; - } - - if ($numberCount !== 1) { - return; - } - - $nextNumber = $previousNumber; - if ($tokens[$nextNumber]['content'] === '1') { - if ($tokens[$stackPtr]['code'] === T_EQUAL) { - $opToken = $phpcsFile->findNext(array(T_PLUS, T_MINUS), ($nextVar + 1), $statementEnd); - if ($opToken === false) { - // Operator was before the variable, like: - // $var = 1 + $var; - // So we ignore it. - return; - } - - $operator = $tokens[$opToken]['content']; - } else { - $operator = substr($tokens[$stackPtr]['content'], 0, 1); - } - - // If we are adding or subtracting negative value, the operator - // needs to be reversed. - if ($tokens[$stackPtr]['code'] !== T_EQUAL) { - $negative = $phpcsFile->findPrevious(T_MINUS, ($nextNumber - 1), $stackPtr); - if ($negative !== false) { - $operator = ($operator === '+') ? '-' : '+'; - } - } - - $expected = $tokens[$assignedVar]['content'].$operator.$operator; - $found = $phpcsFile->getTokensAsString($assignedVar, ($statementEnd - $assignedVar + 1)); - - if ($operator === '+') { - $error = 'Increment'; - } else { - $error = 'Decrement'; - } - - $error .= " operators should be used where possible; found \"$found\" but expected \"$expected\""; - $phpcsFile->addError($error, $stackPtr); - }//end if - - }//end processAssignment() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Operators/ValidLogicalOperatorsSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Operators/ValidLogicalOperatorsSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Operators/ValidLogicalOperatorsSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Operators/ValidLogicalOperatorsSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,87 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_Operators_ValidLogicalOperatorsSniff. - * - * Checks to ensure that the logical operators 'and' and 'or' are not used. - * Use the && and || operators instead. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_Operators_ValidLogicalOperatorsSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array( - T_LOGICAL_AND, - T_LOGICAL_OR, - T_LOGICAL_XOR, - ); - - }//end register() - - - /** - * Processes this test, when one of its tokens is encountered. - * - * @param PHP_CodeSniffer_File $phpcsFile The current 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(); - - $replacements = array( - 'and' => '&&', - 'or' => '||', - 'xor' => '^', - ); - - $operator = strtolower($tokens[$stackPtr]['content']); - if (isset($replacements[$operator]) === false) { - return; - } - - $error = 'Logical operator "%s" is prohibited; use "%s" instead'; - $data = array( - $operator, - $replacements[$operator], - ); - $phpcsFile->addError($error, $stackPtr, 'NotAllowed', $data); - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/PHP/CommentedOutCodeSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/PHP/CommentedOutCodeSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/PHP/CommentedOutCodeSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/PHP/CommentedOutCodeSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,214 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_PHP_CommentedOutCodeSniff. - * - * Warn about commented out code. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_PHP_CommentedOutCodeSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = array( - 'PHP', - 'CSS', - ); - - /** - * If a comment is more than $maxPercentage% code, a warning will be shown. - * - * @var int - */ - public $maxPercentage = 35; - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return PHP_CodeSniffer_Tokens::$commentTokens; - - }//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(); - - // Process whole comment blocks at once, so skip all but the first token. - if ($stackPtr > 0 && $tokens[$stackPtr]['code'] === $tokens[($stackPtr - 1)]['code']) { - return; - } - - // Ignore comments at the end of code blocks. - if (substr($tokens[$stackPtr]['content'], 0, 6) === '//end ') { - return; - } - - $content = ''; - if ($phpcsFile->tokenizerType === 'PHP') { - $content = 'numTokens; $i++) { - if ($tokens[$stackPtr]['code'] !== $tokens[$i]['code']) { - break; - } - - /* - Trim as much off the comment as possible so we don't - have additional whitespace tokens or comment tokens - */ - - $tokenContent = trim($tokens[$i]['content']); - - if (substr($tokenContent, 0, 2) === '//') { - $tokenContent = substr($tokenContent, 2); - } - - if (substr($tokenContent, 0, 1) === '#') { - $tokenContent = substr($tokenContent, 1); - } - - if (substr($tokenContent, 0, 3) === '/**') { - $tokenContent = substr($tokenContent, 3); - } - - if (substr($tokenContent, 0, 2) === '/*') { - $tokenContent = substr($tokenContent, 2); - } - - if (substr($tokenContent, -2) === '*/') { - $tokenContent = substr($tokenContent, 0, -2); - } - - if (substr($tokenContent, 0, 1) === '*') { - $tokenContent = substr($tokenContent, 1); - } - - $content .= $tokenContent.$phpcsFile->eolChar; - }//end for - - $content = trim($content); - - if ($phpcsFile->tokenizerType === 'PHP') { - $content .= ' ?>'; - } - - // Quite a few comments use multiple dashes, equals signs etc - // to frame comments and licence headers. - $content = preg_replace('/[-=*]+/', '-', $content); - - $stringTokens = PHP_CodeSniffer_File::tokenizeString($content, $phpcsFile->tokenizer, $phpcsFile->eolChar); - - $emptyTokens = array( - T_WHITESPACE, - T_STRING, - T_STRING_CONCAT, - T_ENCAPSED_AND_WHITESPACE, - T_NONE, - ); - - $numTokens = count($stringTokens); - - /* - We know what the first two and last two tokens should be - (because we put them there) so ignore this comment if those - tokens were not parsed correctly. It obvously means this is not - valid code. - */ - - // First token is always the opening PHP tag. - if ($stringTokens[0]['code'] !== T_OPEN_TAG) { - return; - } - - // Last token is always the closing PHP tag. - if ($stringTokens[($numTokens - 1)]['code'] !== T_CLOSE_TAG) { - return; - } - - // Second last token is always whitespace or a comment, depending - // on the code inside the comment. - if (in_array($stringTokens[($numTokens - 2)]['code'], PHP_CodeSniffer_Tokens::$emptyTokens) === false) { - return; - } - - $numComment = 0; - $numCode = 0; - - for ($i = 0; $i < $numTokens; $i++) { - if (in_array($stringTokens[$i]['code'], $emptyTokens) === true) { - // Looks like comment. - $numComment++; - } else { - // Looks like code. - $numCode++; - } - } - - // We subtract 3 from the token number so we ignore the start/end tokens - // and their surrounding whitespace. We take 2 off the number of code - // tokens so we ignore the start/end tokens. - if ($numTokens > 3) { - $numTokens -= 3; - } - - if ($numCode >= 2) { - $numCode -= 2; - } - - $percentCode = ceil((($numCode / $numTokens) * 100)); - if ($percentCode > $this->maxPercentage) { - // Just in case. - $percentCode = min(100, $percentCode); - - $error = 'This comment is %s%% valid code; is this commented out code?'; - $data = array($percentCode); - $phpcsFile->addWarning($error, $stackPtr, 'Found', $data); - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/PHP/DisallowComparisonAssignmentSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/PHP/DisallowComparisonAssignmentSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/PHP/DisallowComparisonAssignmentSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/PHP/DisallowComparisonAssignmentSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,119 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_PHP_DisallowComparisonAssignmentSniff. - * - * Ensures that the value of a comparison is not assigned to a variable. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_PHP_DisallowComparisonAssignmentSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array(T_EQUAL); - - }//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(); - - // Ignore default value assignments in function definitions. - $function = $phpcsFile->findPrevious(T_FUNCTION, ($stackPtr - 1)); - if ($function !== false) { - $opener = $tokens[$function]['parenthesis_opener']; - $closer = $tokens[$function]['parenthesis_closer']; - if ($opener < $stackPtr && $closer > $stackPtr) { - return; - } - } - - // Ignore values in array definitions. - $array = $phpcsFile->findNext( - T_ARRAY, - ($stackPtr + 1), - null, - false, - null, - true - ); - - if ($array !== false) { - return; - } - - // Ignore function calls. - $ignore = array( - T_STRING, - T_WHITESPACE, - T_OBJECT_OPERATOR, - ); - - $next = $phpcsFile->findNext($ignore, ($stackPtr + 1), null, true); - if ($tokens[$next]['code'] === T_OPEN_PARENTHESIS - && $tokens[($next - 1)]['code'] === T_STRING - ) { - // Code will look like: $var = myFunction( - // and will be ignored. - return; - } - - $endStatement = $phpcsFile->findNext(T_SEMICOLON, ($stackPtr + 1)); - for ($i = ($stackPtr + 1); $i < $endStatement; $i++) { - if (in_array($tokens[$i]['code'], PHP_CodeSniffer_Tokens::$comparisonTokens) === true) { - $error = 'The value of a comparison must not be assigned to a variable'; - $phpcsFile->addError($error, $stackPtr, 'AssignedComparison'); - break; - } - - if (in_array($tokens[$i]['code'], PHP_CodeSniffer_Tokens::$booleanOperators) === true - || $tokens[$i]['code'] === T_BOOLEAN_NOT - ) { - $error = 'The value of a boolean operation must not be assigned to a variable'; - $phpcsFile->addError($error, $stackPtr, 'AssignedBool'); - break; - } - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/PHP/DisallowInlineIfSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/PHP/DisallowInlineIfSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/PHP/DisallowInlineIfSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/PHP/DisallowInlineIfSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,74 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_Formatting_DisallowInlineIfSniff. - * - * Stops inline IF statements from being used. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_PHP_DisallowInlineIfSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - ); - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array(T_INLINE_THEN); - - }//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) - { - $phpcsFile->addError('Inline IF statements are not allowed', $stackPtr, 'Found'); - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/PHP/DisallowMultipleAssignmentsSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/PHP/DisallowMultipleAssignmentsSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/PHP/DisallowMultipleAssignmentsSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/PHP/DisallowMultipleAssignmentsSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,183 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_PHP_DisallowMultipleAssignmentsSniff. - * - * Ensures that there is only one value assignment on a line, and that it is - * the first thing on the line. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_PHP_DisallowMultipleAssignmentsSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array(T_EQUAL); - - }//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(); - - // Ignore default value assignments in function definitions. - $function = $phpcsFile->findPrevious(T_FUNCTION, ($stackPtr - 1)); - if ($function !== false) { - $opener = $tokens[$function]['parenthesis_opener']; - $closer = $tokens[$function]['parenthesis_closer']; - if ($opener < $stackPtr && $closer > $stackPtr) { - return; - } - } - - /* - The general rule is: - Find an equal sign and go backwards along the line. If you hit an - end bracket, skip to the opening bracket. When you find a variable, - stop. That variable must be the first non-empty token on the line - or in the statement. If not, throw an error. - */ - - for ($varToken = ($stackPtr - 1); $varToken >= 0; $varToken--) { - // Skip brackets. - if (isset($tokens[$varToken]['parenthesis_opener']) === true && $tokens[$varToken]['parenthesis_opener'] < $varToken) { - $varToken = $tokens[$varToken]['parenthesis_opener']; - continue; - } - - if (isset($tokens[$varToken]['bracket_opener']) === true) { - $varToken = $tokens[$varToken]['bracket_opener']; - continue; - } - - if ($tokens[$varToken]['code'] === T_SEMICOLON) { - // We've reached the next statement, so we - // didn't find a variable. - return; - } - - if ($tokens[$varToken]['code'] === T_VARIABLE) { - // We found our variable. - break; - } - } - - if ($varToken <= 0) { - // Didn't find a variable. - return; - } - - // Deal with this type of variable: self::$var by setting the var - // token to be "self" rather than "$var". - if ($tokens[($varToken - 1)]['code'] === T_DOUBLE_COLON) { - $varToken = ($varToken - 2); - } - - // Deal with this type of variable: $obj->$var by setting the var - // token to be "$obj" rather than "$var". - if ($tokens[($varToken - 1)]['code'] === T_OBJECT_OPERATOR) { - $varToken = ($varToken - 2); - } - - // Deal with this type of variable: $$var by setting the var - // token to be "$" rather than "$var". - if ($tokens[($varToken - 1)]['content'] === '$') { - $varToken--; - } - - // Ignore member var definitions. - $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($varToken - 1), null, true); - if (in_array($tokens[$prev]['code'], PHP_CodeSniffer_Tokens::$scopeModifiers) === true) { - return; - } - - if ($tokens[$prev]['code'] === T_STATIC) { - return; - } - - // Make sure this variable is the first thing in the statement. - $varLine = $tokens[$varToken]['line']; - $prevLine = 0; - for ($i = ($varToken - 1); $i >= 0; $i--) { - if ($tokens[$i]['code'] === T_SEMICOLON) { - // We reached the end of the statement. - return; - } - - if ($tokens[$i]['code'] === T_INLINE_THEN) { - // We reached the end of the inline THEN statement. - return; - } - - if ($tokens[$i]['code'] === T_COLON) { - $then = $phpcsFile->findPrevious(T_INLINE_THEN, ($i - 1), null, false, null, true); - if ($then !== false) { - // We reached the end of the inline ELSE statement. - return; - } - } - - if (in_array($tokens[$i]['code'], PHP_CodeSniffer_Tokens::$emptyTokens) === false) { - $prevLine = $tokens[$i]['line']; - break; - } - } - - // Ignore the first part of FOR loops as we are allowed to - // assign variables there even though the variable is not the - // first thing on the line. Also ignore WHILE loops. - if ($tokens[$i]['code'] === T_OPEN_PARENTHESIS && isset($tokens[$i]['parenthesis_owner']) === true) { - $owner = $tokens[$i]['parenthesis_owner']; - if ($tokens[$owner]['code'] === T_FOR || $tokens[$owner]['code'] === T_WHILE) { - return; - } - } - - if ($prevLine === $varLine) { - $error = 'Assignments must be the first block of code on a line'; - $phpcsFile->addError($error, $stackPtr, 'Found'); - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/PHP/DisallowObEndFlushSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/PHP/DisallowObEndFlushSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/PHP/DisallowObEndFlushSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/PHP/DisallowObEndFlushSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,68 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_Formatting_DisallowObEndFlushSniff. - * - * Checks the indenting used when an ob_start() call occurs. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_PHP_DisallowObEndFlushSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array(T_STRING); - - }//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(); - - if ($tokens[$stackPtr]['content'] === 'ob_end_flush') { - $phpcsFile->addError('Use of ob_end_flush() is not allowed; use ob_get_contents() and ob_end_clean() instead', $stackPtr, 'Found'); - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/PHP/DisallowSizeFunctionsInLoopsSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/PHP/DisallowSizeFunctionsInLoopsSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/PHP/DisallowSizeFunctionsInLoopsSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/PHP/DisallowSizeFunctionsInLoopsSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,121 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_PHP_DisallowSizeFunctionsInLoopsSniff. - * - * Bans the use of size-based functions in loop conditions. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_PHP_DisallowSizeFunctionsInLoopsSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - ); - - /** - * An array of functions we don't want in the condition of loops. - * - * @return array - */ - protected $forbiddenFunctions = array( - 'PHP' => array( - 'sizeof', - 'strlen', - 'count', - ), - 'JS' => array( - 'length', - ), - ); - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array(T_WHILE, T_FOR); - - }//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(); - $tokenizer = $phpcsFile->tokenizerType; - $openBracket = $tokens[$stackPtr]['parenthesis_opener']; - $closeBracket = $tokens[$stackPtr]['parenthesis_closer']; - - if ($tokens[$stackPtr]['code'] === T_FOR) { - // We only want to check the condition in FOR loops. - $start = $phpcsFile->findNext(T_SEMICOLON, ($openBracket + 1)); - $end = $phpcsFile->findPrevious(T_SEMICOLON, ($closeBracket - 1)); - } else { - $start = $openBracket; - $end = $closeBracket; - } - - for ($i = ($start + 1); $i < $end; $i++) { - if ($tokens[$i]['code'] === T_STRING && in_array($tokens[$i]['content'], $this->forbiddenFunctions[$tokenizer])) { - $functionName = $tokens[$i]['content']; - if ($tokenizer === 'JS') { - // Needs to be in the form object.function to be valid. - $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($i - 1), null, true); - if ($prev === false || $tokens[$prev]['code'] !== T_OBJECT_OPERATOR) { - continue; - } - - $functionName = 'object.'.$functionName; - } else { - $functionName .= '()'; - } - - $error = 'The use of %s inside a loop condition is not allowed; assign the return value to a variable and use the variable in the loop condition instead'; - $data = array($functionName); - $phpcsFile->addError($error, $i, 'Found', $data); - }//end if - }//end for - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/PHP/DiscouragedFunctionsSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/PHP/DiscouragedFunctionsSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/PHP/DiscouragedFunctionsSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/PHP/DiscouragedFunctionsSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,57 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -if (class_exists('Generic_Sniffs_PHP_ForbiddenFunctionsSniff', true) === false) { - throw new PHP_CodeSniffer_Exception('Class Generic_Sniffs_PHP_ForbiddenFunctionsSniff not found'); -} - -/** - * Squiz_Sniffs_PHP_DiscouragedFunctionsSniff. - * - * Discourages the use of debug functions. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_PHP_DiscouragedFunctionsSniff extends Generic_Sniffs_PHP_ForbiddenFunctionsSniff -{ - - /** - * A list of forbidden functions with their alternatives. - * - * The value is NULL if no alternative exists. IE, the - * function should just not be used. - * - * @var array(string => string|null) - */ - protected $forbiddenFunctions = array( - 'error_log' => null, - 'print_r' => null, - ); - - /** - * If true, an error will be thrown; otherwise a warning. - * - * @var bool - */ - public $error = false; - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,263 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_PHP_EmbeddedPhpSniff. - * - * Checks the indentation of embedded PHP code segments. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_PHP_EmbeddedPhpSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * 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 void - */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - - // If the close php tag is on the same line as the opening - // then we have an inline embedded PHP block. - $closeTag = $phpcsFile->findNext(array(T_CLOSE_TAG), $stackPtr); - if ($closeTag === false) { - return; - } - - if ($tokens[$stackPtr]['line'] !== $tokens[$closeTag]['line']) { - $this->_validateMultilineEmbeddedPhp($phpcsFile, $stackPtr); - } else { - $this->_validateInlineEmbeddedPhp($phpcsFile, $stackPtr); - } - - }//end process() - - - /** - * Validates embedded PHP that exists on multiple lines. - * - * @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 - */ - private function _validateMultilineEmbeddedPhp(PHP_CodeSniffer_File $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - - $prevTag = $phpcsFile->findPrevious(T_OPEN_TAG, ($stackPtr - 1)); - if ($prevTag === false) { - // This is the first open tag. - return; - } - - // This isn't the first opening tag. - $closingTag = $phpcsFile->findNext(T_CLOSE_TAG, $stackPtr); - if ($closingTag === false) { - // No closing tag? Problem. - return; - } - - $nextContent = $phpcsFile->findNext(T_WHITESPACE, ($closingTag + 1), $phpcsFile->numTokens, true); - if ($nextContent === false) { - // Final closing tag. It will be handled elsewhere. - return; - } - - // Make sure the lines are opening and closing on different lines. - if ($tokens[$stackPtr]['line'] === $tokens[$closingTag]['line']) { - return; - } - - // We have an opening and a closing tag, that lie within other content. - // They are also on different lines. - $firstContent = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), $closingTag, true); - if ($firstContent === false) { - $error = 'Empty embedded PHP tag found'; - $phpcsFile->addError($error, $stackPtr, 'Empty'); - return; - } - - // Check for a blank line at the top. - if ($tokens[$firstContent]['line'] > ($tokens[$stackPtr]['line'] + 1)) { - // Find a token on the blank line to throw the error on. - $i = $stackPtr; - do { - $i++; - } while ($tokens[$i]['line'] !== ($tokens[$stackPtr]['line'] + 1)); - - $error = 'Blank line found at start of embedded PHP content'; - $phpcsFile->addError($error, $i, 'SpacingBefore'); - } else if ($tokens[$firstContent]['line'] === $tokens[$stackPtr]['line']) { - $error = 'Opening PHP tag must be on a line by itself'; - $phpcsFile->addError($error, $stackPtr, 'ContentAfterOpen'); - } - - // Check the indent of the first line. - $startColumn = $tokens[$stackPtr]['column']; - $contentColumn = $tokens[$firstContent]['column']; - if ($contentColumn !== $startColumn) { - $error = 'First line of embedded PHP code must be indented %s spaces; %s found'; - $data = array( - $startColumn, - $contentColumn, - ); - $phpcsFile->addError($error, $firstContent, 'Indent', $data); - } - - // Check for a blank line at the bottom. - $lastContent = $phpcsFile->findPrevious(T_WHITESPACE, ($closingTag - 1), ($stackPtr + 1), true); - if ($tokens[$lastContent]['line'] < ($tokens[$closingTag]['line'] - 1)) { - // Find a token on the blank line to throw the error on. - $i = $closingTag; - do { - $i--; - } while ($tokens[$i]['line'] !== ($tokens[$closingTag]['line'] - 1)); - - $error = 'Blank line found at end of embedded PHP content'; - $phpcsFile->addError($error, $i, 'SpacingAfter'); - } else if ($tokens[$lastContent]['line'] === $tokens[$closingTag]['line']) { - $error = 'Closing PHP tag must be on a line by itself'; - $phpcsFile->addError($error, $closingTag, 'ContentAfterEnd'); - } - - }//end _validateMultilineEmbeddedPhp() - - - /** - * Validates embedded PHP that exists on one line. - * - * @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 - */ - private function _validateInlineEmbeddedPhp(PHP_CodeSniffer_File $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - - // We only want one line PHP sections, so return if the closing tag is - // on the next line. - $closeTag = $phpcsFile->findNext(array(T_CLOSE_TAG), $stackPtr, null, false); - if ($tokens[$stackPtr]['line'] !== $tokens[$closeTag]['line']) { - return; - } - - // Check that there is one, and only one space at the start of the statement. - $firstContent = $phpcsFile->findNext(array(T_WHITESPACE), ($stackPtr + 1), null, true); - - if ($firstContent === false || $tokens[$firstContent]['code'] === T_CLOSE_TAG) { - $error = 'Empty embedded PHP tag found'; - $phpcsFile->addError($error, $stackPtr, 'Empty'); - return; - } - - $leadingSpace = ''; - for ($i = ($stackPtr + 1); $i < $firstContent; $i++) { - $leadingSpace .= $tokens[$i]['content']; - } - - if (strlen($leadingSpace) >= 1) { - $error = 'Expected 1 space after opening PHP tag; %s found'; - $data = array((strlen($leadingSpace) + 1)); - $phpcsFile->addError($error, $stackPtr, 'SpacingAfterOpen', $data); - } - - $semiColonCount = 0; - $semiColon = $stackPtr; - $lastSemiColon = $semiColon; - - while (($semiColon = $phpcsFile->findNext(array(T_SEMICOLON), ($semiColon + 1), $closeTag)) !== false) { - $lastSemiColon = $semiColon; - $semiColonCount++; - } - - $semiColon = $lastSemiColon; - $error = ''; - - // Make sure there is atleast 1 semicolon. - if ($semiColonCount === 0) { - $error = 'Inline PHP statement must end with a semicolon'; - $phpcsFile->addError($error, $stackPtr, 'NoSemicolon'); - return; - } - - // Make sure that there aren't more semicolons than are allowed. - if ($semiColonCount > 1) { - $error = 'Inline PHP statement must contain one statement per line; %s found'; - $data = array($semiColonCount); - $phpcsFile->addError($error, $stackPtr, 'MultipleStatements', $data); - } - - // The statement contains only 1 semicolon, now it must be spaced properly. - $whitespace = ''; - for ($i = ($semiColon + 1); $i < $closeTag; $i++) { - if ($tokens[$i]['code'] !== T_WHITESPACE) { - $error = 'Expected 1 space before closing PHP tag; 0 found'; - $phpcsFile->addError($error, $stackPtr, 'NoSpaceBeforeClose'); - return; - } - - $whitespace .= $tokens[$i]['content']; - } - - if (strlen($whitespace) === 1) { - return; - } - - if (strlen($whitespace) === 0) { - $error = 'Expected 1 space before closing PHP tag; 0 found'; - $phpcsFile->addError($error, $stackPtr, 'NoSpaceBeforeClose'); - } else { - $error = 'Expected 1 space before closing PHP tag; %s found'; - $data = array(strlen($whitespace)); - $phpcsFile->addError($error, $stackPtr, 'SpacingBeforeClose', $data); - } - - }//end _validateInlineEmbeddedPhp() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/PHP/EvalSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/PHP/EvalSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/PHP/EvalSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/PHP/EvalSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,65 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_PHP_EvalSniff. - * - * The use of eval() is discouraged. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_PHP_EvalSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array(T_EVAL); - - }//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) - { - $error = 'Use of eval() is discouraged'; - $phpcsFile->addWarning($error, $stackPtr, 'Discouraged'); - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/PHP/ForbiddenFunctionsSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/PHP/ForbiddenFunctionsSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/PHP/ForbiddenFunctionsSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/PHP/ForbiddenFunctionsSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,71 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -if (class_exists('Generic_Sniffs_PHP_ForbiddenFunctionsSniff', true) === false) { - throw new PHP_CodeSniffer_Exception('Class Generic_Sniffs_PHP_ForbiddenFunctionsSniff not found'); -} - -/** - * Squiz_Sniffs_PHP_ForbiddenFunctionsSniff. - * - * Discourages the use of alias functions that are kept in PHP for compatibility - * with older versions. Can be used to forbid the use of any function. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_PHP_ForbiddenFunctionsSniff extends Generic_Sniffs_PHP_ForbiddenFunctionsSniff -{ - - /** - * A list of forbidden functions with their alternatives. - * - * The value is NULL if no alternative exists. IE, the - * function should just not be used. - * - * @var array(string => string|null) - */ - protected $forbiddenFunctions = array( - 'sizeof' => 'count', - 'delete' => 'unset', - 'print' => 'echo', - 'is_null' => null, - 'create_function' => null, - ); - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - $tokens = parent::register(); - $tokens[] = T_PRINT; - return $tokens; - - }//end register() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/PHP/GlobalKeywordSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/PHP/GlobalKeywordSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/PHP/GlobalKeywordSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/PHP/GlobalKeywordSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,70 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_PHP_GlobalKeywordSniff. - * - * Stops the usage of the "global" keyword. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_PHP_GlobalKeywordSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array(T_GLOBAL); - - }//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(); - - $nextVar = $tokens[$phpcsFile->findNext(array(T_VARIABLE), $stackPtr)]; - $varName = str_replace('$', '', $nextVar['content']); - $error = 'Use of the "global" keyword is forbidden; use "$GLOBALS[\'%s\']" instead'; - $data = array($varName); - $phpcsFile->addError($error, $stackPtr, 'NotAllowed', $data); - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/PHP/HeredocSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/PHP/HeredocSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/PHP/HeredocSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/PHP/HeredocSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,68 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_PHP_HeredocSniff. - * - * Heredocs are prohibited. This test enforces that. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_PHP_HeredocSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array( - T_START_HEREDOC, - T_START_NOWDOC, - ); - - }//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) - { - $error = 'Use of heredoc and nowdoc syntax ("<<<") is not allowed; use standard strings or inline HTML instead'; - $phpcsFile->addError($error, $stackPtr, 'NotAllowed'); - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/PHP/InnerFunctionsSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/PHP/InnerFunctionsSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/PHP/InnerFunctionsSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/PHP/InnerFunctionsSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,75 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_PHP_InnerFunctionsSniff. - * - * Ensures that functions within functions are never used. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_PHP_InnerFunctionsSniff 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(); - - if ($phpcsFile->hasCondition($stackPtr, T_FUNCTION) === true) { - $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); - if ($tokens[$prev]['code'] === T_EQUAL) { - // Ignore closures. - return; - } - - $error = 'The use of inner functions is forbidden'; - $phpcsFile->addError($error, $stackPtr, 'NotAllowed'); - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/PHP/LowercasePHPFunctionsSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/PHP/LowercasePHPFunctionsSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/PHP/LowercasePHPFunctionsSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/PHP/LowercasePHPFunctionsSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,149 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_PHP_LowercasePHPFunctionsSniff. - * - * Ensures all calls to inbuilt PHP functions are lowercase. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_PHP_LowercasePHPFunctionsSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array( - T_ISSET, - T_ECHO, - T_PRINT, - T_RETURN, - T_BREAK, - T_CONTINUE, - T_EMPTY, - T_EVAL, - T_EXIT, - T_LIST, - T_UNSET, - T_INCLUDE, - T_INCLUDE_ONCE, - T_REQUIRE, - T_REQUIRE_ONCE, - T_NEW, - T_DECLARE, - T_STRING, - ); - - }//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(); - - if ($tokens[$stackPtr]['code'] !== T_STRING) { - $content = $tokens[$stackPtr]['content']; - if ($content !== strtolower($content)) { - $error = '%s keyword must be lowercase; expected "%s" but found "%s"'; - $data = array( - strtoupper($content), - strtolower($content), - $content, - ); - $phpcsFile->addError($error, $stackPtr, 'KeywordUppercase', $data); - } - - return; - } - - // Make sure this is a function call. - $next = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); - if ($next === false) { - // Not a function call. - return; - } - - if ($tokens[$next]['code'] !== T_OPEN_PARENTHESIS) { - // Not a function call. - return; - } - - $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); - if ($tokens[$prev]['code'] === T_FUNCTION) { - // Function declaration, not a function call. - return; - } - - if ($tokens[$prev]['code'] === T_NEW) { - // Object creation, not an inbuilt function. - return; - } - - if ($tokens[$prev]['code'] === T_OBJECT_OPERATOR) { - // Not an inbuilt function. - return; - } - - if ($tokens[$prev]['code'] === T_DOUBLE_COLON) { - // Not an inbuilt function. - return; - } - - // Make sure it is an inbuilt PHP function. - // PHP_CodeSniffer doesn't include/require any files, so no - // user defined global functions can exist, except for - // PHP_CodeSniffer ones. - $content = $tokens[$stackPtr]['content']; - if (function_exists($content) === false) { - return; - } - - if ($content !== strtolower($content)) { - $error = 'Calls to inbuilt PHP functions must be lowercase; expected "%s" but found "%s"'; - $data = array( - strtolower($content), - $content, - ); - $phpcsFile->addError($error, $stackPtr, 'CallUppercase', $data); - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/PHP/NonExecutableCodeSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/PHP/NonExecutableCodeSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/PHP/NonExecutableCodeSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/PHP/NonExecutableCodeSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,238 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_PHP_NonExecutableCodeSniff. - * - * Warns about code that can never been executed. This happens when a function - * returns before the code, or a break ends execution of a statement etc. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_PHP_NonExecutableCodeSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array( - T_BREAK, - T_CONTINUE, - T_RETURN, - T_THROW, - T_EXIT, - ); - - }//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(); - - // If this token is preceeded with an "or", it only relates to one line - // and should be ignore. For example: fopen() or die(). - $prev = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true); - if ($tokens[$prev]['code'] === T_LOGICAL_OR) { - return; - } - - // Collect closure function parenthesises to use later for supressing some errors. - $closureReturnParenthesises = array(); - $closureToken = $phpcsFile->findNext(T_CLOSURE, $stackPtr); - if ($closureToken !== false) { - $closureToken--; - while (($closureToken = $phpcsFile->findNext(T_CLOSURE, ($closureToken + 1))) !== false) { - $closureEndToken = $tokens[$closureToken]['scope_closer']; - $parenthesis = $phpcsFile->findNext(T_RETURN, $closureToken, $closureEndToken); - if (isset($tokens[$parenthesis]['nested_parenthesis']) === true) { - $closureReturnParenthesises[] = $tokens[$parenthesis]['nested_parenthesis']; - } - } - } - - if ($tokens[$stackPtr]['code'] === T_RETURN) { - $next = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); - if ($tokens[$next]['code'] === T_SEMICOLON) { - $next = $phpcsFile->findNext(T_WHITESPACE, ($next + 1), null, true); - if ($tokens[$next]['code'] === T_CLOSE_CURLY_BRACKET) { - // If this is the closing brace of a function - // then this return statement doesn't return anything - // and is not required anyway. - $owner = $tokens[$next]['scope_condition']; - if ($tokens[$owner]['code'] === T_FUNCTION) { - $warning = 'Empty return statement not required here'; - $phpcsFile->addWarning($warning, $stackPtr, 'ReturnNotRequired'); - return; - } - } - } - } - - if ($tokens[$stackPtr]['code'] === T_BREAK - && isset($tokens[$stackPtr]['scope_opener']) === true - ) { - // This break closes the scope of a CASE or DEFAULT statement - // so any code between this token and the next CASE, DEFAULT or - // end of SWITCH token will not be executable. - $next = $phpcsFile->findNext( - array(T_CASE, T_DEFAULT, T_CLOSE_CURLY_BRACKET), - ($stackPtr + 1) - ); - - if ($next !== false) { - $lastLine = $tokens[($stackPtr + 1)]['line']; - for ($i = ($stackPtr + 1); $i < $next; $i++) { - if (in_array($tokens[$i]['code'], PHP_CodeSniffer_Tokens::$emptyTokens) === true) { - continue; - } - - $line = $tokens[$i]['line']; - if ($line > $lastLine) { - $type = substr($tokens[$stackPtr]['type'], 2); - $warning = 'Code after %s statement cannot be executed'; - $data = array($type); - $phpcsFile->addWarning($warning, $i, 'Unreachable', $data); - $lastLine = $line; - } - } - }//end if - - // That's all we have to check for these types of BREAK statements. - return; - }//end if - - // This token may be part of an inline condition. - // If we find a closing parenthesis that belongs to a condition - // we should ignore this token. - $prev = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true); - if (isset($tokens[$prev]['parenthesis_owner']) === true) { - $owner = $tokens[$prev]['parenthesis_owner']; - $ignore = array( - T_IF, - T_ELSE, - T_ELSEIF, - ); - if (in_array($tokens[$owner]['code'], $ignore) === true) { - return; - } - } - - $ourConditions = array_keys($tokens[$stackPtr]['conditions']); - - if (empty($ourConditions) === false) { - $condition = array_pop($ourConditions); - - if (isset($tokens[$condition]['scope_closer']) === false) { - return; - } - - $closer = $tokens[$condition]['scope_closer']; - - // If the closer for our condition is shared with other openers, - // we will need to throw errors from this token to the next - // shared opener (if there is one), not to the scope closer. - $nextOpener = null; - for ($i = ($stackPtr + 1); $i < $closer; $i++) { - if (isset($tokens[$i]['scope_closer']) === true) { - if ($tokens[$i]['scope_closer'] === $closer) { - // We found an opener that shares the same - // closing token as us. - $nextOpener = $i; - break; - } - } - }//end for - - $start = $phpcsFile->findNext(T_SEMICOLON, ($stackPtr + 1)); - - if ($nextOpener === null) { - $end = $closer; - } else { - $end = ($nextOpener - 1); - } - } else { - // This token is in the global scope. - if ($tokens[$stackPtr]['code'] === T_BREAK) { - return; - } - - // Throw an error for all lines until the end of the file. - $start = $phpcsFile->findNext(T_SEMICOLON, ($stackPtr + 1)); - $end = ($phpcsFile->numTokens - 1); - }//end if - - $lastLine = $tokens[$start]['line']; - for ($i = ($start + 1); $i < $end; $i++) { - if (in_array($tokens[$i]['code'], PHP_CodeSniffer_Tokens::$emptyTokens) === true - || in_array($tokens[$i]['code'], PHP_CodeSniffer_Tokens::$bracketTokens) === true - ) { - continue; - } - - // Skip returns found in closure functions. - if (isset($tokens[$i]['nested_parenthesis']) === true - && in_array($tokens[$i]['nested_parenthesis'], $closureReturnParenthesises) === true - ) { - return; - } - - // Skip whole functions and classes/interfaces because they are not - // technically executed code, but rather declarations that may be used. - if ($tokens[$i]['code'] === T_FUNCTION - || $tokens[$i]['code'] === T_CLASS - || $tokens[$i]['code'] === T_INTERFACE - ) { - $i = $tokens[$i]['scope_closer']; - continue; - } - - $line = $tokens[$i]['line']; - if ($line > $lastLine) { - $type = substr($tokens[$stackPtr]['type'], 2); - $warning = 'Code after %s statement cannot be executed'; - $data = array($type); - $phpcsFile->addWarning($warning, $i, 'Unreachable', $data); - $lastLine = $line; - } - }//end for - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Scope/MemberVarScopeSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Scope/MemberVarScopeSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Scope/MemberVarScopeSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Scope/MemberVarScopeSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,92 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -if (class_exists('PHP_CodeSniffer_Standards_AbstractVariableSniff', true) === false) { - throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_Standards_AbstractVariableSniff not found'); -} - -/** - * Verifies that class members have scope modifiers. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_Scope_MemberVarScopeSniff extends PHP_CodeSniffer_Standards_AbstractVariableSniff -{ - - - /** - * Processes the function tokens within the class. - * - * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found. - * @param int $stackPtr The position where the token was found. - * - * @return void - */ - protected function processMemberVar(PHP_CodeSniffer_File $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - $modifier = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$scopeModifiers, $stackPtr); - - if (($modifier === false) || ($tokens[$modifier]['line'] !== $tokens[$stackPtr]['line'])) { - $error = 'Scope modifier not specified for member variable "%s"'; - $data = array($tokens[$stackPtr]['content']); - $phpcsFile->addError($error, $stackPtr, 'Missing', $data); - } - - }//end processMemberVar() - - - /** - * Processes normal variables. - * - * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found. - * @param int $stackPtr The position where the token was found. - * - * @return void - */ - protected function processVariable(PHP_CodeSniffer_File $phpcsFile, $stackPtr) - { - // We don't care about normal variables. - return; - - }//end processVariable() - - - /** - * Processes variables in double quoted strings. - * - * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found. - * @param int $stackPtr The position where the token was found. - * - * @return void - */ - protected function processVariableInString(PHP_CodeSniffer_File $phpcsFile, $stackPtr) - { - // We don't care about normal variables. - return; - - }//end processVariableInString() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Scope/MethodScopeSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Scope/MethodScopeSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Scope/MethodScopeSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Scope/MethodScopeSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,77 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -if (class_exists('PHP_CodeSniffer_Standards_AbstractScopeSniff', true) === false) { - throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_Standards_AbstractScopeSniff not found'); -} - -/** - * Verifies that class members have scope modifiers. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_Scope_MethodScopeSniff extends PHP_CodeSniffer_Standards_AbstractScopeSniff -{ - - - /** - * Constructs a Squiz_Sniffs_Scope_MethodScopeSniff. - */ - public function __construct() - { - parent::__construct(array(T_CLASS, T_INTERFACE), array(T_FUNCTION)); - - }//end __construct() - - - /** - * Processes the function tokens within the class. - * - * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found. - * @param int $stackPtr The position where the token was found. - * @param int $currScope The current scope opener token. - * - * @return void - */ - protected function processTokenWithinScope(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $currScope) - { - $tokens = $phpcsFile->getTokens(); - - $methodName = $phpcsFile->getDeclarationName($stackPtr); - if ($methodName === null) { - // Ignore closures. - return; - } - - $modifier = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$scopeModifiers, $stackPtr); - if (($modifier === false) || ($tokens[$modifier]['line'] !== $tokens[$stackPtr]['line'])) { - $error = 'No scope modifier specified for function "%s"'; - $data = array($methodName); - $phpcsFile->addError($error, $stackPtr, 'Missing', $data); - } - - }//end processTokenWithinScope() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Scope/StaticThisUsageSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Scope/StaticThisUsageSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Scope/StaticThisUsageSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Scope/StaticThisUsageSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,99 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -if (class_exists('PHP_CodeSniffer_Standards_AbstractScopeSniff', true) === false) { - throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_Standards_AbstractScopeSniff not found'); -} - -/** - * Squiz_Sniffs_Scope_StaticThisUsageSniff. - * - * Checks for usage of "$this" in static methods, which will cause - * runtime errors. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_Scope_StaticThisUsageSniff extends PHP_CodeSniffer_Standards_AbstractScopeSniff -{ - - - /** - * Constructs the test with the tokens it wishes to listen for. - * - * @return void - */ - public function __construct() - { - parent::__construct(array(T_CLASS), array(T_FUNCTION)); - - }//end __construct() - - - /** - * Processes this test, when one of its tokens is encountered. - * - * @param PHP_CodeSniffer_File $phpcsFile The current file being scanned. - * @param int $stackPtr The position of the current token in the - * stack passed in $tokens. - * @param int $currScope A pointer to the start of the scope. - * - * @return void - */ - public function processTokenWithinScope(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $currScope) - { - $tokens = $phpcsFile->getTokens(); - $function = $tokens[($stackPtr + 2)]; - - if ($function['code'] !== T_STRING) { - return; - } - - $functionName = $function['content']; - $classOpener = $tokens[$currScope]['scope_condition']; - $className = $tokens[($classOpener + 2)]['content']; - - $methodProps = $phpcsFile->getMethodProperties($stackPtr); - - if ($methodProps['is_static'] === true) { - if (isset($tokens[$stackPtr]['scope_closer']) === false) { - // There is no scope opener or closer, so the function - // must be abstract. - return; - } - - $thisUsage = $stackPtr; - while (($thisUsage = $phpcsFile->findNext(array(T_VARIABLE), ($thisUsage + 1), $tokens[$stackPtr]['scope_closer'], false, '$this')) !== false) { - if ($thisUsage === false) { - return; - } - - $error = 'Usage of "$this" in static methods will cause runtime errors'; - $phpcsFile->addError($error, $thisUsage, 'Found'); - } - }//end if - - }//end processTokenWithinScope() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Strings/ConcatenationSpacingSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Strings/ConcatenationSpacingSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Strings/ConcatenationSpacingSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Strings/ConcatenationSpacingSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,71 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_Strings_ConcatenationSpacingSniff. - * - * Makes sure there are no spaces between the concatenation operator (.) and - * the strings being concatenated. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_Strings_ConcatenationSpacingSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array(T_STRING_CONCAT); - - }//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(); - if ($tokens[($stackPtr - 1)]['code'] === T_WHITESPACE - || $tokens[($stackPtr + 1)]['code'] === T_WHITESPACE - ) { - $message = 'Concat operator must not be surrounded by spaces'; - $phpcsFile->addError($message, $stackPtr, 'Missing'); - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,135 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_Strings_DoubleQuoteUsageSniff. - * - * Makes sure that any use of Double Quotes ("") are warranted. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_Strings_DoubleQuoteUsageSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array( - T_CONSTANT_ENCAPSED_STRING, - T_DOUBLE_QUOTED_STRING, - ); - - }//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(); - - // We are only interested in the first token in a multi-line string. - if ($tokens[$stackPtr]['code'] === $tokens[($stackPtr - 1)]['code']) { - return; - } - - $workingString = $tokens[$stackPtr]['content']; - $i = ($stackPtr + 1); - while ($tokens[$i]['code'] === $tokens[$stackPtr]['code']) { - $workingString .= $tokens[$i]['content']; - $i++; - } - - // Check if it's a double quoted string. - if (strpos($workingString, '"') === false) { - return; - } - - // Make sure it's not a part of a string started in a previous line. - // If it is, then we have already checked it. - if ($workingString[0] !== '"') { - return; - } - - // The use of variables in double quoted strings is not allowed. - if ($tokens[$stackPtr]['code'] === T_DOUBLE_QUOTED_STRING) { - $stringTokens = token_get_all('addError($error, $stackPtr, 'ContainsVar', $data); - } - } - - return; - }//end if - - // Work through the following tokens, in case this string is stretched - // over multiple Lines. - for ($i = ($stackPtr + 1); $i < $phpcsFile->numTokens; $i++) { - if ($tokens[$i]['type'] !== 'T_CONSTANT_ENCAPSED_STRING') { - break; - } - - $workingString .= $tokens[$i]['content']; - } - - $allowedChars = array( - '\0', - '\n', - '\r', - '\f', - '\t', - '\v', - '\x', - '\'', - ); - - foreach ($allowedChars as $testChar) { - if (strpos($workingString, $testChar) !== false) { - return; - } - } - - $error = 'String %s does not require double quotes; use single quotes instead'; - $data = array($workingString); - $phpcsFile->addError($error, $stackPtr, 'NotRequired', $data); - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Strings/EchoedStringsSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Strings/EchoedStringsSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Strings/EchoedStringsSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/Strings/EchoedStringsSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,84 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_Strings_EchoedStringsSniff. - * - * Makes sure that any strings that are "echoed" are not enclosed in brackets - * like a function call. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_Strings_EchoedStringsSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array(T_ECHO); - - }//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(); - - $firstContent = $phpcsFile->findNext(array(T_WHITESPACE), ($stackPtr + 1), null, true); - // If the first non-whitespace token is not an opening parenthesis, then we are not concerned. - if ($tokens[$firstContent]['code'] !== T_OPEN_PARENTHESIS) { - return; - } - - $endOfStatement = $phpcsFile->findNext(array(T_SEMICOLON), $stackPtr, null, false); - - // If the token before the semi-colon is not a closing parenthesis, then we are not concerned. - if ($tokens[($endOfStatement - 1)]['code'] !== T_CLOSE_PARENTHESIS) { - return; - } - - if (($phpcsFile->findNext(PHP_CodeSniffer_Tokens::$operators, $stackPtr, $endOfStatement, false)) === false) { - // There are no arithmetic operators in this. - $error = 'Echoed strings should not be bracketed'; - $phpcsFile->addError($error, $stackPtr, 'HasBracket'); - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/CastSpacingSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/CastSpacingSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/CastSpacingSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/CastSpacingSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,77 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_WhiteSpace_CastSpacingSniff. - * - * Ensure cast statements dont contain whitespace. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_WhiteSpace_CastSpacingSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return PHP_CodeSniffer_Tokens::$castTokens; - - }//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(); - - $content = $tokens[$stackPtr]['content']; - $expected = str_replace(' ', '', $content); - $expected = str_replace("\t", '', $expected); - - if ($content !== $expected) { - $error = 'Cast statements must not contain whitespace; expected "%s" but found "%s"'; - $data = array( - $expected, - $content, - ); - $phpcsFile->addError($error, $stackPtr, 'ContainsWhiteSpace', $data); - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,211 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_WhiteSpace_ControlStructureSpacingSniff. - * - * Checks that control structures have the correct spacing around brackets. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_WhiteSpace_ControlStructureSpacingSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - ); - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array( - T_IF, - T_WHILE, - T_FOREACH, - T_FOR, - T_SWITCH, - T_DO, - T_ELSE, - T_ELSEIF, - ); - - }//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(); - - if (isset($tokens[$stackPtr]['scope_closer']) === false) { - return; - } - - if (isset($tokens[$stackPtr]['parenthesis_opener']) === true) { - $parenOpener = $tokens[$stackPtr]['parenthesis_opener']; - $parenCloser = $tokens[$stackPtr]['parenthesis_closer']; - if ($tokens[($parenOpener + 1)]['code'] === T_WHITESPACE) { - $gap = strlen($tokens[($parenOpener + 1)]['content']); - $error = 'Expected 0 spaces after opening bracket; %s found'; - $data = array($gap); - $phpcsFile->addError($error, ($parenOpener + 1), 'SpacingAfterOpenBrace', $data); - } - - if ($tokens[$parenOpener]['line'] === $tokens[$parenCloser]['line'] - && $tokens[($parenCloser - 1)]['code'] === T_WHITESPACE - ) { - $gap = strlen($tokens[($parenCloser - 1)]['content']); - $error = 'Expected 0 spaces before closing bracket; %s found'; - $data = array($gap); - $phpcsFile->addError($error, ($parenCloser - 1), 'SpaceBeforeCloseBrace', $data); - } - }//end if - - $scopeOpener = $tokens[$stackPtr]['scope_opener']; - $scopeCloser = $tokens[$stackPtr]['scope_closer']; - - $firstContent = $phpcsFile->findNext( - T_WHITESPACE, - ($scopeOpener + 1), - null, - true - ); - - if ($tokens[$firstContent]['line'] !== ($tokens[$scopeOpener]['line'] + 1)) { - $error = 'Blank line found at start of control structure'; - $phpcsFile->addError($error, $scopeOpener, 'SpacingBeforeOpen'); - } - - $lastContent = $phpcsFile->findPrevious( - T_WHITESPACE, - ($scopeCloser - 1), - null, - true - ); - - if ($tokens[$lastContent]['line'] !== ($tokens[$scopeCloser]['line'] - 1)) { - $errorToken = $scopeCloser; - for ($i = ($scopeCloser - 1); $i > $lastContent; $i--) { - if ($tokens[$i]['line'] < $tokens[$scopeCloser]['line']) { - $errorToken = $i; - break; - } - } - - $error = 'Blank line found at end of control structure'; - $phpcsFile->addError($error, $errorToken, 'SpacingAfterClose'); - } - - $trailingContent = $phpcsFile->findNext( - T_WHITESPACE, - ($scopeCloser + 1), - null, - true - ); - - if ($tokens[$trailingContent]['code'] === T_ELSE) { - if ($tokens[$stackPtr]['code'] === T_IF) { - // IF with ELSE. - return; - } - } - - if ($tokens[$trailingContent]['code'] === T_COMMENT) { - if ($tokens[$trailingContent]['line'] === $tokens[$scopeCloser]['line']) { - if (substr($tokens[$trailingContent]['content'], 0, 5) === '//end') { - // There is an end comment, so we have to get the next piece - // of content. - $trailingContent = $phpcsFile->findNext( - T_WHITESPACE, - ($trailingContent + 1), - null, - true - ); - } - } - } - - if ($tokens[$trailingContent]['code'] === T_BREAK) { - // If this BREAK is closing a CASE, we don't need the - // blank line after this control structure. - if (isset($tokens[$trailingContent]['scope_condition']) === true) { - $condition = $tokens[$trailingContent]['scope_condition']; - if ($tokens[$condition]['code'] === T_CASE - || $tokens[$condition]['code'] === T_DEFAULT - ) { - return; - } - } - } - - if ($tokens[$trailingContent]['code'] === T_CLOSE_TAG) { - // At the end of the script or embedded code. - return; - } - - if ($tokens[$trailingContent]['code'] === T_CLOSE_CURLY_BRACKET) { - // Another control structure's closing brace. - if (isset($tokens[$trailingContent]['scope_condition']) === true) { - $owner = $tokens[$trailingContent]['scope_condition']; - if ($tokens[$owner]['code'] === T_FUNCTION) { - // The next content is the closing brace of a function - // so normal function rules apply and we can ignore it. - return; - } - } - - if ($tokens[$trailingContent]['line'] !== ($tokens[$scopeCloser]['line'] + 1)) { - $error = 'Blank line found after control structure'; - $phpcsFile->addError($error, $scopeCloser, 'LineAfterClose'); - } - } else { - if ($tokens[$trailingContent]['line'] === ($tokens[$scopeCloser]['line'] + 1)) { - $error = 'No blank line found after control structure'; - $phpcsFile->addError($error, $scopeCloser, 'NoLineAfterClose'); - } - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/FunctionClosingBraceSpaceSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/FunctionClosingBraceSpaceSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/FunctionClosingBraceSpaceSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/FunctionClosingBraceSpaceSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,116 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_WhiteSpace_FunctionClosingBraceSpaceSniff. - * - * Checks that there is one empty line before the closing brace of a function. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_WhiteSpace_FunctionClosingBraceSpaceSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - ); - - - /** - * 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(); - - if (isset($tokens[$stackPtr]['scope_closer']) === false) { - // Probably an interface method. - return; - } - - $closeBrace = $tokens[$stackPtr]['scope_closer']; - $prevContent = $phpcsFile->findPrevious(T_WHITESPACE, ($closeBrace - 1), null, true); - - // Special case for empty JS functions - if ($phpcsFile->tokenizerType === 'JS' && $prevContent === $tokens[$stackPtr]['scope_opener']) { - // In this case, the opening and closing brace must be - // right next to each other. - if ($tokens[$stackPtr]['scope_closer'] !== ($tokens[$stackPtr]['scope_opener'] + 1)) { - $error = 'The opening and closing braces of empty functions must be directly next to each other; e.g., function () {}'; - $phpcsFile->addError($error, $closeBrace, 'SpacingBetween'); - } - - return; - } - - $braceLine = $tokens[$closeBrace]['line']; - $prevLine = $tokens[$prevContent]['line']; - - $found = ($braceLine - $prevLine - 1); - if ($phpcsFile->hasCondition($stackPtr, T_FUNCTION) === true || isset($tokens[$stackPtr]['nested_parenthesis']) === true) { - // Nested function. - if ($found < 0) { - $error = 'Closing brace of nested function must be on a new line'; - $phpcsFile->addError($error, $closeBrace, 'ContentBeforeClose'); - } else if ($found > 0) { - $error = 'Expected 0 blank lines before closing brace of nested function; %s found'; - $data = array($found); - $phpcsFile->addError($error, $closeBrace, 'SpacingBeforeNestedClose', $data); - } - } else { - if ($found !== 1) { - $error = 'Expected 1 blank line before closing function brace; %s found'; - $data = array($found); - $phpcsFile->addError($error, $closeBrace, 'SpacingBeforeClose', $data); - } - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/FunctionOpeningBraceSpaceSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/FunctionOpeningBraceSpaceSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/FunctionOpeningBraceSpaceSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/FunctionOpeningBraceSpaceSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,128 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_WhiteSpace_FunctionOpeningBraceSpaceSniff. - * - * Checks that there is no empty line after the opening brace of a function. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_WhiteSpace_FunctionOpeningBraceSpaceSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - ); - - - /** - * 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(); - - if (isset($tokens[$stackPtr]['scope_opener']) === false) { - // Probably an interface method. - return; - } - - $openBrace = $tokens[$stackPtr]['scope_opener']; - $nextContent = $phpcsFile->findNext(T_WHITESPACE, ($openBrace + 1), null, true); - - if ($nextContent === $tokens[$stackPtr]['scope_closer']) { - // The next bit of content is the closing brace, so this - // is an empty function and should have a blank line - // between the opening and closing braces. - return; - } - - $braceLine = $tokens[$openBrace]['line']; - $nextLine = $tokens[$nextContent]['line']; - - $found = ($nextLine - $braceLine - 1); - if ($found > 0) { - $error = 'Expected 0 blank lines after opening function brace; %s found'; - $data = array($found); - $phpcsFile->addError($error, $openBrace, 'SpacingAfter', $data); - } - - if ($phpcsFile->tokenizerType === 'JS') { - // Do some additional checking before the function brace. - $nestedFunction = ($phpcsFile->hasCondition($stackPtr, T_FUNCTION) === true || isset($tokens[$stackPtr]['nested_parenthesis']) === true); - - $functionLine = $tokens[$tokens[$stackPtr]['parenthesis_closer']]['line']; - $lineDifference = ($braceLine - $functionLine); - - if ($nestedFunction === true) { - if ($lineDifference > 0) { - $error = 'Expected 0 blank lines before opening brace of nested function; %s found'; - $data = array($found); - $phpcsFile->addError($error, $openBrace, 'SpacingAfterNested', $data); - } - } else { - if ($lineDifference === 0) { - $error = 'Opening brace should be on a new line'; - $phpcsFile->addError($error, $openBrace, 'ContentBefore'); - return; - } - - if ($lineDifference > 1) { - $error = 'Opening brace should be on the line after the declaration; found %s blank line(s)'; - $data = array(($lineDifference - 1)); - $phpcsFile->addError($error, $openBrace, 'SpacingBefore', $data); - return; - } - }//end if - }//end if - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/FunctionSpacingSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/FunctionSpacingSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/FunctionSpacingSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/FunctionSpacingSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,170 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_WhiteSpace_FunctionSpacingSniff. - * - * Checks the separation between methods in a class or interface. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_WhiteSpace_FunctionSpacingSniff 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 sniff, 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(); - - /* - Check the number of blank lines - after the function. - */ - - if (isset($tokens[$stackPtr]['scope_closer']) === false) { - // Must be an interface method, so the closer is the semi-colon. - $closer = $phpcsFile->findNext(T_SEMICOLON, $stackPtr); - } else { - $closer = $tokens[$stackPtr]['scope_closer']; - } - - // There needs to be 2 blank lines after the closer. - $nextLineToken = null; - for ($i = $closer; $i < $phpcsFile->numTokens; $i++) { - if (strpos($tokens[$i]['content'], $phpcsFile->eolChar) === false) { - continue; - } else { - $nextLineToken = ($i + 1); - break; - } - } - - if (is_null($nextLineToken) === true) { - // Never found the next line, which means - // there are 0 blank lines after the function. - $foundLines = 0; - } else { - $nextContent = $phpcsFile->findNext(array(T_WHITESPACE), ($nextLineToken + 1), null, true); - if ($nextContent === false) { - // We are at the end of the file. - $foundLines = 0; - } else { - $foundLines = ($tokens[$nextContent]['line'] - $tokens[$nextLineToken]['line']); - } - } - - if ($foundLines !== 2) { - $error = 'Expected 2 blank lines after function; %s found'; - $data = array($foundLines); - $phpcsFile->addError($error, $closer, 'After', $data); - } - - /* - Check the number of blank lines - before the function. - */ - - $prevLineToken = null; - for ($i = $stackPtr; $i > 0; $i--) { - if (strpos($tokens[$i]['content'], $phpcsFile->eolChar) === false) { - continue; - } else { - $prevLineToken = $i; - break; - } - } - - if (is_null($prevLineToken) === true) { - // Never found the previous line, which means - // there are 0 blank lines before the function. - $foundLines = 0; - } else { - $prevContent = $phpcsFile->findPrevious(array(T_WHITESPACE, T_DOC_COMMENT), $prevLineToken, null, true); - - // Before we throw an error, check that we are not throwing an error - // for another function. We don't want to error for no blank lines after - // the previous function and no blank lines before this one as well. - $currentLine = $tokens[$stackPtr]['line']; - $prevLine = ($tokens[$prevContent]['line'] - 1); - $i = ($stackPtr - 1); - $foundLines = 0; - while ($currentLine != $prevLine && $currentLine > 1 && $i > 0) { - if (isset($tokens[$i]['scope_condition']) === true) { - $scopeCondition = $tokens[$i]['scope_condition']; - if ($tokens[$scopeCondition]['code'] === T_FUNCTION) { - // Found a previous function. - return; - } - } else if ($tokens[$i]['code'] === T_FUNCTION) { - // Found another interface function. - return; - } - - $currentLine = $tokens[$i]['line']; - if ($currentLine === $prevLine) { - break; - } - - if ($tokens[($i - 1)]['line'] < $currentLine && $tokens[($i + 1)]['line'] > $currentLine) { - // This token is on a line by itself. If it is whitespace, the line is empty. - if ($tokens[$i]['code'] === T_WHITESPACE) { - $foundLines++; - } - } - - $i--; - }//end while - }//end if - - if ($foundLines !== 2) { - $error = 'Expected 2 blank lines before function; %s found'; - $data = array($foundLines); - $phpcsFile->addError($error, $stackPtr, 'Before', $data); - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/LanguageConstructSpacingSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/LanguageConstructSpacingSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/LanguageConstructSpacingSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/LanguageConstructSpacingSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,96 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_WhiteSpace_LanguageConstructSpacingSniff. - * - * Ensures all language constructs (without brackets) contain a - * single space between themselves and their content. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_WhiteSpace_LanguageConstructSpacingSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array( - T_ECHO, - T_PRINT, - T_RETURN, - T_INCLUDE, - T_INCLUDE_ONCE, - T_REQUIRE, - T_REQUIRE_ONCE, - T_NEW, - ); - - }//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(); - - if ($tokens[($stackPtr + 1)]['code'] === T_SEMICOLON) { - // No content for this language construct. - return; - } - - if ($tokens[($stackPtr + 1)]['code'] === T_WHITESPACE) { - $content = $tokens[($stackPtr + 1)]['content']; - $contentLength = strlen($content); - if ($contentLength !== 1) { - $error = 'Language constructs must be followed by a single space; expected 1 space but found %s'; - $data = array($contentLength); - $phpcsFile->addError($error, $stackPtr, 'IncorrectSingle', $data); - } - } else { - $error = 'Language constructs must be followed by a single space; expected "%s" but found "%s"'; - $data = array( - $tokens[$stackPtr]['content'].' '.$tokens[($stackPtr + 1)]['content'], - $tokens[$stackPtr]['content'].$tokens[($stackPtr + 1)]['content'], - ); - $phpcsFile->addError($error, $stackPtr, 'Incorrect', $data); - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/LogicalOperatorSpacingSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/LogicalOperatorSpacingSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/LogicalOperatorSpacingSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/LogicalOperatorSpacingSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,106 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Sniffs_Squiz_WhiteSpace_OperatorSpacingSniff. - * - * Verifies that operators have valid spacing surrounding them. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_WhiteSpace_LogicalOperatorSpacingSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - ); - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return PHP_CodeSniffer_Tokens::$booleanOperators; - - }//end register() - - - /** - * Processes this sniff, when one of its tokens is encountered. - * - * @param PHP_CodeSniffer_File $phpcsFile The current file being checked. - * @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(); - - // Check there is one space before the operator. - if ($tokens[($stackPtr - 1)]['code'] !== T_WHITESPACE) { - $error = 'Expected 1 space before logical operator; 0 found'; - $phpcsFile->addError($error, $stackPtr, 'NoSpaceBefore'); - } else { - $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); - if ($tokens[$stackPtr]['line'] === $tokens[$prev]['line'] - && strlen($tokens[($stackPtr - 1)]['content']) !== 1 - ) { - $found = strlen($tokens[($stackPtr - 1)]['content']); - $error = 'Expected 1 space before logical operator; %s found'; - $data = array($found); - $phpcsFile->addError($error, $stackPtr, 'TooMuchSpaceBefore', $data); - } - } - - // Check there is one space after the operator. - if ($tokens[($stackPtr + 1)]['code'] !== T_WHITESPACE) { - $error = 'Expected 1 space after logical operator; 0 found'; - $phpcsFile->addError($error, $stackPtr, 'NoSpaceAfter'); - } else { - $next = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr - 1), null, true); - if ($tokens[$stackPtr]['line'] === $tokens[$next]['line'] - && strlen($tokens[($stackPtr + 1)]['content']) !== 1 - ) { - $found = strlen($tokens[($stackPtr + 1)]['content']); - $error = 'Expected 1 space after logical operator; %s found'; - $data = array($found); - $phpcsFile->addError($error, $stackPtr, 'TooMuchSpaceAfter', $data); - } - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/MemberVarSpacingSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/MemberVarSpacingSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/MemberVarSpacingSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/MemberVarSpacingSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,122 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -if (class_exists('PHP_CodeSniffer_Standards_AbstractVariableSniff', true) === false) { - throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_Standards_AbstractVariableSniff not found'); -} - -/** - * Verifies that class members are spaced correctly. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_WhiteSpace_MemberVarSpacingSniff extends PHP_CodeSniffer_Standards_AbstractVariableSniff -{ - - - /** - * Processes the function tokens within the class. - * - * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found. - * @param int $stackPtr The position where the token was found. - * - * @return void - */ - protected function processMemberVar(PHP_CodeSniffer_File $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - - // There needs to be 1 blank line before the var, not counting comments. - $prevLineToken = null; - for ($i = ($stackPtr - 1); $i > 0; $i--) { - if (in_array($tokens[$i]['code'], PHP_CodeSniffer_Tokens::$commentTokens) === true) { - // Skip comments. - continue; - } else if (strpos($tokens[$i]['content'], $phpcsFile->eolChar) === false) { - // Not the end of the line. - continue; - } else { - // If this is a WHITESPACE token, and the token right before - // it is a DOC_COMMENT, then it is just the newline after the - // member var's comment, and can be skipped. - if ($tokens[$i]['code'] === T_WHITESPACE && in_array($tokens[($i - 1)]['code'], PHP_CodeSniffer_Tokens::$commentTokens) === true) { - continue; - } - - $prevLineToken = $i; - break; - } - } - - if (is_null($prevLineToken) === true) { - // Never found the previous line, which means - // there are 0 blank lines before the member var. - $foundLines = 0; - } else { - $prevContent = $phpcsFile->findPrevious(array(T_WHITESPACE, T_DOC_COMMENT), $prevLineToken, null, true); - $foundLines = ($tokens[$prevLineToken]['line'] - $tokens[$prevContent]['line']); - }//end if - - if ($foundLines !== 1) { - $error = 'Expected 1 blank line before member var; %s found'; - $data = array($foundLines); - $phpcsFile->addError($error, $stackPtr, 'After', $data); - } - - }//end processMemberVar() - - - /** - * Processes normal variables. - * - * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found. - * @param int $stackPtr The position where the token was found. - * - * @return void - */ - protected function processVariable(PHP_CodeSniffer_File $phpcsFile, $stackPtr) - { - // We don't care about normal variables. - return; - - }//end processVariable() - - - /** - * Processes variables in double quoted strings. - * - * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found. - * @param int $stackPtr The position where the token was found. - * - * @return void - */ - protected function processVariableInString(PHP_CodeSniffer_File $phpcsFile, $stackPtr) - { - // We don't care about normal variables. - return; - - }//end processVariableInString() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/ObjectOperatorSpacingSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/ObjectOperatorSpacingSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/ObjectOperatorSpacingSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/ObjectOperatorSpacingSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,76 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_WhiteSpace_ObjectOperatorSpacingSniff. - * - * Ensure there is no whitespace before a semicolon. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_WhiteSpace_ObjectOperatorSpacingSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array(T_OBJECT_OPERATOR); - - }//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(); - - $prevType = $tokens[($stackPtr - 1)]['code']; - if (in_array($prevType, PHP_CodeSniffer_Tokens::$emptyTokens) === true) { - $error = 'Space found before object operator'; - $phpcsFile->addError($error, $stackPtr, 'Before'); - } - - $nextType = $tokens[($stackPtr + 1)]['code']; - if (in_array($nextType, PHP_CodeSniffer_Tokens::$emptyTokens) === true) { - $error = 'Space found after object operator'; - $phpcsFile->addError($error, $stackPtr, 'After'); - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,215 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Sniffs_Squiz_WhiteSpace_OperatorSpacingSniff. - * - * Verifies that operators have valid spacing surrounding them. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_WhiteSpace_OperatorSpacingSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - ); - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - $comparison = PHP_CodeSniffer_Tokens::$comparisonTokens; - $operators = PHP_CodeSniffer_Tokens::$operators; - $assignment = PHP_CodeSniffer_Tokens::$assignmentTokens; - - return array_unique(array_merge($comparison, $operators, $assignment)); - - }//end register() - - - /** - * Processes this sniff, when one of its tokens is encountered. - * - * @param PHP_CodeSniffer_File $phpcsFile The current file being checked. - * @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(); - - // Skip default values in function declarations. - if ($tokens[$stackPtr]['code'] === T_EQUAL - || $tokens[$stackPtr]['code'] === T_MINUS - ) { - if (isset($tokens[$stackPtr]['nested_parenthesis']) === true) { - $parenthesis = array_keys($tokens[$stackPtr]['nested_parenthesis']); - $bracket = array_pop($parenthesis); - if (isset($tokens[$bracket]['parenthesis_owner']) === true) { - $function = $tokens[$bracket]['parenthesis_owner']; - if ($tokens[$function]['code'] === T_FUNCTION) { - return; - } - } - } - } - - if ($tokens[$stackPtr]['code'] === T_EQUAL) { - // Skip for '=&' case. - if (isset($tokens[($stackPtr + 1)]) === true && $tokens[($stackPtr + 1)]['code'] === T_BITWISE_AND) { - return; - } - } - - if ($tokens[$stackPtr]['code'] === T_BITWISE_AND) { - // If it's not a reference, then we expect one space either side of the - // bitwise operator. - if ($phpcsFile->isReference($stackPtr) === true) { - return; - } - - // Check there is one space before the & operator. - if ($tokens[($stackPtr - 1)]['code'] !== T_WHITESPACE) { - $error = 'Expected 1 space before "&" operator; 0 found'; - $phpcsFile->addError($error, $stackPtr, 'NoSpaceBeforeAmp'); - } else { - if (strlen($tokens[($stackPtr - 1)]['content']) !== 1) { - $found = strlen($tokens[($stackPtr - 1)]['content']); - $error = 'Expected 1 space before "&" operator; %s found'; - $data = array($found); - $phpcsFile->addError($error, $stackPtr, 'SpacingBeforeAmp', $data); - } - } - - // Check there is one space after the & operator. - if ($tokens[($stackPtr + 1)]['code'] !== T_WHITESPACE) { - $error = 'Expected 1 space after "&" operator; 0 found'; - $phpcsFile->addError($error, $stackPtr, 'NoSpaceAfterAmp'); - } else { - if (strlen($tokens[($stackPtr + 1)]['content']) !== 1) { - $found = strlen($tokens[($stackPtr + 1)]['content']); - $error = 'Expected 1 space after "&" operator; %s found'; - $data = array($found); - $phpcsFile->addError($error, $stackPtr, 'SpacingAfterAmp', $data); - } - } - - return; - }//end if - - if ($tokens[$stackPtr]['code'] === T_MINUS) { - // Check minus spacing, but make sure we aren't just assigning - // a minus value or returning one. - $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); - if ($tokens[$prev]['code'] === T_RETURN) { - // Just returning a negative value; eg. return -1. - return; - } - - if (in_array($tokens[$prev]['code'], PHP_CodeSniffer_Tokens::$operators) === true) { - // Just trying to operate on a negative value; eg. ($var * -1). - return; - } - - if (in_array($tokens[$prev]['code'], PHP_CodeSniffer_Tokens::$comparisonTokens) === true) { - // Just trying to compare a negative value; eg. ($var === -1). - return; - } - - // A list of tokens that indicate that the token is not - // part of an arithmetic operation. - $invalidTokens = array( - T_COMMA, - T_OPEN_PARENTHESIS, - T_OPEN_SQUARE_BRACKET, - T_DOUBLE_ARROW, - T_COLON, - ); - - if (in_array($tokens[$prev]['code'], $invalidTokens) === true) { - // Just trying to use a negative value; eg. myFunction($var, -2). - return; - } - - $number = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); - if (in_array($tokens[$number]['code'], array(T_LNUMBER, T_VARIABLE)) === true) { - $semi = $phpcsFile->findNext(T_WHITESPACE, ($number + 1), null, true); - if ($tokens[$semi]['code'] === T_SEMICOLON) { - if ($prev !== false && (in_array($tokens[$prev]['code'], PHP_CodeSniffer_Tokens::$assignmentTokens) === true)) { - // This is a negative assignment. - return; - } - } - } - }//end if - - $operator = $tokens[$stackPtr]['content']; - - if ($tokens[($stackPtr - 1)]['code'] !== T_WHITESPACE) { - $error = "Expected 1 space before \"$operator\"; 0 found"; - $phpcsFile->addError($error, $stackPtr, 'NoSpaceBefore'); - } else if (strlen($tokens[($stackPtr - 1)]['content']) !== 1) { - // Don't throw an error for assignments, because other standards allow - // multiple spaces there to align multiple assignments. - if (in_array($tokens[$stackPtr]['code'], PHP_CodeSniffer_Tokens::$assignmentTokens) === false) { - $found = strlen($tokens[($stackPtr - 1)]['content']); - $error = 'Expected 1 space before "%s"; %s found'; - $data = array( - $operator, - $found, - ); - $phpcsFile->addError($error, $stackPtr, 'SpacingBefore', $data); - } - } - - if ($tokens[($stackPtr + 1)]['code'] !== T_WHITESPACE) { - $error = "Expected 1 space after \"$operator\"; 0 found"; - $phpcsFile->addError($error, $stackPtr, 'NoSpaceAfter'); - } else if (strlen($tokens[($stackPtr + 1)]['content']) !== 1) { - $found = strlen($tokens[($stackPtr + 1)]['content']); - $error = 'Expected 1 space after "%s"; %s found'; - $data = array( - $operator, - $found, - ); - $phpcsFile->addError($error, $stackPtr, 'SpacingAfter', $data); - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/PropertyLabelSpacingSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/PropertyLabelSpacingSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/PropertyLabelSpacingSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/PropertyLabelSpacingSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,85 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_WhiteSpace_PropertyLabelSpacingSniff. - * - * Ensures that the colon in a property or label definition has a single - * space after it and no space before it. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_WhiteSpace_PropertyLabelSpacingSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = array('JS'); - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array( - T_PROPERTY, - T_LABEL, - ); - - }//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(); - - $colon = $phpcsFile->findNext(T_COLON, ($stackPtr + 1)); - - if ($colon !== ($stackPtr + 1)) { - $error = 'There must be no space before the colon in a property/label declaration'; - $phpcsFile->addError($error, $stackPtr, 'Before'); - } - - if ($tokens[($colon + 1)]['code'] !== T_WHITESPACE || $tokens[($colon + 1)]['content'] !== ' ') { - $error = 'There must be a single space after the colon in a property/label declaration'; - $phpcsFile->addError($error, $stackPtr, 'After'); - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,110 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_Whitespace_ScopeClosingBraceSniff. - * - * Checks that the closing braces of scopes are aligned correctly. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_WhiteSpace_ScopeClosingBraceSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return PHP_CodeSniffer_Tokens::$scopeOpeners; - - }//end register() - - - /** - * Processes this test, when one of its tokens is encountered. - * - * @param PHP_CodeSniffer_File $phpcsFile All the tokens found in the document. - * @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(); - - // If this is an inline condition (ie. there is no scope opener), then - // return, as this is not a new scope. - if (isset($tokens[$stackPtr]['scope_closer']) === false) { - return; - } - - // We need to actually find the first piece of content on this line, - // as if this is a method with tokens before it (public, static etc) - // or an if with an else before it, then we need to start the scope - // checking from there, rather than the current token. - $lineStart = ($stackPtr - 1); - for ($lineStart; $lineStart > 0; $lineStart--) { - if (strpos($tokens[$lineStart]['content'], $phpcsFile->eolChar) !== false) { - break; - } - } - - // We found a new line, now go forward and find the - // first non-whitespace token. - $lineStart = $phpcsFile->findNext(array(T_WHITESPACE), ($lineStart + 1), null, true); - - $startColumn = $tokens[$lineStart]['column']; - $scopeStart = $tokens[$stackPtr]['scope_opener']; - $scopeEnd = $tokens[$stackPtr]['scope_closer']; - - // Check that the closing brace is on it's own line. - $lastContent = $phpcsFile->findPrevious(array(T_WHITESPACE), ($scopeEnd - 1), $scopeStart, true); - if ($tokens[$lastContent]['line'] === $tokens[$scopeEnd]['line']) { - $error = 'Closing brace must be on a line by itself'; - $phpcsFile->addError($error, $scopeEnd, 'ContentBefore'); - return; - } - - // Check now that the closing brace is lined up correctly. - $braceIndent = $tokens[$scopeEnd]['column']; - if (in_array($tokens[$stackPtr]['code'], array(T_CASE, T_DEFAULT)) === false) { - if ($braceIndent !== $startColumn) { - $error = 'Closing brace indented incorrectly; expected %s spaces, found %s'; - $data = array( - ($startColumn - 1), - ($braceIndent - 1), - ); - $phpcsFile->addError($error, $scopeEnd, 'Indent', $data); - } - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/ScopeKeywordSpacingSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/ScopeKeywordSpacingSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/ScopeKeywordSpacingSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/ScopeKeywordSpacingSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,87 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_WhiteSpace_ScopeKeywordSpacingSniff. - * - * Ensure there is a single space after scope keywords. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_WhiteSpace_ScopeKeywordSpacingSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - $register = PHP_CodeSniffer_Tokens::$scopeModifiers; - $register[] = T_STATIC; - return $register; - - }//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(); - - $prevToken = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); - $nextToken = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); - - if ($tokens[$stackPtr]['code'] === T_STATIC - && ($tokens[$nextToken]['code'] === T_DOUBLE_COLON - || $tokens[$prevToken]['code'] === T_NEW) - ) { - // Late static binding, e.g., static:: OR new static() usage. - return; - } - - $nextToken = $tokens[($stackPtr + 1)]; - if ($nextToken['code'] !== T_WHITESPACE - || strlen($nextToken['content']) !== 1 - || $nextToken['content'] === $phpcsFile->eolChar - ) { - $error = 'Scope keyword "%s" must be followed by a single space'; - $data = array($tokens[$stackPtr]['content']); - $phpcsFile->addError($error, $stackPtr, 'Incorrect', $data); - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/SemicolonSpacingSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/SemicolonSpacingSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/SemicolonSpacingSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/SemicolonSpacingSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,86 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_WhiteSpace_SemicolonSpacingSniff. - * - * Ensure there is no whitespace before a semicolon. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_WhiteSpace_SemicolonSpacingSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - ); - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array(T_SEMICOLON); - - }//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(); - - $prevType = $tokens[($stackPtr - 1)]['code']; - if (in_array($prevType, PHP_CodeSniffer_Tokens::$emptyTokens) === true) { - $nonSpace = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 2), null, true); - $expected = $tokens[$nonSpace]['content'].';'; - $found = $phpcsFile->getTokensAsString($nonSpace, ($stackPtr - $nonSpace)).';'; - $error = 'Space found before semicolon; expected "%s" but found "%s"'; - $data = array( - $expected, - $found, - ); - $phpcsFile->addError($error, $stackPtr, 'Incorrect', $data); - } - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/SuperfluousWhitespaceSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/SuperfluousWhitespaceSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/SuperfluousWhitespaceSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/SuperfluousWhitespaceSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,204 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Squiz_Sniffs_WhiteSpace_SuperfluousWhitespaceSniff. - * - * Checks that no whitespace proceeds the first content of the file, exists - * after the last content of the file, resides after content on any line, or - * are two empty lines in functions. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Sniffs_WhiteSpace_SuperfluousWhitespaceSniff implements PHP_CodeSniffer_Sniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = array( - 'PHP', - 'JS', - 'CSS', - ); - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array( - T_OPEN_TAG, - T_CLOSE_TAG, - T_WHITESPACE, - T_COMMENT, - ); - - }//end register() - - - /** - * Processes this sniff, 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(); - - if ($tokens[$stackPtr]['code'] === T_OPEN_TAG) { - - /* - Check for start of file whitespace. - */ - - if ($phpcsFile->tokenizerType !== 'PHP') { - // The first token is always the open tag inserted when tokenizsed - // and the second token is always the first piece of content in - // the file. If the second token is whitespace, there was - // whitespace at the start of the file. - if ($tokens[($stackPtr + 1)]['code'] !== T_WHITESPACE) { - return; - } - } else { - // If its the first token, then there is no space. - if ($stackPtr === 0) { - return; - } - - for ($i = ($stackPtr - 1); $i >= 0; $i--) { - // If we find something that isn't inline html then there is something previous in the file. - if ($tokens[$i]['type'] !== 'T_INLINE_HTML') { - return; - } - - // If we have ended up with inline html make sure it isn't just whitespace. - $tokenContent = trim($tokens[$i]['content']); - if ($tokenContent !== '') { - return; - } - } - }//end if - - $phpcsFile->addError('Additional whitespace found at start of file', $stackPtr, 'StartFile'); - - } else if ($tokens[$stackPtr]['code'] === T_CLOSE_TAG) { - - /* - Check for end of file whitespace. - */ - - if ($phpcsFile->tokenizerType === 'JS') { - // The last token is always the close tag inserted when tokenizsed - // and the second last token is always the last piece of content in - // the file. If the second last token is whitespace, there was - // whitespace at the end of the file. - if ($tokens[($stackPtr - 1)]['code'] !== T_WHITESPACE) { - return; - } - } else if ($phpcsFile->tokenizerType === 'CSS') { - // The last two tokens are always the close tag and whitespace - // inserted when tokenizsed and the third last token is always the - // last piece of content in the file. If the third last token is - // whitespace, there was whitespace at the end of the file. - if ($tokens[($stackPtr - 3)]['code'] !== T_WHITESPACE) { - return; - } - - // Adjust the pointer to give the correct line number for the error. - $stackPtr -= 2; - } else { - if (isset($tokens[($stackPtr + 1)]) === false) { - // The close PHP token is the last in the file. - return; - } - - for ($i = ($stackPtr + 1); $i < $phpcsFile->numTokens; $i++) { - // If we find something that isn't inline html then there - // is more to the file. - if ($tokens[$i]['type'] !== 'T_INLINE_HTML') { - return; - } - - // If we have ended up with inline html make sure it - // isn't just whitespace. - $tokenContent = trim($tokens[$i]['content']); - if (empty($tokenContent) === false) { - return; - } - } - } - - $phpcsFile->addError('Additional whitespace found at end of file', $stackPtr, 'EndFile'); - - } else { - - /* - Check for end of line whitespace. - */ - - if (strpos($tokens[$stackPtr]['content'], $phpcsFile->eolChar) === false) { - return; - } - - $tokenContent = rtrim($tokens[$stackPtr]['content'], $phpcsFile->eolChar); - if (empty($tokenContent) === false) { - if (preg_match('|^.*\s+$|', $tokenContent) !== 0) { - $phpcsFile->addError('Whitespace found at end of line', $stackPtr, 'EndLine'); - } - } - - /* - Check for multiple blanks lines in a function. - */ - - if ($phpcsFile->hasCondition($stackPtr, T_FUNCTION) === true) { - if ($tokens[($stackPtr - 1)]['line'] < $tokens[$stackPtr]['line'] && $tokens[($stackPtr - 2)]['line'] === $tokens[($stackPtr - 1)]['line']) { - // This is an empty line and the line before this one is not - // empty, so this could be the start of a multiple empty - // line block. - $next = $phpcsFile->findNext(T_WHITESPACE, $stackPtr, null, true); - $lines = $tokens[$next]['line'] - $tokens[$stackPtr]['line']; - if ($lines > 1) { - $error = 'Functions must not contain multiple empty lines in a row; found %s empty lines'; - $data = array($lines); - $phpcsFile->addError($error, $stackPtr, 'EmptyLines', $data); - } - } - } - - }//end if - - }//end process() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Arrays/ArrayBracketSpacingUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Arrays/ArrayBracketSpacingUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Arrays/ArrayBracketSpacingUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Arrays/ArrayBracketSpacingUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ - \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Arrays/ArrayBracketSpacingUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Arrays/ArrayBracketSpacingUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Arrays/ArrayBracketSpacingUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Arrays/ArrayBracketSpacingUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,72 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the ArrayBracketSpacing sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_Arrays_ArrayBracketSpacingUnitTest 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 array( - 3 => 1, - 4 => 2, - 5 => 3, - 7 => 3, - ); - - }//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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,181 +0,0 @@ - 1, - ); -} - - -class TestClass -{ - public $good = array( - 'width' => '', - 'height' => '', - ); - - private $_bad = Array( - 'width' => '', - 'height' => '' - ); - - - public function test() - { - $truck = array( - 'width' => '', - 'height' => '', - ); - - $plane = Array( - 'width' => '', - 'height' => '', - ); - - $car = array( - 'width' => '', - 'height' => '', - ); - - $bus = array( - 'width' => '', - 'height' => '' - ); - - $train = array ( - TRUE, - FALSE, - 'aaa' - ); - - $inline = array('aaa', 'bbb', 'ccc'); - $inline = array('aaa'); - $inline = Array('aaa'); - - $bigone = array( - 'name' => 'bigone', - 'children' => Array( - '1a' => 'child', - '11b' => 'child', - '111c' => 'child', - 'children' => Array( - 'child' => 'aaa', - ), - ), - 'short_name' => 'big' - ); - } - -}//end class - -$value = array ( ); -$value = array( ); -$value = array('1'=>$one, '2' => $two, '3'=> $three, '4' =>$four); -$value = array('1'=>$one); - -if (in_array('1', array('1','2','3')) === TRUE) { - $value = in_array('1', array('1' , '2', '3','4')); -} - -$value = array( - '1'=> TRUE, - FALSE, - '3' => 'aaa',); - -$value = array( - '1'=> TRUE, - FALSE, - ); - -$value = array( - TRUE, - '1' => FALSE, - ); - -$value = array(1, - 2 , - 3 , - ); - -$value = array(1 => $one, - 2 => $two , - 3 => $three , - ); - -$value = array( - 'tag' => $tag, - 'space' => $this->_getIndentation($tag, $tagElement), - ); - -$expected = array( - array( - '1' => 1, - '1' => 2, - ), - ); - -$expected = array( - array( - '1' => 1, - '1' => 2 - ) - ); - -// Space in second arg. -$args = array( - '"'.$this->id.'"', - (int) $hasSessions, - ); - -// No errors. -$paths = array( - Init::ROOT_DIR.'/Systems' => 'Systems', - Init::ROOT_DIR.'/Installer' => 'Systems', - ); - -$x = array( - ); - -$x = array('test' - ); -$x = array('test', - ); -$x = array('name' => 'test', - ); - -$x = array( - $x, - ); - -$func = array( - $x, - 'get'.$x.'Replacement' - ); - -$array = array( - 'input_one' => 'one', - 'inputTwo' => 'two', - 'input_3' => 3, - ); - -$array = array( - 'input_one', - 'inputTwo', - 'input_3', - ); - -// Malformed -$foo = array(1 -, 2); - -$listItems[$aliasPath] = array('itemContent' => implode('
', $aliases)); - -$listItems[$aliasPath] = array( - 'itemContent' => implode('
', $aliases) - ); -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,118 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the ArrayDeclaration sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_Arrays_ArrayDeclarationUnitTest 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 array( - 7 => 2, - 9 => 2, - 22 => 1, - 23 => 1, - 24 => 1, - 25 => 1, - 31 => 1, - 35 => 1, - 36 => 1, - 41 => 1, - 46 => 1, - 47 => 1, - 50 => 1, - 51 => 1, - 53 => 1, - 56 => 1, - 58 => 1, - 61 => 1, - 62 => 1, - 63 => 1, - 64 => 1, - 65 => 1, - 66 => 3, - 70 => 1, - 76 => 2, - 77 => 1, - 78 => 7, - 79 => 2, - 81 => 2, - 82 => 4, - 87 => 1, - 88 => 1, - 92 => 1, - 97 => 1, - 100 => 1, - 101 => 1, - 102 => 1, - 105 => 1, - 106 => 1, - 107 => 1, - 125 => 1, - 126 => 1, - 141 => 1, - 144 => 1, - 146 => 1, - 148 => 1, - 151 => 1, - 157 => 1, - 174 => 3, - 179 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/ClassDefinitionClosingBraceSpaceUnitTest.css php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/ClassDefinitionClosingBraceSpaceUnitTest.css --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/ClassDefinitionClosingBraceSpaceUnitTest.css 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/ClassDefinitionClosingBraceSpaceUnitTest.css 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -.my-style { -} - - -.my-style { -} - -/* Comment */ - -.my-style { -} - - -/* Comment */ - -.my-style { - float: left; - -} - -.AssetLineageWidgetType-item { - color: #CCC; -} - -/*.AssetLineageWidgetType-item2 .selected, -.AssetLineageWidgetType-item .selected { -}*/ - -.AssetLineageWidgetType-item.selected { -} - -@media screen and (max-device-width: 769px) { - - header #logo img { - max-width: 100%; - } - -} - -@media screen and (max-device-width: 769px) { - - header #logo img { - max-width: 100%; - } -} diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/ClassDefinitionClosingBraceSpaceUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/ClassDefinitionClosingBraceSpaceUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/ClassDefinitionClosingBraceSpaceUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/ClassDefinitionClosingBraceSpaceUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,70 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the ClassDefinitionClosingBraceSpace sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_CSS_ClassDefinitionClosingBraceSpaceUnitTest 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 array( - 2 => 1, - 11 => 1, - 19 => 1, - 44 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/ClassDefinitionNameSpacingUnitTest.css php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/ClassDefinitionNameSpacingUnitTest.css --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/ClassDefinitionNameSpacingUnitTest.css 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/ClassDefinitionNameSpacingUnitTest.css 1970-01-01 00:00:00.000000000 +0000 @@ -1,57 +0,0 @@ -.AssetListingEditWidgetType-BottomPanel select, -#EditEditingModeWidgetType-assetEditor-filters-assetTypes-addNew { - float: left; -} - -.AssetListingEditWidgetType-BottomPanel select, - -#EditEditingModeWidgetType-assetEditor-filters-assetTypes-addNew { - float: left; -} - -.AssetListingEditWidgetType-BottomPanel select, -/*.AssetListingEditWidgetType-BottomPanel ul,*/ -#EditEditingModeWidgetType-assetEditor-filters-assetTypes-addNew { - float: left; -} - -.AssetListingEditWidgetType-BottomPanel select, - -.AssetListingEditWidgetType-BottomPanel ul, -#EditEditingModeWidgetType-assetEditor-filters-assetTypes-addNew { - float: left; -} - -#SuperUsersSystemConfigScreen-table { - display: block; - left: 50%; - margin-left: -500px; - margin-top: 180px; - position: relative; - width: 1000px; -} - -/** - * More styles below here. - */ - -td.TableWidgetType-header.TableWidgetType-header-lastLogin, -td.TableWidgetType-header.TableWidgetType-header-remove, -td.TableWidgetType-header.TableWidgetType-header-email, -td.TableWidgetType-header.TableWidgetType-header-userName { - background: url(images/ScreenImages/table_header_bg.png) repeat-x; - border-top: 1px solid #D4D4D4; - color: #787878; - height: 33px; - padding-left: 12px; - width: 150px; -} - -@media screen and (max-device-width: 769px) { - - header #logo img { - max-width: 100%; - padding: 20px; - margin: 40px; - } -} diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/ClassDefinitionNameSpacingUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/ClassDefinitionNameSpacingUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/ClassDefinitionNameSpacingUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/ClassDefinitionNameSpacingUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,68 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the ClassDefinitionNameSpacing sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_CSS_ClassDefinitionNameSpacingUnitTest 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 array( - 7 => 1, - 19 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/ClassDefinitionOpeningBraceSpaceUnitTest.css php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/ClassDefinitionOpeningBraceSpaceUnitTest.css --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/ClassDefinitionOpeningBraceSpaceUnitTest.css 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/ClassDefinitionOpeningBraceSpaceUnitTest.css 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -.HelpWidgetType-new-bug-title { - float: left; -} -.HelpWidgetType-new-bug-title { - float: left; -} -.HelpWidgetType-new-bug-title { - float: left; -} -.HelpWidgetType-new-bug-title{ - float: left; -} -.HelpWidgetType-new-bug-title { - - float: left; -} - -@media screen and (max-device-width: 769px) { - - header #logo img { - max-width: 100%; - } - -} - -@media screen and (max-device-width: 769px) { - header #logo img { - max-width: 100%; - } - -} diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/ClassDefinitionOpeningBraceSpaceUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/ClassDefinitionOpeningBraceSpaceUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/ClassDefinitionOpeningBraceSpaceUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/ClassDefinitionOpeningBraceSpaceUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,71 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the ClassDefinitionOpeningBraceSpace sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_CSS_ClassDefinitionOpeningBraceSpaceUnitTest 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 array( - 4 => 1, - 7 => 1, - 10 => 1, - 13 => 1, - 26 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/ColonSpacingUnitTest.css php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/ColonSpacingUnitTest.css --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/ColonSpacingUnitTest.css 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/ColonSpacingUnitTest.css 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -body { -font-family: Arial, Helvetica, sans-serif; -margin : 40px 0 0 0; -padding : 0; -background: #8FB7DB url(diag_lines_bg.gif) top left; -margin-top: -10px; -margin-bottom: -0px; -} - -.TableWidgetType .recover:hover { - background-color: #FFF; -} - -#clearCache-settings:rootNodes-list_0 { - border-top: none; -} - -.LookupEditScreenWidgetType-urls a, .LookupEditScreenWidgetType-urls a:visited { - text-decoration: none; - color: #444; -} - -/* checking embedded PHP */ -li { - background:url(/images//bullet.gif) left px no-repeat; - margin:0px; - padding-left:10px; - margin-bottom:px; - line-height:13px; -} diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/ColonSpacingUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/ColonSpacingUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/ColonSpacingUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/ColonSpacingUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,75 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the ColonSpacing sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_CSS_ColonSpacingUnitTest 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 array( - 3 => 1, - 4 => 2, - 5 => 1, - 6 => 1, - 8 => 1, - 27 => 1, - 28 => 1, - 29 => 1, - 30 => 1, - 31 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/ColourDefinitionUnitTest.css php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/ColourDefinitionUnitTest.css --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/ColourDefinitionUnitTest.css 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/ColourDefinitionUnitTest.css 1970-01-01 00:00:00.000000000 +0000 @@ -1,7 +0,0 @@ -#title-bar-bottom-right { - background-color: #333333; - padding: 10px; - border-bottom: 1px dotted #F0F0F0; - border-top: 1px dotted #FF00FF; - background: #8fb7db url(diag_lines_bg.gif) top left; -} diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/ColourDefinitionUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/ColourDefinitionUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/ColourDefinitionUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/ColourDefinitionUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,68 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the ColourDefinition sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_CSS_ColourDefinitionUnitTest 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 array( - 2 => 1, - 5 => 1, - 6 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/DisallowMultipleStyleDefinitionsUnitTest.css php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/DisallowMultipleStyleDefinitionsUnitTest.css --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/DisallowMultipleStyleDefinitionsUnitTest.css 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/DisallowMultipleStyleDefinitionsUnitTest.css 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -.SettingsTabPaneWidgetType-tab-mid { - background: transparent url(tab_inact_mid.png) repeat-x; - height: 100%;float: left; - line-height: -25px; - cursor: pointer; margin: 10px; float: right; -} - -/* testing embedded PHP */ -li { - background:url(/images//bullet.gif) left px no-repeat; margin:0px; padding-left:10px; margin-bottom:px; line-height:13px; -} diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/DisallowMultipleStyleDefinitionsUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/DisallowMultipleStyleDefinitionsUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/DisallowMultipleStyleDefinitionsUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/DisallowMultipleStyleDefinitionsUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,68 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the DisallowMultipleStyleDefinitions sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_CSS_DisallowMultipleStyleDefinitionsUnitTest 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 array( - 3 => 1, - 5 => 2, - 10 => 4, - ); - - }//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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/DuplicateClassDefinitionUnitTest.css php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/DuplicateClassDefinitionUnitTest.css --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/DuplicateClassDefinitionUnitTest.css 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/DuplicateClassDefinitionUnitTest.css 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -.AssetLineageWidgetType-item { - color: #FFF; -} - -.AssetLineageWidgetType-title { - color: #CCC; -} - -.AssetLineageWidgetType-item { - color: #CCC; -} - -.AssetLineageWidgetType-item .selected { -} - -.AssetLineageWidgetType-item.selected { -} - -#Blah .AssetLineageWidgetType-item { -} - -#X.selected, -.AssetLineageWidgetType-item { -} - -.MyClass, .YourClass { -} - -.YourClass, .MyClass { -} - -.YourClass, .MyClass, .OurClass { -} diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/DuplicateClassDefinitionUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/DuplicateClassDefinitionUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/DuplicateClassDefinitionUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/DuplicateClassDefinitionUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,68 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the DuplicateClassDefinition sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_CSS_DuplicateClassDefinitionUnitTest 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 array( - 9 => 1, - 29 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/DuplicateStyleDefinitionUnitTest.css php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/DuplicateStyleDefinitionUnitTest.css --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/DuplicateStyleDefinitionUnitTest.css 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/DuplicateStyleDefinitionUnitTest.css 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -.ViperSubToolbar-wrapper { - height: 34px; - left: 0; - position: fixed; - top: 60px; - z-index: 997; - left: 50%; -} - -.expandable { - -moz-transition-property: margin-left, margin-right; - -moz-transition-duration: 0.2s; - -moz-transition-timing-function: ease; - -webkit-transition-property: margin-left, margin-right; - -webkit-transition-duration: 0.2s; - -webkit-transition-timing-function: ease; - z-index: 2; -} diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/DuplicateStyleDefinitionUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/DuplicateStyleDefinitionUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/DuplicateStyleDefinitionUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/DuplicateStyleDefinitionUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,67 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the DuplicateStyleDefinition sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_CSS_DuplicateStyleDefinitionUnitTest 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 array( - 7 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/EmptyClassDefinitionUnitTest.css php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/EmptyClassDefinitionUnitTest.css --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/EmptyClassDefinitionUnitTest.css 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/EmptyClassDefinitionUnitTest.css 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -.HelpWidgetType-new-bug-title {} -.HelpWidgetType-new-bug-title { -} -.HelpWidgetType-new-bug-title { - -} -.HelpWidgetType-new-bug-title { - -} -.HelpWidgetType-new-bug-title { - /* Nothing to see here */ -} -.HelpWidgetType-new-bug-title { - float: left; -} diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/EmptyClassDefinitionUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/EmptyClassDefinitionUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/EmptyClassDefinitionUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/EmptyClassDefinitionUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,70 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the EmptyClassDefinition sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_CSS_EmptyClassDefinitionUnitTest 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 array( - 1 => 1, - 2 => 1, - 4 => 1, - 7 => 1, - 10 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/EmptyStyleDefinitionUnitTest.css php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/EmptyStyleDefinitionUnitTest.css --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/EmptyStyleDefinitionUnitTest.css 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/EmptyStyleDefinitionUnitTest.css 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -#MetadataAdminScreen-addField-fieldType { - margin-left: 10px; - margin-right: - float: ; -} diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/EmptyStyleDefinitionUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/EmptyStyleDefinitionUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/EmptyStyleDefinitionUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/EmptyStyleDefinitionUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,67 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the EmptyStyleDefinition sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_CSS_EmptyStyleDefinitionUnitTest 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 array( - 3 => 1, - 4 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/IndentationUnitTest.css php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/IndentationUnitTest.css --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/IndentationUnitTest.css 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/IndentationUnitTest.css 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -body { - - font-family: Arial, Helvetica, sans-serif; - margin: 40px 0 0 0; -padding: 0; - background: #8FB7DB url(diag_lines_bg.gif) top left; - -} - -td { - margin: 40px; - - padding: 20px; -} - -/* -#AdminScreenModeWidgetType-tab_pane-containers .TabPaneWidgetType-tab-selected-left { - background: transparent url(images/ScreenImages/tab_on_left.png) no-repeat; -} -#AdminScreenModeWidgetType-tab_pane-containers .TabPaneWidgetType-tab-selected-right { - background: transparent url(images/ScreenImages/tab_on_right.png) no-repeat; -} -*/ - -@media screen and (max-device-width: 769px) { - - header #logo img { - max-width: 100%; - padding: 20px; - margin: 40px; - } -} - -@media screen and (max-device-width: 769px) { - - header #logo img { - max-width: 100%; - } - - header #logo img { - min-width: 100%; - } - -} diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/IndentationUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/IndentationUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/IndentationUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/IndentationUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,73 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the Indentation sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_CSS_IndentationUnitTest 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 array( - 2 => 1, - 3 => 1, - 5 => 1, - 6 => 1, - 7 => 1, - 12 => 1, - 28 => 1, - 30 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/LowercaseStyleDefinitionUnitTest.css php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/LowercaseStyleDefinitionUnitTest.css --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/LowercaseStyleDefinitionUnitTest.css 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/LowercaseStyleDefinitionUnitTest.css 1970-01-01 00:00:00.000000000 +0000 @@ -1,6 +0,0 @@ -.SettingsTabPaneWidgetType-tab-mid { - font-family: Arial; - Font-Family: arial; - background-color: #DA9393; - BACKGROUND-IMAGE: URL(Warning_Close.png); -} diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/LowercaseStyleDefinitionUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/LowercaseStyleDefinitionUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/LowercaseStyleDefinitionUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/LowercaseStyleDefinitionUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,68 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the LowercaseStyleDefinition sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_CSS_LowercaseStyleDefinitionUnitTest 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 array( - 2 => 1, - 3 => 1, - 5 => 2, - ); - - }//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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/MissingColonUnitTest.css php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/MissingColonUnitTest.css --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/MissingColonUnitTest.css 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/MissingColonUnitTest.css 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -.my-style { - margin-right 15px; - float: left; - margin-left 15px; - margin-top: 15px; - margin-bottom 15px; -} - -@media screen and (max-device-width: 769px) { - header #logo img { - max-width: 100%; - margin-bottom 15px; - } -} diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/MissingColonUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/MissingColonUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/MissingColonUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/MissingColonUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,69 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the MissingColon sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_CSS_MissingColonUnitTest 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 array( - 2 => 1, - 4 => 1, - 6 => 1, - 12 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/OpacityUnitTest.css php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/OpacityUnitTest.css --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/OpacityUnitTest.css 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/OpacityUnitTest.css 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -.my-style { - opacity: 0; - opacity: 0.0; - opacity: 1; - opacity: 1.0; - opacity: 1.5; - opacity: .5; - opacity: 0.5; - opacity: 2; - opacity: -1; - opacity: 0.55; -} diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/OpacityUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/OpacityUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/OpacityUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/OpacityUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,72 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the Opacity sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_CSS_OpacityUnitTest 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 array( - 3 => 1, - 5 => 1, - 6 => 1, - 7 => 1, - 9 => 1, - 10 => 1, - 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/SemicolonSpacingUnitTest.css php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/SemicolonSpacingUnitTest.css --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/SemicolonSpacingUnitTest.css 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/SemicolonSpacingUnitTest.css 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -.HelpWidgetType-new-bug-title { - width: 308px - float: left; -} - -#MetadataAdminScreen-addField-add { - float: left ; -} - -.TableWidgetType .recover:hover { - background-color: #FFF; -} - -#clearCache-settings:rootNodes-list_0 { - border-top: none; -} - -.HelpWidgetType-list { - list-style-image: url(); -} diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/SemicolonSpacingUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/SemicolonSpacingUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/SemicolonSpacingUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CSS/SemicolonSpacingUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,67 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the SemicolonSpacing sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_CSS_SemicolonSpacingUnitTest 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 array( - 2 => 1, - 7 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Classes/ClassDeclarationUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Classes/ClassDeclarationUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Classes/ClassDeclarationUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Classes/ClassDeclarationUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,100 +0,0 @@ - - - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the ClassDeclaration sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_Classes_ClassDeclarationUnitTest 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 array( - 10 => 1, - 15 => 2, - 18 => 1, - 22 => 3, - 23 => 3, - 24 => 3, - 27 => 2, - 28 => 1, - 30 => 2, - 34 => 1, - 35 => 1, - 39 => 1, - 42 => 2, - 45 => 1, - 48 => 1, - 50 => 2, - 55 => 1, - 59 => 4, - 63 => 1, - 65 => 1, - 69 => 2, - 74 => 2, - 77 => 1, - 80 => 1, - 85 => 2, - 89 => 1, - 92 => 1, - 97 => 1, - 100 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Classes/ClassFileNameUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Classes/ClassFileNameUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Classes/ClassFileNameUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Classes/ClassFileNameUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ - \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Classes/ClassFileNameUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Classes/ClassFileNameUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Classes/ClassFileNameUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Classes/ClassFileNameUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,75 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the ClassFileName sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_Classes_ClassFileNameUnitTest 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 array( - 9 => 1, - 10 => 1, - 11 => 1, - 15 => 1, - 16 => 1, - 17 => 1, - 18 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Classes/DuplicatePropertyUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Classes/DuplicatePropertyUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Classes/DuplicatePropertyUnitTest.js 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Classes/DuplicatePropertyUnitTest.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -var x = { - abc: 1, - zyz: 2, - abc: 5, - mno: { - abc: 4 - }, - abc: 5 - - this.request({ - action: 'getSubmissions' - }); - - this.request({ - action: 'deleteSubmission' - }); -} - - -LinkingEditScreenWidgetType.prototype = { - - _addDeleteButtonEvent: function(parentid) - { - var params = { - screen: 'LinkingEditScreenWidget', - assetid: self.assetid, - parentid: parentid, - assetid: parentid, - op: 'deleteLink' - }; - - }, - - saveDesignEdit: function() - { - var params = { - screen: [this.id, 'Widget'].join(''), - assetid: this.assetid, - changes: dfx.jsonEncode(this.currnetLinksWdgt.getChanges()), - op: 'saveLinkEdit' - }; - - } - -}; \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Classes/DuplicatePropertyUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Classes/DuplicatePropertyUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Classes/DuplicatePropertyUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Classes/DuplicatePropertyUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,69 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the DuplicateProperty sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_Classes_DuplicatePropertyUnitTest 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 array( - 4 => 1, - 8 => 1, - 28 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Classes/LowercaseClassKeywordsUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Classes/LowercaseClassKeywordsUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Classes/LowercaseClassKeywordsUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Classes/LowercaseClassKeywordsUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ - \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Classes/LowercaseClassKeywordsUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Classes/LowercaseClassKeywordsUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Classes/LowercaseClassKeywordsUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Classes/LowercaseClassKeywordsUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,73 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the LowercaseClassKeywords sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_Classes_LowercaseClassKeywordsUnitTest 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 array( - 2 => 3, - 3 => 3, - 4 => 1, - 8 => 1, - 9 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Classes/SelfMemberReferenceUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Classes/SelfMemberReferenceUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Classes/SelfMemberReferenceUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Classes/SelfMemberReferenceUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,67 +0,0 @@ -testResults; - - - // Correct call to self. - $testResults[] = self::selfMemberReferenceUnitTestFunction(); - $testResults[] = parent::selfMemberReferenceUnitTestFunction(); - - // Incorrect case. - $testResults[] = Self::selfMemberReferenceUnitTestFunction(); - $testResults[] = SELF::selfMemberReferenceUnitTestFunction(); - $testResults[] = SelfMemberReferenceUnitTestExample::selfMemberReferenceUnitTestFunction(); - - - // Incorrect spacing. - $testResults[] = self ::selfMemberReferenceUnitTestFunction(); - $testResults[] = self:: selfMemberReferenceUnitTestFunction(); - $testResults[] = self :: selfMemberReferenceUnitTestFunction(); - - } - - - function selfMemberReferenceUnitTestFunction() - { - $this->testCount = $this->testCount + 1; - return $this->testCount; - - } - - -} - - -class MyClass { - - public static function test($value) { - echo "$value\n"; - } - - public static function walk() { - $callback = function($value, $key) { - // This is valid because you cant use self:: in a closure - MyClass::test($value); - }; - - $array = array(1,2,3); - array_walk($array, $callback); - } -} - -MyClass::walk(); - -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Classes/SelfMemberReferenceUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Classes/SelfMemberReferenceUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Classes/SelfMemberReferenceUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Classes/SelfMemberReferenceUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,74 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the SelfMemberReference sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_Classes_SelfMemberReferenceUnitTest 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 array( - 24 => 1, - 25 => 1, - 26 => 1, - 30 => 1, - 31 => 1, - 32 => 2, - ); - - }//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 array(); - - }//end getWarningList() - - -}//end class - -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Classes/ValidClassNameUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Classes/ValidClassNameUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Classes/ValidClassNameUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Classes/ValidClassNameUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ - \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Classes/ValidClassNameUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Classes/ValidClassNameUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Classes/ValidClassNameUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Classes/ValidClassNameUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,75 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the ValidClassName sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_Classes_ValidClassNameUnitTest 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 array( - 9 => 1, - 10 => 1, - 14 => 1, - 15 => 1, - 20 => 1, - 30 => 1, - 32 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CodeAnalysis/EmptyStatementUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CodeAnalysis/EmptyStatementUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CodeAnalysis/EmptyStatementUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/CodeAnalysis/EmptyStatementUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,57 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the EmptyStatement sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_CodeAnalysis_EmptyStatementUnitTest 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 array( - 3 => 1, - 15 => 1, - 17 => 1, - 19 => 1, - 30 => 1, - 35 => 1, - 41 => 1, - 47 => 1, - 52 => 1, - 55 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/BlockCommentUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/BlockCommentUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/BlockCommentUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/BlockCommentUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,145 +0,0 @@ - \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/BlockCommentUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/BlockCommentUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/BlockCommentUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/BlockCommentUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,94 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the BlockComment sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_Commenting_BlockCommentUnitTest 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 array( - 8 => 1, - 19 => 1, - 20 => 1, - 24 => 1, - 30 => 1, - 31 => 1, - 34 => 1, - 40 => 1, - 45 => 1, - 49 => 1, - 51 => 1, - 53 => 1, - 57 => 1, - 60 => 1, - 61 => 1, - 63 => 1, - 65 => 1, - 68 => 1, - 70 => 1, - 75 => 1, - 84 => 1, - 85 => 2, - 86 => 1, - 87 => 1, - 89 => 1, - 92 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/ClassCommentUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/ClassCommentUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/ClassCommentUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/ClassCommentUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,133 +0,0 @@ - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/ClassCommentUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/ClassCommentUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/ClassCommentUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/ClassCommentUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,87 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for ClassCommentSniff. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_Commenting_ClassCommentUnitTest 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 array( - 4 => 1, - 15 => 1, - 22 => 1, - 25 => 1, - 28 => 1, - 49 => 1, - 55 => 1, - 64 => 2, - 77 => 1, - 88 => 1, - 97 => 1, - 99 => 1, - 108 => 1, - 110 => 1, - 118 => 1, - 128 => 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 array( - 30 => 1, - 31 => 1, - 51 => 1, - 68 => 1, - 69 => 1, - ); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,77 +0,0 @@ - \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,77 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the ClosingDeclarationComment sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_Commenting_ClosingDeclarationCommentUnitTest 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 array( - 13 => 1, - 17 => 1, - 31 => 1, - 41 => 1, - 59 => 1, - 63 => 1, - 67 => 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 array( - 71 => 1, - ); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,52 +0,0 @@ - \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,80 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the DocCommentAlignment sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_Commenting_DocCommentAlignmentUnitTest 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 array( - 11 => 1, - 17 => 1, - 18 => 1, - 19 => 1, - 23 => 1, - 24 => 1, - 25 => 2, - 26 => 1, - 32 => 1, - 33 => 1, - 38 => 1, - 39 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/EmptyCatchCommentUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/EmptyCatchCommentUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/EmptyCatchCommentUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/EmptyCatchCommentUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,55 +0,0 @@ - \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/EmptyCatchCommentUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/EmptyCatchCommentUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/EmptyCatchCommentUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/EmptyCatchCommentUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,74 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the EmptyCatchComment sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_Commenting_EmptyCatchCommentUnitTest 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 array( - 13 => 1, - 33 => 1, - 49 => 1, - 50 => 1, - 51 => 1, - 52 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ - -* @author -* @copyright 1997~1994 The PHP Group -* @license http://www.php.net/license/3_0.txt -* @summary An unknown summary tag -* -*/ -?> - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.js 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ - - - - -/** -* -* 0Multi-line short description without full stop -* -* -* asdasd -* long description for file (if any) -* asdasdadada -* -* PHP versio -* -* LICENSE: This source file is subject to version 3.0 of the PHP license -* that is available through the world-wide-web at the following URI: -* http://www.php.net/license/3_0.txt. If you did not receive a copy of -* the PHP License and are unable to obtain it through the web, please -* send a note to license@php.net so we can mail you a copy immediately. -* @package SquizCMS -* @package ADDITIONAL PACKAGE TAG -* @subpackage not_camelcased -* @author Antônio Carlos Venâncio Júnior -* @author -* @copyright 1997~1994 The PHP Group -* @license http://www.php.net/license/3_0.txt -* @summary An unknown summary tag -* -*/ - - -/** -* This bit here is not qualified as file comment -* -* as it is not the first comment in the file -* -*/ diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,89 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for FileCommentSniff. - * - * Verifies that : - *
    - *
  • A doc comment exists.
  • - *
  • Short description must start with a capital letter and end with a period.
  • - *
  • There must be one blank newline after the short description.
  • - *
  • A PHP version is specified.
  • - *
  • Check the order of the tags.
  • - *
  • Check the indentation of each tag.
  • - *
  • Check required and optional tags and the format of their content.
  • - *
- * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_Commenting_FileCommentUnitTest 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 array( - 1 => 1, - 6 => 3, - 8 => 1, - 10 => 1, - 21 => 1, - 22 => 2, - 23 => 1, - 24 => 2, - 26 => 1, - 27 => 2, - 30 => 2, - ); - - }//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 array( - 28 => 1, - ); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/FunctionCommentThrowTagUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/FunctionCommentThrowTagUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/FunctionCommentThrowTagUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/FunctionCommentThrowTagUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,232 +0,0 @@ -callSomeFunction(); - - }//end okFunction() - - - /** - * Comment inside function. - * - * @throws Exception - */ - function okFunction() - { - /** - * @var FooClass - */ - $foo = FooFactory::factory(); - throw new Exception; - - }//end okFunction - - -}//end class - -class NamespacedException { - /** - * @throws \Exception - */ - public function foo() { - throw new \Exception(); - } - - /** - * @throws \Foo\Bar\FooBarException - */ - public function fooBar2() { - throw new \Foo\Bar\FooBarException(); - } - - /** - * @throws FooBarException - */ - public function fooBar2() { - throw new \Foo\Bar\FooBarException(); - } -} - -class Foo { - /** - * Comment - */ - public function foo() { - }//end foo() - - public function bar() { - throw new Exception(); - } -} -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/FunctionCommentThrowTagUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/FunctionCommentThrowTagUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/FunctionCommentThrowTagUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/FunctionCommentThrowTagUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,81 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for FunctionCommentThrowTagSniff. - * - * Verifies that : - *
    - *
  • A @throws tag exists for a function that throws exceptions.
  • - *
  • The number of @throws tags and the number of throw tokens matches.
  • - *
  • The exception type in comment matches the token.
  • - *
- * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_Commenting_FunctionCommentThrowTagUnitTest 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 array( - 9 => 1, - 21 => 1, - 35 => 1, - 46 => 1, - 59 => 1, - 60 => 1, - 106 => 1, - 123 => 1, - 214 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,546 +0,0 @@ -MyClass) - */ -public function caseSensitive($a1, $a2, $a3, arRay $a4, $a5, $a6, myclas $a7) -{ - -}//end caseSensitive() - - -/** - * More type hint check for custom type and array. - * - * @param array $a1 Comment here. - * @param array $a2 Comment here. - * @param MyClass $a3 Comment here. - * @param MyClass $a4 Comment here. - * - * @return array(int => MyClass) - */ -public function typeHint(MyClass $a1, $a2, myclass $a3, $a4) -{ - return (3 => 'myclass obj'); - -}//end typeHint() - - -/** - * Mixed variable type separated by a '|'. - * - * @param array|string $a1 Comment here. - * @param mixed $a2 Comment here. - * @param string|array $a3 Comment here. - * @param MyClass|int $a4 Comment here. - * - * @return bool - */ -public function mixedType($a1, $a2, $a3, $a4) -{ - return true; - -}//end mixedType() - - -/** - * Array type. - * - * @param array(MyClass) $a1 OK. - * @param array() $a2 Invalid type. - * @param array( $a3 Typo. - * @param array(int) $a4 Use 'array(integer)' instead. - * @param array(int => integer) $a5 Use 'array(integer => integer)' instead. - * @param array(integer => bool) $a6 Use 'array(integer => boolean)' instead. - * @param aRRay $a7 Use 'array' instead. - * @param string $a8 String with unknown type hint. - * - * @return int - */ -public function mixedArrayType($a1, $a2, array $a3, $a4, $a5, $a6, $a7, unknownTypeHint $a8) -{ - return 1; - -}//end mixedArrayType() - - -/** - */ -function empty1() -{ -}//end empty1() - - -/** - * - */ -function empty2() -{ -}//end empty2() - - -/** - * - * - * - */ -function empty3() -{ -}//end empty3 - - -/** - * @return boolean - */ -public function missingShortDescriptionInFunctionComment() -{ - return true; - -}//end missingShortDescriptionInFunctionComment() - - -class Another_Class -{ - - /** - * Destructor should not include a return tag. - * - * @return void - */ - function __destruct() - { - return; - } - - /** - * Constructor should not include a return tag. - * - * @return void - */ - function __construct() - { - return; - } - -}//end class - - -/** - * Comment param alignment test. - * - * @param string $varrr1 Comment1.. - * @param string $vr2 Comment2. - * @param string $var3 Comment3.. - * - * @return void - */ -public static function paramAlign($varrr1, $vr2, $var3) -{ - -}//end paramAlign() - - -/** - * Comment. - * - * @param string $id Comment. - * @param array $design Comment. - * - * @return void - */ -public static function paint($id, array $design) -{ - -}//end paint() - - -/** - * Adds specified class name to class attribute of this widget. - * - * @since 4.0.0 - * @return string - */ -public function myFunction() -{ - if ($condition === FALSE) { - echo 'hi'; - } - -}//end myFunction() - - -/** - * Adds specified class name to class attribute of this widget. - * - * @return string - */ -public function myFunction() -{ - if ($condition === FALSE) { - echo 'hi'; - return; - } - - return 'blah'; - -}//end myFunction() - - -/** - * Adds specified class name to class attribute of this widget. - * - * @return string - */ -public function myFunction() -{ - if ($condition === FALSE) { - echo 'hi'; - } - - return 'blah'; - -}//end myFunction() - -/** - * Test function. - * - * @param string $arg1 An argument - * - * @access public - * @return bool - */ - -echo $blah; - -function myFunction($arg1) {} - -class MyClass() { - /** - * An abstract function. - * - * @return array(string) - */ - abstract final protected function myFunction(); -} - -/** - * Comment. - * - * @param mixed $test An argument. - * - * @return mixed - */ -function test($test) -{ - if ($test === TRUE) { - return; - } - - return $test; - -}//end test() - - -/** Comment. - * - * @return mixed - * - */ -function test() -{ - -}//end test() - -/** - * Comment. - * - * @param \other\ns\item $test An argument. - * - * @return mixed - */ -function test(\other\ns\item $test) -{ - return $test; - -}//end test() - -/** - * Comment. - * - * @param item $test An argument. - * - * @return mixed - */ -function test(\other\ns\item $test) -{ - return $test; - -}//end test() - -/** - * Comment. - * - * @param \first\ns\item $test An argument. - * - * @return mixed - */ -function test(\first\ns\item $test = \second\ns::CONSTANT) -{ - return $test; - -}//end test() - -/** - * Comment. - * - * @param \first\item $test An argument. - * - * @return mixed - */ -function test(\first\ns\item $test = \second\ns::CONSTANT) -{ - return $test; - -}//end test() - -// Closures should be ignored. -preg_replace_callback( - '~-([a-z])~', - function ($match) { - return strtoupper($match[1]); - }, - 'hello-world' -); - -$callback = function ($bar) use ($foo) - { - $bar += $foo; - }; - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,143 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for FunctionCommentSniff. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_Commenting_FunctionCommentUnitTest 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 array( - 6 => 1, - 8 => 1, - 10 => 4, - 12 => 3, - 13 => 3, - 14 => 1, - 15 => 1, - 28 => 1, - 35 => 3, - 38 => 1, - 40 => 1, - 41 => 1, - 43 => 1, - 52 => 1, - 53 => 1, - 103 => 1, - 109 => 1, - 110 => 1, - 112 => 2, - 122 => 1, - 123 => 4, - 124 => 3, - 125 => 5, - 126 => 6, - 137 => 3, - 138 => 2, - 139 => 3, - 143 => 2, - 155 => 2, - 158 => 1, - 166 => 1, - 173 => 1, - 180 => 1, - 183 => 1, - 193 => 4, - 195 => 1, - 196 => 1, - 199 => 2, - 210 => 1, - 211 => 1, - 222 => 1, - 223 => 1, - 224 => 1, - 225 => 1, - 226 => 1, - 227 => 1, - 230 => 2, - 232 => 1, - 246 => 1, - 248 => 4, - 261 => 1, - 263 => 1, - 276 => 1, - 277 => 1, - 278 => 1, - 279 => 1, - 280 => 1, - 281 => 1, - 284 => 1, - 286 => 2, - 293 => 1, - 300 => 1, - 308 => 1, - 318 => 1, - 334 => 1, - 344 => 1, - 358 => 1, - 359 => 1, - 373 => 2, - 387 => 1, - 407 => 1, - 441 => 1, - 470 => 1, - 474 => 1, - 500 => 1, - 526 => 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 array( - 198 => 1, - ); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,93 +0,0 @@ - \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.js 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,99 +0,0 @@ -// Some content here. -var code = 'hello'; - -// This comment contains # multiple -// hash signs (#). -code = 'hello'; - -/** - * This is the first line of a function comment. - * This is the second line. - */ -function testFunction() -{ - // Callback methods which are added by external objects. - this.callbacks = {}; - -}//end testFunction() - -/** - * This is the first line of a class comment. - * This is the second line. - */ -myClass.prototype = { - - /** - * This is the first line of a method comment. - * This is the second line. - */ - load: function(url, callback) - { - // Some code here. - - } -}; - -// some code goes here! - -/* - A longer comment goes here. - It spans multiple lines!! - Or does it? -*/ - -// 0This is a simple multi-line -// comment! -code = 'hello'; - -//This is not valid. -code = 'hello'; - -// Neither is this! -code = 'hello'; - -// -code = 'hello'; - -/** Neither is this! **/ -code = 'hello'; - -/** - * This is the first line of a function comment. - * This is the second line. - */ -var myFunction = function() { -} - -/** - * This is the first line of a function comment. - * This is the second line. - */ -myFunction = function() { -} - -/** - * This is the first line of a function comment. - * This is the second line. - */ -myClass.myFunction = function() { -} - -dfx.getIframeDocument = function(iframe) -{ - return doc; - -};//end dfx.getIframeDocument() - -mig.Gallery.prototype = { - - init: function(cb) - { - - },//end init() - - imageClicked: function(id) - { - - }//end imageClicked() - -}; \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,99 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the InlineComment sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_Commenting_InlineCommentUnitTest 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='InlineCommentUnitTest.inc') - { - switch ($testFile) { - case 'InlineCommentUnitTest.inc': - return array( - 17 => 1, - 27 => 1, - 28 => 1, - 32 => 2, - 36 => 1, - 44 => 2, - 54 => 1, - 58 => 1, - 61 => 1, - 64 => 2, - 67 => 1, - ); - break; - case 'InlineCommentUnitTest.js': - return array( - 31 => 1, - 36 => 2, - 44 => 1, - 48 => 1, - 51 => 1, - 54 => 2, - 57 => 1, - ); - break; - default: - return array(); - break; - }//end switch - - }//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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/LongConditionClosingCommentUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/LongConditionClosingCommentUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/LongConditionClosingCommentUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/LongConditionClosingCommentUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,696 +0,0 @@ - \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/LongConditionClosingCommentUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/LongConditionClosingCommentUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/LongConditionClosingCommentUnitTest.js 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/LongConditionClosingCommentUnitTest.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,444 +0,0 @@ -function long_function() -{ - if (longFunction) { - // This is a long - // IF statement - // that does - // not have - // and ELSE - // block on it - variable = 'hello'; - - if (variable === 'hello') { - // This is a short - // IF statement - } - - if (variable === 'hello') { - // This is a short - // IF statement - } else { - // This is a short ELSE - // statement - } - }//end if - - if (longFunction) { - // This is a long - // IF statement - // that does - // not have - // and ELSE - // block on it - variable = 'hello'; - - if (variable === 'hello') { - // This is a short - // IF statement - } - - if (variable === 'hello') { - // This is a short - // IF statement - } else { - // This is a short ELSE - // statement - } - } - - if (longFunction) { - // This is a long - // IF statement - // that does - // not have - // and ELSE - // block on it - variable = 'hello'; - - if (variable === 'hello') { - // This is a short - // IF statement - } - - if (variable === 'hello') { - // This is a short - // IF statement - } else { - // This is a short ELSE - // statement - } - } else { - // Short ELSE - }//end if - - if (longFunction) { - // This is a long - // IF statement - // that does - // not have - // and ELSE - // block on it - variable = 'hello'; - - if (variable === 'hello') { - // This is a short - // IF statement - } - - if (variable === 'hello') { - // This is a short - // IF statement - } else { - // This is a short ELSE - // statement - } - } else { - // Short ELSE - } -} - -for (variable=1; variable < 20; variable++) { - // Line 1 - // Line 2 - // Line 3 - // Line 4 - // Line 5 - // Line 6 - // Line 7 - // Line 8 - // Line 9 - // Line 10 - // Line 11 - // Line 12 - // Line 13 - // Line 14 - // Line 15 - // Line 16 - // Line 17 - // Line 18 - // Line 19 - // Line 20 -}//end for - -for (variable=1; variable < 20; variable++) { - // Line 1 - // Line 2 - // Line 3 - // Line 4 - // Line 5 - // Line 6 - // Line 7 - // Line 8 - // Line 9 - for (val =1; val < 20; val++) { - // Short for. - } - // Line 13 - // Line 14 - // Line 15 - // Line 16 - // Line 17 - // Line 18 - // Line 19 - // Line 20 -} - -while (variable < 20) { - // Line 1 - // Line 2 - // Line 3 - // Line 4 - // Line 5 - // Line 6 - // Line 7 - // Line 8 - // Line 9 - // Line 10 - // Line 11 - // Line 12 - // Line 13 - // Line 14 - // Line 15 - // Line 16 - // Line 17 - // Line 18 - // Line 19 - // Line 20 -}//end while - -while (variable < 20) { - // Line 1 - // Line 2 - // Line 3 - // Line 4 - // Line 5 - // Line 6 - // Line 7 - // Line 8 - // Line 9 - while (something) { - // Short while. - } - // Line 13 - // Line 14 - // Line 15 - // Line 16 - // Line 17 - // Line 18 - // Line 19 - // Line 20 -} - -if (longFunction) { - // This is a long - // IF statement - // that does - // not have - // and ELSE - // block on it - variable = 'hello'; - - if (variable === 'hello') { - // This is a short - // IF statement - } - - if (variable === 'hello') { - // This is a short - // IF statement - } else { - // This is a short ELSE - // statement - } -} //end if - -if (longFunction) { - // This is a long - // IF statement - // that does - // not have - // and ELSE - // block on it - variable = 'hello'; - - if (variable === 'hello') { - // This is a short - // IF statement - } - - if (variable === 'hello') { - // This is a short - // IF statement - } else { - // This is a short ELSE - // statement - } -} else { - // Short ELSE -} //end if - -for (variable=1; variable < 20; variable++) { - // Line 1 - // Line 2 - // Line 3 - // Line 4 - // Line 5 - // Line 6 - // Line 7 - // Line 8 - // Line 9 - // Line 10 - // Line 11 - // Line 12 - // Line 13 - // Line 14 - // Line 15 - // Line 16 - // Line 17 - // Line 18 - // Line 19 - // Line 20 -} //end for - -while (variable < 20) { - // Line 1 - // Line 2 - // Line 3 - // Line 4 - // Line 5 - // Line 6 - // Line 7 - // Line 8 - // Line 9 - // Line 10 - // Line 11 - // Line 12 - // Line 13 - // Line 14 - // Line 15 - // Line 16 - // Line 17 - // Line 18 - // Line 19 - // Line 20 -} //end while - -while (variable < 20) { - // Line 1 - // Line 2 - // Line 3 - // Line 4 - // Line 5 - // Line 6 - // Line 7 - // Line 8 - // Line 9 - // Line 10 - // Line 11 - // Line 12 - // Line 13 - // Line 14 - // Line 15 - // Line 16 - // Line 17 - // Line 18 - // Line 19 - // Line 20 -}//end for - -if (true) { - // Line 1 - // Line 2 - // Line 3 - // Line 4 - // Line 5 - // Line 6 - // Line 7 - // Line 8 - // Line 9 - // Line 10 - // Line 11 - // Line 12 - // Line 13 - // Line 14 - // Line 15 - // Line 16 - // Line 17 - // Line 18 - // Line 19 - // Line 20 -} else if (condition) { - // Line 1 - // Line 2 - // Line 3 - // Line 4 - // Line 5 - // Line 6 - // Line 7 - // Line 8 - // Line 9 - // Line 10 - // Line 11 - // Line 12 - // Line 13 - // Line 14 - // Line 15 - // Line 16 - // Line 17 - // Line 18 - // Line 19 - // Line 20 -} else { - // Line 1 - // Line 2 - // Line 3 - // Line 4 - // Line 5 - // Line 6 - // Line 7 - // Line 8 - // Line 9 - // Line 10 - // Line 11 - // Line 12 - // Line 13 - // Line 14 - // Line 15 - // Line 16 - // Line 17 - // Line 18 - // Line 19 - // Line 20 -}//end if - -if (something) { - // Line 1 - // Line 2 -} else if (somethingElse) { - // Line 1 - // Line 2 -} else { - // Line 1 - // Line 2 - // Line 3 - // Line 4 - // Line 5 - // Line 6 - // Line 7 - // Line 8 - // Line 9 - // Line 10 - // Line 11 - // Line 12 - // Line 13 - // Line 14 - // Line 15 - // Line 16 - // Line 17 - // Line 18 - // Line 19 - // Line 20 -} - -switch (something) { - case '1': - // Line 1 - // Line 2 - // Line 3 - // Line 4 - // Line 5 - break; - case '2': - // Line 1 - // Line 2 - // Line 3 - // Line 4 - // Line 5 - break; - case '3': - // Line 1 - // Line 2 - // Line 3 - // Line 4 - // Line 5 - break; - case '4': - // Line 1 - // Line 2 - // Line 3 - // Line 4 - // Line 5 - break; - case '5': - // Line 1 - // Line 2 - // Line 3 - // Line 4 - // Line 5 - break; -} - -// Wrong comment -if (condition) { - condition = true; -}//end foreach \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/LongConditionClosingCommentUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/LongConditionClosingCommentUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/LongConditionClosingCommentUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/LongConditionClosingCommentUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,113 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the LongConditionClosingComment sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_Commenting_LongConditionClosingCommentUnitTest 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='LongConditionClosingCommentUnitTest.inc') - { - switch ($testFile) { - case 'LongConditionClosingCommentUnitTest.inc': - return array( - 49 => 1, - 99 => 1, - 146 => 1, - 192 => 1, - 215 => 1, - 238 => 1, - 261 => 1, - 286 => 1, - 309 => 1, - 332 => 1, - 355 => 1, - 378 => 1, - 493 => 1, - 531 => 1, - 536 => 1, - 540 => 1, - 562 => 1, - 601 => 1, - 629 => 1, - 663 => 1, - ); - break; - case 'LongConditionClosingCommentUnitTest.js': - return array( - 47 => 1, - 97 => 1, - 144 => 1, - 190 => 1, - 213 => 1, - 238 => 1, - 261 => 1, - 284 => 1, - 307 => 1, - 401 => 1, - 439 => 1, - 444 => 1, - ); - break; - default: - return array(); - break; - }//end switch - - }//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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ - \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.js 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -function test(id, buttons) // cool function -{ - alert('hello'); - alert('hello again'); // And again. - // Valid comment. - -}//end test() - -var good = true; // Indeed. - -mig.Gallery.prototype = { - - init: function(cb) - { - - },//end init() - - imageClicked: function(id) - { - - }//end imageClicked() - -}; - -dfx.getIframeDocument = function(iframe) -{ - - return doc; - -};//end dfx.getIframeDocument() \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,87 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the PostStatementComment sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_Commenting_PostStatementCommentUnitTest 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='PostStatementCommentUnitTest.inc') - { - switch ($testFile) { - case 'PostStatementCommentUnitTest.inc': - return array( - 6 => 1, - 10 => 1, - 18 => 1, - ); - break; - case 'PostStatementCommentUnitTest.js': - return array( - 1 => 1, - 4 => 1, - 9 => 1, - ); - break; - default: - return array(); - break; - }//end switch - - }//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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,189 +0,0 @@ - $content) { - echo $content; - } - - return $var1; - - }//end checkVariable() - - - /** - * - * - */ - $emptyVarDoc = ''; - - /** - * Var type checking (int v.s. integer). - * - * @var int - */ - private $_varSimpleTypeCheck; - - - /** - * Var type checking (array(int => string) v.s. array(int => string)). - * - * @var array(int => string) - */ - private $_varArrayTypeCheck; - - - /** - * Var type checking (STRING v.s. string). - * - * @var STRING - */ - private $_varCaseTypeCheck; - - - /** - * @var integer - */ - private $_varWithNoShortComment; - - protected $noComment2 = ''; - - -}//end class - - -/** - * VariableCommentUnitTest2. - * - * Long description goes here. - * - */ -class VariableCommentUnitTest2 -{ - - public $hello; - - /** Comment starts here. - * - * @var string - * - */ - private $_varCaseTypeCheck; - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,95 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for VariableCommentSniff. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_Commenting_VariableCommentUnitTest 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 array( - 6 => 1, - 8 => 1, - 21 => 1, - 24 => 1, - 28 => 1, - 38 => 1, - 41 => 1, - 53 => 1, - 56 => 1, - 63 => 1, - 64 => 1, - 69 => 2, - 73 => 1, - 81 => 1, - 82 => 1, - 84 => 1, - 90 => 1, - 92 => 1, - 128 => 1, - 137 => 1, - 145 => 1, - 153 => 1, - 158 => 1, - 159 => 1, - 163 => 1, - 178 => 1, - 180 => 1, - 184 => 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 array( - 93 => 1, - ); - - }//end getWarningList() - - -}//end class - -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,155 +0,0 @@ - 0); - -do -{ - echo $i; -} while ($i > 0); - -do -{ - echo $i; -} -while ($i > 0); - -do { echo $i; } while ($i > 0); - -do{ - echo $i; -}while($i > 0); - - -// while -while ($i < 1) { - echo $i; -} - -while($i < 1){ - echo $i; -} - -while ($i < 1) { echo $i; } - - -// for -for ($i = 1; $i < 1; $i++) { - echo $i; -} - -for($i = 1; $i < 1; $i++){ - echo $i; -} - -for ($i = 1; $i < 1; $i++) { echo $i; } - - -// foreach -foreach ($items as $item) { - echo $item; -} - -foreach($items as $item){ - echo $item; -} - -for ($items as $item) { echo $item; } - - -// if -if ($i == 0) { - $i = 1; -} - -if($i == 0){ - $i = 1; -} - -if ($i == 0) { $i = 1; } - - -// else -if ($i == 0) { - $i = 1; -} else { - $i = 0; -} - -if ($i == 0) { - $i = 1; -}else{ - $i = 0; -} - -if ($i == 0) { $i = 1; } else { $i = 0; } - - -// else -if ($i == 0) { - $i = 1; -} else { - $i = 0; -} - -if ($i == 0) { - $i = 1; -}else{ - $i = 0; -} - -if ($i == 0) { $i = 1; } else { $i = 0; } - - -// else if -if ($i == 0) { - $i = 1; -} else if ($i == 2) { - $i = 0; -} - -if ($i == 0) { - $i = 1; -}else if($i == 2){ - $i = 0; -} - -if ($i == 0) { $i = 1; } else if ($i == 2) { $i = 0; } - -if ($i == 0) { // comments are not allowed - $i = 1; -} - -if ($i == 0) {// comments are not allowed - $i = 1; -} - -if ($i == 0) { /* comments are not allowed*/ - $i = 1; -} - -if ($i == 0) -{ // this is not ok - $i = 1; -} - -if ($i == 0) /* this is not ok */ { -} - -try { - $code = 'this'; -} catch (Exception $e) { - // Caught! -} - -try { $code = 'this'; } catch (Exception $e) { - // Caught! -} - -do { echo $i; -} while ($i > 0); - -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.js 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,125 +0,0 @@ -// do ... while -i = 0; -do { - i = 0; -} while (i > 0); - -do -{ - i = 0; -} while (i > 0); - -do -{ - i = 0; -} -while (i > 0); - -do { i = 0; } while (i > 0); - -do{ - i = 0; -}while(i > 0); - -// while -while (i < 1) { - i = 0; -} - -while(i < 1){ - i = 0; -} - -while (i < 1) { i = 0; } - -// for -for (i = 1; i < 1; i++) { - i = 0; -} - -for(i = 1; i < 1; i++){ - i = 0; -} - -for (i = 1; i < 1; i++) { i = 0; } - -// if -if (i == 0) { - i = 1; -} - -if(i == 0){ - i = 1; -} - -if (i == 0) { i = 1; } - -// else -if (i == 0) { - i = 1; -} else { - i = 0; -} - -if (i == 0) { - i = 1; -}else{ - i = 0; -} - -if (i == 0) { i = 1; } else { i = 0; } - -// else -if (i == 0) { - i = 1; -} else { - i = 0; -} - -// else if -if (i == 0) { - i = 1; -} else if (i == 2) { - i = 0; -} - -if (i == 0) { - i = 1; -}else if(i == 2){ - i = 0; -} - -if (i == 0) { i = 1; } else if (i == 2) { i = 0; } - -if (i == 0) { // comments are not allowed - i = 1; -} - -if (i == 0) {// comments are not allowed - i = 1; -} - -if (i == 0) { /* comments are not allowed*/ - i = 1; -} - -if (i == 0) -{ // this is not ok - i = 1; -} - -if (i == 0) /* this is not ok */ { -} - -try { - code = 'this'; -} catch (e) { - // Caught! -} - -try { code = 'this'; } catch (e) { - // Caught! -} - -do { i = 0; -} while (i > 0); \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,127 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the ControlSignature sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_ControlStructures_ControlSignatureUnitTest 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='ControlSignatureUnitTest.inc') - { - switch ($testFile) { - case 'ControlSignatureUnitTest.inc': - return array( - 9 => 1, - 14 => 1, - 20 => 1, - 22 => 1, - 32 => 1, - 36 => 1, - 44 => 1, - 48 => 1, - 56 => 1, - 60 => 1, - 68 => 1, - 72 => 1, - 84 => 1, - 88 => 2, - 100 => 1, - 104 => 2, - 116 => 2, - 120 => 3, - 122 => 1, - 126 => 1, - 130 => 1, - 134 => 1, - 139 => 1, - 148 => 1, - 152 => 1, - ); - break; - case 'ControlSignatureUnitTest.js': - return array( - 7 => 1, - 12 => 1, - 18 => 1, - 20 => 1, - 29 => 1, - 33 => 1, - 40 => 1, - 44 => 1, - 51 => 1, - 55 => 1, - 66 => 1, - 70 => 2, - 88 => 2, - 92 => 3, - 94 => 1, - 98 => 1, - 102 => 1, - 106 => 1, - 111 => 1, - 120 => 1, - 124 => 1, - ); - break; - default: - return array(); - break; - }//end switch - - }//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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ElseIfDeclarationUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ElseIfDeclarationUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ElseIfDeclarationUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ElseIfDeclarationUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ - \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ElseIfDeclarationUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ElseIfDeclarationUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ElseIfDeclarationUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ElseIfDeclarationUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,70 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the ElseIfDeclaration sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_ControlStructures_ElseIfDeclarationUnitTest 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 array( - 8 => 1, - 13 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ForEachLoopDeclarationUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ForEachLoopDeclarationUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ForEachLoopDeclarationUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ForEachLoopDeclarationUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ - $that) { -} - -// Invalid. -foreach ( $something as $blah => $that ) { -} - -foreach ($something as $blah => $that) { -} - -foreach ($something as $blah => $that) { -} - -foreach (${something}AS$blah=>$that) { -} - -// The works. -foreach ( $something aS $blah => $that ) { -} - -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ForEachLoopDeclarationUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ForEachLoopDeclarationUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ForEachLoopDeclarationUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ForEachLoopDeclarationUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,73 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the ForEachLoopDeclaration sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_ControlStructures_ForEachLoopDeclarationUnitTest 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 array( - 8 => 2, - 11 => 2, - 14 => 2, - 17 => 5, - 21 => 7, - ); - - }//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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ - \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.js 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// Valid. -for (var i = 0; i < 10; i++) { -} - -// Invalid. -for ( i = 0; i < 10; i++ ) { -} - -for (i = 0; i < 10; i++) { -} - -for (var i = 0 ; i < 10 ; i++) { -} - -for (i = 0;i < 10;i++) { -} - -// The works. -for ( var i = 0 ; i < 10 ; i++ ) { -} - -this.formats = {}; -dfx.inherits('ContentFormat', 'Widget'); - -for (var widgetid in this.loadedContents) { - if (dfx.isset(widget) === true) { - widget.loadAutoSaveCWidgetStore.setData('activeScreen', null);widget.getContents(this.loadedContents[widgetid], function() {self.widgetLoaded(widget.id);}); - } -} \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,91 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the ForEachLoopDeclaration sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_ControlStructures_ForLoopDeclarationUnitTest 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='ForLoopDeclarationUnitTest.inc') - { - switch ($testFile) { - case 'ForLoopDeclarationUnitTest.inc': - return array( - 8 => 2, - 11 => 2, - 14 => 2, - 17 => 2, - 21 => 6, - ); - break; - case 'ForLoopDeclarationUnitTest.js': - return array( - 6 => 2, - 9 => 2, - 12 => 2, - 15 => 2, - 19 => 6, - ); - break; - default: - return array(); - break; - }//end switch - - }//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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/InlineIfDeclarationUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/InlineIfDeclarationUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/InlineIfDeclarationUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/InlineIfDeclarationUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -id.'"', - '"'.$this->stepInfo['title'].'"', - '"'.((isset($this->stepInfo['description']) === TRUE) ? $this->stepInfo['description'] : '').'"', - '"'.(isset($this->stepInfo['description']) === TRUE ? $this->stepInfo['description'] : '').'"', - '"'.$this->stepInfo['title'].'"', - ); - -echo (TRUE)?'Hello':'Bye'; - -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/InlineIfDeclarationUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/InlineIfDeclarationUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/InlineIfDeclarationUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/InlineIfDeclarationUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,78 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the InlineIfDeclaration sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_ControlStructures_InlineIfDeclarationUnitTest 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 array( - 4 => 1, - 5 => 1, - 6 => 1, - 7 => 1, - 8 => 1, - 9 => 1, - 10 => 1, - 13 => 1, - 20 => 1, - 24 => 4, - ); - - }//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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/LowercaseDeclarationUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/LowercaseDeclarationUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/LowercaseDeclarationUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/LowercaseDeclarationUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ - \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/LowercaseDeclarationUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/LowercaseDeclarationUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/LowercaseDeclarationUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/LowercaseDeclarationUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,79 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the LowercaseDeclaration sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_ControlStructures_LowercaseDeclarationUnitTest 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 array( - 3 => 1, - 5 => 1, - 7 => 1, - 9 => 1, - 10 => 1, - 12 => 1, - 14 => 1, - 15 => 1, - 16 => 1, - 20 => 1, - 21 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,241 +0,0 @@ - \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.js 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,240 +0,0 @@ - - -// Valid SWITCH statement. -switch (something) { - case '1': - myvar = '1'; - break; - - case '2': - case '3': - myvar = '5'; - break; - - case '4': - myvar = '4'; - break; - - default: - myvar = null; - break; -} - -// Alignment wrong. -switch (something) { - case '1': - myvar = '1'; - break; - -case '2': - case '3': - myvar = '5'; - break; - -case '4': - myvar = '4'; -break; - - default: - myvar = null; - break; -} - -// Closing brace wrong. -switch (something) { - case '1': - myvar = '1'; - break; - } - -// PEAR style. -switch (something) { -case '1': - myvar = '1'; - break; -case '2': -case '3': - myvar = '5'; - break; -case '4': - myvar = '4'; - break; -default: - myvar = null; - break; -} - -// Valid, but missing BREAKS. -switch (something) { - case '1': - myvar = '1'; - - case '2': - case '3': - myvar = '5'; - - case '4': - myvar = '4'; - - default: - myvar = null; -} - -// Invalid, and missing BREAKS. -switch (something) { - Case '1' : - myvar = '1'; - -case '2': - case '3' : - myvar = '5'; - - case'4': - myvar = '4'; - - Default : - myvar = null; - something = 'hello'; - other = 'hi'; - } - -// Valid -switch (condition) { - case 'string': - varStr = 'test'; - - default: - // Ignore the default. - break; -} - -// No default comment -switch (condition) { - case 'string': - varStr = 'test'; - - default: - break; -} - -// Break problems -switch (condition) { - case 'string': - - - varStr = 'test'; - - break; - - - case 'bool': - varStr = 'test'; - - - break; - default: - - varStr = 'test'; - break; - -} - -switch (var) { - case 'one': - case 'two': - break; - - case 'three': - // Nothing to do. - break; - - case 'four': - echo hi; - break; - - default: - // No default. - break; -} - -switch (var) { - case 'one': - if (blah) { - } - - break; - - default: - // No default. - break; -} - -switch (name) { - case "1": - switch (name2) { - case "1": - return true; - break; - - case "2": - return true; - break; - - default: - // No default. - break; - } - break; - - case "2": -switch (name2) { - case "1": - return true; - break; - - case "2": - return true; - break; - - default: - // No default. - break; -} - break; -} - -switch (name) { - case "1": - switch (name2) { - case "1": - return true; - break; - - default: - // No default. - break; - } - break; - - default: - // No default. - break; -} - -switch (name2) { - default: - // No default. - break; -} - -switch (foo) { - case "1": - return true; - break; - - default: - if (foo === false) { - break; - } - break; -} \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,103 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the SwitchDeclaration sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_ControlStructures_SwitchDeclarationUnitTest 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='SwitchDeclarationUnitTest.inc') - { - return array( - 27 => 1, - 29 => 1, - 34 => 1, - 36 => 1, - 44 => 1, - 48 => 1, - 52 => 1, - 54 => 1, - 55 => 1, - 56 => 1, - 58 => 1, - 59 => 1, - 61 => 1, - 62 => 1, - 79 => 1, - 85 => 2, - 88 => 2, - 89 => 2, - 92 => 1, - 95 => 3, - 99 => 1, - 116 => 1, - 122 => 1, - 127 => 2, - 134 => 2, - 135 => 1, - 138 => 1, - 143 => 1, - 144 => 1, - 147 => 1, - 165 => 1, - 172 => 1, - 224 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Debug/JSLintUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Debug/JSLintUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Debug/JSLintUnitTest.js 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Debug/JSLintUnitTest.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -alert('hi') -alert('hi'); diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Debug/JSLintUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Debug/JSLintUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Debug/JSLintUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Debug/JSLintUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,81 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the JSLint sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_Debug_JSLintUnitTest extends AbstractSniffUnitTest -{ - - - /** - * Should this test be skipped for some reason. - * - * @return void - */ - protected function shouldSkipTest() - { - $jslPath = PHP_CodeSniffer::getConfigData('jslint_path'); - return (is_null($jslPath)); - - }//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 array(); - - }//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 array( - 1 => 2, - 2 => 1, - ); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Debug/JavaScriptLintUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Debug/JavaScriptLintUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Debug/JavaScriptLintUnitTest.js 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Debug/JavaScriptLintUnitTest.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -alert('hi') -alert('hi'); diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Debug/JavaScriptLintUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Debug/JavaScriptLintUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Debug/JavaScriptLintUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Debug/JavaScriptLintUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,80 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the JavaScriptLint sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_Debug_JavaScriptLintUnitTest extends AbstractSniffUnitTest -{ - - - /** - * Should this test be skipped for some reason. - * - * @return void - */ - protected function shouldSkipTest() - { - $jslPath = PHP_CodeSniffer::getConfigData('jsl_path'); - return (is_null($jslPath)); - - }//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 array(); - - }//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 array( - 2 => 1, - ); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Files/FileExtensionUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Files/FileExtensionUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Files/FileExtensionUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Files/FileExtensionUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,3 +0,0 @@ - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Files/FileExtensionUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Files/FileExtensionUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Files/FileExtensionUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Files/FileExtensionUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,69 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the FileExtension sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_Files_FileExtensionUnitTest 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 array( - 1 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,133 +0,0 @@ -words[$wordPos-1]) || $this->words[$wordPos-1] !== ' ') { -} else if ($this->tokens[$pos + 1] === "\n") { -} - -if ($pos === count($this->tokens) - 1) { - $file = '...'.substr($file, (($padding * -1) + 3)); -} - -if (substr($basename, -5) !== 'Sniff') { - $i = ($this->_tokens[$i]['parenthesis_closer'] + 1); -} - -$pos = $this->_getShortCommentEndPos(); -if ($pos === -1) { - $stackPtr = ($tokens[$next][$to] - 1); - $stackPtr = ($tokens[$next][$pattern[$i]['to']] + 1); - $var = (($var1 + $var2) + $var3 + $var4) -} - -$commentStart = ($phpcsFile->findPrevious(T_DOC_COMMENT, ($commentEnd - 1), null, true) + 1); -$commentEnd = ($this->_phpcsFile->findNext(T_DOC_COMMENT, ($commentStart + 1), null, true) - 1); -$expected .= '...'.substr($tokens[($stackPtr - 2)]['content'], -5).$tokens[$stackPtr]['content']; - -if (($tokens[$nextToken - 1]['code']) !== T_WHITESPACE) { - $errorPos = ($params[(count($params) - 1)]->getLine() + $commentStart); -} - -while (($nextSpace = $phpcsFile->findNext(T_WHITESPACE, $nextSpace + 1, $nextBreak)) !== false) { -} - -foreach ($attributes as $id => &$attribute) { -} - -class MyClass -{ - - - public function &myFunction(array &$one, array &$two) - { - - }//end myFunction() - - -}//end class - -if ($index < -1) $index = 0; -if ($index < - 1) $index = 0; - -$three = ceil($one / $two); -$three = ceil(($one / $two) / $four); -$three = ceil($one / ($two / $four)); - -$four = -0.25; - -$three = ceil($one[1] / $two); - -switch ($number % 10) { - case 1: - $suffix = 'st'; - break; -} - -$expectedPermission = array( - 'granted' => 4, - 'denied' => 1, - 'cascade' => TRUE, - 'blockergranted' => 2, - 'blockerdenied' => - 3, - 'effective' => TRUE, - ); -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.js 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,106 +0,0 @@ -value = (one + two); -value = one + two; - -value = (one - two); -value = one - two; - -value = (one * two); -value = one * two; - -value = (one / two); -value = one / two; - -value = (one % two); -value = one % two; - -value = (one + two + three); -value = one + two + three; -value = (one + (two + three)); -value = one + (two + three); - -value++; -value--; -value = -1; -value = - 1; - -value = (1 + 2); -value = 1 + 2; - -value = (1 - 2); -value = 1 - 2; - -value = (1 * 2); -value = 1 * 2; - -value = (1 / 2); -value = 1 / 2; - -value = (1 % 2); -value = 1 % 2; - -value = (1 + 2 + 3); -value = 1 + 2 + 3; -value = (1 + (2 + 3)); -value = 1 + (2 + 3); - -value = one + 2 + 3 - (four * five * (6 + 7)) + nine + 2; -value = myFunction(tokens[stackPtr - 1]); - -for (i = 1 + 2; i < 4 + 5; i++) { -} - -function myFunction() -{ - value = (one + 1) + (two + 2) + (myFunction() + 2); - value = myFunction() + 2; - value = (myFunction(mvar) + myFunction2(mvar)); - return -1; -} - -params['mode'] = id.replace(/WidgetType/, ''); - -if (index < -1) index = 0; -if (index < - 1) index = 0; - -var classN = prvId.replace(/\./g, '-'); - -three = myFunction(one / two); -three = myFunction((one / two) / four); -three = myFunction(one / (two / four)); - -four = -0.25; - -id = id.replace(/row\/:/gi, ''); -return /MSIE/.test(navigator.userAgent); - -var re = new RegExp(/<\/?(\w+)((\s+\w+(\s*=\s*(?:".*?"|'.*?'|[^'">\s]+))?)+\s*|\s*)\/?>/gim); - -var options = { - minVal: -1, - maxVal: -1 -}; - -stepWidth = Math.round(this.width / 5); - -date.setMonth(d[2] - 1); - -switch (number % 10) { - case 1: - suffix = 'st'; - break; -} - -var pathSplit = ipt.value.split(/\/|\\/); - -if (pairs[i].search(/=/) !== -1) { -} - -if (urlValue.search(/[a-zA-z]+:\/\//) !== 0) { -} - -if (urlValue.search(/[a-zA-z]+:\/\/*/) !== 0) { -} - -if (!value || /^\s*$/.test(value)) { - return true; -} diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,120 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the OperatorBracket sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_Formatting_OperatorBracketUnitTest 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='OperatorBracketUnitTest.inc') - { - switch ($testFile) { - case 'OperatorBracketUnitTest.inc': - return array( - 3 => 1, - 6 => 1, - 9 => 1, - 12 => 1, - 15 => 1, - 18 => 2, - 20 => 1, - 25 => 1, - 28 => 1, - 31 => 1, - 34 => 1, - 37 => 1, - 40 => 1, - 43 => 2, - 45 => 1, - 47 => 5, - 48 => 1, - 50 => 2, - 55 => 2, - 56 => 1, - 63 => 2, - 64 => 1, - 67 => 1, - 86 => 1, - 90 => 1, - 109 => 1, - 130 => 1, - ); - break; - case 'OperatorBracketUnitTest.js': - return array( - 5 => 1, - 8 => 1, - 11 => 1, - 14 => 1, - 24 => 1, - 30 => 1, - 33 => 1, - 36 => 1, - 39 => 1, - 46 => 1, - 47 => 1, - 63 => 1, - ); - break; - default: - return array(); - break; - }//end switch - - }//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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Functions/FunctionDeclarationArgumentSpacingUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Functions/FunctionDeclarationArgumentSpacingUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Functions/FunctionDeclarationArgumentSpacingUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Functions/FunctionDeclarationArgumentSpacingUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Functions/FunctionDeclarationArgumentSpacingUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Functions/FunctionDeclarationArgumentSpacingUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Functions/FunctionDeclarationArgumentSpacingUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Functions/FunctionDeclarationArgumentSpacingUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,79 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the FunctionDeclarationArgumentSpacing sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_Functions_FunctionDeclarationArgumentSpacingUnitTest 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 array( - 3 => 1, - 5 => 2, - 7 => 2, - 8 => 2, - 9 => 2, - 11 => 2, - 13 => 7, - 14 => 2, - 15 => 2, - 16 => 4, - 18 => 2, - ); - - }//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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Functions/FunctionDeclarationUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Functions/FunctionDeclarationUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Functions/FunctionDeclarationUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Functions/FunctionDeclarationUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,66 +0,0 @@ - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Functions/FunctionDeclarationUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Functions/FunctionDeclarationUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Functions/FunctionDeclarationUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Functions/FunctionDeclarationUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,69 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the FunctionDeclaration sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_Functions_FunctionDeclarationUnitTest 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 array( - 55 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Functions/FunctionDuplicateArgumentUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Functions/FunctionDuplicateArgumentUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Functions/FunctionDuplicateArgumentUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Functions/FunctionDuplicateArgumentUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,6 +0,0 @@ - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Functions/FunctionDuplicateArgumentUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Functions/FunctionDuplicateArgumentUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Functions/FunctionDuplicateArgumentUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Functions/FunctionDuplicateArgumentUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,71 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the FunctionDuplicateArgument sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_Functions_FunctionDuplicateArgumentUnitTest 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 array( - 2 => 1, - 4 => 2, - 5 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Functions/GlobalFunctionUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Functions/GlobalFunctionUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Functions/GlobalFunctionUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Functions/GlobalFunctionUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Functions/GlobalFunctionUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Functions/GlobalFunctionUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Functions/GlobalFunctionUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Functions/GlobalFunctionUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,69 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the GlobalFunction sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_Functions_GlobalFunctionUnitTest 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 array(); - - }//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 array( - 2 => 1, - ); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Functions/LowercaseFunctionKeywordsUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Functions/LowercaseFunctionKeywordsUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Functions/LowercaseFunctionKeywordsUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Functions/LowercaseFunctionKeywordsUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,7 +0,0 @@ - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Functions/LowercaseFunctionKeywordsUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Functions/LowercaseFunctionKeywordsUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Functions/LowercaseFunctionKeywordsUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Functions/LowercaseFunctionKeywordsUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,73 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the LowercaseFunctionKeywords sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_Functions_LowercaseFunctionKeywordsUnitTest 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 array( - 2 => 1, - 3 => 1, - 4 => 1, - 5 => 1, - 6 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,60 +0,0 @@ - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,79 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the MultiLineFunctionDeclaration sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_Functions_MultiLineFunctionDeclarationUnitTest 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 array( - 2 => 1, - 3 => 1, - 4 => 3, - 5 => 1, - 7 => 1, - 11 => 1, - 12 => 1, - 13 => 1, - 16 => 1, - 33 => 1, - 36 => 1, - 43 => 2, - 48 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/NamingConventions/ConstantCaseUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/NamingConventions/ConstantCaseUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/NamingConventions/ConstantCaseUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/NamingConventions/ConstantCaseUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,52 +0,0 @@ -null = 7; -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/NamingConventions/ConstantCaseUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/NamingConventions/ConstantCaseUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/NamingConventions/ConstantCaseUnitTest.js 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/NamingConventions/ConstantCaseUnitTest.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -if (variable === true) { } -if (variable === TRUE) { } -if (variable === True) { } -variable = True; - -if (variable === false) { } -if (variable === FALSE) { } -if (variable === False) { } -variable = false; - -if (variable === null) { } -if (variable === NULL) { } -if (variable === Null) { } -variable = NULL; diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/NamingConventions/ConstantCaseUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/NamingConventions/ConstantCaseUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/NamingConventions/ConstantCaseUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/NamingConventions/ConstantCaseUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,101 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the ConstantCase sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_NamingConventions_ConstantCaseUnitTest 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='ConstantCaseUnitTest.inc') - { - switch ($testFile) { - case 'ConstantCaseUnitTest.inc': - return array( - 7 => 1, - 10 => 1, - 15 => 1, - 16 => 1, - 23 => 1, - 26 => 1, - 31 => 1, - 32 => 1, - 39 => 1, - 42 => 1, - 47 => 1, - 48 => 1, - ); - break; - case 'ConstantCaseUnitTest.js': - return array( - 2 => 1, - 3 => 1, - 4 => 1, - 7 => 1, - 8 => 1, - 12 => 1, - 13 => 1, - 14 => 1, - ); - break; - default: - return array(); - break; - }//end switch - - }//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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/NamingConventions/ValidFunctionNameUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/NamingConventions/ValidFunctionNameUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/NamingConventions/ValidFunctionNameUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/NamingConventions/ValidFunctionNameUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/NamingConventions/ValidFunctionNameUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/NamingConventions/ValidFunctionNameUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/NamingConventions/ValidFunctionNameUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/NamingConventions/ValidFunctionNameUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,79 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the ValidFunctionName sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_NamingConventions_ValidFunctionNameUnitTest 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 array( - 4 => 1, - 5 => 1, - 6 => 1, - 7 => 1, - 8 => 1, - 9 => 1, - 11 => 1, - 12 => 1, - 13 => 1, - 14 => 1, - 16 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/NamingConventions/ValidVariableNameUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/NamingConventions/ValidVariableNameUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/NamingConventions/ValidVariableNameUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/NamingConventions/ValidVariableNameUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,102 +0,0 @@ -varName2; -echo $this->var_name2; -echo $this->varname2; -echo $this->_varName2; -echo $object->varName2; -echo $object->var_name2; -echo $object_name->varname2; -echo $object_name->_varName2; - -echo $this->myFunction($one, $two); -echo $object->myFunction($one_two); - -$error = "format is \$GLOBALS['$varName']"; - -echo $_SESSION['var_name']; -echo $_FILES['var_name']; -echo $_ENV['var_name']; -echo $_COOKIE['var_name']; - -$XML = 'hello'; -$myXML = 'hello'; -$XMLParser = 'hello'; -$xmlParser = 'hello'; - -echo "{$_SERVER['HOSTNAME']} $var_name"; - -// Need to be the last thing in this test file. -$obj->$classVar = $prefix.'-'.$type; - -class foo -{ - const bar = << diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/NamingConventions/ValidVariableNameUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/NamingConventions/ValidVariableNameUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/NamingConventions/ValidVariableNameUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/NamingConventions/ValidVariableNameUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,94 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the ValidVariableName sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_NamingConventions_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 array( - 3 => 1, - 5 => 1, - 10 => 1, - 12 => 1, - 15 => 1, - 17 => 1, - 20 => 1, - 22 => 1, - 25 => 1, - 27 => 1, - 31 => 1, - 33 => 1, - 36 => 1, - 37 => 1, - 39 => 1, - 42 => 1, - 44 => 1, - 53 => 1, - 58 => 1, - 62 => 1, - 63 => 1, - 64 => 1, - 67 => 1, - 76 => 1, - 78 => 1, - 81 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Objects/DisallowObjectStringIndexUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Objects/DisallowObjectStringIndexUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Objects/DisallowObjectStringIndexUnitTest.js 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Objects/DisallowObjectStringIndexUnitTest.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -function test(id) -{ - - this.id = id; - -} - -test.prototype = { - init: function() - { - var x = {}; - x.name = 'test'; - x['phone'] = 123124324; - var t = ['test', 'this'].join(''); - var y = ['test'].join(''); - var a = x[0]; - var z = x[x['name']]; - var p = x[x.name]; - } - -}; - -function test() { - this.errors['step_' + step] = errors; - this.errors['test'] = x; - this.errors['test' + 10] = x; - this.errors['test' + y] = x; - this.errors['test' + 'blah'] = x; - this.errors[y] = x; - this.errors[y + z] = x; - this.permissions['workflow.cancel'] = x; -} - -if (child.prototype) { - above.prototype['constructor'] = parent; - child.prototype['super'] = new above(); -} diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Objects/DisallowObjectStringIndexUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Objects/DisallowObjectStringIndexUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Objects/DisallowObjectStringIndexUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Objects/DisallowObjectStringIndexUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,76 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the DisallowObjectStringIndex sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Sertan Danis - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_Objects_DisallowObjectStringIndexUnitTest 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='DisallowObjectStringIndexUnitTest.js') - { - if ($testFile !== 'DisallowObjectStringIndexUnitTest.js') { - return array(); - } - - return array( - 13 => 1, - 17 => 1, - 25 => 1, - 35 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Objects/ObjectInstantiationUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Objects/ObjectInstantiationUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Objects/ObjectInstantiationUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Objects/ObjectInstantiationUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ - new MyClass()); -$object->myFunction(new MyClass()); - -throw new MyException($msg); - -function foo() { return new MyClass(); } - -$doodad = $x ? new Foo : new Bar; -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Objects/ObjectInstantiationUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Objects/ObjectInstantiationUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Objects/ObjectInstantiationUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Objects/ObjectInstantiationUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,70 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the ObjectInstantiation sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_Objects_ObjectInstantiationUnitTest 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 array( - 5 => 1, - 8 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Objects/ObjectMemberCommaUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Objects/ObjectMemberCommaUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Objects/ObjectMemberCommaUnitTest.js 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Objects/ObjectMemberCommaUnitTest.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -this.request({ action: 'getTypeFormatContents', }); - -addTypeFormatButton.addClickEvent(function() { - self.addNewTypeFormat(); -}); - -var x = {}; - -var y = { - VarOne : 'If you ask me, thats if you ask', - VarTwo : ['Alonzo played you', 'for a fool', 'esse'], - VarThree: function(arg) { - console.info(1); - } -}; - -var z = { - VarOne : 'If you ask me, thats if you ask', - VarTwo : ['Alonzo played you', 'for a fool', 'esse'], - VarThree: function(arg) { - console.info(1); - }, -}; - -var x = function() { - console.info(2); -}; - -AssetListingEditWidgetType.prototype = { - init: function(data, assetid, editables) - { - } -}; - -AssetListingEditWidgetType.prototype = { - init: function(data, assetid, editables) - { - }, -}; diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Objects/ObjectMemberCommaUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Objects/ObjectMemberCommaUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Objects/ObjectMemberCommaUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Objects/ObjectMemberCommaUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,75 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the ObjectMemberComma sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_Objects_ObjectMemberCommaUnitTest 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='ObjectMemberCommaUnitTest.js') - { - if ($testFile !== 'ObjectMemberCommaUnitTest.js') { - return array(); - } - - return array( - 1 => 1, - 22 => 1, - 38 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,81 +0,0 @@ - - - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.js 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -if (value === TRUE) { -} else if (value === FALSE) { -} - -if (value == TRUE) { -} else if (value == FALSE) { -} - -if (value) { -} else if (!value) { -} - -if (value.isSomething === TRUE) { -} else if (myFunction(value) === FALSE) { -} - -if (value.isSomething == TRUE) { -} else if (myFunction(value) == FALSE) { -} - -if (value.isSomething) { -} else if (!myFunction(value)) { -} - -if (value === TRUE || other === FALSE) { -} - -if (value == TRUE || other == FALSE) { -} - -if (value || !other) { -} - -if (one === TRUE || two === TRUE || three === FALSE || four === TRUE) { -} - -if (one || two || !three || four) { -} diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,103 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the ComparionOperatorUsage sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_Operators_ComparisonOperatorUsageUnitTest 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='ComparisonOperatorUsageUnitTest.inc') - { - switch ($testFile) { - case 'ComparisonOperatorUsageUnitTest.inc': - return array( - 6 => 1, - 7 => 1, - 10 => 1, - 11 => 1, - 18 => 1, - 19 => 1, - 22 => 1, - 23 => 1, - 29 => 2, - 32 => 2, - 38 => 4, - 47 => 2, - 69 => 1, - 72 => 1, - 75 => 1, - 78 => 1, - 80 => 1, - ); - break; - case 'ComparisonOperatorUsageUnitTest.js': - return array( - 5 => 1, - 6 => 1, - 17 => 1, - 18 => 1, - 28 => 2, - ); - break; - default: - return array(); - break; - }//end switch - - }//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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,77 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the IncrementDecrementUsage sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_Operators_IncrementDecrementUsageUnitTest 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 array( - 2 => 1, - 6 => 1, - 12 => 1, - 16 => 1, - 25 => 1, - 26 => 1, - 27 => 1, - 29 => 1, - 31 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Operators/ValidLogicalOperatorsUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Operators/ValidLogicalOperatorsUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Operators/ValidLogicalOperatorsUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Operators/ValidLogicalOperatorsUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Operators/ValidLogicalOperatorsUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Operators/ValidLogicalOperatorsUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Operators/ValidLogicalOperatorsUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Operators/ValidLogicalOperatorsUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,73 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the ValidLogicalOperators sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_Operators_ValidLogicalOperatorsUnitTest 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 array( - 5 => 1, - 11 => 1, - 17 => 2, - 23 => 1, - 26 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.css php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.css --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.css 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.css 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -/* CSS Document */ - -body { -font-family: Arial, Helvetica, sans-serif; -margin : 40px 0 0 0; -padding : 0; -/*background: #8FB7DB url(login_glow_bg.jpg) no-repeat 30% 0;*/ -background: #8FB7DB url(diag_lines_bg.gif) top left; -} - -#login-container { - margin-left: -225px; - margin-top: -161px; - position:absolute; - top :50%; - /*left :50%;*/ - width:450px; -} - -#cacheConfig-dayLabel, #cacheConfig-hourLabel, #cacheConfig-minuteLabel { - float: left; - padding-right: 8px; -} diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,61 +0,0 @@ - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,85 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the CommentedOutCode sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_PHP_CommentedOutCodeUnitTest 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 array(); - - }//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($testFile='CommentedOutCodeUnitTest.inc') - { - switch ($testFile) { - case 'CommentedOutCodeUnitTest.inc': - return array( - 6 => 1, - 8 => 1, - 15 => 1, - 19 => 1, - ); - break; - case 'CommentedOutCodeUnitTest.css': - return array( - 7 => 1, - 16 => 1, - ); - break; - default: - return array(); - break; - }//end switch - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowComparisonAssignmentUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowComparisonAssignmentUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowComparisonAssignmentUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowComparisonAssignmentUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowComparisonAssignmentUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowComparisonAssignmentUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowComparisonAssignmentUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowComparisonAssignmentUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,74 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the DisallowComparisonAssignment sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_PHP_DisallowComparisonAssignmentUnitTest 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 array( - 3 => 1, - 5 => 1, - 6 => 1, - 7 => 1, - 8 => 1, - 10 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowInlineIfUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowInlineIfUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowInlineIfUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowInlineIfUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowInlineIfUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowInlineIfUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowInlineIfUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowInlineIfUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,81 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the DisallowInlineIf sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_PHP_DisallowInlineIfUnitTest 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($testFile='DisallowInlineIfUnitTest.inc') - { - switch ($testFile) { - case 'DisallowInlineIfUnitTest.inc': - return array( - 8 => 1, - ); - break; - case 'DisallowInlineIfUnitTest.js': - return array( - 1 => 1, - ); - break; - default: - return array(); - break; - }//end switch - - }//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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowMultipleAssignmentsUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowMultipleAssignmentsUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowMultipleAssignmentsUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowMultipleAssignmentsUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -fetch(PDO::FETCH_NUM)) { - $result[$row[0]] = array() - $result[$row[0]][] = $current; - - self::$_inTransaction = TRUE; - $$varName = $varValue; - } - -}//end getVar() - -class myClass -{ - private static $_dbh = NULL; - public $dbh = NULL; - protected $dbh = NULL; -} - -$var = $var2; -list ($a, $b) = explode(',', $c); -$var1 ? $var2 = 0 : $var2 = 1; - -$obj->$classVar = $prefix.'-'.$type; -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowMultipleAssignmentsUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowMultipleAssignmentsUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowMultipleAssignmentsUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowMultipleAssignmentsUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,74 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the DisallowMultipleAssignments sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_PHP_DisallowMultipleAssignmentsUnitTest 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 array( - 4 => 1, - 5 => 2, - 7 => 1, - 9 => 1, - 12 => 1, - 14 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowObEndFlushUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowObEndFlushUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowObEndFlushUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowObEndFlushUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowObEndFlushUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowObEndFlushUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowObEndFlushUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowObEndFlushUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,69 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the DisallowObEndFlush sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_PHP_DisallowObEndFlushUnitTest 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 array( - 9 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowSizeFunctionsInLoopsUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowSizeFunctionsInLoopsUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowSizeFunctionsInLoopsUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowSizeFunctionsInLoopsUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,52 +0,0 @@ -children); $i++) { -} - - - -for ($i = 0; $i < sizeof($array); $i++) { -} - -$num = sizeof($array); - -while ($i < sizeof($array)) { -} - -do { -} while ($i < sizeof($array)); - -for ($i = 0; $i < sizeof($this->children); $i++) { -} - - - - -for ($i = 0; $i < strlen($string); $i++) { -} - -$num = strlen($string); - -while ($i < strlen($string)) { -} - -do { -} while ($i < strlen($string)); - -for ($i = 0; $i < strlen($this->string); $i++) { -} - -for ($i = sizeof($array); $i > 0; $i--) { -} - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowSizeFunctionsInLoopsUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowSizeFunctionsInLoopsUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowSizeFunctionsInLoopsUnitTest.js 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowSizeFunctionsInLoopsUnitTest.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -for (var i = 0; i < permissions.length; i++) { - // Code here. -} - -var permLen = permissions.length; -for (var length = 0; i < permLen; i++) { - // Code here. -} - -var myArray = [1, 2, 3, 4]; -for (var i = myArray.length; i >= 0; i--) { - var x = i; -} diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowSizeFunctionsInLoopsUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowSizeFunctionsInLoopsUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowSizeFunctionsInLoopsUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowSizeFunctionsInLoopsUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,94 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the DisallowSizeFunctionsInLoops sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_PHP_DisallowSizeFunctionsInLoopsUnitTest 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='DisallowSizeFunctionsInLoopsUnitTest.inc') - { - switch ($testFile) { - case 'DisallowSizeFunctionsInLoopsUnitTest.inc': - return array( - 2 => 1, - 7 => 1, - 11 => 1, - 13 => 1, - 18 => 1, - 23 => 1, - 27 => 1, - 29 => 1, - 35 => 1, - 40 => 1, - 44 => 1, - 46 => 1, - ); - break; - case 'DisallowSizeFunctionsInLoopsUnitTest.js': - return array( - 1 => 1, - ); - break; - default: - return array(); - break; - }//end switch - - }//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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/DiscouragedFunctionsUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/DiscouragedFunctionsUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/DiscouragedFunctionsUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/DiscouragedFunctionsUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,4 +0,0 @@ - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/DiscouragedFunctionsUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/DiscouragedFunctionsUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/DiscouragedFunctionsUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/DiscouragedFunctionsUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,68 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the DiscouragedFunctions sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_PHP_DiscouragedFunctionsUnitTest 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 array(); - - }//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 array( - 2 => 1, - 3 => 1, - ); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ - - - -<?php echo $title ?> - - - - - hello - - - - - - - - - - - - - - - - - - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,84 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the EmbeddedPhp sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_PHP_EmbeddedPhpUnitTest 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 array( - 7 => 1, - 12 => 1, - 18 => 1, - 19 => 2, - 20 => 1, - 21 => 1, - 22 => 3, - 24 => 1, - 26 => 1, - 29 => 1, - 30 => 1, - 31 => 1, - 34 => 1, - 36 => 1, - 40 => 1, - 41 => 2, - ); - - }//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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/EvalUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/EvalUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/EvalUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/EvalUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/EvalUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/EvalUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/EvalUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/EvalUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,70 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the Eval sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_PHP_EvalUnitTest 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 array(); - - }//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 array( - 2 => 1, - 4 => 1, - ); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/ForbiddenFunctionsUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/ForbiddenFunctionsUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/ForbiddenFunctionsUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/ForbiddenFunctionsUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/ForbiddenFunctionsUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/ForbiddenFunctionsUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/ForbiddenFunctionsUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/ForbiddenFunctionsUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,72 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the ForbiddenFunctions sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_PHP_ForbiddenFunctionsUnitTest 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 array( - 2 => 1, - 3 => 1, - 4 => 1, - 5 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/GlobalKeywordUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/GlobalKeywordUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/GlobalKeywordUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/GlobalKeywordUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/GlobalKeywordUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/GlobalKeywordUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/GlobalKeywordUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/GlobalKeywordUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,70 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the GlobalKeyword sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_PHP_GlobalKeywordUnitTest 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 array( - 8 => 1, - 9 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/HeredocUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/HeredocUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/HeredocUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/HeredocUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -foo. -Now, I am printing some {$foo->bar[1]}. -This should not print a capital 'A': \x41 -EOT; -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/HeredocUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/HeredocUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/HeredocUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/HeredocUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,70 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the Heredoc sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_PHP_HeredocUnitTest 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 array( - 2 => 1, - 8 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/InnerFunctionsUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/InnerFunctionsUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/InnerFunctionsUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/InnerFunctionsUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/InnerFunctionsUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/InnerFunctionsUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/InnerFunctionsUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/InnerFunctionsUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,69 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the InnerFunctions sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_PHP_InnerFunctionsUnitTest 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 array( - 5 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/LowercasePHPFunctionsUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/LowercasePHPFunctionsUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/LowercasePHPFunctionsUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/LowercasePHPFunctionsUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/LowercasePHPFunctionsUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/LowercasePHPFunctionsUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/LowercasePHPFunctionsUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/LowercasePHPFunctionsUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,88 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the LowercasePHPFunctions sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_PHP_LowercasePHPFunctionsUnitTest 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 array( - 2 => 1, - 3 => 1, - 4 => 1, - 5 => 1, - 7 => 1, - 8 => 1, - 9 => 1, - 10 => 1, - 11 => 1, - 12 => 1, - 14 => 1, - 15 => 1, - 18 => 1, - 19 => 1, - 20 => 1, - 21 => 1, - 22 => 1, - 24 => 1, - 27 => 1, - 29 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,159 +0,0 @@ - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,91 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the NonExecutableCode sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_PHP_NonExecutableCodeUnitTest 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 array(); - - }//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 array( - 5 => 1, - 11 => 1, - 17 => 1, - 18 => 1, - 19 => 2, - 28 => 1, - 32 => 1, - 33 => 2, - 34 => 2, - 42 => 1, - 45 => 1, - 54 => 1, - 58 => 1, - 73 => 1, - 83 => 1, - 95 => 1, - 105 => 1, - 118 => 1, - 140 => 1, - 141 => 1, - 142 => 1, - 143 => 2, - 147 => 1, - ); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Scope/MemberVarScopeUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Scope/MemberVarScopeUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Scope/MemberVarScopeUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Scope/MemberVarScopeUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ - \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Scope/MemberVarScopeUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Scope/MemberVarScopeUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Scope/MemberVarScopeUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Scope/MemberVarScopeUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,69 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the MemberVarScope sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_Scope_MemberVarScopeUnitTest 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 array( - 7 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Scope/MethodScopeUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Scope/MethodScopeUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Scope/MethodScopeUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Scope/MethodScopeUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ - \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Scope/MethodScopeUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Scope/MethodScopeUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Scope/MethodScopeUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Scope/MethodScopeUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,69 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the MethodScope sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_Scope_MethodScopeUnitTest 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 array( - 6 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Scope/StaticThisUsageUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Scope/StaticThisUsageUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Scope/StaticThisUsageUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Scope/StaticThisUsageUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -func2()); - $result = $this->getValue($value); - return $this->setValue($result); - } - - public function func1() - { - $value = 'hello'; - $newValue = array($this->func2()); - $result = $this->getValue($value); - return $this->setValue($result); - } - - function func1() - { - $value = 'hello'; - $newValue = array($this->func2()); - $result = $this->getValue($value); - return $this->setValue($result); - } -} -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Scope/StaticThisUsageUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Scope/StaticThisUsageUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Scope/StaticThisUsageUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Scope/StaticThisUsageUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,71 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the StaticThisUsage sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_Scope_StaticThisUsageUnitTest 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 array( - 7 => 1, - 8 => 1, - 9 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Strings/ConcatenationSpacingUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Strings/ConcatenationSpacingUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Strings/ConcatenationSpacingUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Strings/ConcatenationSpacingUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ - \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Strings/ConcatenationSpacingUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Strings/ConcatenationSpacingUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Strings/ConcatenationSpacingUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Strings/ConcatenationSpacingUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,71 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the ConcatenationSpacing sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_Strings_ConcatenationSpacingUnitTest 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 array( - 4 => 5, - 6 => 1, - 7 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Strings/DoubleQuoteUsageUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Strings/DoubleQuoteUsageUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Strings/DoubleQuoteUsageUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Strings/DoubleQuoteUsageUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -"; -$string = "Value: $var[test]"; -$string = "\0"; - -$x = "bar = '$z', -baz = '" . $a . "'...$x"; -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Strings/DoubleQuoteUsageUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Strings/DoubleQuoteUsageUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Strings/DoubleQuoteUsageUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Strings/DoubleQuoteUsageUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,76 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the DoubleQuoteUsage sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_Strings_DoubleQuoteUsageUnitTest 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 array( - 4 => 1, - 5 => 1, - 6 => 1, - 8 => 2, - 13 => 1, - 14 => 1, - 17 => 1, - 18 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Strings/EchoedStringsUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Strings/EchoedStringsUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Strings/EchoedStringsUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Strings/EchoedStringsUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ - \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Strings/EchoedStringsUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Strings/EchoedStringsUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Strings/EchoedStringsUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/Strings/EchoedStringsUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,72 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the EchoedStrings sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_Strings_EchoedStringsUnitTest 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 array( - 5 => 1, - 6 => 1, - 7 => 1, - 8 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/CastSpacingUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/CastSpacingUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/CastSpacingUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/CastSpacingUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,7 +0,0 @@ - \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/CastSpacingUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/CastSpacingUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/CastSpacingUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/CastSpacingUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,72 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the CastSpacing sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_WhiteSpace_CastSpacingUnitTest 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 array( - 3 => 1, - 4 => 1, - 5 => 1, - 6 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ControlStructureSpacingUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ControlStructureSpacingUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ControlStructureSpacingUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ControlStructureSpacingUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,125 +0,0 @@ - - - - - -
- children as $child) { - // There should be no error after this - // foreach, because it is followed by a - // close PHP tag. - } - ?> -
-children as $child) { - echo $child; - -} - -if ($defaultPageDesign === 0 - && $defaultCascade === TRUE - && $defaultChildDesign === 0 -) { - $settingsUpdated = FALSE; -} - -foreach ( $blah as $var ) { - if ( $blah ) { - } -} - -if ( - $defaultPageDesign === 0 - && $defaultCascade === TRUE - && $defaultChildDesign === 0 -) { - $settingsUpdated = FALSE; -} -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ControlStructureSpacingUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ControlStructureSpacingUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ControlStructureSpacingUnitTest.js 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ControlStructureSpacingUnitTest.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,86 +0,0 @@ - \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ControlStructureSpacingUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ControlStructureSpacingUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ControlStructureSpacingUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ControlStructureSpacingUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,106 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the ControlStructureSpacing sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_WhiteSpace_ControlStructureSpacingUnitTest 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='ControlStructureSpacingUnitTest.inc') - { - switch ($testFile) { - case 'ControlStructureSpacingUnitTest.inc': - return array( - 3 => 1, - 5 => 1, - 8 => 1, - 15 => 1, - 23 => 1, - 74 => 1, - 79 => 1, - 82 => 1, - 83 => 1, - 87 => 1, - 103 => 1, - 113 => 2, - 114 => 2, - 118 => 1, - ); - break; - case 'ControlStructureSpacingUnitTest.js': - return array( - 3 => 1, - 9 => 1, - 15 => 1, - 21 => 1, - 56 => 1, - 61 => 1, - 64 => 1, - 65 => 1, - 68 => 1, - 74 => 2, - 75 => 2, - ); - break; - default: - return array(); - break; - }//end switch - - }//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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionClosingBraceSpaceUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionClosingBraceSpaceUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionClosingBraceSpaceUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionClosingBraceSpaceUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionClosingBraceSpaceUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionClosingBraceSpaceUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionClosingBraceSpaceUnitTest.js 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionClosingBraceSpaceUnitTest.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,106 +0,0 @@ -function FuncOne() -{ - // Code here. - -}//end AdjustModalDialogWidgetType - - -Testing.prototype = { - - doSomething: function() - { - // Code here. - }, - - doSomethingElse: function() - { - // Code here. - - }, -}; - -function FuncFour() -{ - // Code here. -} - -function FuncFive() -{ - // Code here. - - -} - -function valid() -{ - if (true) { - test = { - namespaces: {} - }; - } - -} - -dfx.addEvent(this.rightScroll, 'mousedown', function() { - t = setInterval(function() { - pos -= 10; - }, 30); -}); - -// Valid because function is empty. -if (dfx.isFn(callback) === false) { - callback = function() {}; - callback = function() { }; -} - -AbstractAttributeEditorWidgetType.prototype = { - isActive: function() { - return this.active; - }, - - activate: function(data) - { - var x = { - test: function () { - alert('This is ok'); - - } - }; - - this.active = true; - - } - -}; - -var myFunc = function() -{ - var x = 1; - - blah(function() { - alert(2); - }); - - blah(function() { alert(2); }); - - return x; - -} - -CustomFormEditWidgetType.prototype = { - - addQuestion: function() - { - var settings = { - default: '' - }; - - }, - - addQuestionRulesEvent: function() - { - var self = this; - - } - -}; diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionClosingBraceSpaceUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionClosingBraceSpaceUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionClosingBraceSpaceUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionClosingBraceSpaceUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,90 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the FunctionClosingBraceSpace sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_WhiteSpace_FunctionClosingBraceSpaceUnitTest 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='FunctionClosingBraceSpaceUnitTest.inc') - { - switch ($testFile) { - case 'FunctionClosingBraceSpaceUnitTest.inc': - return array( - 10 => 1, - 21 => 1, - ); - break; - case 'FunctionClosingBraceSpaceUnitTest.js': - return array( - 13 => 1, - 25 => 1, - 32 => 1, - 53 => 1, - 59 => 1, - 67 => 1, - 84 => 1, - ); - break; - default: - return array(); - break; - }//end switch - - }//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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionOpeningBraceSpaceUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionOpeningBraceSpaceUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionOpeningBraceSpaceUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionOpeningBraceSpaceUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionOpeningBraceSpaceUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionOpeningBraceSpaceUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionOpeningBraceSpaceUnitTest.js 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionOpeningBraceSpaceUnitTest.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,112 +0,0 @@ -function FuncOne() -{ - // Code here. - -}//end AdjustModalDialogWidgetType - - -Testing.prototype = { - - doSomething: function() - { - - // Code here. - - }, - - doSomethingElse: function() - { - // Code here. - - }, - - start: function() - { - this.toolbarPlugin.addButton('Image', 'imageEditor', 'Insert/Edit Image', function () { self.editImage() }); - - }, -}; - -function FuncFour() -{ - - - // Code here. -} - -AbstractAttributeEditorWidgetType.prototype = { - isActive: function() { - return this.active; - - }, - - activate: function(data) - { - var x = { - test: function () { - alert('This is ok'); - } - }; - - this.active = true; - - } - -}; - -function test() { - var x = 1; - var y = function() - { - alert(1); - } - - return x; - -} - -var myFunc = function() -{ - var x = 1; - - blah(x, y, function() - { - alert(2); - }, z); - - blah(function() { alert(2); }); - - return x; - -} - -HelpWidgetType.prototype = { - init: function() { - var x = 1; - var y = { - test: function() { - alert(3); - } - } - return x; - - } -} - -CustomFormEditWidgetType.prototype = { - - addQuestion: function() - { - var settings = { - default: '' - }; - - }, - - addQuestionRulesEvent: function() - { - var self = this; - - } - -}; diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionOpeningBraceSpaceUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionOpeningBraceSpaceUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionOpeningBraceSpaceUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionOpeningBraceSpaceUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,91 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the FunctionOpeningBraceSpace sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_WhiteSpace_FunctionOpeningBraceSpaceUnitTest 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='FunctionOpeningBraceSpaceUnitTest.inc') - { - switch ($testFile) { - case 'FunctionOpeningBraceSpaceUnitTest.inc': - return array( - 10 => 1, - 25 => 1, - ); - break; - case 'FunctionOpeningBraceSpaceUnitTest.js': - return array( - 11 => 1, - 31 => 1, - 38 => 1, - 57 => 1, - 60 => 1, - 73 => 1, - 84 => 1, - ); - break; - default: - return array(); - break; - }//end switch - - - }//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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,201 +0,0 @@ - \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,85 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the FunctionSpacing sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_WhiteSpace_FunctionSpacingUnitTest 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 array( - 2 => 1, - 9 => 1, - 18 => 1, - 25 => 1, - 29 => 1, - 35 => 1, - 38 => 1, - 40 => 1, - 55 => 1, - 74 => 1, - 85 => 1, - 87 => 1, - 93 => 2, - 115 => 1, - 134 => 1, - 147 => 2, - 164 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,83 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the LanguageConstructSpacing sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_WhiteSpace_LanguageConstructSpacingUnitTest 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 array( - 3 => 1, - 4 => 1, - 7 => 1, - 8 => 1, - 11 => 1, - 12 => 1, - 15 => 1, - 16 => 1, - 19 => 1, - 20 => 1, - 23 => 1, - 24 => 1, - 27 => 1, - 31 => 1, - 32 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/LogicalOperatorSpacingUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/LogicalOperatorSpacingUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/LogicalOperatorSpacingUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/LogicalOperatorSpacingUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/LogicalOperatorSpacingUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/LogicalOperatorSpacingUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/LogicalOperatorSpacingUnitTest.js 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/LogicalOperatorSpacingUnitTest.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ - - -if (foo || bar) {} -if (foo||bar && baz) {} -if (foo|| bar&&baz) {} -if (foo || bar && baz) {} - -if (foo || - bar - && baz -) { -} - -if (foo|| - bar - &&baz -) { -} diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/LogicalOperatorSpacingUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/LogicalOperatorSpacingUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/LogicalOperatorSpacingUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/LogicalOperatorSpacingUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,73 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the LogicalOperatorSpacing sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_WhiteSpace_LogicalOperatorSpacingUnitTest 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='LogicalOperatorSpacingUnitTest.inc') - { - return array( - 4 => 2, - 5 => 3, - 6 => 3, - 14 => 1, - 16 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/MemberVarSpacingUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/MemberVarSpacingUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/MemberVarSpacingUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/MemberVarSpacingUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,110 +0,0 @@ - \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/MemberVarSpacingUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/MemberVarSpacingUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/MemberVarSpacingUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/MemberVarSpacingUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,77 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the MemberVarSpacing sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_WhiteSpace_MemberVarSpacingUnitTest 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 array( - 4 => 1, - 7 => 1, - 20 => 1, - 30 => 1, - 35 => 1, - 44 => 1, - 50 => 1, - 73 => 1, - 86 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ObjectOperatorSpacingUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ObjectOperatorSpacingUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ObjectOperatorSpacingUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ObjectOperatorSpacingUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,7 +0,0 @@ -testThis(); -$this-> testThis(); -$this -> testThis(); -$this->/* comment here */testThis(); -$this/* comment here */ -> testThis(); -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ObjectOperatorSpacingUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ObjectOperatorSpacingUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ObjectOperatorSpacingUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ObjectOperatorSpacingUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,72 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the ObjectOperatorSpacing sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_WhiteSpace_ObjectOperatorSpacingUnitTest 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 array( - 3 => 1, - 4 => 2, - 5 => 1, - 6 => 2, - ); - - }//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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,107 +0,0 @@ - $j && $k< $l && $m>= $n && $o<= $p && $q<> $r; - -$a ==$b && $c !=$d && $e ===$f && $g !==$h; -$i >$j && $k <$l && $m >=$n && $o <=$p && $q <>$r; - -function myFunction($variable=0, $var2='string') {} - -if (index > -1) { -} - -array_walk_recursive($array, function(&$item) use (&$something) { -}); - -$var = saveFile(&$model, &$foo); - -// This is all valid. -$boo = -$foo; -function foo($boo = -1) {} -$foo = array('boo' => -1); -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.js 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ - - -result = 1 + 2; -result = 1 + 2; -result = 1 + 2; -result = 1 +2; -result = 1+ 2; -result = 1+2; - -result = 1 - 2; -result = 1 - 2; -result = 1 - 2; -result = 1 -2; -result = 1- 2; -result = 1-2; - -result = 1 * 2; -result = 1 * 2; -result = 1 * 2; -result = 1 *2; -result = 1* 2; -result = 1*2; - -result = 1 / 2; -result = 1 / 2; -result = 1 / 2; -result = 1 /2; -result = 1/ 2; -result = 1/2; - -result = 1 % 2; -result = 1 % 2; -result = 1 % 2; -result = 1 %2; -result = 1% 2; -result = 1%2; -result = '100%'; - -result += 4; -result+=4; -result -= 4; -result-=4; -result /= 4; -result/=4; -result *=4; -result*=4; - -$.localScroll({offset: {top: -32}}); diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,156 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the OperatorSpacing sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_WhiteSpace_OperatorSpacingUnitTest 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='OperatorSpacingUnitTest.inc') - { - switch ($testFile) { - case 'OperatorSpacingUnitTest.inc': - return array( - 4 => 1, - 5 => 2, - 6 => 1, - 7 => 1, - 8 => 2, - 11 => 1, - 12 => 2, - 13 => 1, - 14 => 1, - 15 => 2, - 18 => 1, - 19 => 2, - 20 => 1, - 21 => 1, - 22 => 2, - 25 => 1, - 26 => 2, - 27 => 1, - 28 => 1, - 29 => 2, - 32 => 1, - 33 => 2, - 34 => 1, - 35 => 1, - 36 => 2, - 40 => 2, - 42 => 2, - 44 => 2, - 45 => 1, - 46 => 2, - 53 => 2, - 54 => 1, - 59 => 10, - 64 => 1, - 77 => 4, - 78 => 1, - 79 => 1, - 80 => 2, - 81 => 1, - 84 => 6, - 85 => 6, - 87 => 4, - 88 => 5, - 90 => 4, - 91 => 5, - ); - break; - case 'OperatorSpacingUnitTest.js': - return array( - 4 => 1, - 5 => 2, - 6 => 1, - 7 => 1, - 8 => 2, - 11 => 1, - 12 => 2, - 13 => 1, - 14 => 1, - 15 => 2, - 18 => 1, - 19 => 2, - 20 => 1, - 21 => 1, - 22 => 2, - 25 => 1, - 26 => 2, - 27 => 1, - 28 => 1, - 29 => 2, - 32 => 1, - 33 => 2, - 34 => 1, - 35 => 1, - 36 => 2, - 40 => 2, - 42 => 2, - 44 => 2, - 45 => 1, - 46 => 2, - ); - break; - default: - return array(); - break; - }//end switch - - }//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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/PropertyLabelSpacingUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/PropertyLabelSpacingUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/PropertyLabelSpacingUnitTest.js 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/PropertyLabelSpacingUnitTest.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -var x = { - b: 'x', - xasd: x, - a: function () { - alert('thats right'); - x = (x?a:x); - }, - casdasd : 123123, - omgwtfbbq: { - a: 1, - b: 2 - } -}; - -id = id.replace(/row\/:/gi, ''); - -outer_loop: -for (i=0; i<3; i++) { - for (j=0; j<5; j++) { - if (j==x) - break outer_loop; - } -} -alert('hi'); - -even_number: if ((i % 2) == 0) { - if (i == 12) - break even_number; -} - -switch (blah) { - case dfx.DOM_VK_LEFT: - this.caretLeft(shiftKey); - break; - default: - if (blah) { - } - break; -} \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/PropertyLabelSpacingUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/PropertyLabelSpacingUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/PropertyLabelSpacingUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/PropertyLabelSpacingUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,73 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the PropertyLabel sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_WhiteSpace_PropertyLabelSpacingUnitTest 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 array( - 2 => 1, - 8 => 2, - 9 => 1, - 11 => 1, - 17 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ScopeClosingBraceUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ScopeClosingBraceUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ScopeClosingBraceUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ScopeClosingBraceUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,56 +0,0 @@ -{$property} =& new $class_name($this->db_index); - $this->modules[$module] =& $this->{$property}; -} - -foreach ($elements as $element) { - if ($something) { - // Do IF. - } else if ($somethingElse) { - // Do ELSE. - } -} - -switch ($blah) { - case 'one': - echo 'one'; - break; - default: - echo 'another'; -} - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ScopeClosingBraceUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ScopeClosingBraceUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ScopeClosingBraceUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ScopeClosingBraceUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,71 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the ScopeClosingBrace sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_WhiteSpace_ScopeClosingBraceUnitTest 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 array( - 11 => 1, - 13 => 1, - 24 => 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ - \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,74 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the ScopeKeywordSpacing sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_WhiteSpace_ScopeKeywordSpacingUnitTest 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 array( - 7 => 2, - 8 => 1, - 13 => 1, - 14 => 1, - 15 => 1, - 17 => 2, - ); - - }//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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -testThis(); -$test = $this->testThis() ; -$test = $this->testThis() ; -for ($var = 1 ; $var < 10 ; $var++) { - echo $var ; -} -$test = $this->testThis() /* comment here */; -$test = $this->testThis() /* comment here */ ; -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.js 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -var x = { - a: function () { - alert('thats right') ; - x = (x?a:x) ; - }, -} ; - -id = id.replace(/row\/:;/gi, ''); - -for (i=0 ; i<3 ; i++) { - for (j=0; j<5 ; j++) { - if (j==x) - break ; - } -} -alert('hi'); \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,93 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the SemicolonSpacing sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_WhiteSpace_SemicolonSpacingUnitTest 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='SemicolonSpacingUnitTest.inc') - { - switch ($testFile) { - case 'SemicolonSpacingUnitTest.inc': - return array( - 3 => 1, - 4 => 1, - 5 => 2, - 6 => 1, - 8 => 1, - 9 => 1, - ); - break; - case 'SemicolonSpacingUnitTest.js': - return array( - 3 => 1, - 4 => 1, - 6 => 1, - 10 => 2, - 11 => 1, - 13 => 1, - ); - break; - default: - return array(); - break; - }//end switch - - }//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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.css php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.css --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.css 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.css 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ - -.HelpWidgetType-new-bug-title { - float: left; -} -.HelpWidgetType-new-bug-title { - float: left; -} -.HelpWidgetType-new-bug-title { - float: left; -} -.HelpWidgetType-new-bug-title{ - float: left; -} - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ - - - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.js 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ - -alert('hi'); -alert('hello'); - -if (something) { - -} - - -function myFunction() -{ - alert('code here'); - - alert('code here'); - - - // Hello. - - /* - HI - */ - - -} - -function myFunction2() -{ - alert('code here'); - - - alert('code here'); - -} - - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,107 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the SuperfluousWhitespace sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Squiz_Tests_WhiteSpace_SuperfluousWhitespaceUnitTest 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='SuperfluousWhitespaceUnitTest.inc') - { - switch ($testFile) { - case 'SuperfluousWhitespaceUnitTest.inc': - return array( - 2 => 1, - 4 => 1, - 5 => 1, - 6 => 1, - 7 => 1, - 16 => 1, - 23 => 1, - 30 => 1, - 36 => 1, - ); - break; - case 'SuperfluousWhitespaceUnitTest.js': - return array( - 1 => 1, - 3 => 1, - 4 => 1, - 5 => 1, - 6 => 1, - 15 => 1, - 22 => 1, - 29 => 1, - 35 => 1, - ); - break; - case 'SuperfluousWhitespaceUnitTest.css': - return array( - 1 => 1, - 8 => 1, - 9 => 1, - 14 => 1, - ); - break; - default: - return array(); - break; - }//end switch - - }//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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/ruleset.xml php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/ruleset.xml --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/ruleset.xml 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Squiz/ruleset.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,73 +0,0 @@ - - - The Squiz coding standard. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - %2$s - - - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Zend/Sniffs/Debug/CodeAnalyzerSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Zend/Sniffs/Debug/CodeAnalyzerSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Zend/Sniffs/Debug/CodeAnalyzerSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Zend/Sniffs/Debug/CodeAnalyzerSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,125 +0,0 @@ - - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Zend_Sniffs_Debug_CodeAnalyzerSniff. - * - * Runs the Zend Code Analyzer (from Zend Studio) on the file. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Holger Kral - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Zend_Sniffs_Debug_CodeAnalyzerSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * Returns the token types that this sniff is interested in. - * - * @return array(int) - */ - public function register() - { - return array(T_OPEN_TAG); - - }//end 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. - * - * @return void - */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) - { - // Because we are analyzing the whole file in one step, execute this method - // only on first occurence of a T_OPEN_TAG. - $prevOpenTag = $phpcsFile->findPrevious(T_OPEN_TAG, ($stackPtr - 1)); - if ($prevOpenTag !== false) { - return; - } - - $fileName = $phpcsFile->getFilename(); - - $analyzerPath = PHP_CodeSniffer::getConfigData('zend_ca_path'); - if (is_null($analyzerPath) === true) { - return; - } - - // 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 = $analyzerPath.' '.$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); - - // $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 PHP_CodeSniffer_Exception("Failed invoking ZendCodeAnalyzer, exitcode was [$exitCode], retval was [$retval], output was [$msg]"); - } - - if (is_array($output) === true) { - $tokens = $phpcsFile->getTokens(); - - foreach ($output as $finding) { - // The first two lines of analyzer output contain - // something like this: - // > Zend Code Analyzer 1.2.2 - // > Analyzing ... - // So skip these... - $res = preg_match("/^.+\(line ([0-9]+)\):(.+)$/", $finding, $regs); - if (empty($regs) === true || $res === false) { - continue; - } - - // Find the token at the start of the line. - $lineToken = null; - foreach ($tokens as $ptr => $info) { - if ($info['line'] == $regs[1]) { - $lineToken = $ptr; - break; - } - } - - if ($lineToken !== null) { - $phpcsFile->addWarning(trim($regs[2]), $ptr, 'ExternalTool'); - } - }//end foreach - }//end if - - }//end process() - -}//end class -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Zend/Sniffs/Files/ClosingTagSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Zend/Sniffs/Files/ClosingTagSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Zend/Sniffs/Files/ClosingTagSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Zend/Sniffs/Files/ClosingTagSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,84 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Zend_Sniffs_Files_LineEndingsSniff. - * - * Checks that the file does not end with a closing tag. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Zend_Sniffs_Files_ClosingTagSniff implements PHP_CodeSniffer_Sniff -{ - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array(T_CLOSE_TAG); - - }//end register() - - - /** - * Processes this sniff, 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(); - - $next = $phpcsFile->findNext(T_INLINE_HTML, ($stackPtr + 1), null, true); - if ($next !== false) { - return; - } - - // We've found the last closing tag in the file so the only thing - // potentially remaining is inline HTML. Now we need to figure out - // whether or not it's just a bunch of whitespace. - $content = ''; - for ($i = ($stackPtr + 1); $i < $phpcsFile->numTokens; $i++) { - $content .= $tokens[$i]['content']; - } - - // Check if the remaining inline HTML is just whitespace. - $content = trim($content); - if (empty($content) === true) { - $error = 'A closing tag is not permitted at the end of a PHP file'; - $phpcsFile->addError($error, $stackPtr, 'NotAllowed'); - } - - }//end process() - - -}//end class - -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Zend/Sniffs/NamingConventions/ValidVariableNameSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Zend/Sniffs/NamingConventions/ValidVariableNameSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Zend/Sniffs/NamingConventions/ValidVariableNameSniff.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Zend/Sniffs/NamingConventions/ValidVariableNameSniff.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,252 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -if (class_exists('PHP_CodeSniffer_Standards_AbstractVariableSniff', true) === false) { - throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_Standards_AbstractVariableSniff not found'); -} - -/** - * Squiz_Sniffs_NamingConventions_ValidVariableNameSniff. - * - * Checks the naming of variables and member variables. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Zend_Sniffs_NamingConventions_ValidVariableNameSniff extends PHP_CodeSniffer_Standards_AbstractVariableSniff -{ - - /** - * Tokens to ignore so that we can find a DOUBLE_COLON. - * - * @var array - */ - private $_ignore = array( - T_WHITESPACE, - T_COMMENT, - ); - - - /** - * 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 - */ - protected function processVariable(PHP_CodeSniffer_File $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - $varName = ltrim($tokens[$stackPtr]['content'], '$'); - - $phpReservedVars = array( - '_SERVER', - '_GET', - '_POST', - '_REQUEST', - '_SESSION', - '_ENV', - '_COOKIE', - '_FILES', - 'GLOBALS', - ); - - // If it's a php reserved var, then its ok. - if (in_array($varName, $phpReservedVars) === true) { - return; - } - - $objOperator = $phpcsFile->findNext(array(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(array(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(array(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 (PHP_CodeSniffer::isCamelCaps($objVarName, false, true, false) === false) { - $error = 'Variable "%s" is not in valid camel caps format'; - $data = array($originalVarName); - $phpcsFile->addError($error, $var, 'NotCamelCaps', $data); - } else if (preg_match('|\d|', $objVarName)) { - $warning = 'Variable "%s" contains numbers but this is discouraged'; - $data = array($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(array(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, array(T_CLASS, T_INTERFACE)); - } - - if ($inClass === true) { - $varName = substr($varName, 1); - } - } - - if (PHP_CodeSniffer::isCamelCaps($varName, false, true, false) === false) { - $error = 'Variable "%s" is not in valid camel caps format'; - $data = array($originalVarName); - $phpcsFile->addError($error, $stackPtr, 'NotCamelCaps', $data); - } else if (preg_match('|\d|', $varName)) { - $warning = 'Variable "%s" contains numbers but this is discouraged'; - $data = array($originalVarName); - $phpcsFile->addWarning($warning, $stackPtr, 'ContainsNumbers', $data); - } - - }//end processVariable() - - - /** - * Processes class member variables. - * - * @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 - */ - protected function processMemberVar(PHP_CodeSniffer_File $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - $varName = ltrim($tokens[$stackPtr]['content'], '$'); - $memberProps = $phpcsFile->getMemberProperties($stackPtr); - $public = ($memberProps['scope'] === 'public'); - - if ($public === true) { - if (substr($varName, 0, 1) === '_') { - $error = 'Public member variable "%s" must not contain a leading underscore'; - $data = array($varName); - $phpcsFile->addError($error, $stackPtr, 'PublicHasUnderscore', $data); - return; - } - } else { - if (substr($varName, 0, 1) !== '_') { - $scope = ucfirst($memberProps['scope']); - $error = '%s member variable "%s" must contain a leading underscore'; - $data = array( - $scope, - $varName, - ); - $phpcsFile->addError($error, $stackPtr, 'PrivateNoUnderscore', $data); - return; - } - } - - if (PHP_CodeSniffer::isCamelCaps($varName, false, $public, false) === false) { - $error = 'Variable "%s" is not in valid camel caps format'; - $data = array($varName); - $phpcsFile->addError($error, $stackPtr, 'MemberVarNotCamelCaps', $data); - } else if (preg_match('|\d|', $varName)) { - $warning = 'Variable "%s" contains numbers but this is discouraged'; - $data = array($varName); - $phpcsFile->addWarning($warning, $stackPtr, 'MemberVarContainsNumbers', $data); - } - - }//end processMemberVar() - - - /** - * Processes the variable found within a double quoted string. - * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the double quoted - * string. - * - * @return void - */ - protected function processVariableInString(PHP_CodeSniffer_File $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - - $phpReservedVars = array( - '_SERVER', - '_GET', - '_POST', - '_REQUEST', - '_SESSION', - '_ENV', - '_COOKIE', - '_FILES', - 'GLOBALS', - ); - - 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; - } - - // 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) === '_') { - if ($phpcsFile->hasCondition($stackPtr, array(T_CLASS, T_INTERFACE)) === true) { - $varName = substr($varName, 1); - } - } - - if (PHP_CodeSniffer::isCamelCaps($varName, false, true, false) === false) { - $varName = $matches[0]; - $error = 'Variable "%s" is not in valid camel caps format'; - $data = array($originalVarName); - $phpcsFile->addError($error, $stackPtr, 'StringVarNotCamelCaps', $data); - } else if (preg_match('|\d|', $varName)) { - $warning = 'Variable "%s" contains numbers but this is discouraged'; - $data = array($originalVarName); - $phpcsFile->addWarning($warning, $stackPtr, 'StringVarContainsNumbers', $data); - } - } - }//end if - - }//end processVariableInString() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Zend/Tests/Debug/CodeAnalyzerUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Zend/Tests/Debug/CodeAnalyzerUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Zend/Tests/Debug/CodeAnalyzerUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Zend/Tests/Debug/CodeAnalyzerUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,6 +0,0 @@ - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Zend/Tests/Debug/CodeAnalyzerUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Zend/Tests/Debug/CodeAnalyzerUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Zend/Tests/Debug/CodeAnalyzerUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Zend/Tests/Debug/CodeAnalyzerUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,82 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the CodeAnalyzer sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Zend_Tests_Debug_CodeAnalyzerUnitTest extends AbstractSniffUnitTest -{ - - - /** - * Should this test be skipped for some reason. - * - * @return void - */ - protected function shouldSkipTest() - { - $analyzerPath = PHP_CodeSniffer::getConfigData('zend_ca_path'); - 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 array(); - - }//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 array( - 2 => 1, - ); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Zend/Tests/Files/ClosingTagUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Zend/Tests/Files/ClosingTagUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Zend/Tests/Files/ClosingTagUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Zend/Tests/Files/ClosingTagUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ - - - - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Zend/Tests/Files/ClosingTagUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Zend/Tests/Files/ClosingTagUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Zend/Tests/Files/ClosingTagUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Zend/Tests/Files/ClosingTagUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,69 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the ClosingTag sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Zend_Tests_Files_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. - * - * @return array(int => int) - */ - public function getErrorList() - { - return array( - 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 array(); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Zend/Tests/NamingConventions/ValidVariableNameUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Zend/Tests/NamingConventions/ValidVariableNameUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Zend/Tests/NamingConventions/ValidVariableNameUnitTest.inc 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Zend/Tests/NamingConventions/ValidVariableNameUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 @@ -1,100 +0,0 @@ -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); -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Zend/Tests/NamingConventions/ValidVariableNameUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Zend/Tests/NamingConventions/ValidVariableNameUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Zend/Tests/NamingConventions/ValidVariableNameUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Zend/Tests/NamingConventions/ValidVariableNameUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,111 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Unit test class for the ValidVariableName sniff. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings are stored in this class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Zend_Tests_NamingConventions_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 array( - 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, - 90 => 1, - 92 => 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 array( - 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, - ); - - }//end getWarningList() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Zend/ruleset.xml php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Zend/ruleset.xml --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Zend/ruleset.xml 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Zend/ruleset.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ - - - A coding standard based on an early Zend Framework coding standard. Note that this standard is out of date. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Tokenizers/CSS.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Tokenizers/CSS.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Tokenizers/CSS.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Tokenizers/CSS.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,509 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -if (class_exists('PHP_CodeSniffer_Tokenizers_PHP', true) === false) { - throw new Exception('Class PHP_CodeSniffer_Tokenizers_PHP not found'); -} - -/** - * Tokenizes CSS code. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PHP_CodeSniffer_Tokenizers_CSS extends PHP_CodeSniffer_Tokenizers_PHP -{ - - - /** - * Creates an array of tokens when given some CSS code. - * - * Uses the PHP tokenizer to do all the tricky work - * - * @param string $string The string to tokenize. - * @param string $eolChar The EOL character to use for splitting strings. - * - * @return array - */ - public function tokenizeString($string, $eolChar='\n') - { - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t*** START CSS TOKENIZING ***".PHP_EOL; - } - - $tokens = parent::tokenizeString('', $eolChar); - $finalTokens = array(); - - $newStackPtr = 0; - $numTokens = count($tokens); - $multiLineComment = false; - for ($stackPtr = 0; $stackPtr < $numTokens; $stackPtr++) { - $token = $tokens[$stackPtr]; - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $type = $token['type']; - $content = str_replace($eolChar, '\n', $token['content']); - echo "\tProcess token $stackPtr: $type => $content".PHP_EOL; - } - - // Sometimes, there are PHP tags embedded in the code, which causes issues - // with how PHP tokenizeses the string. After the first closing tag is found, - // everything outside PHP tags is set as inline HTML tokens (1 for each line). - // So we need to go through and find these tokens so we can re-tokenize them. - if ($token['code'] === T_CLOSE_TAG && $stackPtr !== ($numTokens - 1)) { - $content = ''; - } - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t\t=> Found premature closing tag at $stackPtr".PHP_EOL; - $cleanContent = str_replace($eolChar, '\n', $content); - echo "\t\tcontent: $cleanContent".PHP_EOL; - $oldNumTokens = $numTokens; - } - - // Tokenize the string and remove the extra PHP tags we dont need. - $moreTokens = parent::tokenizeString($content, $eolChar); - array_shift($moreTokens); - array_pop($moreTokens); - array_pop($moreTokens); - - // Rebuild the tokens array. - array_splice($tokens, ($stackPtr + 1), ($x - $stackPtr), $moreTokens); - $numTokens = count($tokens); - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $count = count($moreTokens); - $diff = ($x - $stackPtr); - echo "\t\t* added $count tokens, replaced $diff; size changed from $oldNumTokens to $numTokens *".PHP_EOL; - } - }//end if - - if ($token['code'] === T_FUNCTION) { - // There are no functions in CSS, so convert this to a string. - $finalTokens[$newStackPtr] = array( - 'type' => 'T_STRING', - 'code' => T_STRING, - 'content' => $token['content'], - ); - - $newStackPtr++; - continue; - } - - if ($token['code'] === T_COMMENT - && substr($token['content'], 0, 2) === '/*' - ) { - // Multi-line comment. Record it so we can ignore other - // comment tags until we get out of this one. - $multiLineComment = true; - } - - if ($token['code'] === T_COMMENT - && $multiLineComment === false - && (substr($token['content'], 0, 2) === '//' - || $token['content']{0} === '#') - ) { - $content = ltrim($token['content'], '#/'); - $commentTokens - = parent::tokenizeString('', $eolChar); - - // The first and last tokens are the open/close tags. - array_shift($commentTokens); - array_pop($commentTokens); - - if ($token['content']{0} === '#') { - // The # character is not a comment in CSS files, so - // determine what it means in this context. - $firstContent = $commentTokens[0]['content']; - - // If the first content is just a number, it is probably a - // colour like 8FB7DB, which PHP splits into 8 and FB7DB. - if (($commentTokens[0]['code'] === T_LNUMBER - || $commentTokens[0]['code'] === T_DNUMBER) - && $commentTokens[1]['code'] === T_STRING - ) { - $firstContent .= $commentTokens[1]['content']; - array_shift($commentTokens); - } - - // If the first content looks like a colour and not a class - // definition, join the tokens together. - if (preg_match('/^[ABCDEF0-9]+$/i', $firstContent) === 1) { - array_shift($commentTokens); - // Work out what we trimmed off above and remember to re-add it. - $trimmed = substr($token['content'], 0, (strlen($token['content']) - strlen($content))); - $finalTokens[$newStackPtr] = array( - 'type' => 'T_COLOUR', - 'code' => T_COLOUR, - 'content' => $trimmed.$firstContent, - ); - } else { - $finalTokens[$newStackPtr] = array( - 'type' => 'T_HASH', - 'code' => T_HASH, - 'content' => '#', - ); - } - } else { - $finalTokens[$newStackPtr] = array( - 'type' => 'T_STRING', - 'code' => T_STRING, - 'content' => '//', - ); - }//end if - - $newStackPtr++; - - foreach ($commentTokens as $tokenData) { - if ($tokenData['code'] === T_COMMENT - && (substr($tokenData['content'], 0, 2) === '//' - || $tokenData['content']{0} === '#') - ) { - // This is a comment in a comment, so it needs - // to go through the whole process again. - $tokens[$stackPtr]['content'] = $tokenData['content']; - $stackPtr--; - break; - } - - $finalTokens[$newStackPtr] = $tokenData; - $newStackPtr++; - } - - continue; - }//end if - - if ($token['code'] === T_COMMENT - && substr($token['content'], -2) === '*/' - ) { - // Multi-line comment is done. - $multiLineComment = false; - } - - $finalTokens[$newStackPtr] = $token; - $newStackPtr++; - }//end for - - // A flag to indicate if we are inside a style definition, - // which is defined using curly braces. I'm assuming you can't - // have nested curly brackets. - $inStyleDef = false; - - $numTokens = count($finalTokens); - for ($stackPtr = 0; $stackPtr < $numTokens; $stackPtr++) { - $token = $finalTokens[$stackPtr]; - - switch ($token['code']) { - case T_OPEN_CURLY_BRACKET: - $inStyleDef = true; - break; - case T_CLOSE_CURLY_BRACKET: - $inStyleDef = false; - break; - case T_MINUS: - // Minus signs are often used instead of spaces inside - // class names, IDs and styles. - if ($finalTokens[($stackPtr + 1)]['code'] === T_STRING) { - if ($finalTokens[($stackPtr - 1)]['code'] === T_STRING) { - $newContent = $finalTokens[($stackPtr - 1)]['content'].'-'.$finalTokens[($stackPtr + 1)]['content']; - - $finalTokens[($stackPtr - 1)]['content'] = $newContent; - unset($finalTokens[$stackPtr]); - unset($finalTokens[($stackPtr + 1)]); - $stackPtr -= 2; - } else { - $newContent = '-'.$finalTokens[($stackPtr + 1)]['content']; - - $finalTokens[($stackPtr + 1)]['content'] = $newContent; - unset($finalTokens[$stackPtr]); - $stackPtr--; - } - - $finalTokens = array_values($finalTokens); - $numTokens = count($finalTokens); - } else if ($finalTokens[($stackPtr + 1)]['code'] === T_LNUMBER) { - // They can also be used to provide negative numbers. - $finalTokens[($stackPtr + 1)]['content'] - = '-'.$finalTokens[($stackPtr + 1)]['content']; - unset($finalTokens[$stackPtr]); - - $finalTokens = array_values($finalTokens); - $numTokens = count($finalTokens); - } - - break; - case T_COLON: - // Only interested in colons that are defining styles. - if ($inStyleDef === false) { - break; - } - - for ($x = ($stackPtr - 1); $x >= 0; $x--) { - if (in_array($finalTokens[$x]['code'], PHP_CodeSniffer_Tokens::$emptyTokens) === false) { - break; - } - } - - $finalTokens[$x]['type'] = 'T_STYLE'; - $finalTokens[$x]['code'] = T_STYLE; - break; - case T_STRING: - if (strtolower($token['content']) === 'url') { - // Find the next content. - for ($x = ($stackPtr + 1); $x < $numTokens; $x++) { - if (in_array($finalTokens[$x]['code'], PHP_CodeSniffer_Tokens::$emptyTokens) === false) { - break; - } - } - - // Needs to be in the format "url(" for it to be a URL. - if ($finalTokens[$x]['code'] !== T_OPEN_PARENTHESIS) { - continue; - } - - // Make sure the content isn't empty. - for ($y = ($x + 1); $y < $numTokens; $y++) { - if (in_array($finalTokens[$y]['code'], PHP_CodeSniffer_Tokens::$emptyTokens) === false) { - break; - } - } - - if ($finalTokens[$y]['code'] === T_CLOSE_PARENTHESIS) { - continue; - } - - // Join all the content together inside the url() statement. - $newContent = ''; - for ($i = ($x + 2); $i < $numTokens; $i++) { - if ($finalTokens[$i]['code'] === T_CLOSE_PARENTHESIS) { - break; - } - - $newContent .= $finalTokens[$i]['content']; - unset($finalTokens[$i]); - } - - // If the content inside the "url()" is in double quotes - // there will only be one token and so we don't have to do - // anything except change its type. If it is not empty, - // we need to do some token merging. - $finalTokens[($x + 1)]['type'] = 'T_URL'; - $finalTokens[($x + 1)]['code'] = T_URL; - - if ($newContent !== '') { - $finalTokens[($x + 1)]['content'] .= $newContent; - - $finalTokens = array_values($finalTokens); - $numTokens = count($finalTokens); - } - }//end if - - break; - default: - // Nothing special to be done with this token. - break; - }//end switch - }//end for - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t*** END CSS TOKENIZING ***".PHP_EOL; - } - - return $finalTokens; - - }//end tokenizeString() - - - /** - * Performs additional processing after main tokenizing. - * - * This additional processsing converts T_LIST tokens to T_STRING - * because there are no list constructs in CSS and list-* styles - * look like lists to the PHP tokenizer. - * - * @param array &$tokens The array of tokens to process. - * @param string $eolChar The EOL character to use for splitting strings. - * - * @return void - */ - public function processAdditional(&$tokens, $eolChar) - { - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t*** START ADDITIONAL CSS PROCESSING ***".PHP_EOL; - } - - $numTokens = (count($tokens) - 1); - $changeMade = false; - - for ($i = 0; $i < $numTokens; $i++) { - if ($tokens[($i + 1)]['code'] !== T_STYLE) { - continue; - } - - $style = ($i + 1); - - if ($tokens[$i]['code'] === T_LIST) { - $tokens[$style]['content'] = $tokens[$i]['content'].$tokens[$style]['content']; - $tokens[$style]['column'] = $tokens[$i]['column']; - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $line = $tokens[$i]['line']; - echo "\t* T_LIST token $i on line $line merged into T_STYLE token $style *".PHP_EOL; - } - - // Now fix the brackets that surround this token as they will - // be pointing too far ahead now that we have removed a token. - for ($t = $i; $t >= 0; $t--) { - if (isset($tokens[$t]['bracket_closer']) === true) { - $old = $tokens[$t]['bracket_closer']; - $tokens[$t]['bracket_closer']--; - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $new = $tokens[$t]['bracket_closer']; - $type = $tokens[$t]['type']; - $line = $tokens[$t]['line']; - echo "\t\t* $type token $t on line $line closer changed from $old to $new *".PHP_EOL; - } - - // Only need to fix one set of brackets. - break; - } - } - - // Now fix all future brackets as they are no longer pointing - // to the correct tokens either. - for ($t = $i; $t <= $numTokens; $t++) { - if (isset($tokens[$t]) === false) { - break; - } - - if ($tokens[$t]['code'] === T_OPEN_CURLY_BRACKET) { - $old = $tokens[$t]['bracket_closer']; - $tokens[$t]['bracket_closer']--; - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $new = $tokens[$t]['bracket_closer']; - $type = $tokens[$t]['type']; - $line = $tokens[$t]['line']; - echo "\t\t* $type token $t on line $line closer changed from $old to $new *".PHP_EOL; - } - - $t = $old; - } - } - - unset($tokens[$i]); - $changeMade = true; - $i++; - } else if ($tokens[$i]['code'] === T_BREAK) { - // Break is sometimes used in style definitions, like page-break-inside - // so we need merge the elements around it into the next T_STYLE. - $newStyle = 'break'.$tokens[$style]['content']; - for ($x = ($i - 1); $x >= 0; $x--) { - if ($tokens[$x]['code'] !== T_STRING && $tokens[$x]['code'] !== T_MINUS) { - break; - } - - $newStyle = $tokens[$x]['content'].$newStyle; - } - - $x++; - $tokens[$style]['content'] = $newStyle; - $tokens[$style]['column'] = $tokens[$x]['column']; - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $line = $tokens[$i]['line']; - echo "\t* tokens $x - $i on line $line merged into T_STYLE token $style due to T_BREAK at token $i *".PHP_EOL; - } - - // Now fix the brackets that surround this token as they will - // be pointing too far ahead now that we have removed tokens. - $diff = ($style - $x); - for ($t = $style; $t >= 0; $t--) { - if (isset($tokens[$t]['bracket_closer']) === true) { - $old = $tokens[$t]['bracket_closer']; - $tokens[$t]['bracket_closer'] -= $diff; - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $new = $tokens[$t]['bracket_closer']; - $type = $tokens[$t]['type']; - $line = $tokens[$t]['line']; - echo "\t\t* $type token $t on line $line closer changed from $old to $new *".PHP_EOL; - } - - // Only need to fix one set of brackets. - break; - } - } - - // Now fix all future brackets as they are no longer pointing - // to the correct tokens either. - for ($t = $style; $t <= $numTokens; $t++) { - if (isset($tokens[$t]) === false) { - break; - } - - if ($tokens[$t]['code'] === T_OPEN_CURLY_BRACKET) { - $old = $tokens[$t]['bracket_closer']; - $tokens[$t]['bracket_closer'] -= $diff; - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $new = $tokens[$t]['bracket_closer']; - $type = $tokens[$t]['type']; - $line = $tokens[$t]['line']; - echo "\t\t* $type token $t on line $line closer changed from $old to $new *".PHP_EOL; - } - - $t = $old; - } - } - - for ($x; $x <= $i; $x++) { - unset($tokens[$x]); - } - - $changeMade = true; - $i++; - }//end if - }//end for - - if ($changeMade === true) { - $tokens = array_values($tokens); - } - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t*** END ADDITIONAL CSS PROCESSING ***".PHP_EOL; - } - - }//end processAdditional() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Tokenizers/JS.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Tokenizers/JS.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Tokenizers/JS.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Tokenizers/JS.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,1124 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Tokenizes JS code. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PHP_CodeSniffer_Tokenizers_JS -{ - - /** - * A list of tokens that are allowed to open a scope. - * - * This array also contains information about what kind of token the scope - * opener uses to open and close the scope, if the token strictly requires - * an opener, if the token can share a scope closer, and who it can be shared - * with. An example of a token that shares a scope closer is a CASE scope. - * - * @var array - */ - public $scopeOpeners = array( - T_IF => array( - 'start' => array(T_OPEN_CURLY_BRACKET), - 'end' => array(T_CLOSE_CURLY_BRACKET), - 'strict' => false, - 'shared' => false, - 'with' => array(), - ), - T_TRY => array( - 'start' => array(T_OPEN_CURLY_BRACKET), - 'end' => array(T_CLOSE_CURLY_BRACKET), - 'strict' => true, - 'shared' => false, - 'with' => array(), - ), - T_CATCH => array( - 'start' => array(T_OPEN_CURLY_BRACKET), - 'end' => array(T_CLOSE_CURLY_BRACKET), - 'strict' => true, - 'shared' => false, - 'with' => array(), - ), - T_ELSE => array( - 'start' => array(T_OPEN_CURLY_BRACKET), - 'end' => array(T_CLOSE_CURLY_BRACKET), - 'strict' => false, - 'shared' => false, - 'with' => array(), - ), - T_FOR => array( - 'start' => array(T_OPEN_CURLY_BRACKET), - 'end' => array(T_CLOSE_CURLY_BRACKET), - 'strict' => false, - 'shared' => false, - 'with' => array(), - ), - T_FUNCTION => array( - 'start' => array(T_OPEN_CURLY_BRACKET), - 'end' => array(T_CLOSE_CURLY_BRACKET), - 'strict' => false, - 'shared' => false, - 'with' => array(), - ), - T_WHILE => array( - 'start' => array(T_OPEN_CURLY_BRACKET), - 'end' => array(T_CLOSE_CURLY_BRACKET), - 'strict' => false, - 'shared' => false, - 'with' => array(), - ), - T_DO => array( - 'start' => array(T_OPEN_CURLY_BRACKET), - 'end' => array(T_CLOSE_CURLY_BRACKET), - 'strict' => true, - 'shared' => false, - 'with' => array(), - ), - T_SWITCH => array( - 'start' => array(T_OPEN_CURLY_BRACKET), - 'end' => array(T_CLOSE_CURLY_BRACKET), - 'strict' => true, - 'shared' => false, - 'with' => array(), - ), - T_CASE => array( - 'start' => array(T_COLON), - 'end' => array(T_BREAK), - 'strict' => true, - 'shared' => true, - 'with' => array( - T_DEFAULT, - T_CASE, - T_SWITCH, - ), - ), - T_DEFAULT => array( - 'start' => array(T_COLON), - 'end' => array(T_BREAK), - 'strict' => true, - 'shared' => true, - 'with' => array( - T_CASE, - T_SWITCH, - ), - ), - ); - - /** - * A list of tokens that end the scope. - * - * This array is just a unique collection of the end tokens - * from the _scopeOpeners array. The data is duplicated here to - * save time during parsing of the file. - * - * @var array - */ - public $endScopeTokens = array( - T_CLOSE_CURLY_BRACKET, - T_BREAK, - ); - - /** - * A list of special JS tokens and their types. - * - * @var array - */ - protected $tokenValues = array( - 'function' => 'T_FUNCTION', - 'prototype' => 'T_PROTOTYPE', - 'try' => 'T_TRY', - 'catch' => 'T_CATCH', - 'return' => 'T_RETURN', - 'break' => 'T_BREAK', - 'switch' => 'T_SWITCH', - 'continue' => 'T_CONTINUE', - 'if' => 'T_IF', - 'else' => 'T_ELSE', - 'do' => 'T_DO', - 'while' => 'T_WHILE', - 'for' => 'T_FOR', - 'var' => 'T_VAR', - 'case' => 'T_CASE', - 'default' => 'T_DEFAULT', - 'true' => 'T_TRUE', - 'false' => 'T_FALSE', - 'null' => 'T_NULL', - 'this' => 'T_THIS', - 'typeof' => 'T_TYPEOF', - '(' => 'T_OPEN_PARENTHESIS', - ')' => 'T_CLOSE_PARENTHESIS', - '{' => 'T_OPEN_CURLY_BRACKET', - '}' => 'T_CLOSE_CURLY_BRACKET', - '[' => 'T_OPEN_SQUARE_BRACKET', - ']' => 'T_CLOSE_SQUARE_BRACKET', - '?' => 'T_INLINE_THEN', - '.' => 'T_OBJECT_OPERATOR', - '+' => 'T_PLUS', - '-' => 'T_MINUS', - '*' => 'T_MULTIPLY', - '%' => 'T_MODULUS', - '/' => 'T_DIVIDE', - '^' => 'T_POWER', - ',' => 'T_COMMA', - ';' => 'T_SEMICOLON', - ':' => 'T_COLON', - '<' => 'T_LESS_THAN', - '>' => 'T_GREATER_THAN', - '<=' => 'T_IS_SMALLER_OR_EQUAL', - '>=' => 'T_IS_GREATER_OR_EQUAL', - '!' => 'T_BOOLEAN_NOT', - '||' => 'T_BOOLEAN_OR', - '&&' => 'T_BOOLEAN_AND', - '|' => 'T_BITWISE_OR', - '&' => 'T_BITWISE_AND', - '!=' => 'T_IS_NOT_EQUAL', - '!==' => 'T_IS_NOT_IDENTICAL', - '=' => 'T_EQUAL', - '==' => 'T_IS_EQUAL', - '===' => 'T_IS_IDENTICAL', - '-=' => 'T_MINUS_EQUAL', - '+=' => 'T_PLUS_EQUAL', - '*=' => 'T_MUL_EQUAL', - '/=' => 'T_DIV_EQUAL', - '%=' => 'T_MOD_EQUAL', - '++' => 'T_INC', - '--' => 'T_DEC', - '//' => 'T_COMMENT', - '/*' => 'T_COMMENT', - '/**' => 'T_DOC_COMMENT', - '*/' => 'T_COMMENT', - ); - - /** - * A list string delimiters. - * - * @var array - */ - protected $stringTokens = array( - '\'', - '"', - ); - - /** - * A list tokens that start and end comments. - * - * @var array - */ - protected $commentTokens = array( - '//' => null, - '/*' => '*/', - '/**' => '*/', - ); - - - /** - * Creates an array of tokens when given some PHP code. - * - * Starts by using token_get_all() but does a lot of extra processing - * to insert information about the context of the token. - * - * @param string $string The string to tokenize. - * @param string $eolChar The EOL character to use for splitting strings. - * - * @return array - */ - public function tokenizeString($string, $eolChar='\n') - { - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t*** START JS TOKENIZING ***".PHP_EOL; - } - - $tokenTypes = array_keys($this->tokenValues); - - $maxTokenLength = 0; - foreach ($tokenTypes as $token) { - if (strlen($token) > $maxTokenLength) { - $maxTokenLength = strlen($token); - } - } - - $tokens = array(); - $inString = ''; - $stringChar = null; - $inComment = ''; - $buffer = ''; - $preStringBuffer = ''; - $cleanBuffer = false; - - $tokens[] = array( - 'code' => T_OPEN_TAG, - 'type' => 'T_OPEN_TAG', - 'content' => '', - ); - - // Convert newlines to single characters for ease of - // processing. We will change them back later. - $string = str_replace($eolChar, "\n", $string); - - $chars = str_split($string); - $numChars = count($chars); - for ($i = 0; $i < $numChars; $i++) { - $char = $chars[$i]; - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $content = str_replace("\n", '\n', $char); - $bufferContent = str_replace("\n", '\n', $buffer); - if ($inString !== '') { - echo "\t"; - } - - if ($inComment !== '') { - echo "\t"; - } - - echo "\tProcess char $i => $content (buffer: $bufferContent)".PHP_EOL; - } - - if ($inString === '' && $inComment === '' && $buffer !== '') { - // If the buffer only has whitespace and we are about to - // add a character, store the whitespace first. - if (trim($char) !== '' && trim($buffer) === '') { - $tokens[] = array( - 'code' => T_WHITESPACE, - 'type' => 'T_WHITESPACE', - 'content' => str_replace("\n", $eolChar, $buffer), - ); - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $content = str_replace("\n", '\n', $buffer); - echo "\t=> Added token T_WHITESPACE ($content)".PHP_EOL; - } - - $buffer = ''; - } - - // If the buffer is not whitespace and we are about to - // add a whitespace character, store the content first. - if ($inString === '' - && $inComment === '' - && trim($char) === '' - && trim($buffer) !== '' - ) { - $tokens[] = array( - 'code' => T_STRING, - 'type' => 'T_STRING', - 'content' => str_replace("\n", $eolChar, $buffer), - ); - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $content = str_replace("\n", '\n', $buffer); - echo "\t=> Added token T_STRING ($content)".PHP_EOL; - } - - $buffer = ''; - } - }//end if - - // Process strings. - if ($inComment === '' && in_array($char, $this->stringTokens) === true) { - if ($inString === $char) { - // This could be the end of the string, but make sure it - // is not escaped first. - $escapes = 0; - for ($x = ($i - 1); $x >= 0; $x--) { - if ($chars[$x] !== '\\') { - break; - } - - $escapes++; - } - - if ($escapes === 0 || ($escapes % 2) === 0) { - // There is an even number escape chars, - // so this is not escaped, it is the end of the string. - $tokens[] = array( - 'code' => T_CONSTANT_ENCAPSED_STRING, - 'type' => 'T_CONSTANT_ENCAPSED_STRING', - 'content' => str_replace("\n", $eolChar, $buffer).$char, - ); - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t\t* found end of string *".PHP_EOL; - $content = str_replace("\n", '\n', $buffer.$char); - echo "\t=> Added token T_CONSTANT_ENCAPSED_STRING ($content)".PHP_EOL; - } - - $buffer = ''; - $preStringBuffer = ''; - $inString = ''; - $stringChar = null; - continue; - } - } else if ($inString === '') { - $inString = $char; - $stringChar = $i; - $preStringBuffer = $buffer; - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t\t* looking for string closer *".PHP_EOL; - } - }//end if - }//end if - - if ($inString !== '' && $char === "\n") { - // Unless this newline character is escaped, the string did not - // end before the end of the line, which means it probably - // wasn't a string at all (maybe a regex). - if ($chars[($i - 1)] !== '\\') { - $i = $stringChar; - $buffer = $preStringBuffer; - $preStringBuffer = ''; - $inString = ''; - $stringChar = null; - $char = $chars[$i]; - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t\t* found newline before end of string, bailing *".PHP_EOL; - } - } - } - - $buffer .= $char; - - // We don't look for special tokens inside strings, - // so if we are in a string, we can continue here now - // that the current char is in the buffer. - if ($inString !== '') { - continue; - } - - // Special case for T_DIVIDE which can actually be - // the start of a regular expression. - if ($char === '/') { - $regex = $this->getRegexToken( - $i, - $string, - $chars, - $tokens, - $eolChar - ); - - if ($regex !== null) { - $tokens[] = array( - 'code' => T_REGULAR_EXPRESSION, - 'type' => 'T_REGULAR_EXPRESSION', - 'content' => $regex['content'], - ); - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $content = str_replace("\n", '\n', $regex['content']); - echo "\t=> Added token T_REGULAR_EXPRESSION ($content)".PHP_EOL; - } - - $i = $regex['end']; - $buffer = ''; - $cleanBuffer = false; - continue; - } - }//end if - - // Check for known tokens, but ignore tokens found that are not at - // the end of a string, like FOR and this.FORmat. - if (in_array(strtolower($buffer), $tokenTypes) === true - && (preg_match('|[a-zA-z0-9_]|', $char) === 0 - || isset($chars[($i + 1)]) === false - || preg_match('|[a-zA-z0-9_]|', $chars[($i + 1)]) === 0) - ) { - $matchedToken = false; - $lookAheadLength = ($maxTokenLength - strlen($buffer)); - - if ($lookAheadLength > 0) { - // The buffer contains a token type, but we need - // to look ahead at the next chars to see if this is - // actually part of a larger token. For example, - // FOR and FOREACH. - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t\t* buffer possibly contains token, looking ahead $lookAheadLength chars *".PHP_EOL; - } - - $charBuffer = $buffer; - for ($x = 1; $x <= $lookAheadLength; $x++) { - if (isset($chars[($i + $x)]) === false) { - break; - } - - $charBuffer .= $chars[($i + $x)]; - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $content = str_replace("\n", '\n', $charBuffer); - echo "\t\t=> Looking ahead $x chars => $content".PHP_EOL; - } - - if (in_array(strtolower($charBuffer), $tokenTypes) === true) { - // We've found something larger that matches - // so we can ignore this char. - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $type = $this->tokenValues[strtolower($charBuffer)]; - echo "\t\t* look ahead found more specific token ($type), ignoring $i *".PHP_EOL; - } - - $matchedToken = true; - break; - } - }//end for - }//end if - - if ($matchedToken === false) { - if (PHP_CODESNIFFER_VERBOSITY > 1 && $lookAheadLength > 0) { - echo "\t\t* look ahead found nothing *".PHP_EOL; - } - - $value = $this->tokenValues[strtolower($buffer)]; - $tokens[] = array( - 'code' => constant($value), - 'type' => $value, - 'content' => $buffer, - ); - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $content = str_replace("\n", '\n', $buffer); - echo "\t=> Added token $value ($content)".PHP_EOL; - } - - $cleanBuffer = true; - }//end if - } else if (in_array(strtolower($char), $tokenTypes) === true) { - // No matter what token we end up using, we don't - // need the content in the buffer any more because we have - // found a valid token. - $newContent = substr(str_replace("\n", $eolChar, $buffer), 0, -1); - if ($newContent !== '') { - $tokens[] = array( - 'code' => T_STRING, - 'type' => 'T_STRING', - 'content' => $newContent, - ); - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $content = str_replace("\n", '\n', substr($buffer, 0, -1)); - echo "\t=> Added token T_STRING ($content)".PHP_EOL; - } - } - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t\t* char is token, looking ahead ".($maxTokenLength - 1).' chars *'.PHP_EOL; - } - - // The char is a token type, but we need to look ahead at the - // next chars to see if this is actually part of a larger token. - // For example, = and ===. - $charBuffer = $char; - $matchedToken = false; - for ($x = 1; $x <= $maxTokenLength; $x++) { - if (isset($chars[($i + $x)]) === false) { - break; - } - - $charBuffer .= $chars[($i + $x)]; - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $content = str_replace("\n", '\n', $charBuffer); - echo "\t\t=> Looking ahead $x chars => $content".PHP_EOL; - } - - if (in_array(strtolower($charBuffer), $tokenTypes) === true) { - // We've found something larger that matches - // so we can ignore this char. - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $type = $this->tokenValues[strtolower($charBuffer)]; - echo "\t\t* look ahead found more specific token ($type), ignoring $i *".PHP_EOL; - } - - $matchedToken = true; - break; - } - }//end for - - if ($matchedToken === false) { - $value = $this->tokenValues[strtolower($char)]; - $tokens[] = array( - 'code' => constant($value), - 'type' => $value, - 'content' => $char, - ); - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t\t* look ahead found nothing *".PHP_EOL; - $content = str_replace("\n", '\n', $char); - echo "\t=> Added token $value ($content)".PHP_EOL; - } - - $cleanBuffer = true; - } else { - $buffer = $char; - } - }//end if - - // Keep track of content inside comments. - if ($inComment === '' - && array_key_exists($buffer, $this->commentTokens) === true - ) { - // This is not really a comment if the content - // looks like \// (i.e., it is escaped). - if (isset($chars[($i - 2)]) === true && $chars[($i - 2)] === '\\') { - $lastToken = array_pop($tokens); - $lastContent = $lastToken['content']; - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $value = $this->tokenValues[strtolower($lastContent)]; - $content = str_replace("\n", '\n', $lastContent); - echo "\t=> Removed token $value ($content)".PHP_EOL; - } - - $lastChars = str_split($lastContent); - $lastNumChars = count($lastChars); - for ($x = 0; $x < $lastNumChars; $x++) { - $lastChar = $lastChars[$x]; - $value = $this->tokenValues[strtolower($lastChar)]; - $tokens[] = array( - 'code' => constant($value), - 'type' => $value, - 'content' => $lastChar, - ); - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $content = str_replace("\n", '\n', $lastChar); - echo "\t=> Added token $value ($content)".PHP_EOL; - } - } - } else { - // We have started a comment. - $inComment = $buffer; - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t\t* looking for end of comment *".PHP_EOL; - } - } - } else if ($inComment !== '') { - if ($this->commentTokens[$inComment] === null) { - // Comment ends at the next newline. - if (strpos($buffer, "\n") !== false) { - $inComment = ''; - } - } else { - if ($this->commentTokens[$inComment] === $buffer) { - $inComment = ''; - } - } - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - if ($inComment === '') { - echo "\t\t* found end of comment *".PHP_EOL; - } - } - - if ($inComment === '' && $cleanBuffer === false) { - $tokens[] = array( - 'code' => T_STRING, - 'type' => 'T_STRING', - 'content' => str_replace("\n", $eolChar, $buffer), - ); - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $content = str_replace("\n", '\n', $buffer); - echo "\t=> Added token T_STRING ($content)".PHP_EOL; - } - - $buffer = ''; - } - }//end if - - if ($cleanBuffer === true) { - $buffer = ''; - $cleanBuffer = false; - } - }//end foreach - - // Trim the last newline off the end of the buffer before - // adding it's contents to the token stack. - // This is so we don't count the very final newline of a file. - $buffer = substr($buffer, 0, -1); - - if (empty($buffer) === false) { - // Buffer contians whitespace from the end of the file, and not - // just the final newline. - $tokens[] = array( - 'code' => T_WHITESPACE, - 'type' => 'T_WHITESPACE', - 'content' => str_replace("\n", $eolChar, $buffer), - ); - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $content = str_replace($eolChar, '\n', $buffer); - echo "\t=> Added token T_WHITESPACE ($content)".PHP_EOL; - } - } - - $tokens[] = array( - 'code' => T_CLOSE_TAG, - 'type' => 'T_CLOSE_TAG', - 'content' => '', - ); - - /* - Now that we have done some basic tokenizing, we need to - modify the tokens to join some together and split some apart - so they match what the PHP tokenizer does. - */ - - $finalTokens = array(); - $newStackPtr = 0; - $numTokens = count($tokens); - for ($stackPtr = 0; $stackPtr < $numTokens; $stackPtr++) { - $token = $tokens[$stackPtr]; - - /* - Look for comments and join the tokens together. - */ - - if (array_key_exists($token['content'], $this->commentTokens) === true) { - $newContent = ''; - $tokenContent = $token['content']; - $endContent = $this->commentTokens[$tokenContent]; - while ($tokenContent !== $endContent) { - if ($endContent === null - && strpos($tokenContent, $eolChar) !== false - ) { - // A null end token means the comment ends at the end of - // the line so we look for newlines and split the token. - $tokens[$stackPtr]['content'] = substr( - $tokenContent, - (strpos($tokenContent, $eolChar) + strlen($eolChar)) - ); - - $tokenContent = substr( - $tokenContent, - 0, - (strpos($tokenContent, $eolChar) + strlen($eolChar)) - ); - - // If the substr failed, skip the token as the content - // will now be blank. - if ($tokens[$stackPtr]['content'] !== false) { - $stackPtr--; - } - - break; - }//end if - - $stackPtr++; - $newContent .= $tokenContent; - if (isset($tokens[$stackPtr]) === false) { - break; - } - - $tokenContent = $tokens[$stackPtr]['content']; - }//end while - - // Save the new content in the current token so - // the code below can chop it up on newlines. - $token['content'] = $newContent.$tokenContent; - }//end if - - /* - If this token has newlines in its content, split each line up - and create a new token for each line. We do this so it's easier - to asertain where errors occur on a line. - Note that $token[1] is the token's content. - */ - - if (strpos($token['content'], $eolChar) !== false) { - $tokenLines = explode($eolChar, $token['content']); - $numLines = count($tokenLines); - - for ($i = 0; $i < $numLines; $i++) { - $newToken['content'] = $tokenLines[$i]; - if ($i === ($numLines - 1)) { - if ($tokenLines[$i] === '') { - break; - } - } else { - $newToken['content'] .= $eolChar; - } - - $newToken['type'] = $token['type']; - $newToken['code'] = $token['code']; - $finalTokens[$newStackPtr] = $newToken; - $newStackPtr++; - } - } else { - $finalTokens[$newStackPtr] = $token; - $newStackPtr++; - }//end if - - // Convert numbers, including decimals. - if ($token['code'] === T_STRING - || $token['code'] === T_OBJECT_OPERATOR - ) { - $newContent = ''; - $oldStackPtr = $stackPtr; - while (preg_match('|^[0-9\.]+$|', $tokens[$stackPtr]['content']) !== 0) { - $newContent .= $tokens[$stackPtr]['content']; - $stackPtr++; - } - - if ($newContent !== '' && $newContent !== '.') { - $finalTokens[($newStackPtr - 1)]['content'] = $newContent; - if (ctype_digit($newContent) === true) { - $finalTokens[($newStackPtr - 1)]['code'] - = constant('T_LNUMBER'); - $finalTokens[($newStackPtr - 1)]['type'] = 'T_LNUMBER'; - } else { - $finalTokens[($newStackPtr - 1)]['code'] - = constant('T_DNUMBER'); - $finalTokens[($newStackPtr - 1)]['type'] = 'T_DNUMBER'; - } - - $stackPtr--; - } else { - $stackPtr = $oldStackPtr; - } - }//end if - }//end for - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t*** END TOKENIZING ***".PHP_EOL; - } - - return $finalTokens; - - }//end tokenizeString() - - - /** - * Tokenizes a regular expression if one is found. - * - * If a regular expression is not found, NULL is returned. - * - * @param string $char The index of the possible regex start character. - * @param string $string The complete content of the string being tokenized. - * @param string $chars An array of characters being tokenized. - * @param string $tokens The current array of tokens found in the string. - * @param string $eolChar The EOL character to use for splitting strings. - * - * @return void - */ - public function getRegexToken($char, $string, $chars, $tokens, $eolChar) - { - $beforeTokens = array( - T_EQUAL, - T_OPEN_PARENTHESIS, - T_RETURN, - T_BOOLEAN_OR, - T_BOOLEAN_AND, - T_BITWISE_OR, - T_BITWISE_AND, - T_COMMA, - T_COLON, - T_TYPEOF, - ); - - $afterTokens = array( - ',', - ')', - ';', - ' ', - '.', - $eolChar, - ); - - // Find the last non-whitespace token that was added - // to the tokens array. - $numTokens = count($tokens); - for ($prev = ($numTokens - 1); $prev >= 0; $prev--) { - if (in_array($tokens[$prev]['code'], PHP_CodeSniffer_Tokens::$emptyTokens) === false) { - break; - } - } - - if (in_array($tokens[$prev]['code'], $beforeTokens) === false) { - return null; - } - - // This is probably a regular expression, so look for the end of it. - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $content = str_replace("\n", '\n', $char); - echo "\t* token possibly starts a regular expression *".PHP_EOL; - } - - $numChars = count($chars); - for ($next = ($char + 1); $next < $numChars; $next++) { - if ($chars[$next] === '/') { - // Just make sure this is not escaped first. - if ($chars[($next - 1)] !== '\\') { - // In the simple form: /.../ so we found the end. - break; - } else if ($chars[($next - 2)] === '\\') { - // In the form: /...\\/ so we found the end. - break; - } - } else { - $possibleEolChar = substr($string, $next, strlen($eolChar)); - if ($possibleEolChar === $eolChar) { - // This is the last token on the line and regular - // expressions need to be defined on a single line, - // so this is not a regular expression. - break; - } - } - } - - if ($chars[$next] !== '/') { - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t* could not find end of regular expression *".PHP_EOL; - } - - return null; - } - - while (preg_match('|[a-zA-Z]|', $chars[($next + 1)]) !== 0) { - // The token directly after the end of the regex can - // be modifiers like global and case insensitive - // (.e.g, /pattern/gi). - $next++; - } - - $regexEnd = $next; - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t* found end of regular expression at token $regexEnd *".PHP_EOL; - } - - for ($next = ($next + 1); $next < $numChars; $next++) { - if ($chars[$next] !== ' ') { - break; - } else { - $possibleEolChar = substr($string, $next, strlen($eolChar)); - if ($possibleEolChar === $eolChar) { - // This is the last token on the line. - break; - } - } - } - - if (in_array($chars[$next], $afterTokens) === false) { - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t* tokens after regular expression do not look correct *".PHP_EOL; - } - - return null; - } - - // This is a regular expression, so join all the tokens together. - $content = ''; - for ($x = $char; $x <= $regexEnd; $x++) { - $content .= $chars[$x]; - } - - $token = array( - 'start' => $char, - 'end' => $regexEnd, - 'content' => $content, - ); - - return $token; - - }//end getRegexToken() - - - /** - * Performs additional processing after main tokenizing. - * - * This additional processing looks for properties, labels and objects. - * - * @param array &$tokens The array of tokens to process. - * @param string $eolChar The EOL character to use for splitting strings. - * - * @return void - */ - public function processAdditional(&$tokens, $eolChar) - { - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t*** START ADDITIONAL JS PROCESSING ***".PHP_EOL; - } - - $numTokens = count($tokens); - $classStack = array(); - - for ($i = 0; $i < $numTokens; $i++) { - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $type = $tokens[$i]['type']; - $content = str_replace($eolChar, '\n', $tokens[$i]['content']); - echo str_repeat("\t", count($classStack)); - - echo "\tProcess token $i: $type => $content".PHP_EOL; - } - - if ($tokens[$i]['code'] === T_OPEN_CURLY_BRACKET - && isset($tokens[$i]['scope_condition']) === false - ) { - $classStack[] = $i; - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo str_repeat("\t", count($classStack)); - echo "\t=> Found property opener".PHP_EOL; - } - - // This could also be an object definition. - for ($x = ($i - 1); $x >= 0; $x--) { - if (in_array($tokens[$x]['code'], PHP_CodeSniffer_Tokens::$emptyTokens) === false) { - // Non-whitespace content. - break; - } - } - - if ($tokens[$x]['code'] === T_EQUAL) { - for ($x--; $x >= 0; $x--) { - if (in_array($tokens[$x]['code'], PHP_CodeSniffer_Tokens::$emptyTokens) === false) { - break; - } - } - - if ($tokens[$x]['code'] === T_STRING - || $tokens[$x]['code'] === T_PROTOTYPE - ) { - // Find the first string in this definition. - // E.g., WantedString.DontWantThis.prototype - for ($x--; $x >= 0; $x--) { - $wantedTokens = array( - T_STRING, - T_PROTOTYPE, - T_OBJECT_OPERATOR, - ); - - if (in_array($tokens[$x]['code'], $wantedTokens) === false) { - $x++; - break; - } - } - - $closer = $tokens[$i]['bracket_closer']; - $tokens[$i]['scope_condition'] = $x; - $tokens[$i]['scope_closer'] = $closer; - $tokens[$closer]['scope_condition'] = $x; - $tokens[$closer]['scope_opener'] = $i; - $tokens[$x]['scope_opener'] = $i; - $tokens[$x]['scope_closer'] = $closer; - $tokens[$x]['code'] = T_OBJECT; - $tokens[$x]['type'] = 'T_OBJECT'; - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo str_repeat("\t", count($classStack)); - echo "\t* token $x converted from T_STRING to T_OBJECT *".PHP_EOL; - echo str_repeat("\t", count($classStack)); - echo "\t* set scope opener ($i) and closer ($closer) for token $x *".PHP_EOL; - } - }//end if - }//end if - } else if ($tokens[$i]['code'] === T_CLOSE_CURLY_BRACKET - && (isset($tokens[$i]['scope_condition']) === false - || $tokens[$tokens[$i]['scope_condition']]['code'] === T_OBJECT) - ) { - $opener = array_pop($classStack); - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo str_repeat("\t", count($classStack)); - echo "\t\t=> Found property closer for $opener".PHP_EOL; - } - } else if ($tokens[$i]['code'] === T_COLON) { - // If it is a scope opener, it belongs to a - // DEFAULT or CASE statement. - if (isset($tokens[$i]['scope_condition']) === true) { - continue; - } - - // Make sure this is not part of an inline IF statement. - for ($x = ($i - 1); $x >= 0; $x--) { - if ($tokens[$x]['code'] === T_INLINE_THEN) { - continue(2); - } else if ($tokens[$x]['line'] < $tokens[$i]['line']) { - break; - } - } - - // The string to the left of the colon is either a property or label. - for ($label = ($i - 1); $label >= 0; $label--) { - if (in_array($tokens[$label]['code'], PHP_CodeSniffer_Tokens::$emptyTokens) === false) { - break; - } - } - - if ($tokens[$label]['code'] !== T_STRING) { - continue; - } - - if (empty($classStack) === false) { - $tokens[$label]['code'] = T_PROPERTY; - $tokens[$label]['type'] = 'T_PROPERTY'; - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo str_repeat("\t", count($classStack)); - echo "\t* token $label converted from T_STRING to T_PROPERTY *".PHP_EOL; - } - - // If the net token after the colon is a curly brace, - // this property is actually an object, so we can give it - // and opener and closer. - for ($x = ($i + 1); $x < $numTokens; $x++) { - if (in_array($tokens[$x]['code'], PHP_CodeSniffer_Tokens::$emptyTokens) === false) { - break; - } - } - - if ($tokens[$x]['code'] === T_OPEN_CURLY_BRACKET) { - $closer = $tokens[$x]['bracket_closer']; - $tokens[$label]['scope_opener'] = $x; - $tokens[$label]['scope_closer'] = $closer; - $tokens[$x]['scope_condition'] = $label; - $tokens[$x]['scope_closer'] = $closer; - $tokens[$closer]['scope_condition'] = $label; - $tokens[$closer]['scope_opener'] = $x; - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo str_repeat("\t", count($classStack)); - echo "\t* set scope opener ($x) and closer ($closer) for token $label *".PHP_EOL; - } - } - } else { - $tokens[$label]['code'] = T_LABEL; - $tokens[$label]['type'] = 'T_LABEL'; - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo str_repeat("\t", count($classStack)); - echo "\t* token $label converted from T_STRING to T_LABEL *".PHP_EOL; - } - } - }//end if - }//end for - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t*** END ADDITIONAL JS PROCESSING ***".PHP_EOL; - } - - }//end processAdditional() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Tokenizers/PHP.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Tokenizers/PHP.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Tokenizers/PHP.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Tokenizers/PHP.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,619 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Tokenizes PHP code. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PHP_CodeSniffer_Tokenizers_PHP -{ - - /** - * A list of tokens that are allowed to open a scope. - * - * This array also contains information about what kind of token the scope - * opener uses to open and close the scope, if the token strictly requires - * an opener, if the token can share a scope closer, and who it can be shared - * with. An example of a token that shares a scope closer is a CASE scope. - * - * @var array - */ - public $scopeOpeners = array( - T_IF => array( - 'start' => array(T_OPEN_CURLY_BRACKET), - 'end' => array(T_CLOSE_CURLY_BRACKET), - 'strict' => false, - 'shared' => false, - 'with' => array(), - ), - T_TRY => array( - 'start' => array(T_OPEN_CURLY_BRACKET), - 'end' => array(T_CLOSE_CURLY_BRACKET), - 'strict' => true, - 'shared' => false, - 'with' => array(), - ), - T_CATCH => array( - 'start' => array(T_OPEN_CURLY_BRACKET), - 'end' => array(T_CLOSE_CURLY_BRACKET), - 'strict' => true, - 'shared' => false, - 'with' => array(), - ), - T_ELSE => array( - 'start' => array(T_OPEN_CURLY_BRACKET), - 'end' => array(T_CLOSE_CURLY_BRACKET), - 'strict' => false, - 'shared' => false, - 'with' => array(), - ), - T_ELSEIF => array( - 'start' => array(T_OPEN_CURLY_BRACKET), - 'end' => array(T_CLOSE_CURLY_BRACKET), - 'strict' => false, - 'shared' => false, - 'with' => array(), - ), - T_FOR => array( - 'start' => array(T_OPEN_CURLY_BRACKET), - 'end' => array(T_CLOSE_CURLY_BRACKET), - 'strict' => false, - 'shared' => false, - 'with' => array(), - ), - T_FOREACH => array( - 'start' => array(T_OPEN_CURLY_BRACKET), - 'end' => array(T_CLOSE_CURLY_BRACKET), - 'strict' => false, - 'shared' => false, - 'with' => array(), - ), - T_INTERFACE => array( - 'start' => array(T_OPEN_CURLY_BRACKET), - 'end' => array(T_CLOSE_CURLY_BRACKET), - 'strict' => true, - 'shared' => false, - 'with' => array(), - ), - T_FUNCTION => array( - 'start' => array(T_OPEN_CURLY_BRACKET), - 'end' => array(T_CLOSE_CURLY_BRACKET), - 'strict' => true, - 'shared' => false, - 'with' => array(), - ), - T_CLASS => array( - 'start' => array(T_OPEN_CURLY_BRACKET), - 'end' => array(T_CLOSE_CURLY_BRACKET), - 'strict' => true, - 'shared' => false, - 'with' => array(), - ), - T_TRAIT => array( - 'start' => array(T_OPEN_CURLY_BRACKET), - 'end' => array(T_CLOSE_CURLY_BRACKET), - 'strict' => true, - 'shared' => false, - 'with' => array(), - ), - T_NAMESPACE => array( - 'start' => array(T_OPEN_CURLY_BRACKET), - 'end' => array(T_CLOSE_CURLY_BRACKET), - 'strict' => false, - 'shared' => false, - 'with' => array(), - ), - T_WHILE => array( - 'start' => array(T_OPEN_CURLY_BRACKET), - 'end' => array(T_CLOSE_CURLY_BRACKET), - 'strict' => false, - 'shared' => false, - 'with' => array(), - ), - T_DO => array( - 'start' => array(T_OPEN_CURLY_BRACKET), - 'end' => array(T_CLOSE_CURLY_BRACKET), - 'strict' => true, - 'shared' => false, - 'with' => array(), - ), - T_SWITCH => array( - 'start' => array(T_OPEN_CURLY_BRACKET), - 'end' => array(T_CLOSE_CURLY_BRACKET), - 'strict' => true, - 'shared' => false, - 'with' => array(), - ), - T_CASE => array( - 'start' => array( - T_COLON, - T_SEMICOLON, - ), - 'end' => array(T_BREAK), - 'strict' => true, - 'shared' => true, - 'with' => array( - T_DEFAULT, - T_CASE, - T_SWITCH, - ), - ), - T_DEFAULT => array( - 'start' => array(T_COLON), - 'end' => array(T_BREAK), - 'strict' => true, - 'shared' => true, - 'with' => array( - T_CASE, - T_SWITCH, - ), - ), - T_START_HEREDOC => array( - 'start' => array(T_START_HEREDOC), - 'end' => array(T_END_HEREDOC), - 'strict' => true, - 'shared' => false, - 'with' => array(), - ), - ); - - /** - * A list of tokens that end the scope. - * - * This array is just a unique collection of the end tokens - * from the _scopeOpeners array. The data is duplicated here to - * save time during parsing of the file. - * - * @var array - */ - public $endScopeTokens = array( - T_CLOSE_CURLY_BRACKET, - T_BREAK, - T_END_HEREDOC, - ); - - - /** - * Creates an array of tokens when given some PHP code. - * - * Starts by using token_get_all() but does a lot of extra processing - * to insert information about the context of the token. - * - * @param string $string The string to tokenize. - * @param string $eolChar The EOL character to use for splitting strings. - * - * @return array - */ - public function tokenizeString($string, $eolChar='\n') - { - $tokens = @token_get_all($string); - $finalTokens = array(); - - $newStackPtr = 0; - $numTokens = count($tokens); - for ($stackPtr = 0; $stackPtr < $numTokens; $stackPtr++) { - $token = $tokens[$stackPtr]; - $tokenIsArray = is_array($token); - - /* - If we are using \r\n newline characters, the \r and \n are sometimes - split over two tokens. This normally occurs after comments. We need - to merge these two characters together so that our line endings are - consistent for all lines. - */ - - if ($tokenIsArray === true && substr($token[1], -1) === "\r") { - if (isset($tokens[($stackPtr + 1)]) === true - && is_array($tokens[($stackPtr + 1)]) === true - && $tokens[($stackPtr + 1)][1][0] === "\n" - ) { - $token[1] .= "\n"; - - if ($tokens[($stackPtr + 1)][1] === "\n") { - // The next token's content has been merged into this token, - // so we can skip it. - $stackPtr++; - } else { - $tokens[($stackPtr + 1)][1] - = substr($tokens[($stackPtr + 1)][1], 1); - } - } - }//end if - - /* - If this is a double quoted string, PHP will tokenise the whole - thing which causes problems with the scope map when braces are - within the string. So we need to merge the tokens together to - provide a single string. - */ - - if ($tokenIsArray === false && $token === '"') { - $tokenContent = '"'; - $nestedVars = array(); - for ($i = ($stackPtr + 1); $i < $numTokens; $i++) { - $subTokenIsArray = is_array($tokens[$i]); - - if ($subTokenIsArray === true) { - $tokenContent .= $tokens[$i][1]; - if ($tokens[$i][1] === '{' - && $tokens[$i][0] !== T_ENCAPSED_AND_WHITESPACE - ) { - $nestedVars[] = $i; - } - } else { - $tokenContent .= $tokens[$i]; - if ($tokens[$i] === '}') { - array_pop($nestedVars); - } - } - - if ($subTokenIsArray === false - && $tokens[$i] === '"' - && empty($nestedVars) === true - ) { - // We found the other end of the double quoted string. - break; - } - } - - $stackPtr = $i; - - // Convert each line within the double quoted string to a - // new token, so it conforms with other multiple line tokens. - $tokenLines = explode($eolChar, $tokenContent); - $numLines = count($tokenLines); - $newToken = array(); - - for ($j = 0; $j < $numLines; $j++) { - $newToken['content'] = $tokenLines[$j]; - if ($j === ($numLines - 1)) { - if ($tokenLines[$j] === '') { - break; - } - } else { - $newToken['content'] .= $eolChar; - } - - $newToken['code'] = T_DOUBLE_QUOTED_STRING; - $newToken['type'] = 'T_DOUBLE_QUOTED_STRING'; - $finalTokens[$newStackPtr] = $newToken; - $newStackPtr++; - } - - // Continue, as we're done with this token. - continue; - }//end if - - /* - If this is a heredoc, PHP will tokenise the whole - thing which causes problems when heredocs don't - contain real PHP code, which is almost never. - We want to leave the start and end heredoc tokens - alone though. - */ - - if ($tokenIsArray === true && $token[0] === T_START_HEREDOC) { - // Add the start heredoc token to the final array. - $finalTokens[$newStackPtr] - = PHP_CodeSniffer::standardiseToken($token); - - // Check if this is actually a nowdoc and use a different token - // to help the sniffs. - $nowdoc = false; - if ($token[1][3] === "'") { - $finalTokens[$newStackPtr]['code'] = T_START_NOWDOC; - $finalTokens[$newStackPtr]['type'] = 'T_START_NOWDOC'; - $nowdoc = true; - } - - $newStackPtr++; - - $tokenContent = ''; - for ($i = ($stackPtr + 1); $i < $numTokens; $i++) { - $subTokenIsArray = is_array($tokens[$i]); - if ($subTokenIsArray === true - && $tokens[$i][0] === T_END_HEREDOC - ) { - // We found the other end of the heredoc. - break; - } - - if ($subTokenIsArray === true) { - $tokenContent .= $tokens[$i][1]; - } else { - $tokenContent .= $tokens[$i]; - } - } - - $stackPtr = $i; - - // Convert each line within the heredoc to a - // new token, so it conforms with other multiple line tokens. - $tokenLines = explode($eolChar, $tokenContent); - $numLines = count($tokenLines); - $newToken = array(); - - for ($j = 0; $j < $numLines; $j++) { - $newToken['content'] = $tokenLines[$j]; - if ($j === ($numLines - 1)) { - if ($tokenLines[$j] === '') { - break; - } - } else { - $newToken['content'] .= $eolChar; - } - - if ($nowdoc === true) { - $newToken['code'] = T_NOWDOC; - $newToken['type'] = 'T_NOWDOC'; - } else { - $newToken['code'] = T_HEREDOC; - $newToken['type'] = 'T_HEREDOC'; - } - - $finalTokens[$newStackPtr] = $newToken; - $newStackPtr++; - } - - // Add the end heredoc token to the final array. - $finalTokens[$newStackPtr] - = PHP_CodeSniffer::standardiseToken($tokens[$stackPtr]); - - if ($nowdoc === true) { - $finalTokens[$newStackPtr]['code'] = T_END_NOWDOC; - $finalTokens[$newStackPtr]['type'] = 'T_END_NOWDOC'; - $nowdoc = true; - } - - $newStackPtr++; - - // Continue, as we're done with this token. - continue; - }//end if - - /* - If this token has newlines in its content, split each line up - and create a new token for each line. We do this so it's easier - to asertain where errors occur on a line. - Note that $token[1] is the token's content. - */ - - if ($tokenIsArray === true && strpos($token[1], $eolChar) !== false) { - $tokenLines = explode($eolChar, $token[1]); - $numLines = count($tokenLines); - $tokenName = token_name($token[0]); - - for ($i = 0; $i < $numLines; $i++) { - $newToken['content'] = $tokenLines[$i]; - if ($i === ($numLines - 1)) { - if ($tokenLines[$i] === '') { - break; - } - } else { - $newToken['content'] .= $eolChar; - } - - $newToken['type'] = $tokenName; - $newToken['code'] = $token[0]; - $finalTokens[$newStackPtr] = $newToken; - $newStackPtr++; - } - } else { - $newToken = PHP_CodeSniffer::standardiseToken($token); - - // This is a special condition for T_ARRAY tokens use to - // type hint function arguments as being arrays. We want to keep - // the parenthsis map clean, so let's tag these tokens as - // T_ARRAY_HINT. - if ($newToken['code'] === T_ARRAY) { - // Recalculate number of tokens. - $numTokens = count($tokens); - for ($i = $stackPtr; $i < $numTokens; $i++) { - if (is_array($tokens[$i]) === false) { - if ($tokens[$i] === '(') { - break; - } - } else if ($tokens[$i][0] === T_VARIABLE) { - $newToken['code'] = T_ARRAY_HINT; - $newToken['type'] = 'T_ARRAY_HINT'; - break; - } - } - } - - $finalTokens[$newStackPtr] = $newToken; - $newStackPtr++; - }//end if - }//end for - - return $finalTokens; - - }//end tokenizeString() - - - /** - * Performs additional processing after main tokenizing. - * - * This additional processing checks for CASE statements - * that are using curly braces for scope openers and closers. It - * also turn some T_FUNCTION tokens into T_CLOSURE when they - * are not standard function definitions. - * - * @param array &$tokens The array of tokens to process. - * @param string $eolChar The EOL character to use for splitting strings. - * - * @return void - */ - public function processAdditional(&$tokens, $eolChar) - { - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t*** START ADDITIONAL PHP PROCESSING ***".PHP_EOL; - } - - $numTokens = count($tokens); - for ($i = ($numTokens - 1); $i >= 0; $i--) { - // Looking for functions that are actually closures. - if ($tokens[$i]['code'] === T_FUNCTION && isset($tokens[$i]['scope_opener']) === true) { - for ($x = ($i + 1); $x < $numTokens; $x++) { - if (in_array($tokens[$x]['code'], PHP_CodeSniffer_Tokens::$emptyTokens) === false) { - break; - } - } - - if ($tokens[$x]['code'] === T_OPEN_PARENTHESIS) { - $tokens[$i]['code'] = T_CLOSURE; - $tokens[$i]['type'] = 'T_CLOSURE'; - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $line = $tokens[$i]['line']; - echo "\t* token $i on line $line changed from T_FUNCTION to T_CLOSURE".PHP_EOL; - } - - for ($x = ($tokens[$i]['scope_opener'] + 1); $x < $tokens[$i]['scope_closer']; $x++) { - if (isset($tokens[$x]['conditions'][$i]) === false) { - continue; - } - - $tokens[$x]['conditions'][$i] = T_CLOSURE; - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $type = $tokens[$x]['type']; - echo "\t\t* cleaned $x ($type) *".PHP_EOL; - } - } - } - - continue; - }//end if - - if (($tokens[$i]['code'] !== T_CASE - && $tokens[$i]['code'] !== T_DEFAULT) - || isset($tokens[$i]['scope_opener']) === false - ) { - // Only interested in CASE and DEFAULT statements - // from here on in. - continue; - } - - $scopeOpener = $tokens[$i]['scope_opener']; - $scopeCloser = $tokens[$i]['scope_closer']; - - // If the first char after the opener is a curly brace - // and that brace has been ignored, it is actually - // opening this case statement and the opener and closer are - // probably set incorrectly. - for ($x = ($scopeOpener + 1); $x < $numTokens; $x++) { - if (in_array($tokens[$x]['code'], PHP_CodeSniffer_Tokens::$emptyTokens) === false) { - // Non-whitespace content. - break; - } - } - - if ($tokens[$x]['code'] === T_CASE) { - // Special case for multiple CASE statements that - // share the same closer. Because we are going - // backwards through the file, this next CASE - // statement is already fixed, so just use its - // closer and don't worry about fixing anything. - $newCloser = $tokens[$x]['scope_closer']; - $tokens[$i]['scope_closer'] = $newCloser; - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $oldType = $tokens[$scopeCloser]['type']; - $newType = $tokens[$newCloser]['type']; - $line = $tokens[$i]['line']; - echo "\t* token $i (T_CASE) on line $line closer changed from $scopeCloser ($oldType) to $newCloser ($newType)".PHP_EOL; - } - - continue; - } - - if ($tokens[$x]['code'] !== T_OPEN_CURLY_BRACKET - || isset($tokens[$x]['scope_condition']) === true - ) { - // Not a CASE with a curly brace opener. - continue; - } - - // The closer for this CASE/DEFAULT should be the closing - // curly brace and not whatever it already is. The opener needs - // to be the opening curly brace so everything matches up. - $newCloser = $tokens[$x]['bracket_closer']; - $tokens[$i]['scope_closer'] = $newCloser; - $tokens[$x]['scope_closer'] = $newCloser; - $tokens[$i]['scope_opener'] = $x; - $tokens[$x]['scope_condition'] = $i; - $tokens[$newCloser]['scope_condition'] = $i; - $tokens[$newCloser]['scope_opener'] = $x; - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $line = $tokens[$i]['line']; - $tokenType = $tokens[$i]['type']; - - $oldType = $tokens[$scopeOpener]['type']; - $newType = $tokens[$x]['type']; - echo "\t* token $i ($tokenType) on line $line opener changed from $scopeOpener ($oldType) to $x ($newType)".PHP_EOL; - - $oldType = $tokens[$scopeCloser]['type']; - $newType = $tokens[$newCloser]['type']; - echo "\t* token $i ($tokenType) on line $line closer changed from $scopeCloser ($oldType) to $newCloser ($newType)".PHP_EOL; - } - - // Now fix up all the tokens that think they are - // inside the CASE/DEFAULT statement when they are really outside. - for ($x = $newCloser; $x < $scopeCloser; $x++) { - foreach ($tokens[$x]['conditions'] as $num => $oldCond) { - if ($oldCond === $tokens[$i]['code']) { - $oldConditions = $tokens[$x]['conditions']; - unset($tokens[$x]['conditions'][$num]); - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $type = $tokens[$x]['type']; - $oldConds = ''; - foreach ($oldConditions as $condition) { - $oldConds .= token_name($condition).','; - } - - $oldConds = rtrim($oldConds, ','); - - $newConds = ''; - foreach ($tokens[$x]['conditions'] as $condition) { - $newConds .= token_name($condition).','; - } - - $newConds = rtrim($newConds, ','); - - echo "\t\t* cleaned $x ($type) *".PHP_EOL; - echo "\t\t\t=> conditions changed from $oldConds to $newConds".PHP_EOL; - } - - break; - } - } - } - }//end for - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t*** END ADDITIONAL PHP PROCESSING ***".PHP_EOL; - } - - }//end processAdditional() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Tokens.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Tokens.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer/Tokens.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer/Tokens.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,472 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -define('T_NONE', 0); -define('T_OPEN_CURLY_BRACKET', 1000); -define('T_CLOSE_CURLY_BRACKET', 1001); -define('T_OPEN_SQUARE_BRACKET', 1002); -define('T_CLOSE_SQUARE_BRACKET', 1003); -define('T_OPEN_PARENTHESIS', 1004); -define('T_CLOSE_PARENTHESIS', 1005); -define('T_COLON', 1006); -define('T_STRING_CONCAT', 1007); -define('T_INLINE_THEN', 1008); -define('T_NULL', 1009); -define('T_FALSE', 1010); -define('T_TRUE', 1011); -define('T_SEMICOLON', 1012); -define('T_EQUAL', 1013); -define('T_MULTIPLY', 1015); -define('T_DIVIDE', 1016); -define('T_PLUS', 1017); -define('T_MINUS', 1018); -define('T_MODULUS', 1019); -define('T_POWER', 1020); -define('T_BITWISE_AND', 1021); -define('T_BITWISE_OR', 1022); -define('T_ARRAY_HINT', 1023); -define('T_GREATER_THAN', 1024); -define('T_LESS_THAN', 1025); -define('T_BOOLEAN_NOT', 1026); -define('T_SELF', 1027); -define('T_PARENT', 1028); -define('T_DOUBLE_QUOTED_STRING', 1029); -define('T_COMMA', 1030); -define('T_HEREDOC', 1031); -define('T_PROTOTYPE', 1032); -define('T_THIS', 1033); -define('T_REGULAR_EXPRESSION', 1034); -define('T_PROPERTY', 1035); -define('T_LABEL', 1036); -define('T_OBJECT', 1037); -define('T_COLOUR', 1038); -define('T_HASH', 1039); -define('T_URL', 1040); -define('T_STYLE', 1041); -define('T_ASPERAND', 1042); -define('T_DOLLAR', 1043); -define('T_TYPEOF', 1044); -define('T_CLOSURE', 1045); -define('T_BACKTICK', 1046); -define('T_START_NOWDOC', 1047); -define('T_NOWDOC', 1048); -define('T_END_NOWDOC', 1049); - -// Some PHP 5.3 tokens, replicated for lower versions. -if (defined('T_NAMESPACE') === false) { - define('T_NAMESPACE', 1050); -} - -if (defined('T_NS_SEPARATOR') === false) { - define('T_NS_SEPARATOR', 1051); -} - -if (defined('T_GOTO') === false) { - define('T_GOTO', 1052); -} - -// Some PHP 5.4 tokens, replicated for lower versions. -if (defined('T_TRAIT') === false) { - define('T_TRAIT', 1053); -} - -/** - * The Tokens class contains weightings for tokens based on their - * probability of occurance in a file. - * - * The less the chance of a high occurance of an abitrary token, the higher - * the weighting. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -final class PHP_CodeSniffer_Tokens -{ - - /** - * The token weightings. - * - * @var array(int => int) - */ - public static $weightings = array( - T_CLASS => 1000, - T_INTERFACE => 1000, - T_TRAIT => 1000, - T_NAMESPACE => 1000, - T_FUNCTION => 100, - T_CLOSURE => 100, - - /* - Conditions. - */ - - T_WHILE => 50, - T_FOR => 50, - T_FOREACH => 50, - T_IF => 50, - T_ELSE => 50, - T_ELSEIF => 50, - T_WHILE => 50, - T_DO => 50, - T_TRY => 50, - T_CATCH => 50, - T_SWITCH => 50, - - T_SELF => 25, - T_PARENT => 25, - - /* - Operators and arithmetic. - */ - - T_BITWISE_AND => 8, - T_BITWISE_OR => 8, - - T_MULTIPLY => 5, - T_DIVIDE => 5, - T_PLUS => 5, - T_MINUS => 5, - T_MODULUS => 5, - T_POWER => 5, - - T_EQUAL => 5, - T_AND_EQUAL => 5, - T_CONCAT_EQUAL => 5, - T_DIV_EQUAL => 5, - T_MINUS_EQUAL => 5, - T_MOD_EQUAL => 5, - T_MUL_EQUAL => 5, - T_OR_EQUAL => 5, - T_PLUS_EQUAL => 5, - T_XOR_EQUAL => 5, - - T_BOOLEAN_AND => 5, - T_BOOLEAN_OR => 5, - - /* - Equality. - */ - - T_IS_EQUAL => 5, - T_IS_NOT_EQUAL => 5, - T_IS_IDENTICAL => 5, - T_IS_NOT_IDENTICAL => 5, - T_IS_SMALLER_OR_EQUAL => 5, - T_IS_GREATER_OR_EQUAL => 5, - ); - - /** - * Tokens that represent assignments. - * - * @var array(int) - */ - public static $assignmentTokens = array( - T_EQUAL, - T_AND_EQUAL, - T_CONCAT_EQUAL, - T_DIV_EQUAL, - T_MINUS_EQUAL, - T_MOD_EQUAL, - T_MUL_EQUAL, - T_PLUS_EQUAL, - T_XOR_EQUAL, - T_DOUBLE_ARROW, - ); - - /** - * Tokens that represent equality comparisons. - * - * @var array(int) - */ - public static $equalityTokens = array( - T_IS_EQUAL, - T_IS_NOT_EQUAL, - T_IS_IDENTICAL, - T_IS_NOT_IDENTICAL, - T_IS_SMALLER_OR_EQUAL, - T_IS_GREATER_OR_EQUAL, - ); - - /** - * Tokens that represent comparison operator. - * - * @var array(int) - */ - public static $comparisonTokens = array( - T_IS_EQUAL, - T_IS_IDENTICAL, - T_IS_NOT_EQUAL, - T_IS_NOT_IDENTICAL, - T_LESS_THAN, - T_GREATER_THAN, - T_IS_SMALLER_OR_EQUAL, - T_IS_GREATER_OR_EQUAL, - ); - - /** - * Tokens that represent arithmetic operators. - * - * @var array(int) - */ - public static $arithmeticTokens = array( - T_PLUS, - T_MINUS, - T_MULTIPLY, - T_DIVIDE, - T_MODULUS, - ); - - /** - * Tokens that represent casting. - * - * @var array(int) - */ - public static $castTokens = array( - T_INT_CAST, - T_STRING_CAST, - T_DOUBLE_CAST, - T_ARRAY_CAST, - T_BOOL_CAST, - T_OBJECT_CAST, - T_UNSET_CAST, - ); - - /** - * Token types that open parethesis. - * - * @var array(int) - */ - public static $parenthesisOpeners = array( - T_ARRAY, - T_FUNCTION, - T_CLOSURE, - T_WHILE, - T_FOR, - T_FOREACH, - T_SWITCH, - T_IF, - T_ELSEIF, - T_CATCH, - ); - - /** - * Tokens that are allowed to open scopes. - * - * @var array(int) - */ - public static $scopeOpeners = array( - T_CLASS, - T_INTERFACE, - T_TRAIT, - T_NAMESPACE, - T_FUNCTION, - T_CLOSURE, - T_IF, - T_SWITCH, - T_CASE, - T_DEFAULT, - T_WHILE, - T_ELSE, - T_ELSEIF, - T_FOR, - T_FOREACH, - T_DO, - T_TRY, - T_CATCH, - ); - - /** - * Tokens that represent scope modifiers. - * - * @var array(int) - */ - public static $scopeModifiers = array( - T_PRIVATE, - T_PUBLIC, - T_PROTECTED, - ); - - /** - * Tokens that perform operations. - * - * @var array(int) - */ - public static $operators = array( - T_MINUS, - T_PLUS, - T_MULTIPLY, - T_DIVIDE, - T_MODULUS, - T_POWER, - T_BITWISE_AND, - T_BITWISE_OR, - ); - - /** - * Tokens that perform boolean operations. - * - * @var array(int) - */ - public static $booleanOperators = array( - T_BOOLEAN_AND, - T_BOOLEAN_OR, - T_LOGICAL_AND, - T_LOGICAL_OR, - T_LOGICAL_XOR, - ); - - /** - * Tokens that open code blocks. - * - * @var array(int) - */ - public static $blockOpeners = array( - T_OPEN_CURLY_BRACKET, - T_OPEN_SQUARE_BRACKET, - T_OPEN_PARENTHESIS, - ); - - /** - * Tokens that don't represent code. - * - * @var array(int) - */ - public static $emptyTokens = array( - T_WHITESPACE, - T_COMMENT, - T_DOC_COMMENT, - ); - - /** - * Tokens that are comments. - * - * @var array(int) - */ - public static $commentTokens = array( - T_COMMENT, - T_DOC_COMMENT, - ); - - /** - * Tokens that represent strings. - * - * Note that T_STRINGS are NOT represented in this list. - * - * @var array(int) - */ - public static $stringTokens = array( - T_CONSTANT_ENCAPSED_STRING, - T_DOUBLE_QUOTED_STRING, - ); - - /** - * Tokens that represent brackets and parenthesis. - * - * @var array(int) - */ - public static $bracketTokens = array( - T_OPEN_CURLY_BRACKET, - T_CLOSE_CURLY_BRACKET, - T_OPEN_SQUARE_BRACKET, - T_CLOSE_SQUARE_BRACKET, - T_OPEN_PARENTHESIS, - T_CLOSE_PARENTHESIS, - ); - - /** - * Tokens that include files. - * - * @var array(int) - */ - public static $includeTokens = array( - T_REQUIRE_ONCE, - T_REQUIRE, - T_INCLUDE_ONCE, - T_INCLUDE, - ); - - /** - * Tokens that make up a heredoc string. - * - * @var array(int) - */ - public static $heredocTokens = array( - T_START_HEREDOC, - T_END_HEREDOC, - T_HEREDOC, - ); - - - /** - * A PHP_CodeSniffer_Tokens class cannot be constructed. - * - * Only static calls are allowed. - */ - private function __construct() - { - - }//end __construct() - - - /** - * Returns the highest weighted token type. - * - * Tokens are weighted by their approximate frequency of appearance in code - * - the less frequently they appear in the code, the higher the weighting. - * For example T_CLASS tokens apprear very infrequently in a file, and - * therefore have a high weighting. - * - * Returns false if there are no weightings for any of the specified tokens. - * - * @param array(int) $tokens The token types to get the highest weighted - * type for. - * - * @return int The highest weighted token. - */ - public static function getHighestWeightedToken(array $tokens) - { - $highest = -1; - $highestType = false; - - $weights = self::$weightings; - - foreach ($tokens as $token) { - if (isset($weights[$token]) === true) { - $weight = $weights[$token]; - } else { - $weight = 0; - } - - if ($weight > $highest) { - $highest = $weight; - $highestType = $token; - } - } - - return $highestType; - - }//end getHighestWeightedToken() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,2024 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -spl_autoload_register(array('PHP_CodeSniffer', 'autoload')); - -if (class_exists('PHP_CodeSniffer_Exception', true) === false) { - throw new Exception('Class PHP_CodeSniffer_Exception not found'); -} - -if (class_exists('PHP_CodeSniffer_File', true) === false) { - throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_File not found'); -} - -if (class_exists('PHP_CodeSniffer_Tokens', true) === false) { - throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_Tokens not found'); -} - -if (class_exists('PHP_CodeSniffer_CLI', true) === false) { - throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_CLI not found'); -} - -if (interface_exists('PHP_CodeSniffer_Sniff', true) === false) { - throw new PHP_CodeSniffer_Exception('Interface PHP_CodeSniffer_Sniff not found'); -} - -if (interface_exists('PHP_CodeSniffer_MultiFileSniff', true) === false) { - throw new PHP_CodeSniffer_Exception('Interface PHP_CodeSniffer_MultiFileSniff not found'); -} - -/** - * PHP_CodeSniffer tokenises PHP code and detects violations of a - * defined set of coding standards. - * - * Standards are specified by classes that implement the PHP_CodeSniffer_Sniff - * interface. A sniff registers what token types it wishes to listen for, then - * PHP_CodeSniffer encounters that token, the sniff is invoked and passed - * information about where the token was found in the stack, and the token stack - * itself. - * - * Sniff files and their containing class must be prefixed with Sniff, and - * have an extension of .php. - * - * Multiple PHP_CodeSniffer operations can be performed by re-calling the - * process function with different parameters. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: @package_version@ - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PHP_CodeSniffer -{ - - /** - * The file or directory that is currently being processed. - * - * @var string - */ - protected $file = ''; - - /** - * The files that have been processed. - * - * @var array(PHP_CodeSniffer_File) - */ - protected $files = array(); - - /** - * The directory to search for sniffs in. - * - * This is declared static because it is also used in the - * autoloader to look for sniffs outside the PHPCS install. - * This way, standards designed to be installed inside PHPCS can - * also be used from outside the PHPCS Standards directory. - * - * @var string - */ - protected static $standardDir = ''; - - /** - * The CLI object controlling the run. - * - * @var string - */ - public $cli = null; - - /** - * An array of sniffs that are being used to check files. - * - * @var array(PHP_CodeSniffer_Sniff) - */ - protected $listeners = array(); - - /** - * An array of rules from the ruleset.xml file. - * - * It may be empty, indicating that the ruleset does not override - * any of the default sniff settings. - * - * @var array - */ - protected $ruleset = array(); - - /** - * The listeners array, indexed by token type. - * - * @var array - */ - private $_tokenListeners = array( - 'file' => array(), - 'multifile' => array(), - ); - - /** - * An array of patterns to use for skipping files. - * - * @var array - */ - protected $ignorePatterns = array(); - - /** - * An array of extensions for files we will check. - * - * @var array - */ - public $allowedFileExtensions = array( - 'php' => 'PHP', - 'inc' => 'PHP', - 'js' => 'JS', - 'css' => 'CSS', - ); - - /** - * An array of variable types for param/var we will check. - * - * @var array(string) - */ - public static $allowedTypes = array( - 'array', - 'boolean', - 'float', - 'integer', - 'mixed', - 'object', - 'string', - ); - - - /** - * Constructs a PHP_CodeSniffer object. - * - * @param int $verbosity The verbosity level. - * 1: Print progress information. - * 2: Print tokenizer debug information. - * 3: Print sniff debug information. - * @param int $tabWidth The number of spaces each tab represents. - * If greater than zero, tabs will be replaced - * by spaces before testing each file. - * @param string $encoding The charset of the sniffed files. - * This is important for some reports that output - * with utf-8 encoding as you don't want it double - * encoding messages. - * @param bool $interactive If TRUE, will stop after each file with errors - * and wait for user input. - * - * @see process() - */ - public function __construct( - $verbosity=0, - $tabWidth=0, - $encoding='iso-8859-1', - $interactive=false - ) { - if (defined('PHP_CODESNIFFER_VERBOSITY') === false) { - define('PHP_CODESNIFFER_VERBOSITY', $verbosity); - } - - if (defined('PHP_CODESNIFFER_TAB_WIDTH') === false) { - define('PHP_CODESNIFFER_TAB_WIDTH', $tabWidth); - } - - if (defined('PHP_CODESNIFFER_ENCODING') === false) { - define('PHP_CODESNIFFER_ENCODING', $encoding); - } - - if (defined('PHP_CODESNIFFER_INTERACTIVE') === false) { - define('PHP_CODESNIFFER_INTERACTIVE', $interactive); - } - - if (defined('PHPCS_DEFAULT_ERROR_SEV') === false) { - define('PHPCS_DEFAULT_ERROR_SEV', 5); - } - - if (defined('PHPCS_DEFAULT_WARN_SEV') === false) { - define('PHPCS_DEFAULT_WARN_SEV', 5); - } - - // Change into a directory that we know about to stop any - // relative path conflicts. - if (defined('PHPCS_CWD') === false) { - define('PHPCS_CWD', getcwd()); - } - - chdir(dirname(__FILE__).'/CodeSniffer/'); - - // Set default CLI object in case someone is running us - // without using the command line script. - $this->cli = new PHP_CodeSniffer_CLI(); - $this->cli->errorSeverity = PHPCS_DEFAULT_ERROR_SEV; - $this->cli->warningSeverity = PHPCS_DEFAULT_WARN_SEV; - - }//end __construct() - - - /** - * Destructs a PHP_CodeSniffer object. - * - * Restores the current working directory to what it - * was before we started our run. - * - * @return void - */ - public function __destruct() - { - chdir(PHPCS_CWD); - - }//end __destruct() - - - /** - * Autoload static method for loading classes and interfaces. - * - * @param string $className The name of the class or interface. - * - * @return void - */ - public static function autoload($className) - { - if (substr($className, 0, 4) === 'PHP_') { - $newClassName = substr($className, 4); - } else { - $newClassName = $className; - } - - $path = str_replace('_', '/', $newClassName).'.php'; - - if (is_file(dirname(__FILE__).'/'.$path) === true) { - // Check standard file locations based on class name. - include dirname(__FILE__).'/'.$path; - } else if (is_file(dirname(__FILE__).'/CodeSniffer/Standards/'.$path) === true) { - // Check for included sniffs. - include dirname(__FILE__).'/CodeSniffer/Standards/'.$path; - } else if (self::$standardDir !== '' - && is_file(dirname(self::$standardDir).'/'.$path) === true - ) { - // Check standard file locations based on the passed standard directory. - include dirname(self::$standardDir).'/'.$path; - } else { - // Everything else. - @include $path; - } - - }//end autoload() - - - /** - * Sets an array of file extensions that we will allow checking of. - * - * If the extension is one of the defaults, a specific tokenizer - * will be used. Otherwise, the PHP tokenizer will be used for - * all extensions passed. - * - * @param array $extensions An array of file extensions. - * - * @return void - */ - public function setAllowedFileExtensions(array $extensions) - { - $newExtensions = array(); - foreach ($extensions as $ext) { - if (isset($this->allowedFileExtensions[$ext]) === true) { - $newExtensions[$ext] = $this->allowedFileExtensions[$ext]; - } else { - $newExtensions[$ext] = 'PHP'; - } - } - - $this->allowedFileExtensions = $newExtensions; - - }//end setAllowedFileExtensions() - - - /** - * Sets an array of ignore patterns that we use to skip files and folders. - * - * Patterns are not case sensitive. - * - * @param array $patterns An array of ignore patterns. - * - * @return void - */ - public function setIgnorePatterns(array $patterns) - { - $this->ignorePatterns = $patterns; - - }//end setIgnorePatterns() - - - /** - * Gets the array of ignore patterns. - * - * Optionally takes a listener to get ignore patterns specified - * for that sniff only. - * - * @param string $listener The listener to get patterns for. If NULL, all - * patterns are returned. - * - * @return array - */ - public function getIgnorePatterns($listener=null) - { - if ($listener === null) { - return $this->ignorePatterns; - } - - if (isset($this->ignorePatterns[$listener]) === true) { - return $this->ignorePatterns[$listener]; - } - - return array(); - - }//end getIgnorePatterns() - - - /** - * Sets the internal CLI object. - * - * @param object $cli The CLI object controlling the run. - * - * @return void - */ - public function setCli($cli) - { - $this->cli = $cli; - - }//end setCli() - - - /** - * Adds a file to the list of checked files. - * - * Checked files are used to generate error reports after the run. - * - * @param PHP_CodeSniffer_File $phpcsFile The file to add. - * - * @return void - */ - public function addFile(PHP_CodeSniffer_File $phpcsFile) - { - $this->files[] = $phpcsFile; - - }//end addFile() - - - /** - * Processes the files/directories that PHP_CodeSniffer was constructed with. - * - * @param string|array $files The files and directories to process. For - * directories, each sub directory will also - * be traversed for source files. - * @param string $standard The set of code sniffs we are testing - * against. - * @param array $sniffs The sniff names to restrict the allowed - * listeners to. - * @param boolean $local If true, don't recurse into directories. - * - * @return void - * @throws PHP_CodeSniffer_Exception If files or standard are invalid. - */ - public function process($files, $standard, array $sniffs=array(), $local=false) - { - if (is_array($files) === false) { - if (is_string($files) === false || $files === null) { - throw new PHP_CodeSniffer_Exception('$file must be a string'); - } - - $files = array($files); - } - - if (is_string($standard) === false || $standard === null) { - throw new PHP_CodeSniffer_Exception('$standard must be a string'); - } - - // Reset the members. - $this->listeners = array(); - $this->files = array(); - $this->ruleset = array(); - $this->_tokenListeners = array( - 'file' => array(), - 'multifile' => array(), - ); - - // Ensure this option is enabled or else line endings will not always - // be detected properly for files created on a Mac with the /r line ending. - ini_set('auto_detect_line_endings', true); - - if (PHP_CODESNIFFER_VERBOSITY > 0) { - // If this is a custom ruleset.xml file, load the standard name - // from the file. I know this looks a little ugly, but it is - // just when verbose output is on so we have to go to the effort - // of finding the correct name. - $standardName = basename($standard); - if (is_file($standard) === true) { - $ruleset = simplexml_load_file($standard); - if ($ruleset !== false) { - $standardName = (string) $ruleset['name']; - } - } else if (is_file(realpath(PHPCS_CWD.'/'.$standard)) === true) { - $ruleset = simplexml_load_file(realpath(PHPCS_CWD.'/'.$standard)); - if ($ruleset !== false) { - $standardName = (string) $ruleset['name']; - } - } - - echo "Registering sniffs in $standardName standard... "; - if (PHP_CODESNIFFER_VERBOSITY > 2) { - echo PHP_EOL; - } - }//end if - - $this->setTokenListeners($standard, $sniffs); - $this->populateCustomRules(); - $this->populateTokenListeners(); - - if (PHP_CODESNIFFER_VERBOSITY > 0) { - $numSniffs = count($this->listeners); - echo "DONE ($numSniffs sniffs registered)".PHP_EOL; - } - - // The SVN pre-commit calls process() to init the sniffs - // and ruleset so there may not be any files to process. - // But this has to come after that initial setup. - if (empty($files) === true) { - return; - } - - $reporting = new PHP_CodeSniffer_Reporting(); - $cliValues = $this->cli->getCommandLineValues(); - $showProgress = $cliValues['showProgress']; - - if (PHP_CODESNIFFER_VERBOSITY > 0) { - $numSniffs = count($this->listeners); - echo 'Creating file list... '; - } - - $todo = $this->getFilesToProcess($files, $local); - $numFiles = count($todo); - - if (PHP_CODESNIFFER_VERBOSITY > 0) { - $numSniffs = count($this->listeners); - echo "DONE ($numFiles files in queue)".PHP_EOL; - } - - $numProcessed = 0; - $dots = 0; - $maxLength = strlen($numFiles); - $lastDir = ''; - foreach ($todo as $file) { - $this->file = $file; - $currDir = dirname($file); - if ($lastDir !== $currDir) { - if (PHP_CODESNIFFER_VERBOSITY > 0) { - echo 'Changing into directory '.$currDir.PHP_EOL; - } - - $lastDir = $currDir; - } - - $phpcsFile = $this->processFile($file); - $numProcessed++; - - if (PHP_CODESNIFFER_VERBOSITY > 0 - || PHP_CODESNIFFER_INTERACTIVE === true - || $showProgress === false - ) { - continue; - } - - // Show progress information. - if ($phpcsFile === null) { - echo 'S'; - } else { - $errors = $phpcsFile->getErrorCount(); - $warnings = $phpcsFile->getWarningCount(); - if ($errors > 0) { - echo 'E'; - } else if ($warnings > 0) { - echo 'W'; - } else { - echo '.'; - } - } - - $dots++; - if ($dots === 60) { - $padding = ($maxLength - strlen($numProcessed)); - echo str_repeat(' ', $padding); - echo " $numProcessed / $numFiles".PHP_EOL; - $dots = 0; - } - }//end foreach - - if (PHP_CODESNIFFER_VERBOSITY === 0 - && PHP_CODESNIFFER_INTERACTIVE === false - && $showProgress === true - ) { - echo PHP_EOL.PHP_EOL; - } - - // Now process the multi-file sniffs, assuming there are - // multiple files being sniffed. - if (count($files) > 1 || is_dir($files[0]) === true) { - $this->processMulti(); - } - - }//end process() - - - /** - * Processes multi-file sniffs. - * - * @return void - */ - public function processMulti() - { - foreach ($this->_tokenListeners['multifile'] as $listener) { - // Set the name of the listener for error messages. - $activeListener = get_class($listener); - foreach ($this->files as $file) { - $file->setActiveListener($activeListener); - } - - $listener->process($this->files); - } - - }//end processMulti() - - - /** - * Sets installed sniffs in the coding standard being used. - * - * Traverses the standard directory for classes that implement the - * PHP_CodeSniffer_Sniff interface asks them to register. Each of the - * sniff's class names must be exact as the basename of the sniff file. - * If the standard is a file, will skip transversal and just load sniffs - * from the file. - * - * @param string $standard The name of the coding standard we are checking. - * Can also be a path to a custom standard dir - * containing a ruleset.xml file or can be a path - * to a custom ruleset file. - * @param array $sniffs The sniff names to restrict the allowed - * listeners to. - * - * @return void - * @throws PHP_CodeSniffer_Exception If the standard is not valid. - */ - public function setTokenListeners($standard, array $sniffs=array()) - { - if (is_dir($standard) === true) { - // This is an absolute path to a custom standard. - self::$standardDir = $standard; - $standard = basename($standard); - } else if (is_file($standard) === true) { - // Might be a custom ruleset file. - $ruleset = simplexml_load_file($standard); - if ($ruleset === false) { - throw new PHP_CodeSniffer_Exception("Ruleset $standard is not valid"); - } - - if (basename($standard) === 'ruleset.xml') { - // The ruleset uses the generic name, so this may actually - // be a complete standard with it's own sniffs. By setting the - // the standardDir to be the directory, we will process both - // the directory (for custom sniffs) and the ruleset.xml file - // (as it uses the generic name) in getSniffFiles. - self::$standardDir = dirname($standard); - } else { - // This is a custom ruleset file with a custom name, so we have - // to assume there are no custom sniffs to go with this otherwise - // we'd be recursing through directories on every run, even if - // we don't need to. - self::$standardDir = $standard; - } - - $standard = (string) $ruleset['name']; - } else { - self::$standardDir = realpath(dirname(__FILE__).'/CodeSniffer/Standards').DIRECTORY_SEPARATOR.$standard; - if (is_dir(self::$standardDir) === false) { - // This isn't looking good. Let's see if this - // is a relative path to a custom standard. - $path = realpath(PHPCS_CWD.'/'.$standard); - if (is_dir($path) === true) { - // This is a relative path to a custom standard. - self::$standardDir = $path; - $standard = basename($standard); - } else if (is_file($path) === true) { - // Might be a custom ruleset file. - $ruleset = simplexml_load_file($path); - if ($ruleset === false) { - throw new PHP_CodeSniffer_Exception("Ruleset $path is not valid"); - } - - // See comments in ELSE IF condition above for why we do this. - if (basename($path) === 'ruleset.xml') { - self::$standardDir = dirname($path); - } else { - self::$standardDir = $path; - } - - $standard = (string) $ruleset['name']; - } - } - }//end if - - $files = $this->getSniffFiles(self::$standardDir, $standard); - - if (empty($sniffs) === false) { - // Convert the allowed sniffs to lower case so - // they are easier to check. - foreach ($sniffs as &$sniff) { - $sniff = strtolower($sniff); - } - } - - $listeners = array(); - - foreach ($files as $file) { - // Work out where the position of /StandardName/Sniffs/... is - // so we can determine what the class will be called. - $sniffPos = strrpos($file, DIRECTORY_SEPARATOR.'Sniffs'.DIRECTORY_SEPARATOR); - if ($sniffPos === false) { - continue; - } - - $slashPos = strrpos(substr($file, 0, $sniffPos), DIRECTORY_SEPARATOR); - if ($slashPos === false) { - continue; - } - - $className = substr($file, ($slashPos + 1)); - $className = substr($className, 0, -4); - $className = str_replace(DIRECTORY_SEPARATOR, '_', $className); - - include_once $file; - - // If they have specified a list of sniffs to restrict to, check - // to see if this sniff is allowed. - $allowed = in_array(strtolower($className), $sniffs); - if (empty($sniffs) === false && $allowed === false) { - continue; - } - - $listeners[] = $className; - - if (PHP_CODESNIFFER_VERBOSITY > 2) { - echo "\tRegistered $className".PHP_EOL; - } - }//end foreach - - $this->listeners = $listeners; - - }//end setTokenListeners() - - - /** - * Return a list of sniffs that a coding standard has defined. - * - * Sniffs are found by recursing the standard directory and also by - * asking the standard for included sniffs. - * - * @param string $dir The directory where to look for the files. - * @param string $standard The name of the coding standard. If NULL, no - * included sniffs will be checked for. - * - * @return array - * @throws PHP_CodeSniffer_Exception If an included or excluded sniff does - * not exist. - */ - public function getSniffFiles($dir, $standard=null) - { - $ownSniffs = array(); - $includedSniffs = array(); - $excludedSniffs = array(); - - if (is_dir($dir) === true) { - $di = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir)); - foreach ($di as $file) { - $fileName = $file->getFilename(); - - // Skip hidden files. - if (substr($fileName, 0, 1) === '.') { - continue; - } - - // We are only interested in PHP and sniff files. - $fileParts = explode('.', $fileName); - if (array_pop($fileParts) !== 'php') { - continue; - } - - $basename = basename($fileName, '.php'); - if (substr($basename, -5) !== 'Sniff') { - continue; - } - - $ownSniffs[] = $file->getPathname(); - }//end foreach - }//end if - - if ($standard !== null) { - $rulesetPath = $dir; - if (is_dir($rulesetPath) === true) { - $rulesetPath .= '/ruleset.xml'; - } - - $ruleset = simplexml_load_file($rulesetPath); - if ($ruleset === false) { - throw new PHP_CodeSniffer_Exception("Ruleset $rulesetPath is not valid"); - } - - foreach ($ruleset->rule as $rule) { - $includedSniffs = array_merge($includedSniffs, $this->_expandRulesetReference($rule['ref'])); - - if (isset($rule->exclude) === true) { - foreach ($rule->exclude as $exclude) { - $excludedSniffs = array_merge($excludedSniffs, $this->_expandRulesetReference($exclude['name'])); - } - } - }//end foreach - }//end if - - $includedSniffs = array_unique($includedSniffs); - $excludedSniffs = array_unique($excludedSniffs); - - // Merge our own sniff list with our externally included - // sniff list, but filter out any excluded sniffs. - $files = array(); - foreach (array_merge($ownSniffs, $includedSniffs) as $sniff) { - if (in_array($sniff, $excludedSniffs) === true) { - continue; - } else { - $files[] = $sniff; - } - } - - return array_unique($files); - - }//end getSniffFiles() - - - /** - * Expand a ruleset sniff reference into a list of sniff files. - * - * @param string $sniff The sniff reference from the rulset.xml file. - * - * @return array - * @throws PHP_CodeSniffer_Exception If the sniff reference is invalid. - */ - private function _expandRulesetReference($sniff) - { - $referencedSniffs = array(); - - // Ignore internal sniffs as they are used to only - // hide and change internal messages. - if (substr($sniff, 0, 9) === 'Internal.') { - return $referencedSniffs; - } - - // As sniffs can't begin with a full stop, assume sniffs in - // this format are relative paths and attempt to convert them - // to absolute paths. If this fails, let the sniff path run through - // the normal checks and have it fail as normal. - if (substr($sniff, 0, 1) === '.') { - $standardDir = self::$standardDir; - if (substr(self::$standardDir, -4) === '.xml') { - $standardDir = dirname($standardDir); - } - - $realpath = realpath($standardDir.'/'.$sniff); - if ($realpath !== false) { - $sniff = $realpath; - } - } - - $isDir = false; - $path = $sniff; - if (is_dir($sniff) === true) { - // Referencing a custom standard. - $isDir = true; - $path = $sniff; - $sniff = basename($path); - } else if (is_file($sniff) === false) { - // See if this is a whole standard being referenced. - $path = realpath(dirname(__FILE__).'/CodeSniffer/Standards').DIRECTORY_SEPARATOR.$sniff; - if (is_dir($path) === true) { - $isDir = true; - } else { - // Work out the sniff path. - $parts = explode('.', $sniff); - if (count($parts) < 3) { - $error = "Referenced sniff $sniff does not exist"; - throw new PHP_CodeSniffer_Exception($error); - } - - $path = $parts[0].'/Sniffs/'.$parts[1].'/'.$parts[2].'Sniff.php'; - $path = realpath(dirname(__FILE__).'/CodeSniffer/Standards').DIRECTORY_SEPARATOR.$path; - if ($path === false && self::$standardDir !== '') { - // The sniff is not locally installed, so check if it is being - // referenced as a remote sniff outside the install. We do this by - // looking directly in the passed standard dir to see if it is - // installed in there. - $path = realpath(self::$standardDir.'/Sniffs/'.$parts[1].'/'.$parts[2].'Sniff.php'); - } - } - }//end if - - if ($isDir === true) { - if (self::isInstalledStandard($sniff) === true) { - // We are referencing a coding standard. - $referencedSniffs = $this->getSniffFiles($path, $sniff); - $this->populateCustomRules($path); - } else { - // We are referencing a whole directory of sniffs. - $referencedSniffs = $this->getSniffFiles($path); - } - } else { - if (is_file($path) === false) { - $error = "Referenced sniff $sniff does not exist"; - throw new PHP_CodeSniffer_Exception($error); - } - - if (substr($path, -9) === 'Sniff.php') { - // A single sniff. - $referencedSniffs[] = $path; - } else { - // Assume an external ruleset.xml file. - $referencedSniffs = $this->getSniffFiles($path, $sniff); - } - }//end if - - return $referencedSniffs; - - }//end _expandRulesetReference() - - - /** - * Sets installed sniffs in the coding standard being used. - * - * @param string $standard The name of the coding standard we are checking. - * Can also be a path to a custom ruleset.xml file. - * - * @return void - */ - public function populateCustomRules($standard=null) - { - if ($standard === null) { - $standard = self::$standardDir; - } - - if (is_file($standard) === false) { - $standard .= '/ruleset.xml'; - if (is_file($standard) === false) { - return; - } - } - - $ruleset = simplexml_load_file($standard); - foreach ($ruleset->rule as $rule) { - if (isset($rule['ref']) === false) { - continue; - } - - $code = (string) $rule['ref']; - - // Custom severity. - if (isset($rule->severity) === true) { - if (isset($this->ruleset[$code]) === false) { - $this->ruleset[$code] = array(); - } - - $this->ruleset[$code]['severity'] = (int) $rule->severity; - } - - // Custom message. - if (isset($rule->message) === true) { - if (isset($this->ruleset[$code]) === false) { - $this->ruleset[$code] = array(); - } - - $this->ruleset[$code]['message'] = (string) $rule->message; - } - - // Custom properties. - if (isset($rule->properties) === true) { - foreach ($rule->properties->property as $prop) { - if (isset($this->ruleset[$code]) === false) { - $this->ruleset[$code] = array( - 'properties' => array(), - ); - } else if (isset($this->ruleset[$code]['properties']) === false) { - $this->ruleset[$code]['properties'] = array(); - } - - $name = (string) $prop['name']; - if (isset($prop['type']) === true - && (string) $prop['type'] === 'array' - ) { - $value = (string) $prop['value']; - $this->ruleset[$code]['properties'][$name] = explode(',', $value); - } else { - $this->ruleset[$code]['properties'][$name] = (string) $prop['value']; - } - } - }//end if - - // Ignore patterns. - foreach ($rule->{'exclude-pattern'} as $pattern) { - if (isset($this->ignorePatterns[$code]) === false) { - $this->ignorePatterns[$code] = array(); - } - - $this->ignorePatterns[$code][] = (string) $pattern; - } - }//end foreach - - // Process custom ignore pattern rules. - foreach ($ruleset->{'exclude-pattern'} as $pattern) { - $this->ignorePatterns[] = (string) $pattern; - } - - }//end populateCustomRules() - - - /** - * Populates the array of PHP_CodeSniffer_Sniff's for this file. - * - * @return void - * @throws PHP_CodeSniffer_Exception If sniff registration fails. - */ - public function populateTokenListeners() - { - // Construct a list of listeners indexed by token being listened for. - $this->_tokenListeners = array( - 'file' => array(), - 'multifile' => array(), - ); - - foreach ($this->listeners as $listenerClass) { - $listener = new $listenerClass(); - - // Work out the internal code for this sniff. - $parts = explode('_', $listenerClass); - $code = $parts[0].'.'.$parts[2].'.'.$parts[3]; - $code = substr($code, 0, -5); - - // Set custom properties. - if (isset($this->ruleset[$code]['properties']) === true) { - foreach ($this->ruleset[$code]['properties'] as $name => $value) { - // Special case for booleans. - if ($value === 'true') { - $value = true; - } else if ($value === 'false') { - $value = false; - } - - $listener->$name = $value; - } - } - - if (($listener instanceof PHP_CodeSniffer_Sniff) === true) { - $tokens = $listener->register(); - if (is_array($tokens) === false) { - $msg = "Sniff $listenerClass register() method must return an array"; - throw new PHP_CodeSniffer_Exception($msg); - } - - foreach ($tokens as $token) { - if (isset($this->_tokenListeners['file'][$token]) === false) { - $this->_tokenListeners['file'][$token] = array(); - } - - if (in_array($listener, $this->_tokenListeners['file'][$token], true) === false) { - $this->_tokenListeners['file'][$token][] = $listener; - } - } - } else if (($listener instanceof PHP_CodeSniffer_MultiFileSniff) === true) { - $this->_tokenListeners['multifile'][] = $listener; - } - }//end foreach - - }//end populateTokenListeners() - - - /** - * Get a list of files that will be processed. - * - * If passed directories, this method will find all files within them. - * The method will also perform file extension and ignore pattern filtering. - * - * @param string $paths A list of file or directory paths to process. - * @param boolean $local If true, only process 1 level of files in directories - * - * @return array - * @throws Exception If there was an error opening a directory. - * @see shouldProcessFile() - */ - public function getFilesToProcess($paths, $local=false) - { - $files = array(); - - foreach ($paths as $path) { - if (is_dir($path) === true) { - if ($local === true) { - $di = new DirectoryIterator($path); - } else { - $di = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)); - } - - foreach ($di as $file) { - // Check if the file exists after all symlinks are reolved. - $filePath = realpath($file->getPathname()); - if ($filePath === false) { - continue; - } - - if (is_dir($filePath) === true) { - continue; - } - - if ($this->shouldProcessFile($file->getPathname()) === false) { - continue; - } - - $files[] = $file->getPathname(); - }//end foreach - } else { - if ($this->shouldIgnoreFile($path) === true) { - continue; - } - - $files[] = $path; - }//end if - }//end foreach - - return $files; - - }//end getFilesToProcess() - - - /** - * Checks filtering rules to see if a file should be checked. - * - * Checks both file extension filters and path ignore filters. - * - * @param string $path The path to the file being checked. - * - * @return bool - */ - public function shouldProcessFile($path) - { - // Check that the file's extension is one we are checking. - // We are strict about checking the extension and we don't - // let files through with no extension or that start with a dot. - $fileName = basename($path); - $fileParts = explode('.', $fileName); - if ($fileParts[0] === $fileName || $fileParts[0] === '') { - return false; - } - - // Checking multi-part file extensions, so need to create a - // complete extension list and make sure one is allowed. - $extensions = array(); - array_shift($fileParts); - foreach ($fileParts as $part) { - $extensions[implode('.', $fileParts)] = 1; - array_shift($fileParts); - } - - $matches = array_intersect_key($extensions, $this->allowedFileExtensions); - if (empty($matches) === true) { - return false; - } - - // If the file's path matches one of our ignore patterns, skip it. - if ($this->shouldIgnoreFile($path) === true) { - return false; - } - - return true; - - }//end shouldProcessFile() - - - /** - * Checks filtering rules to see if a file should be ignored. - * - * @param string $path The path to the file being checked. - * - * @return bool - */ - public function shouldIgnoreFile($path) - { - foreach ($this->ignorePatterns as $pattern) { - if (is_array($pattern) === true) { - // A sniff specific ignore pattern. - continue; - } - - $replacements = array( - '\\,' => ',', - '*' => '.*', - ); - - $pattern = strtr($pattern, $replacements); - if (preg_match("|{$pattern}|i", $path) === 1) { - return true; - } - }//end foreach - - return false; - - }//end shouldIgnoreFile() - - - /** - * Run the code sniffs over a single given file. - * - * Processes the file and runs the PHP_CodeSniffer sniffs to verify that it - * conforms with the standard. Returns the processed file object, or NULL - * if no file was processed due to error. - * - * @param string $file The file to process. - * @param string $contents The contents to parse. If NULL, the content - * is taken from the file system. - * - * @return PHP_CodeSniffer_File - * @throws PHP_CodeSniffer_Exception If the file could not be processed. - * @see _processFile() - */ - public function processFile($file, $contents=null) - { - if ($contents === null && file_exists($file) === false) { - throw new PHP_CodeSniffer_Exception("Source file $file does not exist"); - } - - $filePath = realpath($file); - if ($filePath === false) { - $filePath = $file; - } - - // Before we go and spend time tokenizing this file, just check - // to see if there is a tag up top to indicate that the whole - // file should be ignored. It must be on one of the first two lines. - $firstContent = $contents; - if ($contents === null && is_readable($filePath) === true) { - $handle = fopen($filePath, 'r'); - if ($handle !== false) { - $firstContent = fgets($handle); - $firstContent .= fgets($handle); - fclose($handle); - } - } - - if (strpos($firstContent, '@codingStandardsIgnoreFile') !== false) { - // We are ignoring the whole file. - if (PHP_CODESNIFFER_VERBOSITY > 0) { - echo 'Ignoring '.basename($filePath).PHP_EOL; - } - - return null; - } - - try { - $phpcsFile = $this->_processFile($file, $contents); - } catch (Exception $e) { - $trace = $e->getTrace(); - - $filename = $trace[0]['args'][0]; - if (is_object($filename) === true - && get_class($filename) === 'PHP_CodeSniffer_File' - ) { - $filename = $filename->getFilename(); - } else if (is_numeric($filename) === true) { - // See if we can find the PHP_CodeSniffer_File object. - foreach ($trace as $data) { - if (isset($data['args'][0]) === true && ($data['args'][0] instanceof PHP_CodeSniffer_File) === true) { - $filename = $data['args'][0]->getFilename(); - } - } - } else if (is_string($filename) === false) { - $filename = (string) $filename; - } - - $error = 'An error occurred during processing; checking has been aborted. The error message was: '.$e->getMessage(); - - $phpcsFile = new PHP_CodeSniffer_File( - $filename, - $this->listeners, - $this->allowedFileExtensions, - $this->ruleset, - $this - ); - - $this->addFile($phpcsFile); - $phpcsFile->addError($error, null); - }//end try - - if (PHP_CODESNIFFER_INTERACTIVE === false) { - return $phpcsFile; - } - - /* - Running interactively. - Print the error report for the current file and then wait for user input. - */ - - $reporting = new PHP_CodeSniffer_Reporting(); - $cliValues = $this->cli->getCommandLineValues(); - - // Get current violations and then clear the list to make sure - // we only print violations for a single file each time. - $numErrors = null; - while ($numErrors !== 0) { - $filesViolations = $this->getFilesErrors(); - $this->files = array(); - - $numErrors = $reporting->printReport( - 'full', - $filesViolations, - $cliValues['showSources'], - null, - $cliValues['reportWidth'] - ); - - if ($numErrors === 0) { - continue; - } - - echo ' to recheck, [s] to skip or [q] to quit : '; - $input = fgets(STDIN); - $input = trim($input); - - switch ($input) { - case 's': - break; - case 'q': - exit(0); - break; - default: - // Repopulate the sniffs because some of them save their state - // and only clear it when the file changes, but we are rechecking - // the same file. - $this->populateTokenListeners(); - $phpcsFile = $this->_processFile($file, $contents); - break; - } - }//end while - - return $phpcsFile; - - }//end processFile() - - - /** - * Process the sniffs for a single file. - * - * Does raw processing only. No interactive support or error checking. - * - * @param string $file The file to process. - * @param string $contents The contents to parse. If NULL, the content - * is taken from the file system. - * - * @return PHP_CodeSniffer_File - * @see processFile() - */ - private function _processFile($file, $contents) - { - if (PHP_CODESNIFFER_VERBOSITY > 0) { - $startTime = time(); - echo 'Processing '.basename($file).' '; - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo PHP_EOL; - } - } - - $phpcsFile = new PHP_CodeSniffer_File( - $file, - $this->_tokenListeners['file'], - $this->allowedFileExtensions, - $this->ruleset, - $this - ); - $this->addFile($phpcsFile); - $phpcsFile->start($contents); - - // Clean up the test if we can to save memory. This can't be done if - // we need to leave the files around for multi-file sniffs. - if (PHP_CODESNIFFER_INTERACTIVE === false - && empty($this->_tokenListeners['multifile']) === true - ) { - $phpcsFile->cleanUp(); - } - - if (PHP_CODESNIFFER_VERBOSITY > 0) { - $timeTaken = (time() - $startTime); - if ($timeTaken === 0) { - echo 'DONE in < 1 second'; - } else if ($timeTaken === 1) { - echo 'DONE in 1 second'; - } else { - echo "DONE in $timeTaken seconds"; - } - - $errors = $phpcsFile->getErrorCount(); - $warnings = $phpcsFile->getWarningCount(); - echo " ($errors errors, $warnings warnings)".PHP_EOL; - } - - return $phpcsFile; - - }//end _processFile() - - - /** - * Gives collected violations for reports. - * - * @return array - */ - public function getFilesErrors() - { - $files = array(); - foreach ($this->files as $file) { - $files[$file->getFilename()] - = array( - 'warnings' => $file->getWarnings(), - 'errors' => $file->getErrors(), - 'numWarnings' => $file->getWarningCount(), - 'numErrors' => $file->getErrorCount(), - ); - } - - return $files; - - }//end getFilesErrors() - - - /** - * Generates documentation for a coding standard. - * - * @param string $standard The standard to generate docs for - * @param array $sniffs A list of sniffs to limit the docs to. - * @param string $generator The name of the generator class to use. - * - * @return void - */ - public function generateDocs($standard, array $sniffs=array(), $generator='Text') - { - if (class_exists('PHP_CodeSniffer_DocGenerators_'.$generator, true) === false) { - throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_DocGenerators_'.$generator.' not found'); - } - - $class = "PHP_CodeSniffer_DocGenerators_$generator"; - $generator = new $class($standard, $sniffs); - - $generator->generate(); - - }//end generateDocs() - - - /** - * Returns the PHP_CodeSniffer file objects. - * - * @return array(PHP_CodeSniffer_File) - */ - public function getFiles() - { - return $this->files; - - }//end getFiles() - - - /** - * Gets the array of PHP_CodeSniffer_Sniff's. - * - * @return array(PHP_CodeSniffer_Sniff) - */ - public function getSniffs() - { - return $this->listeners; - - }//end getSniffs() - - - /** - * Gets the array of PHP_CodeSniffer_Sniff's indexed by token type. - * - * @return array() - */ - public function getTokenSniffs() - { - return $this->_tokenListeners; - - }//end getTokenSniffs() - - - /** - * Takes a token produced from token_get_all() and produces a - * more uniform token. - * - * Note that this method also resolves T_STRING tokens into more descrete - * types, therefore there is no need to call resolveTstringToken() - * - * @param string|array $token The token to convert. - * - * @return array The new token. - */ - public static function standardiseToken($token) - { - if (is_array($token) === false) { - $newToken = self::resolveSimpleToken($token); - } else { - switch ($token[0]) { - case T_STRING: - // Some T_STRING tokens can be more specific. - $newToken = self::resolveTstringToken($token); - break; - case T_CURLY_OPEN: - $newToken = array( - 'code' => T_OPEN_CURLY_BRACKET, - 'content' => $token[1], - 'type' => 'T_OPEN_CURLY_BRACKET', - ); - break; - default: - $newToken = array( - 'code' => $token[0], - 'content' => $token[1], - 'type' => token_name($token[0]), - ); - break; - }//end switch - }//end if - - return $newToken; - - }//end standardiseToken() - - - /** - * Converts T_STRING tokens into more usable token names. - * - * The token should be produced using the token_get_all() function. - * Currently, not all T_STRING tokens are converted. - * - * @param string|array $token The T_STRING token to convert as constructed - * by token_get_all(). - * - * @return array The new token. - */ - public static function resolveTstringToken(array $token) - { - $newToken = array(); - switch (strtolower($token[1])) { - case 'false': - $newToken['type'] = 'T_FALSE'; - break; - case 'true': - $newToken['type'] = 'T_TRUE'; - break; - case 'null': - $newToken['type'] = 'T_NULL'; - break; - case 'self': - $newToken['type'] = 'T_SELF'; - break; - case 'parent': - $newToken['type'] = 'T_PARENT'; - break; - default: - $newToken['type'] = 'T_STRING'; - break; - } - - $newToken['code'] = constant($newToken['type']); - $newToken['content'] = $token[1]; - - return $newToken; - - }//end resolveTstringToken() - - - /** - * Converts simple tokens into a format that conforms to complex tokens - * produced by token_get_all(). - * - * Simple tokens are tokens that are not in array form when produced from - * token_get_all(). - * - * @param string $token The simple token to convert. - * - * @return array The new token in array format. - */ - public static function resolveSimpleToken($token) - { - $newToken = array(); - - switch ($token) { - case '{': - $newToken['type'] = 'T_OPEN_CURLY_BRACKET'; - break; - case '}': - $newToken['type'] = 'T_CLOSE_CURLY_BRACKET'; - break; - case '[': - $newToken['type'] = 'T_OPEN_SQUARE_BRACKET'; - break; - case ']': - $newToken['type'] = 'T_CLOSE_SQUARE_BRACKET'; - break; - case '(': - $newToken['type'] = 'T_OPEN_PARENTHESIS'; - break; - case ')': - $newToken['type'] = 'T_CLOSE_PARENTHESIS'; - break; - case ':': - $newToken['type'] = 'T_COLON'; - break; - case '.': - $newToken['type'] = 'T_STRING_CONCAT'; - break; - case '?': - $newToken['type'] = 'T_INLINE_THEN'; - break; - case ';': - $newToken['type'] = 'T_SEMICOLON'; - break; - case '=': - $newToken['type'] = 'T_EQUAL'; - break; - case '*': - $newToken['type'] = 'T_MULTIPLY'; - break; - case '/': - $newToken['type'] = 'T_DIVIDE'; - break; - case '+': - $newToken['type'] = 'T_PLUS'; - break; - case '-': - $newToken['type'] = 'T_MINUS'; - break; - case '%': - $newToken['type'] = 'T_MODULUS'; - break; - case '^': - $newToken['type'] = 'T_POWER'; - break; - case '&': - $newToken['type'] = 'T_BITWISE_AND'; - break; - case '|': - $newToken['type'] = 'T_BITWISE_OR'; - break; - case '<': - $newToken['type'] = 'T_LESS_THAN'; - break; - case '>': - $newToken['type'] = 'T_GREATER_THAN'; - break; - case '!': - $newToken['type'] = 'T_BOOLEAN_NOT'; - break; - case ',': - $newToken['type'] = 'T_COMMA'; - break; - case '@': - $newToken['type'] = 'T_ASPERAND'; - break; - case '$': - $newToken['type'] = 'T_DOLLAR'; - break; - case '`': - $newToken['type'] = 'T_BACKTICK'; - break; - default: - $newToken['type'] = 'T_NONE'; - break; - }//end switch - - $newToken['code'] = constant($newToken['type']); - $newToken['content'] = $token; - - return $newToken; - - }//end resolveSimpleToken() - - - /** - * Returns true if the specified string is in the camel caps format. - * - * @param string $string The string the verify. - * @param boolean $classFormat If true, check to see if the string is in the - * class format. Class format strings must start - * with a capital letter and contain no - * underscores. - * @param boolean $public If true, the first character in the string - * must be an a-z character. If false, the - * character must be an underscore. This - * argument is only applicable if $classFormat - * is false. - * @param boolean $strict If true, the string must not have two captial - * letters next to each other. If false, a - * relaxed camel caps policy is used to allow - * for acronyms. - * - * @return boolean - */ - public static function isCamelCaps( - $string, - $classFormat=false, - $public=true, - $strict=true - ) { - // Check the first character first. - if ($classFormat === false) { - if ($public === false) { - $legalFirstChar = '[_][a-z]'; - } else { - $legalFirstChar = '[a-z]'; - } - } else { - $legalFirstChar = '[A-Z]'; - } - - if (preg_match("|^$legalFirstChar|", $string) === 0) { - return false; - } - - // Check that the name only contains legal characters. - $legalChars = 'a-zA-Z0-9'; - if (preg_match("|[^$legalChars]|", substr($string, 1)) > 0) { - return false; - } - - if ($strict === true) { - // Check that there are not two captial letters next to each other. - $length = strlen($string); - $lastCharWasCaps = $classFormat; - - for ($i = 1; $i < $length; $i++) { - $ascii = ord($string{$i}); - if ($ascii >= 48 && $ascii <= 57) { - // The character is a number, so it cant be a captial. - $isCaps = false; - } else { - if (strtoupper($string{$i}) === $string{$i}) { - $isCaps = true; - } else { - $isCaps = false; - } - } - - if ($isCaps === true && $lastCharWasCaps === true) { - return false; - } - - $lastCharWasCaps = $isCaps; - } - }//end if - - return true; - - }//end isCamelCaps() - - - /** - * Returns true if the specified string is in the underscore caps format. - * - * @param string $string The string to verify. - * - * @return boolean - */ - public static function isUnderscoreName($string) - { - // If there are space in the name, it can't be valid. - if (strpos($string, ' ') !== false) { - return false; - } - - $validName = true; - $nameBits = explode('_', $string); - - if (preg_match('|^[A-Z]|', $string) === 0) { - // Name does not begin with a capital letter. - $validName = false; - } else { - foreach ($nameBits as $bit) { - if ($bit === '') { - continue; - } - - if ($bit{0} !== strtoupper($bit{0})) { - $validName = false; - break; - } - } - } - - return $validName; - - }//end isUnderscoreName() - - - /** - * Returns a valid variable type for param/var tag. - * - * If type is not one of the standard type, it must be a custom type. - * Returns the correct type name suggestion if type name is invalid. - * - * @param string $varType The variable type to process. - * - * @return string - */ - public static function suggestType($varType) - { - if ($varType === '') { - return ''; - } - - if (in_array($varType, self::$allowedTypes) === true) { - return $varType; - } else { - $lowerVarType = strtolower($varType); - switch ($lowerVarType) { - case 'bool': - return 'boolean'; - case 'double': - case 'real': - return 'float'; - case 'int': - return 'integer'; - case 'array()': - return 'array'; - }//end switch - - if (strpos($lowerVarType, 'array(') !== false) { - // Valid array declaration: - // array, array(type), array(type1 => type2). - $matches = array(); - $pattern = '/^array\(\s*([^\s^=^>]*)(\s*=>\s*(.*))?\s*\)/i'; - if (preg_match($pattern, $varType, $matches) !== 0) { - $type1 = ''; - if (isset($matches[1]) === true) { - $type1 = $matches[1]; - } - - $type2 = ''; - if (isset($matches[3]) === true) { - $type2 = $matches[3]; - } - - $type1 = self::suggestType($type1); - $type2 = self::suggestType($type2); - if ($type2 !== '') { - $type2 = ' => '.$type2; - } - - return "array($type1$type2)"; - } else { - return 'array'; - }//end if - } else if (in_array($lowerVarType, self::$allowedTypes) === true) { - // A valid type, but not lower cased. - return $lowerVarType; - } else { - // Must be a custom type name. - return $varType; - }//end if - }//end if - - }//end suggestType() - - - /** - * Get a list of all coding standards installed. - * - * Coding standards are directories located in the - * CodeSniffer/Standards directory. Valid coding standards - * include a Sniffs subdirectory. - * - * @param boolean $includeGeneric If true, the special "Generic" - * coding standard will be included - * if installed. - * @param string $standardsDir A specific directory to look for standards - * in. If not specified, PHP_CodeSniffer will - * look in its default location. - * - * @return array - * @see isInstalledStandard() - */ - public static function getInstalledStandards( - $includeGeneric=false, - $standardsDir='' - ) { - $installedStandards = array(); - - if ($standardsDir === '') { - $standardsDir = dirname(__FILE__).'/CodeSniffer/Standards'; - } - - $di = new DirectoryIterator($standardsDir); - foreach ($di as $file) { - if ($file->isDir() === true && $file->isDot() === false) { - $filename = $file->getFilename(); - - // Ignore the special "Generic" standard. - if ($includeGeneric === false && $filename === 'Generic') { - continue; - } - - // Valid coding standard dirs include a standard class. - $csFile = $file->getPathname().'/ruleset.xml'; - if (is_file($csFile) === true) { - // We found a coding standard directory. - $installedStandards[] = $filename; - } - } - } - - return $installedStandards; - - }//end getInstalledStandards() - - - /** - * Determine if a standard is installed. - * - * Coding standards are directories located in the - * CodeSniffer/Standards directory. Valid coding standards - * include a Sniffs subdirectory. - * - * @param string $standard The name of the coding standard. - * - * @return boolean - * @see getInstalledStandards() - */ - public static function isInstalledStandard($standard) - { - $standardDir = dirname(__FILE__); - $standardDir .= '/CodeSniffer/Standards/'.$standard; - if (is_file($standardDir.'/ruleset.xml') === true) { - return true; - } else { - // This could be a custom standard, installed outside our - // standards directory. - $ruleset = rtrim($standard, ' /\\').DIRECTORY_SEPARATOR.'ruleset.xml'; - if (is_file($ruleset) === true) { - return true; - } - - // Might also be an actual ruleset file itself. - // If it has an XML extension, let's at least try it. - if (is_file($standard) === true - && substr(strtolower($standard), -4) === '.xml' - ) { - return true; - } - } - - return false; - - }//end isInstalledStandard() - - - /** - * Get a single config value. - * - * Config data is stored in the data dir, in a file called - * CodeSniffer.conf. It is a simple PHP array. - * - * @param string $key The name of the config value. - * - * @return string - * @see setConfigData() - * @see getAllConfigData() - */ - public static function getConfigData($key) - { - $phpCodeSnifferConfig = self::getAllConfigData(); - - if ($phpCodeSnifferConfig === null) { - return null; - } - - if (isset($phpCodeSnifferConfig[$key]) === false) { - return null; - } - - return $phpCodeSnifferConfig[$key]; - - }//end getConfigData() - - - /** - * Set a single config value. - * - * Config data is stored in the data dir, in a file called - * CodeSniffer.conf. It is a simple PHP array. - * - * @param string $key The name of the config value. - * @param string|null $value The value to set. If null, the config - * entry is deleted, reverting it to the - * default value. - * @param boolean $temp Set this config data temporarily for this - * script run. This will not write the config - * data to the config file. - * - * @return boolean - * @see getConfigData() - * @throws PHP_CodeSniffer_Exception If the config file can not be written. - */ - public static function setConfigData($key, $value, $temp=false) - { - if ($temp === false) { - $configFile = dirname(__FILE__).'/CodeSniffer.conf'; - if (is_file($configFile) === false) { - $configFile = '@data_dir@/PHP_CodeSniffer/CodeSniffer.conf'; - } - - if (is_file($configFile) === true - && is_writable($configFile) === false - ) { - $error = "Config file $configFile is not writable"; - throw new PHP_CodeSniffer_Exception($error); - } - } - - $phpCodeSnifferConfig = self::getAllConfigData(); - - if ($value === null) { - if (isset($phpCodeSnifferConfig[$key]) === true) { - unset($phpCodeSnifferConfig[$key]); - } - } else { - $phpCodeSnifferConfig[$key] = $value; - } - - if ($temp === false) { - $output = '<'.'?php'."\n".' $phpCodeSnifferConfig = '; - $output .= var_export($phpCodeSnifferConfig, true); - $output .= "\n?".'>'; - - if (file_put_contents($configFile, $output) === false) { - return false; - } - } - - $GLOBALS['PHP_CODESNIFFER_CONFIG_DATA'] = $phpCodeSnifferConfig; - - return true; - - }//end setConfigData() - - - /** - * Get all config data in an array. - * - * @return string - * @see getConfigData() - */ - public static function getAllConfigData() - { - if (isset($GLOBALS['PHP_CODESNIFFER_CONFIG_DATA']) === true) { - return $GLOBALS['PHP_CODESNIFFER_CONFIG_DATA']; - } - - $configFile = dirname(__FILE__).'/CodeSniffer.conf'; - if (is_file($configFile) === false) { - $configFile = '@data_dir@/PHP_CodeSniffer/CodeSniffer.conf'; - } - - if (is_file($configFile) === false) { - return null; - } - - include $configFile; - $GLOBALS['PHP_CODESNIFFER_CONFIG_DATA'] = $phpCodeSnifferConfig; - return $GLOBALS['PHP_CODESNIFFER_CONFIG_DATA']; - - }//end getAllConfigData() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer.sample.conf php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer.sample.conf --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer.sample.conf 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/CodeSniffer.sample.conf 1970-01-01 00:00:00.000000000 +0000 @@ -1,6 +0,0 @@ - '/path/to/ZendStudio/bin/ZendCodeAnalyzer', - 'default_standard' => 'Zend', -) -?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/scripts/phpcs php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/scripts/phpcs --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/scripts/phpcs 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/scripts/phpcs 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -#!@php_bin@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -error_reporting(E_ALL | E_STRICT); - -// Optionally use PHP_Timer to print time/memory stats for the run. -// Note that the reports are the ones who actually print the data -// as they decide if it is ok to print this data to screen. -@include_once 'PHP/Timer.php'; -if (class_exists('PHP_Timer', false) === true) { - PHP_Timer::start(); -} - -if (is_file(dirname(__FILE__).'/../CodeSniffer/CLI.php') === true) { - include_once dirname(__FILE__).'/../CodeSniffer/CLI.php'; -} else { - include_once 'PHP/CodeSniffer/CLI.php'; -} - -$phpcs = new PHP_CodeSniffer_CLI(); -$phpcs->checkRequirements(); - -$numErrors = $phpcs->process(); -if ($numErrors === 0) { - exit(0); -} else { - exit(1); -} - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/scripts/phpcs-svn-pre-commit php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/scripts/phpcs-svn-pre-commit --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/scripts/phpcs-svn-pre-commit 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/scripts/phpcs-svn-pre-commit 1970-01-01 00:00:00.000000000 +0000 @@ -1,221 +0,0 @@ -#!@php_bin@ - - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -if (is_file(dirname(__FILE__).'/../CodeSniffer/CLI.php') === true) { - include_once dirname(__FILE__).'/../CodeSniffer/CLI.php'; -} else { - include_once 'PHP/CodeSniffer/CLI.php'; -} - -define('PHP_CODESNIFFER_SVNLOOK', '/usr/bin/svnlook'); - - -/** - * A class to process command line options. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Jack Bates - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: @package_version@ - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PHP_CodeSniffer_SVN_Hook extends PHP_CodeSniffer_CLI -{ - - - /** - * Get a list of default values for all possible command line arguments. - * - * @return array - */ - public function getDefaults() - { - $defaults = parent::getDefaults(); - - $defaults['svnArgs'] = array(); - return $defaults; - - }//end getDefaults() - - - /** - * Processes an unknown command line argument. - * - * All unknown args are sent to SVN commands. - * - * @param string $arg The command line argument. - * @param int $pos The position of the argument on the command line. - * @param array $values An array of values determined from CLI args. - * - * @return array The updated CLI values. - * @see getCommandLineValues() - */ - public function processUnknownArgument($arg, $pos, $values) - { - $values['svnArgs'][] = escapeshellarg($arg); - return $values; - - }//end processUnknownArgument() - - - /** - * Runs PHP_CodeSniffer over files are directories. - * - * @param array $values An array of values determined from CLI args. - * - * @return int The number of error and warning messages shown. - * @see getCommandLineValues() - */ - public function process($values=array()) - { - if (empty($values) === true) { - $values = parent::getCommandLineValues(); - } - - // Get list of files in this transaction. - $command = PHP_CODESNIFFER_SVNLOOK.' changed '.implode(' ', $values['svnArgs']); - $handle = popen($command, 'r'); - if ($handle === false) { - echo 'ERROR: Could not execute "'.$command.'"'.PHP_EOL.PHP_EOL; - exit(2); - } - - $contents = stream_get_contents($handle); - fclose($handle); - - // Do not check deleted paths. - $contents = preg_replace('/^D.*/m', null, $contents); - - // Drop the four characters representing the action which precede the path on - // each line. - $contents = preg_replace('/^.{4}/m', null, $contents); - - $values['standard'] = $this->validateStandard($values['standard']); - if (PHP_CodeSniffer::isInstalledStandard($values['standard']) === false) { - // They didn't select a valid coding standard, so help them - // out by letting them know which standards are installed. - echo 'ERROR: the "'.$values['standard'].'" coding standard is not installed. '; - $this->printInstalledStandards(); - exit(2); - } - - $phpcs = new PHP_CodeSniffer( - $values['verbosity'], - $values['tabWidth'], - $values['encoding'] - ); - - // Set file extensions if they were specified. Otherwise, - // let PHP_CodeSniffer decide on the defaults. - if (empty($values['extensions']) === false) { - $phpcs->setAllowedFileExtensions($values['extensions']); - } - - // Set ignore patterns if they were specified. - if (empty($values['ignored']) === false) { - $phpcs->setIgnorePatterns($values['ignored']); - } - - // Set some convenience member vars. - if ($values['errorSeverity'] === null) { - $this->errorSeverity = PHPCS_DEFAULT_ERROR_SEV; - } else { - $this->errorSeverity = $values['errorSeverity']; - } - - if ($values['warningSeverity'] === null) { - $this->warningSeverity = PHPCS_DEFAULT_WARN_SEV; - } else { - $this->warningSeverity = $values['warningSeverity']; - } - - // Initialize PHP_CodeSniffer listeners but don't process any files. - $phpcs->setCli($this); - $phpcs->process(array(), $values['standard'], $values['sniffs']); - - // Need double quotes around the following regex beause the vertical whitespace - // char is not always treated correctly for whatever reason. - foreach (preg_split("/\v|\n/", $contents, -1, PREG_SPLIT_NO_EMPTY) as $path) { - // No need to process folders as each changed file is checked. - if (substr($path, -1) === '/') { - continue; - } - - // We need to check ignore rules ourself because they are - // not checked when processing a single file. - if ($phpcs->shouldProcessFile($path) === false) { - continue; - } - - // Get the contents of each file, as it would be after this transaction. - $command = PHP_CODESNIFFER_SVNLOOK.' cat '.implode(' ', $values['svnArgs']).' '.escapeshellarg($path); - $handle = popen($command, 'r'); - if ($handle === false) { - echo 'ERROR: Could not execute "'.$command.'"'.PHP_EOL.PHP_EOL; - exit(2); - } - - $contents = stream_get_contents($handle); - fclose($handle); - - $phpcs->processFile($path, $contents); - }//end foreach - - return $this->printErrorReport( - $phpcs, - $values['reports'], - $values['showSources'], - $values['reportFile'], - $values['reportWidth'] - ); - - }//end process() - - - /** - * Prints out the usage information for this script. - * - * @return void - */ - public function printUsage() - { - parent::printUsage(); - - echo PHP_EOL; - echo ' Each additional argument is passed to the `svnlook changed ...`'.PHP_EOL; - echo ' and `svnlook cat ...` commands. The report is printed on standard output,'.PHP_EOL; - echo ' however Subversion displays only standard error to the user, so in a'.PHP_EOL; - echo ' pre-commit hook, this script should be invoked as follows:'.PHP_EOL; - echo PHP_EOL; - echo ' '.basename($_SERVER['argv'][0]).' ... "$REPOS" -t "$TXN" >&2 || exit 1'.PHP_EOL; - - }//end printUsage() - - -}//end class - -$phpcs = new PHP_CodeSniffer_SVN_Hook(); -$phpcs->checkRequirements(); - -$numErrors = $phpcs->process(); -if ($numErrors !== 0) { - exit(1); -} - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/scripts/phpcs.bat php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/scripts/phpcs.bat --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/scripts/phpcs.bat 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/scripts/phpcs.bat 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -@echo off -REM PHP_CodeSniffer tokenises PHP code and detects violations of a -REM defined set of coding standards. -REM -REM PHP version 5 -REM -REM @category PHP -REM @package PHP_CodeSniffer -REM @author Greg Sherwood -REM @author Marc McIntyre -REM @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) -REM @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence -REM @version CVS: $Id: phpcs.bat,v 1.3 2007-11-04 22:02:16 squiz Exp $ -REM @link http://pear.php.net/package/PHP_CodeSniffer - -"@php_bin@" -d auto_append_file="" -d auto_prepend_file="" -d include_path="'@php_dir@'" -f "@bin_dir@\phpcs" -- %* diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/tests/AllTests.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/tests/AllTests.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/tests/AllTests.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/tests/AllTests.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,86 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -require_once 'TestSuite.php'; -require_once 'PHPUnit/TextUI/TestRunner.php'; - -if (is_file(dirname(__FILE__).'/../CodeSniffer.php') === true) { - // We are not installed. - include_once 'Core/AllTests.php'; - include_once 'Standards/AllSniffs.php'; - include_once dirname(__FILE__).'/../CodeSniffer.php'; -} else { - include_once 'CodeSniffer/Core/AllTests.php'; - include_once 'CodeSniffer/Standards/AllSniffs.php'; - include_once 'PHP/CodeSniffer.php'; -} - -/** - * A test class for running all PHP_CodeSniffer unit tests. - * - * Usage: phpunit AllTests.php - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PHP_CodeSniffer_AllTests -{ - - - /** - * Prepare the test runner. - * - * @return void - */ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - - }//end main() - - - /** - * Add all PHP_CodeSniffer test suites into a single test suite. - * - * @return PHPUnit_Framework_TestSuite - */ - public static function suite() - { - // Use a special PHP_CodeSniffer test suite so that we can - // unset our autoload function after the run. - $suite = new PHP_CodeSniffer_TestSuite('PHP CodeSniffer'); - - $suite->addTest(PHP_CodeSniffer_Core_AllTests::suite()); - $suite->addTest(PHP_CodeSniffer_Standards_AllSniffs::suite()); - - // Unregister this here because the PEAR tester loads - // all package suites before running then, so our autoloader - // will cause problems for the packages included after us. - spl_autoload_unregister(array('PHP_CodeSniffer', 'autoload')); - - return $suite; - - }//end suite() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/tests/Core/AllTests.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/tests/Core/AllTests.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/tests/Core/AllTests.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/tests/Core/AllTests.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,98 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -require_once 'IsCamelCapsTest.php'; -require_once 'ErrorSuppressionTest.php'; -require_once 'File/GetMethodParametersTest.php'; -require_once 'ReportingTest.php'; -require_once 'Reports/CheckstyleTest.php'; -require_once 'Reports/FullTest.php'; -require_once 'Reports/SummaryTest.php'; -require_once 'Reports/XmlTest.php'; -require_once 'Reports/CsvTest.php'; -require_once 'Reports/EmacsTest.php'; -require_once 'Reports/SourceTest.php'; -require_once 'Reports/SvnblameTest.php'; -require_once 'Reports/GitblameTest.php'; -require_once 'Reports/HgblameTest.php'; - -if (is_file(dirname(__FILE__).'/../../CodeSniffer.php') === true) { - // We are not installed. - include_once dirname(__FILE__).'/../../CodeSniffer.php'; -} else { - include_once 'PHP/CodeSniffer.php'; -} - -/** - * A test class for testing the core. - * - * Do not run this file directly. Run the AllSniffs.php file in the root - * testing directory of PHP_CodeSniffer. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PHP_CodeSniffer_Core_AllTests -{ - - - /** - * Prepare the test runner. - * - * @return void - */ - public static function main() - { - PHPUnit2_TextUI_TestRunner::run(self::suite()); - - }//end main() - - - /** - * Add all core unit tests into a test suite. - * - * @return PHPUnit_Framework_TestSuite - */ - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('PHP CodeSniffer Core'); - $suite->addTestSuite('Core_IsCamelCapsTest'); - $suite->addTestSuite('Core_ErrorSuppressionTest'); - $suite->addTestSuite('Core_File_GetMethodParametersTest'); - $suite->addTestSuite('Core_ReportingTest'); - $suite->addTestSuite('Core_Reports_CheckstyleTest'); - $suite->addTestSuite('Core_Reports_FullTest'); - $suite->addTestSuite('Core_Reports_SummaryTest'); - $suite->addTestSuite('Core_Reports_XmlTest'); - $suite->addTestSuite('Core_Reports_CsvTest'); - $suite->addTestSuite('Core_Reports_EmacsTest'); - $suite->addTestSuite('Core_Reports_SourceTest'); - $suite->addTestSuite('Core_Reports_SvnblameTest'); - $suite->addTestSuite('Core_Reports_GitblameTest'); - $suite->addTestSuite('Core_Reports_HgblameTest'); - return $suite; - - }//end suite() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/tests/Core/ErrorSuppressionTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/tests/Core/ErrorSuppressionTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/tests/Core/ErrorSuppressionTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/tests/Core/ErrorSuppressionTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,183 +0,0 @@ - - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -require_once 'PHPUnit/Framework/TestCase.php'; - -/** - * Tests for PHP_CodeSniffer error suppression tags. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Core_ErrorSuppressionTest extends PHPUnit_Framework_TestCase -{ - - - /** - * Test suppressing a single error. - * - * @return void - */ - public function testSuppressError() - { - $phpcs = new PHP_CodeSniffer(); - $phpcs->setTokenListeners('PEAR', array('Generic_Sniffs_PHP_LowerCaseConstantSniff')); - $phpcs->populateTokenListeners(); - - // Process without suppression. - $content = 'processFile('noSuppressionTest.php', $content); - - $files = $phpcs->getFiles(); - $file = $files[0]; - - $errors = $file->getErrors(); - $numErrors = $file->getErrorCount(); - $this->assertEquals(1, $numErrors); - $this->assertEquals(1, count($errors)); - - // Process with suppression. - $content = 'processFile('suppressionTest.php', $content); - - $files = $phpcs->getFiles(); - $file = $files[1]; - - $errors = $file->getErrors(); - $numErrors = $file->getErrorCount(); - $this->assertEquals(0, $numErrors); - $this->assertEquals(0, count($errors)); - - }//end testSuppressError() - - - /** - * Test suppressing 1 out of 2 errors. - * - * @return void - */ - public function testSuppressSomeErrors() - { - $phpcs = new PHP_CodeSniffer(); - $phpcs->setTokenListeners('PEAR', array('Generic_Sniffs_PHP_LowerCaseConstantSniff')); - $phpcs->populateTokenListeners(); - - // Process without suppression. - $content = 'processFile('noSuppressionTest.php', $content); - - $files = $phpcs->getFiles(); - $file = $files[0]; - - $errors = $file->getErrors(); - $numErrors = $file->getErrorCount(); - $this->assertEquals(2, $numErrors); - $this->assertEquals(2, count($errors)); - - // Process with suppression. - $content = 'processFile('suppressionTest.php', $content); - - $files = $phpcs->getFiles(); - $file = $files[1]; - - $errors = $file->getErrors(); - $numErrors = $file->getErrorCount(); - $this->assertEquals(1, $numErrors); - $this->assertEquals(1, count($errors)); - - }//end testSuppressSomeErrors() - - - /** - * Test suppressing a single warning. - * - * @return void - */ - public function testSuppressWarning() - { - $phpcs = new PHP_CodeSniffer(); - $phpcs->setTokenListeners('Squiz', array('Generic_Sniffs_Commenting_TodoSniff')); - $phpcs->populateTokenListeners(); - - // Process without suppression. - $content = 'processFile('noSuppressionTest.php', $content); - - $files = $phpcs->getFiles(); - $file = $files[0]; - - $warnings = $file->getWarnings(); - $numWarnings = $file->getWarningCount(); - $this->assertEquals(1, $numWarnings); - $this->assertEquals(1, count($warnings)); - - // Process with suppression. - $content = 'processFile('suppressionTest.php', $content); - - $files = $phpcs->getFiles(); - $file = $files[1]; - - $warnings = $file->getWarnings(); - $numWarnings = $file->getWarningCount(); - $this->assertEquals(0, $numWarnings); - $this->assertEquals(0, count($warnings)); - - }//end testSuppressWarning() - - - /** - * Test suppressing a whole file. - * - * @return void - */ - public function testSuppressFile() - { - $phpcs = new PHP_CodeSniffer(); - $phpcs->setTokenListeners('Squiz', array('Squiz_Sniffs_Commenting_FileCommentSniff')); - $phpcs->populateTokenListeners(); - - // Process without suppression. - $content = 'processFile('noSuppressionTest.php', $content); - - $files = $phpcs->getFiles(); - $file = $files[0]; - - $errors = $file->getErrors(); - $numErrors = $file->getErrorCount(); - $this->assertEquals(1, $numErrors); - $this->assertEquals(1, count($errors)); - $this->assertEquals(1, count($files)); - - // Process with suppression. - $content = 'processFile('suppressionTest.php', $content); - - // The file shouldn't even be added to the $files array. - $files = $phpcs->getFiles(); - $this->assertEquals(1, count($files)); - - }//end testSupressError() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/tests/Core/File/GetMethodParametersTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/tests/Core/File/GetMethodParametersTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/tests/Core/File/GetMethodParametersTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/tests/Core/File/GetMethodParametersTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,280 +0,0 @@ - - * @author Greg Sherwood - * @copyright 2009 SQLI - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -require_once 'PHPUnit/Framework/TestCase.php'; - -/** - * Tests for the PHP_CodeSniffer_File:getMethodParameters method. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Anti Veeranna - * @author Greg Sherwood - * @copyright 2009 SQLI - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Core_File_GetMethodParametersTest extends PHPUnit_Framework_TestCase -{ - - /** - * The PHP_CodeSniffer_File object containing parsed contents of this file. - * - * @var PHP_CodeSniffer_File - */ - private $_phpcsFile; - - - /** - * Initialize & tokenize PHP_CodeSniffer_File with code from this file. - * - * Methods used for these tests can be found at the bottom of - * this file. - * - * @return void - */ - public function setUp() - { - $phpcs = new PHP_CodeSniffer(); - $this->_phpcsFile = new PHP_CodeSniffer_File( - __FILE__, - array(), - array(), - array(), - $phpcs - ); - - $contents = file_get_contents(__FILE__); - $this->_phpcsFile->start($contents); - - }//end setUp() - - - /** - * Clean up after finished test. - * - * @return void - */ - public function tearDown() - { - unset($this->_phpcsFile); - - }//end tearDown() - - - /** - * Verify pass-by-reference parsing. - * - * @return void - */ - public function testPassByReference() - { - $expected = array(); - $expected[0] = array( - 'name' => '$var', - 'pass_by_reference' => true, - 'type_hint' => '', - ); - - $start = ($this->_phpcsFile->numTokens - 1); - $function = $this->_phpcsFile->findPrevious( - T_COMMENT, - $start, - null, - false, - '/* testPassByReference */' - ); - - $found = $this->_phpcsFile->getMethodParameters(($function + 2)); - $this->assertSame($expected, $found); - - }//end testPassByReference() - - - /** - * Verify array hint parsing. - * - * @return void - */ - public function testArrayHint() - { - $expected = array(); - $expected[0] = array( - 'name' => '$var', - 'pass_by_reference' => false, - 'type_hint' => 'array', - ); - - $start = ($this->_phpcsFile->numTokens - 1); - $function = $this->_phpcsFile->findPrevious( - T_COMMENT, - $start, - null, - false, - '/* testArrayHint */' - ); - - $found = $this->_phpcsFile->getMethodParameters(($function + 2)); - $this->assertSame($expected, $found); - - }//end testArrayHint() - - - /** - * Verify type hint parsing. - * - * @return void - */ - public function testTypeHint() - { - $expected = array(); - $expected[0] = array( - 'name' => '$var1', - 'pass_by_reference' => false, - 'type_hint' => 'foo', - ); - - $expected[1] = array( - 'name' => '$var2', - 'pass_by_reference' => false, - 'type_hint' => 'bar', - ); - - $start = ($this->_phpcsFile->numTokens - 1); - $function = $this->_phpcsFile->findPrevious( - T_COMMENT, - $start, - null, - false, - '/* testTypeHint */' - ); - - $found = $this->_phpcsFile->getMethodParameters(($function + 2)); - $this->assertSame($expected, $found); - - }//end testTypeHint() - - - /** - * Verify variable. - * - * @return void - */ - public function testVariable() - { - $expected = array(); - $expected[0] = array( - 'name' => '$var', - 'pass_by_reference' => false, - 'type_hint' => '', - ); - - $start = ($this->_phpcsFile->numTokens - 1); - $function = $this->_phpcsFile->findPrevious( - T_COMMENT, - $start, - null, - false, - '/* testVariable */' - ); - - $found = $this->_phpcsFile->getMethodParameters(($function + 2)); - $this->assertSame($expected, $found); - - }//end testVariable() - - - /** - * Verify default value parsing with a single function param. - * - * @return void - */ - public function testSingleDefaultValue() - { - $expected = array(); - $expected[0] = array( - 'name' => '$var1', - 'default' => 'self::CONSTANT', - 'pass_by_reference' => false, - 'type_hint' => '', - ); - - $start = ($this->_phpcsFile->numTokens - 1); - $function = $this->_phpcsFile->findPrevious( - T_COMMENT, - $start, - null, - false, - '/* testSingleDefaultValue */' - ); - - $found = $this->_phpcsFile->getMethodParameters(($function + 2)); - $this->assertSame($expected, $found); - - }//end testSingleDefaultValue() - - - /** - * Verify default value parsing. - * - * @return void - */ - public function testDefaultValues() - { - $expected = array(); - $expected[0] = array( - 'name' => '$var1', - 'default' => '1', - 'pass_by_reference' => false, - 'type_hint' => '', - ); - $expected[1] = array( - 'name' => '$var2', - 'default' => "'value'", - 'pass_by_reference' => false, - 'type_hint' => '', - ); - - $start = ($this->_phpcsFile->numTokens - 1); - $function = $this->_phpcsFile->findPrevious( - T_COMMENT, - $start, - null, - false, - '/* testDefaultValues */' - ); - - $found = $this->_phpcsFile->getMethodParameters(($function + 2)); - $this->assertSame($expected, $found); - - }//end testDefaultValues() - - -}//end class - -// @codingStandardsIgnoreStart -/* testPassByReference */ function passByReference(&$var) {} -/* testArrayHint */ function arrayHint(array $var) {} -/* testVariable */ function variable($var) {} -/* testSingleDefaultValue */ function defaultValue($var1=self::CONSTANT) {} -/* testDefaultValues */ function defaultValues($var1=1, $var2='value') {} -/* testTypeHint */ function typeHint(foo $var1, bar $var2) {} -// @codingStandardsIgnoreEnd - -?> - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/tests/Core/IsCamelCapsTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/tests/Core/IsCamelCapsTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/tests/Core/IsCamelCapsTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/tests/Core/IsCamelCapsTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,152 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -require_once 'PHPUnit/Framework/TestCase.php'; - -/** - * Tests for the PHP_CodeSniffer:isCamelCaps method. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Core_IsCamelCapsTest extends PHPUnit_Framework_TestCase -{ - - - /** - * Test valid public function/method names. - * - * @return void - */ - public function testValidNotClassFormatPublic() - { - $this->assertTrue(PHP_CodeSniffer::isCamelCaps('thisIsCamelCaps', false, true, true)); - $this->assertTrue(PHP_CodeSniffer::isCamelCaps('thisISCamelCaps', false, true, false)); - - }//end testValidNotClassFormatPublic() - - - /** - * Test invalid public function/method names. - * - * @return void - */ - public function testInvalidNotClassFormatPublic() - { - $this->assertFalse(PHP_CodeSniffer::isCamelCaps('_thisIsCamelCaps', false, true, true)); - $this->assertFalse(PHP_CodeSniffer::isCamelCaps('thisISCamelCaps', false, true, true)); - $this->assertFalse(PHP_CodeSniffer::isCamelCaps('ThisIsCamelCaps', false, true, true)); - - $this->assertFalse(PHP_CodeSniffer::isCamelCaps('3thisIsCamelCaps', false, true, true)); - $this->assertFalse(PHP_CodeSniffer::isCamelCaps('*thisIsCamelCaps', false, true, true)); - $this->assertFalse(PHP_CodeSniffer::isCamelCaps('-thisIsCamelCaps', false, true, true)); - - $this->assertFalse(PHP_CodeSniffer::isCamelCaps('this*IsCamelCaps', false, true, true)); - $this->assertFalse(PHP_CodeSniffer::isCamelCaps('this-IsCamelCaps', false, true, true)); - $this->assertFalse(PHP_CodeSniffer::isCamelCaps('this_IsCamelCaps', false, true, true)); - $this->assertFalse(PHP_CodeSniffer::isCamelCaps('this_is_camel_caps', false, true, true)); - - }//end testInvalidNotClassFormatPublic() - - - /** - * Test valid private method names. - * - * @return void - */ - public function testValidNotClassFormatPrivate() - { - $this->assertTrue(PHP_CodeSniffer::isCamelCaps('_thisIsCamelCaps', false, false, true)); - $this->assertTrue(PHP_CodeSniffer::isCamelCaps('_thisISCamelCaps', false, false, false)); - $this->assertTrue(PHP_CodeSniffer::isCamelCaps('_i18N', false, false, true)); - $this->assertTrue(PHP_CodeSniffer::isCamelCaps('_i18n', false, false, true)); - - }//end testValidNotClassFormatPrivate() - - - /** - * Test invalid private method names. - * - * @return void - */ - public function testInvalidNotClassFormatPrivate() - { - $this->assertFalse(PHP_CodeSniffer::isCamelCaps('thisIsCamelCaps', false, false, true)); - $this->assertFalse(PHP_CodeSniffer::isCamelCaps('_thisISCamelCaps', false, false, true)); - $this->assertFalse(PHP_CodeSniffer::isCamelCaps('_ThisIsCamelCaps', false, false, true)); - $this->assertFalse(PHP_CodeSniffer::isCamelCaps('__thisIsCamelCaps', false, false, true)); - $this->assertFalse(PHP_CodeSniffer::isCamelCaps('__thisISCamelCaps', false, false, false)); - - $this->assertFalse(PHP_CodeSniffer::isCamelCaps('3thisIsCamelCaps', false, false, true)); - $this->assertFalse(PHP_CodeSniffer::isCamelCaps('*thisIsCamelCaps', false, false, true)); - $this->assertFalse(PHP_CodeSniffer::isCamelCaps('-thisIsCamelCaps', false, false, true)); - $this->assertFalse(PHP_CodeSniffer::isCamelCaps('_this_is_camel_caps', false, false, true)); - - }//end testInvalidNotClassFormatPrivate() - - - /** - * Test valid class names. - * - * @return void - */ - public function testValidClassFormatPublic() - { - $this->assertTrue(PHP_CodeSniffer::isCamelCaps('ThisIsCamelCaps', true, true, true)); - $this->assertTrue(PHP_CodeSniffer::isCamelCaps('ThisISCamelCaps', true, true, false)); - $this->assertTrue(PHP_CodeSniffer::isCamelCaps('This3IsCamelCaps', true, true, false)); - - }//end testValidClassFormatPublic() - - - /** - * Test invalid class names. - * - * @return void - */ - public function testInvalidClassFormat() - { - $this->assertFalse(PHP_CodeSniffer::isCamelCaps('thisIsCamelCaps', true)); - $this->assertFalse(PHP_CodeSniffer::isCamelCaps('This-IsCamelCaps', true)); - $this->assertFalse(PHP_CodeSniffer::isCamelCaps('This_Is_Camel_Caps', true)); - - }//end testInvalidClassFormat() - - - /** - * Test invalid class names with the private flag set. - * - * Note that the private flag is ignored if the class format - * flag is set, so these names are all invalid. - * - * @return void - */ - public function testInvalidClassFormatPrivate() - { - $this->assertFalse(PHP_CodeSniffer::isCamelCaps('_ThisIsCamelCaps', true, true)); - $this->assertFalse(PHP_CodeSniffer::isCamelCaps('_ThisIsCamelCaps', true, false)); - - }//end testInvalidClassFormatPrivate() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/tests/Core/ReportingTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/tests/Core/ReportingTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/tests/Core/ReportingTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/tests/Core/ReportingTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,234 +0,0 @@ - - * @author Greg Sherwood - * @copyright 2009 SQLI - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -require_once 'PHPUnit/Framework/TestCase.php'; - -/** - * Tests for the PHP_CodeSniffer reporting system. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Gabriele Santini - * @author Greg Sherwood - * @copyright 2009 SQLI - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Core_ReportingTest extends PHPUnit_Framework_TestCase -{ - - /** - * Called class - * - * @var PHP_CodeSniffer_Reporting - */ - protected $reporting; - - /** - * Report error fixtures. - * - * @var array - */ - protected $fixtureErrors = array( - 10 => array( - 1 => array( - array( - 'message' => 'Fourth error message', - 'source' => 'MyStandard.MyType.Mysniff1.Mycode1', - 'severity' => 5, - ), - ) - ), - 1 => array( - 10 => array( - array( - 'message' => 'Second error message', - 'source' => 'MyStandard.MyType.Mysniff2.Mycode1', - 'severity' => 5, - ), - array( - 'message' => 'Third error message', - 'source' => 'MyStandard.MyType.Mysniff1.Mycode2', - 'severity' => 5, - ), - ), - 1 => array( - array( - 'message' => 'First error message', - 'source' => 'MyStandard.MyType.Mysniff1.Mycode2', - 'severity' => 5, - ), - ) - ) - ); - - /** - * Report warning fixtures. - * - * @var array - */ - protected $fixtureWarnings = array( - 10 => array( - 1 => array( - array( - 'message' => 'First warning message', - 'source' => 'MyStandard.MyType.Mysniff1.Mycode3', - 'severity' => 5, - ), - ) - ), - 5 => array( - 1 => array( - array( - 'message' => 'Second warning message', - 'source' => 'MyStandard.MyType.Mysniff2.Mycode2', - 'severity' => 5, - ), - ) - ), - ); - - - /** - * Gives a Reporting instance. - * - * @return void - */ - public function setUp() - { - $this->reporting = new PHP_CodeSniffer_Reporting(); - - }//end setUp() - - - /** - * Test report factory method. - * - * @return void - */ - public function testFactory() - { - $type = 'checkstyle'; - $reportClass = $this->reporting->factory($type); - $this->assertInstanceOf('PHP_CodeSniffer_Report', $reportClass); - $this->assertInstanceOf('PHP_CodeSniffer_Reports_Checkstyle', $reportClass); - - $this->setExpectedException('PHP_CodeSniffer_Exception'); - $type = 'foo'; - $reportClass = $this->reporting->factory($type); - - }//end testFactory() - - - /** - * Compose fixture violations. - * - * @return array - */ - protected function getFixtureFilesViolations() - { - return array( - 'foo' => array( - 'errors' => $this->fixtureErrors, - 'warnings' => $this->fixtureWarnings, - 'numErrors' => 4, - 'numWarnings' => 2, - ), - 'bar' => array( - 'errors' => $this->fixtureErrors, - 'warnings' => array(), - 'numErrors' => 4, - 'numWarnings' => 0, - ), - 'baz' => array( - 'errors' => array(), - 'warnings' => array(), - 'numErrors' => 0, - 'numWarnings' => 0, - ) - ); - - }//end getFixtureFilesViolations() - - - /** - * Test prepare report method. - * - * @return void - */ - public function testPrepare() - { - $fixtureFilesViolations = $this->getFixtureFilesViolations(); - $reports = $this->reporting->prepare($fixtureFilesViolations); - - $this->assertArrayHasKey('files', $reports); - $this->assertEquals(3, count($reports['files'])); - - $this->assertArrayHasKey('foo', $reports['files']); - $this->assertArrayHasKey('errors', $reports['files']['foo']); - $this->assertEquals(4, $reports['files']['foo']['errors']); - $this->assertArrayHasKey('warnings', $reports['files']['foo']); - $this->assertEquals(2, $reports['files']['foo']['warnings']); - - // Two errors on line 1 column 10. - $this->assertArrayHasKey('messages', $reports['files']['foo']); - $fooMessages = $reports['files']['foo']['messages']; - - $this->assertArrayHasKey(1, $fooMessages, 'messages on line 1'); - $this->assertArrayHasKey(10, $fooMessages[1], 'messages on line 1 column 10'); - $this->assertEquals(2, count($fooMessages[1][10]), '2 messages on line 1 column 10'); - - // One error one warning on line 10 column 1. - $this->assertArrayHasKey(10, $fooMessages, 'messages on line 10'); - $this->assertArrayHasKey(1, $fooMessages[10], 'messages on line 10 column 1'); - $this->assertEquals(2, count($fooMessages[10][1]), '2 messages on line 10 column 1'); - - // Empty file has structure without data. - $this->assertArrayHasKey('baz', $reports['files']); - $this->assertArrayHasKey('messages', $reports['files']['baz']); - $this->assertEquals(0, count($reports['files']['baz']['messages'])); - - // Totals. - $this->assertArrayHasKey('totals', $reports, 'report totals exist'); - $this->assertArrayHasKey('errors', $reports['totals'], 'errors total exists'); - $this->assertEquals(8, $reports['totals']['errors'], 'errors total is well calculated'); - $this->assertArrayHasKey('warnings', $reports['totals'], 'warnings total exists'); - $this->assertEquals(2, $reports['totals']['warnings'], 'warnings total is well calculated'); - - // Files Order. - reset($reports['files']); - $this->assertEquals('bar', key($reports['files']), 'report files ordered by name'); - next($reports['files']); - $this->assertEquals('baz', key($reports['files']), 'report files ordered by name'); - - // Violations Order. - reset($fooMessages); - $this->assertEquals(1, key($fooMessages), 'line level violations order'); - next($fooMessages); - $this->assertEquals(5, key($fooMessages), 'line level violations order'); - reset($fooMessages[1]); - $this->assertEquals(1, key($fooMessages[1]), 'column level violations order'); - next($fooMessages[1]); - $this->assertEquals(10, key($fooMessages[1]), 'column level violations order'); - - }//end testPrepare() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/tests/Core/Reports/AbstractTestCase.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/tests/Core/Reports/AbstractTestCase.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/tests/Core/Reports/AbstractTestCase.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/tests/Core/Reports/AbstractTestCase.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,172 +0,0 @@ - - * @author Greg Sherwood - * @copyright 2009 SQLI - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -require_once 'PHPUnit/Framework/TestCase.php'; - -/** - * TestCase Abstract Helper class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Gabriele Santini - * @author Greg Sherwood - * @copyright 2009 SQLI - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Core_Reports_AbstractTestCase extends PHPUnit_Framework_TestCase -{ - - /** - * Fixtures of report data. - * - * @var array - */ - protected $fixtureReportData - = array( - 'totals' => array( - 'warnings' => 2, - 'errors' => 8, - ), - 'files' => array( - 'bar' => array( - 'errors' => 4, - 'warnings' => 0, - 'messages' => array( - 1 => array( - 1 => array( - 0 => array( - 'message' => 'First error message', - 'source' => 'MyStandard.Mytype.Mysniff1Sniff.Mycode2', - 'type' => 'ERROR', - 'severity' => 5, - ), - ), - 10 => array( - 0 => array( - 'message' => 'Second error message', - 'source' => 'MyStandard.Mytype.Mysniff2Sniff.Mycode1', - 'type' => 'ERROR', - 'severity' => 5, - ), - 1 => array( - 'message' => 'Third error message', - 'source' => 'MyStandard.Mytype.Mysniff1Sniff.Mycode2', - 'type' => 'ERROR', - 'severity' => 5, - ) - ) - ), - 10 => array( - 1 => array( - 0 => array( - 'message' => 'Fourth error message', - 'source' => 'MyStandard.Mytype.Mysniff1Sniff.Mycode1', - 'type' => 'ERROR', - 'severity' => 5, - ) - ) - ) - ) - ), - 'baz' => array( - 'errors' => 0, - 'warnings' => 0, - 'messages' => array(), - ), - 'foo' => array( - 'errors' => 4, - 'warnings' => 2, - 'messages' => array( - 1 => array( - 1 => array( - 0 => array( - 'message' => 'First error message', - 'source' => 'MyStandard.Mytype.Mysniff1Sniff.Mycode2', - 'type' => 'ERROR', - 'severity' => 5, - ) - ), - 10 => array( - 0 => array( - 'message' => 'Second error message', - 'source' => 'MyStandard.Mytype.Mysniff2Sniff.Mycode1', - 'type' => 'ERROR', - 'severity' => 5, - ), - 1 => array( - 'message' => 'Third error message', - 'source' => 'MyStandard.Mytype.Mysniff1Sniff.Mycode2', - 'type' => 'ERROR', - 'severity' => 5, - ) - ) - ), - 5 => array( - 1 => array( - 0 => array( - 'message' => 'First warning message', - 'source' => 'MyStandard.Mytype.Mysniff2Sniff.Mycode2', - 'type' => 'WARNING', - 'severity' => 5, - ) - ) - ), - 10 => array( - 1 => array( - 0 => array( - 'message' => 'Second warning message', - 'source' => 'MyStandard.Mytype.Mysniff1Sniff.Mycode3', - 'type' => 'WARNING', - 'severity' => 5, - ), - 1 => array( - 'message' => 'Fourth error message', - 'source' => 'MyStandard.Mytype.Mysniff1Sniff.Mycode1', - 'type' => 'ERROR', - 'severity' => 5, - ) - ) - ) - ) - ) - ) - ); - - - /** - * Returns report standard generation. - * - * @param PHP_CodeSniffer_Report $report The report under test. - * - * @return string - */ - protected function getFixtureReport(PHP_CodeSniffer_Report $report) - { - ob_start(); - $report->generate($this->fixtureReportData); - $generated = ob_get_clean(); - - return $generated; - - }//end getFixtureReport() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/tests/Core/Reports/CheckstyleTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/tests/Core/Reports/CheckstyleTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/tests/Core/Reports/CheckstyleTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/tests/Core/Reports/CheckstyleTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,60 +0,0 @@ - - * @author Greg Sherwood - * @copyright 2009 SQLI - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -require_once 'PHPUnit/Framework/TestCase.php'; -require_once dirname(__FILE__).'/AbstractTestCase.php'; - -/** - * Tests for the Checkstyle report. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Gabriele Santini - * @author Greg Sherwood - * @copyright 2009 SQLI - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Core_Reports_CheckstyleTest extends Core_Reports_AbstractTestCase -{ - - - /** - * Tests standard report. - * - * @return void - */ - public function testGenerate() - { - $checkstyleReport = new PHP_CodeSniffer_Reports_Checkstyle(); - $generated = $this->getFixtureReport($checkstyleReport); - $xmlDocument = new DOMDocument(); - - $xmlDocument->loadXML($generated); - $result = $xmlDocument->schemaValidate( - dirname(__FILE__).'/XSD/Checkstyle.xsd' - ); - - $this->assertTrue($result); - - }//end testGenerate() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/tests/Core/Reports/CsvTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/tests/Core/Reports/CsvTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/tests/Core/Reports/CsvTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/tests/Core/Reports/CsvTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,79 +0,0 @@ - - * @author Greg Sherwood - * @copyright 2009 SQLI - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -require_once 'PHPUnit/Framework/TestCase.php'; -require_once dirname(__FILE__).'/AbstractTestCase.php'; - -/** - * Tests for the Csv report of PHP_CodeSniffer. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Gabriele Santini - * @author Greg Sherwood - * @copyright 2009 SQLI - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Core_Reports_CsvTest extends Core_Reports_AbstractTestCase -{ - - /** - * Path to generated files. - * - * @var string - */ - protected $genFilesFolder; - - - /** - * Store path to generated files. - * - * @return void - */ - public function setUp() - { - $this->genFilesFolder = sys_get_temp_dir(); - parent::setUp(); - - }//end setUp() - - - /** - * Tests standard report. - * - * @return void - */ - public function testGenerate() - { - $fullReport = new PHP_CodeSniffer_Reports_Csv(); - $generated = $this->getFixtureReport($fullReport); - - $reportFile = $this->genFilesFolder.'/CsvReportResult.csv'; - file_put_contents($reportFile, $generated); - $file = fopen($reportFile, 'r'); - while ($csvLine = fgetcsv($file)) { - $this->assertEquals(7, count($csvLine)); - } - - }//end testGenerate() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/tests/Core/Reports/EmacsTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/tests/Core/Reports/EmacsTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/tests/Core/Reports/EmacsTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/tests/Core/Reports/EmacsTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,54 +0,0 @@ - - * @author Greg Sherwood - * @copyright 2009 SQLI - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -require_once 'PHPUnit/Framework/TestCase.php'; -require_once dirname(__FILE__).'/AbstractTestCase.php'; - -/** - * Tests for the Emacs report of PHP_CodeSniffer. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Gabriele Santini - * @author Greg Sherwood - * @copyright 2009 SQLI - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Core_Reports_EmacsTest extends Core_Reports_AbstractTestCase -{ - - - /** - * Tests standard generation. - * - * @return void - */ - public function testGenerate() - { - $fullReport = new PHP_CodeSniffer_Reports_Emacs(); - $generated = $this->getFixtureReport($fullReport); - $this->assertEquals(8, substr_count($generated, ': error -')); - $this->assertEquals(2, substr_count($generated, ': warning -')); - - }//end testGenerate() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/tests/Core/Reports/FullTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/tests/Core/Reports/FullTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/tests/Core/Reports/FullTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/tests/Core/Reports/FullTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,64 +0,0 @@ - - * @author Greg Sherwood - * @copyright 2009 SQLI - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -require_once 'PHPUnit/Framework/TestCase.php'; -require_once dirname(__FILE__).'/AbstractTestCase.php'; - -/** - * Tests for the Full report of PHP_CodeSniffer. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Gabriele Santini - * @author Greg Sherwood - * @copyright 2009 SQLI - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Core_Reports_FullTest extends Core_Reports_AbstractTestCase -{ - - - /** - * Test standard report. - * - * @return void - */ - public function testGenerate() - { - $fullReport = new PHP_CodeSniffer_Reports_Full(); - $generated = $this->getFixtureReport($fullReport); - - $i = 1; - $line = strtok($generated, PHP_EOL); - while (false !== $line) { - $this->assertLessThan( - 81, - strlen($line), - 'Report line '.$i.' is longer than 80 characters' - ); - $i++; - $line = strtok(PHP_EOL); - } - - }//end testGenerate() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/tests/Core/Reports/GitblameTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/tests/Core/Reports/GitblameTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/tests/Core/Reports/GitblameTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/tests/Core/Reports/GitblameTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,101 +0,0 @@ - - * @copyright 2009 SQLI - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -require_once 'PHPUnit/Framework/TestCase.php'; -require_once dirname(__FILE__).'/AbstractTestCase.php'; -require_once dirname(__FILE__).'/Mock/Gitblame.php'; - -if (is_file(dirname(__FILE__).'/../../../CodeSniffer.php') === true) { - // We are not installed. - include_once dirname(__FILE__).'/../../../CodeSniffer/Reports/VersionControl.php'; -} else { - include_once 'PHP/CodeSniffer/Reports/VersionControl.php'; -} - -/** - * Tests for the Gitblame report of PHP_CodeSniffer. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Ben Selby - * @copyright 2009 SQLI - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Core_Reports_GitblameTest extends Core_Reports_AbstractTestCase -{ - - - /** - * Test standard generation - * - * @return void - */ - public function testGenerate() - { - $fullReport = new PHP_CodeSniffer_Reports_Mock_Gitblame(); - $generated = $this->getFixtureReport($fullReport); - $generatedLines = explode(PHP_EOL, $generated); - $this->assertGreaterThan(10, count($generatedLines)); - - }//end testGenerate() - - - /** - * Test author recovering from a git blame line - * - * @param string $line The git blame output - * @param string $expected The author name - * - * @dataProvider provideDataForGetGitAuthor - * - * @return void - */ - public function testGetGitAuthor($line, $expected) - { - $fullReport = new PHP_CodeSniffer_Reports_Mock_gitblame(); - $author = $fullReport->testGetGitAuthor($line); - $this->assertEquals($expected, $author); - - }//end testGetGitAuthor() - - - /** - * Data provider for testGetGitAuthor - * - * @return array - */ - public static function provideDataForGetGitAuthor() - { - return array( - array('054e758d (Ben Selby 2010-07-03 45) * @return', 'Ben Selby'), - array('054e758d (Ben Selby Dev 1 2010-07-03 45) * @return', 'Ben Selby Dev 1'), - array('054e758d (Ben 2010-07-03 45) * @return', 'Ben'), - array('054e758d (Ben Selby 2010-07-03 45) * @return', 'Ben Selby'), - array('054e758d (Ben Selby 2010-07-03 1) * @return', 'Ben Selby'), - array('054e758d (Ben Selby 2010-07-03 11) * @return', 'Ben Selby'), - array('054e758d (Ben Selby 2010-07-03 111) * @return', 'Ben Selby'), - array('054e758d (Ben Selby 2010-07-03 1111) * @return', 'Ben Selby'), - array('054e758d (Ben Selby 2010-07-03 11111) * @return', 'Ben Selby'), - ); - - }//end provideDataForGetGitAuthor() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/tests/Core/Reports/HgblameTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/tests/Core/Reports/HgblameTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/tests/Core/Reports/HgblameTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/tests/Core/Reports/HgblameTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,95 +0,0 @@ - - * @copyright 2009 SQLI - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -require_once 'PHPUnit/Framework/TestCase.php'; -require_once dirname(__FILE__).'/AbstractTestCase.php'; -require_once dirname(__FILE__).'/Mock/Hgblame.php'; - -if (is_file(dirname(__FILE__).'/../../../CodeSniffer.php') === true) { - // We are not installed. - include_once dirname(__FILE__).'/../../../CodeSniffer/Reports/VersionControl.php'; -} else { - include_once 'PHP/CodeSniffer/Reports/VersionControl.php'; -} - -/** - * Tests for the Hgblame report of PHP_CodeSniffer. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Ben Selby - * @copyright 2009 SQLI - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Core_Reports_HgblameTest extends Core_Reports_AbstractTestCase -{ - - - /** - * Test standard generation - * - * @return void - */ - public function testGenerate() - { - $fullReport = new PHP_CodeSniffer_Reports_Mock_Hgblame(); - $generated = $this->getFixtureReport($fullReport); - $generatedLines = explode(PHP_EOL, $generated); - $this->assertGreaterThan(10, count($generatedLines)); - - }//end testGenerate() - - - /** - * Test author recovering from a hg blame line - * - * @param string $line The hg blame output - * @param string $expected The author name - * - * @dataProvider provideDataForGetHgAuthor - * - * @return void - */ - public function testGetHgAuthor($line, $expected) - { - $fullReport = new PHP_CodeSniffer_Reports_Mock_Hgblame(); - $author = $fullReport->testGetHgAuthor($line); - $this->assertEquals($expected, $author); - - }//end testGetHgAuthor() - - - /** - * Data provider for testGetHgAuthor - * - * @return array - */ - public static function provideDataForGetHgAuthor() - { - return array( - array('Ben Selby Sun May 29 00:05:15 2011 +0300: /**', 'Ben Selby'), - array(' benmatselby@somewhere Sun May 29 00:05:15 2011 +0300: /**', 'benmatselby@somewhere'), - array('Ben Selby Tue Apr 26 00:36:36 2011 +0300: * // Some random text with dates (e.g. 2011-05-01 12:30:00, Y-m-d H:i:s', 'Ben Selby'), - ); - - }//end provideDataForGetHgAuthor() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/tests/Core/Reports/Mock/Gitblame.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/tests/Core/Reports/Mock/Gitblame.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/tests/Core/Reports/Mock/Gitblame.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/tests/Core/Reports/Mock/Gitblame.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,163 +0,0 @@ - - * @copyright 2009 SQLI - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -if (is_file(dirname(__FILE__).'/../../../../CodeSniffer.php') === true) { - // We are not installed. - include_once dirname(__FILE__).'/../../../../CodeSniffer/Report.php'; - include_once dirname(__FILE__).'/../../../../CodeSniffer/Reports/VersionControl.php'; - include_once dirname(__FILE__).'/../../../../CodeSniffer/Reports/Gitblame.php'; -} else { - include_once 'PHP/CodeSniffer/Report.php'; - include_once 'PHP/CodeSniffer/Reports/VersionControl.php'; - include_once 'PHP/CodeSniffer/Reports/Gitblame.php'; -} - -/** - * Gitblame report mock class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Ben Selby - * @copyright 2009 SQLI - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PHP_CodeSniffer_Reports_Mock_Gitblame extends PHP_CodeSniffer_Reports_Gitblame -{ - - /** - * Example gitblame output. - * - * @var array - */ - protected $fooBlames = array( - '054e7580 (Ben Selby 1 2009-08-25 45) * @return', - '054e758a (Ben Selby 2 2009-08-25 45) * @return', - '054e758b (Ben Selby 3 2009-08-25 45) * @return', - '054e758c (Ben Selby 4 2009-08-25 45) * @return', - '054e758d (Ben Selby 5 2009-08-25 45) * @return', - '1ee0f411 (Ben Selby 6 2009-08-25 45) * @return', - '1ee0f41b (Ben Selby 7 2009-08-25 45) * @return', - '1ee0f41c (Ben Selby 8 2009-08-25 45) * @return', - '1ee0f41d (Ben Selby 9 2009-08-25 45) * @return', - '1ee0f41e (Ben Selby 10 2009-08-25 45) * @return', - ); - - /** - * Example gitblame output. - * - * @var array - */ - protected $barBlames = array( - '054e7580 (Ben Selby 1 2009-08-25 45) * @return', - '054e758a (Ben Selby 2 2009-08-25 45) * @return', - '054e758b (Ben Selby 3 2009-08-25 45) * @return', - '054e758c (Ben Selby 4 2009-08-25 45) * @return', - '054e758d (Ben Selby 5 2009-08-25 45) * @return', - '1ee0f411 (Ben Selby 6 2009-08-25 45) * @return', - '1ee0f41b (Ben Selby 7 2009-08-25 45) * @return', - '1ee0f41c (Ben Selby 8 2009-08-25 45) * @return', - '1ee0f41d (Ben Selby 9 2009-08-25 45) * @return', - '1ee0f41e (Ben Selby 10 2009-08-25 45) * @return', - ); - - /** - * Example gitblame output. - * - * @var array - */ - protected $bazBlames = array( - '054e7580 (Ben Selby 1 2009-08-25 45) * @return', - '054e758a (Ben Selby 2 2009-08-25 45) * @return', - '054e758b (Ben Selby 3 2009-08-25 45) * @return', - '054e758c (Ben Selby 4 2009-08-25 45) * @return', - '054e758d (Ben Selby 5 2009-08-25 45) * @return', - '1ee0f411 (Ben Selby 6 2009-08-25 45) * @return', - '1ee0f41b (Ben Selby 7 2009-08-25 45) * @return', - '1ee0f41c (Ben Selby 8 2009-08-25 45) * @return', - '1ee0f41d (Ben Selby 9 2009-08-25 45) * @return', - '1ee0f41e (Ben Selby 10 2009-08-25 45) * @return', - ); - - /** - * Example gitblame output with long revision numbers. - * - * @var array - */ - protected $bigRevisionNumberBlames = array( - '054e7580 (Ben Selby 1 2009-08-25 45) * @return', - '054e758a (Ben Selby 2 2009-08-25 45) * @return', - '054e758b (Ben Selby 3 2009-08-25 45) * @return', - '054e758c (Ben Selby 4 2009-08-25 45) * @return', - '054e758d (Ben Selby 5 2009-08-25 45) * @return', - '1ee0f411 (Ben Selby 6 2009-08-25 45) * @return', - '1ee0f41b (Ben Selby 7 2009-08-25 45) * @return', - '1ee0f41c (Ben Selby 8 2009-08-25 45) * @return', - '1ee0f41d (Ben Selby 9 2009-08-25 45) * @return', - '1ee0f41e (Ben Selby 10 2009-08-25 45) * @return', - ); - - - /** - * Mocks the gitblame command. - * - * @param string $filename filename (equals fixtures keys). - * - * @return string - * @throws PHP_CodeSniffer_Exception - */ - protected function getBlameContent($filename) - { - switch ($filename) { - case 'foo': - $blames = $this->fooBlames; - break; - case 'bar': - $blames = $this->barBlames; - break; - case 'baz': - $blames = $this->bazBlames; - break; - case 'bigRevisionNumber': - $blames = $this->bigRevisionNumberBlames; - break; - default: - throw new PHP_CodeSniffer_Exception('Unexpected filename '.$filename); - } - - return $blames; - - }//end getGitblameContent() - - - /** - * Needed to test protected method. - * - * @param string $line Line to parse. - * - * @return string - */ - public function testGetGitAuthor($line) - { - return $this->getAuthor($line); - - }//end testGetGitAuthor() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/tests/Core/Reports/Mock/Hgblame.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/tests/Core/Reports/Mock/Hgblame.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/tests/Core/Reports/Mock/Hgblame.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/tests/Core/Reports/Mock/Hgblame.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,163 +0,0 @@ - - * @copyright 2009 SQLI - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -if (is_file(dirname(__FILE__).'/../../../../CodeSniffer.php') === true) { - // We are not installed. - include_once dirname(__FILE__).'/../../../../CodeSniffer/Report.php'; - include_once dirname(__FILE__).'/../../../../CodeSniffer/Reports/VersionControl.php'; - include_once dirname(__FILE__).'/../../../../CodeSniffer/Reports/Hgblame.php'; -} else { - include_once 'PHP/CodeSniffer/Report.php'; - include_once 'PHP/CodeSniffer/Reports/VersionControl.php'; - include_once 'PHP/CodeSniffer/Reports/Hgblame.php'; -} - -/** - * Hgblame report mock class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Ben Selby - * @copyright 2009 SQLI - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PHP_CodeSniffer_Reports_Mock_Hgblame extends PHP_CodeSniffer_Reports_Hgblame -{ - - /** - * Example Hgblame output. - * - * @var array - */ - protected $fooBlames = array( - 'Ben Selby Sun May 29 00:05:15 2011 +0300: /**', - 'Ben Selby Sun May 29 00:05:15 2011 +0300: /**', - 'Ben Selby Sun May 29 00:05:15 2011 +0300: /**', - 'Ben Selby Sun May 29 00:05:15 2011 +0300: /**', - 'Ben Selby Sun May 29 00:05:15 2011 +0300: /**', - 'Ben Selby Sun May 29 00:05:15 2011 +0300: /**', - 'Ben Selby Sun May 29 00:05:15 2011 +0300: /**', - 'Ben Selby Sun May 29 00:05:15 2011 +0300: /**', - 'Ben Selby Sun May 29 00:05:15 2011 +0300: /**', - 'Ben Selby Sun May 29 00:05:15 2011 +0300: /**', - ); - - /** - * Example Hgblame output. - * - * @var array - */ - protected $barBlames = array( - 'Ben Selby Sun May 29 00:05:15 2011 +0300: /**', - 'Ben Selby Sun May 29 00:05:15 2011 +0300: /**', - 'Ben Selby Sun May 29 00:05:15 2011 +0300: /**', - 'Ben Selby Sun May 29 00:05:15 2011 +0300: /**', - 'Ben Selby Sun May 29 00:05:15 2011 +0300: /**', - 'Ben Selby Sun May 29 00:05:15 2011 +0300: /**', - 'Ben Selby Sun May 29 00:05:15 2011 +0300: /**', - 'Ben Selby Sun May 29 00:05:15 2011 +0300: /**', - 'Ben Selby Sun May 29 00:05:15 2011 +0300: /**', - 'Ben Selby Sun May 29 00:05:15 2011 +0300: /**', - ); - - /** - * Example Hgblame output. - * - * @var array - */ - protected $bazBlames = array( - 'Ben Selby Sun May 29 00:05:15 2011 +0300: /**', - 'Ben Selby Sun May 29 00:05:15 2011 +0300: /**', - 'Ben Selby Sun May 29 00:05:15 2011 +0300: /**', - 'Ben Selby Sun May 29 00:05:15 2011 +0300: /**', - 'Ben Selby Sun May 29 00:05:15 2011 +0300: /**', - 'Ben Selby Sun May 29 00:05:15 2011 +0300: /**', - 'Ben Selby Sun May 29 00:05:15 2011 +0300: /**', - 'Ben Selby Sun May 29 00:05:15 2011 +0300: /**', - 'Ben Selby Sun May 29 00:05:15 2011 +0300: /**', - 'Ben Selby Sun May 29 00:05:15 2011 +0300: /**', - ); - - /** - * Example Hgblame output with long revision numbers. - * - * @var array - */ - protected $bigRevisionNumberBlames = array( - 'Ben Selby Sun May 29 00:05:15 2011 +0300: /**', - 'Ben Selby Sun May 29 00:05:15 2011 +0300: /**', - 'Ben Selby Sun May 29 00:05:15 2011 +0300: /**', - 'Ben Selby Sun May 29 00:05:15 2011 +0300: /**', - 'Ben Selby Sun May 29 00:05:15 2011 +0300: /**', - 'Ben Selby Sun May 29 00:05:15 2011 +0300: /**', - 'Ben Selby Sun May 29 00:05:15 2011 +0300: /**', - 'Ben Selby Sun May 29 00:05:15 2011 +0300: /**', - 'Ben Selby Sun May 29 00:05:15 2011 +0300: /**', - 'Ben Selby Sun May 29 00:05:15 2011 +0300: /**', - ); - - - /** - * Mocks the Hgblame command. - * - * @param string $filename filename (equals fixtures keys). - * - * @return string - * @throws PHP_CodeSniffer_Exception - */ - protected function getBlameContent($filename) - { - switch ($filename) { - case 'foo': - $blames = $this->fooBlames; - break; - case 'bar': - $blames = $this->barBlames; - break; - case 'baz': - $blames = $this->bazBlames; - break; - case 'bigRevisionNumber': - $blames = $this->bigRevisionNumberBlames; - break; - default: - throw new PHP_CodeSniffer_Exception('Unexpected filename '.$filename); - } - - return $blames; - - }//end getHgblameContent() - - - /** - * Needed to test protected method. - * - * @param string $line Line to parse. - * - * @return string - */ - public function testGetHgAuthor($line) - { - return $this->getAuthor($line); - - }//end testGetHgAuthor() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/tests/Core/Reports/Mock/Svnblame.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/tests/Core/Reports/Mock/Svnblame.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/tests/Core/Reports/Mock/Svnblame.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/tests/Core/Reports/Mock/Svnblame.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,165 +0,0 @@ - - * @author Greg Sherwood - * @copyright 2009 SQLI - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -if (is_file(dirname(__FILE__).'/../../../../CodeSniffer.php') === true) { - // We are not installed. - include_once dirname(__FILE__).'/../../../../CodeSniffer/Report.php'; - include_once dirname(__FILE__).'/../../../../CodeSniffer/Reports/VersionControl.php'; - include_once dirname(__FILE__).'/../../../../CodeSniffer/Reports/Svnblame.php'; -} else { - include_once 'PHP/CodeSniffer/Report.php'; - include_once 'PHP/CodeSniffer/Reports/VersionControl.php'; - include_once 'PHP/CodeSniffer/Reports/Svnblame.php'; -} - -/** - * Svnblame report mock class. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Gabriele Santini - * @author Greg Sherwood - * @copyright 2009 SQLI - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PHP_CodeSniffer_Reports_Mock_Svnblame extends PHP_CodeSniffer_Reports_Svnblame -{ - - /** - * Example svnblame output. - * - * @var array - */ - protected $fooBlames = array( - ' 4 devel1 * @return void', - ' 4 devel1 * @return void', - ' 5 devel2 * @return void', - ' 4 devel1 * @return void', - ' 4 devel1 * @return void', - ' 5 devel2 * @return void', - ' 5 devel2 * @return void', - ' 4 devel1 * @return void', - ' 10 devel3 * @return void', - ' 10 devel3 * @return void', - ); - - /** - * Example svnblame output. - * - * @var array - */ - protected $barBlames = array( - ' 4 devel1 * @return void', - ' 4 devel1 * @return void', - ' 5 devel2 * @return void', - ' 4 devel1 * @return void', - ' 4 devel1 * @return void', - ' 5 devel2 * @return void', - ' 5 devel2 * @return void', - ' 4 devel1 * @return void', - ' 10 devel3 * @return void', - ' 10 devel3 * @return void', - ); - - /** - * Example svnblame output. - * - * @var array - */ - protected $bazBlames = array( - ' 4 devel1 * @return void', - ' 4 devel1 * @return void', - ' 5 devel2 * @return void', - ' 4 devel1 * @return void', - ' 4 devel1 * @return void', - ' 5 devel2 * @return void', - ' 5 devel2 * @return void', - ' 4 devel1 * @return void', - ' 10 devel3 * @return void', - ' 10 devel3 * @return void', - ); - - /** - * Example svnblame output with long revision numbers. - * - * @var array - */ - protected $bigRevisionNumberBlames = array( - '123456 devel1 * @return void', - '123456 devel1 * @return void', - '251897 devel3 * @return void', - '251897 devel3 * @return void', - ' 12345 devel1 * @return void', - '220123 devel2 * @return void', - '220123 devel2 * @return void', - '220123 devel2 * @return void', - '219571 devel1 * @return void', - '219571 devel1 * @return void', - ); - - - /** - * Mocks the svnblame command. - * - * @param string $filename filename (equals fixtures keys). - * - * @return string - * @throws PHP_CodeSniffer_Exception - */ - protected function getBlameContent($filename) - { - switch ($filename) { - case 'foo': - $blames = $this->fooBlames; - break; - case 'bar': - $blames = $this->barBlames; - break; - case 'baz': - $blames = $this->bazBlames; - break; - case 'bigRevisionNumber': - $blames = $this->bigRevisionNumberBlames; - break; - default: - throw new PHP_CodeSniffer_Exception('Unexpected filename '.$filename); - }//end switch - - return $blames; - - }//end getSvnblameContent() - - - /** - * Needed to test protected method. - * - * @param string $line Line to parse. - * - * @return string - */ - public function testGetSvnAuthor($line) - { - return $this->getAuthor($line); - - }//end testGetSvnAuthor() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/tests/Core/Reports/SourceTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/tests/Core/Reports/SourceTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/tests/Core/Reports/SourceTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/tests/Core/Reports/SourceTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,56 +0,0 @@ - - * @author Greg Sherwood - * @copyright 2009 SQLI - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -require_once 'PHPUnit/Framework/TestCase.php'; -require_once dirname(__FILE__).'/AbstractTestCase.php'; - -/** - * Tests for the Source report of PHP_CodeSniffer. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Gabriele Santini - * @author Greg Sherwood - * @copyright 2009 SQLI - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Core_Reports_SourceTest extends Core_Reports_AbstractTestCase -{ - - - /** - * Test standard generation. - * - * @return void - */ - public function testGenerate() - { - $fullReport = new PHP_CodeSniffer_Reports_Source(); - $generated = $this->getFixtureReport($fullReport); - $this->assertContains( - 'A TOTAL OF 10 SNIFF VIOLATION(S) WERE FOUND IN 5 SOURCE(S)', - $generated - ); - - }//end testGenerate() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/tests/Core/Reports/SummaryTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/tests/Core/Reports/SummaryTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/tests/Core/Reports/SummaryTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/tests/Core/Reports/SummaryTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,64 +0,0 @@ - - * @author Greg Sherwood - * @copyright 2009 SQLI - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -require_once 'PHPUnit/Framework/TestCase.php'; -require_once dirname(__FILE__).'/AbstractTestCase.php'; - -/** - * Tests for the Summary report of PHP_CodeSniffer. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Gabriele Santini - * @author Greg Sherwood - * @copyright 2009 SQLI - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Core_Reports_SummaryTest extends Core_Reports_AbstractTestCase -{ - - - /** - * Test standard generation. - * - * @return void - */ - public function testGenerate() - { - $fullReport = new PHP_CodeSniffer_Reports_Summary(); - $generated = $this->getFixtureReport($fullReport); - - $i = 1; - $line = strtok($generated, PHP_EOL); - while (false !== $line) { - $this->assertLessThan( - 81, - strlen($line), - 'Report line '.$i.' is longer than 80 characters' - ); - $i++; - $line = strtok(PHP_EOL); - } - - }//end testGenerate() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/tests/Core/Reports/SvnblameTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/tests/Core/Reports/SvnblameTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/tests/Core/Reports/SvnblameTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/tests/Core/Reports/SvnblameTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,82 +0,0 @@ - - * @author Greg Sherwood - * @copyright 2009 SQLI - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -require_once 'PHPUnit/Framework/TestCase.php'; -require_once dirname(__FILE__).'/AbstractTestCase.php'; -require_once dirname(__FILE__).'/Mock/Svnblame.php'; - -if (is_file(dirname(__FILE__).'/../../../CodeSniffer.php') === true) { - // We are not installed. - include_once dirname(__FILE__).'/../../../CodeSniffer/Reports/VersionControl.php'; -} else { - include_once 'PHP/CodeSniffer/Reports/VersionControl.php'; -} - -/** - * Tests for the Source report of PHP_CodeSniffer. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Gabriele Santini - * @author Greg Sherwood - * @copyright 2009 SQLI - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Core_Reports_SvnblameTest extends Core_Reports_AbstractTestCase -{ - - - /** - * Test standard generation - * - * @return void - */ - public function testGenerate() - { - $fullReport = new PHP_CodeSniffer_Reports_Mock_Svnblame(); - $generated = $this->getFixtureReport($fullReport); - $generatedLines = explode(PHP_EOL, $generated); - $this->assertGreaterThan(10, count($generatedLines)); - - }//end testGenerate() - - - /** - * Test author recovering from an svn blame line - * - * @return void - */ - public function testGetSvnAuthor() - { - $fixtureNormalRevisionNumber = ' 123 devel1 * @return void'; - $fixtureBigRevisionNumber = '123456 devel1 * @return void'; - - $fullReport = new PHP_CodeSniffer_Reports_Mock_Svnblame(); - $author = $fullReport->testGetSvnAuthor($fixtureNormalRevisionNumber); - $this->assertEquals('devel1', $author); - - $author = $fullReport->testGetSvnAuthor($fixtureBigRevisionNumber); - $this->assertEquals('devel1', $author); - - }//end testGetSvnAuthor() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/tests/Core/Reports/XSD/Checkstyle.xsd php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/tests/Core/Reports/XSD/Checkstyle.xsd --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/tests/Core/Reports/XSD/Checkstyle.xsd 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/tests/Core/Reports/XSD/Checkstyle.xsd 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/tests/Core/Reports/XSD/Xml.xsd php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/tests/Core/Reports/XSD/Xml.xsd --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/tests/Core/Reports/XSD/Xml.xsd 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/tests/Core/Reports/XSD/Xml.xsd 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/tests/Core/Reports/XmlTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/tests/Core/Reports/XmlTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/tests/Core/Reports/XmlTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/tests/Core/Reports/XmlTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,60 +0,0 @@ - - * @author Greg Sherwood - * @copyright 2009 SQLI - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -require_once 'PHPUnit/Framework/TestCase.php'; -require_once dirname(__FILE__).'/AbstractTestCase.php'; - -/** - * Tests for the XML report of PHP_CodeSniffer. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Gabriele Santini - * @author Greg Sherwood - * @copyright 2009 SQLI - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Core_Reports_XmlTest extends Core_Reports_AbstractTestCase -{ - - - /** - * Test standard generation against XML schema. - * - * @return void - */ - public function testGenerate() - { - $checkstyleReport = new PHP_CodeSniffer_Reports_Xml(); - $generated = $this->getFixtureReport($checkstyleReport); - $xmlDocument = new DOMDocument(); - - $xmlDocument->loadXML($generated); - $result = $xmlDocument->schemaValidate( - dirname(__FILE__).'/XSD/Xml.xsd' - ); - - $this->assertTrue($result); - - }//end testGenerate() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/tests/Standards/AbstractSniffUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/tests/Standards/AbstractSniffUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/tests/Standards/AbstractSniffUnitTest.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/tests/Standards/AbstractSniffUnitTest.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,403 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -require_once 'PHPUnit/Framework/TestCase.php'; - -/** - * An abstract class that all sniff unit tests must extend. - * - * A sniff unit test checks a .inc file for expected violations of a single - * coding standard. Expected errors and warnings that are not found, or - * warnings and errors that are not expected, are considered test failures. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -abstract class AbstractSniffUnitTest extends PHPUnit_Framework_TestCase -{ - - /** - * The PHP_CodeSniffer object used for testing. - * - * @var PHP_CodeSniffer - */ - protected static $phpcs = null; - - - /** - * Sets up this unit test. - * - * @return void - */ - protected function setUp() - { - if (self::$phpcs === null) { - self::$phpcs = new PHP_CodeSniffer(); - } - - }//end setUp() - - - /** - * Should this test be skipped for some reason. - * - * @return void - */ - protected function shouldSkipTest() - { - return false; - - }//end shouldSkipTest() - - - /** - * Tests the extending classes Sniff class. - * - * @return void - * @throws PHPUnit_Framework_Error - */ - protected final function runTest() - { - // Skip this test if we can't run in this environment. - if ($this->shouldSkipTest() === true) { - $this->markTestSkipped(); - } - - // The basis for determining file locations. - $basename = substr(get_class($this), 0, -8); - - // The name of the coding standard we are testing. - $standardName = substr($basename, 0, strpos($basename, '_')); - - // The class name of the sniff we are testing. - $sniffClass = str_replace('_Tests_', '_Sniffs_', $basename).'Sniff'; - - if (is_file(dirname(__FILE__).'/../../CodeSniffer.php') === true) { - // We have not been installed. - $standardsDir = realpath(dirname(__FILE__).'/../../CodeSniffer/Standards'); - $testFileBase = $standardsDir.DIRECTORY_SEPARATOR.str_replace('_', DIRECTORY_SEPARATOR, $basename).'UnitTest.'; - } else { - // The name of the dummy file we are testing. - $testFileBase = dirname(__FILE__).DIRECTORY_SEPARATOR.str_replace('_', DIRECTORY_SEPARATOR, $basename).'UnitTest.'; - } - - // Get a list of all test files to check. These will have the same base - // name but different extensions. We ignore the .php file as it is the - // class. - $testFiles = array(); - - $dir = substr($testFileBase, 0, strrpos($testFileBase, DIRECTORY_SEPARATOR)); - $di = new DirectoryIterator($dir); - - foreach ($di as $file) { - $path = $file->getPathname(); - if (substr($path, 0, strlen($testFileBase)) === $testFileBase) { - if ($path !== $testFileBase.'php') { - $testFiles[] = $path; - } - } - } - - // Get them in order. This is particularly important for multi-file sniffs. - sort($testFiles); - - $failureMessages = array(); - $multiFileSniff = false; - foreach ($testFiles as $testFile) { - try { - self::$phpcs->process(array(), $standardName, array($sniffClass)); - self::$phpcs->setIgnorePatterns(array()); - self::$phpcs->processFile($testFile); - self::$phpcs->processMulti(); - } catch (Exception $e) { - $this->fail('An unexpected exception has been caught: '.$e->getMessage()); - } - - // After processing a file, check if the sniff was actually - // a multi-file sniff (i.e., had no individual file sniffs). - // If it is, we can skip checking of the other files and - // do a single multi-file check. - $sniffs = self::$phpcs->getTokenSniffs(); - if (empty($sniffs['file']) === true) { - $multiFileSniff = true; - break; - } - - $files = self::$phpcs->getFiles(); - if (empty($files) === true) { - // File was skipped for some reason. - echo "Skipped: $testFile\n"; - $this->markTestSkipped(); - } - - $file = array_pop($files); - - $failures = $this->generateFailureMessages($file); - $failureMessages = array_merge($failureMessages, $failures); - }//end foreach - - if ($multiFileSniff === true) { - try { - self::$phpcs->process(array(), $standardName, array($sniffClass)); - self::$phpcs->setIgnorePatterns(array()); - foreach ($testFiles as $testFile) { - self::$phpcs->processFile($testFile); - } - - self::$phpcs->processMulti(); - } catch (Exception $e) { - $this->fail('An unexpected exception has been caught: '.$e->getMessage()); - } - - $files = self::$phpcs->getFiles(); - if (empty($files) === true) { - // File was skipped for some reason. - $this->markTestSkipped(); - } else { - foreach ($files as $file) { - $failures = $this->generateFailureMessages($file); - $failureMessages = array_merge($failureMessages, $failures); - } - } - }//end if - - if (empty($failureMessages) === false) { - $this->fail(implode(PHP_EOL, $failureMessages)); - } - - }//end testSniff() - - - /** - * Generate a list of test failures for a given sniffed file. - * - * @param PHP_CodeSniffer_File $file The file being tested. - * - * @return array - * @throws PHP_CodeSniffer_Exception - */ - public function generateFailureMessages(PHP_CodeSniffer_File $file) - { - $testFile = $file->getFilename(); - - $foundErrors = $file->getErrors(); - $foundWarnings = $file->getWarnings(); - $expectedErrors = $this->getErrorList(basename($testFile)); - $expectedWarnings = $this->getWarningList(basename($testFile)); - - if (is_array($expectedErrors) === false) { - throw new PHP_CodeSniffer_Exception('getErrorList() must return an array'); - } - - if (is_array($expectedWarnings) === false) { - throw new PHP_CodeSniffer_Exception('getWarningList() must return an array'); - } - - /* - We merge errors and warnings together to make it easier - to iterate over them and produce the errors string. In this way, - we can report on errors and warnings in the same line even though - it's not really structured to allow that. - */ - - $allProblems = array(); - $failureMessages = array(); - - foreach ($foundErrors as $line => $lineErrors) { - foreach ($lineErrors as $column => $errors) { - if (isset($allProblems[$line]) === false) { - $allProblems[$line] = array( - 'expected_errors' => 0, - 'expected_warnings' => 0, - 'found_errors' => array(), - 'found_warnings' => array(), - ); - } - - $foundErrorsTemp = array(); - foreach ($allProblems[$line]['found_errors'] as $foundError) { - $foundErrorsTemp[] = $foundError; - } - - $errorsTemp = array(); - foreach ($errors as $foundError) { - $errorsTemp[] = $foundError['message']; - } - - $allProblems[$line]['found_errors'] = array_merge($foundErrorsTemp, $errorsTemp); - } - - if (isset($expectedErrors[$line]) === true) { - $allProblems[$line]['expected_errors'] = $expectedErrors[$line]; - } else { - $allProblems[$line]['expected_errors'] = 0; - } - - unset($expectedErrors[$line]); - }//end foreach - - foreach ($expectedErrors as $line => $numErrors) { - if (isset($allProblems[$line]) === false) { - $allProblems[$line] = array( - 'expected_errors' => 0, - 'expected_warnings' => 0, - 'found_errors' => array(), - 'found_warnings' => array(), - ); - } - - $allProblems[$line]['expected_errors'] = $numErrors; - } - - foreach ($foundWarnings as $line => $lineWarnings) { - foreach ($lineWarnings as $column => $warnings) { - if (isset($allProblems[$line]) === false) { - $allProblems[$line] = array( - 'expected_errors' => 0, - 'expected_warnings' => 0, - 'found_errors' => array(), - 'found_warnings' => array(), - ); - } - - $foundWarningsTemp = array(); - foreach ($allProblems[$line]['found_warnings'] as $foundWarning) { - $foundWarningsTemp[] = $foundWarning; - } - - $warningsTemp = array(); - foreach ($warnings as $warning) { - $warningsTemp[] = $warning['message']; - } - - $allProblems[$line]['found_warnings'] = array_merge($foundWarningsTemp, $warningsTemp); - } - - if (isset($expectedWarnings[$line]) === true) { - $allProblems[$line]['expected_warnings'] = $expectedWarnings[$line]; - } else { - $allProblems[$line]['expected_warnings'] = 0; - } - - unset($expectedWarnings[$line]); - }//end foreach - - foreach ($expectedWarnings as $line => $numWarnings) { - if (isset($allProblems[$line]) === false) { - $allProblems[$line] = array( - 'expected_errors' => 0, - 'expected_warnings' => 0, - 'found_errors' => array(), - 'found_warnings' => array(), - ); - } - - $allProblems[$line]['expected_warnings'] = $numWarnings; - } - - // Order the messages by line number. - ksort($allProblems); - - foreach ($allProblems as $line => $problems) { - $numErrors = count($problems['found_errors']); - $numWarnings = count($problems['found_warnings']); - $expectedErrors = $problems['expected_errors']; - $expectedWarnings = $problems['expected_warnings']; - - $errors = ''; - $foundString = ''; - - if ($expectedErrors !== $numErrors || $expectedWarnings !== $numWarnings) { - $lineMessage = "[LINE $line]"; - $expectedMessage = 'Expected '; - $foundMessage = 'in '.basename($testFile).' but found '; - - if ($expectedErrors !== $numErrors) { - $expectedMessage .= "$expectedErrors error(s)"; - $foundMessage .= "$numErrors error(s)"; - if ($numErrors !== 0) { - $foundString .= 'error(s)'; - $errors .= implode(PHP_EOL.' -> ', $problems['found_errors']); - } - - if ($expectedWarnings !== $numWarnings) { - $expectedMessage .= ' and '; - $foundMessage .= ' and '; - if ($numWarnings !== 0) { - if ($foundString !== '') { - $foundString .= ' and '; - } - } - } - } - - if ($expectedWarnings !== $numWarnings) { - $expectedMessage .= "$expectedWarnings warning(s)"; - $foundMessage .= "$numWarnings warning(s)"; - if ($numWarnings !== 0) { - $foundString .= 'warning(s)'; - if (empty($errors) === false) { - $errors .= PHP_EOL.' -> '; - } - - $errors .= implode(PHP_EOL.' -> ', $problems['found_warnings']); - } - } - - $fullMessage = "$lineMessage $expectedMessage $foundMessage."; - if ($errors !== '') { - $fullMessage .= " The $foundString found were:".PHP_EOL." -> $errors"; - } - - $failureMessages[] = $fullMessage; - }//end if - }//end foreach - - return $failureMessages; - - }//end generateFailureMessages() - - - /** - * 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) - */ - protected abstract function 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) - */ - protected abstract function getWarningList(); - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/tests/Standards/AllSniffs.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/tests/Standards/AllSniffs.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/tests/Standards/AllSniffs.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/tests/Standards/AllSniffs.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,125 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -// Require this here so that the unit tests don't have to try and find the -// abstract class once it is installed into the PEAR tests directory. -require_once dirname(__FILE__).'/AbstractSniffUnitTest.php'; - -/** - * A test class for testing all sniffs for installed standards. - * - * Usage: phpunit AllSniffs.php - * - * This test class loads all unit tests for all installed standards into a - * single test suite and runs them. Errors are reported on the command line. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PHP_CodeSniffer_Standards_AllSniffs -{ - - - /** - * Prepare the test runner. - * - * @return void - */ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - - }//end main() - - - /** - * Add all sniff unit tests into a test suite. - * - * Sniff unit tests are found by recursing through the 'Tests' directory - * of each installed coding standard. - * - * @return PHPUnit_Framework_TestSuite - */ - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('PHP CodeSniffer Standards'); - - $isInstalled = !is_file(dirname(__FILE__).'/../../CodeSniffer.php'); - - if ($isInstalled === false) { - // We have not been installed. - $standardsDir = realpath(dirname(__FILE__).'/../../CodeSniffer/Standards'); - } else { - $standardsDir = ''; - } - - $standards = PHP_CodeSniffer::getInstalledStandards(true, $standardsDir); - - foreach ($standards as $standard) { - if ($isInstalled === false) { - $standardDir = $standardsDir.'/'.$standard.'/Tests/'; - } else { - $standardDir = dirname(__FILE__).'/'.$standard.'/Tests/'; - } - - if (is_dir($standardDir) === false) { - // No tests for this standard. - continue; - } - - // Locate the actual directory that contains the standard's tests. - // This is individual to each standard as they could be symlinked in. - $baseDir = dirname(dirname($standardDir)); - - $di = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($standardDir)); - - foreach ($di as $file) { - // Skip hidden files. - if (substr($file->getFilename(), 0, 1) === '.') { - continue; - } - - // Tests must have the extension 'php'. - $parts = explode('.', $file); - $ext = array_pop($parts); - if ($ext !== 'php') { - continue; - } - - $filePath = $file->getPathname(); - $className = str_replace($baseDir.DIRECTORY_SEPARATOR, '', $filePath); - $className = substr($className, 0, -4); - $className = str_replace(DIRECTORY_SEPARATOR, '_', $className); - - include_once $filePath; - $class = new $className('getErrorList'); - $suite->addTest($class); - }//end foreach - }//end foreach - - return $suite; - - }//end suite() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/tests/TestSuite.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/tests/TestSuite.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/tests/TestSuite.php 2012-05-17 03:49:06.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.3.4/tests/TestSuite.php 1970-01-01 00:00:00.000000000 +0000 @@ -1,56 +0,0 @@ - - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -require_once 'PHPUnit/Framework/TestSuite.php'; - -/** - * A PHP_CodeSniffer specific test suite for PHPUnit. - * - * Unregisters the PHP_CodeSniffer autoload function after the run. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.4 - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class PHP_CodeSniffer_TestSuite extends PHPUnit_Framework_TestSuite -{ - - - /** - * Runs the tests and collects their result in a TestResult. - * - * @param PHPUnit_Framework_TestResult $result A test result. - * @param mixed $filter The filter passed to each test. - * - * @return PHPUnit_Framework_TestResult - */ - public function run(PHPUnit_Framework_TestResult $result=null, $filter=false) - { - spl_autoload_register(array('PHP_CodeSniffer', 'autoload')); - $result = parent::run($result, $filter); - spl_autoload_unregister(array('PHP_CodeSniffer', 'autoload')); - return $result; - - }//end run() - - -}//end class - -?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/CLI.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/CLI.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/CLI.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/CLI.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,882 @@ + + * @copyright 2006-2012 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 + */ + +if (is_file(dirname(__FILE__).'/../CodeSniffer.php') === true) { + include_once dirname(__FILE__).'/../CodeSniffer.php'; +} else { + include_once 'PHP/CodeSniffer.php'; +} + +/** + * A class to process command line phpcs scripts. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PHP_CodeSniffer_CLI +{ + + /** + * An array of all values specified on the command line. + * + * @var array + */ + protected $values = array(); + + /** + * The minimum severity level errors must have to be displayed. + * + * @var bool + */ + public $errorSeverity = 0; + + /** + * The minimum severity level warnings must have to be displayed. + * + * @var bool + */ + public $warningSeverity = 0; + + /** + * Whether or not to kill the process when an unknown command line arg is found. + * + * If FALSE, arguments that are not command line options or file/directory paths + * will be ignored and execution will continue. + * + * @var bool + */ + public $dieOnUnknownArg = true; + + + /** + * Exits if the minimum requirements of PHP_CodSniffer are not met. + * + * @return array + */ + public function checkRequirements() + { + // Check the PHP version. + if (version_compare(PHP_VERSION, '5.1.2') === -1) { + echo 'ERROR: PHP_CodeSniffer requires PHP version 5.1.2 or greater.'.PHP_EOL; + exit(2); + } + + if (extension_loaded('tokenizer') === false) { + echo 'ERROR: PHP_CodeSniffer requires the tokenizer extension to be enabled.'.PHP_EOL; + exit(2); + } + + }//end checkRequirements() + + + /** + * Get a list of default values for all possible command line arguments. + * + * @return array + */ + public function getDefaults() + { + // The default values for config settings. + $defaults['files'] = array(); + $defaults['standard'] = null; + $defaults['verbosity'] = 0; + $defaults['interactive'] = false; + $defaults['explain'] = false; + $defaults['local'] = false; + $defaults['showSources'] = false; + $defaults['extensions'] = array(); + $defaults['sniffs'] = array(); + $defaults['ignored'] = array(); + $defaults['reportFile'] = null; + $defaults['generator'] = ''; + $defaults['reports'] = array(); + $defaults['errorSeverity'] = null; + $defaults['warningSeverity'] = null; + + $reportFormat = PHP_CodeSniffer::getConfigData('report_format'); + if ($reportFormat !== null) { + $defaults['reports'][$reportFormat] = null; + } + + $tabWidth = PHP_CodeSniffer::getConfigData('tab_width'); + if ($tabWidth === null) { + $defaults['tabWidth'] = 0; + } else { + $defaults['tabWidth'] = (int) $tabWidth; + } + + $encoding = PHP_CodeSniffer::getConfigData('encoding'); + if ($encoding === null) { + $defaults['encoding'] = 'iso-8859-1'; + } else { + $defaults['encoding'] = strtolower($encoding); + } + + $severity = PHP_CodeSniffer::getConfigData('severity'); + if ($severity !== null) { + $defaults['errorSeverity'] = (int) $severity; + $defaults['warningSeverity'] = (int) $severity; + } + + $severity = PHP_CodeSniffer::getConfigData('error_severity'); + if ($severity !== null) { + $defaults['errorSeverity'] = (int) $severity; + } + + $severity = PHP_CodeSniffer::getConfigData('warning_severity'); + if ($severity !== null) { + $defaults['warningSeverity'] = (int) $severity; + } + + $showWarnings = PHP_CodeSniffer::getConfigData('show_warnings'); + if ($showWarnings !== null) { + $showWarnings = (bool) $showWarnings; + if ($showWarnings === false) { + $defaults['warningSeverity'] = 0; + } + } + + $reportWidth = PHP_CodeSniffer::getConfigData('report_width'); + if ($reportWidth === null) { + $defaults['reportWidth'] = 80; + } else { + $defaults['reportWidth'] = (int) $reportWidth; + } + + $showProgress = PHP_CodeSniffer::getConfigData('show_progress'); + if ($showProgress === null) { + $defaults['showProgress'] = false; + } else { + $defaults['showProgress'] = (bool) $showProgress; + } + + return $defaults; + + }//end getDefaults() + + + /** + * Process the command line arguments and returns the values. + * + * @return array + */ + public function getCommandLineValues() + { + if (defined('PHP_CODESNIFFER_IN_TESTS') === true) { + return array(); + } + + if (empty($this->values) === false) { + return $this->values; + } + + $values = $this->getDefaults(); + + for ($i = 1; $i < $_SERVER['argc']; $i++) { + $arg = $_SERVER['argv'][$i]; + if ($arg === '') { + continue; + } + + if ($arg{0} === '-') { + if ($arg === '-' || $arg === '--') { + // Empty argument, ignore it. + continue; + } + + if ($arg{1} === '-') { + $values + = $this->processLongArgument(substr($arg, 2), $i, $values); + } else { + $switches = str_split($arg); + foreach ($switches as $switch) { + if ($switch === '-') { + continue; + } + + $values = $this->processShortArgument($switch, $i, $values); + } + } + } else { + $values = $this->processUnknownArgument($arg, $i, $values); + }//end if + }//end for + + $this->values = $values; + return $values; + + }//end getCommandLineValues() + + + /** + * Processes a short (-e) command line argument. + * + * @param string $arg The command line argument. + * @param int $pos The position of the argument on the command line. + * @param array $values An array of values determined from CLI args. + * + * @return array The updated CLI values. + * @see getCommandLineValues() + */ + public function processShortArgument($arg, $pos, $values) + { + switch ($arg) { + case 'h': + case '?': + $this->printUsage(); + exit(0); + break; + case 'i' : + $this->printInstalledStandards(); + exit(0); + break; + case 'v' : + $values['verbosity']++; + break; + case 'l' : + $values['local'] = true; + break; + case 's' : + $values['showSources'] = true; + break; + case 'a' : + $values['interactive'] = true; + break; + case 'e': + $values['explain'] = true; + break; + case 'p' : + $values['showProgress'] = true; + break; + case 'd' : + $ini = explode('=', $_SERVER['argv'][($pos + 1)]); + $_SERVER['argv'][($pos + 1)] = ''; + if (isset($ini[1]) === true) { + ini_set($ini[0], $ini[1]); + } else { + ini_set($ini[0], true); + } + + break; + case 'n' : + $values['warningSeverity'] = 0; + break; + case 'w' : + $values['warningSeverity'] = null; + break; + default: + $values = $this->processUnknownArgument('-'.$arg, $pos, $values); + }//end switch + + return $values; + + }//end processShortArgument() + + + /** + * Processes a long (--example) command line argument. + * + * @param string $arg The command line argument. + * @param int $pos The position of the argument on the command line. + * @param array $values An array of values determined from CLI args. + * + * @return array The updated CLI values. + * @see getCommandLineValues() + */ + public function processLongArgument($arg, $pos, $values) + { + switch ($arg) { + case 'help': + $this->printUsage(); + exit(0); + break; + case 'version': + echo 'PHP_CodeSniffer version 1.5.0RC2 (beta) '; + echo 'by Squiz Pty Ltd. (http://www.squiz.com.au)'.PHP_EOL; + exit(0); + break; + case 'config-set': + $key = $_SERVER['argv'][($pos + 1)]; + $value = $_SERVER['argv'][($pos + 2)]; + PHP_CodeSniffer::setConfigData($key, $value); + exit(0); + break; + case 'config-delete': + $key = $_SERVER['argv'][($pos + 1)]; + PHP_CodeSniffer::setConfigData($key, null); + exit(0); + break; + case 'config-show': + $data = PHP_CodeSniffer::getAllConfigData(); + print_r($data); + exit(0); + break; + default: + if (substr($arg, 0, 7) === 'sniffs=') { + $values['sniffs'] = array(); + + $sniffs = substr($arg, 7); + $sniffs = explode(',', $sniffs); + + // Convert the sniffs to class names. + foreach ($sniffs as $sniff) { + $parts = explode('.', strtolower($sniff)); + $values['sniffs'][] = $parts[0].'_sniffs_'.$parts[1].'_'.$parts[2].'sniff'; + } + } else if (substr($arg, 0, 12) === 'report-file=') { + $values['reportFile'] = realpath(substr($arg, 12)); + + // It may not exist and return false instead. + if ($values['reportFile'] === false) { + $values['reportFile'] = substr($arg, 12); + } + + if (is_dir($values['reportFile']) === true) { + echo 'ERROR: The specified report file path "'.$values['reportFile'].'" is a directory.'.PHP_EOL.PHP_EOL; + $this->printUsage(); + exit(2); + } + + $dir = dirname($values['reportFile']); + if (is_dir($dir) === false) { + echo 'ERROR: The specified report file path "'.$values['reportFile'].'" points to a non-existent directory.'.PHP_EOL.PHP_EOL; + $this->printUsage(); + exit(2); + } + + if ($dir === '.') { + // Passed report file is a filename in the current directory. + $values['reportFile'] = getcwd().'/'.basename($values['reportFile']); + } else { + $dir = realpath(getcwd().'/'.$dir); + if ($dir !== false) { + // Report file path is relative. + $values['reportFile'] = $dir.'/'.basename($values['reportFile']); + } + } + } else if (substr($arg, 0, 13) === 'report-width=') { + $values['reportWidth'] = (int) substr($arg, 13); + } else if (substr($arg, 0, 7) === 'report=' + || substr($arg, 0, 7) === 'report-' + ) { + if ($arg[6] === '-') { + // This is a report with file output. + $split = strpos($arg, '='); + if ($split === false) { + $report = substr($arg, 7); + $output = null; + } else { + $report = substr($arg, 7, ($split - 7)); + $output = substr($arg, ($split + 1)); + if ($output === false) { + $output = null; + } else { + $dir = dirname($output); + if ($dir === '.') { + // Passed report file is a filename in the current directory. + $output = getcwd().'/'.basename($output); + } else { + $dir = realpath(getcwd().'/'.$dir); + if ($dir !== false) { + // Report file path is relative. + $output = $dir.'/'.basename($output); + } + } + }//end if + }//end if + } else { + // This is a single report. + $report = substr($arg, 7); + $output = null; + } + + $validReports = array( + 'full', + 'xml', + 'checkstyle', + 'csv', + 'emacs', + 'notifysend', + 'source', + 'summary', + 'svnblame', + 'gitblame', + 'hgblame', + ); + + if (in_array($report, $validReports) === false) { + echo 'ERROR: Report type "'.$report.'" not known.'.PHP_EOL; + exit(2); + } + + $values['reports'][$report] = $output; + } else if (substr($arg, 0, 9) === 'standard=') { + $values['standard'] = explode(',', substr($arg, 9)); + } else if (substr($arg, 0, 11) === 'extensions=') { + $values['extensions'] = explode(',', substr($arg, 11)); + } else if (substr($arg, 0, 9) === 'severity=') { + $values['errorSeverity'] = (int) substr($arg, 9); + $values['warningSeverity'] = $values['errorSeverity']; + } else if (substr($arg, 0, 15) === 'error-severity=') { + $values['errorSeverity'] = (int) substr($arg, 15); + } else if (substr($arg, 0, 17) === 'warning-severity=') { + $values['warningSeverity'] = (int) substr($arg, 17); + } else if (substr($arg, 0, 7) === 'ignore=') { + // Split the ignore string on commas, unless the comma is escaped + // using 1 or 3 slashes (\, or \\\,). + $ignored = preg_split( + '/(?<=(?processUnknownArgument('--'.$arg, $pos, $values); + }//end if + + break; + }//end switch + + return $values; + + }//end processLongArgument() + + + /** + * Processes an unknown command line argument. + * + * Assumes all unknown arguments are files and folders to check. + * + * @param string $arg The command line argument. + * @param int $pos The position of the argument on the command line. + * @param array $values An array of values determined from CLI args. + * + * @return array The updated CLI values. + * @see getCommandLineValues() + */ + public function processUnknownArgument($arg, $pos, $values) + { + // We don't know about any additional switches; just files. + if ($arg{0} === '-') { + if ($this->dieOnUnknownArg === false) { + return $values; + } + + echo 'ERROR: option "'.$arg.'" not known.'.PHP_EOL.PHP_EOL; + $this->printUsage(); + exit(2); + } + + $file = realpath($arg); + if (file_exists($file) === false) { + if ($this->dieOnUnknownArg === false) { + return $values; + } + + echo 'ERROR: The file "'.$arg.'" does not exist.'.PHP_EOL.PHP_EOL; + $this->printUsage(); + exit(2); + } else { + $values['files'][] = $file; + } + + return $values; + + }//end processUnknownArgument() + + + /** + * Runs PHP_CodeSniffer over files and directories. + * + * @param array $values An array of values determined from CLI args. + * + * @return int The number of error and warning messages shown. + * @see getCommandLineValues() + */ + public function process($values=array()) + { + if (empty($values) === true) { + $values = $this->getCommandLineValues(); + } + + if ($values['generator'] !== '') { + $phpcs = new PHP_CodeSniffer($values['verbosity']); + foreach ($values['standard'] as $standard) { + $phpcs->generateDocs( + $standard, + $values['files'], + $values['generator'] + ); + } + exit(0); + } + + // If no standard is supplied, get the default. + $values['standard'] = $this->validateStandard($values['standard']); + foreach ($values['standard'] as $standard) { + if (PHP_CodeSniffer::isInstalledStandard($standard) === false) { + // They didn't select a valid coding standard, so help them + // out by letting them know which standards are installed. + echo 'ERROR: the "'.$standard.'" coding standard is not installed. '; + $this->printInstalledStandards(); + exit(2); + } + } + + if ($values['explain'] === true) { + foreach ($values['standard'] as $standard) { + $this->explainStandard($standard); + } + + exit(0); + } + + $fileContents = ''; + if (empty($values['files']) === true) { + // Check if they are passing in the file contents. + $handle = fopen('php://stdin', 'r'); + $fileContents = stream_get_contents($handle); + fclose($handle); + + if ($fileContents === '') { + // No files and no content passed in. + echo 'ERROR: You must supply at least one file or directory to process.'.PHP_EOL.PHP_EOL; + $this->printUsage(); + exit(2); + } + } + + $phpcs = new PHP_CodeSniffer( + $values['verbosity'], + $values['tabWidth'], + $values['encoding'], + $values['interactive'] + ); + + // Set file extensions if they were specified. Otherwise, + // let PHP_CodeSniffer decide on the defaults. + if (empty($values['extensions']) === false) { + $phpcs->setAllowedFileExtensions($values['extensions']); + } + + // Set ignore patterns if they were specified. + if (empty($values['ignored']) === false) { + $phpcs->setIgnorePatterns($values['ignored']); + } + + // Set some convenience member vars. + if ($values['errorSeverity'] === null) { + $this->errorSeverity = PHPCS_DEFAULT_ERROR_SEV; + } else { + $this->errorSeverity = $values['errorSeverity']; + } + + if ($values['warningSeverity'] === null) { + $this->warningSeverity = PHPCS_DEFAULT_WARN_SEV; + } else { + $this->warningSeverity = $values['warningSeverity']; + } + + if (empty($values['reports']) === true) { + $this->values['reports']['full'] = $values['reportFile']; + } + + $phpcs->setCli($this); + + $phpcs->process( + $values['files'], + $values['standard'], + $values['sniffs'], + $values['local'] + ); + + if ($fileContents !== '') { + $phpcs->processFile('STDIN', $fileContents); + } + + // Interactive runs don't require a final report and it doesn't really + // matter what the retun value is because we know it isn't being read + // by a script. + if ($values['interactive'] === true) { + return 0; + } + + return $this->printErrorReport( + $phpcs, + $values['reports'], + $values['showSources'], + $values['reportFile'], + $values['reportWidth'] + ); + + }//end process() + + + /** + * Prints the error report for the run. + * + * Note that this function may actually print multiple reports + * as the user may have specified a number of output formats. + * + * @param PHP_CodeSniffer $phpcs The PHP_CodeSniffer object containing + * the errors. + * @param array $reports A list of reports to print. + * @param bool $showSources TRUE if report should show error sources + * (not used by all reports). + * @param string $reportFile A default file to log report output to. + * @param int $reportWidth How wide the screen reports should be. + * + * @return int The number of error and warning messages shown. + */ + public function printErrorReport( + PHP_CodeSniffer $phpcs, + $reports, + $showSources, + $reportFile, + $reportWidth + ) { + if (empty($reports) === true) { + $reports['full'] = $reportFile; + } + + $errors = 0; + $toScreen = false; + + foreach ($reports as $report => $output) { + if ($output === null) { + $output = $reportFile; + } + + if ($reportFile === null) { + $toScreen = true; + } + + // We don't add errors here because the number of + // errors reported by each report type will always be the + // same, so we really just need 1 number. + $errors = $phpcs->reporting->printReport( + $report, + $showSources, + $output, + $reportWidth + ); + } + + // Only print PHP_Timer output if no reports were + // printed to the screen so we don't put additional output + // in something like an XML report. If we are printing to screen, + // the report types would have already worked out who should + // print the timer info. + if ($toScreen === false + && PHP_CODESNIFFER_INTERACTIVE === false + && class_exists('PHP_Timer', false) === true + ) { + echo PHP_Timer::resourceUsage().PHP_EOL.PHP_EOL; + } + + // They should all return the same value, so it + // doesn't matter which return value we end up using. + return $errors; + + }//end printErrorReport() + + + /** + * Convert the passed standards into valid standards. + * + * Checks things like default values and case. + * + * @param array $standards The standards to validate. + * + * @return array + */ + public function validateStandard($standards) + { + if ($standards === null) { + // They did not supply a standard to use. + // Try to get the default from the config system. + $standard = PHP_CodeSniffer::getConfigData('default_standard'); + if ($standard === null) { + // Product default standard. + $standard = 'PEAR'; + } + + return array($standard); + } + + $cleaned = array(); + + // Check if the standard name is valid, or if the case is invalid. + $installedStandards = PHP_CodeSniffer::getInstalledStandards(); + foreach ($standards as $standard) { + foreach ($installedStandards as $validStandard) { + if (strtolower($standard) === strtolower($validStandard)) { + $standard = $validStandard; + break; + } + } + + $cleaned[] = $standard; + } + + return $cleaned; + + }//end validateStandard() + + + /** + * Prints a report showing the sniffs contained in a standard. + * + * @param string $standard The standard to validate. + * + * @return void + */ + public function explainStandard($standard) + { + $phpcs = new PHP_CodeSniffer(); + $phpcs->process(array(), $standard); + $sniffs = $phpcs->getSniffs(); + $sniffs = array_keys($sniffs); + sort($sniffs); + + ob_start(); + + $lastStandard = ''; + $lastCount = ''; + $sniffCount = count($sniffs); + $sniffs[] = '___'; + + echo PHP_EOL."The $standard standard contains $sniffCount sniffs".PHP_EOL; + + ob_start(); + + foreach ($sniffs as $sniff) { + $parts = explode('_', $sniff); + if ($lastStandard === '') { + $lastStandard = $parts[0]; + } + + if ($parts[0] !== $lastStandard) { + $sniffList = ob_get_contents(); + ob_end_clean(); + + echo PHP_EOL.$lastStandard.' ('.$lastCount.' sniffs)'.PHP_EOL; + echo str_repeat('-', strlen($lastStandard.$lastCount) + 10); + echo PHP_EOL; + echo $sniffList; + + $lastStandard = $parts[0]; + $lastCount = 0; + + ob_start(); + } + + echo ' '.$parts[0].'.'.$parts[2].'.'.substr($parts[3], 0, -5).PHP_EOL; + $lastCount++; + }//end foreach + + ob_end_clean(); + + }//end explainStandard() + + + /** + * Prints out the usage information for this script. + * + * @return void + */ + public function printUsage() + { + echo 'Usage: phpcs [-nwlsaepvi] [-d key[=value]]'.PHP_EOL; + echo ' [--report=] [--report-file=] [--report-=] ...'.PHP_EOL; + echo ' [--report-width=] [--generator=] [--tab-width=]'.PHP_EOL; + echo ' [--severity=] [--error-severity=] [--warning-severity=]'.PHP_EOL; + echo ' [--config-set key value] [--config-delete key] [--config-show]'.PHP_EOL; + echo ' [--standard=] [--sniffs=] [--encoding=]'.PHP_EOL; + echo ' [--extensions=] [--ignore=] ...'.PHP_EOL; + echo ' -n Do not print warnings (shortcut for --warning-severity=0)'.PHP_EOL; + echo ' -w Print both warnings and errors (on by default)'.PHP_EOL; + echo ' -l Local directory only, no recursion'.PHP_EOL; + echo ' -s Show sniff codes in all reports'.PHP_EOL; + echo ' -a Run interactively'.PHP_EOL; + echo ' -e Explain a standard by showing the sniffs it includes'.PHP_EOL; + echo ' -p Show progress of the run'.PHP_EOL; + echo ' -v[v][v] Print verbose output'.PHP_EOL; + echo ' -i Show a list of installed coding standards'.PHP_EOL; + echo ' -d Set the [key] php.ini value to [value] or [true] if value is omitted'.PHP_EOL; + echo ' --help Print this help message'.PHP_EOL; + echo ' --version Print version information'.PHP_EOL; + echo ' One or more files and/or directories to check'.PHP_EOL; + echo ' A comma separated list of file extensions to check'.PHP_EOL; + echo ' (only valid if checking a directory)'.PHP_EOL; + echo ' A comma separated list of patterns to ignore files and directories'.PHP_EOL; + echo ' The encoding of the files being checked (default is iso-8859-1)'.PHP_EOL; + echo ' A comma separated list of sniff codes to limit the check to'.PHP_EOL; + echo ' (all sniffs must be part of the specified standard)'.PHP_EOL; + echo ' The minimum severity required to display an error or warning'.PHP_EOL; + echo ' The name or path of the coding standard to use'.PHP_EOL; + echo ' The number of spaces each tab represents'.PHP_EOL; + echo ' The name of a doc generator to use'.PHP_EOL; + echo ' (forces doc generation instead of checking)'.PHP_EOL; + echo ' Print either the "full", "xml", "checkstyle", "csv", "emacs"'.PHP_EOL; + echo ' "source", "summary", "svnblame", "gitblame", "hgblame" or'.PHP_EOL; + echo ' "notifysend" report'.PHP_EOL; + echo ' (the "full" report is printed by default)'.PHP_EOL; + echo ' Write the report to the specified file path'.PHP_EOL; + echo ' How many columns wide screen reports should be printed'.PHP_EOL; + + }//end printUsage() + + + /** + * Prints out a list of installed coding standards. + * + * @return void + */ + public function printInstalledStandards() + { + $installedStandards = PHP_CodeSniffer::getInstalledStandards(); + $numStandards = count($installedStandards); + + if ($numStandards === 0) { + echo 'No coding standards are installed.'.PHP_EOL; + } else { + $lastStandard = array_pop($installedStandards); + if ($numStandards === 1) { + echo "The only coding standard installed is $lastStandard".PHP_EOL; + } else { + $standardList = implode(', ', $installedStandards); + $standardList .= ' and '.$lastStandard; + echo 'The installed coding standards are '.$standardList.PHP_EOL; + } + } + + }//end printInstalledStandards() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/CommentParser/AbstractDocElement.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/CommentParser/AbstractDocElement.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/CommentParser/AbstractDocElement.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/CommentParser/AbstractDocElement.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,353 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +if (interface_exists('PHP_CodeSniffer_CommentParser_DocElement', true) === false) { + $error = 'Interface PHP_CodeSniffer_CommentParser_DocElement not found'; + throw new PHP_CodeSniffer_Exception($error); +} + +/** + * A class to handle most of the parsing operations of a doc comment element. + * + * Extending classes should implement the getSubElements method to return + * a list of elements that the doc comment element contains, in the order that + * they appear in the element. For example a function parameter element has a + * type, a variable name and a comment. It should therefore implement the method + * as follows: + * + * + * protected function getSubElements() + * { + * return array( + * 'type', + * 'variable', + * 'comment', + * ); + * } + * + * + * The processSubElement will be called for each of the sub elements to allow + * the extending class to process them. So for the parameter element we would + * have: + * + * + * protected function processSubElement($name, $content, $whitespaceBefore) + * { + * if ($name === 'type') { + * echo 'The name of the variable was '.$content; + * } + * // Process other tags. + * } + * + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +abstract class PHP_CodeSniffer_CommentParser_AbstractDocElement implements PHP_CodeSniffer_CommentParser_DocElement +{ + + /** + * The element previous to this element. + * + * @var PHP_CodeSniffer_CommentParser_DocElement + */ + protected $previousElement = null; + + /** + * The element proceeding this element. + * + * @var PHP_CodeSniffer_CommentParser_DocElement + */ + protected $nextElement = null; + + /** + * The whitespace the occurs after this element and its sub elements. + * + * @var string + */ + protected $afterWhitespace = ''; + + /** + * The tokens that comprise this element. + * + * @var array(string) + */ + protected $tokens = array(); + + /** + * The file this element is in. + * + * @var array(string) + */ + protected $phpcsFile = null; + + /** + * The tag that this element represents (omitting the @ symbol). + * + * @var string + */ + protected $tag = ''; + + + /** + * Constructs a Doc Element. + * + * @param PHP_CodeSniffer_CommentParser_DocElement $previousElement The element + * that ocurred + * before this. + * @param array $tokens The tokens of + * this element. + * @param string $tag The doc + * element tag + * this element + * represents. + * @param PHP_CodeSniffer_File $phpcsFile The file that + * this element + * is in. + * + * @throws Exception If $previousElement in not a DocElement or if + * getSubElements() does not return an array. + */ + public function __construct( + $previousElement, + array $tokens, + $tag, + PHP_CodeSniffer_File $phpcsFile + ) { + if ($previousElement !== null + && ($previousElement instanceof PHP_CodeSniffer_CommentParser_DocElement) === false + ) { + $error = '$previousElement must be an instance of DocElement'; + throw new Exception($error); + } + + $this->phpcsFile = $phpcsFile; + + $this->previousElement = $previousElement; + if ($previousElement !== null) { + $this->previousElement->nextElement = $this; + } + + $this->tag = $tag; + $this->tokens = $tokens; + + $subElements = $this->getSubElements(); + + if (is_array($subElements) === false) { + throw new Exception('getSubElements() must return an array'); + } + + $whitespace = ''; + $currElem = 0; + $lastElement = ''; + $lastElementWhitespace = null; + $numSubElements = count($subElements); + + foreach ($this->tokens as $token) { + if (trim($token) === '') { + $whitespace .= $token; + } else { + if ($currElem < ($numSubElements - 1)) { + $element = $subElements[$currElem]; + $this->processSubElement($element, $token, $whitespace); + $whitespace = ''; + $currElem++; + } else { + if ($lastElementWhitespace === null) { + $lastElementWhitespace = $whitespace; + } + + $lastElement .= $whitespace.$token; + $whitespace = ''; + } + } + }//end foreach + + $lastElement = ltrim($lastElement); + $lastElementName = $subElements[($numSubElements - 1)]; + + // Process the last element in this tag. + $this->processSubElement( + $lastElementName, + $lastElement, + $lastElementWhitespace + ); + + $this->afterWhitespace = $whitespace; + + }//end __construct() + + + /** + * Returns the element that exists before this. + * + * @return PHP_CodeSniffer_CommentParser_DocElement + */ + public function getPreviousElement() + { + return $this->previousElement; + + }//end getPreviousElement() + + + /** + * Returns the element that exists after this. + * + * @return PHP_CodeSniffer_CommentParser_DocElement + */ + public function getNextElement() + { + return $this->nextElement; + + }//end getNextElement() + + + /** + * Returns the whitespace that exists before this element. + * + * @return string + */ + public function getWhitespaceBefore() + { + if ($this->previousElement !== null) { + return $this->previousElement->getWhitespaceAfter(); + } + + return ''; + + }//end getWhitespaceBefore() + + + /** + * Returns the whitespace that exists after this element. + * + * @return string + */ + public function getWhitespaceAfter() + { + return $this->afterWhitespace; + + }//end getWhitespaceAfter() + + + /** + * Returns the order that this element appears in the comment. + * + * @return int + */ + public function getOrder() + { + if ($this->previousElement === null) { + return 1; + } else { + return ($this->previousElement->getOrder() + 1); + } + + }//end getOrder() + + + /** + * Returns the tag that this element represents, ommiting the @ symbol. + * + * @return string + */ + public function getTag() + { + return $this->tag; + + }//end getTag() + + + /** + * Returns the raw content of this element, ommiting the tag. + * + * @return string + */ + public function getRawContent() + { + return implode('', $this->tokens); + + }//end getRawContent() + + + /** + * Returns the comment tokens. + * + * @return array + */ + public function getTokens() + { + return $this->tokens; + + }//end getTokens() + + + /** + * Returns the line in which this element first occured. + * + * @return int + */ + public function getLine() + { + if ($this->previousElement === null) { + // First element is on line one. + return 1; + } else { + $previousContent = $this->previousElement->getRawContent(); + $previousLine = $this->previousElement->getLine(); + + return ($previousLine + substr_count($previousContent, $this->phpcsFile->eolChar)); + } + + }//end getLine() + + + /** + * Returns the sub element names that make up this element in the order they + * appear in the element. + * + * @return array(string) + * @see processSubElement() + */ + abstract protected function getSubElements(); + + + /** + * Called to process each sub element as sepcified in the return value + * of getSubElements(). + * + * @param string $name The name of the element to process. + * @param string $content The content of the the element. + * @param string $whitespaceBefore The whitespace found before this element. + * + * @return void + * @see getSubElements() + */ + abstract protected function processSubElement( + $name, + $content, + $whitespaceBefore + ); + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/CommentParser/AbstractParser.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/CommentParser/AbstractParser.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/CommentParser/AbstractParser.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/CommentParser/AbstractParser.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,684 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +if (class_exists('PHP_CodeSniffer_CommentParser_SingleElement', true) === false) { + $error = 'Class PHP_CodeSniffer_CommentParser_SingleElement not found'; + throw new PHP_CodeSniffer_Exception($error); +} + +if (class_exists('PHP_CodeSniffer_CommentParser_CommentElement', true) === false) { + $error = 'Class PHP_CodeSniffer_CommentParser_CommentElement not found'; + throw new PHP_CodeSniffer_Exception($error); +} + +if (class_exists('PHP_CodeSniffer_CommentParser_ParserException', true) === false) { + $error = 'Class PHP_CodeSniffer_CommentParser_ParserException not found'; + throw new PHP_CodeSniffer_Exception($error); +} + +/** + * Parses doc comments. + * + * This abstract parser handles the following tags: + * + *
    + *
  • The short description and the long description
  • + *
  • @see
  • + *
  • @link
  • + *
  • @deprecated
  • + *
  • @since
  • + *
+ * + * Extending classes should implement the getAllowedTags() method to return the + * tags that they wish to process, omitting the tags that this base class + * processes. When one of these tags in encountered, the process<tag_name> + * method is called on that class. For example, if a parser's getAllowedTags() + * method returns \@param as one of its tags, the processParam method will be + * called so that the parser can process such a tag. + * + * The method is passed the tokens that comprise this tag. The tokens array + * includes the whitespace that exists between the tokens, as separate tokens. + * It's up to the method to create a element that implements the DocElement + * interface, which should be returned. The AbstractDocElement class is a helper + * class that can be used to handle most of the parsing of the tokens into their + * individual sub elements. It requires that you construct it with the element + * previous to the element currently being processed, which can be acquired + * with the protected $previousElement class member of this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +abstract class PHP_CodeSniffer_CommentParser_AbstractParser +{ + + /** + * The comment element that appears in the doc comment. + * + * @var PHP_CodeSniffer_CommentParser_CommentElement + */ + protected $comment = null; + + /** + * The string content of the comment. + * + * @var string + */ + protected $commentString = ''; + + /** + * The file that the comment exists in. + * + * @var PHP_CodeSniffer_File + */ + protected $phpcsFile = null; + + /** + * The word tokens that appear in the comment. + * + * Whitespace tokens also appear in this stack, but are separate tokens + * from words. + * + * @var array(string) + */ + protected $words = array(); + + /** + * An array of all tags found in the comment. + * + * @var array(string) + */ + protected $foundTags = array(); + + /** + * The previous doc element that was processed. + * + * null if the current element being processed is the first element in the + * doc comment. + * + * @var PHP_CodeSniffer_CommentParser_DocElement + */ + protected $previousElement = null; + + /** + * A list of see elements that appear in this doc comment. + * + * @var array(PHP_CodeSniffer_CommentParser_SingleElement) + */ + protected $sees = array(); + + /** + * A list of see elements that appear in this doc comment. + * + * @var array(PHP_CodeSniffer_CommentParser_SingleElement) + */ + protected $deprecated = null; + + /** + * A list of see elements that appear in this doc comment. + * + * @var array(PHP_CodeSniffer_CommentParser_SingleElement) + */ + protected $links = array(); + + /** + * A element to represent \@since tags. + * + * @var PHP_CodeSniffer_CommentParser_SingleElement + */ + protected $since = null; + + /** + * True if the comment has been parsed. + * + * @var boolean + */ + private $_hasParsed = false; + + /** + * The tags that this class can process. + * + * @var array(string) + */ + private static $_tags = array( + 'see' => false, + 'link' => false, + 'deprecated' => true, + 'since' => true, + ); + + /** + * An array of unknown tags. + * + * @var array(string) + */ + public $unknown = array(); + + /** + * The order of tags. + * + * @var array(string) + */ + public $orders = array(); + + + /** + * Constructs a Doc Comment Parser. + * + * @param string $comment The comment to parse. + * @param PHP_CodeSniffer_File $phpcsFile The file that this comment is in. + */ + public function __construct($comment, PHP_CodeSniffer_File $phpcsFile) + { + $this->commentString = $comment; + $this->phpcsFile = $phpcsFile; + + }//end __construct() + + + /** + * Initiates the parsing of the doc comment. + * + * @return void + * @throws PHP_CodeSniffer_CommentParser_ParserException If the parser finds a + * problem with the + * comment. + */ + public function parse() + { + if ($this->_hasParsed === false) { + $this->_parse($this->commentString); + } + + }//end parse() + + + /** + * Parse the comment. + * + * @param string $comment The doc comment to parse. + * + * @return void + * @see _parseWords() + */ + private function _parse($comment) + { + // Firstly, remove the comment tags and any stars from the left side. + $lines = explode($this->phpcsFile->eolChar, $comment); + foreach ($lines as &$line) { + $line = trim($line); + + if ($line !== '') { + if (substr($line, 0, 3) === '/**') { + $line = substr($line, 3); + } else if (substr($line, -2, 2) === '*/') { + $line = substr($line, 0, -2); + } else if ($line{0} === '*') { + $line = substr($line, 1); + } + + // Add the words to the stack, preserving newlines. Other parsers + // might be interested in the spaces between words, so tokenize + // spaces as well as separate tokens. + $flags = (PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); + $words = preg_split( + '|(\s+)|', + $line.$this->phpcsFile->eolChar, + -1, + $flags + ); + + $this->words = array_merge($this->words, $words); + }//end if + }//end foreach + + $this->_parseWords(); + + }//end _parse() + + + /** + * Parses each word within the doc comment. + * + * @return void + * @see _parse() + * @throws PHP_CodeSniffer_CommentParser_ParserException If more than the allowed + * number of occurences of + * a tag is found. + */ + private function _parseWords() + { + $allowedTags = (self::$_tags + $this->getAllowedTags()); + $allowedTagNames = array_keys($allowedTags); + $prevTagPos = false; + $wordWasEmpty = true; + + foreach ($this->words as $wordPos => $word) { + if (trim($word) !== '') { + $wordWasEmpty = false; + } + + if ($word{0} === '@') { + $tag = substr($word, 1); + + // Filter out @ tags in the comment description. + // A real comment tag should have whitespace and a newline before it. + if (isset($this->words[($wordPos - 1)]) === false + || trim($this->words[($wordPos - 1)]) !== '' + ) { + continue; + } + + if (isset($this->words[($wordPos - 2)]) === false + || $this->words[($wordPos - 2)] !== $this->phpcsFile->eolChar + ) { + continue; + } + + $this->foundTags[] = array( + 'tag' => $tag, + 'line' => $this->getLine($wordPos), + 'pos' => $wordPos, + ); + + if ($prevTagPos !== false) { + // There was a tag before this so let's process it. + $prevTag = substr($this->words[$prevTagPos], 1); + $this->parseTag($prevTag, $prevTagPos, ($wordPos - 1)); + } else { + // There must have been a comment before this tag, so + // let's process that. + $this->parseTag('comment', 0, ($wordPos - 1)); + } + + $prevTagPos = $wordPos; + + if (in_array($tag, $allowedTagNames) === false) { + // This is not a tag that we process, but let's check to + // see if it is a tag we know about. If we don't know about it, + // we add it to a list of unknown tags. + $knownTags = array( + 'abstract', + 'access', + 'example', + 'filesource', + 'global', + 'ignore', + 'internal', + 'name', + 'static', + 'staticvar', + 'todo', + 'tutorial', + 'uses', + 'package_version@', + ); + + if (in_array($tag, $knownTags) === false) { + $this->unknown[] = array( + 'tag' => $tag, + 'line' => $this->getLine($wordPos), + 'pos' => $wordPos, + ); + } + }//end if + }//end if + }//end foreach + + // Only process this tag if there was something to process. + if ($wordWasEmpty === false) { + if ($prevTagPos === false) { + // There must only be a comment in this doc comment. + $this->parseTag('comment', 0, count($this->words)); + } else { + // Process the last tag element. + $prevTag = substr($this->words[$prevTagPos], 1); + $numWords = count($this->words); + $endPos = $numWords; + + if ($prevTag === 'package' || $prevTag === 'subpackage') { + // These are single-word tags, so anything after a newline + // is really a comment. + for ($endPos = $prevTagPos; $endPos < $numWords; $endPos++) { + if (strpos($this->words[$endPos], $this->phpcsFile->eolChar) !== false) { + break; + } + } + } + + $this->parseTag($prevTag, $prevTagPos, $endPos); + + if ($endPos !== $numWords) { + // Process the final comment, if it is not empty. + $tokens = array_slice($this->words, ($endPos + 1), $numWords); + $content = implode('', $tokens); + if (trim($content) !== '') { + $this->parseTag('comment', ($endPos + 1), $numWords); + } + } + }//end if + }//end if + + }//end _parseWords() + + + /** + * Returns the line that the token exists on in the doc comment. + * + * @param int $tokenPos The position in the words stack to find the line + * number for. + * + * @return int + */ + protected function getLine($tokenPos) + { + $newlines = 0; + for ($i = 0; $i < $tokenPos; $i++) { + $newlines += substr_count($this->phpcsFile->eolChar, $this->words[$i]); + } + + return $newlines; + + }//end getLine() + + + /** + * Parses see tag element within the doc comment. + * + * @param array(string) $tokens The word tokens that comprise this element. + * + * @return DocElement The element that represents this see comment. + */ + protected function parseSee($tokens) + { + $see = new PHP_CodeSniffer_CommentParser_SingleElement( + $this->previousElement, + $tokens, + 'see', + $this->phpcsFile + ); + + $this->sees[] = $see; + return $see; + + }//end parseSee() + + + /** + * Parses the comment element that appears at the top of the doc comment. + * + * @param array(string) $tokens The word tokens that comprise this element. + * + * @return DocElement The element that represents this comment element. + */ + protected function parseComment($tokens) + { + $this->comment = new PHP_CodeSniffer_CommentParser_CommentElement( + $this->previousElement, + $tokens, + $this->phpcsFile + ); + + return $this->comment; + + }//end parseComment() + + + /** + * Parses \@deprecated tags. + * + * @param array(string) $tokens The word tokens that comprise this element. + * + * @return DocElement The element that represents this deprecated tag. + */ + protected function parseDeprecated($tokens) + { + $this->deprecated = new PHP_CodeSniffer_CommentParser_SingleElement( + $this->previousElement, + $tokens, + 'deprecated', + $this->phpcsFile + ); + + return $this->deprecated; + + }//end parseDeprecated() + + + /** + * Parses \@since tags. + * + * @param array(string) $tokens The word tokens that comprise this element. + * + * @return SingleElement The element that represents this since tag. + */ + protected function parseSince($tokens) + { + $this->since = new PHP_CodeSniffer_CommentParser_SingleElement( + $this->previousElement, + $tokens, + 'since', + $this->phpcsFile + ); + + return $this->since; + + }//end parseSince() + + + /** + * Parses \@link tags. + * + * @param array(string) $tokens The word tokens that comprise this element. + * + * @return SingleElement The element that represents this link tag. + */ + protected function parseLink($tokens) + { + $link = new PHP_CodeSniffer_CommentParser_SingleElement( + $this->previousElement, + $tokens, + 'link', + $this->phpcsFile + ); + + $this->links[] = $link; + return $link; + + }//end parseLink() + + + /** + * Returns the see elements that appear in this doc comment. + * + * @return array(SingleElement) + */ + public function getSees() + { + return $this->sees; + + }//end getSees() + + + /** + * Returns the comment element that appears at the top of this doc comment. + * + * @return CommentElement + */ + public function getComment() + { + return $this->comment; + + }//end getComment() + + + /** + * Returns the word list. + * + * @return array + */ + public function getWords() + { + return $this->words; + + }//end getWords() + + + /** + * Returns the list of found tags. + * + * @return array + */ + public function getTags() + { + return $this->foundTags; + + }//end getTags() + + + /** + * Returns the link elements found in this comment. + * + * Returns an empty array if no links are found in the comment. + * + * @return array(SingleElement) + */ + public function getLinks() + { + return $this->links; + + }//end getLinks() + + + /** + * Returns the deprecated element found in this comment. + * + * Returns null if no element exists in the comment. + * + * @return SingleElement + */ + public function getDeprecated() + { + return $this->deprecated; + + }//end getDeprecated() + + + /** + * Returns the since element found in this comment. + * + * Returns null if no element exists in the comment. + * + * @return SingleElement + */ + public function getSince() + { + return $this->since; + + }//end getSince() + + + /** + * Parses the specified tag. + * + * @param string $tag The tag name to parse (omitting the @ symbol from + * the tag) + * @param int $start The position in the word tokens where this element + * started. + * @param int $end The position in the word tokens where this element + * ended. + * + * @return void + * @throws Exception If the process method for the tag cannot be found. + */ + protected function parseTag($tag, $start, $end) + { + $tokens = array_slice($this->words, ($start + 1), ($end - $start)); + + $allowedTags = (self::$_tags + $this->getAllowedTags()); + $allowedTagNames = array_keys($allowedTags); + if ($tag === 'comment' || in_array($tag, $allowedTagNames) === true) { + $method = 'parse'.$tag; + if (method_exists($this, $method) === false) { + $error = 'Method '.$method.' must be implemented to process '.$tag.' tags'; + throw new Exception($error); + } + + $this->previousElement = $this->$method($tokens); + } else { + $this->previousElement = new PHP_CodeSniffer_CommentParser_SingleElement( + $this->previousElement, + $tokens, + $tag, + $this->phpcsFile + ); + } + + $this->orders[] = $tag; + + if ($this->previousElement === null + || ($this->previousElement instanceof PHP_CodeSniffer_CommentParser_DocElement) === false + ) { + throw new Exception('Parse method must return a DocElement'); + } + + }//end parseTag() + + + /** + * Returns a list of tags that this comment parser allows for it's comment. + * + * Each tag should indicate if only one entry of this tag can exist in the + * comment by specifying true as the array value, or false if more than one + * is allowed. Each tag should omit the @ symbol. Only tags other than + * the standard tags should be returned. + * + * @return array(string => boolean) + */ + protected abstract function getAllowedTags(); + + + /** + * Returns the tag orders (index => tagName). + * + * @return array + */ + public function getTagOrders() + { + return $this->orders; + + }//end getTagOrders() + + + /** + * Returns the unknown tags. + * + * @return array + */ + public function getUnknown() + { + return $this->unknown; + + }//end getUnknown() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/CommentParser/ClassCommentParser.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/CommentParser/ClassCommentParser.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/CommentParser/ClassCommentParser.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/CommentParser/ClassCommentParser.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,341 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +if (class_exists('PHP_CodeSniffer_CommentParser_AbstractParser', true) === false) { + $error = 'Class PHP_CodeSniffer_CommentParser_AbstractParser not found'; + throw new PHP_CodeSniffer_Exception($error); +} + +/** + * Parses Class doc comments. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PHP_CodeSniffer_CommentParser_ClassCommentParser extends PHP_CodeSniffer_CommentParser_AbstractParser +{ + + /** + * The package element of this class. + * + * @var SingleElement + */ + private $_package = null; + + /** + * The subpackage element of this class. + * + * @var SingleElement + */ + private $_subpackage = null; + + /** + * The version element of this class. + * + * @var SingleElement + */ + private $_version = null; + + /** + * The category element of this class. + * + * @var SingleElement + */ + private $_category = null; + + /** + * The copyright elements of this class. + * + * @var array(SingleElement) + */ + private $_copyrights = array(); + + /** + * The licence element of this class. + * + * @var PairElement + */ + private $_license = null; + + /** + * The author elements of this class. + * + * @var array(SingleElement) + */ + private $_authors = array(); + + + /** + * Returns the allowed tags withing a class comment. + * + * @return array(string => int) + */ + protected function getAllowedTags() + { + return array( + 'category' => false, + 'package' => true, + 'subpackage' => true, + 'author' => false, + 'copyright' => true, + 'license' => false, + 'version' => true, + ); + + }//end getAllowedTags() + + + /** + * Parses the license tag of this class comment. + * + * @param array $tokens The tokens that comprise this tag. + * + * @return PHP_CodeSniffer_CommentParser_PairElement + */ + protected function parseLicense($tokens) + { + $this->_license = new PHP_CodeSniffer_CommentParser_PairElement( + $this->previousElement, + $tokens, + 'license', + $this->phpcsFile + ); + + return $this->_license; + + }//end parseLicense() + + + /** + * Parses the copyright tags of this class comment. + * + * @param array $tokens The tokens that comprise this tag. + * + * @return PHP_CodeSniffer_CommentParser_SingleElement + */ + protected function parseCopyright($tokens) + { + $copyright = new PHP_CodeSniffer_CommentParser_SingleElement( + $this->previousElement, + $tokens, + 'copyright', + $this->phpcsFile + ); + + $this->_copyrights[] = $copyright; + return $copyright; + + }//end parseCopyright() + + + /** + * Parses the category tag of this class comment. + * + * @param array $tokens The tokens that comprise this tag. + * + * @return PHP_CodeSniffer_CommentParser_SingleElement + */ + protected function parseCategory($tokens) + { + $this->_category = new PHP_CodeSniffer_CommentParser_SingleElement( + $this->previousElement, + $tokens, + 'category', + $this->phpcsFile + ); + + return $this->_category; + + }//end parseCategory() + + + /** + * Parses the author tag of this class comment. + * + * @param array $tokens The tokens that comprise this tag. + * + * @return array(PHP_CodeSniffer_CommentParser_SingleElement) + */ + protected function parseAuthor($tokens) + { + $author = new PHP_CodeSniffer_CommentParser_SingleElement( + $this->previousElement, + $tokens, + 'author', + $this->phpcsFile + ); + + $this->_authors[] = $author; + return $author; + + }//end parseAuthor() + + + /** + * Parses the version tag of this class comment. + * + * @param array $tokens The tokens that comprise this tag. + * + * @return PHP_CodeSniffer_CommentParser_SingleElement + */ + protected function parseVersion($tokens) + { + $this->_version = new PHP_CodeSniffer_CommentParser_SingleElement( + $this->previousElement, + $tokens, + 'version', + $this->phpcsFile + ); + + return $this->_version; + + }//end parseVersion() + + + /** + * Parses the package tag found in this test. + * + * @param array $tokens The tokens that comprise this var. + * + * @return PHP_CodeSniffer_CommentParser_SingleElement + */ + protected function parsePackage($tokens) + { + $this->_package = new PHP_CodeSniffer_CommentParser_SingleElement( + $this->previousElement, + $tokens, + 'package', + $this->phpcsFile + ); + + return $this->_package; + + }//end parsePackage() + + + /** + * Parses the package tag found in this test. + * + * @param array $tokens The tokens that comprise this var. + * + * @return PHP_CodeSniffer_CommentParser_SingleElement + */ + protected function parseSubpackage($tokens) + { + $this->_subpackage = new PHP_CodeSniffer_CommentParser_SingleElement( + $this->previousElement, + $tokens, + 'subpackage', + $this->phpcsFile + ); + + return $this->_subpackage; + + }//end parseSubpackage() + + + /** + * Returns the authors of this class comment. + * + * @return array(PHP_CodeSniffer_CommentParser_SingleElement) + */ + public function getAuthors() + { + return $this->_authors; + + }//end getAuthors() + + + /** + * Returns the version of this class comment. + * + * @return PHP_CodeSniffer_CommentParser_SingleElement + */ + public function getVersion() + { + return $this->_version; + + }//end getVersion() + + + /** + * Returns the license of this class comment. + * + * @return PHP_CodeSniffer_CommentParser_PairElement + */ + public function getLicense() + { + return $this->_license; + + }//end getLicense() + + + /** + * Returns the copyrights of this class comment. + * + * @return PHP_CodeSniffer_CommentParser_SingleElement + */ + public function getCopyrights() + { + return $this->_copyrights; + + }//end getCopyrights() + + + /** + * Returns the category of this class comment. + * + * @return PHP_CodeSniffer_CommentParser_SingleElement + */ + public function getCategory() + { + return $this->_category; + + }//end getCategory() + + + /** + * Returns the package that this class belongs to. + * + * @return PHP_CodeSniffer_CommentParser_SingleElement + */ + public function getPackage() + { + return $this->_package; + + }//end getPackage() + + + /** + * Returns the subpackage that this class belongs to. + * + * @return PHP_CodeSniffer_CommentParser_SingleElement + */ + public function getSubpackage() + { + return $this->_subpackage; + + }//end getSubpackage() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/CommentParser/CommentElement.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/CommentParser/CommentElement.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/CommentParser/CommentElement.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/CommentParser/CommentElement.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,245 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +if (class_exists('PHP_CodeSniffer_CommentParser_SingleElement', true) === false) { + $error = 'Class PHP_CodeSniffer_CommentParser_SingleElement not found'; + throw new PHP_CodeSniffer_Exception($error); +} + +/** + * A class to represent Comments of a doc comment. + * + * Comments are in the following format. + * + * /** <--this is the start of the comment. + * * This is a short comment description + * * + * * This is a long comment description + * * <-- this is the end of the comment + * * @return something + * {@/} + * + * + * Note that the sentence before two newlines is assumed + * the short comment description. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PHP_CodeSniffer_CommentParser_CommentElement extends PHP_CodeSniffer_CommentParser_SingleElement +{ + + + /** + * Constructs a PHP_CodeSniffer_CommentParser_CommentElement. + * + * @param PHP_CodeSniffer_CommentParser_DocElement $previousElement The element + * that + * appears + * before this + * element. + * @param array $tokens The tokens + * that make + * up this + * element. + * @param PHP_CodeSniffer_File $phpcsFile The file + * that this + * element is + * in. + */ + public function __construct( + $previousElement, + $tokens, + PHP_CodeSniffer_File $phpcsFile + ) { + parent::__construct($previousElement, $tokens, 'comment', $phpcsFile); + + }//end __construct() + + + /** + * Returns the short comment description. + * + * @return string + * @see getLongComment() + */ + public function getShortComment() + { + $pos = $this->_getShortCommentEndPos(); + if ($pos === -1) { + return ''; + } + + return implode('', array_slice($this->tokens, 0, ($pos + 1))); + + }//end getShortComment() + + + /** + * Returns the last token position of the short comment description. + * + * @return int The last token position of the short comment description + * @see _getLongCommentStartPos() + */ + private function _getShortCommentEndPos() + { + $found = false; + $whiteSpace = array( + ' ', + "\t", + ); + + foreach ($this->tokens as $pos => $token) { + $token = str_replace($whiteSpace, '', $token); + if ($token === $this->phpcsFile->eolChar) { + if ($found === false) { + // Include newlines before short description. + continue; + } else { + if (isset($this->tokens[($pos + 1)]) === true) { + if ($this->tokens[($pos + 1)] === $this->phpcsFile->eolChar) { + return ($pos - 1); + } + } else { + return $pos; + } + } + } else { + $found = true; + } + }//end foreach + + return (count($this->tokens) - 1); + + }//end _getShortCommentEndPos() + + + /** + * Returns the long comment description. + * + * @return string + * @see getShortComment + */ + public function getLongComment() + { + $start = $this->_getLongCommentStartPos(); + if ($start === -1) { + return ''; + } + + return implode('', array_slice($this->tokens, $start)); + + }//end getLongComment() + + + /** + * Returns the start position of the long comment description. + * + * Returns -1 if there is no long comment. + * + * @return int The start position of the long comment description. + * @see _getShortCommentEndPos() + */ + private function _getLongCommentStartPos() + { + $pos = ($this->_getShortCommentEndPos() + 1); + if ($pos === (count($this->tokens) - 1)) { + return -1; + } + + $count = count($this->tokens); + for ($i = $pos; $i < $count; $i++) { + $content = trim($this->tokens[$i]); + if ($content !== '') { + if ($content{0} === '@') { + return -1; + } + + return $i; + } + } + + return -1; + + }//end _getLongCommentStartPos() + + + /** + * Returns the whitespace that exists between + * the short and the long comment description. + * + * @return string + */ + public function getWhiteSpaceBetween() + { + $endShort = ($this->_getShortCommentEndPos() + 1); + $startLong = ($this->_getLongCommentStartPos() - 1); + if ($startLong === -1) { + return ''; + } + + return implode( + '', + array_slice($this->tokens, $endShort, ($startLong - $endShort)) + ); + + }//end getWhiteSpaceBetween() + + + /** + * Returns the number of newlines that exist before the tags. + * + * @return int + */ + public function getNewlineAfter() + { + $long = $this->getLongComment(); + if ($long !== '') { + $long = rtrim($long, ' '); + $long = strrev($long); + $newlines = strspn($long, $this->phpcsFile->eolChar); + } else { + $endShort = ($this->_getShortCommentEndPos() + 1); + $after = implode('', array_slice($this->tokens, $endShort)); + $after = trim($after, ' '); + $newlines = strspn($after, $this->phpcsFile->eolChar); + } + + return ($newlines / strlen($this->phpcsFile->eolChar)); + + }//end getNewlineAfter() + + + /** + * Returns true if there is no comment. + * + * @return boolean + */ + public function isEmpty() + { + return (trim($this->getContent()) === ''); + + }//end isEmpty() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/CommentParser/DocElement.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/CommentParser/DocElement.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/CommentParser/DocElement.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/CommentParser/DocElement.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,104 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * A DocElement represents a logical element within a Doc Comment. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +interface PHP_CodeSniffer_CommentParser_DocElement +{ + + + /** + * Returns the name of the tag this element represents, omitting the @ symbol. + * + * @return string + */ + public function getTag(); + + + /** + * Returns the whitespace that exists before this element. + * + * @return string + * @see getWhitespaceAfter() + */ + public function getWhitespaceBefore(); + + + /** + * Returns the whitespace that exists after this element. + * + * @return string + * @see getWhitespaceBefore() + */ + public function getWhitespaceAfter(); + + + /** + * Returns the order that this element appears in the doc comment. + * + * The first element in the comment should have an order of 1. + * + * @return int + */ + public function getOrder(); + + + /** + * Returns the element that appears before this element. + * + * @return PHP_CodeSniffer_CommentParser_DocElement + * @see getNextElement() + */ + public function getPreviousElement(); + + + /** + * Returns the element that appears after this element. + * + * @return PHP_CodeSniffer_CommentParser_DocElement + * @see getPreviousElement() + */ + public function getNextElement(); + + + /** + * Returns the line that this element started on. + * + * @return int + */ + public function getLine(); + + + /** + * Returns the raw content of this element, omitting the tag. + * + * @return string + */ + public function getRawContent(); + + +}//end interface + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/CommentParser/FunctionCommentParser.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/CommentParser/FunctionCommentParser.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/CommentParser/FunctionCommentParser.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/CommentParser/FunctionCommentParser.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,212 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +if (class_exists('PHP_CodeSniffer_CommentParser_AbstractParser', true) === false) { + $error = 'Class PHP_CodeSniffer_CommentParser_AbstractParser not found'; + throw new PHP_CodeSniffer_Exception($error); +} + +if (class_exists('PHP_CodeSniffer_CommentParser_ParameterElement', true) === false) { + $error = 'Class PHP_CodeSniffer_CommentParser_ParameterElement not found'; + throw new PHP_CodeSniffer_Exception($error); +} + +if (class_exists('PHP_CodeSniffer_CommentParser_PairElement', true) === false) { + $error = 'Class PHP_CodeSniffer_CommentParser_PairElement not found'; + throw new PHP_CodeSniffer_Exception($error); +} + +if (class_exists('PHP_CodeSniffer_CommentParser_SingleElement', true) === false) { + $error = 'Class PHP_CodeSniffer_CommentParser_SingleElement not found'; + throw new PHP_CodeSniffer_Exception($error); +} + +/** + * Parses function doc comments. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PHP_CodeSniffer_CommentParser_FunctionCommentParser extends PHP_CodeSniffer_CommentParser_AbstractParser +{ + + /** + * The parameter elements within this function comment. + * + * @var array(PHP_CodeSniffer_CommentParser_ParameterElement) + */ + private $_params = array(); + + /** + * The return element in this function comment. + * + * @var PHP_CodeSniffer_CommentParser_PairElement. + */ + private $_return = null; + + /** + * The throws element list for this function comment. + * + * @var array(PHP_CodeSniffer_CommentParser_PairElement) + */ + private $_throws = array(); + + + /** + * Constructs a PHP_CodeSniffer_CommentParser_FunctionCommentParser. + * + * @param string $comment The comment to parse. + * @param PHP_CodeSniffer_File $phpcsFile The file that this comment is in. + */ + public function __construct($comment, PHP_CodeSniffer_File $phpcsFile) + { + parent::__construct($comment, $phpcsFile); + + }//end __construct() + + + /** + * Parses parameter elements. + * + * @param array(string) $tokens The tokens that comprise this sub element. + * + * @return PHP_CodeSniffer_CommentParser_ParameterElement + */ + protected function parseParam($tokens) + { + $param = new PHP_CodeSniffer_CommentParser_ParameterElement( + $this->previousElement, + $tokens, + $this->phpcsFile + ); + + $this->_params[] = $param; + return $param; + + }//end parseParam() + + + /** + * Parses return elements. + * + * @param array(string) $tokens The tokens that comprise this sub element. + * + * @return PHP_CodeSniffer_CommentParser_PairElement + */ + protected function parseReturn($tokens) + { + $return = new PHP_CodeSniffer_CommentParser_PairElement( + $this->previousElement, + $tokens, + 'return', + $this->phpcsFile + ); + + $this->_return = $return; + return $return; + + }//end parseReturn() + + + /** + * Parses throws elements. + * + * @param array(string) $tokens The tokens that comprise this sub element. + * + * @return PHP_CodeSniffer_CommentParser_PairElement + */ + protected function parseThrows($tokens) + { + $throws = new PHP_CodeSniffer_CommentParser_PairElement( + $this->previousElement, + $tokens, + 'throws', + $this->phpcsFile + ); + + $this->_throws[] = $throws; + return $throws; + + }//end parseThrows() + + + /** + * Returns the parameter elements that this function comment contains. + * + * Returns an empty array if no parameter elements are contained within + * this function comment. + * + * @return array(PHP_CodeSniffer_CommentParser_ParameterElement) + */ + public function getParams() + { + return $this->_params; + + }//end getParams() + + + /** + * Returns the return element in this function comment. + * + * Returns null if no return element exists in the comment. + * + * @return PHP_CodeSniffer_CommentParser_PairElement + */ + public function getReturn() + { + return $this->_return; + + }//end getReturn() + + + /** + * Returns the throws elements in this function comment. + * + * Returns empty array if no throws elements in the comment. + * + * @return array(PHP_CodeSniffer_CommentParser_PairElement) + */ + public function getThrows() + { + return $this->_throws; + + }//end getThrows() + + + /** + * Returns the allowed tags that can exist in a function comment. + * + * @return array(string => boolean) + */ + protected function getAllowedTags() + { + return array( + 'param' => false, + 'return' => true, + 'throws' => false, + ); + + }//end getAllowedTags() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/CommentParser/MemberCommentParser.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/CommentParser/MemberCommentParser.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/CommentParser/MemberCommentParser.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/CommentParser/MemberCommentParser.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,91 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +if (class_exists('PHP_CodeSniffer_CommentParser_ClassCommentParser', true) === false) { + $error = 'Class PHP_CodeSniffer_CommentParser_ClassCommentParser not found'; + throw new PHP_CodeSniffer_Exception($error); +} + +/** + * Parses class member comments. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PHP_CodeSniffer_CommentParser_MemberCommentParser extends PHP_CodeSniffer_CommentParser_ClassCommentParser +{ + + /** + * Represents a \@var tag in a member comment. + * + * @var PHP_CodeSniffer_CommentParser_SingleElement + */ + private $_var = null; + + + /** + * Parses Var tags. + * + * @param array $tokens The tokens that represent this tag. + * + * @return PHP_CodeSniffer_CommentParser_SingleElement + */ + protected function parseVar($tokens) + { + $this->_var = new PHP_CodeSniffer_CommentParser_SingleElement( + $this->previousElement, + $tokens, + 'var', + $this->phpcsFile + ); + + return $this->_var; + + }//end parseVar() + + + /** + * Returns the var tag found in the member comment. + * + * @return PHP_CodeSniffer_CommentParser_PairElement + */ + public function getVar() + { + return $this->_var; + + }//end getVar() + + + /** + * Returns the allowed tags for this parser. + * + * @return array + */ + protected function getAllowedTags() + { + return array('var' => true); + + }//end getAllowedTags() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/CommentParser/PairElement.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/CommentParser/PairElement.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/CommentParser/PairElement.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/CommentParser/PairElement.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,171 @@ + comment format. + * + * PHP version 5 + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +if (class_exists('PHP_CodeSniffer_CommentParser_AbstractDocElement', true) === false) { + $error = 'Class PHP_CodeSniffer_CommentParser_AbstractDocElement not found'; + throw new PHP_CodeSniffer_Exception($error); +} + +/** + * A class to represent elements that have a value => comment format. + * + * An example of a pair element tag is the \@throws as it has an exception type + * and a comment on the circumstance of when the exception is thrown. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PHP_CodeSniffer_CommentParser_PairElement extends PHP_CodeSniffer_CommentParser_AbstractDocElement +{ + + /** + * The value of the tag. + * + * @var string + */ + private $_value = ''; + + /** + * The comment of the tag. + * + * @var string + */ + private $_comment = ''; + + /** + * The whitespace that exists before the value elem. + * + * @var string + */ + private $_valueWhitespace = ''; + + /** + * The whitespace that exists before the comment elem. + * + * @var string + */ + private $_commentWhitespace = ''; + + + /** + * Constructs a PHP_CodeSniffer_CommentParser_PairElement doc tag. + * + * @param PHP_CodeSniffer_CommentParser_DocElement $previousElement The element + * before this + * one. + * @param array $tokens The tokens + * that comprise + * this element. + * @param string $tag The tag that + * this element + * represents. + * @param PHP_CodeSniffer_File $phpcsFile The file that + * this element + * is in. + */ + public function __construct( + $previousElement, + $tokens, + $tag, + PHP_CodeSniffer_File $phpcsFile + ) { + parent::__construct($previousElement, $tokens, $tag, $phpcsFile); + + }//end __construct() + + + /** + * Returns the element names that this tag is comprised of, in the order + * that they appear in the tag. + * + * @return array(string) + * @see processSubElement() + */ + protected function getSubElements() + { + return array( + 'value', + 'comment', + ); + + }//end getSubElements() + + + /** + * Processes the sub element with the specified name. + * + * @param string $name The name of the sub element to process. + * @param string $content The content of this sub element. + * @param string $whitespaceBefore The whitespace that exists before the + * sub element. + * + * @return void + * @see getSubElements() + */ + protected function processSubElement($name, $content, $whitespaceBefore) + { + $element = '_'.$name; + $whitespace = $element.'Whitespace'; + $this->$element = $content; + $this->$whitespace = $whitespaceBefore; + + }//end processSubElement() + + + /** + * Returns the value of the tag. + * + * @return string + */ + public function getValue() + { + return $this->_value; + + }//end getValue() + + + /** + * Returns the comment associated with the value of this tag. + * + * @return string + */ + public function getComment() + { + return $this->_comment; + + }//end getComment() + + + /** + * Returns the whitespace before the content of this tag. + * + * @return string + */ + public function getWhitespaceBeforeValue() + { + return $this->_valueWhitespace; + + }//end getWhitespaceBeforeValue() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/CommentParser/ParameterElement.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/CommentParser/ParameterElement.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/CommentParser/ParameterElement.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/CommentParser/ParameterElement.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,338 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +if (class_exists('PHP_CodeSniffer_CommentParser_AbstractDocElement', true) === false) { + $error = 'Class PHP_CodeSniffer_CommentParser_AbstractDocElement not found'; + throw new PHP_CodeSniffer_Exception($error); +} + +/** + * A class to represent param tags within a function comment. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PHP_CodeSniffer_CommentParser_ParameterElement extends PHP_CodeSniffer_CommentParser_AbstractDocElement +{ + + /** + * The variable name of this parameter name, including the $ sign. + * + * @var string + */ + private $_varName = ''; + + /** + * The comment of this parameter tag. + * + * @var string + */ + private $_comment = ''; + + /** + * The variable type of this parameter tag. + * + * @var string + */ + private $_type = ''; + + /** + * The whitespace that exists before the variable name. + * + * @var string + */ + private $_varNameWhitespace = ''; + + /** + * The whitespace that exists before the comment. + * + * @var string + */ + private $_commentWhitespace = null; + + /** + * The whitespace that exists before the variable type. + * + * @var string + */ + private $_typeWhitespace = ''; + + + /** + * Constructs a PHP_CodeSniffer_CommentParser_ParameterElement. + * + * @param PHP_CodeSniffer_CommentParser_DocElement $previousElement The element + * previous to + * this one. + * @param array $tokens The tokens + * that make up + * this element. + * @param PHP_CodeSniffer_File $phpcsFile The file that + * this element + * is in. + */ + public function __construct( + $previousElement, + $tokens, + PHP_CodeSniffer_File $phpcsFile + ) { + parent::__construct($previousElement, $tokens, 'param', $phpcsFile); + + // Handle special variable type: array(x => y). + $type = strtolower($this->_type); + if ($this->_varName === '=>' && strpos($type, 'array(') !== false) { + $rawContent = $this->getRawContent(); + $matches = array(); + $pattern = '/^(\s+)(array\(.*\))(\s+)(\$\S*)(\s+)(.*)/i'; + if (preg_match($pattern, $rawContent, $matches) !== 0) { + // Process the sub elements correctly for this special case. + if (count($matches) === 7) { + $this->processSubElement('type', $matches[2], $matches[1]); + $this->processSubElement('varName', $matches[4], $matches[3]); + $this->processSubElement('comment', $matches[6], $matches[5]); + } + } + } + + }//end __construct() + + + /** + * Returns the element names that this tag is comprised of, in the order + * that they appear in the tag. + * + * @return array(string) + * @see processSubElement() + */ + protected function getSubElements() + { + return array( + 'type', + 'varName', + 'comment', + ); + + }//end getSubElements() + + + /** + * Processes the sub element with the specified name. + * + * @param string $name The name of the sub element to process. + * @param string $content The content of this sub element. + * @param string $beforeWhitespace The whitespace that exists before the + * sub element. + * + * @return void + * @see getSubElements() + */ + protected function processSubElement($name, $content, $beforeWhitespace) + { + $element = '_'.$name; + $whitespace = $element.'Whitespace'; + $this->$element = $content; + $this->$whitespace = $beforeWhitespace; + + }//end processSubElement() + + + /** + * Returns the variable name that this parameter tag represents. + * + * @return string + */ + public function getVarName() + { + return $this->_varName; + + }//end getVarName() + + + /** + * Returns the variable type that this string represents. + * + * @return string + */ + public function getType() + { + return $this->_type; + + }//end getType() + + + /** + * Returns the comment of this comment for this parameter. + * + * @return string + */ + public function getComment() + { + return $this->_comment; + + }//end getComment() + + + /** + * Returns the whitespace before the variable type. + * + * @return string + * @see getWhiteSpaceBeforeVarName() + * @see getWhiteSpaceBeforeComment() + */ + public function getWhiteSpaceBeforeType() + { + return $this->_typeWhitespace; + + }//end getWhiteSpaceBeforeType() + + + /** + * Returns the whitespace before the variable name. + * + * @return string + * @see getWhiteSpaceBeforeComment() + * @see getWhiteSpaceBeforeType() + */ + public function getWhiteSpaceBeforeVarName() + { + return $this->_varNameWhitespace; + + }//end getWhiteSpaceBeforeVarName() + + + /** + * Returns the whitespace before the comment. + * + * @return string + * @see getWhiteSpaceBeforeVarName() + * @see getWhiteSpaceBeforeType() + */ + public function getWhiteSpaceBeforeComment() + { + return $this->_commentWhitespace; + + }//end getWhiteSpaceBeforeComment() + + + /** + * Returns the position of this parameter are it appears in the comment. + * + * This method differs from getOrder as it is only relative to method + * parameters. + * + * @return int + */ + public function getPosition() + { + if (($this->getPreviousElement() instanceof PHP_CodeSniffer_CommentParser_ParameterElement) === false) { + return 1; + } else { + return ($this->getPreviousElement()->getPosition() + 1); + } + + }//end getPosition() + + + /** + * Returns true if this parameter's variable aligns with the other's. + * + * @param PHP_CodeSniffer_CommentParser_ParameterElement $other The other param + * to check + * alignment with. + * + * @return boolean + */ + public function alignsVariableWith( + PHP_CodeSniffer_CommentParser_ParameterElement $other + ) { + // Format is: + // @param type $variable Comment. + // @param <-a-><---b----> + // Compares the index before param variable. + $otherVar = (strlen($other->_type) + strlen($other->_varNameWhitespace)); + $thisVar = (strlen($this->_type) + strlen($this->_varNameWhitespace)); + if ($otherVar !== $thisVar) { + return false; + } + + return true; + + }//end alignsVariableWith() + + + /** + * Returns true if this parameter's comment aligns with the other's. + * + * @param PHP_CodeSniffer_CommentParser_ParameterElement $other The other param + * to check + * alignment with. + * + * @return boolean + */ + public function alignsCommentWith( + PHP_CodeSniffer_CommentParser_ParameterElement $other + ) { + // Compares the index before param comment. + if (strlen($other->_commentWhitespace) === 0 && strlen($this->_commentWhitespace) === 0) { + return true; + } + + $otherComment + = (strlen($other->_varName) + strlen($other->_commentWhitespace)); + $thisComment + = (strlen($this->_varName) + strlen($this->_commentWhitespace)); + + if ($otherComment !== $thisComment) { + return false; + } + + return true; + + }//end alignsCommentWith() + + + /** + * Returns true if this parameter aligns with the other paramter. + * + * @param PHP_CodeSniffer_CommentParser_ParameterElement $other The other param + * to check + * alignment with. + * + * @return boolean + */ + public function alignsWith(PHP_CodeSniffer_CommentParser_ParameterElement $other) + { + if ($this->alignsVariableWith($other) === false) { + return false; + } + + if ($this->alignsCommentWith($other) === false) { + return false; + } + + return true; + + }//end alignsWith() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/CommentParser/ParserException.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/CommentParser/ParserException.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/CommentParser/ParserException.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/CommentParser/ParserException.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,71 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * An exception to be thrown when a DocCommentParser finds an anomaly in a + * doc comment. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PHP_CodeSniffer_CommentParser_ParserException extends Exception +{ + + /** + * The line where the exception occurred, in relation to the doc comment. + * + * @var int + */ + private $_line = 0; + + + /** + * Constructs a DocCommentParserException. + * + * @param string $message The message of the exception. + * @param int $line The position in comment where the error occurred. + * A position of 0 indicates that the error occurred + * at the opening line of the doc comment. + */ + public function __construct($message, $line) + { + parent::__construct($message); + $this->_line = $line; + + }//end __construct() + + + /** + * Returns the line number within the comment where the exception occurred. + * + * @return int + */ + public function getLineWithinComment() + { + return $this->_line; + + }//end getLineWithinComment() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/CommentParser/SingleElement.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/CommentParser/SingleElement.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/CommentParser/SingleElement.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/CommentParser/SingleElement.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,171 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +if (class_exists('PHP_CodeSniffer_CommentParser_AbstractDocElement', true) === false) { + $error = 'Class PHP_CodeSniffer_CommentParser_AbstractDocElement not found'; + throw new PHP_CodeSniffer_Exception($error); +} + +/** + * A class to represent single element doc tags. + * + * A single element doc tag contains only one value after the tag itself. An + * example would be the \@package tag. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PHP_CodeSniffer_CommentParser_SingleElement extends PHP_CodeSniffer_CommentParser_AbstractDocElement +{ + + /** + * The content that exists after the tag. + * + * @var string + * @see getContent() + */ + protected $content = ''; + + /** + * The whitespace that exists before the content. + * + * @var string + * @see getWhitespaceBeforeContent() + */ + protected $contentWhitespace = ''; + + + /** + * Constructs a SingleElement doc tag. + * + * @param PHP_CodeSniffer_CommentParser_DocElement $previousElement The element + * before this + * one. + * @param array $tokens The tokens + * that comprise + * this element. + * @param string $tag The tag that + * this element + * represents. + * @param PHP_CodeSniffer_File $phpcsFile The file that + * this element + * is in. + */ + public function __construct( + $previousElement, + $tokens, + $tag, + PHP_CodeSniffer_File $phpcsFile + ) { + parent::__construct($previousElement, $tokens, $tag, $phpcsFile); + + }//end __construct() + + + /** + * Returns the element names that this tag is comprised of, in the order + * that they appear in the tag. + * + * @return array(string) + * @see processSubElement() + */ + protected function getSubElements() + { + return array('content'); + + }//end getSubElements() + + + /** + * Processes the sub element with the specified name. + * + * @param string $name The name of the sub element to process. + * @param string $content The content of this sub element. + * @param string $whitespaceBefore The whitespace that exists before the + * sub element. + * + * @return void + * @see getSubElements() + */ + protected function processSubElement($name, $content, $whitespaceBefore) + { + $this->content = $content; + $this->contentWhitespace = $whitespaceBefore; + + }//end processSubElement() + + + /** + * Returns the content of this tag. + * + * @return string + */ + public function getContent() + { + return $this->content; + + }//end getContent() + + + /** + * Returns the whitespace before the content of this tag. + * + * @return string + */ + public function getWhitespaceBeforeContent() + { + return $this->contentWhitespace; + + }//end getWhitespaceBeforeContent() + + + /** + * Processes a content check for single doc element. + * + * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. + * @param int $commentStart The line number where + * the error occurs. + * @param string $docBlock Whether this is a file or + * class comment doc. + * + * @return void + */ + public function process( + PHP_CodeSniffer_File $phpcsFile, + $commentStart, + $docBlock + ) { + if ($this->content === '') { + $errorPos = ($commentStart + $this->getLine()); + $error = 'Content missing for %s tag in %s comment'; + $data = array( + $this->tag, + $docBlock, + ); + $phpcsFile->addError($error, $errorPos, 'EmptyTagContent', $data); + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/DocGenerators/Generator.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/DocGenerators/Generator.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/DocGenerators/Generator.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/DocGenerators/Generator.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,197 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * The base class for all PHP_CodeSniffer documentation generators. + * + * Documentation generators are used to print documentation about code sniffs + * in a standard. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PHP_CodeSniffer_DocGenerators_Generator +{ + + /** + * The name of the coding standard we are generating docs for. + * + * @var string + */ + private $_standard = ''; + + /** + * An array of sniffs that we are limiting the generated docs to. + * + * If this array is empty, docs are generated for all sniffs in the + * supplied coding standard. + * + * @var string + */ + private $_sniffs = array(); + + + /** + * Constructs a PHP_CodeSniffer_DocGenerators_Generator object. + * + * @param string $standard The name of the coding standard to generate + * docs for. + * @param array $sniffs An array of sniffs that we are limiting the + * generated docs to. + * + * @see generate() + */ + public function __construct($standard, array $sniffs=array()) + { + $this->_standard = $standard; + $this->_sniffs = $sniffs; + + }//end __construct() + + + /** + * Retrieves the title of the sniff from the DOMNode supplied. + * + * @param DOMNode $doc The DOMNode object for the sniff. + * It represents the "documentation" tag in the XML + * standard file. + * + * @return string + */ + protected function getTitle(DOMNode $doc) + { + return $doc->getAttribute('title'); + + }//end getTitle() + + + /** + * Retrieves the name of the standard we are generating docs for. + * + * @return string + */ + protected function getStandard() + { + return $this->_standard; + + }//end getStandard() + + + /** + * Generates the documentation for a standard. + * + * It's probably wise for doc generators to override this method so they + * have control over how the docs are produced. Otherwise, the processSniff + * method should be overridden to output content for each sniff. + * + * @return void + * @see processSniff() + */ + public function generate() + { + $standardFiles = $this->getStandardFiles(); + + foreach ($standardFiles as $standard) { + $doc = new DOMDocument(); + $doc->load($standard); + $documentation = $doc->getElementsByTagName('documentation')->item(0); + $this->processSniff($documentation); + } + + }//end generate() + + + /** + * Returns a list of paths to XML standard files for all sniffs in a standard. + * + * Any sniffs that do not have an XML standard file are obviously not included + * in the returned array. If documentation is only being generated for some + * sniffs (ie. $this->_sniffs is not empty) then all others sniffs will + * be filtered from the results as well. + * + * @return array(string) + */ + protected function getStandardFiles() + { + if (is_dir($this->_standard) === true) { + // This is a custom standard. + $standardDir = $this->_standard; + $standard = basename($this->_standard); + } else { + $standardDir + = realpath(dirname(__FILE__).'/../Standards/'.$this->_standard); + + $standard = $this->_standard; + } + + $phpcs = new PHP_CodeSniffer(); + $sniffs = $phpcs->getSniffFiles($standardDir, $standard); + + $standardFiles = array(); + foreach ($sniffs as $sniff) { + if (empty($this->_sniffs) === false) { + // We are limiting the docs to certain sniffs only, so filter + // out any unwanted sniffs. + $sniffName = substr($sniff, (strrpos($sniff, '/') + 1)); + $sniffName = substr($sniffName, 0, -9); + if (in_array($sniffName, $this->_sniffs) === false) { + continue; + } + } + + $standardFile = str_replace( + DIRECTORY_SEPARATOR.'Sniffs'.DIRECTORY_SEPARATOR, + DIRECTORY_SEPARATOR.'Docs'.DIRECTORY_SEPARATOR, + $sniff + ); + $standardFile = str_replace('Sniff.php', 'Standard.xml', $standardFile); + + if (is_file($standardFile) === true) { + $standardFiles[] = $standardFile; + } + }//end foreach + + return $standardFiles; + + }//end getStandardFiles() + + + /** + * Process the documentation for a single sniff. + * + * Doc generators should override this function to produce output. + * + * @param DOMNode $doc The DOMNode object for the sniff. + * It represents the "documentation" tag in the XML + * standard file. + * + * @return void + * @see generate() + */ + protected function processSniff(DOMNode $doc) + { + + }//end processSniff() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/DocGenerators/HTML.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/DocGenerators/HTML.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/DocGenerators/HTML.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/DocGenerators/HTML.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,292 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +if (class_exists('PHP_CodeSniffer_DocGenerators_Generator', true) === false) { + throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_DocGenerators_Generator not found'); +} + +/** + * A doc generator that outputs documentation in one big HTML file. + * + * Output is in one large HTML file and is designed for you to style with + * your own stylesheet. It contains a table of contents at the top with anchors + * to each sniff. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PHP_CodeSniffer_DocGenerators_HTML extends PHP_CodeSniffer_DocGenerators_Generator +{ + + + /** + * Generates the documentation for a standard. + * + * @return void + * @see processSniff() + */ + public function generate() + { + ob_start(); + $this->printHeader(); + + $standardFiles = $this->getStandardFiles(); + $this->printToc($standardFiles); + + foreach ($standardFiles as $standard) { + $doc = new DOMDocument(); + $doc->load($standard); + $documentation = $doc->getElementsByTagName('documentation')->item(0); + $this->processSniff($documentation); + } + + $this->printFooter(); + + $content = ob_get_contents(); + ob_end_clean(); + + echo $content; + + }//end generate() + + + /** + * Print the header of the HTML page. + * + * @return void + */ + protected function printHeader() + { + $standard = $this->getStandard(); + echo ''.PHP_EOL; + echo ' '.PHP_EOL; + echo " $standard Coding Standards".PHP_EOL; + echo ' '.PHP_EOL; + echo ' '.PHP_EOL; + echo ' '.PHP_EOL; + echo "

$standard Coding Standards

".PHP_EOL; + + }//end printHeader() + + + /** + * Print the table of contents for the standard. + * + * The TOC is just an unordered list of bookmarks to sniffs on the page. + * + * @param array $standardFiles An array of paths to the XML standard files. + * + * @return void + */ + protected function printToc($standardFiles) + { + echo '

Table of Contents

'.PHP_EOL; + echo '
'.PHP_EOL; + + }//end printToc() + + + /** + * Print the footer of the HTML page. + * + * @return void + */ + protected function printFooter() + { + // Turn off strict errors so we don't get timezone warnings if people + // don't have their timezone set. + error_reporting(E_ALL); + echo '
'; + echo 'Documentation generated on '.date('r'); + echo ' by PHP_CodeSniffer 1.5.0RC2'; + echo '
'.PHP_EOL; + error_reporting(E_ALL | E_STRICT); + + echo ' '.PHP_EOL; + echo ''.PHP_EOL; + + }//end printFooter() + + + /** + * Process the documentation for a single sniff. + * + * @param DOMNode $doc The DOMNode object for the sniff. + * It represents the "documentation" tag in the XML + * standard file. + * + * @return void + */ + public function processSniff(DOMNode $doc) + { + $title = $this->getTitle($doc); + echo ' '.PHP_EOL; + echo "

$title

".PHP_EOL; + + foreach ($doc->childNodes as $node) { + if ($node->nodeName === 'standard') { + $this->printTextBlock($node); + } else if ($node->nodeName === 'code_comparison') { + $this->printCodeComparisonBlock($node); + } + } + + }//end processSniff() + + + /** + * Print a text block found in a standard. + * + * @param DOMNode $node The DOMNode object for the text block. + * + * @return void + */ + protected function printTextBlock($node) + { + $content = trim($node->nodeValue); + $content = htmlspecialchars($content); + + // Allow em tags only. + $content = str_replace('<em>', '', $content); + $content = str_replace('</em>', '', $content); + + echo "

$content

".PHP_EOL; + + }//end printTextBlock() + + + /** + * Print a code comparison block found in a standard. + * + * @param DOMNode $node The DOMNode object for the code comparison block. + * + * @return void + */ + protected function printCodeComparisonBlock($node) + { + $codeBlocks = $node->getElementsByTagName('code'); + + $firstTitle = $codeBlocks->item(0)->getAttribute('title'); + $first = trim($codeBlocks->item(0)->nodeValue); + $first = str_replace("\n", '
', $first); + $first = str_replace(' ', ' ', $first); + $first = str_replace('', '', $first); + $first = str_replace('', '', $first); + + $secondTitle = $codeBlocks->item(1)->getAttribute('title'); + $second = trim($codeBlocks->item(1)->nodeValue); + $second = str_replace("\n", '
', $second); + $second = str_replace(' ', ' ', $second); + $second = str_replace('', '', $second); + $second = str_replace('', '', $second); + + echo ' '.PHP_EOL; + echo ' '.PHP_EOL; + echo " ".PHP_EOL; + echo " ".PHP_EOL; + echo ' '.PHP_EOL; + echo ' '.PHP_EOL; + echo " ".PHP_EOL; + echo " ".PHP_EOL; + echo ' '.PHP_EOL; + echo '
$firstTitle$secondTitle
$first$second
'.PHP_EOL; + + }//end printCodeComparisonBlock() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/DocGenerators/Text.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/DocGenerators/Text.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/DocGenerators/Text.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/DocGenerators/Text.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,267 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +if (class_exists('PHP_CodeSniffer_DocGenerators_Generator', true) === false) { + throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_DocGenerators_Generator not found'); +} + +/** + * A doc generator that outputs text-based documentation. + * + * Output is designed to be displayed in a terminal and is wrapped to 100 characters. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PHP_CodeSniffer_DocGenerators_Text extends PHP_CodeSniffer_DocGenerators_Generator +{ + + + /** + * Process the documentation for a single sniff. + * + * @param DOMNode $doc The DOMNode object for the sniff. + * It represents the "documentation" tag in the XML + * standard file. + * + * @return void + */ + public function processSniff(DOMNode $doc) + { + $this->printTitle($doc); + + foreach ($doc->childNodes as $node) { + if ($node->nodeName === 'standard') { + $this->printTextBlock($node); + } else if ($node->nodeName === 'code_comparison') { + $this->printCodeComparisonBlock($node); + } + } + + }//end processSniff() + + + /** + * Prints the title area for a single sniff. + * + * @param DOMNode $doc The DOMNode object for the sniff. + * It represents the "documentation" tag in the XML + * standard file. + * + * @return void + */ + protected function printTitle(DOMNode $doc) + { + $title = $this->getTitle($doc); + $standard = $this->getStandard(); + + echo PHP_EOL; + echo str_repeat('-', (strlen("$standard CODING STANDARD: $title") + 4)); + echo strtoupper(PHP_EOL."| $standard CODING STANDARD: $title |".PHP_EOL); + echo str_repeat('-', (strlen("$standard CODING STANDARD: $title") + 4)); + echo PHP_EOL.PHP_EOL; + + }//end printTitle() + + + /** + * Print a text block found in a standard. + * + * @param DOMNode $node The DOMNode object for the text block. + * + * @return void + */ + protected function printTextBlock($node) + { + $text = trim($node->nodeValue); + $text = str_replace('', '*', $text); + $text = str_replace('', '*', $text); + + $lines = array(); + $tempLine = ''; + $words = explode(' ', $text); + + foreach ($words as $word) { + if (strlen($tempLine.$word) >= 99) { + if (strlen($tempLine.$word) === 99) { + // Adding the extra space will push us to the edge + // so we are done. + $lines[] = $tempLine.$word; + $tempLine = ''; + } else if (strlen($tempLine.$word) === 100) { + // We are already at the edge, so we are done. + $lines[] = $tempLine.$word; + $tempLine = ''; + } else { + $lines[] = rtrim($tempLine); + $tempLine = $word.' '; + } + } else { + $tempLine .= $word.' '; + } + }//end foreach + + if ($tempLine !== '') { + $lines[] = rtrim($tempLine); + } + + echo implode(PHP_EOL, $lines).PHP_EOL.PHP_EOL; + + }//end printTextBlock() + + + /** + * Print a code comparison block found in a standard. + * + * @param DOMNode $node The DOMNode object for the code comparison block. + * + * @return void + */ + protected function printCodeComparisonBlock($node) + { + $codeBlocks = $node->getElementsByTagName('code'); + $first = trim($codeBlocks->item(0)->nodeValue); + $firstTitle = $codeBlocks->item(0)->getAttribute('title'); + + $firstTitleLines = array(); + $tempTitle = ''; + $words = explode(' ', $firstTitle); + + foreach ($words as $word) { + if (strlen($tempTitle.$word) >= 45) { + if (strlen($tempTitle.$word) === 45) { + // Adding the extra space will push us to the edge + // so we are done. + $firstTitleLines[] = $tempTitle.$word; + $tempTitle = ''; + } else if (strlen($tempTitle.$word) === 46) { + // We are already at the edge, so we are done. + $firstTitleLines[] = $tempTitle.$word; + $tempTitle = ''; + } else { + $firstTitleLines[] = $tempTitle; + $tempTitle = $word; + } + } else { + $tempTitle .= $word.' '; + } + }//end foreach + + if ($tempTitle !== '') { + $firstTitleLines[] = $tempTitle; + } + + $first = str_replace('', '', $first); + $first = str_replace('', '', $first); + $firstLines = explode("\n", $first); + + $second = trim($codeBlocks->item(1)->nodeValue); + $secondTitle = $codeBlocks->item(1)->getAttribute('title'); + + $secondTitleLines = array(); + $tempTitle = ''; + $words = explode(' ', $secondTitle); + + foreach ($words as $word) { + if (strlen($tempTitle.$word) >= 45) { + if (strlen($tempTitle.$word) === 45) { + // Adding the extra space will push us to the edge + // so we are done. + $secondTitleLines[] = $tempTitle.$word; + $tempTitle = ''; + } else if (strlen($tempTitle.$word) === 46) { + // We are already at the edge, so we are done. + $secondTitleLines[] = $tempTitle.$word; + $tempTitle = ''; + } else { + $secondTitleLines[] = $tempTitle; + $tempTitle = $word; + } + } else { + $tempTitle .= $word.' '; + } + }//end foreach + + if ($tempTitle !== '') { + $secondTitleLines[] = $tempTitle; + } + + $second = str_replace('', '', $second); + $second = str_replace('', '', $second); + $secondLines = explode("\n", $second); + + $maxCodeLines = max(count($firstLines), count($secondLines)); + $maxTitleLines = max(count($firstTitleLines), count($secondTitleLines)); + + echo str_repeat('-', 41); + echo ' CODE COMPARISON '; + echo str_repeat('-', 42).PHP_EOL; + + for ($i = 0; $i < $maxTitleLines; $i++) { + if (isset($firstTitleLines[$i]) === true) { + $firstLineText = $firstTitleLines[$i]; + } else { + $firstLineText = ''; + } + + if (isset($secondTitleLines[$i]) === true) { + $secondLineText = $secondTitleLines[$i]; + } else { + $secondLineText = ''; + } + + echo '| '; + echo $firstLineText.str_repeat(' ', (46 - strlen($firstLineText))); + echo ' | '; + echo $secondLineText.str_repeat(' ', (47 - strlen($secondLineText))); + echo ' |'.PHP_EOL; + }//end for + + echo str_repeat('-', 100).PHP_EOL; + + for ($i = 0; $i < $maxCodeLines; $i++) { + if (isset($firstLines[$i]) === true) { + $firstLineText = $firstLines[$i]; + } else { + $firstLineText = ''; + } + + if (isset($secondLines[$i]) === true) { + $secondLineText = $secondLines[$i]; + } else { + $secondLineText = ''; + } + + echo '| '; + echo $firstLineText.str_repeat(' ', (47 - strlen($firstLineText))); + echo '| '; + echo $secondLineText.str_repeat(' ', (48 - strlen($secondLineText))); + echo '|'.PHP_EOL; + }//end for + + echo str_repeat('-', 100).PHP_EOL.PHP_EOL; + + }//end printCodeComparisonBlock() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Exception.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Exception.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Exception.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Exception.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,33 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * An exception thrown by PHP_CodeSniffer when it encounters an unrecoverable error. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PHP_CodeSniffer_Exception extends Exception +{ + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/File.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/File.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/File.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/File.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,2872 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * A PHP_CodeSniffer_File object represents a PHP source file and the tokens + * associated with it. + * + * It provides a means for traversing the token stack, along with + * other token related operations. If a PHP_CodeSniffer_Sniff finds and error or + * warning within a PHP_CodeSniffer_File, you can raise an error using the + * addError() or addWarning() methods. + * + * Token Information + * + * Each token within the stack contains information about itself: + * + * + * array( + * 'code' => 301, // the token type code (see token_get_all()) + * 'content' => 'if', // the token content + * 'type' => 'T_IF', // the token name + * 'line' => 56, // the line number when the token is located + * 'column' => 12, // the column in the line where this token + * // starts (starts from 1) + * 'level' => 2 // the depth a token is within the scopes open + * 'conditions' => array( // a list of scope condition token + * // positions => codes that + * 2 => 50, // openened the scopes that this token exists + * 9 => 353, // in (see conditional tokens section below) + * ), + * ); + * + * + * Conditional Tokens + * + * In addition to the standard token fields, conditions contain information to + * determine where their scope begins and ends: + * + * + * array( + * 'scope_condition' => 38, // the token position of the condition + * 'scope_opener' => 41, // the token position that started the scope + * 'scope_closer' => 70, // the token position that ended the scope + * ); + * + * + * The condition, the scope opener and the scope closer each contain this + * information. + * + * Parenthesis Tokens + * + * Each parenthesis token (T_OPEN_PARENTHESIS and T_CLOSE_PARENTHESIS) has a + * reference to their opening and closing parenthesis, one being itself, the + * other being its opposite. + * + * + * array( + * 'parenthesis_opener' => 34, + * 'parenthesis_closer' => 40, + * ); + * + * + * Some tokens can "own" a set of parenthesis. For example a T_FUNCTION token + * has parenthesis around its argument list. These tokens also have the + * parenthesis_opener and and parenthesis_closer indices. Not all parenthesis + * have owners, for example parenthesis used for arithmetic operations and + * function calls. The parenthesis tokens that have an owner have the following + * auxiliary array indices. + * + * + * array( + * 'parenthesis_opener' => 34, + * 'parenthesis_closer' => 40, + * 'parenthesis_owner' => 33, + * ); + * + * + * Each token within a set of parenthesis also has an array indice + * 'nested_parenthesis' which is an array of the + * left parenthesis => right parenthesis token positions. + * + * + * 'nested_parenthesis' => array( + * 12 => 15 + * 11 => 14 + * ); + * + * + * Extended Tokens + * + * PHP_CodeSniffer extends and augments some of the tokens created by + * token_get_all(). A full list of these tokens can be seen in the + * Tokens.php file. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PHP_CodeSniffer_File +{ + + /** + * The absolute path to the file associated with this object. + * + * @var string + */ + private $_file = ''; + + /** + * The EOL character this file uses. + * + * @var string + */ + public $eolChar = ''; + + /** + * The PHP_CodeSniffer object controlling this run. + * + * @var PHP_CodeSniffer + */ + public $phpcs = null; + + /** + * The tokenizer being used for this file. + * + * @var object + */ + public $tokenizer = null; + + /** + * The tokenizer being used for this file. + * + * @var string + */ + public $tokenizerType = 'PHP'; + + /** + * The number of tokens in this file. + * + * Stored here to save calling count() everywhere. + * + * @var int + */ + public $numTokens = 0; + + /** + * The tokens stack map. + * + * Note that the tokens in this array differ in format to the tokens + * produced by token_get_all(). Tokens are initially produced with + * token_get_all(), then augmented so that it's easier to process them. + * + * @var array() + * @see Tokens.php + */ + private $_tokens = array(); + + /** + * The errors raised from PHP_CodeSniffer_Sniffs. + * + * @var array() + * @see getErrors() + */ + private $_errors = array(); + + /** + * The warnings raised form PHP_CodeSniffer_Sniffs. + * + * @var array() + * @see getWarnings() + */ + private $_warnings = array(); + + /** + * Record the errors and warnings raised. + * + * @var bool + */ + private $_recordErrors = true; + + /** + * And array of lines being ignored by PHP_CodeSniffer. + * + * @var array() + */ + private $_ignoredLines = array(); + + /** + * The total number of errors raised. + * + * @var int + */ + private $_errorCount = 0; + + /** + * The total number of warnings raised. + * + * @var int + */ + private $_warningCount = 0; + + /** + * An array of sniffs listening to this file's processing. + * + * @var array(PHP_CodeSniffer_Sniff) + */ + private $_listeners = array(); + + /** + * The class name of the sniff currently processing the file. + * + * @var string + */ + private $_activeListener = ''; + + /** + * An array of sniffs being processed and how long they took. + * + * @var array() + */ + private $_listenerTimes = array(); + + /** + * An array of extensions mapping to the tokenizer to use. + * + * This value gets set by PHP_CodeSniffer when the object is created. + * + * @var array + */ + protected $tokenizers = array(); + + /** + * An array of rules from the ruleset.xml file. + * + * This value gets set by PHP_CodeSniffer when the object is created. + * It may be empty, indicating that the ruleset does not override + * any of the default sniff settings. + * + * @var array + */ + protected $ruleset = array(); + + + /** + * Constructs a PHP_CodeSniffer_File. + * + * @param string $file The absolute path to the file to process. + * @param array(string) $listeners The initial listeners listening + * to processing of this file. + * @param array $tokenizers An array of extensions mapping + * to the tokenizer to use. + * @param array $ruleset An array of rules from the + * ruleset.xml file. + * @param PHP_CodeSniffer $phpcs The PHP_CodeSniffer object controlling + * this run. + * + * @throws PHP_CodeSniffer_Exception If the register() method does + * not return an array. + */ + public function __construct( + $file, + array $listeners, + array $tokenizers, + array $ruleset, + PHP_CodeSniffer $phpcs + ) { + $this->_file = trim($file); + $this->_listeners = $listeners; + $this->tokenizers = $tokenizers; + $this->ruleset = $ruleset; + $this->phpcs = $phpcs; + + $cliValues = $phpcs->cli->getCommandLineValues(); + if (isset($cliValues['showSources']) === true + && $cliValues['showSources'] !== true + && array_key_exists('summary', $cliValues['reports']) === true + && count($cliValues['reports']) === 1 + ) { + $this->_recordErrors = false; + } + + }//end __construct() + + + /** + * Sets the name of the currently active sniff. + * + * @param string $activeListener The class name of the current sniff. + * + * @return void + */ + public function setActiveListener($activeListener) + { + $this->_activeListener = $activeListener; + + }//end setActiveListener() + + + /** + * Adds a listener to the token stack that listens to the specific tokens. + * + * When PHP_CodeSniffer encounters on the the tokens specified in $tokens, + * it invokes the process method of the sniff. + * + * @param PHP_CodeSniffer_Sniff $listener The listener to add to the + * listener stack. + * @param array(int) $tokens The token types the listener wishes to + * listen to. + * + * @return void + */ + public function addTokenListener(PHP_CodeSniffer_Sniff $listener, array $tokens) + { + foreach ($tokens as $token) { + if (isset($this->_listeners[$token]) === false) { + $this->_listeners[$token] = array(); + } + + if (in_array($listener, $this->_listeners[$token], true) === false) { + $this->_listeners[$token][] = $listener; + } + } + + }//end addTokenListener() + + + /** + * Removes a listener from listening from the specified tokens. + * + * @param PHP_CodeSniffer_Sniff $listener The listener to remove from the + * listener stack. + * @param array(int) $tokens The token types the listener wishes to + * stop listen to. + * + * @return void + */ + public function removeTokenListener( + PHP_CodeSniffer_Sniff $listener, + array $tokens + ) { + foreach ($tokens as $token) { + if (isset($this->_listeners[$token]) === false) { + continue; + } + + if (in_array($listener, $this->_listeners[$token]) === true) { + foreach ($this->_listeners[$token] as $pos => $value) { + if ($value === $listener) { + unset($this->_listeners[$token][$pos]); + } + } + } + } + + }//end removeTokenListener() + + + /** + * Returns the token stack for this file. + * + * @return array() + */ + public function getTokens() + { + return $this->_tokens; + + }//end getTokens() + + + /** + * Starts the stack traversal and tells listeners when tokens are found. + * + * @param string $contents The contents to parse. If NULL, the content + * is taken from the file system. + * + * @return void + */ + public function start($contents=null) + { + $this->_parse($contents); + + if (PHP_CODESNIFFER_VERBOSITY > 2) { + echo "\t*** START TOKEN PROCESSING ***".PHP_EOL; + } + + $foundCode = false; + $ignoring = false; + + // Foreach of the listeners that have registered to listen for this + // token, get them to process it. + foreach ($this->_tokens as $stackPtr => $token) { + // Check for ignored lines. + if ($token['code'] === T_COMMENT) { + if (strpos($token['content'], '@codingStandardsIgnoreStart') !== false) { + $ignoring = true; + } else if (strpos($token['content'], '@codingStandardsIgnoreEnd') !== false) { + $ignoring = false; + // Ignore this comment too. + $this->_ignoredLines[$token['line']] = true; + } else if (strpos($token['content'], '@codingStandardsIgnoreFile') !== false) { + // Ignoring the whole file, just a little late. + $this->_errors = array(); + $this->_warnings = array(); + $this->_errorCount = 0; + $this->_warningCount = 0; + return; + } else if (strpos($token['content'], '@codingStandardsChangeSetting') !== false) { + $start = strpos($token['content'], '@codingStandardsChangeSetting'); + $comment = substr($token['content'], $start + 30); + $parts = explode(' ', $comment); + $sniffParts = explode('.', $parts[0]); + $listenerClass = $sniffParts[0].'_Sniffs_'.$sniffParts[1].'_'.$sniffParts[2].'Sniff'; + $this->phpcs->setSniffProperty($listenerClass, $parts[1], $parts[2]); + } + } + + if ($ignoring === true) { + $this->_ignoredLines[$token['line']] = true; + continue; + } + + if (PHP_CODESNIFFER_VERBOSITY > 2) { + $type = $token['type']; + $content = str_replace($this->eolChar, '\n', $token['content']); + echo "\t\tProcess token $stackPtr: $type => $content".PHP_EOL; + } + + $tokenType = $token['code']; + if ($tokenType !== T_INLINE_HTML) { + $foundCode = true; + } + + if (isset($this->_listeners[$tokenType]) === false) { + continue; + } + + foreach ($this->_listeners[$tokenType] as $listenerData) { + // Make sure this sniff supports the tokenizer + // we are currently using. + $listener = $listenerData['listener']; + $class = $listenerData['class']; + + if (in_array($this->tokenizerType, $listenerData['tokenizers']) === false) { + continue; + } + + // If the file path matches one of our ignore patterns, skip it. + $parts = explode('_', $class); + if (isset($parts[3]) === true) { + $source = $parts[0].'.'.$parts[2].'.'.substr($parts[3], 0, -5); + $patterns = $this->phpcs->getIgnorePatterns($source); + foreach ($patterns as $pattern => $type) { + // While there is support for a type of each pattern + // (absolute or relative) we don't actually support it here. + $replacements = array( + '\\,' => ',', + '*' => '.*', + ); + + $pattern = strtr($pattern, $replacements); + if (preg_match("|{$pattern}|i", $this->_file) === 1) { + continue(2); + } + } + } + + $this->setActiveListener($class); + + if (PHP_CODESNIFFER_VERBOSITY > 2) { + $startTime = microtime(true); + echo "\t\t\tProcessing ".$this->_activeListener.'... '; + } + + $listener->process($this, $stackPtr); + + if (PHP_CODESNIFFER_VERBOSITY > 2) { + $timeTaken = (microtime(true) - $startTime); + if (isset($this->_listenerTimes[$this->_activeListener]) === false) { + $this->_listenerTimes[$this->_activeListener] = 0; + } + + $this->_listenerTimes[$this->_activeListener] += $timeTaken; + + $timeTaken = round(($timeTaken), 4); + echo "DONE in $timeTaken seconds".PHP_EOL; + } + + $this->_activeListener = ''; + }//end foreach + }//end foreach + + // Remove errors and warnings for ignored lines. + foreach ($this->_ignoredLines as $line => $ignore) { + if (isset($this->_errors[$line]) === true) { + if ($this->_recordErrors === false) { + $this->_errorCount -= $this->_errors[$line]; + } else { + foreach ($this->_errors[$line] as $col => $errors) { + $this->_errorCount -= count($errors); + } + } + + unset($this->_errors[$line]); + } + + if (isset($this->_warnings[$line]) === true) { + if ($this->_recordErrors === false) { + $this->_errorCount -= $this->_warnings[$line]; + } else { + foreach ($this->_warnings[$line] as $col => $warnings) { + $this->_warningCount -= count($warnings); + } + } + + unset($this->_warnings[$line]); + } + }//end foreach + + if ($this->_recordErrors === false) { + $this->_errors = array(); + $this->_warnings = array(); + } + + // If short open tags are off but the file being checked uses + // short open tags, the whole content will be inline HTML + // and nothing will be checked. So try and handle this case. + if ($foundCode === false) { + $shortTags = (bool) ini_get('short_open_tag'); + if ($shortTags === false) { + $error = 'No PHP code was found in this file and short open tags are not allowed by this install of PHP. This file may be using short open tags but PHP does not allow them.'; + $this->addWarning($error, null, 'Internal.NoCodeFound'); + } + } + + if (PHP_CODESNIFFER_VERBOSITY > 2) { + echo "\t*** END TOKEN PROCESSING ***".PHP_EOL; + } + + if (PHP_CODESNIFFER_VERBOSITY > 2) { + echo "\t*** START SNIFF PROCESSING REPORT ***".PHP_EOL; + + asort($this->_listenerTimes, SORT_NUMERIC); + $this->_listenerTimes = array_reverse($this->_listenerTimes, true); + foreach ($this->_listenerTimes as $listener => $timeTaken) { + echo "\t$listener: ".round(($timeTaken), 4).' secs'.PHP_EOL; + } + + echo "\t*** END SNIFF PROCESSING REPORT ***".PHP_EOL; + } + + }//end start() + + + /** + * Remove vars stored in this sniff that are no longer required. + * + * @return void + */ + public function cleanUp() + { + $this->_tokens = null; + $this->_listeners = null; + + }//end cleanUp() + + + /** + * Tokenizes the file and prepares it for the test run. + * + * @param string $contents The contents to parse. If NULL, the content + * is taken from the file system. + * + * @return void + */ + private function _parse($contents=null) + { + try { + $this->eolChar = self::detectLineEndings($this->_file, $contents); + } catch (PHP_CodeSniffer_Exception $e) { + $this->addWarning($e->getMessage(), null, 'Internal.DetectLineEndings'); + return; + } + + // Determine the tokenizer from the file extension. + $fileParts = explode('.', $this->_file); + $extension = array_pop($fileParts); + if (isset($this->tokenizers[$extension]) === true) { + $tokenizerClass = 'PHP_CodeSniffer_Tokenizers_'.$this->tokenizers[$extension]; + $this->tokenizerType = $this->tokenizers[$extension]; + } else { + // Revert to default. + $tokenizerClass = 'PHP_CodeSniffer_Tokenizers_'.$this->tokenizerType; + } + + $tokenizer = new $tokenizerClass(); + $this->tokenizer = $tokenizer; + + if ($contents === null) { + $contents = file_get_contents($this->_file); + } + + $this->_tokens = self::tokenizeString($contents, $tokenizer, $this->eolChar); + $this->numTokens = count($this->_tokens); + + // Check for mixed line endings as these can cause tokenizer errors and we + // should let the user know that the results they get may be incorrect. + // This is done by removing all backslashes, removing the newline char we + // detected, then converting newlines chars into text. If any backslashes + // are left at the end, we have additional newline chars in use. + $contents = str_replace('\\', '', $contents); + $contents = str_replace($this->eolChar, '', $contents); + $contents = str_replace("\n", '\n', $contents); + $contents = str_replace("\r", '\r', $contents); + if (strpos($contents, '\\') !== false) { + $error = 'File has mixed line endings; this may cause incorrect results'; + $this->addWarning($error, 0, 'Internal.LineEndings.Mixed'); + } + + if (PHP_CODESNIFFER_VERBOSITY > 0) { + if ($this->numTokens === 0) { + $numLines = 0; + } else { + $numLines = $this->_tokens[($this->numTokens - 1)]['line']; + } + + echo "[$this->numTokens tokens in $numLines lines]... "; + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo PHP_EOL; + } + } + + }//end _parse() + + + /** + * Opens a file and detects the EOL character being used. + * + * @param string $file The full path to the file. + * @param string $contents The contents to parse. If NULL, the content + * is taken from the file system. + * + * @return string + * @throws PHP_CodeSniffer_Exception If $file could not be opened. + */ + public static function detectLineEndings($file, $contents=null) + { + if ($contents === null) { + // Determine the newline character being used in this file. + // Will be either \r, \r\n or \n. + if (is_readable($file) === false) { + $error = 'Error opening file; file no longer exists or you do not have access to read the file'; + throw new PHP_CodeSniffer_Exception($error); + } else { + $handle = fopen($file, 'r'); + if ($handle === false) { + $error = 'Error opening file; could not auto-detect line endings'; + throw new PHP_CodeSniffer_Exception($error); + } + } + + $firstLine = fgets($handle); + fclose($handle); + + $eolChar = substr($firstLine, -1); + if ($eolChar === "\n") { + $secondLastChar = substr($firstLine, -2, 1); + if ($secondLastChar === "\r") { + $eolChar = "\r\n"; + } + } else if ($eolChar !== "\r") { + // Must not be an EOL char at the end of the line. + // Probably a one-line file, so assume \n as it really + // doesn't matter considering there are no newlines. + $eolChar = "\n"; + } + } else { + if (preg_match("/\r\n?|\n/", $contents, $matches) !== 1) { + // Assuming there are no newlines. + $eolChar = "\n"; + } else { + $eolChar = $matches[0]; + } + }//end if + + return $eolChar; + + }//end detectLineEndings() + + + /** + * Adds an error to the error stack. + * + * @param string $error The error message. + * @param int $stackPtr The stack position where the error occurred. + * @param string $code A violation code unique to the sniff message. + * @param array $data Replacements for the error message. + * @param int $severity The severity level for this error. A value of 0 + * will be converted into the default severity level. + * + * @return void + */ + public function addError($error, $stackPtr, $code='', $data=array(), $severity=0) + { + // Don't bother doing any processing if errors are just going to + // be hidden in the reports anyway. + if ($this->phpcs->cli->errorSeverity === 0) { + return; + } + + // Work out which sniff generated the error. + if (substr($code, 0, 9) === 'Internal.') { + // Any internal message. + $sniff = $code; + } else { + $parts = explode('_', $this->_activeListener); + if (isset($parts[3]) === true) { + $sniff = $parts[0].'.'.$parts[2].'.'.$parts[3]; + + // Remove "Sniff" from the end. + $sniff = substr($sniff, 0, -5); + } else { + $sniff = 'unknownSniff'; + } + + if ($code !== '') { + $sniff .= '.'.$code; + } + } + + // Make sure this message type has not been set to "warning". + if (isset($this->ruleset[$sniff]['type']) === true + && $this->ruleset[$sniff]['type'] === 'warning' + ) { + // Pass this off to the warning handler. + $this->addWarning($error, $stackPtr, $code, $data, $severity); + return; + } + + // Make sure we are interested in this severity level. + if (isset($this->ruleset[$sniff]['severity']) === true) { + $severity = $this->ruleset[$sniff]['severity']; + } else if ($severity === 0) { + $severity = PHPCS_DEFAULT_ERROR_SEV; + } + + if ($this->phpcs->cli->errorSeverity > $severity) { + return; + } + + // Make sure we are not ignoring this file. + $patterns = $this->phpcs->getIgnorePatterns($sniff); + foreach ($patterns as $pattern => $type) { + // While there is support for a type of each pattern + // (absolute or relative) we don't actually support it here. + $replacements = array( + '\\,' => ',', + '*' => '.*', + ); + + $pattern = strtr($pattern, $replacements); + if (preg_match("|{$pattern}|i", $this->_file) === 1) { + return; + } + } + + if ($stackPtr === null) { + $lineNum = 1; + $column = 1; + } else { + $lineNum = $this->_tokens[$stackPtr]['line']; + $column = $this->_tokens[$stackPtr]['column']; + } + + $this->_errorCount++; + if ($this->_recordErrors === false) { + if (isset($this->_errors[$lineNum]) === false) { + $this->_errors[$lineNum] = 0; + } + $this->_errors[$lineNum]++; + return; + } + + // Work out the warning message. + if (isset($this->ruleset[$sniff]['message']) === true) { + $error = $this->ruleset[$sniff]['message']; + } + + if (empty($data) === true) { + $message = $error; + } else { + $message = vsprintf($error, $data); + } + + if (isset($this->_errors[$lineNum]) === false) { + $this->_errors[$lineNum] = array(); + } + + if (isset($this->_errors[$lineNum][$column]) === false) { + $this->_errors[$lineNum][$column] = array(); + } + + $this->_errors[$lineNum][$column][] = array( + 'message' => $message, + 'source' => $sniff, + 'severity' => $severity, + ); + + }//end addError() + + + /** + * Adds an warning to the warning stack. + * + * @param string $warning The error message. + * @param int $stackPtr The stack position where the error occurred. + * @param string $code A violation code unique to the sniff message. + * @param array $data Replacements for the warning message. + * @param int $severity The severity level for this warning. A value of 0 + * will be converted into the default severity level. + * + * @return void + */ + public function addWarning($warning, $stackPtr, $code='', $data=array(), $severity=0) + { + // Don't bother doing any processing if warnings are just going to + // be hidden in the reports anyway. + if ($this->phpcs->cli->warningSeverity === 0) { + return; + } + + // Work out which sniff generated the warning. + if (substr($code, 0, 9) === 'Internal.') { + // Any internal message. + $sniff = $code; + } else { + $parts = explode('_', $this->_activeListener); + if (isset($parts[3]) === true) { + $sniff = $parts[0].'.'.$parts[2].'.'.$parts[3]; + + // Remove "Sniff" from the end. + $sniff = substr($sniff, 0, -5); + } else { + $sniff = 'unknownSniff'; + } + + if ($code !== '') { + $sniff .= '.'.$code; + } + } + + // Make sure this message type has not been set to "error". + if (isset($this->ruleset[$sniff]['type']) === true + && $this->ruleset[$sniff]['type'] === 'error' + ) { + // Pass this off to the error handler. + $this->addError($warning, $stackPtr, $code, $data, $severity); + return; + } + + // Make sure we are interested in this severity level. + if (isset($this->ruleset[$sniff]['severity']) === true) { + $severity = $this->ruleset[$sniff]['severity']; + } else if ($severity === 0) { + $severity = PHPCS_DEFAULT_WARN_SEV; + } + + if ($this->phpcs->cli->warningSeverity > $severity) { + return; + } + + // Make sure we are not ignoring this file. + $patterns = $this->phpcs->getIgnorePatterns($sniff); + foreach ($patterns as $pattern => $type) { + // While there is support for a type of each pattern + // (absolute or relative) we don't actually support it here. + $replacements = array( + '\\,' => ',', + '*' => '.*', + ); + + $pattern = strtr($pattern, $replacements); + if (preg_match("|{$pattern}|i", $this->_file) === 1) { + return; + } + } + + if ($stackPtr === null) { + $lineNum = 1; + $column = 1; + } else { + $lineNum = $this->_tokens[$stackPtr]['line']; + $column = $this->_tokens[$stackPtr]['column']; + } + + $this->_warningCount++; + if ($this->_recordErrors === false) { + if (isset($this->_warnings[$lineNum]) === false) { + $this->_warnings[$lineNum] = 0; + } + $this->_warnings[$lineNum]++; + return; + } + + // Work out the warning message. + if (isset($this->ruleset[$sniff]['message']) === true) { + $warning = $this->ruleset[$sniff]['message']; + } + + if (empty($data) === true) { + $message = $warning; + } else { + $message = vsprintf($warning, $data); + } + + if (isset($this->_warnings[$lineNum]) === false) { + $this->_warnings[$lineNum] = array(); + } + + if (isset($this->_warnings[$lineNum][$column]) === false) { + $this->_warnings[$lineNum][$column] = array(); + } + + $this->_warnings[$lineNum][$column][] = array( + 'message' => $message, + 'source' => $sniff, + 'severity' => $severity, + ); + + }//end addWarning() + + + /** + * Returns the number of errors raised. + * + * @return int + */ + public function getErrorCount() + { + return $this->_errorCount; + + }//end getErrorCount() + + + /** + * Returns the number of warnings raised. + * + * @return int + */ + public function getWarningCount() + { + return $this->_warningCount; + + }//end getWarningCount() + + + /** + * Returns the list of ignored lines. + * + * @return array + */ + public function getIgnoredLines() + { + return $this->_ignoredLines; + + }//end getIgnoredLines() + + + /** + * Returns the errors raised from processing this file. + * + * @return array + */ + public function getErrors() + { + return $this->_errors; + + }//end getErrors() + + + /** + * Returns the warnings raised from processing this file. + * + * @return array + */ + public function getWarnings() + { + return $this->_warnings; + + }//end getWarnings() + + + /** + * Returns the absolute filename of this file. + * + * @return string + */ + public function getFilename() + { + return $this->_file; + + }//end getFilename() + + + /** + * Creates an array of tokens when given some PHP code. + * + * Starts by using token_get_all() but does a lot of extra processing + * to insert information about the context of the token. + * + * @param string $string The string to tokenize. + * @param object $tokenizer A tokenizer class to use to tokenize the string. + * @param string $eolChar The EOL character to use for splitting strings. + * + * @return array + */ + public static function tokenizeString($string, $tokenizer, $eolChar='\n') + { + $tokens = $tokenizer->tokenizeString($string, $eolChar); + + self::_createLineMap($tokens, $tokenizer, $eolChar); + self::_createBracketMap($tokens, $tokenizer, $eolChar); + self::_createParenthesisMap($tokens, $tokenizer, $eolChar); + self::_createParenthesisNestingMap($tokens, $tokenizer, $eolChar); + self::_createScopeMap($tokens, $tokenizer, $eolChar); + + // If we know the width of each tab, convert tabs + // into spaces so sniffs can use one method of checking. + if (PHP_CODESNIFFER_TAB_WIDTH > 0) { + self::_convertTabs($tokens, $tokenizer, $eolChar); + } + + // Column map requires the line map to be complete. + self::_createColumnMap($tokens, $tokenizer, $eolChar); + self::_createLevelMap($tokens, $tokenizer, $eolChar); + + // Allow the tokenizer to do additional processing if required. + $tokenizer->processAdditional($tokens, $eolChar); + + return $tokens; + + }//end tokenizeString() + + + /** + * Creates a map of tokens => line numbers for each token. + * + * @param array &$tokens The array of tokens to process. + * @param object $tokenizer The tokenizer being used to process this file. + * @param string $eolChar The EOL character to use for splitting strings. + * + * @return void + */ + private static function _createLineMap(&$tokens, $tokenizer, $eolChar) + { + $lineNumber = 1; + $count = count($tokens); + + for ($i = 0; $i < $count; $i++) { + $tokens[$i]['line'] = $lineNumber; + if ($tokens[$i]['content'] === '') { + continue; + } + + $lineNumber += substr_count($tokens[$i]['content'], $eolChar); + } + + }//end _createLineMap() + + + /** + * Converts tabs into spaces. + * + * Each tab can represent between 1 and $width spaces, so + * this cannot be a straight string replace. + * + * @param array &$tokens The array of tokens to process. + * @param object $tokenizer The tokenizer being used to process this file. + * @param string $eolChar The EOL character to use for splitting strings. + * + * @return void + */ + private static function _convertTabs(&$tokens, $tokenizer, $eolChar) + { + $currColumn = 1; + $count = count($tokens); + + for ($i = 0; $i < $count; $i++) { + $tokenContent = $tokens[$i]['content']; + + if (strpos($tokenContent, "\t") === false) { + // There are no tabs in this content. + $currColumn += strlen($tokenContent); + } else { + // We need to determine the length of each tab. + $tabs = preg_split( + "|(\t)|", + $tokenContent, + -1, + PREG_SPLIT_DELIM_CAPTURE + ); + + $tabNum = 0; + $tabsToSpaces = array(); + $newContent = ''; + + foreach ($tabs as $content) { + if ($content === '') { + continue; + } + + if (strpos($content, "\t") === false) { + // This piece of content is not a tab. + $currColumn += strlen($content); + $newContent .= $content; + } else { + $lastCurrColumn = $currColumn; + $tabNum++; + + // Move the pointer to the next tab stop. + if (($currColumn % PHP_CODESNIFFER_TAB_WIDTH) === 0) { + // This is the first tab, and we are already at a + // tab stop, so this tab counts as a single space. + $currColumn++; + } else { + $currColumn++; + while (($currColumn % PHP_CODESNIFFER_TAB_WIDTH) != 0) { + $currColumn++; + } + + $currColumn++; + } + + $length = ($currColumn - $lastCurrColumn); + $newContent .= str_repeat(' ', $length); + }//end if + }//end foreach + + $tokens[$i]['content'] = $newContent; + }//end if + + if (isset($tokens[($i + 1)]['line']) === true + && $tokens[($i + 1)]['line'] !== $tokens[$i]['line'] + ) { + $currColumn = 1; + } + }//end for + + }//end _convertTabs() + + + /** + * Creates a column map. + * + * The column map indicates where the token started on the line where it + * exists. + * + * @param array &$tokens The array of tokens to process. + * @param object $tokenizer The tokenizer being used to process this file. + * @param string $eolChar The EOL character to use for splitting strings. + * + * @return void + */ + private static function _createColumnMap(&$tokens, $tokenizer, $eolChar) + { + $currColumn = 1; + $count = count($tokens); + + for ($i = 0; $i < $count; $i++) { + $tokens[$i]['column'] = $currColumn; + if (isset($tokens[($i + 1)]['line']) === true + && $tokens[($i + 1)]['line'] !== $tokens[$i]['line'] + ) { + $currColumn = 1; + } else { + $currColumn += strlen($tokens[$i]['content']); + } + } + + }//end _createColumnMap() + + + /** + * Creates a map for opening and closing of square brackets. + * + * Each bracket token (T_OPEN_SQUARE_BRACKET and T_CLOSE_SQUARE_BRACKET) + * has a reference to their opening and closing bracket + * (bracket_opener and bracket_closer). + * + * @param array &$tokens The array of tokens to process. + * @param object $tokenizer The tokenizer being used to process this file. + * @param string $eolChar The EOL character to use for splitting strings. + * + * @return void + */ + private static function _createBracketMap(&$tokens, $tokenizer, $eolChar) + { + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo "\t*** START BRACKET MAP ***".PHP_EOL; + } + + $squareOpeners = array(); + $curlyOpeners = array(); + $numTokens = count($tokens); + + for ($i = 0; $i < $numTokens; $i++) { + switch ($tokens[$i]['code']) { + case T_OPEN_SQUARE_BRACKET: + $squareOpeners[] = $i; + + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo str_repeat("\t", count($squareOpeners)); + echo str_repeat("\t", count($curlyOpeners)); + echo "=> Found square bracket opener at $i".PHP_EOL; + } + + break; + case T_OPEN_CURLY_BRACKET: + if (isset($tokens[$i]['scope_closer']) === false) { + $curlyOpeners[] = $i; + + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo str_repeat("\t", count($squareOpeners)); + echo str_repeat("\t", count($curlyOpeners)); + echo "=> Found curly bracket opener at $i".PHP_EOL; + } + } + break; + case T_CLOSE_SQUARE_BRACKET: + if (empty($squareOpeners) === false) { + $opener = array_pop($squareOpeners); + $tokens[$i]['bracket_opener'] = $opener; + $tokens[$i]['bracket_closer'] = $i; + $tokens[$opener]['bracket_opener'] = $opener; + $tokens[$opener]['bracket_closer'] = $i; + + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo str_repeat("\t", count($squareOpeners)); + echo str_repeat("\t", count($curlyOpeners)); + echo "\t=> Found square bracket closer at $i for $opener".PHP_EOL; + } + } + break; + case T_CLOSE_CURLY_BRACKET: + if (empty($curlyOpeners) === false + && isset($tokens[$i]['scope_opener']) === false + ) { + $opener = array_pop($curlyOpeners); + $tokens[$i]['bracket_opener'] = $opener; + $tokens[$i]['bracket_closer'] = $i; + $tokens[$opener]['bracket_opener'] = $opener; + $tokens[$opener]['bracket_closer'] = $i; + + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo str_repeat("\t", count($squareOpeners)); + echo str_repeat("\t", count($curlyOpeners)); + echo "\t=> Found curly bracket closer at $i for $opener".PHP_EOL; + } + } + break; + default: + continue; + }//end switch + }//end for + + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo "\t*** END BRACKET MAP ***".PHP_EOL; + } + + }//end _createBracketMap() + + + /** + * Creates a map for opening and closing of parenthesis. + * + * Each parenthesis token (T_OPEN_PARENTHESIS and T_CLOSE_PARENTHESIS) has a + * reference to their opening and closing parenthesis (parenthesis_opener + * and parenthesis_closer). + * + * @param array &$tokens The array of tokens to process. + * @param object $tokenizer The tokenizer being used to process this file. + * @param string $eolChar The EOL character to use for splitting strings. + * + * @return void + */ + private static function _createParenthesisMap(&$tokens, $tokenizer, $eolChar) + { + $openers = array(); + $numTokens = count($tokens); + $openOwner = null; + + for ($i = 0; $i < $numTokens; $i++) { + if (in_array($tokens[$i]['code'], PHP_CodeSniffer_Tokens::$parenthesisOpeners) === true) { + $tokens[$i]['parenthesis_opener'] = null; + $tokens[$i]['parenthesis_closer'] = null; + $tokens[$i]['parenthesis_owner'] = $i; + $openOwner = $i; + } else if ($tokens[$i]['code'] === T_OPEN_PARENTHESIS) { + $openers[] = $i; + $tokens[$i]['parenthesis_opener'] = $i; + if ($openOwner !== null) { + $tokens[$openOwner]['parenthesis_opener'] = $i; + $tokens[$i]['parenthesis_owner'] = $openOwner; + $openOwner = null; + } + } else if ($tokens[$i]['code'] === T_CLOSE_PARENTHESIS) { + // Did we set an owner for this set of parenthesis? + $numOpeners = count($openers); + if ($numOpeners !== 0) { + $opener = array_pop($openers); + if (isset($tokens[$opener]['parenthesis_owner']) === true) { + $owner = $tokens[$opener]['parenthesis_owner']; + + $tokens[$owner]['parenthesis_closer'] = $i; + $tokens[$i]['parenthesis_owner'] = $owner; + } + + $tokens[$i]['parenthesis_opener'] = $opener; + $tokens[$i]['parenthesis_closer'] = $i; + $tokens[$opener]['parenthesis_closer'] = $i; + } + }//end if + }//end for + + }//end _createParenthesisMap() + + + /** + * Creates a map for the parenthesis tokens that surround other tokens. + * + * @param array &$tokens The array of tokens to process. + * @param object $tokenizer The tokenizer being used to process this file. + * @param string $eolChar The EOL character to use for splitting strings. + * + * @return void + */ + private static function _createParenthesisNestingMap( + &$tokens, + $tokenizer, + $eolChar + ) { + $numTokens = count($tokens); + $map = array(); + for ($i = 0; $i < $numTokens; $i++) { + if (isset($tokens[$i]['parenthesis_opener']) === true + && $i === $tokens[$i]['parenthesis_opener'] + ) { + if (empty($map) === false) { + $tokens[$i]['nested_parenthesis'] = $map; + } + + if (isset($tokens[$i]['parenthesis_closer']) === true) { + $map[$tokens[$i]['parenthesis_opener']] + = $tokens[$i]['parenthesis_closer']; + } + } else if (isset($tokens[$i]['parenthesis_closer']) === true + && $i === $tokens[$i]['parenthesis_closer'] + ) { + array_pop($map); + if (empty($map) === false) { + $tokens[$i]['nested_parenthesis'] = $map; + } + } else { + if (empty($map) === false) { + $tokens[$i]['nested_parenthesis'] = $map; + } + }//end if + }//end for + + }//end _createParenthesisNestingMap() + + + /** + * Creates a scope map of tokens that open scopes. + * + * @param array &$tokens The array of tokens to process. + * @param object $tokenizer The tokenizer being used to process this file. + * @param string $eolChar The EOL character to use for splitting strings. + * + * @return void + * @see _recurseScopeMap() + */ + private static function _createScopeMap(&$tokens, $tokenizer, $eolChar) + { + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo "\t*** START SCOPE MAP ***".PHP_EOL; + } + + $numTokens = count($tokens); + for ($i = 0; $i < $numTokens; $i++) { + // Check to see if the current token starts a new scope. + if (isset($tokenizer->scopeOpeners[$tokens[$i]['code']]) === true) { + if (PHP_CODESNIFFER_VERBOSITY > 1) { + $type = $tokens[$i]['type']; + $content = str_replace($eolChar, '\n', $tokens[$i]['content']); + echo "\tStart scope map at $i: $type => $content".PHP_EOL; + } + + $i = self::_recurseScopeMap( + $tokens, + $numTokens, + $tokenizer, + $eolChar, + $i + ); + } + }//end for + + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo "\t*** END SCOPE MAP ***".PHP_EOL; + } + + }//end _createScopeMap() + + + /** + * Recurses though the scope openers to build a scope map. + * + * @param array &$tokens The array of tokens to process. + * @param int $numTokens The size of the tokens array. + * @param object $tokenizer The tokenizer being used to process this file. + * @param string $eolChar The EOL character to use for splitting strings. + * @param int $stackPtr The position in the stack of the token that + * opened the scope (eg. an IF token or FOR token). + * @param int $depth How many scope levels down we are. + * @param int &$ignore How many curly braces we are ignoring. + * + * @return int The position in the stack that closed the scope. + */ + private static function _recurseScopeMap( + &$tokens, + $numTokens, + $tokenizer, + $eolChar, + $stackPtr, + $depth=1, + &$ignore=0 + ) { + $opener = null; + $currType = $tokens[$stackPtr]['code']; + $startLine = $tokens[$stackPtr]['line']; + + // We will need this to restore the value if we end up + // returning a token ID that causes our calling function to go back + // over already ignored braces. + $originalIgnore = $ignore; + + // If the start token for this scope opener is the same as + // the scope token, we have already found our opener. + if (in_array($currType, $tokenizer->scopeOpeners[$currType]['start']) === true) { + $opener = $stackPtr; + } + + for ($i = ($stackPtr + 1); $i < $numTokens; $i++) { + $tokenType = $tokens[$i]['code']; + + if (PHP_CODESNIFFER_VERBOSITY > 1) { + $type = $tokens[$i]['type']; + $content = str_replace($eolChar, '\n', $tokens[$i]['content']); + echo str_repeat("\t", $depth); + echo "Process token $i ["; + if ($opener !== null) { + echo "opener:$opener;"; + } + + if ($ignore > 0) { + echo "ignore=$ignore;"; + } + + echo "]: $type => $content".PHP_EOL; + } + + // Very special case for IF statements in PHP that can be defined without + // scope tokens. If an IF statement below this one has an opener but no + // keyword, the opener will be incorrectly assigned to this IF statement. + // E.g., if (1) 1; 1 ? (1 ? 1 : 1) : 1; + if ($currType === T_IF && $opener === null && $tokens[$i]['code'] === T_SEMICOLON) { + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo str_repeat("\t", $depth); + echo "=> Found semicolon before scope opener for $stackPtr (T_IF), bailing".PHP_EOL; + } + + return $i; + } + + // Is this an opening condition ? + if (isset($tokenizer->scopeOpeners[$tokenType]) === true) { + if ($opener === null) { + // Found another opening condition but still haven't + // found our opener, so we are never going to find one. + if (PHP_CODESNIFFER_VERBOSITY > 1) { + $type = $tokens[$stackPtr]['type']; + echo str_repeat("\t", $depth); + echo "=> Couldn't find scope opener for $stackPtr ($type), bailing".PHP_EOL; + } + + return $stackPtr; + } + + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo str_repeat("\t", $depth); + echo '* token is an opening condition *'.PHP_EOL; + } + + $isShared + = ($tokenizer->scopeOpeners[$tokenType]['shared'] === true); + + if (isset($tokens[$i]['scope_condition']) === true) { + // We've been here before. + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo str_repeat("\t", $depth); + echo '* already processed, skipping *'.PHP_EOL; + } + + if ($isShared === false + && isset($tokens[$i]['scope_closer']) === true + ) { + $i = $tokens[$i]['scope_closer']; + } + + continue; + } else if ($currType === $tokenType + && $isShared === false + && $opener === null + ) { + // We haven't yet found our opener, but we have found another + // scope opener which is the same type as us, and we don't + // share openers, so we will never find one. + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo str_repeat("\t", $depth); + echo '* it was another token\'s opener, bailing *'.PHP_EOL; + } + + return $stackPtr; + } else { + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo str_repeat("\t", $depth); + echo '* searching for opener *'.PHP_EOL; + } + + if (in_array(T_CLOSE_CURLY_BRACKET, $tokenizer->scopeOpeners[$tokenType]['end']) === true) { + $oldIgnore = $ignore; + $ignore = 0; + } + + $i = self::_recurseScopeMap( + $tokens, + $numTokens, + $tokenizer, + $eolChar, + $i, + ($depth + 1), + $ignore + ); + + if (in_array(T_CLOSE_CURLY_BRACKET, $tokenizer->scopeOpeners[$tokenType]['end']) === true) { + $ignore = $oldIgnore; + } + }//end if + }//end if + + if (in_array($tokenType, $tokenizer->scopeOpeners[$currType]['start']) === true + && $opener === null + ) { + if ($tokenType === T_OPEN_CURLY_BRACKET) { + // Make sure this is actually an opener and not a + // string offset (e.g., $var{0}). + for ($x = ($i - 1); $x > 0; $x--) { + if (in_array($tokens[$x]['code'], PHP_CodeSniffer_Tokens::$emptyTokens) === true) { + continue; + } else { + // If the first non-whitespace/comment token is a + // variable or object operator then this is an opener + // for a string offset and not a scope. + if ($tokens[$x]['code'] === T_VARIABLE + || $tokens[$x]['code'] === T_OBJECT_OPERATOR + ) { + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo str_repeat("\t", $depth); + echo '* ignoring curly brace *'.PHP_EOL; + } + + $ignore++; + }//end if + + break; + }//end if + }//end for + }//end if + + if ($ignore === 0) { + // We found the opening scope token for $currType. + if (PHP_CODESNIFFER_VERBOSITY > 1) { + $type = $tokens[$stackPtr]['type']; + echo str_repeat("\t", $depth); + echo "=> Found scope opener for $stackPtr ($type)".PHP_EOL; + } + + $opener = $i; + } + } else if (in_array($tokenType, $tokenizer->scopeOpeners[$currType]['end']) === true + && $opener !== null + ) { + if ($ignore > 0 && $tokenType === T_CLOSE_CURLY_BRACKET) { + // The last opening bracket must have been for a string + // offset or alike, so let's ignore it. + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo str_repeat("\t", $depth); + echo '* finished ignoring curly brace *'.PHP_EOL; + } + + $ignore--; + } else { + if (PHP_CODESNIFFER_VERBOSITY > 1) { + $type = $tokens[$stackPtr]['type']; + echo str_repeat("\t", $depth); + echo "=> Found scope closer for $stackPtr ($type)".PHP_EOL; + } + + foreach (array($stackPtr, $opener, $i) as $token) { + $tokens[$token]['scope_condition'] = $stackPtr; + $tokens[$token]['scope_opener'] = $opener; + $tokens[$token]['scope_closer'] = $i; + } + + if ($tokenizer->scopeOpeners[$tokens[$stackPtr]['code']]['shared'] === true) { + // As we are going back to where we started originally, restore + // the ignore value back to its original value. + $ignore = $originalIgnore; + return $opener; + } else { + return $i; + } + }//end if + } else if ($tokenType === T_OPEN_PARENTHESIS) { + if (isset($tokens[$i]['parenthesis_owner']) === true) { + $owner = $tokens[$i]['parenthesis_owner']; + if (in_array($tokens[$owner]['code'], PHP_CodeSniffer_Tokens::$scopeOpeners) === true + && isset($tokens[$i]['parenthesis_closer']) === true + ) { + // If we get into here, then we opened a parenthesis for + // a scope (eg. an if or else if). We can just skip to + // the closing parenthesis. + $i = $tokens[$i]['parenthesis_closer']; + + // Update the start of the line so that when we check to see + // if the closing parenthesis is more than 3 lines away from + // the statement, we check from the closing parenthesis. + $startLine + = $tokens[$tokens[$i]['parenthesis_closer']]['line']; + + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo str_repeat("\t", $depth); + echo '* skipping parenthesis *'.PHP_EOL; + } + } + }//end if + } else if ($tokenType === T_OPEN_CURLY_BRACKET && $opener !== null) { + // We opened something that we don't have a scope opener for. + // Examples of this are curly brackets for string offsets etc. + // We want to ignore this so that we don't have an invalid scope + // map. + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo str_repeat("\t", $depth); + echo '* ignoring curly brace *'.PHP_EOL; + } + + $ignore++; + } else if ($opener === null + && isset($tokenizer->scopeOpeners[$currType]) === true + ) { + // If we still haven't found the opener after 3 lines, + // we're not going to find it, unless we know it requires + // an opener (in which case we better keep looking) or the last + // token was empty (in which case we'll just confirm there is + // more code in this file and not just a big comment). + if ($tokens[$i]['line'] >= ($startLine + 3) + && in_array($tokens[($i - 1)]['code'], PHP_CodeSniffer_Tokens::$emptyTokens) === false + ) { + if ($tokenizer->scopeOpeners[$currType]['strict'] === true) { + if (PHP_CODESNIFFER_VERBOSITY > 1) { + $type = $tokens[$stackPtr]['type']; + $lines = ($tokens[$i]['line'] - $startLine); + echo str_repeat("\t", $depth); + echo "=> Still looking for $stackPtr ($type) scope opener after $lines lines".PHP_EOL; + } + } else { + if (PHP_CODESNIFFER_VERBOSITY > 1) { + $type = $tokens[$stackPtr]['type']; + echo str_repeat("\t", $depth); + echo "=> Couldn't find scope opener for $stackPtr ($type), bailing".PHP_EOL; + } + + return $stackPtr; + } + } + } else if ($opener !== null + && $tokenType !== T_BREAK + && in_array($tokenType, $tokenizer->endScopeTokens) === true + ) { + if (isset($tokens[$i]['scope_condition']) === false) { + if ($ignore > 0) { + // We found the end token for the opener we were ignoring. + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo str_repeat("\t", $depth); + echo '* finished ignoring curly brace *'.PHP_EOL; + } + + $ignore--; + } else { + // We found a token that closes the scope but it doesn't + // have a condition, so it belongs to another token and + // our token doesn't have a closer, so pretend this is + // the closer. + if (PHP_CODESNIFFER_VERBOSITY > 1) { + $type = $tokens[$stackPtr]['type']; + echo str_repeat("\t", $depth); + echo "=> Found (unexpected) scope closer for $stackPtr ($type)".PHP_EOL; + } + + foreach (array($stackPtr, $opener) as $token) { + $tokens[$token]['scope_condition'] = $stackPtr; + $tokens[$token]['scope_opener'] = $opener; + $tokens[$token]['scope_closer'] = $i; + } + + return ($i - 1); + }//end if + }//end if + }//end if + }//end for + + return $stackPtr; + + }//end _recurseScopeMap() + + + /** + * Constructs the level map. + * + * The level map adds a 'level' indice to each token which indicates the + * depth that a token within a set of scope blocks. It also adds a + * 'condition' indice which is an array of the scope conditions that opened + * each of the scopes - position 0 being the first scope opener. + * + * @param array &$tokens The array of tokens to process. + * @param object $tokenizer The tokenizer being used to process this file. + * @param string $eolChar The EOL character to use for splitting strings. + * + * @return void + */ + private static function _createLevelMap(&$tokens, $tokenizer, $eolChar) + { + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo "\t*** START LEVEL MAP ***".PHP_EOL; + } + + $numTokens = count($tokens); + $level = 0; + $conditions = array(); + $lastOpener = null; + $openers = array(); + + for ($i = 0; $i < $numTokens; $i++) { + if (PHP_CODESNIFFER_VERBOSITY > 1) { + $type = $tokens[$i]['type']; + $line = $tokens[$i]['line']; + $content = str_replace($eolChar, '\n', $tokens[$i]['content']); + echo str_repeat("\t", ($level + 1)); + echo "Process token $i on line $line [lvl:$level;"; + if (empty($conditions) !== true) { + $condString = 'conds;'; + foreach ($conditions as $condition) { + $condString .= token_name($condition).','; + } + + echo rtrim($condString, ',').';'; + } + + echo "]: $type => $content".PHP_EOL; + } + + $tokens[$i]['level'] = $level; + $tokens[$i]['conditions'] = $conditions; + + if (isset($tokens[$i]['scope_condition']) === true) { + // Check to see if this token opened the scope. + if ($tokens[$i]['scope_opener'] === $i) { + $stackPtr = $tokens[$i]['scope_condition']; + if (PHP_CODESNIFFER_VERBOSITY > 1) { + $type = $tokens[$stackPtr]['type']; + echo str_repeat("\t", ($level + 1)); + echo "=> Found scope opener for $stackPtr ($type)".PHP_EOL; + } + + $stackPtr = $tokens[$i]['scope_condition']; + + // If we find a scope opener that has a shared closer, + // then we need to go back over the condition map that we + // just created and fix ourselves as we just added some + // conditions where there was none. This happens for T_CASE + // statements that are using the same break statement. + if ($lastOpener !== null && $tokens[$lastOpener]['scope_closer'] === $tokens[$i]['scope_closer']) { + // This opener shares its closer with the previous opener, + // but we still need to check if the two openers share their + // closer with each other directly (like CASE and DEFAULT) + // or if they are just sharing because one doesn't have a + // closer (like CASE with no BREAK using a SWITCHes closer). + $thisType = $tokens[$tokens[$i]['scope_condition']]['code']; + $opener = $tokens[$lastOpener]['scope_condition']; + + $isShared = in_array( + $tokens[$opener]['code'], + $tokenizer->scopeOpeners[$thisType]['with'] + ); + + $sameEnd = ($tokenizer->scopeOpeners[$thisType]['end'][0] === $tokenizer->scopeOpeners[$tokens[$opener]['code']]['end'][0]); + if ($isShared === true && $sameEnd === true) { + $badToken = $opener; + if (PHP_CODESNIFFER_VERBOSITY > 1) { + $type = $tokens[$badToken]['type']; + echo str_repeat("\t", ($level + 1)); + echo "* shared closer, cleaning up $badToken ($type) *".PHP_EOL; + } + + for ($x = $tokens[$i]['scope_condition']; $x <= $i; $x++) { + $oldConditions = $tokens[$x]['conditions']; + $oldLevel = $tokens[$x]['level']; + $tokens[$x]['level']--; + unset($tokens[$x]['conditions'][$badToken]); + if (PHP_CODESNIFFER_VERBOSITY > 1) { + $type = $tokens[$x]['type']; + $oldConds = ''; + foreach ($oldConditions as $condition) { + $oldConds .= token_name($condition).','; + } + + $oldConds = rtrim($oldConds, ','); + + $newConds = ''; + foreach ($tokens[$x]['conditions'] as $condition) { + $newConds .= token_name($condition).','; + } + + $newConds = rtrim($newConds, ','); + + $newLevel = $tokens[$x]['level']; + echo str_repeat("\t", ($level + 1)); + echo "* cleaned $x ($type) *".PHP_EOL; + echo str_repeat("\t", ($level + 2)); + echo "=> level changed from $oldLevel to $newLevel".PHP_EOL; + echo str_repeat("\t", ($level + 2)); + echo "=> conditions changed from $oldConds to $newConds".PHP_EOL; + }//end if + }//end for + + unset($conditions[$badToken]); + if (PHP_CODESNIFFER_VERBOSITY > 1) { + $type = $tokens[$badToken]['type']; + echo str_repeat("\t", ($level + 1)); + echo "* token $badToken ($type) removed from conditions array *".PHP_EOL; + } + + unset ($openers[$lastOpener]); + + $level--; + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo str_repeat("\t", ($level + 2)); + echo '* level decreased *'.PHP_EOL; + } + }//end if + }//end if + + $level++; + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo str_repeat("\t", ($level + 1)); + echo '* level increased *'.PHP_EOL; + } + + $conditions[$stackPtr] = $tokens[$stackPtr]['code']; + if (PHP_CODESNIFFER_VERBOSITY > 1) { + $type = $tokens[$stackPtr]['type']; + echo str_repeat("\t", ($level + 1)); + echo "* token $stackPtr ($type) added to conditions array *".PHP_EOL; + } + + $lastOpener = $tokens[$i]['scope_opener']; + if ($lastOpener !== null) { + $openers[$lastOpener] = $lastOpener; + } + } else if ($tokens[$i]['scope_closer'] === $i) { + foreach (array_reverse($openers) as $opener) { + if ($tokens[$opener]['scope_closer'] === $i) { + $oldOpener = array_pop($openers); + if (empty($openers) === false) { + $lastOpener = array_pop($openers); + $openers[$lastOpener] = $lastOpener; + } else { + $lastOpener = null; + } + + if (PHP_CODESNIFFER_VERBOSITY > 1) { + $type = $tokens[$oldOpener]['type']; + echo str_repeat("\t", ($level + 1)); + echo "=> Found scope closer for $oldOpener ($type)".PHP_EOL; + } + + $oldCondition = array_pop($conditions); + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo str_repeat("\t", ($level + 1)); + echo '* token '.token_name($oldCondition).' removed from conditions array *'.PHP_EOL; + } + + // Make sure this closer actually belongs to us. + // Either the condition also has to think this is the + // closer, or it has to allow sharing with us. + $condition + = $tokens[$tokens[$i]['scope_condition']]['code']; + if ($condition !== $oldCondition) { + if (in_array($condition, $tokenizer->scopeOpeners[$oldCondition]['with']) === false) { + $badToken = $tokens[$oldOpener]['scope_condition']; + + if (PHP_CODESNIFFER_VERBOSITY > 1) { + $type = token_name($oldCondition); + echo str_repeat("\t", ($level + 1)); + echo "* scope closer was bad, cleaning up $badToken ($type) *".PHP_EOL; + } + + for ($x = ($oldOpener + 1); $x <= $i; $x++) { + $oldConditions = $tokens[$x]['conditions']; + $oldLevel = $tokens[$x]['level']; + $tokens[$x]['level']--; + unset($tokens[$x]['conditions'][$badToken]); + if (PHP_CODESNIFFER_VERBOSITY > 1) { + $type = $tokens[$x]['type']; + $oldConds = ''; + foreach ($oldConditions as $condition) { + $oldConds .= token_name($condition).','; + } + + $oldConds = rtrim($oldConds, ','); + + $newConds = ''; + foreach ($tokens[$x]['conditions'] as $condition) { + $newConds .= token_name($condition).','; + } + + $newConds = rtrim($newConds, ','); + + $newLevel = $tokens[$x]['level']; + echo str_repeat("\t", ($level + 1)); + echo "* cleaned $x ($type) *".PHP_EOL; + echo str_repeat("\t", ($level + 2)); + echo "=> level changed from $oldLevel to $newLevel".PHP_EOL; + echo str_repeat("\t", ($level + 2)); + echo "=> conditions changed from $oldConds to $newConds".PHP_EOL; + }//end if + }//end for + }//end if + }//end if + + $level--; + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo str_repeat("\t", ($level + 2)); + echo '* level decreased *'.PHP_EOL; + } + + $tokens[$i]['level'] = $level; + $tokens[$i]['conditions'] = $conditions; + }//end if + }//end foreach + }//end if + }//end if + }//end for + + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo "\t*** END LEVEL MAP ***".PHP_EOL; + } + + }//end _createLevelMap() + + + /** + * Returns the declaration names for T_CLASS, T_INTERFACE and T_FUNCTION tokens. + * + * @param int $stackPtr The position of the declaration token which + * declared the class, interface or function. + * + * @return string|null The name of the class, interface or function. + * or NULL if the function is a closure. + * @throws PHP_CodeSniffer_Exception If the specified token is not of type + * T_FUNCTION, T_CLASS or T_INTERFACE. + */ + public function getDeclarationName($stackPtr) + { + $tokenCode = $this->_tokens[$stackPtr]['code']; + if ($tokenCode !== T_FUNCTION + && $tokenCode !== T_CLASS + && $tokenCode !== T_INTERFACE + && $tokenCode !== T_TRAIT + ) { + throw new PHP_CodeSniffer_Exception('Token type is not T_FUNCTION, T_CLASS, T_INTERFACE or T_TRAIT'); + } + + if ($tokenCode === T_FUNCTION + && $this->isAnonymousFunction($stackPtr) === true + ) { + return null; + } + + $token = $this->findNext(T_STRING, $stackPtr); + return $this->_tokens[$token]['content']; + + }//end getDeclarationName() + + + /** + * Check if the token at the specified position is a anonymous function. + * + * @param int $stackPtr The position of the declaration token which + * declared the class, interface or function. + * + * @return boolean + * @throws PHP_CodeSniffer_Exception If the specified token is not of type + * T_FUNCTION + */ + public function isAnonymousFunction($stackPtr) + { + $tokenCode = $this->_tokens[$stackPtr]['code']; + if ($tokenCode !== T_FUNCTION) { + throw new PHP_CodeSniffer_Exception('Token type is not T_FUNCTION'); + } + + if (isset($this->_tokens[$stackPtr]['parenthesis_opener']) === false) { + // Something is not right with this function. + return false; + } + + $name = $this->findNext(T_STRING, ($stackPtr + 1)); + if ($name === false) { + // No name found. + return true; + } + + $open = $this->_tokens[$stackPtr]['parenthesis_opener']; + if ($name > $open) { + return true; + } + + return false; + + }//end isAnonymousFunction() + + + /** + * Returns the method parameters for the specified T_FUNCTION token. + * + * Each parameter is in the following format: + * + * + * 0 => array( + * 'name' => '$var', // The variable name. + * 'pass_by_reference' => false, // Passed by reference. + * 'type_hint' => string, // Type hint for array or custom type + * ) + * + * + * Parameters with default values have and additional array indice of + * 'default' with the value of the default as a string. + * + * @param int $stackPtr The position in the stack of the T_FUNCTION token + * to acquire the parameters for. + * + * @return array() + * @throws PHP_CodeSniffer_Exception If the specified $stackPtr is not of + * type T_FUNCTION. + */ + public function getMethodParameters($stackPtr) + { + if ($this->_tokens[$stackPtr]['code'] !== T_FUNCTION) { + throw new PHP_CodeSniffer_Exception('$stackPtr must be of type T_FUNCTION'); + } + + $opener = $this->_tokens[$stackPtr]['parenthesis_opener']; + $closer = $this->_tokens[$stackPtr]['parenthesis_closer']; + + $vars = array(); + $currVar = null; + $defaultStart = null; + $paramCount = 0; + $passByReference = false; + $typeHint = ''; + + for ($i = ($opener + 1); $i <= $closer; $i++) { + // Check to see if this token has a parenthesis opener. If it does + // its likely to be an array, which might have arguments in it, which + // we cause problems in our parsing below, so lets just skip to the + // end of it. + if (isset($this->_tokens[$i]['parenthesis_opener']) === true) { + // Don't do this if it's the close parenthesis for the method. + if ($i !== $this->_tokens[$i]['parenthesis_closer']) { + $i = ($this->_tokens[$i]['parenthesis_closer'] + 1); + } + } + + switch ($this->_tokens[$i]['code']) { + case T_BITWISE_AND: + $passByReference = true; + break; + case T_VARIABLE: + $currVar = $i; + break; + case T_ARRAY_HINT: + $typeHint = $this->_tokens[$i]['content']; + break; + case T_STRING: + // This is a string, so it may be a type hint, but it could + // also be a constant used as a default value. + $prevComma = $this->findPrevious(T_COMMA, $i, $opener); + if ($prevComma !== false) { + $nextEquals = $this->findNext(T_EQUAL, $prevComma, $i); + if ($nextEquals !== false) { + break; + } + } + + if ($defaultStart === null) { + $typeHint .= $this->_tokens[$i]['content']; + } + + break; + case T_NS_SEPARATOR: + // Part of a type hint or default value. + if ($defaultStart === null) { + $typeHint .= $this->_tokens[$i]['content']; + } + + break; + case T_CLOSE_PARENTHESIS: + case T_COMMA: + // If it's null, then there must be no parameters for this + // method. + if ($currVar === null) { + continue; + } + + $vars[$paramCount] = array(); + $vars[$paramCount]['name'] = $this->_tokens[$currVar]['content']; + + if ($defaultStart !== null) { + $vars[$paramCount]['default'] + = $this->getTokensAsString( + $defaultStart, + ($i - $defaultStart) + ); + } + + $vars[$paramCount]['pass_by_reference'] = $passByReference; + $vars[$paramCount]['type_hint'] = $typeHint; + + // Reset the vars, as we are about to process the next parameter. + $defaultStart = null; + $passByReference = false; + $typeHint = ''; + + $paramCount++; + break; + case T_EQUAL: + $defaultStart = ($i + 1); + break; + }//end switch + }//end for + + return $vars; + + }//end getMethodParameters() + + + /** + * Returns the visibility and implementation properties of a method. + * + * The format of the array is: + * + * array( + * 'scope' => 'public', // public private or protected + * 'scope_specified' => true, // true is scope keyword was found. + * 'is_abstract' => false, // true if the abstract keyword was found. + * 'is_final' => false, // true if the final keyword was found. + * 'is_static' => false, // true if the static keyword was found. + * 'is_closure' => false, // true if no name is found. + * ); + * + * + * @param int $stackPtr The position in the stack of the T_FUNCTION token to + * acquire the properties for. + * + * @return array + * @throws PHP_CodeSniffer_Exception If the specified position is not a + * T_FUNCTION token. + */ + public function getMethodProperties($stackPtr) + { + if ($this->_tokens[$stackPtr]['code'] !== T_FUNCTION) { + throw new PHP_CodeSniffer_Exception('$stackPtr must be of type T_FUNCTION'); + } + + $valid = array( + T_PUBLIC, + T_PRIVATE, + T_PROTECTED, + T_STATIC, + T_FINAL, + T_ABSTRACT, + T_WHITESPACE, + T_COMMENT, + T_DOC_COMMENT, + ); + + $scope = 'public'; + $scopeSpecified = false; + $isAbstract = false; + $isFinal = false; + $isStatic = false; + $isClosure = $this->isAnonymousFunction($stackPtr); + + for ($i = ($stackPtr - 1); $i > 0; $i--) { + if (in_array($this->_tokens[$i]['code'], $valid) === false) { + break; + } + + switch ($this->_tokens[$i]['code']) { + case T_PUBLIC: + $scope = 'public'; + $scopeSpecified = true; + break; + case T_PRIVATE: + $scope = 'private'; + $scopeSpecified = true; + break; + case T_PROTECTED: + $scope = 'protected'; + $scopeSpecified = true; + break; + case T_ABSTRACT: + $isAbstract = true; + break; + case T_FINAL: + $isFinal = true; + break; + case T_STATIC: + $isStatic = true; + break; + }//end switch + }//end for + + return array( + 'scope' => $scope, + 'scope_specified' => $scopeSpecified, + 'is_abstract' => $isAbstract, + 'is_final' => $isFinal, + 'is_static' => $isStatic, + 'is_closure' => $isClosure, + ); + + }//end getMethodProperties() + + + /** + * Returns the visibility and implementation properties of the class member + * variable found at the specified position in the stack. + * + * The format of the array is: + * + * + * array( + * 'scope' => 'public', // public private or protected + * 'is_static' => false, // true if the static keyword was found. + * ); + * + * + * @param int $stackPtr The position in the stack of the T_VARIABLE token to + * acquire the properties for. + * + * @return array + * @throws PHP_CodeSniffer_Exception If the specified position is not a + * T_VARIABLE token, or if the position is not + * a class member variable. + */ + public function getMemberProperties($stackPtr) + { + if ($this->_tokens[$stackPtr]['code'] !== T_VARIABLE) { + throw new PHP_CodeSniffer_Exception('$stackPtr must be of type T_VARIABLE'); + } + + $conditions = array_keys($this->_tokens[$stackPtr]['conditions']); + $ptr = array_pop($conditions); + if (isset($this->_tokens[$ptr]) === false + || $this->_tokens[$ptr]['code'] !== T_CLASS + ) { + if (isset($this->_tokens[$ptr]) === true + && $this->_tokens[$ptr]['code'] === T_INTERFACE + ) { + // T_VARIABLEs in interfaces can actually be method arguments + // but they wont be seen as being inside the method because there + // are no scope openers and closers for abstract methods. If it is in + // parentheses, we can be pretty sure it is a method argument. + if (isset($this->_tokens[$stackPtr]['nested_parenthesis']) === false + || empty($this->_tokens[$stackPtr]['nested_parenthesis']) === true + ) { + $error = 'Possible parse error: interfaces may not include member vars'; + $this->addWarning($error, $stackPtr, 'Internal.ParseError.InterfaceHasMemberVar'); + return array(); + } + } else { + throw new PHP_CodeSniffer_Exception('$stackPtr is not a class member var'); + } + } + + $valid = array( + T_PUBLIC, + T_PRIVATE, + T_PROTECTED, + T_STATIC, + T_WHITESPACE, + T_COMMENT, + T_DOC_COMMENT, + T_VARIABLE, + T_COMMA, + ); + + $scope = 'public'; + $scopeSpecified = false; + $isStatic = false; + + for ($i = ($stackPtr - 1); $i > 0; $i--) { + if (in_array($this->_tokens[$i]['code'], $valid) === false) { + break; + } + + switch ($this->_tokens[$i]['code']) { + case T_PUBLIC: + $scope = 'public'; + $scopeSpecified = true; + break; + case T_PRIVATE: + $scope = 'private'; + $scopeSpecified = true; + break; + case T_PROTECTED: + $scope = 'protected'; + $scopeSpecified = true; + break; + case T_STATIC: + $isStatic = true; + break; + } + }//end for + + return array( + 'scope' => $scope, + 'scope_specified' => $scopeSpecified, + 'is_static' => $isStatic, + ); + + }//end getMemberProperties() + + + /** + * Returns the visibility and implementation properties of a class. + * + * The format of the array is: + * + * array( + * 'is_abstract' => false, // true if the abstract keyword was found. + * 'is_final' => false, // true if the final keyword was found. + * ); + * + * + * @param int $stackPtr The position in the stack of the T_CLASS token to + * acquire the properties for. + * + * @return array + * @throws PHP_CodeSniffer_Exception If the specified position is not a + * T_CLASS token. + */ + public function getClassProperties($stackPtr) + { + if ($this->_tokens[$stackPtr]['code'] !== T_CLASS) { + throw new PHP_CodeSniffer_Exception('$stackPtr must be of type T_CLASS'); + } + + $valid = array( + T_FINAL, + T_ABSTRACT, + T_WHITESPACE, + T_COMMENT, + T_DOC_COMMENT, + ); + + $isAbstract = false; + $isFinal = false; + + for ($i = ($stackPtr - 1); $i > 0; $i--) { + if (in_array($this->_tokens[$i]['code'], $valid) === false) { + break; + } + + switch ($this->_tokens[$i]['code']) { + case T_ABSTRACT: + $isAbstract = true; + break; + + case T_FINAL: + $isFinal = true; + break; + } + }//end for + + return array( + 'is_abstract' => $isAbstract, + 'is_final' => $isFinal, + ); + + }//end getClassProperties() + + + /** + * Determine if the passed token is a reference operator. + * + * Returns true if the specified token position represents a reference. + * Returns false if the token represents a bitwise operator. + * + * @param int $stackPtr The position of the T_BITWISE_AND token. + * + * @return boolean + */ + public function isReference($stackPtr) + { + if ($this->_tokens[$stackPtr]['code'] !== T_BITWISE_AND) { + return false; + } + + $tokenBefore = $this->findPrevious( + PHP_CodeSniffer_Tokens::$emptyTokens, + ($stackPtr - 1), + null, + true + ); + + if ($this->_tokens[$tokenBefore]['code'] === T_FUNCTION) { + // Function returns a reference. + return true; + } + + if ($this->_tokens[$tokenBefore]['code'] === T_DOUBLE_ARROW) { + // Inside a foreach loop, this is a reference. + return true; + } + + if ($this->_tokens[$tokenBefore]['code'] === T_AS) { + // Inside a foreach loop, this is a reference. + return true; + } + + if (in_array($this->_tokens[$tokenBefore]['code'], PHP_CodeSniffer_Tokens::$assignmentTokens) === true) { + // This is directly after an assignment. It's a reference. Even if + // it is part of an operation, the other tests will handle it. + return true; + } + + if (isset($this->_tokens[$stackPtr]['nested_parenthesis']) === true) { + $brackets = $this->_tokens[$stackPtr]['nested_parenthesis']; + $lastBracket = array_pop($brackets); + if (isset($this->_tokens[$lastBracket]['parenthesis_owner']) === true) { + $owner = $this->_tokens[$this->_tokens[$lastBracket]['parenthesis_owner']]; + if ($owner['code'] === T_FUNCTION + || $owner['code'] === T_CLOSURE + || $owner['code'] === T_ARRAY + ) { + // Inside a function or array declaration, this is a reference. + return true; + } + } else { + $prev = $this->findPrevious( + array(T_WHITESPACE), + ($this->_tokens[$lastBracket]['parenthesis_opener'] - 1), + null, + true + ); + + if ($prev !== false && $this->_tokens[$prev]['code'] === T_USE) { + return true; + } + } + } + + $tokenAfter = $this->findNext( + PHP_CodeSniffer_Tokens::$emptyTokens, + ($stackPtr + 1), + null, + true + ); + + if ($this->_tokens[$tokenAfter]['code'] === T_VARIABLE + && ($this->_tokens[$tokenBefore]['code'] === T_OPEN_PARENTHESIS + || $this->_tokens[$tokenBefore]['code'] === T_COMMA) + ) { + return true; + } + + return false; + + }//end isReference() + + + /** + * Returns the content of the tokens from the specified start position in + * the token stack for the specified length. + * + * @param int $start The position to start from in the token stack. + * @param int $length The length of tokens to traverse from the start pos. + * + * @return string The token contents. + */ + public function getTokensAsString($start, $length) + { + $str = ''; + $end = ($start + $length); + if ($end > $this->numTokens) { + $end = $this->numTokens; + } + + for ($i = $start; $i < $end; $i++) { + $str .= $this->_tokens[$i]['content']; + } + + return $str; + + }//end getTokensAsString() + + + /** + * Returns the position of the next specified token(s). + * + * If a value is specified, the next token of the specified type(s) + * containing the specified value will be returned. + * + * Returns false if no token can be found. + * + * @param int|array $types The type(s) of tokens to search for. + * @param int $start The position to start searching from in the + * token stack. + * @param int $end The end position to fail if no token is found. + * if not specified or null, end will default to + * the start of the token stack. + * @param bool $exclude If true, find the next token that are NOT of + * the types specified in $types. + * @param string $value The value that the token(s) must be equal to. + * If value is omitted, tokens with any value will + * be returned. + * @param bool $local If true, tokens outside the current statement + * will not be checked. IE. checking will stop + * at the next semi-colon found. + * + * @return int | bool + * @see findNext() + */ + public function findPrevious( + $types, + $start, + $end=null, + $exclude=false, + $value=null, + $local=false + ) { + $types = (array) $types; + + if ($end === null) { + $end = 0; + } + + for ($i = $start; $i >= $end; $i--) { + $found = (bool) $exclude; + foreach ($types as $type) { + if ($this->_tokens[$i]['code'] === $type) { + $found = !$exclude; + break; + } + } + + if ($found === true) { + if ($value === null) { + return $i; + } else if ($this->_tokens[$i]['content'] === $value) { + return $i; + } + } + + if ($local === true && $this->_tokens[$i]['code'] === T_SEMICOLON) { + break; + } + }//end for + + return false; + + }//end findPrevious() + + + /** + * Returns the position of the next specified token(s). + * + * If a value is specified, the next token of the specified type(s) + * containing the specified value will be returned. + * + * Returns false if no token can be found. + * + * @param int|array $types The type(s) of tokens to search for. + * @param int $start The position to start searching from in the + * token stack. + * @param int $end The end position to fail if no token is found. + * if not specified or null, end will default to + * the end of the token stack. + * @param bool $exclude If true, find the next token that is NOT of + * a type specified in $types. + * @param string $value The value that the token(s) must be equal to. + * If value is omitted, tokens with any value will + * be returned. + * @param bool $local If true, tokens outside the current statement + * will not be checked. i.e., checking will stop + * at the next semi-colon found. + * + * @return int | bool + * @see findPrevious() + */ + public function findNext( + $types, + $start, + $end=null, + $exclude=false, + $value=null, + $local=false + ) { + $types = (array) $types; + + if ($end === null || $end > $this->numTokens) { + $end = $this->numTokens; + } + + for ($i = $start; $i < $end; $i++) { + $found = (bool) $exclude; + foreach ($types as $type) { + if ($this->_tokens[$i]['code'] === $type) { + $found = !$exclude; + break; + } + } + + if ($found === true) { + if ($value === null) { + return $i; + } else if ($this->_tokens[$i]['content'] === $value) { + return $i; + } + } + + if ($local === true && $this->_tokens[$i]['code'] === T_SEMICOLON) { + break; + } + }//end for + + return false; + + }//end findNext() + + + /** + * Returns the position of the first token on a line, matching given type. + * + * Returns false if no token can be found. + * + * @param int|array $types The type(s) of tokens to search for. + * @param int $start The position to start searching from in the + * token stack. The first token matching on + * this line before this token will be returned. + * @param bool $exclude If true, find the token that is NOT of + * the types specified in $types. + * @param string $value The value that the token must be equal to. + * If value is omitted, tokens with any value will + * be returned. + * + * @return int | bool + */ + public function findFirstOnLine($types, $start, $exclude=false, $value=null) + { + if (is_array($types) === false) { + $types = array($types); + } + + $foundToken = false; + + for ($i = $start; $i >= 0; $i--) { + if ($this->_tokens[$i]['line'] < $this->_tokens[$start]['line']) { + break; + } + + $found = $exclude; + foreach ($types as $type) { + if ($exclude === false) { + if ($this->_tokens[$i]['code'] === $type) { + $found = true; + break; + } + } else { + if ($this->_tokens[$i]['code'] === $type) { + $found = false; + break; + } + } + } + + if ($found === true) { + if ($value === null) { + $foundToken = $i; + } else if ($this->_tokens[$i]['content'] === $value) { + $foundToken = $i; + } + } + }//end for + + return $foundToken; + + }//end findFirstOnLine() + + + /** + * Determine if the passed token has a condition of one of the passed types. + * + * @param int $stackPtr The position of the token we are checking. + * @param int|array $types The type(s) of tokens to search for. + * + * @return boolean + */ + public function hasCondition($stackPtr, $types) + { + // Check for the existence of the token. + if (isset($this->_tokens[$stackPtr]) === false) { + return false; + } + + // Make sure the token has conditions. + if (isset($this->_tokens[$stackPtr]['conditions']) === false) { + return false; + } + + $types = (array) $types; + $conditions = $this->_tokens[$stackPtr]['conditions']; + + foreach ($types as $type) { + if (in_array($type, $conditions) === true) { + // We found a token with the required type. + return true; + } + } + + return false; + + }//end hasCondition() + + + /** + * Return the position of the condition for the passed token. + * + * Returns FALSE if the token does not have the condition. + * + * @param int $stackPtr The position of the token we are checking. + * @param int $type The type of token to search for. + * + * @return int + */ + public function getCondition($stackPtr, $type) + { + // Check for the existence of the token. + if (isset($this->_tokens[$stackPtr]) === false) { + return false; + } + + // Make sure the token has conditions. + if (isset($this->_tokens[$stackPtr]['conditions']) === false) { + return false; + } + + $conditions = $this->_tokens[$stackPtr]['conditions']; + foreach ($conditions as $token => $condition) { + if ($condition === $type) { + return $token; + } + } + + return false; + + }//end getCondition() + + + /** + * Returns the name of the class that the specified class extends. + * + * Returns FALSE on error or if there is no extended class name. + * + * @param int $stackPtr The stack position of the class. + * + * @return string + */ + public function findExtendedClassName($stackPtr) + { + // Check for the existence of the token. + if (isset($this->_tokens[$stackPtr]) === false) { + return false; + } + + if ($this->_tokens[$stackPtr]['code'] !== T_CLASS) { + return false; + } + + if (isset($this->_tokens[$stackPtr]['scope_closer']) === false) { + return false; + } + + $classCloserIndex = $this->_tokens[$stackPtr]['scope_closer']; + $extendsIndex = $this->findNext(T_EXTENDS, $stackPtr, $classCloserIndex); + if (false === $extendsIndex) { + return false; + } + + $find = array( + T_NS_SEPARATOR, + T_STRING, + T_WHITESPACE, + ); + + $end = $this->findNext($find, ($extendsIndex + 1), $classCloserIndex, true); + $name = $this->getTokensAsString(($extendsIndex + 1), ($end - $extendsIndex - 1)); + $name = trim($name); + + if ($name === '') { + return false; + } + + return $name; + + }//end findExtendedClassName() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/MultiFileSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/MultiFileSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/MultiFileSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/MultiFileSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,47 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Represents a PHP_CodeSniffer multi-file sniff for sniffing coding standards. + * + * A multi-file sniff is called after all files have been checked using the + * regular sniffs. The process() method is passed an array of PHP_CodeSniffer_File + * objects, one for each file checked during the script run. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +interface PHP_CodeSniffer_MultiFileSniff +{ + + + /** + * Called once per script run to allow for processing of this sniff. + * + * @param array(PHP_CodeSniffer_File) $files The PHP_CodeSniffer files processed + * during the script run. + * + * @return void + */ + public function process(array $files); + + +}//end interface + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Report.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Report.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Report.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Report.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,81 @@ + + * @author Greg Sherwood + * @copyright 2009 SQLI + * @copyright 2006-2012 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 + */ + +/** + * Represents a PHP_CodeSniffer report. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Gabriele Santini + * @author Greg Sherwood + * @copyright 2009 SQLI + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +interface PHP_CodeSniffer_Report +{ + + + /** + * Generate a partial report for a single processed file. + * + * Function should return TRUE if it printed or stored data about the file + * and FALSE if it ignored the file. Returning TRUE indicates that the file and + * its data should be counted in the grand totals. + * + * @param array $report Prepared report data. + * @param boolean $showSources Show sources? + * @param int $width Maximum allowed line width. + * + * @return boolean + */ + public function generateFileReport( + $report, + $showSources=false, + $width=80 + ); + + + /** + * Generate the actual report. + * + * @param string $cachedData Any partial report data that was returned from + * generateFileReport during the run. + * @param int $totalFiles Total number of files processed during the run. + * @param int $totalErrors Total number of errors found during the run. + * @param int $totalWarnings Total number of warnings found during the run. + * @param boolean $showSources Show sources? + * @param int $width Maximum allowed line width. + * @param boolean $toScreen Is the report being printed to screen? + * + * @return void + */ + public function generate( + $cachedData, + $totalFiles, + $totalErrors, + $totalWarnings, + $showSources=false, + $width=80, + $toScreen=true + ); + + +}//end interface + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Reporting.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Reporting.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Reporting.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Reporting.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,311 @@ + + * @author Greg Sherwood + * @copyright 2009 SQLI + * @copyright 2006-2012 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 + */ + +if (is_file(dirname(__FILE__).'/../CodeSniffer.php') === true) { + include_once dirname(__FILE__).'/../CodeSniffer.php'; +} else { + include_once 'PHP/CodeSniffer.php'; +} + +/** + * A class to manage reporting. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Gabriele Santini + * @author Greg Sherwood + * @copyright 2009 SQLI + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PHP_CodeSniffer_Reporting +{ + + /** + * Total number of files that contain errors or warnings. + * + * @var int + */ + public $totalFiles = 0; + + /** + * Total number of errors found during the run. + * + * @var int + */ + public $totalErrors = 0; + + /** + * Total number of warnings found during the run. + * + * @var int + */ + public $totalWarnings = 0; + + /** + * A list of reports that have written partial report output. + * + * @var array + */ + private $_cachedReports = array(); + + /** + * A cache of report objects. + * + * @var array + */ + private $_reports = array(); + + + /** + * Produce the appropriate report object based on $type parameter. + * + * @param string $type The type of the report. + * + * @return PHP_CodeSniffer_Report + * @throws PHP_CodeSniffer_Exception If report is not available. + */ + public function factory($type) + { + $type = ucfirst($type); + if (isset($this->_reports[$type]) === true) { + return $this->_reports[$type]; + } + + $filename = $type.'.php'; + $reportClassName = 'PHP_CodeSniffer_Reports_'.$type; + if (class_exists($reportClassName, true) === false) { + throw new PHP_CodeSniffer_Exception('Report type "'.$type.'" not found.'); + } + + $reportClass = new $reportClassName(); + if (false === ($reportClass instanceof PHP_CodeSniffer_Report)) { + throw new PHP_CodeSniffer_Exception('Class "'.$reportClassName.'" must implement the "PHP_CodeSniffer_Report" interface.'); + } + + $this->_reports[$type] = $reportClass; + return $this->_reports[$type]; + + }//end factory() + + + /** + * Actually generates the report. + * + * @param PHP_CodeSniffer_File $phpcsFile The file that has been processed. + * @param array $cliValues An array of command line arguments. + * + * @return void + */ + public function cacheFileReport(PHP_CodeSniffer_File $phpcsFile, array $cliValues) + { + if (isset($cliValues['reports']) === false) { + // This happens during unit testing, or any time someone just wants + // the error data and not the printed report. + return; + } + + $reportData = $this->prepareFileReport($phpcsFile); + $errorsShown = false; + + foreach ($cliValues['reports'] as $report => $output) { + $reportClass = self::factory($report); + + ob_start(); + $result = $reportClass->generateFileReport($reportData, $cliValues['showSources'], $cliValues['reportWidth']); + if ($result === true) { + $errorsShown = true; + } + + $generatedReport = ob_get_contents(); + ob_end_clean(); + + if ($generatedReport !== '') { + $flags = FILE_APPEND; + if (in_array($report, $this->_cachedReports) === false) { + $this->_cachedReports[] = $report; + $flags = null; + } + + if ($output === null) { + $output = getcwd().'/phpcs-'.$report.'.tmp'; + } + + file_put_contents($output, $generatedReport, $flags); + } + }//end foreach + + if ($errorsShown === true) { + $this->totalFiles++; + $this->totalErrors += $reportData['errors']; + $this->totalWarnings += $reportData['warnings']; + } + + }//end cacheFileReport() + + + /** + * Actually generates the report. + * + * @param string $report Report type. + * @param boolean $showSources Show sources? + * @param string $reportFile Report file to generate. + * @param integer $reportWidth Report max width. + * + * @return integer + */ + public function printReport( + $report, + $showSources, + $reportFile='', + $reportWidth=80 + ) { + if ($this->totalFiles === 0) { + // No files generated errors. + return 0; + } + + $reportClass = self::factory($report); + + if ($reportFile !== null) { + $filename = $reportFile; + $toScreen = false; + ob_start(); + } else { + $filename = getcwd().'/phpcs-'.$report.'.tmp'; + $toScreen = true; + } + + if (file_exists($filename) === true) { + $reportCache = file_get_contents($filename); + } else { + $reportCache = ''; + } + + $reportClass->generate( + $reportCache, + $this->totalFiles, + $this->totalErrors, + $this->totalWarnings, + $showSources, + $reportWidth, + $toScreen + ); + + if ($reportFile !== null) { + $generatedReport = ob_get_contents(); + ob_end_clean(); + + if (PHP_CODESNIFFER_VERBOSITY > 0) { + echo $generatedReport; + } + + $generatedReport = trim($generatedReport); + file_put_contents($reportFile, $generatedReport.PHP_EOL); + } else if (file_exists($filename) === true) { + unlink($filename); + } + + return ($this->totalErrors + $this->totalWarnings); + + }//end printReport() + + + /** + * Pre-process and package violations for all files. + * + * Used by error reports to get a packaged list of all errors in each file. + * + * @param PHP_CodeSniffer_File $phpcsFile The file that has been processed. + * + * @return array + */ + public function prepareFileReport(PHP_CodeSniffer_File $phpcsFile) + { + $report = array( + 'filename' => $phpcsFile->getFilename(), + 'errors' => $phpcsFile->getErrorCount(), + 'warnings' => $phpcsFile->getWarningCount(), + 'messages' => array(), + ); + + if ($report['errors'] === 0 && $report['warnings'] === 0) { + // Prefect score! + return $report; + } + + $errors = array(); + + // Merge errors and warnings. + foreach ($phpcsFile->getErrors() as $line => $lineErrors) { + foreach ($lineErrors as $column => $colErrors) { + $newErrors = array(); + foreach ($colErrors as $data) { + $newErrors[] = array( + 'message' => $data['message'], + 'source' => $data['source'], + 'severity' => $data['severity'], + 'type' => 'ERROR', + ); + } + + $errors[$line][$column] = $newErrors; + }//end foreach + + ksort($errors[$line]); + }//end foreach + + foreach ($phpcsFile->getWarnings() as $line => $lineWarnings) { + foreach ($lineWarnings as $column => $colWarnings) { + $newWarnings = array(); + foreach ($colWarnings as $data) { + $newWarnings[] = array( + 'message' => $data['message'], + 'source' => $data['source'], + 'severity' => $data['severity'], + 'type' => 'WARNING', + ); + } + + if (isset($errors[$line]) === false) { + $errors[$line] = array(); + } + + if (isset($errors[$line][$column]) === true) { + $errors[$line][$column] = array_merge( + $newWarnings, + $errors[$line][$column] + ); + } else { + $errors[$line][$column] = $newWarnings; + } + }//end foreach + + ksort($errors[$line]); + }//end foreach + + ksort($errors); + $report['messages'] = $errors; + return $report; + + }//end prepareFileReport() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Reports/Checkstyle.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Reports/Checkstyle.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Reports/Checkstyle.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Reports/Checkstyle.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,126 @@ + + * @author Greg Sherwood + * @copyright 2009 SQLI + * @copyright 2006-2012 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 + */ + +/** + * Checkstyle report for PHP_CodeSniffer. + * + * PHP version 5 + * + * @category PHP + * @package PHP_CodeSniffer + * @author Gabriele Santini + * @author Greg Sherwood + * @copyright 2009 SQLI + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PHP_CodeSniffer_Reports_Checkstyle implements PHP_CodeSniffer_Report +{ + + + /** + * Generate a partial report for a single processed file. + * + * Function should return TRUE if it printed or stored data about the file + * and FALSE if it ignored the file. Returning TRUE indicates that the file and + * its data should be counted in the grand totals. + * + * @param array $report Prepared report data. + * @param boolean $showSources Show sources? + * @param int $width Maximum allowed line width. + * + * @return boolean + */ + public function generateFileReport( + $report, + $showSources=false, + $width=80 + ) { + $out = new XMLWriter; + $out->openMemory(); + $out->setIndent(true); + + if ($report['errors'] === 0 && $report['warnings'] === 0) { + // Nothing to print. + return false; + } + + $out->startElement('file'); + $out->writeAttribute('name', $report['filename']); + + foreach ($report['messages'] as $line => $lineErrors) { + foreach ($lineErrors as $column => $colErrors) { + foreach ($colErrors as $error) { + $error['type'] = strtolower($error['type']); + if (PHP_CODESNIFFER_ENCODING !== 'utf-8') { + $error['message'] = iconv(PHP_CODESNIFFER_ENCODING, 'utf-8', $error['message']); + } + + $out->startElement('error'); + $out->writeAttribute('line', $line); + $out->writeAttribute('column', $column); + $out->writeAttribute('severity', $error['type']); + $out->writeAttribute('message', $error['message']); + $out->writeAttribute('source', $error['source']); + $out->endElement(); + } + } + }//end foreach + + $out->endElement(); + echo $out->flush(); + + return true; + + }//end generateFileReport() + + + /** + * Prints all violations for processed files, in a Checkstyle format. + * + * @param string $cachedData Any partial report data that was returned from + * generateFileReport during the run. + * @param int $totalFiles Total number of files processed during the run. + * @param int $totalErrors Total number of errors found during the run. + * @param int $totalWarnings Total number of warnings found during the run. + * @param boolean $showSources Show sources? + * @param int $width Maximum allowed line width. + * @param boolean $toScreen Is the report being printed to screen? + * + * @return void + */ + public function generate( + $cachedData, + $totalFiles, + $totalErrors, + $totalWarnings, + $showSources=false, + $width=80, + $toScreen=true + ) { + echo ''.PHP_EOL; + echo ''.PHP_EOL; + echo $cachedData; + echo ''.PHP_EOL; + + }//end generate() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Reports/Csv.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Reports/Csv.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Reports/Csv.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Reports/Csv.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,108 @@ + + * @author Greg Sherwood + * @copyright 2009 SQLI + * @copyright 2006-2012 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 + */ + +/** + * Csv report for PHP_CodeSniffer. + * + * PHP version 5 + * + * @category PHP + * @package PHP_CodeSniffer + * @author Gabriele Santini + * @author Greg Sherwood + * @copyright 2009 SQLI + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PHP_CodeSniffer_Reports_Csv implements PHP_CodeSniffer_Report +{ + + + /** + * Generate a partial report for a single processed file. + * + * Function should return TRUE if it printed or stored data about the file + * and FALSE if it ignored the file. Returning TRUE indicates that the file and + * its data should be counted in the grand totals. + * + * @param array $report Prepared report data. + * @param boolean $showSources Show sources? + * @param int $width Maximum allowed line width. + * + * @return boolean + */ + public function generateFileReport( + $report, + $showSources=false, + $width=80 + ) { + if ($report['errors'] === 0 && $report['warnings'] === 0) { + // Nothing to print. + return false; + } + + foreach ($report['messages'] as $line => $lineErrors) { + foreach ($lineErrors as $column => $colErrors) { + foreach ($colErrors as $error) { + $filename = str_replace('"', '\"', $report['filename']); + $message = str_replace('"', '\"', $error['message']); + $type = strtolower($error['type']); + $source = $error['source']; + $severity = $error['severity']; + echo "\"$filename\",$line,$column,$type,\"$message\",$source,$severity".PHP_EOL; + } + } + } + + return true; + + }//end generateFileReport() + + + /** + * Generates a csv report. + * + * @param string $cachedData Any partial report data that was returned from + * generateFileReport during the run. + * @param int $totalFiles Total number of files processed during the run. + * @param int $totalErrors Total number of errors found during the run. + * @param int $totalWarnings Total number of warnings found during the run. + * @param boolean $showSources Show sources? + * @param int $width Maximum allowed line width. + * @param boolean $toScreen Is the report being printed to screen? + * + * @return void + */ + public function generate( + $cachedData, + $totalFiles, + $totalErrors, + $totalWarnings, + $showSources=false, + $width=80, + $toScreen=true + ) { + echo 'File,Line,Column,Type,Message,Source,Severity'.PHP_EOL; + echo $cachedData; + + }//end generate() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Reports/Emacs.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Reports/Emacs.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Reports/Emacs.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Reports/Emacs.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,108 @@ + + * @author Greg Sherwood + * @copyright 2009 SQLI + * @copyright 2006-2012 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 + */ + +/** + * Emacs report for PHP_CodeSniffer. + * + * PHP version 5 + * + * @category PHP + * @package PHP_CodeSniffer + * @author Gabriele Santini + * @author Greg Sherwood + * @copyright 2009 SQLI + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PHP_CodeSniffer_Reports_Emacs implements PHP_CodeSniffer_Report +{ + + + /** + * Generate a partial report for a single processed file. + * + * Function should return TRUE if it printed or stored data about the file + * and FALSE if it ignored the file. Returning TRUE indicates that the file and + * its data should be counted in the grand totals. + * + * @param array $report Prepared report data. + * @param boolean $showSources Show sources? + * @param int $width Maximum allowed line width. + * + * @return boolean + */ + public function generateFileReport( + $report, + $showSources=false, + $width=80 + ) { + if ($report['errors'] === 0 && $report['warnings'] === 0) { + // Nothing to print. + return false; + } + + foreach ($report['messages'] as $line => $lineErrors) { + foreach ($lineErrors as $column => $colErrors) { + foreach ($colErrors as $error) { + $message = $error['message']; + if ($showSources === true) { + $message .= ' ('.$error['source'].')'; + } + + $type = strtolower($error['type']); + echo $report['filename'].':'.$line.':'.$column.': '.$type.' - '.$message.PHP_EOL; + } + } + } + + return true; + + }//end generateFileReport() + + + /** + * Generates an emacs report. + * + * @param string $cachedData Any partial report data that was returned from + * generateFileReport during the run. + * @param int $totalFiles Total number of files processed during the run. + * @param int $totalErrors Total number of errors found during the run. + * @param int $totalWarnings Total number of warnings found during the run. + * @param boolean $showSources Show sources? + * @param int $width Maximum allowed line width. + * @param boolean $toScreen Is the report being printed to screen? + * + * @return void + */ + public function generate( + $cachedData, + $totalFiles, + $totalErrors, + $totalWarnings, + $showSources=false, + $width=80, + $toScreen=true + ) { + echo $cachedData; + + }//end generate() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Reports/Full.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Reports/Full.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Reports/Full.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Reports/Full.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,178 @@ + + * @author Greg Sherwood + * @copyright 2009 SQLI + * @copyright 2006-2012 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 + */ + +/** + * Full report for PHP_CodeSniffer. + * + * PHP version 5 + * + * @category PHP + * @package PHP_CodeSniffer + * @author Gabriele Santini + * @author Greg Sherwood + * @copyright 2009 SQLI + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PHP_CodeSniffer_Reports_Full implements PHP_CodeSniffer_Report +{ + + + /** + * Generate a partial report for a single processed file. + * + * Function should return TRUE if it printed or stored data about the file + * and FALSE if it ignored the file. Returning TRUE indicates that the file and + * its data should be counted in the grand totals. + * + * @param array $report Prepared report data. + * @param boolean $showSources Show sources? + * @param int $width Maximum allowed line width. + * + * @return boolean + */ + public function generateFileReport( + $report, + $showSources=false, + $width=80 + ) { + if ($report['errors'] === 0 && $report['warnings'] === 0) { + // Nothing to print. + return false; + } + + $width = max($width, 70); + $file = $report['filename']; + + echo PHP_EOL.'FILE: '; + if (strlen($file) <= ($width - 9)) { + echo $file; + } else { + echo '...'.substr($file, (strlen($file) - ($width - 9))); + } + + echo PHP_EOL; + echo str_repeat('-', $width).PHP_EOL; + + echo 'FOUND '.$report['errors'].' ERROR(S) '; + if ($report['warnings'] > 0) { + echo 'AND '.$report['warnings'].' WARNING(S) '; + } + + echo 'AFFECTING '.count($report['messages']).' LINE(S)'.PHP_EOL; + echo str_repeat('-', $width).PHP_EOL; + + // Work out the max line number for formatting. + $maxLine = 0; + foreach ($report['messages'] as $line => $lineErrors) { + if ($line > $maxLine) { + $maxLine = $line; + } + } + + $maxLineLength = strlen($maxLine); + + // The length of the word ERROR or WARNING; used for padding. + if ($report['warnings'] > 0) { + $typeLength = 7; + } else { + $typeLength = 5; + } + + // The padding that all lines will require that are + // printing an error message overflow. + $paddingLine2 = str_repeat(' ', ($maxLineLength + 1)); + $paddingLine2 .= ' | '; + $paddingLine2 .= str_repeat(' ', $typeLength); + $paddingLine2 .= ' | '; + + // The maximum amount of space an error message can use. + $maxErrorSpace = ($width - strlen($paddingLine2) - 1); + + foreach ($report['messages'] as $line => $lineErrors) { + foreach ($lineErrors as $column => $colErrors) { + foreach ($colErrors as $error) { + $message = $error['message']; + if ($showSources === true) { + $message .= ' ('.$error['source'].')'; + } + + // The padding that goes on the front of the line. + $padding = ($maxLineLength - strlen($line)); + $errorMsg = wordwrap( + $message, + $maxErrorSpace, + PHP_EOL.$paddingLine2 + ); + + echo ' '.str_repeat(' ', $padding).$line.' | '.$error['type']; + if ($error['type'] === 'ERROR') { + if ($report['warnings'] > 0) { + echo ' '; + } + } + + echo ' | '.$errorMsg.PHP_EOL; + }//end foreach + }//end foreach + }//end foreach + + echo str_repeat('-', $width).PHP_EOL.PHP_EOL; + return true; + + }//end generateFileReport() + + + /** + * Prints all errors and warnings for each file processed. + * + * @param string $cachedData Any partial report data that was returned from + * generateFileReport during the run. + * @param int $totalFiles Total number of files processed during the run. + * @param int $totalErrors Total number of errors found during the run. + * @param int $totalWarnings Total number of warnings found during the run. + * @param boolean $showSources Show sources? + * @param int $width Maximum allowed line width. + * @param boolean $toScreen Is the report being printed to screen? + * + * @return void + */ + public function generate( + $cachedData, + $totalFiles, + $totalErrors, + $totalWarnings, + $showSources=false, + $width=80, + $toScreen=true + ) { + echo $cachedData; + + if ($toScreen === true + && PHP_CODESNIFFER_INTERACTIVE === false + && class_exists('PHP_Timer', false) === true + ) { + echo PHP_Timer::resourceUsage().PHP_EOL.PHP_EOL; + } + + }//end generate() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Reports/Gitblame.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Reports/Gitblame.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Reports/Gitblame.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Reports/Gitblame.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,133 @@ + + * @copyright 2009 SQLI + * @copyright 2006-2012 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 + */ + +/** + * Gitblame report for PHP_CodeSniffer. + * + * PHP version 5 + * + * @category PHP + * @package PHP_CodeSniffer + * @author Ben Selby + * @copyright 2009 SQLI + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.2.2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PHP_CodeSniffer_Reports_Gitblame extends PHP_CodeSniffer_Reports_VersionControl +{ + + /** + * The name of the report we want in the output + * + * @var string + */ + protected $reportName = 'GIT'; + + + /** + * Extract the author from a blame line. + * + * @param string $line Line to parse. + * + * @return mixed string or false if impossible to recover. + */ + protected function getAuthor($line) + { + $blameParts = array(); + $line = preg_replace('|\s+|', ' ', $line); + preg_match( + '|\(.+[0-9]{4}-[0-9]{2}-[0-9]{2}\s+[0-9]+\)|', + $line, + $blameParts + ); + + if (isset($blameParts[0]) === false) { + return false; + } + + $parts = explode(' ', $blameParts[0]); + + if (count($parts) < 2) { + return false; + } + + $parts = array_slice($parts, 0, (count($parts) - 2)); + + return preg_replace('|\(|', '', implode($parts, ' ')); + + }//end getAuthor() + + + /** + * Gets the blame output. + * + * @param string $filename File to blame. + * + * @return array + */ + protected function getBlameContent($filename) + { + $cwd = getcwd(); + + if (PHP_CODESNIFFER_VERBOSITY > 0) { + echo 'Getting GIT blame info for '.basename($filename).'... '; + } + + $fileParts = explode(DIRECTORY_SEPARATOR, $filename); + $found = false; + $location = ''; + while (empty($fileParts) === false) { + array_pop($fileParts); + $location = implode($fileParts, DIRECTORY_SEPARATOR); + if (is_dir($location.DIRECTORY_SEPARATOR.'.git') === true) { + $found = true; + break; + } + } + + if ($found === true) { + chdir($location); + } else { + echo 'ERROR: Could not locate .git directory '.PHP_EOL.PHP_EOL; + exit(2); + } + + $command = 'git blame --date=short "'.$filename.'"'; + $handle = popen($command, 'r'); + if ($handle === false) { + echo 'ERROR: Could not execute "'.$command.'"'.PHP_EOL.PHP_EOL; + exit(2); + } + + $rawContent = stream_get_contents($handle); + fclose($handle); + + if (PHP_CODESNIFFER_VERBOSITY > 0) { + echo 'DONE'.PHP_EOL; + } + + $blames = explode("\n", $rawContent); + chdir($cwd); + + return $blames; + + }//end getBlameContent() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Reports/Hgblame.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Reports/Hgblame.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Reports/Hgblame.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Reports/Hgblame.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,134 @@ + + * @copyright 2009 SQLI + * @copyright 2006-2012 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 + */ + +/** + * Mercurial report for PHP_CodeSniffer. + * + * PHP version 5 + * + * @category PHP + * @package PHP_CodeSniffer + * @author Ben Selby + * @copyright 2009 SQLI + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PHP_CodeSniffer_Reports_Hgblame extends PHP_CodeSniffer_Reports_VersionControl +{ + + /** + * The name of the report we want in the output + * + * @var string + */ + protected $reportName = 'MERCURIAL'; + + + /** + * Extract the author from a blame line. + * + * @param string $line Line to parse. + * + * @return mixed string or false if impossible to recover. + */ + protected function getAuthor($line) + { + $blameParts = array(); + $line = preg_replace('|\s+|', ' ', $line); + + preg_match( + '|(.+[0-9]{2}:[0-9]{2}:[0-9]{2}\s[0-9]{4}\s.[0-9]{4}:)|', + $line, + $blameParts + ); + + if (isset($blameParts[0]) === false) { + return false; + } + + $parts = explode(' ', $blameParts[0]); + + if (count($parts) < 6) { + return false; + } + + $parts = array_slice($parts, 0, (count($parts) - 6)); + + return trim(preg_replace('|<.+>|', '', implode($parts, ' '))); + + }//end getAuthor() + + + /** + * Gets the blame output. + * + * @param string $filename File to blame. + * + * @return array + */ + protected function getBlameContent($filename) + { + $cwd = getcwd(); + + if (PHP_CODESNIFFER_VERBOSITY > 0) { + echo 'Getting MERCURIAL blame info for '.basename($filename).'... '; + } + + $fileParts = explode(DIRECTORY_SEPARATOR, $filename); + $found = false; + $location = ''; + while (empty($fileParts) === false) { + array_pop($fileParts); + $location = implode($fileParts, DIRECTORY_SEPARATOR); + if (is_dir($location.DIRECTORY_SEPARATOR.'.hg') === true) { + $found = true; + break; + } + } + + if ($found === true) { + chdir($location); + } else { + echo 'ERROR: Could not locate .hg directory '.PHP_EOL.PHP_EOL; + exit(2); + } + + $command = 'hg blame -u -d -v "'.$filename.'"'; + $handle = popen($command, 'r'); + if ($handle === false) { + echo 'ERROR: Could not execute "'.$command.'"'.PHP_EOL.PHP_EOL; + exit(2); + } + + $rawContent = stream_get_contents($handle); + fclose($handle); + + if (PHP_CODESNIFFER_VERBOSITY > 0) { + echo 'DONE'.PHP_EOL; + } + + $blames = explode("\n", $rawContent); + chdir($cwd); + + return $blames; + + }//end getBlameContent() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Reports/Notifysend.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Reports/Notifysend.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Reports/Notifysend.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Reports/Notifysend.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,261 @@ + + * @author Greg Sherwood + * @copyright 2012 Christian Weiske + * @copyright 2006-2012 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 + */ + +/** + * Notify-send report for PHP_CodeSniffer. + * + * Supported configuration parameters: + * - notifysend_path - Full path to notify-send cli command + * - notifysend_timeout - Timeout in milliseconds + * - notifysend_showok - Show "ok, all fine" messages (0/1) + * + * @category PHP + * @package PHP_CodeSniffer + * @author Christian Weiske + * @author Greg Sherwood + * @copyright 2012 Christian Weiske + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PHP_CodeSniffer_Reports_Notifysend implements PHP_CodeSniffer_Report +{ + + /** + * Notification timeout in milliseconds. + * + * @var integer + */ + protected $timeout = 3000; + + /** + * Path to notify-send command. + * + * @var string + */ + protected $path = 'notify-send'; + + /** + * Show "ok, all fine" messages. + * + * @var boolean + */ + protected $showOk = true; + + /** + * Version of installed notify-send executable. + * + * @var string + */ + protected $version = null; + + /** + * A record of the last file checked. + * + * This is used in case we only checked one file and need to print + * the name/path of the file. We wont have access to the checked file list + * after the run has been completed. + * + * @var string + */ + private $_lastCheckedFile = ''; + + + /** + * Load configuration data. + * + * @return void + */ + public function __construct() + { + $path = PHP_CodeSniffer::getConfigData('notifysend_path'); + if ($path !== null) { + $this->path = $path; + } + + $timeout = PHP_CodeSniffer::getConfigData('notifysend_timeout'); + if ($timeout !== null) { + $this->timeout = (int) $timeout; + } + + $showOk = PHP_CodeSniffer::getConfigData('notifysend_showok'); + if ($showOk !== null) { + $this->showOk = (boolean) $showOk; + } + + $this->version = str_replace( + 'notify-send ', + '', + exec($this->path . ' --version') + ); + + }//end __construct() + + + /** + * Generate a partial report for a single processed file. + * + * Function should return TRUE if it printed or stored data about the file + * and FALSE if it ignored the file. Returning TRUE indicates that the file and + * its data should be counted in the grand totals. + * + * @param array $report Prepared report data. + * @param boolean $showSources Show sources? + * @param int $width Maximum allowed line width. + * + * @return boolean + */ + public function generateFileReport( + $report, + $showSources=false, + $width=80 + ) { + // We don't need to print anything, but we want this file counted + // in the total number of checked files even if it has no errors. + $this->_lastCheckedFile = $report['filename']; + return true; + + }//end generateFileReport() + + + /** + * Generates a summary of errors and warnings for each file processed. + * + * @param string $cachedData Any partial report data that was returned from + * generateFileReport during the run. + * @param int $totalFiles Total number of files processed during the run. + * @param int $totalErrors Total number of errors found during the run. + * @param int $totalWarnings Total number of warnings found during the run. + * @param boolean $showSources Show sources? + * @param int $width Maximum allowed line width. + * @param boolean $toScreen Is the report being printed to screen? + * + * @return void + */ + public function generate( + $cachedData, + $totalFiles, + $totalErrors, + $totalWarnings, + $showSources=false, + $width=80, + $toScreen=true + ) { + $msg = $this->generateMessage($totalFiles, $totalErrors, $totalWarnings); + if ($msg === null) { + if ($this->showOk === true) { + $this->notifyAllFine(); + } + } else { + $this->notifyErrors($msg); + } + + }//end generate() + + + /** + * Generate the error message to show to the user. + * + * @param int $totalFiles Total number of files processed during the run. + * @param int $totalErrors Total number of errors found during the run. + * @param int $totalWarnings Total number of warnings found during the run. + * + * @return string Error message or NULL if no error/warning found. + */ + protected function generateMessage($totalFiles, $totalErrors, $totalWarnings) + { + if ($totalErrors === 0 && $totalWarnings === 0) { + // Nothing to print. + return null; + } + + $msg = ''; + if ($totalFiles > 1) { + $msg .= 'Checked '.$totalFiles.' files'.PHP_EOL; + } else { + $msg .= $this->_lastCheckedFile.PHP_EOL; + } + + if ($totalWarnings > 0) { + $msg .= $totalWarnings.' warnings'.PHP_EOL; + } + + if ($totalErrors > 0) { + $msg .= $totalErrors.' errors'.PHP_EOL; + } + + return $msg; + + }//end generateMessage() + + + /** + * Tell the user that all is fine and no error/warning has been found. + * + * @return void + */ + protected function notifyAllFine() + { + $cmd = $this->getBasicCommand(); + $cmd .= ' -i info'; + $cmd .= ' "PHP CodeSniffer: Ok"'; + $cmd .= ' "All fine"'; + exec($cmd); + + }//end notifyAllFine() + + + /** + * Tell the user that errors/warnings have been found. + * + * @param string $msg Message to display. + * + * @return void + */ + protected function notifyErrors($msg) + { + $cmd = $this->getBasicCommand(); + $cmd .= ' -i error'; + $cmd .= ' "PHP CodeSniffer: Error"'; + $cmd .= ' '.escapeshellarg(trim($msg)); + exec($cmd); + + }//end notifyErrors() + + + /** + * Generate and return the basic notify-send command string to execute. + * + * @return string Shell command with common parameters. + */ + protected function getBasicCommand() + { + $cmd = escapeshellcmd($this->path); + $cmd .= ' --category dev.validate'; + $cmd .= ' -t '.(int) $this->timeout; + if (version_compare($this->version, '0.7.3', '>=') === true) { + $cmd .= ' -a phpcs'; + } + + return $cmd; + + }//end getBasicCommand() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Reports/Source.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Reports/Source.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Reports/Source.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Reports/Source.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,235 @@ + + * @author Greg Sherwood + * @copyright 2009 SQLI + * @copyright 2006-2012 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 + */ + +/** + * Source report for PHP_CodeSniffer. + * + * PHP version 5 + * + * @category PHP + * @package PHP_CodeSniffer + * @author Gabriele Santini + * @author Greg Sherwood + * @copyright 2009 SQLI + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PHP_CodeSniffer_Reports_Source implements PHP_CodeSniffer_Report +{ + + /** + * A cache of source stats collected during the run. + * + * @var array + */ + private $_sourceCache = array(); + + + /** + * Generate a partial report for a single processed file. + * + * Function should return TRUE if it printed or stored data about the file + * and FALSE if it ignored the file. Returning TRUE indicates that the file and + * its data should be counted in the grand totals. + * + * @param array $report Prepared report data. + * @param boolean $showSources Show sources? + * @param int $width Maximum allowed line width. + * + * @return boolean + */ + public function generateFileReport( + $report, + $showSources=false, + $width=80 + ) { + if ($report['errors'] === 0 && $report['warnings'] === 0) { + // Nothing to print. + return false; + } + + foreach ($report['messages'] as $line => $lineErrors) { + foreach ($lineErrors as $column => $colErrors) { + foreach ($colErrors as $error) { + $source = $error['source']; + if (isset($this->_sourceCache[$source]) === false) { + $this->_sourceCache[$source] = 1; + } else { + $this->_sourceCache[$source]++; + } + } + } + } + + return true; + + }//end generateFileReport() + + + /** + * Prints the source of all errors and warnings. + * + * @param string $cachedData Any partial report data that was returned from + * generateFileReport during the run. + * @param int $totalFiles Total number of files processed during the run. + * @param int $totalErrors Total number of errors found during the run. + * @param int $totalWarnings Total number of warnings found during the run. + * @param boolean $showSources Show sources? + * @param int $width Maximum allowed line width. + * @param boolean $toScreen Is the report being printed to screen? + * + * @return void + */ + public function generate( + $cachedData, + $totalFiles, + $totalErrors, + $totalWarnings, + $showSources=false, + $width=80, + $toScreen=true + ) { + $width = max($width, 70); + + if (empty($this->_sourceCache) === true) { + // Nothing to show. + return; + } + + asort($this->_sourceCache); + $this->_sourceCache = array_reverse($this->_sourceCache); + + echo PHP_EOL.'PHP CODE SNIFFER VIOLATION SOURCE SUMMARY'.PHP_EOL; + echo str_repeat('-', $width).PHP_EOL; + if ($showSources === true) { + echo 'SOURCE'.str_repeat(' ', ($width - 11)).'COUNT'.PHP_EOL; + echo str_repeat('-', $width).PHP_EOL; + } else { + echo 'STANDARD CATEGORY SNIFF'.str_repeat(' ', ($width - 40)).'COUNT'.PHP_EOL; + echo str_repeat('-', $width).PHP_EOL; + } + + foreach ($this->_sourceCache as $source => $count) { + if ($showSources === true) { + echo $source.str_repeat(' ', ($width - 5 - strlen($source))); + } else { + $parts = explode('.', $source); + + if (strlen($parts[0]) > 8) { + $parts[0] = substr($parts[0], 0, ((strlen($parts[0]) - 8) * -1)); + } + + echo $parts[0].str_repeat(' ', (10 - strlen($parts[0]))); + + $category = $this->makeFriendlyName($parts[1]); + if (strlen($category) > 18) { + $category = substr($category, 0, ((strlen($category) - 18) * -1)); + } + + echo $category.str_repeat(' ', (20 - strlen($category))); + + $sniff = $this->makeFriendlyName($parts[2]); + if (isset($parts[3]) === true) { + $name = $this->makeFriendlyName($parts[3]); + $name[0] = strtolower($name[0]); + $sniff .= ' '.$name; + } + + if (strlen($sniff) > ($width - 37)) { + $sniff = substr($sniff, 0, ($width - 37 - strlen($sniff))); + } + + echo $sniff.str_repeat(' ', ($width - 35 - strlen($sniff))); + }//end if + + echo $count.PHP_EOL; + }//end foreach + + echo str_repeat('-', $width).PHP_EOL; + echo 'A TOTAL OF '.($totalErrors + $totalWarnings).' SNIFF VIOLATION(S) '; + echo 'WERE FOUND IN '.count($this->_sourceCache).' SOURCE(S)'.PHP_EOL; + echo str_repeat('-', $width).PHP_EOL.PHP_EOL; + + if ($toScreen === true + && PHP_CODESNIFFER_INTERACTIVE === false + && class_exists('PHP_Timer', false) === true + ) { + echo PHP_Timer::resourceUsage().PHP_EOL.PHP_EOL; + } + + }//end generate() + + + /** + * Converts a camel caps name into a readable string. + * + * @param string $name The camel caps name to convert. + * + * @return string + */ + public function makeFriendlyName($name) + { + $friendlyName = ''; + $length = strlen($name); + + $lastWasUpper = false; + $lastWasNumeric = false; + for ($i = 0; $i < $length; $i++) { + if (is_numeric($name[$i]) === true) { + if ($lastWasNumeric === false) { + $friendlyName .= ' '; + } + + $lastWasUpper = false; + $lastWasNumeric = true; + } else { + $lastWasNumeric = false; + + $char = strtolower($name[$i]); + if ($char === $name[$i]) { + // Lowercase. + $lastWasUpper = false; + } else { + // Uppercase. + if ($lastWasUpper === false) { + $friendlyName .= ' '; + $next = $name[($i + 1)]; + if (strtolower($next) === $next) { + // Next char is lowercase so it is a word boundary. + $name[$i] = strtolower($name[$i]); + } + } + + $lastWasUpper = true; + } + }//end if + + $friendlyName .= $name[$i]; + }//end for + + $friendlyName = trim($friendlyName); + $friendlyName[0] = strtoupper($friendlyName[0]); + + return $friendlyName; + + }//end makeFriendlyName() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Reports/Summary.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Reports/Summary.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Reports/Summary.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Reports/Summary.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,131 @@ + + * @author Greg Sherwood + * @copyright 2009 SQLI + * @copyright 2006-2012 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 + */ + +/** + * Summary report for PHP_CodeSniffer. + * + * PHP version 5 + * + * @category PHP + * @package PHP_CodeSniffer + * @author Gabriele Santini + * @author Greg Sherwood + * @copyright 2009 SQLI + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PHP_CodeSniffer_Reports_Summary implements PHP_CodeSniffer_Report +{ + + + /** + * Generate a partial report for a single processed file. + * + * If verbose output is enabled, results are shown for all files, even if + * they have no errors or warnings. If verbose output is disabled, we only + * show files that have at least one warning or error. + * + * @param array $report Prepared report data. + * @param boolean $showSources Show sources? + * @param int $width Maximum allowed line width. + * + * @return boolean + */ + public function generateFileReport( + $report, + $showSources=false, + $width=80 + ) { + if (PHP_CODESNIFFER_VERBOSITY === 0 + && $report['errors'] === 0 + && $report['warnings'] === 0 + ) { + // Nothing to print. + return false; + } + + $width = max($width, 70); + $file = $report['filename']; + + $padding = ($width - 18 - strlen($file)); + if ($padding < 0) { + $file = '...'.substr($file, (($padding * -1) + 3)); + $padding = 0; + } + + echo $file.str_repeat(' ', $padding).' '; + echo $report['errors']; + echo str_repeat(' ', (8 - strlen((string) $report['errors']))); + echo $report['warnings']; + echo PHP_EOL; + + return true; + + }//end generateFileReport() + + + /** + * Generates a summary of errors and warnings for each file processed. + * + * @param string $cachedData Any partial report data that was returned from + * generateFileReport during the run. + * @param int $totalFiles Total number of files processed during the run. + * @param int $totalErrors Total number of errors found during the run. + * @param int $totalWarnings Total number of warnings found during the run. + * @param boolean $showSources Show sources? + * @param int $width Maximum allowed line width. + * @param boolean $toScreen Is the report being printed to screen? + * + * @return void + */ + public function generate( + $cachedData, + $totalFiles, + $totalErrors, + $totalWarnings, + $showSources=false, + $width=80, + $toScreen=true + ) { + echo PHP_EOL.'PHP CODE SNIFFER REPORT SUMMARY'.PHP_EOL; + echo str_repeat('-', $width).PHP_EOL; + echo 'FILE'.str_repeat(' ', ($width - 20)).'ERRORS WARNINGS'.PHP_EOL; + echo str_repeat('-', $width).PHP_EOL; + + echo $cachedData; + + echo str_repeat('-', $width).PHP_EOL; + echo 'A TOTAL OF '.$totalErrors.' ERROR(S) '; + echo 'AND '.$totalWarnings.' WARNING(S) '; + + echo 'WERE FOUND IN '.$totalFiles.' FILE(S)'.PHP_EOL; + echo str_repeat('-', $width).PHP_EOL.PHP_EOL; + + if ($toScreen === true + && PHP_CODESNIFFER_INTERACTIVE === false + && class_exists('PHP_Timer', false) === true + ) { + echo PHP_Timer::resourceUsage().PHP_EOL.PHP_EOL; + } + + }//end generate() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Reports/Svnblame.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Reports/Svnblame.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Reports/Svnblame.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Reports/Svnblame.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,100 @@ + + * @author Greg Sherwood + * @copyright 2009 SQLI + * @copyright 2006-2012 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 + */ + +/** + * Svnblame report for PHP_CodeSniffer. + * + * PHP version 5 + * + * @category PHP + * @package PHP_CodeSniffer + * @author Gabriele Santini + * @author Greg Sherwood + * @copyright 2009 SQLI + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PHP_CodeSniffer_Reports_Svnblame extends PHP_CodeSniffer_Reports_VersionControl +{ + + /** + * The name of the report we want in the output + * + * @var string + */ + protected $reportName = 'SVN'; + + + /** + * Extract the author from a blame line. + * + * @param string $line Line to parse. + * + * @return mixed string or false if impossible to recover. + */ + protected function getAuthor($line) + { + $blameParts = array(); + preg_match('|\s*([^\s]+)\s+([^\s]+)|', $line, $blameParts); + + if (isset($blameParts[2]) === false) { + return false; + } + + return $blameParts[2]; + + }//end getAuthor() + + + /** + * Gets the blame output. + * + * @param string $filename File to blame. + * + * @return array + */ + protected function getBlameContent($filename) + { + if (PHP_CODESNIFFER_VERBOSITY > 0) { + echo 'Getting SVN blame info for '.basename($filename).'... '; + } + + $command = 'svn blame "'.$filename.'"'; + $handle = popen($command, 'r'); + if ($handle === false) { + echo 'ERROR: Could not execute "'.$command.'"'.PHP_EOL.PHP_EOL; + exit(2); + } + + $rawContent = stream_get_contents($handle); + fclose($handle); + + if (PHP_CODESNIFFER_VERBOSITY > 0) { + echo 'DONE'.PHP_EOL; + } + + $blames = explode("\n", $rawContent); + + return $blames; + + }//end getBlameContent() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Reports/VersionControl.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Reports/VersionControl.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Reports/VersionControl.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Reports/VersionControl.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,257 @@ + + * @copyright 2009 SQLI + * @copyright 2006-2012 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 + */ + +/** + * Version control report base class for PHP_CodeSniffer. + * + * PHP version 5 + * + * @category PHP + * @package PHP_CodeSniffer + * @author Ben Selby + * @copyright 2009 SQLI + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.2.2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +abstract class PHP_CodeSniffer_Reports_VersionControl implements PHP_CodeSniffer_Report +{ + + /** + * The name of the report we want in the output. + * + * @var string + */ + protected $reportName = 'VERSION CONTROL'; + + /** + * A cache of author stats collected during the run. + * + * @var array + */ + private $_authorCache = array(); + + /** + * A cache of blame stats collected during the run. + * + * @var array + */ + private $_praiseCache = array(); + + /** + * A cache of source stats collected during the run. + * + * @var array + */ + private $_sourceCache = array(); + + + /** + * Generate a partial report for a single processed file. + * + * Function should return TRUE if it printed or stored data about the file + * and FALSE if it ignored the file. Returning TRUE indicates that the file and + * its data should be counted in the grand totals. + * + * @param array $report Prepared report data. + * @param boolean $showSources Show sources? + * @param int $width Maximum allowed line width. + * + * @return boolean + */ + public function generateFileReport( + $report, + $showSources=false, + $width=80 + ) { + $blames = $this->getBlameContent($report['filename']); + + foreach ($report['messages'] as $line => $lineErrors) { + $author = $this->getAuthor($blames[($line - 1)]); + if ($author === false) { + continue; + } + + if (isset($this->_authorCache[$author]) === false) { + $this->_authorCache[$author] = 0; + $this->_praiseCache[$author] = array( + 'good' => 0, + 'bad' => 0, + ); + } + + $this->_praiseCache[$author]['bad']++; + + foreach ($lineErrors as $column => $colErrors) { + foreach ($colErrors as $error) { + $this->_authorCache[$author]++; + + if ($showSources === true) { + $source = $error['source']; + if (isset($this->_sourceCache[$author][$source]) === false) { + $this->_sourceCache[$author][$source] = 1; + } else { + $this->_sourceCache[$author][$source]++; + } + } + } + } + + unset($blames[($line - 1)]); + }//end foreach + + // No go through and give the authors some credit for + // all the lines that do not have errors. + foreach ($blames as $line) { + $author = $this->getAuthor($line); + if (false === $author) { + continue; + } + + if (isset($this->_authorCache[$author]) === false) { + // This author doesn't have any errors. + if (PHP_CODESNIFFER_VERBOSITY === 0) { + continue; + } + + $this->_authorCache[$author] = 0; + $this->_praiseCache[$author] = array( + 'good' => 0, + 'bad' => 0, + ); + } + + $this->_praiseCache[$author]['good']++; + }//end foreach + + return true; + + }//end generateFileReport() + + + /** + * Prints the author of all errors and warnings, as given by "version control blame". + * + * @param string $cachedData Any partial report data that was returned from + * generateFileReport during the run. + * @param int $totalFiles Total number of files processed during the run. + * @param int $totalErrors Total number of errors found during the run. + * @param int $totalWarnings Total number of warnings found during the run. + * @param boolean $showSources Show sources? + * @param int $width Maximum allowed line width. + * @param boolean $toScreen Is the report being printed to screen? + * + * @return void + */ + public function generate( + $cachedData, + $totalFiles, + $totalErrors, + $totalWarnings, + $showSources=false, + $width=80, + $toScreen=true + ) { + $errorsShown = ($totalErrors + $totalWarnings); + if ($errorsShown === 0) { + // Nothing to show. + return; + } + + $width = max($width, 70); + arsort($this->_authorCache); + + echo PHP_EOL.'PHP CODE SNIFFER '.$this->reportName.' BLAME SUMMARY'.PHP_EOL; + echo str_repeat('-', $width).PHP_EOL; + if ($showSources === true) { + echo 'AUTHOR SOURCE'.str_repeat(' ', ($width - 43)).'(Author %) (Overall %) COUNT'.PHP_EOL; + echo str_repeat('-', $width).PHP_EOL; + } else { + echo 'AUTHOR'.str_repeat(' ', ($width - 34)).'(Author %) (Overall %) COUNT'.PHP_EOL; + echo str_repeat('-', $width).PHP_EOL; + } + + foreach ($this->_authorCache as $author => $count) { + if ($this->_praiseCache[$author]['good'] === 0) { + $percent = 0; + } else { + $total = ($this->_praiseCache[$author]['bad'] + $this->_praiseCache[$author]['good']); + $percent = round(($this->_praiseCache[$author]['bad'] / $total * 100), 2); + } + + $overallPercent = '('.round((($count / $errorsShown) * 100), 2).')'; + $authorPercent = '('.$percent.')'; + $line = str_repeat(' ', (6 - strlen($count))).$count; + $line = str_repeat(' ', (12 - strlen($overallPercent))).$overallPercent.$line; + $line = str_repeat(' ', (11 - strlen($authorPercent))).$authorPercent.$line; + $line = $author.str_repeat(' ', ($width - strlen($author) - strlen($line))).$line; + + echo $line.PHP_EOL; + + if ($showSources === true && isset($this->_sourceCache[$author]) === true) { + $errors = $this->_sourceCache[$author]; + asort($errors); + $errors = array_reverse($errors); + + foreach ($errors as $source => $count) { + if ($source === 'count') { + continue; + } + + $line = str_repeat(' ', (5 - strlen($count))).$count; + echo ' '.$source.str_repeat(' ', ($width - 14 - strlen($source))).$line.PHP_EOL; + } + } + }//end foreach + + echo str_repeat('-', $width).PHP_EOL; + echo 'A TOTAL OF '.$errorsShown.' SNIFF VIOLATION(S) '; + echo 'WERE COMMITTED BY '.count($this->_authorCache).' AUTHOR(S)'.PHP_EOL; + echo str_repeat('-', $width).PHP_EOL.PHP_EOL; + + if ($toScreen === true + && PHP_CODESNIFFER_INTERACTIVE === false + && class_exists('PHP_Timer', false) === true + ) { + echo PHP_Timer::resourceUsage().PHP_EOL.PHP_EOL; + } + + }//end generate() + + + /** + * Extract the author from a blame line. + * + * @param string $line Line to parse. + * + * @return mixed string or false if impossible to recover. + */ + abstract protected function getAuthor($line); + + + /** + * Gets the blame output. + * + * @param string $filename File to blame. + * + * @return array + */ + abstract protected function getBlameContent($filename); + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Reports/Xml.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Reports/Xml.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Reports/Xml.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Reports/Xml.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,128 @@ + + * @author Greg Sherwood + * @copyright 2009 SQLI + * @copyright 2006-2012 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 + */ + +/** + * Xml report for PHP_CodeSniffer. + * + * PHP version 5 + * + * @category PHP + * @package PHP_CodeSniffer + * @author Gabriele Santini + * @author Greg Sherwood + * @copyright 2009 SQLI + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PHP_CodeSniffer_Reports_Xml implements PHP_CodeSniffer_Report +{ + + + /** + * Generate a partial report for a single processed file. + * + * Function should return TRUE if it printed or stored data about the file + * and FALSE if it ignored the file. Returning TRUE indicates that the file and + * its data should be counted in the grand totals. + * + * @param array $report Prepared report data. + * @param boolean $showSources Show sources? + * @param int $width Maximum allowed line width. + * + * @return boolean + */ + public function generateFileReport( + $report, + $showSources=false, + $width=80 + ) { + $out = new XMLWriter; + $out->openMemory(); + $out->setIndent(true); + + if ($report['errors'] === 0 && $report['warnings'] === 0) { + // Nothing to print. + return false; + } + + $out->startElement('file'); + $out->writeAttribute('name', $report['filename']); + $out->writeAttribute('errors', $report['errors']); + $out->writeAttribute('warnings', $report['warnings']); + + foreach ($report['messages'] as $line => $lineErrors) { + foreach ($lineErrors as $column => $colErrors) { + foreach ($colErrors as $error) { + $error['type'] = strtolower($error['type']); + if (PHP_CODESNIFFER_ENCODING !== 'utf-8') { + $error['message'] = iconv(PHP_CODESNIFFER_ENCODING, 'utf-8', $error['message']); + } + + $out->startElement($error['type']); + $out->writeAttribute('line', $line); + $out->writeAttribute('column', $column); + $out->writeAttribute('source', $error['source']); + $out->writeAttribute('severity', $error['severity']); + $out->text($error['message']); + $out->endElement(); + } + } + }//end foreach + + $out->endElement(); + echo $out->flush(); + + return true; + + }//end generateFileReport() + + + /** + * Prints all violations for processed files, in a proprietary XML format. + * + * @param string $cachedData Any partial report data that was returned from + * generateFileReport during the run. + * @param int $totalFiles Total number of files processed during the run. + * @param int $totalErrors Total number of errors found during the run. + * @param int $totalWarnings Total number of warnings found during the run. + * @param boolean $showSources Show sources? + * @param int $width Maximum allowed line width. + * @param boolean $toScreen Is the report being printed to screen? + * + * @return void + */ + public function generate( + $cachedData, + $totalFiles, + $totalErrors, + $totalWarnings, + $showSources=false, + $width=80, + $toScreen=true + ) { + echo ''.PHP_EOL; + echo ''.PHP_EOL; + echo $cachedData; + echo ''.PHP_EOL; + + }//end generate() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Sniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Sniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Sniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Sniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,93 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Represents a PHP_CodeSniffer sniff for sniffing coding standards. + * + * A sniff registers what token types it wishes to listen for, then, when + * PHP_CodeSniffer encounters that token, the sniff is invoked and passed + * information about where the token was found in the stack, and the + * PHP_CodeSniffer file in which the token was found. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +interface PHP_CodeSniffer_Sniff +{ + + + /** + * Registers the tokens that this sniff wants to listen for. + * + * An example return value for a sniff that wants to listen for whitespace + * and any comments would be: + * + * + * return array( + * T_WHITESPACE, + * T_DOC_COMMENT, + * T_COMMENT, + * ); + * + * + * @return array(int) + * @see Tokens.php + */ + public function register(); + + + /** + * Called when one of the token types that this sniff is listening for + * is found. + * + * The stackPtr variable indicates where in the stack the token was found. + * A sniff can acquire information this token, along with all the other + * tokens within the stack by first acquiring the token stack: + * + * + * $tokens = $phpcsFile->getTokens(); + * echo 'Encountered a '.$tokens[$stackPtr]['type'].' token'; + * echo 'token information: '; + * print_r($tokens[$stackPtr]); + * + * + * If the sniff discovers an anomaly in the code, they can raise an error + * by calling addError() on the PHP_CodeSniffer_File object, specifying an error + * message and the position of the offending token: + * + * + * $phpcsFile->addError('Encountered an error', $stackPtr); + * + * + * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where the + * token was found. + * @param int $stackPtr The position in the PHP_CodeSniffer + * file's token stack where the token + * was found. + * + * @return void + */ + public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr); + + +}//end interface + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/AbstractPatternSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/AbstractPatternSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/AbstractPatternSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/AbstractPatternSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,959 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +if (class_exists('PHP_CodeSniffer_Standards_IncorrectPatternException', true) === false) { + $error = 'Class PHP_CodeSniffer_Standards_IncorrectPatternException not found'; + throw new PHP_CodeSniffer_Exception($error); +} + +/** + * Processes pattern strings and checks that the code conforms to the pattern. + * + * This test essentially checks that code is correctly formatted with whitespace. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +abstract class PHP_CodeSniffer_Standards_AbstractPatternSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * If true, comments will be ignored if they are found in the code. + * + * @var boolean + */ + public $ignoreComments = false; + + /** + * The current file being checked. + * + * @var string + */ + protected $currFile = ''; + + /** + * The parsed patterns array. + * + * @var array + */ + private $_parsedPatterns = array(); + + /** + * Tokens that this sniff wishes to process outside of the patterns. + * + * @var array(int) + * @see registerSupplementary() + * @see processSupplementary() + */ + private $_supplementaryTokens = array(); + + /** + * Positions in the stack where errors have occurred. + * + * @var array() + */ + private $_errorPos = array(); + + + /** + * Constructs a PHP_CodeSniffer_Standards_AbstractPatternSniff. + * + * @param boolean $ignoreComments If true, comments will be ignored. + */ + public function __construct($ignoreComments=null) + { + // This is here for backwards compatibility. + if ($ignoreComments !== null) { + $this->ignoreComments = $ignoreComments; + } + + $this->_supplementaryTokens = $this->registerSupplementary(); + + }//end __construct() + + + /** + * Registers the tokens to listen to. + * + * Classes extending AbstractPatternTest should implement the + * getPatterns() method to register the patterns they wish to test. + * + * @return array(int) + * @see process() + */ + public final function register() + { + $listenTypes = array(); + $patterns = $this->getPatterns(); + + foreach ($patterns as $pattern) { + $parsedPattern = $this->_parse($pattern); + + // Find a token position in the pattern that we can use + // for a listener token. + $pos = $this->_getListenerTokenPos($parsedPattern); + $tokenType = $parsedPattern[$pos]['token']; + $listenTypes[] = $tokenType; + + $patternArray = array( + 'listen_pos' => $pos, + 'pattern' => $parsedPattern, + 'pattern_code' => $pattern, + ); + + if (isset($this->_parsedPatterns[$tokenType]) === false) { + $this->_parsedPatterns[$tokenType] = array(); + } + + $this->_parsedPatterns[$tokenType][] = $patternArray; + + }//end foreach + + return array_unique(array_merge($listenTypes, $this->_supplementaryTokens)); + + }//end register() + + + /** + * Returns the token types that the specified pattern is checking for. + * + * Returned array is in the format: + * + * array( + * T_WHITESPACE => 0, // 0 is the position where the T_WHITESPACE token + * // should occur in the pattern. + * ); + * + * + * @param array $pattern The parsed pattern to find the acquire the token + * types from. + * + * @return array(int => int) + */ + private function _getPatternTokenTypes($pattern) + { + $tokenTypes = array(); + foreach ($pattern as $pos => $patternInfo) { + if ($patternInfo['type'] === 'token') { + if (isset($tokenTypes[$patternInfo['token']]) === false) { + $tokenTypes[$patternInfo['token']] = $pos; + } + } + } + + return $tokenTypes; + + }//end _getPatternTokenTypes() + + + /** + * Returns the position in the pattern that this test should register as + * a listener for the pattern. + * + * @param array $pattern The pattern to acquire the listener for. + * + * @return int The postition in the pattern that this test should register + * as the listener. + * @throws PHP_CodeSniffer_Exception If we could not determine a token + * to listen for. + */ + private function _getListenerTokenPos($pattern) + { + $tokenTypes = $this->_getPatternTokenTypes($pattern); + $tokenCodes = array_keys($tokenTypes); + $token = PHP_CodeSniffer_Tokens::getHighestWeightedToken($tokenCodes); + + // If we could not get a token. + if ($token === false) { + $error = 'Could not determine a token to listen for'; + throw new PHP_CodeSniffer_Exception($error); + } + + return $tokenTypes[$token]; + + }//end _getListenerTokenPos() + + + /** + * Processes the test. + * + * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where the + * token occured. + * @param int $stackPtr The postion in the tokens stack + * where the listening token type was + * found. + * + * @return void + * @see register() + */ + public final function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + $file = $phpcsFile->getFilename(); + if ($this->currFile !== $file) { + // We have changed files, so clean up. + $this->_errorPos = array(); + $this->currFile = $file; + } + + $tokens = $phpcsFile->getTokens(); + + if (in_array($tokens[$stackPtr]['code'], $this->_supplementaryTokens) === true) { + $this->processSupplementary($phpcsFile, $stackPtr); + } + + $type = $tokens[$stackPtr]['code']; + + // If the type is not set, then it must have been a token registered + // with registerSupplementary(). + if (isset($this->_parsedPatterns[$type]) === false) { + return; + } + + $allErrors = array(); + + // Loop over each pattern that is listening to the current token type + // that we are processing. + foreach ($this->_parsedPatterns[$type] as $patternInfo) { + // If processPattern returns false, then the pattern that we are + // checking the code with must not be designed to check that code. + $errors = $this->processPattern($patternInfo, $phpcsFile, $stackPtr); + if ($errors === false) { + // The pattern didn't match. + continue; + } else if (empty($errors) === true) { + // The pattern matched, but there were no errors. + break; + } + + foreach ($errors as $stackPtr => $error) { + if (isset($this->_errorPos[$stackPtr]) === false) { + $this->_errorPos[$stackPtr] = true; + $allErrors[$stackPtr] = $error; + } + } + } + + foreach ($allErrors as $stackPtr => $error) { + $phpcsFile->addError($error, $stackPtr); + } + + }//end process() + + + /** + * Processes the pattern and verifies the code at $stackPtr. + * + * @param array $patternInfo Information about the pattern used + * for checking, which includes are + * parsed token representation of the + * pattern. + * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where the + * token occured. + * @param int $stackPtr The postion in the tokens stack where + * the listening token type was found. + * + * @return array(errors) + */ + protected function processPattern( + $patternInfo, + PHP_CodeSniffer_File $phpcsFile, + $stackPtr + ) { + $tokens = $phpcsFile->getTokens(); + $pattern = $patternInfo['pattern']; + $patternCode = $patternInfo['pattern_code']; + $errors = array(); + $found = ''; + + $ignoreTokens = array(T_WHITESPACE); + if ($this->ignoreComments === true) { + $ignoreTokens + = array_merge($ignoreTokens, PHP_CodeSniffer_Tokens::$commentTokens); + } + + $origStackPtr = $stackPtr; + $hasError = false; + + if ($patternInfo['listen_pos'] > 0) { + $stackPtr--; + + for ($i = ($patternInfo['listen_pos'] - 1); $i >= 0; $i--) { + if ($pattern[$i]['type'] === 'token') { + if ($pattern[$i]['token'] === T_WHITESPACE) { + if ($tokens[$stackPtr]['code'] === T_WHITESPACE) { + $found = $tokens[$stackPtr]['content'].$found; + } + + // Only check the size of the whitespace if this is not + // the first token. We don't care about the size of + // leading whitespace, just that there is some. + if ($i !== 0) { + if ($tokens[$stackPtr]['content'] !== $pattern[$i]['value']) { + $hasError = true; + } + } + } else { + // Check to see if this important token is the same as the + // previous important token in the pattern. If it is not, + // then the pattern cannot be for this piece of code. + $prev = $phpcsFile->findPrevious( + $ignoreTokens, + $stackPtr, + null, + true + ); + + if ($prev === false + || $tokens[$prev]['code'] !== $pattern[$i]['token'] + ) { + return false; + } + + // If we skipped past some whitespace tokens, then add them + // to the found string. + $tokenContent = $phpcsFile->getTokensAsString( + ($prev + 1), + ($stackPtr - $prev - 1) + ); + + $found = $tokens[$prev]['content'].$tokenContent.$found; + + if (isset($pattern[($i - 1)]) === true + && $pattern[($i - 1)]['type'] === 'skip' + ) { + $stackPtr = $prev; + } else { + $stackPtr = ($prev - 1); + } + }//end if + } else if ($pattern[$i]['type'] === 'skip') { + // Skip to next piece of relevant code. + if ($pattern[$i]['to'] === 'parenthesis_closer') { + $to = 'parenthesis_opener'; + } else { + $to = 'scope_opener'; + } + + // Find the previous opener. + $next = $phpcsFile->findPrevious( + $ignoreTokens, + $stackPtr, + null, + true + ); + + if ($next === false || isset($tokens[$next][$to]) === false) { + // If there was not opener, then we must be + // using the wrong pattern. + return false; + } + + if ($to === 'parenthesis_opener') { + $found = '{'.$found; + } else { + $found = '('.$found; + } + + $found = '...'.$found; + + // Skip to the opening token. + $stackPtr = ($tokens[$next][$to] - 1); + } else if ($pattern[$i]['type'] === 'string') { + $found = 'abc'; + } else if ($pattern[$i]['type'] === 'newline') { + if ($this->ignoreComments === true + && in_array($tokens[$stackPtr]['code'], PHP_CodeSniffer_Tokens::$commentTokens) === true + ) { + $startComment = $phpcsFile->findPrevious( + PHP_CodeSniffer_Tokens::$commentTokens, + ($stackPtr - 1), + null, + true + ); + + if ($tokens[$startComment]['line'] !== $tokens[($startComment + 1)]['line']) { + $startComment++; + } + + $tokenContent = $phpcsFile->getTokensAsString( + $startComment, + ($stackPtr - $startComment + 1) + ); + + $found = $tokenContent.$found; + $stackPtr = ($startComment - 1); + } + + if ($tokens[$stackPtr]['code'] === T_WHITESPACE) { + if ($tokens[$stackPtr]['content'] !== $phpcsFile->eolChar) { + $found = $tokens[$stackPtr]['content'].$found; + + // This may just be an indent that comes after a newline + // so check the token before to make sure. If it is a newline, we + // can ignore the error here. + if ($tokens[($stackPtr - 1)]['content'] !== $phpcsFile->eolChar) { + $hasError = true; + } else { + $stackPtr--; + } + } else { + $found = 'EOL'.$found; + } + } else { + $found = $tokens[$stackPtr]['content'].$found; + $hasError = true; + } + + if ($hasError === false && $pattern[($i - 1)]['type'] !== 'newline') { + // Make sure they only have 1 newline. + $prev = $phpcsFile->findPrevious($ignoreTokens, ($stackPtr - 1), null, true); + if ($prev !== false && $tokens[$prev]['line'] !== $tokens[$stackPtr]['line']) { + $hasError = true; + } + } + }//end if + }//end for + }//end if + + $stackPtr = $origStackPtr; + $lastAddedStackPtr = null; + $patternLen = count($pattern); + + for ($i = $patternInfo['listen_pos']; $i < $patternLen; $i++) { + if ($pattern[$i]['type'] === 'token') { + if ($pattern[$i]['token'] === T_WHITESPACE) { + if ($this->ignoreComments === true) { + // If we are ignoring comments, check to see if this current + // token is a comment. If so skip it. + if (in_array($tokens[$stackPtr]['code'], PHP_CodeSniffer_Tokens::$commentTokens) === true) { + continue; + } + + // If the next token is a comment, the we need to skip the + // current token as we should allow a space before a + // comment for readability. + if (in_array($tokens[($stackPtr + 1)]['code'], PHP_CodeSniffer_Tokens::$commentTokens) === true) { + continue; + } + } + + $tokenContent = ''; + if ($tokens[$stackPtr]['code'] === T_WHITESPACE) { + if (isset($pattern[($i + 1)]) === false) { + // This is the last token in the pattern, so just compare + // the next token of content. + $tokenContent = $tokens[$stackPtr]['content']; + } else { + // Get all the whitespace to the next token. + $next = $phpcsFile->findNext( + PHP_CodeSniffer_Tokens::$emptyTokens, + $stackPtr, + null, + true + ); + + $tokenContent = $phpcsFile->getTokensAsString( + $stackPtr, + ($next - $stackPtr) + ); + + $lastAddedStackPtr = $stackPtr; + $stackPtr = $next; + } + + if ($stackPtr !== $lastAddedStackPtr) { + $found .= $tokenContent; + } + } else { + if ($stackPtr !== $lastAddedStackPtr) { + $found .= $tokens[$stackPtr]['content']; + $lastAddedStackPtr = $stackPtr; + } + }//end if + + if (isset($pattern[($i + 1)]) === true + && $pattern[($i + 1)]['type'] === 'skip' + ) { + // The next token is a skip token, so we just need to make + // sure the whitespace we found has *at least* the + // whitespace required. + if (strpos($tokenContent, $pattern[$i]['value']) !== 0) { + $hasError = true; + } + } else { + if ($tokenContent !== $pattern[$i]['value']) { + $hasError = true; + } + } + } else { + // Check to see if this important token is the same as the + // next important token in the pattern. If it is not, then + // the pattern cannot be for this piece of code. + $next = $phpcsFile->findNext( + $ignoreTokens, + $stackPtr, + null, + true + ); + + if ($next === false + || $tokens[$next]['code'] !== $pattern[$i]['token'] + ) { + // The next important token did not match the pattern. + return false; + } + + if ($lastAddedStackPtr !== null) { + if (($tokens[$next]['code'] === T_OPEN_CURLY_BRACKET + || $tokens[$next]['code'] === T_CLOSE_CURLY_BRACKET) + && isset($tokens[$next]['scope_condition']) === true + && $tokens[$next]['scope_condition'] > $lastAddedStackPtr + ) { + // This is a brace, but the owner of it is after the current + // token, which means it does not belong to any token in + // our pattern. This means the pattern is not for us. + return false; + } + + if (($tokens[$next]['code'] === T_OPEN_PARENTHESIS + || $tokens[$next]['code'] === T_CLOSE_PARENTHESIS) + && isset($tokens[$next]['parenthesis_owner']) === true + && $tokens[$next]['parenthesis_owner'] > $lastAddedStackPtr + ) { + // This is a bracket, but the owner of it is after the current + // token, which means it does not belong to any token in + // our pattern. This means the pattern is not for us. + return false; + } + }//end if + + // If we skipped past some whitespace tokens, then add them + // to the found string. + if (($next - $stackPtr) > 0) { + $hasComment = false; + for ($j = $stackPtr; $j < $next; $j++) { + $found .= $tokens[$j]['content']; + if (in_array($tokens[$j]['code'], PHP_CodeSniffer_Tokens::$commentTokens) === true) { + $hasComment = true; + } + } + + // If we are not ignoring comments, this additional + // whitespace or comment is not allowed. If we are + // ignoring comments, there needs to be at least one + // comment for this to be allowed. + if ($this->ignoreComments === false + || ($this->ignoreComments === true + && $hasComment === false) + ) { + $hasError = true; + } + + // Even when ignoring comments, we are not allowed to include + // newlines without the pattern specifying them, so + // everything should be on the same line. + if ($tokens[$next]['line'] !== $tokens[$stackPtr]['line']) { + $hasError = true; + } + }//end if + + if ($next !== $lastAddedStackPtr) { + $found .= $tokens[$next]['content']; + $lastAddedStackPtr = $next; + } + + if (isset($pattern[($i + 1)]) === true + && $pattern[($i + 1)]['type'] === 'skip' + ) { + $stackPtr = $next; + } else { + $stackPtr = ($next + 1); + } + }//end if + } else if ($pattern[$i]['type'] === 'skip') { + if ($pattern[$i]['to'] === 'unknown') { + $next = $phpcsFile->findNext( + $pattern[($i + 1)]['token'], + $stackPtr + ); + + if ($next === false) { + // Couldn't find the next token, sowe we must + // be using the wrong pattern. + return false; + } + + $found .= '...'; + $stackPtr = $next; + } else { + // Find the previous opener. + $next = $phpcsFile->findPrevious( + PHP_CodeSniffer_Tokens::$blockOpeners, + $stackPtr + ); + + if ($next === false + || isset($tokens[$next][$pattern[$i]['to']]) === false + ) { + // If there was not opener, then we must + // be using the wrong pattern. + return false; + } + + $found .= '...'; + if ($pattern[$i]['to'] === 'parenthesis_closer') { + $found .= ')'; + } else { + $found .= '}'; + } + + // Skip to the closing token. + $stackPtr = ($tokens[$next][$pattern[$i]['to']] + 1); + }//end if + } else if ($pattern[$i]['type'] === 'string') { + if ($tokens[$stackPtr]['code'] !== T_STRING) { + $hasError = true; + } + + if ($stackPtr !== $lastAddedStackPtr) { + $found .= 'abc'; + $lastAddedStackPtr = $stackPtr; + } + + $stackPtr++; + } else if ($pattern[$i]['type'] === 'newline') { + // Find the next token that contains a newline character. + $newline = 0; + for ($j = $stackPtr; $j < $phpcsFile->numTokens; $j++) { + if (strpos($tokens[$j]['content'], $phpcsFile->eolChar) !== false) { + $newline = $j; + break; + } + } + + if ($newline === 0) { + // We didn't find a newline character in the rest of the file. + $next = ($phpcsFile->numTokens - 1); + $hasError = true; + } else { + if ($this->ignoreComments === false) { + // The newline character cannot be part of a comment. + if (in_array($tokens[$newline]['code'], PHP_CodeSniffer_Tokens::$commentTokens) === true) { + $hasError = true; + } + } + + if ($newline === $stackPtr) { + $next = ($stackPtr + 1); + } else { + // Check that there were no significant tokens that we + // skipped over to find our newline character. + $next = $phpcsFile->findNext( + $ignoreTokens, + $stackPtr, + null, + true + ); + + if ($next < $newline) { + // We skipped a non-ignored token. + $hasError = true; + } else { + $next = ($newline + 1); + } + } + }//end if + + if ($stackPtr !== $lastAddedStackPtr) { + $found .= $phpcsFile->getTokensAsString( + $stackPtr, + ($next - $stackPtr) + ); + + $diff = ($next - $stackPtr); + $lastAddedStackPtr = ($next - 1); + } + + $stackPtr = $next; + }//end if + }//end for + + if ($hasError === true) { + $error = $this->prepareError($found, $patternCode); + $errors[$origStackPtr] = $error; + } + + return $errors; + + }//end processPattern() + + + /** + * Prepares an error for the specified patternCode. + * + * @param string $found The actual found string in the code. + * @param string $patternCode The expected pattern code. + * + * @return string The error message. + */ + protected function prepareError($found, $patternCode) + { + $found = str_replace("\r\n", '\n', $found); + $found = str_replace("\n", '\n', $found); + $found = str_replace("\r", '\n', $found); + $found = str_replace('EOL', '\n', $found); + $expected = str_replace('EOL', '\n', $patternCode); + + $error = "Expected \"$expected\"; found \"$found\""; + + return $error; + + }//end prepareError() + + + /** + * Returns the patterns that should be checked. + * + * @return array(string) + */ + protected abstract function getPatterns(); + + + /** + * Registers any supplementary tokens that this test might wish to process. + * + * A sniff may wish to register supplementary tests when it wishes to group + * an arbitary validation that cannot be performed using a pattern, with + * other pattern tests. + * + * @return array(int) + * @see processSupplementary() + */ + protected function registerSupplementary() + { + return array(); + + }//end registerSupplementary() + + + /** + * Processes any tokens registered with registerSupplementary(). + * + * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where to + * process the skip. + * @param int $stackPtr The position in the tokens stack to + * process. + * + * @return void + * @see registerSupplementary() + */ + protected function processSupplementary( + PHP_CodeSniffer_File $phpcsFile, + $stackPtr + ) { + + }//end processSupplementary() + + + /** + * Parses a pattern string into an array of pattern steps. + * + * @param string $pattern The pattern to parse. + * + * @return array The parsed pattern array. + * @see _createSkipPattern() + * @see _createTokenPattern() + */ + private function _parse($pattern) + { + $patterns = array(); + $length = strlen($pattern); + $lastToken = 0; + $firstToken = 0; + + for ($i = 0; $i < $length; $i++) { + + $specialPattern = false; + $isLastChar = ($i === ($length - 1)); + $oldFirstToken = $firstToken; + + if (substr($pattern, $i, 3) === '...') { + // It's a skip pattern. The skip pattern requires the + // content of the token in the "from" position and the token + // to skip to. + $specialPattern = $this->_createSkipPattern($pattern, ($i - 1)); + $lastToken = ($i - $firstToken); + $firstToken = ($i + 3); + $i = ($i + 2); + + if ($specialPattern['to'] !== 'unknown') { + $firstToken++; + } + } else if (substr($pattern, $i, 3) === 'abc') { + $specialPattern = array('type' => 'string'); + $lastToken = ($i - $firstToken); + $firstToken = ($i + 3); + $i = ($i + 2); + } else if (substr($pattern, $i, 3) === 'EOL') { + $specialPattern = array('type' => 'newline'); + $lastToken = ($i - $firstToken); + $firstToken = ($i + 3); + $i = ($i + 2); + } + + if ($specialPattern !== false || $isLastChar === true) { + // If we are at the end of the string, don't worry about a limit. + if ($isLastChar === true) { + // Get the string from the end of the last skip pattern, if any, + // to the end of the pattern string. + $str = substr($pattern, $oldFirstToken); + } else { + // Get the string from the end of the last special pattern, + // if any, to the start of this special pattern. + if ($lastToken === 0) { + // Note that if the last special token was zero characters ago, + // there will be nothing to process so we can skip this bit. + // This happens if you have something like: EOL... in your pattern. + $str = ''; + } else { + $str = substr($pattern, $oldFirstToken, $lastToken); + } + } + + if ($str !== '') { + $tokenPatterns = $this->_createTokenPattern($str); + foreach ($tokenPatterns as $tokenPattern) { + $patterns[] = $tokenPattern; + } + } + + // Make sure we don't skip the last token. + if ($isLastChar === false && $i === ($length - 1)) { + $i--; + } + }//end if + + // Add the skip pattern *after* we have processed + // all the tokens from the end of the last skip pattern + // to the start of this skip pattern. + if ($specialPattern !== false) { + $patterns[] = $specialPattern; + } + }//end for + + return $patterns; + + }//end _parse() + + + /** + * Creates a skip pattern. + * + * @param string $pattern The pattern being parsed. + * @param string $from The token content that the skip pattern starts from. + * + * @return array The pattern step. + * @see _createTokenPattern() + * @see _parse() + */ + private function _createSkipPattern($pattern, $from) + { + $skip = array('type' => 'skip'); + + $nestedParenthesis = 0; + $nestedBraces = 0; + for ($start = $from; $start >= 0; $start--) { + switch ($pattern[$start]) { + case '(': + if ($nestedParenthesis === 0) { + $skip['to'] = 'parenthesis_closer'; + } + + $nestedParenthesis--; + break; + case '{': + if ($nestedBraces === 0) { + $skip['to'] = 'scope_closer'; + } + + $nestedBraces--; + break; + case '}': + $nestedBraces++; + break; + case ')': + $nestedParenthesis++; + break; + } + + if (isset($skip['to']) === true) { + break; + } + } + + if (isset($skip['to']) === false) { + $skip['to'] = 'unknown'; + } + + return $skip; + + }//end _createSkipPattern() + + + /** + * Creates a token pattern. + * + * @param string $str The tokens string that the pattern should match. + * + * @return array The pattern step. + * @see _createSkipPattern() + * @see _parse() + */ + private function _createTokenPattern($str) + { + // Don't add a space after the closing php tag as it will add a new + // whitespace token. + $tokens = token_get_all(''); + + // Remove the 'token', + 'token' => $patternInfo['code'], + 'value' => $patternInfo['content'], + ); + } + + return $patterns; + + }//end _createTokenPattern() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/AbstractScopeSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/AbstractScopeSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/AbstractScopeSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/AbstractScopeSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,201 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * An AbstractScopeTest allows for tests that extend from this class to + * listen for tokens within a particular scope. + * + * Below is a test that listens to methods that exist only within classes: + * + * class ClassScopeTest extends PHP_CodeSniffer_Standards_AbstractScopeSniff + * { + * public function __construct() + * { + * parent::__construct(array(T_CLASS), array(T_FUNCTION)); + * } + * + * protected function processTokenWithinScope(PHP_CodeSniffer_File $phpcsFile, $) + * { + * $className = $phpcsFile->getDeclarationName($currScope); + * echo 'encountered a method within class '.$className; + * } + * } + * + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +abstract class PHP_CodeSniffer_Standards_AbstractScopeSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * The token types that this test wishes to listen to within the scope. + * + * @var array + */ + private $_tokens = array(); + + /** + * The type of scope opener tokens that this test wishes to listen to. + * + * @var string + */ + private $_scopeTokens = array(); + + /** + * True if this test should fire on tokens outside of the scope. + * + * @var boolean + */ + private $_listenOutside = false; + + + /** + * Constructs a new AbstractScopeTest. + * + * @param array $scopeTokens The type of scope the test wishes to listen to. + * @param array $tokens The tokens that the test wishes to listen to + * within the scope. + * @param boolean $listenOutside If true this test will also alert the + * extending class when a token is found outside + * the scope, by calling the + * processTokenOutsideScope method. + * + * @see PHP_CodeSniffer.getValidScopeTokeners() + * @throws PHP_CodeSniffer_Exception If the specified tokens array is empty. + */ + public function __construct( + array $scopeTokens, + array $tokens, + $listenOutside=false + ) { + if (empty($scopeTokens) === true) { + $error = 'The scope tokens list cannot be empty'; + throw new PHP_CodeSniffer_Exception($error); + } + + if (empty($tokens) === true) { + $error = 'The tokens list cannot be empty'; + throw new PHP_CodeSniffer_Exception($error); + } + + $invalidScopeTokens = array_intersect($scopeTokens, $tokens); + if (empty($invalidScopeTokens) === false) { + $invalid = implode(', ', $invalidScopeTokens); + $error = "Scope tokens [$invalid] cant be in the tokens array"; + throw new PHP_CodeSniffer_Exception($error); + } + + $this->_listenOutside = $listenOutside; + $this->_scopeTokens = $scopeTokens; + $this->_tokens = $tokens; + + }//end __construct() + + + /** + * The method that is called to register the tokens this test wishes to + * listen to. + * + * DO NOT OVERRIDE THIS METHOD. Use the constructor of this class to register + * for the desired tokens and scope. + * + * @return array(int) + * @see __constructor() + */ + public final function register() + { + return $this->_tokens; + + }//end register() + + + /** + * Processes the tokens that this test is listening for. + * + * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found. + * @param int $stackPtr The position in the stack where this + * token was found. + * + * @return void + * @see processTokenWithinScope() + */ + public final function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + $tokens = $phpcsFile->getTokens(); + + $foundScope = false; + foreach ($tokens[$stackPtr]['conditions'] as $scope => $code) { + if (in_array($code, $this->_scopeTokens) === true) { + $this->processTokenWithinScope($phpcsFile, $stackPtr, $scope); + $foundScope = true; + } + } + + if ($this->_listenOutside === true && $foundScope === false) { + $this->processTokenOutsideScope($phpcsFile, $stackPtr); + } + + }//end process() + + + /** + * Processes a token that is found within the scope that this test is + * listening to. + * + * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found. + * @param int $stackPtr The position in the stack where this + * token was found. + * @param int $currScope The position in the tokens array that + * opened the scope that this test is + * listening for. + * + * @return void + */ + protected abstract function processTokenWithinScope( + PHP_CodeSniffer_File $phpcsFile, + $stackPtr, + $currScope + ); + + + /** + * Processes a token that is found within the scope that this test is + * listening to. + * + * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found. + * @param int $stackPtr The position in the stack where this + * token was found. + * + * @return void + */ + protected function processTokenOutsideScope( + PHP_CodeSniffer_File $phpcsFile, + $stackPtr + ) { + + }//end processTokenOutsideScope() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/AbstractVariableSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/AbstractVariableSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/AbstractVariableSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/AbstractVariableSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,245 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +if (class_exists('PHP_CodeSniffer_Standards_AbstractScopeSniff', true) === false) { + $error = 'Class PHP_CodeSniffer_Standards_AbstractScopeSniff not found'; + throw new PHP_CodeSniffer_Exception($error); +} + +/** + * A class to find T_VARIABLE tokens. + * + * This class can distinguish between normal T_VARIABLE tokens, and those tokens + * that represent class members. If a class member is encountered, then then + * processMemberVar method is called so the extending class can process it. If + * the token is found to be a normal T_VARIABLE token, then processVariable is + * called. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +abstract class PHP_CodeSniffer_Standards_AbstractVariableSniff extends PHP_CodeSniffer_Standards_AbstractScopeSniff +{ + + /** + * The end token of the current function that we are in. + * + * @var int + */ + private $_endFunction = -1; + + /** + * true if a function is currently open. + * + * @var boolean + */ + private $_functionOpen = false; + + /** + * The current PHP_CodeSniffer file that we are processing. + * + * @var PHP_CodeSniffer_File + */ + protected $currentFile = null; + + + /** + * Constructs an AbstractVariableTest. + */ + public function __construct() + { + $scopes = array( + T_CLASS, + T_INTERFACE, + ); + + $listen = array( + T_FUNCTION, + T_VARIABLE, + T_DOUBLE_QUOTED_STRING, + T_HEREDOC, + ); + + parent::__construct($scopes, $listen, true); + + }//end __construct() + + + /** + * Processes the token in the specified PHP_CodeSniffer_File. + * + * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where this + * token was found. + * @param int $stackPtr The position where the token was found. + * @param array $currScope The current scope opener token. + * + * @return void + */ + protected final function processTokenWithinScope( + PHP_CodeSniffer_File $phpcsFile, + $stackPtr, + $currScope + ) { + if ($this->currentFile !== $phpcsFile) { + $this->currentFile = $phpcsFile; + $this->_functionOpen = false; + $this->_endFunction = -1; + } + + $tokens = $phpcsFile->getTokens(); + + if ($stackPtr > $this->_endFunction) { + $this->_functionOpen = false; + } + + if ($tokens[$stackPtr]['code'] === T_FUNCTION + && $this->_functionOpen === false + ) { + $this->_functionOpen = true; + + $methodProps = $phpcsFile->getMethodProperties($stackPtr); + + // If the function is abstract, or is in an interface, + // then set the end of the function to it's closing semicolon. + if ($methodProps['is_abstract'] === true + || $tokens[$currScope]['code'] === T_INTERFACE + ) { + $this->_endFunction + = $phpcsFile->findNext(array(T_SEMICOLON), $stackPtr); + } else { + if (isset($tokens[$stackPtr]['scope_closer']) === false) { + $error = 'Possible parse error: non-abstract method defined as abstract'; + $phpcsFile->addWarning($error, $stackPtr); + return; + } + + $this->_endFunction = $tokens[$stackPtr]['scope_closer']; + } + } + + if ($tokens[$stackPtr]['code'] === T_DOUBLE_QUOTED_STRING + || $tokens[$stackPtr]['code'] === T_HEREDOC + ) { + // Check to see if this string has a variable in it. + $pattern = '|(?processVariableInString($phpcsFile, $stackPtr); + } + + return; + } + + if ($this->_functionOpen === true) { + if ($tokens[$stackPtr]['code'] === T_VARIABLE) { + $this->processVariable($phpcsFile, $stackPtr); + } + } else { + // What if we assign a member variable to another? + // ie. private $_count = $this->_otherCount + 1;. + $this->processMemberVar($phpcsFile, $stackPtr); + } + + }//end processTokenWithinScope() + + + /** + * Processes the token outside the scope in the file. + * + * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where this + * token was found. + * @param int $stackPtr The position where the token was found. + * + * @return void + */ + protected final function processTokenOutsideScope( + PHP_CodeSniffer_File $phpcsFile, + $stackPtr + ) { + $tokens = $phpcsFile->getTokens(); + // These variables are not member vars. + if ($tokens[$stackPtr]['code'] === T_VARIABLE) { + $this->processVariable($phpcsFile, $stackPtr); + } else if ($tokens[$stackPtr]['code'] === T_DOUBLE_QUOTED_STRING + || $tokens[$stackPtr]['code'] === T_HEREDOC + ) { + // Check to see if this string has a variable in it. + $pattern = '|(?processVariableInString($phpcsFile, $stackPtr); + } + } + + }//end processTokenOutsideScope() + + + /** + * Called to process class member vars. + * + * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where this + * token was found. + * @param int $stackPtr The position where the token was found. + * + * @return void + */ + abstract protected function processMemberVar( + PHP_CodeSniffer_File $phpcsFile, + $stackPtr + ); + + + /** + * Called to process normal member vars. + * + * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where this + * token was found. + * @param int $stackPtr The position where the token was found. + * + * @return void + */ + abstract protected function processVariable( + PHP_CodeSniffer_File $phpcsFile, + $stackPtr + ); + + + /** + * Called to process variables found in double quoted strings or heredocs. + * + * Note that there may be more than one variable in the string, which will + * result only in one call for the string or one call per line for heredocs. + * + * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where this + * token was found. + * @param int $stackPtr The position where the double quoted + * string was found. + * + * @return void + */ + abstract protected function processVariableInString( + PHP_CodeSniffer_File + $phpcsFile, + $stackPtr + ); + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Docs/Files/LineLengthStandard.xml php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Docs/Files/LineLengthStandard.xml --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Docs/Files/LineLengthStandard.xml 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Docs/Files/LineLengthStandard.xml 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,7 @@ + + + + + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Docs/Formatting/MultipleStatementAlignmentStandard.xml php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Docs/Formatting/MultipleStatementAlignmentStandard.xml --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Docs/Formatting/MultipleStatementAlignmentStandard.xml 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Docs/Formatting/MultipleStatementAlignmentStandard.xml 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,56 @@ + + + + + + + = (1 + 2); +$veryLongVarName = 'string'; +$var = foo($bar, $baz, $quux); + ]]> + + + = (1 + 2); +$veryLongVarName = 'string'; +$var = foo($bar, $baz, $quux); + ]]> + + + + + + + + += 1; +$veryLongVarName = 1; + ]]> + + + += 1; +$veryLongVarName = 1; + ]]> + + + + + = 1; +$veryLongVarName -= 1; + ]]> + + + = 1; +$veryLongVarName -= 1; + ]]> + + + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Docs/Functions/OpeningFunctionBraceBsdAllmanStandard.xml php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Docs/Functions/OpeningFunctionBraceBsdAllmanStandard.xml --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Docs/Functions/OpeningFunctionBraceBsdAllmanStandard.xml 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Docs/Functions/OpeningFunctionBraceBsdAllmanStandard.xml 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,24 @@ + + + + + + + { + ... +} + ]]> + + + { + ... +} + ]]> + + + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Docs/Functions/OpeningFunctionBraceKernighanRitchieStandard.xml php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Docs/Functions/OpeningFunctionBraceKernighanRitchieStandard.xml --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Docs/Functions/OpeningFunctionBraceKernighanRitchieStandard.xml 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Docs/Functions/OpeningFunctionBraceKernighanRitchieStandard.xml 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,24 @@ + + + + + + + { + ... +} + ]]> + + + { + ... +} + ]]> + + + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Docs/NamingConventions/UpperCaseConstantNameStandard.xml php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Docs/NamingConventions/UpperCaseConstantNameStandard.xml --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Docs/NamingConventions/UpperCaseConstantNameStandard.xml 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Docs/NamingConventions/UpperCaseConstantNameStandard.xml 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,29 @@ + + + + + + + FOO_CONSTANT', 'foo'); + +class FooClass +{ + const FOO_CONSTANT = 'foo'; +} + ]]> + + + Foo_Constant', 'foo'); + +class FooClass +{ + const foo_constant = 'foo'; +} + ]]> + + + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Docs/PHP/DisallowShortOpenTagStandard.xml php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Docs/PHP/DisallowShortOpenTagStandard.xml --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Docs/PHP/DisallowShortOpenTagStandard.xml 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Docs/PHP/DisallowShortOpenTagStandard.xml 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,7 @@ + + + to delimit PHP code, not the shorthand. This is the most portable way to include PHP code on differing operating systems and setups. + ]]> + + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Docs/PHP/LowerCaseConstantStandard.xml php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Docs/PHP/LowerCaseConstantStandard.xml --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Docs/PHP/LowerCaseConstantStandard.xml 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Docs/PHP/LowerCaseConstantStandard.xml 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,23 @@ + + + true, false and null constants must always be lowercase. + ]]> + + + + false || $var === null) { + $var = true; +} + ]]> + + + FALSE || $var === NULL) { + $var = TRUE; +} + ]]> + + + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Docs/PHP/UpperCaseConstantStandard.xml php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Docs/PHP/UpperCaseConstantStandard.xml --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Docs/PHP/UpperCaseConstantStandard.xml 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Docs/PHP/UpperCaseConstantStandard.xml 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,23 @@ + + + true, false and null constants must always be uppercase. + ]]> + + + + FALSE || $var === NULL) { + $var = TRUE; +} + ]]> + + + false || $var === null) { + $var = true; +} + ]]> + + + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Classes/DuplicateClassNameSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Classes/DuplicateClassNameSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Classes/DuplicateClassNameSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Classes/DuplicateClassNameSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,125 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Reports errors if the same class or interface name is used in multiple files. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Sniffs_Classes_DuplicateClassNameSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * List of classes that have been found during checking. + * + * @var array + */ + public $foundClasses = array(); + + + /** + * Registers the tokens that this sniff wants to listen for. + * + * @return array(integer) + */ + 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 void + */ + public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + $tokens = $phpcsFile->getTokens(); + + $namespace = ''; + $findTokens = array( + T_CLASS, + T_INTERFACE, + T_NAMESPACE, + T_CLOSE_TAG, + ); + + $stackPtr = $phpcsFile->findNext($findTokens, ($stackPtr + 1)); + while ($stackPtr !== false) { + if ($tokens[$stackPtr]['code'] === T_CLOSE_TAG) { + // We can stop here. The sniff will continue from the next open + // tag when PHPCS reaches that token, if there is one. + return; + } + + // Keep track of what namespace we are in. + if ($tokens[$stackPtr]['code'] === T_NAMESPACE) { + $nsEnd = $phpcsFile->findNext( + array(T_NS_SEPARATOR, T_STRING, T_WHITESPACE), + ($stackPtr + 1), + null, + true + ); + + $namespace = trim($phpcsFile->getTokensAsString(($stackPtr + 1), ($nsEnd - $stackPtr - 1))); + $stackPtr = $nsEnd; + } else { + $nameToken = $phpcsFile->findNext(T_STRING, $stackPtr); + $name = $tokens[$nameToken]['content']; + if ($namespace !== '') { + $name = $namespace.'\\'.$name; + } + + $compareName = strtolower($name); + if (isset($this->foundClasses[$compareName]) === true) { + $type = strtolower($tokens[$stackPtr]['content']); + $file = $this->foundClasses[$compareName]['file']; + $line = $this->foundClasses[$compareName]['line']; + $error = 'Duplicate %s name "%s" found; first defined in %s on line %s'; + $data = array( + $type, + $name, + $file, + $line, + ); + $phpcsFile->addWarning($error, $stackPtr, 'Found', $data); + } else { + $this->foundClasses[$compareName] = array( + 'file' => $phpcsFile->getFilename(), + 'line' => $tokens[$stackPtr]['line'], + ); + } + } + + $stackPtr = $phpcsFile->findNext($findTokens, ($stackPtr + 1)); + }//end while + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/EmptyStatementSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/EmptyStatementSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/EmptyStatementSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/EmptyStatementSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,128 @@ + + * @author Manuel Pichler + * @copyright 2007-2008 Manuel Pichler. All rights reserved. + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://pear.php.net/package/PHP_CodeSniffer + */ + +/** + * This sniff class detected empty statement. + * + * This sniff implements the common algorithm for empty statement body detection. + * A body is considered as empty if it is completely empty or it only contains + * whitespace characters and|or comments. + * + * + * stmt { + * // foo + * } + * stmt (conditions) { + * // foo + * } + * + * + * Statements covered by this sniff are catch, do, else, + * elsif, for, foreach, if, switch, try + * and while. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Manuel Pichler + * @copyright 2007-2008 Manuel Pichler. All rights reserved. + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Sniffs_CodeAnalysis_EmptyStatementSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * List of block tokens that this sniff covers. + * + * The key of this hash identifies the required token while the boolean + * value says mark an error or mark a warning. + * + * @var array + */ + protected $checkedTokens = array( + T_CATCH => false, + T_DO => true, + T_ELSE => true, + T_ELSEIF => true, + T_FOR => true, + T_FOREACH => true, + T_IF => true, + T_SWITCH => true, + T_TRY => true, + T_WHILE => true, + ); + + + /** + * Registers the tokens that this sniff wants to listen for. + * + * @return array(integer) + */ + public function register() + { + return array_keys($this->checkedTokens); + + }//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(); + $token = $tokens[$stackPtr]; + + // Skip for-statements without body. + if (isset($token['scope_opener']) === false) { + return; + } + + $next = ++$token['scope_opener']; + $end = --$token['scope_closer']; + + $emptyBody = true; + for (; $next <= $end; ++$next) { + if (in_array($tokens[$next]['code'], PHP_CodeSniffer_Tokens::$emptyTokens) === false) { + $emptyBody = false; + break; + } + } + + if ($emptyBody === true) { + // Get token identifier. + $name = $phpcsFile->getTokensAsString($stackPtr, 1); + $error = 'Empty %s statement detected'; + $data = array(strtoupper($name)); + if ($this->checkedTokens[$token['code']] === true) { + $phpcsFile->addError($error, $stackPtr, 'NotAllowed', $data); + } else { + $phpcsFile->addWarning($error, $stackPtr, 'NotAllowedWarning', $data); + } + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/ForLoopShouldBeWhileLoopSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/ForLoopShouldBeWhileLoopSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/ForLoopShouldBeWhileLoopSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/ForLoopShouldBeWhileLoopSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,100 @@ + + * @author Manuel Pichler + * @copyright 2007-2008 Manuel Pichler. All rights reserved. + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://pear.php.net/package/PHP_CodeSniffer + */ + +/** + * Detects for-loops that can be simplified to a while-loop. + * + * This rule is based on the PMD rule catalog. Detects for-loops that can be + * simplified as a while-loop. + * + * + * class Foo + * { + * public function bar($x) + * { + * for (;true;) true; // No Init or Update part, may as well be: while (true) + * } + * } + * + * + * @category PHP + * @package PHP_CodeSniffer + * @author Manuel Pichler + * @copyright 2007-2008 Manuel Pichler. All rights reserved. + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Sniffs_CodeAnalysis_ForLoopShouldBeWhileLoopSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Registers the tokens that this sniff wants to listen for. + * + * @return array(integer) + */ + public function register() + { + return array(T_FOR); + + }//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(); + $token = $tokens[$stackPtr]; + + // Skip invalid statement. + if (isset($token['parenthesis_opener']) === false) { + return; + } + + $next = ++$token['parenthesis_opener']; + $end = --$token['parenthesis_closer']; + + $parts = array(0, 0, 0); + $index = 0; + + for (; $next <= $end; ++$next) { + $code = $tokens[$next]['code']; + if ($code === T_SEMICOLON) { + ++$index; + } else if (in_array($code, PHP_CodeSniffer_Tokens::$emptyTokens) === false) { + ++$parts[$index]; + } + } + + if ($parts[0] === 0 && $parts[2] === 0 && $parts[1] > 0) { + $error = 'This FOR loop can be simplified to a WHILE loop'; + $phpcsFile->addWarning($error, $stackPtr, 'CanSimplify'); + } + + }//end process() + + +}//end class + +?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/ForLoopWithTestFunctionCallSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/ForLoopWithTestFunctionCallSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/ForLoopWithTestFunctionCallSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/ForLoopWithTestFunctionCallSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,113 @@ + + * @author Manuel Pichler + * @copyright 2007-2008 Manuel Pichler. All rights reserved. + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://pear.php.net/package/PHP_CodeSniffer + */ + +/** + * Detects for-loops that use a function call in the test expression. + * + * This rule is based on the PMD rule catalog. Detects for-loops that use a + * function call in the test expression. + * + * + * class Foo + * { + * public function bar($x) + * { + * $a = array(1, 2, 3, 4); + * for ($i = 0; $i < count($a); $i++) { + * $a[$i] *= $i; + * } + * } + * } + * + * + * @category PHP + * @package PHP_CodeSniffer + * @author Manuel Pichler + * @copyright 2007-2008 Manuel Pichler. All rights reserved. + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Sniffs_CodeAnalysis_ForLoopWithTestFunctionCallSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Registers the tokens that this sniff wants to listen for. + * + * @return array(integer) + */ + public function register() + { + return array(T_FOR); + + }//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(); + $token = $tokens[$stackPtr]; + + // Skip invalid statement. + if (isset($token['parenthesis_opener']) === false) { + return; + } + + $next = ++$token['parenthesis_opener']; + $end = --$token['parenthesis_closer']; + + $position = 0; + + for (; $next <= $end; ++$next) { + $code = $tokens[$next]['code']; + if ($code === T_SEMICOLON) { + ++$position; + } + + if ($position < 1) { + continue; + } else if ($position > 1) { + break; + } else if ($code !== T_VARIABLE && $code !== T_STRING) { + continue; + } + + // Find next non empty token, if it is a open curly brace we have a + // function call. + $index = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($next + 1), null, true); + + if ($tokens[$index]['code'] === T_OPEN_PARENTHESIS) { + $error = 'Avoid function calls in a FOR loop test part'; + $phpcsFile->addWarning($error, $stackPtr, 'NotAllowed'); + break; + } + }//end for + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/JumbledIncrementerSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/JumbledIncrementerSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/JumbledIncrementerSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/JumbledIncrementerSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,148 @@ + + * @author Manuel Pichler + * @copyright 2007-2008 Manuel Pichler. All rights reserved. + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://pear.php.net/package/PHP_CodeSniffer + */ + +/** + * Detects incrementer jumbling in for loops. + * + * This rule is based on the PMD rule catalog. The jumbling incrementer sniff + * detects the usage of one and the same incrementer into an outer and an inner + * loop. Even it is intended this is confusing code. + * + * + * class Foo + * { + * public function bar($x) + * { + * for ($i = 0; $i < 10; $i++) + * { + * for ($k = 0; $k < 20; $i++) + * { + * echo 'Hello'; + * } + * } + * } + * } + * + * + * @category PHP + * @package PHP_CodeSniffer + * @author Manuel Pichler + * @copyright 2007-2008 Manuel Pichler. All rights reserved. + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Sniffs_CodeAnalysis_JumbledIncrementerSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Registers the tokens that this sniff wants to listen for. + * + * @return array(integer) + */ + public function register() + { + return array(T_FOR); + + }//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(); + $token = $tokens[$stackPtr]; + + // Skip for-loop without body. + if (isset($token['scope_opener']) === false) { + return; + } + + // Find incrementors for outer loop. + $outer = $this->findIncrementers($tokens, $token); + + // Skip if empty. + if (count($outer) === 0) { + return; + } + + // Find nested for loops. + $start = ++$token['scope_opener']; + $end = --$token['scope_closer']; + + for (; $start <= $end; ++$start) { + if ($tokens[$start]['code'] !== T_FOR) { + continue; + } + + $inner = $this->findIncrementers($tokens, $tokens[$start]); + $diff = array_intersect($outer, $inner); + + if (count($diff) !== 0) { + $error = 'Loop incrementor (%s) jumbling with inner loop'; + $data = array(join(', ', $diff)); + $phpcsFile->addWarning($error, $stackPtr, 'Found', $data); + } + } + + }//end process() + + + /** + * Get all used variables in the incrementer part of a for statement. + * + * @param array(integer=>array) $tokens Array with all code sniffer tokens. + * @param array(string=>mixed) $token Current for loop token + * + * @return array(string) List of all found incrementer variables. + */ + protected function findIncrementers(array $tokens, array $token) + { + // Skip invalid statement. + if (isset($token['parenthesis_opener']) === false) { + return array(); + } + + $start = ++$token['parenthesis_opener']; + $end = --$token['parenthesis_closer']; + + $incrementers = array(); + $semicolons = 0; + for ($next = $start; $next <= $end; ++$next) { + $code = $tokens[$next]['code']; + if ($code === T_SEMICOLON) { + ++$semicolons; + } else if ($semicolons === 2 && $code === T_VARIABLE) { + $incrementers[] = $tokens[$next]['content']; + } + } + + return $incrementers; + + }//end findIncrementers() + + +}//end class + +?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/UnconditionalIfStatementSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/UnconditionalIfStatementSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/UnconditionalIfStatementSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/UnconditionalIfStatementSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,106 @@ + + * @author Manuel Pichler + * @copyright 2007-2008 Manuel Pichler. All rights reserved. + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://pear.php.net/package/PHP_CodeSniffer + */ + +/** + * Detects unconditional if- and elseif-statements. + * + * This rule is based on the PMD rule catalog. The Unconditional If Statement + * sniff detects statement conditions that are only set to one of the constant + * values true or false + * + * + * class Foo + * { + * public function close() + * { + * if (true) + * { + * // ... + * } + * } + * } + * + * + * @category PHP + * @package PHP_CodeSniffer + * @author Manuel Pichler + * @copyright 2007-2008 Manuel Pichler. All rights reserved. + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Sniffs_CodeAnalysis_UnconditionalIfStatementSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Registers the tokens that this sniff wants to listen for. + * + * @return array(integer) + */ + public function register() + { + return array( + T_IF, + T_ELSEIF, + ); + + }//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(); + $token = $tokens[$stackPtr]; + + // Skip for-loop without body. + if (isset($token['parenthesis_opener']) === false) { + return; + } + + $next = ++$token['parenthesis_opener']; + $end = --$token['parenthesis_closer']; + + $goodCondition = false; + for (; $next <= $end; ++$next) { + $code = $tokens[$next]['code']; + + if (in_array($code, PHP_CodeSniffer_Tokens::$emptyTokens) === true) { + continue; + } else if ($code !== T_TRUE && $code !== T_FALSE) { + $goodCondition = true; + } + } + + if ($goodCondition === false) { + $error = 'Avoid IF statements that are always true or false'; + $phpcsFile->addWarning($error, $stackPtr, 'Found'); + } + + }//end process() + + +}//end class + +?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/UnnecessaryFinalModifierSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/UnnecessaryFinalModifierSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/UnnecessaryFinalModifierSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/UnnecessaryFinalModifierSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,98 @@ + + * @author Manuel Pichler + * @copyright 2007-2008 Manuel Pichler. All rights reserved. + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://pear.php.net/package/PHP_CodeSniffer + */ + +/** + * Detects unnecessary final modifiers inside of final classes. + * + * This rule is based on the PMD rule catalog. The Unnecessary Final Modifier + * sniff detects the use of the final modifier inside of a final class which + * is unnecessary. + * + * + * final class Foo + * { + * public final function bar() + * { + * } + * } + * + * + * @category PHP + * @package PHP_CodeSniffer + * @author Manuel Pichler + * @copyright 2007-2008 Manuel Pichler. All rights reserved. + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Sniffs_CodeAnalysis_UnnecessaryFinalModifierSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Registers the tokens that this sniff wants to listen for. + * + * @return array(integer) + */ + public function register() + { + return array(T_CLASS); + + }//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(); + $token = $tokens[$stackPtr]; + + // Skip for-statements without body. + if (isset($token['scope_opener']) === false) { + return; + } + + // Fetch previous token. + $prev = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true); + + // Skip for non final class. + if ($prev === false || $tokens[$prev]['code'] !== T_FINAL) { + return; + } + + $next = ++$token['scope_opener']; + $end = --$token['scope_closer']; + + for (; $next <= $end; ++$next) { + if ($tokens[$next]['code'] === T_FINAL) { + $error = 'Unnecessary FINAL modifier in FINAL class'; + $phpcsFile->addWarning($error, $next, 'Found'); + } + } + + }//end process() + + +}//end class + +?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,187 @@ + + * @author Manuel Pichler + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://pear.php.net/package/PHP_CodeSniffer + */ + +/** + * Checks the for unused function parameters. + * + * This sniff checks that all function parameters are used in the function body. + * One exception is made for empty function bodies or function bodies that only + * contain comments. This could be useful for the classes that implement an + * interface that defines multiple methods but the implementation only needs some + * of them. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Manuel Pichler + * @author Greg Sherwood + * @copyright 2007-2008 Manuel Pichler. All rights reserved. + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Sniffs_CodeAnalysis_UnusedFunctionParameterSniff 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(); + $token = $tokens[$stackPtr]; + + // Skip broken function declarations. + if (isset($token['scope_opener']) === false || isset($token['parenthesis_opener']) === false) { + return; + } + + $params = array(); + foreach ($phpcsFile->getMethodParameters($stackPtr) as $param) { + $params[$param['name']] = $stackPtr; + } + + $next = ++$token['scope_opener']; + $end = --$token['scope_closer']; + + $foundContent = false; + + for (; $next <= $end; ++$next) { + $token = $tokens[$next]; + $code = $token['code']; + + // Ignorable tokens. + if (in_array($code, PHP_CodeSniffer_Tokens::$emptyTokens) === true) { + continue; + } + + if ($foundContent === false) { + // A throw statement as the first content indicates an interface method. + if ($code === T_THROW) { + return; + } + + // A return statement as the first content indicates an interface method. + if ($code === T_RETURN) { + $tmp = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($next + 1), null, true); + if ($tmp === false) { + return; + } + + // There is a return. + if ($tokens[$tmp]['code'] === T_SEMICOLON) { + return; + } + + $tmp = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($tmp + 1), null, true); + if ($tmp !== false && $tokens[$tmp]['code'] === T_SEMICOLON) { + // There is a return . + return; + } + }//end if + }//end if + + $foundContent = true; + + if ($code === T_VARIABLE && isset($params[$token['content']]) === true) { + unset($params[$token['content']]); + } else if ($code === T_DOLLAR) { + $nextToken = $phpcsFile->findNext(T_WHITESPACE, ($next + 1), null, true); + if ($tokens[$nextToken]['code'] === T_OPEN_CURLY_BRACKET) { + $nextToken = $phpcsFile->findNext(T_WHITESPACE, ($nextToken + 1), null, true); + if ($tokens[$nextToken]['code'] === T_STRING) { + $varContent = '$'.$tokens[$nextToken]['content']; + if (isset($params[$varContent]) === true) { + unset($params[$varContent]); + } + } + } + } else if ($code === T_DOUBLE_QUOTED_STRING + || $code === T_START_HEREDOC + || $code === T_START_NOWDOC + ) { + // Tokenize strings that can contain variables. + // Make sure the string is re-joined if it occurs over multiple lines. + $validTokens = array( + T_HEREDOC, + T_NOWDOC, + T_END_HEREDOC, + T_END_NOWDOC, + T_DOUBLE_QUOTED_STRING, + ); + $validTokens = array_merge($validTokens, PHP_CodeSniffer_Tokens::$emptyTokens); + + $content = $token['content']; + for ($i = ($next + 1); $i <= $end; $i++) { + if (in_array($tokens[$i]['code'], $validTokens) === true) { + $content .= $tokens[$i]['content']; + $next++; + } else { + break; + } + } + + $stringTokens = token_get_all(sprintf('', $content)); + foreach ($stringTokens as $stringPtr => $stringToken) { + if (is_array($stringToken) === false) { + continue; + } + + $varContent = ''; + if ($stringToken[0] === T_DOLLAR_OPEN_CURLY_BRACES) { + $varContent = '$'.$stringTokens[($stringPtr + 1)][1]; + } else if ($stringToken[0] === T_VARIABLE) { + $varContent = $stringToken[1]; + } + + if ($varContent !== '' && isset($params[$varContent]) === true) { + unset($params[$varContent]); + } + } + }//end if + }//end for + + if ($foundContent === true && count($params) > 0) { + foreach ($params as $paramName => $position) { + $error = 'The method parameter %s is never used'; + $data = array($paramName); + $phpcsFile->addWarning($error, $position, 'Found', $data); + } + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/UselessOverridingMethodSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/UselessOverridingMethodSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/UselessOverridingMethodSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/UselessOverridingMethodSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,180 @@ + + * @author Manuel Pichler + * @copyright 2007-2008 Manuel Pichler. All rights reserved. + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://pear.php.net/package/PHP_CodeSniffer + */ + +/** + * Detects unnecessary overridden methods that simply call their parent. + * + * This rule is based on the PMD rule catalog. The Useless Overriding Method + * sniff detects the use of methods that only call their parent classes's method + * with the same name and arguments. These methods are not required. + * + * + * class FooBar { + * public function __construct($a, $b) { + * parent::__construct($a, $b); + * } + * } + * + * + * @category PHP + * @package PHP_CodeSniffer + * @author Manuel Pichler + * @copyright 2007-2008 Manuel Pichler. All rights reserved. + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Sniffs_CodeAnalysis_UselessOverridingMethodSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Registers the tokens that this sniff wants to listen for. + * + * @return array(integer) + */ + 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(); + $token = $tokens[$stackPtr]; + + // Skip function without body. + if (isset($token['scope_opener']) === false) { + return; + } + + // Get function name. + $methodName = $phpcsFile->getDeclarationName($stackPtr); + + // Get all parameters from method signature. + $signature = array(); + foreach ($phpcsFile->getMethodParameters($stackPtr) as $param) { + $signature[] = $param['name']; + } + + $next = ++$token['scope_opener']; + $end = --$token['scope_closer']; + + for (; $next <= $end; ++$next) { + $code = $tokens[$next]['code']; + + if (in_array($code, PHP_CodeSniffer_Tokens::$emptyTokens) === true) { + continue; + } else if ($code === T_RETURN) { + continue; + } + + break; + } + + // Any token except 'parent' indicates correct code. + if ($tokens[$next]['code'] !== T_PARENT) { + return; + } + + // Find next non empty token index, should be double colon. + $next = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($next + 1), null, true); + + // Skip for invalid code. + if ($next === false || $tokens[$next]['code'] !== T_DOUBLE_COLON) { + return; + } + + // Find next non empty token index, should be the function name. + $next = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($next + 1), null, true); + + // Skip for invalid code or other method. + if ($next === false || $tokens[$next]['content'] !== $methodName) { + return; + } + + // Find next non empty token index, should be the open parenthesis. + $next = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($next + 1), null, true); + + // Skip for invalid code. + if ($next === false || $tokens[$next]['code'] !== T_OPEN_PARENTHESIS) { + return; + } + + $validParameterTypes = array( + T_VARIABLE, + T_LNUMBER, + T_CONSTANT_ENCAPSED_STRING, + ); + + $parameters = array(''); + $parenthesisCount = 1; + $count = count($tokens); + for (++$next; $next < $count; ++$next) { + $code = $tokens[$next]['code']; + + if ($code === T_OPEN_PARENTHESIS) { + ++$parenthesisCount; + } else if ($code === T_CLOSE_PARENTHESIS) { + --$parenthesisCount; + } else if ($parenthesisCount === 1 && $code === T_COMMA) { + $parameters[] = ''; + } else if (in_array($code, PHP_CodeSniffer_Tokens::$emptyTokens) === false) { + $parameters[(count($parameters) - 1)] .= $tokens[$next]['content']; + } + + if ($parenthesisCount === 0) { + break; + } + }//end for + + $next = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($next + 1), null, true); + if ($next === false || $tokens[$next]['code'] !== T_SEMICOLON) { + return; + } + + // Check rest of the scope. + for (++$next; $next <= $end; ++$next) { + $code = $tokens[$next]['code']; + // Skip for any other content. + if (in_array($code, PHP_CodeSniffer_Tokens::$emptyTokens) === false) { + return; + } + } + + $parameters = array_map('trim', $parameters); + $parameters = array_filter($parameters); + + if (count($parameters) === count($signature) && $parameters === $signature) { + $phpcsFile->addWarning('Useless method overriding detected', $stackPtr, 'Found'); + } + + }//end process() + + +}//end class + +?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Commenting/FixmeSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Commenting/FixmeSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Commenting/FixmeSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Commenting/FixmeSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,92 @@ + + * @author Sam Graham + * @copyright 2006-2012 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 + */ + +/** + * Generic_Sniffs_Commenting_FixmeSniff. + * + * Warns about FIXME comments. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Sam Graham + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Sniffs_Commenting_FixmeSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * A list of tokenizers this sniff supports. + * + * @var array + */ + public $supportedTokenizers = array( + 'PHP', + 'JS', + ); + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return PHP_CodeSniffer_Tokens::$commentTokens; + + }//end register() + + + /** + * Processes this sniff, 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(); + + $content = $tokens[$stackPtr]['content']; + $matches = array(); + if (preg_match('|[^a-z]+fixme[^a-z]+(.*)|i', $content, $matches) !== 0) { + // Clear whitespace and some common characters not required at + // the end of a fixme message to make the error more informative. + $type = 'CommentFound'; + $fixmeMessage = trim($matches[1]); + $fixmeMessage = trim($fixmeMessage, '[]().'); + $error = 'Comment refers to a FIXME task'; + $data = array($fixmeMessage); + if ($fixmeMessage !== '') { + $type = 'TaskFound'; + $error .= ' "%s"'; + } + + $phpcsFile->addError($error, $stackPtr, $type, $data); + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Commenting/TodoSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Commenting/TodoSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Commenting/TodoSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Commenting/TodoSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,90 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Generic_Sniffs_Commenting_TodoSniff. + * + * Warns about TODO comments. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Sniffs_Commenting_TodoSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * A list of tokenizers this sniff supports. + * + * @var array + */ + public $supportedTokenizers = array( + 'PHP', + 'JS', + ); + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return PHP_CodeSniffer_Tokens::$commentTokens; + + }//end register() + + + /** + * Processes this sniff, 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(); + + $content = $tokens[$stackPtr]['content']; + $matches = Array(); + if (preg_match('|[^a-z]+todo[^a-z]+(.*)|i', $content, $matches) !== 0) { + // Clear whitespace and some common characters not required at + // the end of a to-do message to make the warning more informative. + $type = 'CommentFound'; + $todoMessage = trim($matches[1]); + $todoMessage = trim($todoMessage, '[]().'); + $error = 'Comment refers to a TODO task'; + $data = array($todoMessage); + if ($todoMessage !== '') { + $type = 'TaskFound'; + $error .= ' "%s"'; + } + + $phpcsFile->addWarning($error, $stackPtr, $type, $data); + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,120 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Generic_Sniffs_ControlStructures_InlineControlStructureSniff. + * + * Verifies that inline control statements are not present. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Sniffs_ControlStructures_InlineControlStructureSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * A list of tokenizers this sniff supports. + * + * @var array + */ + public $supportedTokenizers = array( + 'PHP', + 'JS', + ); + + /** + * If true, an error will be thrown; otherwise a warning. + * + * @var bool + */ + public $error = true; + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array( + T_IF, + T_ELSE, + T_FOREACH, + T_WHILE, + T_DO, + T_SWITCH, + T_FOR, + ); + + }//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(); + + if (isset($tokens[$stackPtr]['scope_opener']) === false) { + // Ignore the ELSE in ELSE IF. We'll process the IF part later. + if (($tokens[$stackPtr]['code'] === T_ELSE) && ($tokens[($stackPtr + 2)]['code'] === T_IF)) { + return; + } + + if ($tokens[$stackPtr]['code'] === T_WHILE) { + // This could be from a DO WHILE, which doesn't have an opening brace. + $lastContent = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); + if ($tokens[$lastContent]['code'] === T_CLOSE_CURLY_BRACKET) { + $brace = $tokens[$lastContent]; + if (isset($brace['scope_condition']) === true) { + $condition = $tokens[$brace['scope_condition']]; + if ($condition['code'] === T_DO) { + return; + } + } + } + } + + // This is a control structure without an opening brace, + // so it is an inline statement. + if ($this->error === true) { + $phpcsFile->addError('Inline control structures are not allowed', $stackPtr, 'NotAllowed'); + } else { + $phpcsFile->addWarning('Inline control structures are discouraged', $stackPtr, 'Discouraged'); + } + + return; + }//end if + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Debug/CSSLintSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Debug/CSSLintSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Debug/CSSLintSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Debug/CSSLintSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,117 @@ + + * @copyright 2013 Roman Levishchenko + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @link http://pear.php.net/package/PHP_CodeSniffer + */ + +/** + * Generic_Sniffs_Debug_CSSLintSniff. + * + * Runs csslint on the file. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Roman Levishchenko + * @copyright 2013 Roman Levishchenko + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Sniffs_Debug_CSSLintSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * A list of tokenizers this sniff supports. + * + * @var array + */ + public $supportedTokenizers = array('CSS'); + + + /** + * Returns the token types that this sniff is interested in. + * + * @return array(int) + */ + public function register() + { + return array(T_OPEN_TAG); + + }//end 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. + * + * @return void + */ + public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + $fileName = $phpcsFile->getFilename(); + + $csslintPath = PHP_CodeSniffer::getConfigData('csslint_path'); + if ($csslintPath === null) { + return; + } + + $cmd = $csslintPath.' '.escapeshellarg($fileName); + exec($cmd, $output, $retval); + + if (is_array($output) === false) { + return; + } + + $tokens = $phpcsFile->getTokens(); + $count = count($output); + + for ($i = 0; $i < $count; $i++) { + $matches = array(); + $numMatches = preg_match( + '/(error|warning) at line (\d+)/', + $output[$i], + $matches + ); + + if ($numMatches === 0) { + continue; + } + + $line = (int) $matches[2]; + $message = 'csslint says: '.$output[($i + 1)]; + // 1-st line is message with error line and error code. + // 2-nd error message. + // 3-d wrong line in file. + // 4-th empty line. + $i += 4; + + $lineToken = null; + foreach ($tokens as $ptr => $info) { + if ($info['line'] === $line) { + $lineToken = $ptr; + break; + } + } + + if ($lineToken !== null) { + $phpcsFile->addWarning($message, $lineToken, 'ExternalTool'); + } + }//end for + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Debug/ClosureLinterSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Debug/ClosureLinterSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Debug/ClosureLinterSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Debug/ClosureLinterSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,139 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Generic_Sniffs_Debug_ClosureLinterSniff. + * + * Runs gjslint on the file. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Sniffs_Debug_ClosureLinterSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * A list of error codes that should show errors. + * + * All other error codes will show warnings. + * + * @var int + */ + public $errorCodes = array(); + + /** + * A list of error codes to ignore. + * + * @var int + */ + public $ignoreCodes = array(); + + /** + * A list of tokenizers this sniff supports. + * + * @var array + */ + public $supportedTokenizers = array('JS'); + + + /** + * Returns the token types that this sniff is interested in. + * + * @return array(int) + */ + public function register() + { + return array(T_OPEN_TAG); + + }//end 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. + * + * @return void + * @throws PHP_CodeSniffer_Exception If jslint.js could not be run + */ + public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + $fileName = $phpcsFile->getFilename(); + + $lintPath = PHP_CodeSniffer::getConfigData('gjslint_path'); + if ($lintPath === null) { + return; + } + + $cmd = "$lintPath --nosummary --notime --unix_mode \"$fileName\""; + $msg = exec($cmd, $output, $retval); + + if (is_array($output) === false) { + return; + } + + $tokens = $phpcsFile->getTokens(); + + foreach ($output as $finding) { + $matches = array(); + $numMatches = preg_match('/^(.*):([0-9]+):\(.*?([0-9]+)\)(.*)$/', $finding, $matches); + if ($numMatches === 0) { + continue; + } + + // Skip error codes we are ignoring. + $code = $matches[3]; + if (in_array($code, $this->ignoreCodes) === true) { + continue; + } + + $line = (int) $matches[2]; + $error = trim($matches[4]); + + // Find the token at the start of the line. + $lineToken = null; + foreach ($tokens as $ptr => $info) { + if ($info['line'] === $line) { + $lineToken = $ptr; + break; + } + } + + if ($lineToken !== null) { + $message = 'gjslint says: (%s) %s'; + $data = array( + $code, + $error, + ); + if (in_array($code, $this->errorCodes) === true) { + $phpcsFile->addError($message, $lineToken, 'ExternalToolError', $data); + } else { + $phpcsFile->addWarning($message, $lineToken, 'ExternalTool', $data); + } + } + }//end foreach + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Debug/JSHintSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Debug/JSHintSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Debug/JSHintSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Debug/JSHintSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,109 @@ + + * @author Alexander Wei§ + * @copyright 2006-2012 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 + */ + +/** + * Generic_Sniffs_Debug_JSHintSniff. + * + * Runs jshint.js on the file. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Alexander Wei§ + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Sniffs_Debug_JSHintSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * A list of tokenizers this sniff supports. + * + * @var array + */ + public $supportedTokenizers = array('JS'); + + + /** + * Returns the token types that this sniff is interested in. + * + * @return array(int) + */ + public function register() + { + return array(T_OPEN_TAG); + + }//end 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. + * + * @return void + * @throws PHP_CodeSniffer_Exception If jshint.js could not be run + */ + public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + $fileName = $phpcsFile->getFilename(); + + $rhinoPath = PHP_CodeSniffer::getConfigData('rhino_path'); + $jshintPath = PHP_CodeSniffer::getConfigData('jshint_path'); + if ($rhinoPath === null || $jshintPath === null) { + return; + } + + $cmd = "$rhinoPath \"$jshintPath\" \"$fileName\""; + $msg = exec($cmd, $output, $retval); + + if (is_array($output) === true) { + $tokens = $phpcsFile->getTokens(); + + foreach ($output as $finding) { + $matches = array(); + $numMatches = preg_match('/^(.+)\(.+:([0-9]+).*:[0-9]+\)$/', $finding, $matches); + if ($numMatches === 0) { + continue; + } + + $line = (int) $matches[2]; + $message = 'jshint says: '.trim($matches[1]); + + // Find the token at the start of the line. + $lineToken = null; + foreach ($tokens as $ptr => $info) { + if ($info['line'] === $line) { + $lineToken = $ptr; + break; + } + } + + if ($lineToken !== null) { + $phpcsFile->addWarning($message, $lineToken, 'ExternalTool'); + } + }//end foreach + }//end if + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Files/ByteOrderMarkSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Files/ByteOrderMarkSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Files/ByteOrderMarkSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Files/ByteOrderMarkSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,93 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Generic_Sniffs_Files_ByteOrderMarkSniff. + * + * A simple sniff for detecting BOMs that may corrupt application work. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Piotr Karas + * @author Greg Sherwood + * @copyright 2010-2011 mediaSELF Sp. z o.o. + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + * @see http://en.wikipedia.org/wiki/Byte_order_mark + */ +class Generic_Sniffs_Files_ByteOrderMarkSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * List of supported BOM definitions. + * + * Use encoding names as keys and hex BOM representations as values. + * + * @var array + */ + public $bomDefinitions = array( + 'UTF-8' => 'efbbbf', + 'UTF-16 (BE)' => 'feff', + 'UTF-16 (LE)' => 'fffe', + ); + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array(T_INLINE_HTML); + + }//end register() + + + /** + * Processes this sniff, 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 ) + { + // The BOM will be the very first token in the file. + if ($stackPtr !== 0) { + return; + } + + $tokens = $phpcsFile->getTokens(); + + foreach ($this->bomDefinitions as $bomName => $expectedBomHex) { + $bomByteLength = (strlen($expectedBomHex) / 2); + $htmlBomHex = bin2hex(substr($tokens[$stackPtr]['content'], 0, $bomByteLength)); + if ($htmlBomHex === $expectedBomHex) { + $errorData = array($bomName); + $error = 'File contains %s byte order mark, which may corrupt your application'; + $phpcsFile->addError($error, $stackPtr, 'Found', $errorData); + break; + } + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Files/EndFileNewlineSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Files/EndFileNewlineSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Files/EndFileNewlineSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Files/EndFileNewlineSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,95 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Generic_Sniffs_Files_EndFileNewlineSniff. + * + * Ensures the file ends with a newline character. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Sniffs_Files_EndFileNewlineSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * A list of tokenizers this sniff supports. + * + * @var array + */ + public $supportedTokenizers = array( + 'PHP', + 'JS', + 'CSS', + ); + + + /** + * 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 sniff, 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) + { + // We are only interested if this is the first open tag. + if ($stackPtr !== 0) { + if ($phpcsFile->findPrevious(T_OPEN_TAG, ($stackPtr - 1)) !== false) { + return; + } + } + + // Skip to the end of the file. + $tokens = $phpcsFile->getTokens(); + $stackPtr = ($phpcsFile->numTokens - 1); + + if ($phpcsFile->tokenizerType === 'JS') { + $stackPtr--; + } else if ($phpcsFile->tokenizerType === 'CSS') { + $stackPtr -= 2; + } + + $eolCharLen = strlen($phpcsFile->eolChar); + $lastChars = substr($tokens[$stackPtr]['content'], ($eolCharLen * -1)); + if ($lastChars !== $phpcsFile->eolChar) { + $error = 'File must end with a newline character'; + $phpcsFile->addError($error, $stackPtr, 'NotFound'); + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Files/EndFileNoNewlineSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Files/EndFileNoNewlineSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Files/EndFileNoNewlineSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Files/EndFileNoNewlineSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,95 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Generic_Sniffs_Files_EndFileNoNewlineSniff. + * + * Ensures the file does not end with a newline character. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Sniffs_Files_EndFileNoNewlineSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * A list of tokenizers this sniff supports. + * + * @var array + */ + public $supportedTokenizers = array( + 'PHP', + 'JS', + 'CSS', + ); + + + /** + * 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 sniff, 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) + { + // We are only interested if this is the first open tag. + if ($stackPtr !== 0) { + if ($phpcsFile->findPrevious(T_OPEN_TAG, ($stackPtr - 1)) !== false) { + return; + } + } + + // Skip to the end of the file. + $tokens = $phpcsFile->getTokens(); + $stackPtr = ($phpcsFile->numTokens - 1); + + if ($phpcsFile->tokenizerType === 'JS') { + $stackPtr--; + } else if ($phpcsFile->tokenizerType === 'CSS') { + $stackPtr -= 2; + } + + $eolCharLen = strlen($phpcsFile->eolChar); + $lastChars = substr($tokens[$stackPtr]['content'], ($eolCharLen * -1)); + if ($lastChars === $phpcsFile->eolChar) { + $error = 'File must not end with a newline character'; + $phpcsFile->addError($error, $stackPtr, 'Found'); + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Files/LineEndingsSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Files/LineEndingsSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Files/LineEndingsSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Files/LineEndingsSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,115 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Generic_Sniffs_Files_LineEndingsSniff. + * + * Checks that end of line characters are correct. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Sniffs_Files_LineEndingsSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * A list of tokenizers this sniff supports. + * + * @var array + */ + public $supportedTokenizers = array( + 'PHP', + 'JS', + 'CSS', + ); + + /** + * The valid EOL character. + * + * @var string + */ + public $eolChar = '\n'; + + + /** + * 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 sniff, 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) + { + // We are only interested if this is the first open tag. + if ($stackPtr !== 0) { + if ($phpcsFile->findPrevious(T_OPEN_TAG, ($stackPtr - 1)) !== false) { + return; + } + } + + $found = $phpcsFile->eolChar; + $found = str_replace("\n", '\n', $found); + $found = str_replace("\r", '\r', $found); + + if ($found !== $this->eolChar) { + // Check for single line files without an EOL. This is a very special + // case and the EOL char is set to \n when this happens. + if ($found === '\n') { + $tokens = $phpcsFile->getTokens(); + $lastToken = ($phpcsFile->numTokens - 1); + if ($tokens[$lastToken]['line'] === 1 + && $tokens[$lastToken]['content'] !== "\n" + ) { + return; + } + } + + $error = 'End of line character is invalid; expected "%s" but found "%s"'; + $expected = $this->eolChar; + $expected = str_replace("\n", '\n', $expected); + $expected = str_replace("\r", '\r', $expected); + $data = array( + $expected, + $found, + ); + $phpcsFile->addError($error, $stackPtr, 'InvalidEOLChar', $data); + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Files/LineLengthSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Files/LineLengthSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Files/LineLengthSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Files/LineLengthSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,161 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Generic_Sniffs_Files_LineLengthSniff. + * + * Checks all lines in the file, and throws warnings if they are over 80 + * characters in length and errors if they are over 100. Both these + * figures can be changed by extending this sniff in your own standard. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Sniffs_Files_LineLengthSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * The limit that the length of a line should not exceed. + * + * @var int + */ + public $lineLimit = 80; + + /** + * The limit that the length of a line must not exceed. + * + * Set to zero (0) to disable. + * + * @var int + */ + public $absoluteLineLimit = 100; + + + /** + * 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 void + */ + public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + $tokens = $phpcsFile->getTokens(); + + // Make sure this is the first open tag. + $previousOpenTag = $phpcsFile->findPrevious(T_OPEN_TAG, ($stackPtr - 1)); + if ($previousOpenTag !== false) { + return; + } + + $tokenCount = 0; + $currentLineContent = ''; + $currentLine = 1; + + $trim = (strlen($phpcsFile->eolChar) * -1); + for (; $tokenCount < $phpcsFile->numTokens; $tokenCount++) { + if ($tokens[$tokenCount]['line'] === $currentLine) { + $currentLineContent .= $tokens[$tokenCount]['content']; + } else { + $currentLineContent = substr($currentLineContent, 0, $trim); + $this->checkLineLength($phpcsFile, ($tokenCount - 1), $currentLineContent); + $currentLineContent = $tokens[$tokenCount]['content']; + $currentLine++; + } + } + + $currentLineContent = substr($currentLineContent, 0, $trim); + $this->checkLineLength($phpcsFile, ($tokenCount - 1), $currentLineContent); + + }//end process() + + + /** + * Checks if a line is too long. + * + * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. + * @param int $stackPtr The token at the end of the line. + * @param string $lineContent The content of the line. + * + * @return void + */ + protected function checkLineLength(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $lineContent) + { + // If the content is a CVS or SVN id in a version tag, or it is + // a license tag with a name and URL, there is nothing the + // developer can do to shorten the line, so don't throw errors. + if (preg_match('|@version[^\$]+\$Id|', $lineContent) !== 0) { + return; + } + + if (preg_match('|@license|', $lineContent) !== 0) { + return; + } + + if (PHP_CODESNIFFER_ENCODING !== 'iso-8859-1') { + // Not using the detault encoding, so take a bit more care. + $lineLength = iconv_strlen($lineContent, PHP_CODESNIFFER_ENCODING); + if ($lineLength === false) { + // String contained invalid characters, so revert to default. + $lineLength = strlen($lineContent); + } + } else { + $lineLength = strlen($lineContent); + } + + if ($this->absoluteLineLimit > 0 + && $lineLength > $this->absoluteLineLimit + ) { + $data = array( + $this->absoluteLineLimit, + $lineLength, + ); + + $error = 'Line exceeds maximum limit of %s characters; contains %s characters'; + $phpcsFile->addError($error, $stackPtr, 'MaxExceeded', $data); + } else if ($lineLength > $this->lineLimit) { + $data = array( + $this->lineLimit, + $lineLength, + ); + + $warning = 'Line exceeds %s characters; contains %s characters'; + $phpcsFile->addWarning($warning, $stackPtr, 'TooLong', $data); + } + }//end checkLineLength() + + +}//end class + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Files/OneClassPerFileSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Files/OneClassPerFileSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Files/OneClassPerFileSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Files/OneClassPerFileSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,64 @@ + + * @copyright 2010 Andy Grunwald + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @link http://pear.php.net/package/PHP_CodeSniffer + */ + +/** + * Checks that only one class is declared per file. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Andy Grunwald + * @copyright 2010 Andy Grunwald + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Sniffs_Files_OneClassPerFileSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array(T_CLASS); + + }//end register() + + + /** + * Processes this sniff, 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) + { + $nextClass = $phpcsFile->findNext($this->register(), ($stackPtr + 1)); + if ($nextClass !== false) { + $error = 'Only one class is allowed in a file'; + $phpcsFile->addError($error, $nextClass, 'MultipleFound'); + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Files/OneInterfacePerFileSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Files/OneInterfacePerFileSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Files/OneInterfacePerFileSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Files/OneInterfacePerFileSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,64 @@ + + * @copyright 2010 Andy Grunwald + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @link http://pear.php.net/package/PHP_CodeSniffer + */ + +/** + * Checks that only one interface is declared per file. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Andy Grunwald + * @copyright 2010 Andy Grunwald + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Sniffs_Files_OneInterfacePerFileSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array(T_INTERFACE); + + }//end register() + + + /** + * Processes this sniff, 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) + { + $nextInterface = $phpcsFile->findNext($this->register(), ($stackPtr + 1)); + if ($nextInterface !== false) { + $error = 'Only one interface is allowed in a file'; + $phpcsFile->addError($error, $nextInterface, 'MultipleFound'); + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Formatting/DisallowMultipleStatementsSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Formatting/DisallowMultipleStatementsSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Formatting/DisallowMultipleStatementsSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Formatting/DisallowMultipleStatementsSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,88 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Generic_Sniffs_Formatting_DisallowMultipleStatementsSniff. + * + * Ensures each statement is on a line by itself. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Sniffs_Formatting_DisallowMultipleStatementsSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array(T_SEMICOLON); + + }//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(); + + $prev = $phpcsFile->findPrevious(T_SEMICOLON, ($stackPtr - 1)); + if ($prev === false) { + return; + } + + // Ignore multiple statements in a FOR condition. + if (isset($tokens[$stackPtr]['nested_parenthesis']) === true) { + foreach ($tokens[$stackPtr]['nested_parenthesis'] as $bracket) { + if (isset($tokens[$bracket]['parenthesis_owner']) === false) { + // Probably a closure sitting inside a function call. + continue; + } + + $owner = $tokens[$bracket]['parenthesis_owner']; + if ($tokens[$owner]['code'] === T_FOR) { + return; + } + } + } + + if ($tokens[$prev]['line'] === $tokens[$stackPtr]['line']) { + $error = 'Each PHP statement must be on a line by itself'; + $phpcsFile->addError($error, $stackPtr, 'SameLine'); + return; + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,304 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Generic_Sniffs_Formatting_MultipleStatementAlignmentSniff. + * + * Checks alignment of assignments. If there are multiple adjacent assignments, + * it will check that the equals signs of each assignment are aligned. It will + * display a warning to advise that the signs should be aligned. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Sniffs_Formatting_MultipleStatementAlignmentSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * A list of tokenizers this sniff supports. + * + * @var array + */ + public $supportedTokenizers = array( + 'PHP', + 'JS', + ); + + /** + * If true, an error will be thrown; otherwise a warning. + * + * @var bool + */ + public $error = false; + + /** + * The maximum amount of padding before the alignment is ignored. + * + * If the amount of padding required to align this assignment with the + * surrounding assignments exceeds this number, the assignment will be + * ignored and no errors or warnings will be thrown. + * + * @var int + */ + public $maxPadding = 1000; + + /** + * If true, multi-line assignments are not checked. + * + * @var int + */ + public $ignoreMultiLine = false; + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return PHP_CodeSniffer_Tokens::$assignmentTokens; + + }//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(); + + // Ignore assignments used in a condition, like an IF or FOR. + if (isset($tokens[$stackPtr]['nested_parenthesis']) === true) { + foreach ($tokens[$stackPtr]['nested_parenthesis'] as $start => $end) { + if (isset($tokens[$start]['parenthesis_owner']) === true) { + return; + } + } + } + + /* + By this stage, it is known that there is an assignment on this line. + We only want to process the block once we reach the last assignment, + so we need to determine if there are more to follow. + */ + + // The assignment may span over multiple lines, so look for the + // end of the assignment so we can check assignment blocks correctly. + $lineEnd = $phpcsFile->findNext(T_SEMICOLON, ($stackPtr + 1)); + + $nextAssign = $phpcsFile->findNext( + PHP_CodeSniffer_Tokens::$assignmentTokens, + ($lineEnd + 1) + ); + + if ($nextAssign !== false) { + $isAssign = true; + if ($tokens[$nextAssign]['line'] === ($tokens[$lineEnd]['line'] + 1)) { + // Assignment may be in the same block as this one. Just make sure + // it is not used in a condition, like an IF or FOR. + if (isset($tokens[$nextAssign]['nested_parenthesis']) === true) { + foreach ($tokens[$nextAssign]['nested_parenthesis'] as $start => $end) { + if (isset($tokens[$start]['parenthesis_owner']) === true) { + // Not an assignment. + $isAssign = false; + break; + } + } + } + + if ($isAssign === true) { + return; + } + } + } + + // Getting here means that this is the last in a block of statements. + $assignments = array(); + $assignments[] = $stackPtr; + $prevAssignment = $stackPtr; + $lastLine = $tokens[$stackPtr]['line']; + + while (($prevAssignment = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$assignmentTokens, ($prevAssignment - 1))) !== false) { + + // We are not interested in double arrows as they assign values inside + // arrays and loops and do not use the same indentation rules. + if ($tokens[$prevAssignment]['code'] === T_DOUBLE_ARROW) { + continue; + } + + // The assignment's end token must be on the line directly + // above the current one to be in the same assignment block. + $lineEnd = $phpcsFile->findNext(T_SEMICOLON, ($prevAssignment + 1)); + + // And the end token must actually belong to this assignment. + $nextOpener = $phpcsFile->findNext( + PHP_CodeSniffer_Tokens::$scopeOpeners, + ($prevAssignment + 1) + ); + + if ($nextOpener !== false && $nextOpener < $lineEnd) { + break; + } + + if ($tokens[$lineEnd]['line'] !== ($lastLine - 1)) { + break; + } + + // Make sure it is not assigned inside a condition (eg. IF, FOR). + if (isset($tokens[$prevAssignment]['nested_parenthesis']) === true) { + foreach ($tokens[$prevAssignment]['nested_parenthesis'] as $start => $end) { + if (isset($tokens[$start]['parenthesis_owner']) === true) { + break(2); + } + } + } + + $assignments[] = $prevAssignment; + $lastLine = $tokens[$prevAssignment]['line']; + }//end while + + $assignmentData = array(); + $maxAssignmentLength = 0; + $maxVariableLength = 0; + + foreach ($assignments as $assignment) { + $prev = $phpcsFile->findPrevious( + PHP_CodeSniffer_Tokens::$emptyTokens, + ($assignment - 1), + null, + true + ); + + $endColumn = $tokens[($prev + 1)]['column']; + + if ($maxVariableLength < $endColumn) { + $maxVariableLength = $endColumn; + } + + if ($maxAssignmentLength < strlen($tokens[$assignment]['content'])) { + $maxAssignmentLength = strlen($tokens[$assignment]['content']); + } + + $assignmentData[$assignment] + = array( + 'variable_length' => $endColumn, + 'assignment_length' => strlen($tokens[$assignment]['content']), + ); + }//end foreach + + foreach ($assignmentData as $assignment => $data) { + if ($data['assignment_length'] === $maxAssignmentLength) { + if ($data['variable_length'] === $maxVariableLength) { + // The assignment is the longest possible, so the column that + // everything has to align to is based on it. + $column = ($maxVariableLength + 1); + break; + } else { + // The assignment token is the longest out of all of the + // assignments, but the variable name is not, so the column + // the start at can go back more to cover the space + // between the variable name and the assignment operator. + $column = ($maxVariableLength - ($maxAssignmentLength - 1) + 1); + } + } + } + + // Determine the actual position that each equals sign should be in. + foreach ($assignments as $assignment) { + // Actual column takes into account the length of the assignment operator. + $actualColumn = ($column + $maxAssignmentLength - strlen($tokens[$assignment]['content'])); + if ($tokens[$assignment]['column'] !== $actualColumn) { + $prev = $phpcsFile->findPrevious( + PHP_CodeSniffer_Tokens::$emptyTokens, + ($assignment - 1), + null, + true + ); + + $expected = ($actualColumn - $tokens[($prev + 1)]['column']); + + if ($tokens[$assignment]['line'] !== $tokens[$prev]['line']) { + // Instead of working out how many spaces there are + // across new lines, the error message becomes more + // generic below. + $found = null; + } else { + $found = ($tokens[$assignment]['column'] - $tokens[($prev + 1)]['column']); + } + + // If the expected number of spaces for alignment exceeds the + // maxPadding rule, we just check for a single space as no + // alignment is required. + if ($expected > $this->maxPadding) { + if ($found === 1) { + continue; + } else { + $expected = 1; + } + } + + // Skip multi-line assignments if required. + if ($found === null && $this->ignoreMultiLine === true) { + continue; + } + + $expected .= ($expected === 1) ? ' space' : ' spaces'; + if ($found === null) { + $found = 'a new line'; + } else { + $found .= ($found === 1) ? ' space' : ' spaces'; + } + + if (count($assignments) === 1) { + $type = 'Incorrect'; + $error = 'Equals sign not aligned correctly; expected %s but found %s'; + } else { + $type = 'NotSame'; + $error = 'Equals sign not aligned with surrounding assignments; expected %s but found %s'; + } + + $errorData = array( + $expected, + $found, + ); + + if ($this->error === true) { + $phpcsFile->addError($error, $assignment, $type, $errorData); + } else { + $phpcsFile->addWarning($error, $assignment, $type.'Warning', $errorData); + } + }//end if + }//end foreach + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Formatting/NoSpaceAfterCastSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Formatting/NoSpaceAfterCastSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Formatting/NoSpaceAfterCastSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Formatting/NoSpaceAfterCastSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,69 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Generic_Sniffs_Formatting_NoSpaceAfterCastSniff. + * + * Ensures there is no space after cast tokens. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Sniffs_Formatting_NoSpaceAfterCastSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return PHP_CodeSniffer_Tokens::$castTokens; + + }//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(); + + if ($tokens[($stackPtr + 1)]['code'] === T_WHITESPACE) { + $error = 'A cast statement must not be followed by a space'; + $phpcsFile->addError($error, $stackPtr, 'SpaceFound'); + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Formatting/SpaceAfterCastSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Formatting/SpaceAfterCastSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Formatting/SpaceAfterCastSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Formatting/SpaceAfterCastSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,75 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Generic_Sniffs_Formatting_SpaceAfterCastSniff. + * + * Ensures there is a single space after cast tokens. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Sniffs_Formatting_SpaceAfterCastSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return PHP_CodeSniffer_Tokens::$castTokens; + + }//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(); + + if ($tokens[($stackPtr + 1)]['code'] !== T_WHITESPACE) { + $error = 'A cast statement must be followed by a single space'; + $phpcsFile->addError($error, $stackPtr, 'NoSpace'); + return; + } + + if ($tokens[($stackPtr + 1)]['content'] !== ' ') { + $error = 'A cast statement must be followed by a single space'; + $phpcsFile->addError($error, $stackPtr, 'TooMuchSpace'); + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Functions/CallTimePassByReferenceSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Functions/CallTimePassByReferenceSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Functions/CallTimePassByReferenceSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Functions/CallTimePassByReferenceSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,148 @@ + + * @copyright 2009 Florian Grandel + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @link http://pear.php.net/package/PHP_CodeSniffer + */ + +/** + * Generic_Sniffs_Functions_CallTimePassByReferenceSniff. + * + * Ensures that variables are not passed by reference when calling a function. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Florian Grandel + * @copyright 2009 Florian Grandel + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Sniffs_Functions_CallTimePassByReferenceSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array(T_STRING); + + }//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(); + + // Skip tokens that are the names of functions or classes + // within their definitions. For example: function myFunction... + // "myFunction" is T_STRING but we should skip because it is not a + // function or method *call*. + $functionName = $stackPtr; + $findTokens = array_merge( + PHP_CodeSniffer_Tokens::$emptyTokens, + array(T_BITWISE_AND) + ); + + $functionKeyword = $phpcsFile->findPrevious( + $findTokens, + ($stackPtr - 1), + null, + true + ); + + if ($tokens[$functionKeyword]['code'] === T_FUNCTION + || $tokens[$functionKeyword]['code'] === T_CLASS + ) { + return; + } + + // If the next non-whitespace token after the function or method call + // is not an opening parenthesis then it cant really be a *call*. + $openBracket = $phpcsFile->findNext( + PHP_CodeSniffer_Tokens::$emptyTokens, + ($functionName + 1), + null, + true + ); + + if ($tokens[$openBracket]['code'] !== T_OPEN_PARENTHESIS) { + return; + } + + $closeBracket = $tokens[$openBracket]['parenthesis_closer']; + + $nextSeparator = $openBracket; + while (($nextSeparator = $phpcsFile->findNext(T_VARIABLE, ($nextSeparator + 1), $closeBracket)) !== false) { + // Make sure the variable belongs directly to this function call + // and is not inside a nested function call or array. + $brackets = $tokens[$nextSeparator]['nested_parenthesis']; + $lastBracket = array_pop($brackets); + if ($lastBracket !== $closeBracket) { + continue; + } + + // Checking this: $value = my_function(...[*]$arg...). + $tokenBefore = $phpcsFile->findPrevious( + PHP_CodeSniffer_Tokens::$emptyTokens, + ($nextSeparator - 1), + null, + true + ); + + if ($tokens[$tokenBefore]['code'] === T_BITWISE_AND) { + // Checking this: $value = my_function(...[*]&$arg...). + $tokenBefore = $phpcsFile->findPrevious( + PHP_CodeSniffer_Tokens::$emptyTokens, + ($tokenBefore - 1), + null, + true + ); + + // We have to exclude all uses of T_BITWISE_AND that are not + // references. We use a blacklist approach as we prefer false + // positives to not identifying a pass-by-reference call at all. + // The blacklist may not yet be complete. + switch ($tokens[$tokenBefore]['code']) { + case T_VARIABLE: + case T_CLOSE_PARENTHESIS: + case T_LNUMBER: + // In these cases T_BITWISE_AND represents + // the bitwise and operator. + continue; + + default: + // T_BITWISE_AND represents a pass-by-reference. + $error = 'Call-time pass-by-reference calls are prohibited'; + $phpcsFile->addError($error, $tokenBefore, 'NotAllowed'); + break; + } + }//end if + }//end while + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Functions/FunctionCallArgumentSpacingSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Functions/FunctionCallArgumentSpacingSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Functions/FunctionCallArgumentSpacingSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Functions/FunctionCallArgumentSpacingSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,141 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Generic_Sniffs_Functions_FunctionCallArgumentSpacingSniff. + * + * Checks that calls to methods and functions are spaced correctly. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Sniffs_Functions_FunctionCallArgumentSpacingSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array(T_STRING); + + }//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(); + + // Skip tokens that are the names of functions or classes + // within their definitions. For example: + // function myFunction... + // "myFunction" is T_STRING but we should skip because it is not a + // function or method *call*. + $functionName = $stackPtr; + $ignoreTokens = PHP_CodeSniffer_Tokens::$emptyTokens; + $ignoreTokens[] = T_BITWISE_AND; + $functionKeyword = $phpcsFile->findPrevious($ignoreTokens, ($stackPtr - 1), null, true); + if ($tokens[$functionKeyword]['code'] === T_FUNCTION || $tokens[$functionKeyword]['code'] === T_CLASS) { + return; + } + + // If the next non-whitespace token after the function or method call + // is not an opening parenthesis then it cant really be a *call*. + $openBracket = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($functionName + 1), null, true); + if ($tokens[$openBracket]['code'] !== T_OPEN_PARENTHESIS) { + return; + } + + $closeBracket = $tokens[$openBracket]['parenthesis_closer']; + + $nextSeparator = $openBracket; + while (($nextSeparator = $phpcsFile->findNext(array(T_COMMA, T_VARIABLE, T_CLOSURE), ($nextSeparator + 1), $closeBracket)) !== false) { + if ($tokens[$nextSeparator]['code'] === T_CLOSURE) { + $nextSeparator = $tokens[$nextSeparator]['scope_closer']; + continue; + } + + // Make sure the comma or variable belongs directly to this function call, + // and is not inside a nested function call or array. + $brackets = $tokens[$nextSeparator]['nested_parenthesis']; + $lastBracket = array_pop($brackets); + if ($lastBracket !== $closeBracket) { + continue; + } + + if ($tokens[$nextSeparator]['code'] === T_COMMA) { + if ($tokens[($nextSeparator - 1)]['code'] === T_WHITESPACE) { + $error = 'Space found before comma in function call'; + $phpcsFile->addError($error, $stackPtr, 'SpaceBeforeComma'); + } + + if ($tokens[($nextSeparator + 1)]['code'] !== T_WHITESPACE) { + $error = 'No space found after comma in function call'; + $phpcsFile->addError($error, $stackPtr, 'NoSpaceAfterComma'); + } else { + // If there is a newline in the space, then the must be formatting + // each argument on a newline, which is valid, so ignore it. + if (strpos($tokens[($nextSeparator + 1)]['content'], $phpcsFile->eolChar) === false) { + $space = strlen($tokens[($nextSeparator + 1)]['content']); + if ($space > 1) { + $error = 'Expected 1 space after comma in function call; %s found'; + $data = array($space); + $phpcsFile->addError($error, $stackPtr, 'TooMuchSpaceAfterComma', $data); + } + } + } + } else { + // Token is a variable. + $nextToken = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($nextSeparator + 1), $closeBracket, true); + if ($nextToken !== false) { + if ($tokens[$nextToken]['code'] === T_EQUAL) { + if (($tokens[($nextToken - 1)]['code']) !== T_WHITESPACE) { + $error = 'Expected 1 space before = sign of default value'; + $phpcsFile->addError($error, $stackPtr, 'NoSpaceBeforeEquals'); + } + + if ($tokens[($nextToken + 1)]['code'] !== T_WHITESPACE) { + $error = 'Expected 1 space after = sign of default value'; + $phpcsFile->addError($error, $stackPtr, 'NoSpaceAfterEquals'); + } + } + } + }//end if + }//end while + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceBsdAllmanSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceBsdAllmanSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceBsdAllmanSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceBsdAllmanSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,121 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Generic_Sniffs_Functions_OpeningFunctionBraceBsdAllmanSniff. + * + * Checks that the opening brace of a function is on the line after the + * function declaration. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Sniffs_Functions_OpeningFunctionBraceBsdAllmanSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Registers the tokens that this sniff wants to listen for. + * + * @return void + */ + 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(); + + if (isset($tokens[$stackPtr]['scope_opener']) === false) { + return; + } + + $openingBrace = $tokens[$stackPtr]['scope_opener']; + + // The end of the function occurs at the end of the argument list. Its + // like this because some people like to break long function declarations + // over multiple lines. + $functionLine = $tokens[$tokens[$stackPtr]['parenthesis_closer']]['line']; + $braceLine = $tokens[$openingBrace]['line']; + + $lineDifference = ($braceLine - $functionLine); + + if ($lineDifference === 0) { + $error = 'Opening brace should be on a new line'; + $phpcsFile->addError($error, $openingBrace, 'BraceOnSameLine'); + return; + } + + if ($lineDifference > 1) { + $error = 'Opening brace should be on the line after the declaration; found %s blank line(s)'; + $data = array(($lineDifference - 1)); + $phpcsFile->addError($error, $openingBrace, 'BraceSpacing', $data); + return; + } + + // We need to actually find the first piece of content on this line, + // as if this is a method with tokens before it (public, static etc) + // or an if with an else before it, then we need to start the scope + // checking from there, rather than the current token. + $lineStart = $stackPtr; + while (($lineStart = $phpcsFile->findPrevious(array(T_WHITESPACE), ($lineStart - 1), null, false)) !== false) { + if (strpos($tokens[$lineStart]['content'], $phpcsFile->eolChar) !== false) { + break; + } + } + + // We found a new line, now go forward and find the first non-whitespace + // token. + $lineStart = $phpcsFile->findNext(array(T_WHITESPACE), $lineStart, null, true); + + // The opening brace is on the correct line, now it needs to be + // checked to be correctly indented. + $startColumn = $tokens[$lineStart]['column']; + $braceIndent = $tokens[$openingBrace]['column']; + + if ($braceIndent !== $startColumn) { + $error = 'Opening brace indented incorrectly; expected %s spaces, found %s'; + $data = array( + ($startColumn - 1), + ($braceIndent - 1), + ); + $phpcsFile->addError($error, $openingBrace, 'BraceIndent', $data); + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,117 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Generic_Sniffs_Functions_OpeningFunctionBraceKernighanRitchieSniff. + * + * Checks that the opening brace of a function is on the same line + * as the function declaration. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Sniffs_Functions_OpeningFunctionBraceKernighanRitchieSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Registers the tokens that this sniff wants to listen for. + * + * @return void + */ + 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(); + + if (isset($tokens[$stackPtr]['scope_opener']) === false) { + return; + } + + $openingBrace = $tokens[$stackPtr]['scope_opener']; + + // The end of the function occurs at the end of the argument list. Its + // like this because some people like to break long function declarations + // over multiple lines. + $functionLine = $tokens[$tokens[$stackPtr]['parenthesis_closer']]['line']; + $braceLine = $tokens[$openingBrace]['line']; + + $lineDifference = ($braceLine - $functionLine); + + if ($lineDifference > 0) { + $error = 'Opening brace should be on the same line as the declaration'; + $phpcsFile->addError($error, $openingBrace, 'BraceOnNewLine'); + return; + } + + $closeBracket = $tokens[$stackPtr]['parenthesis_closer']; + if ($tokens[($closeBracket + 1)]['code'] !== T_WHITESPACE) { + $length = 0; + } else if ($tokens[($closeBracket + 1)]['content'] === "\t") { + $length = '\t'; + } else { + $length = strlen($tokens[($closeBracket + 1)]['content']); + } + + if ($length !== 1) { + $error = 'Expected 1 space after closing parenthesis; found %s'; + $data = array($length); + $phpcsFile->addError($error, $closeBracket, 'SpaceAfterBracket', $data); + return; + } + + $closeBrace = $tokens[$stackPtr]['scope_opener']; + if ($tokens[($closeBrace - 1)]['code'] !== T_WHITESPACE) { + $length = 0; + } else if ($tokens[($closeBrace - 1)]['content'] === "\t") { + $length = '\t'; + } else { + $length = strlen($tokens[($closeBrace - 1)]['content']); + } + + if ($length !== 1) { + $error = 'Expected 1 space before opening brace; found %s'; + $data = array($length); + $phpcsFile->addError($error, $openingBrace, 'SpaceBeforeBrace', $data); + return; + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Metrics/CyclomaticComplexitySniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Metrics/CyclomaticComplexitySniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Metrics/CyclomaticComplexitySniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Metrics/CyclomaticComplexitySniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,129 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Checks the cyclomatic complexity (McCabe) for functions. + * + * The cyclomatic complexity (also called McCabe code metrics) + * indicates the complexity within a function by counting + * the different paths the function includes. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Johann-Peter Hartmann + * @author Greg Sherwood + * @copyright 2007 Mayflower GmbH + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Sniffs_Metrics_CyclomaticComplexitySniff implements PHP_CodeSniffer_Sniff +{ + + /** + * A complexity higher than this value will throw a warning. + * + * @var int + */ + public $complexity = 10; + + /** + * A complexity higer than this value will throw an error. + * + * @var int + */ + public $absoluteComplexity = 20; + + + /** + * 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) + { + $this->currentFile = $phpcsFile; + + $tokens = $phpcsFile->getTokens(); + + // Ignore abstract methods. + if (isset($tokens[$stackPtr]['scope_opener']) === false) { + return; + } + + // Detect start and end of this function definition. + $start = $tokens[$stackPtr]['scope_opener']; + $end = $tokens[$stackPtr]['scope_closer']; + + // Predicate nodes for PHP. + $find = array( + 'T_CASE', + 'T_DEFAULT', + 'T_CATCH', + 'T_IF', + 'T_FOR', + 'T_FOREACH', + 'T_WHILE', + 'T_DO', + 'T_ELSEIF', + ); + + $complexity = 1; + + // Iterate from start to end and count predicate nodes. + for ($i = ($start + 1); $i < $end; $i++) { + if (in_array($tokens[$i]['type'], $find) === true) { + $complexity++; + } + } + + if ($complexity > $this->absoluteComplexity) { + $error = 'Function\'s cyclomatic complexity (%s) exceeds allowed maximum of %s'; + $data = array( + $complexity, + $this->absoluteComplexity, + ); + $phpcsFile->addError($error, $stackPtr, 'MaxExceeded', $data); + } else if ($complexity > $this->complexity) { + $warning = 'Function\'s cyclomatic complexity (%s) exceeds %s; consider refactoring the function'; + $data = array( + $complexity, + $this->complexity, + ); + $phpcsFile->addWarning($warning, $stackPtr, 'TooHigh', $data); + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Metrics/NestingLevelSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Metrics/NestingLevelSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Metrics/NestingLevelSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Metrics/NestingLevelSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,114 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Checks the nesting level for methods. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Johann-Peter Hartmann + * @author Greg Sherwood + * @copyright 2007 Mayflower GmbH + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Sniffs_Metrics_NestingLevelSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * A nesting level than this value will throw a warning. + * + * @var int + */ + public $nestingLevel = 5; + + /** + * A nesting level than this value will throw an error. + * + * @var int + */ + public $absoluteNestingLevel = 10; + + + /** + * 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(); + + // Ignore abstract methods. + if (isset($tokens[$stackPtr]['scope_opener']) === false) { + return; + } + + // Detect start and end of this function definition. + $start = $tokens[$stackPtr]['scope_opener']; + $end = $tokens[$stackPtr]['scope_closer']; + + $nestingLevel = 0; + + // Find the maximum nesting level of any token in the function. + for ($i = ($start + 1); $i < $end; $i++) { + $level = $tokens[$i]['level']; + if ($nestingLevel < $level) { + $nestingLevel = $level; + } + } + + // We subtract the nesting level of the function itself. + $nestingLevel = ($nestingLevel - $tokens[$stackPtr]['level'] - 1); + + if ($nestingLevel > $this->absoluteNestingLevel) { + $error = 'Function\'s nesting level (%s) exceeds allowed maximum of %s'; + $data = array( + $nestingLevel, + $this->absoluteNestingLevel, + ); + $phpcsFile->addError($error, $stackPtr, 'MaxExceeded', $data); + } else if ($nestingLevel > $this->nestingLevel) { + $warning = 'Function\'s nesting level (%s) exceeds %s; consider refactoring the function'; + $data = array( + $nestingLevel, + $this->nestingLevel, + ); + $phpcsFile->addWarning($warning, $stackPtr, 'TooHigh', $data); + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/NamingConventions/CamelCapsFunctionNameSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/NamingConventions/CamelCapsFunctionNameSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/NamingConventions/CamelCapsFunctionNameSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/NamingConventions/CamelCapsFunctionNameSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,210 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +if (class_exists('PHP_CodeSniffer_Standards_AbstractScopeSniff', true) === false) { + throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_Standards_AbstractScopeSniff not found'); +} + +/** + * Generic_Sniffs_NamingConventions_CamelCapsFunctionNameSniff. + * + * Ensures method names are correct depending on whether they are public + * or private, and that functions are named correctly. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Sniffs_NamingConventions_CamelCapsFunctionNameSniff extends PHP_CodeSniffer_Standards_AbstractScopeSniff +{ + + /** + * A list of all PHP magic methods. + * + * @var array + */ + protected $magicMethods = array( + 'construct', + 'destruct', + 'call', + 'callstatic', + 'get', + 'set', + 'isset', + 'unset', + 'sleep', + 'wakeup', + 'tostring', + 'set_state', + 'clone', + 'invoke', + 'call', + ); + + /** + * A list of all PHP non-magic methods starting with a double underscore. + * + * These come from PHP modules such as SOAPClient. + * + * @var array + */ + protected $methodsDoubleUnderscore = array( + 'soapcall', + 'getlastrequest', + 'getlastresponse', + 'getlastrequestheaders', + 'getlastresponseheaders', + 'getfunctions', + 'gettypes', + 'dorequest', + 'setcookie', + 'setlocation', + 'setsoapheaders', + ); + + /** + * A list of all PHP magic functions. + * + * @var array + */ + protected $magicFunctions = array('autoload'); + + /** + * If TRUE, the string must not have two capital letters next to each other. + * + * @var bool + */ + public $strict = true; + + + /** + * Constructs a Generic_Sniffs_NamingConventions_CamelCapsFunctionNameSniff. + */ + public function __construct() + { + parent::__construct(array(T_CLASS, T_INTERFACE, T_TRAIT), array(T_FUNCTION), true); + + }//end __construct() + + + /** + * Processes the tokens within the scope. + * + * @param PHP_CodeSniffer_File $phpcsFile The file being processed. + * @param int $stackPtr The position where this token was + * found. + * @param int $currScope The position of the current scope. + * + * @return void + */ + protected function processTokenWithinScope(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $currScope) + { + $methodName = $phpcsFile->getDeclarationName($stackPtr); + if ($methodName === null) { + // Ignore closures. + return; + } + + $className = $phpcsFile->getDeclarationName($currScope); + $errorData = array($className.'::'.$methodName); + + // Is this a magic method. i.e., is prefixed with "__" ? + if (preg_match('|^__|', $methodName) !== 0) { + $magicPart = strtolower(substr($methodName, 2)); + if (in_array($magicPart, array_merge($this->magicMethods, $this->methodsDoubleUnderscore)) === false) { + $error = 'Method name "%s" is invalid; only PHP magic methods should be prefixed with a double underscore'; + $phpcsFile->addError($error, $stackPtr, 'MethodDoubleUnderscore', $errorData); + } + + return; + } + + // PHP4 constructors are allowed to break our rules. + if ($methodName === $className) { + return; + } + + // PHP4 destructors are allowed to break our rules. + if ($methodName === '_'.$className) { + return; + } + + $methodProps = $phpcsFile->getMethodProperties($stackPtr); + if (PHP_CodeSniffer::isCamelCaps($methodName, false, true, $this->strict) === false) { + if ($methodProps['scope_specified'] === true) { + $error = '%s method name "%s" is not in camel caps format'; + $data = array( + ucfirst($methodProps['scope']), + $errorData[0], + ); + $phpcsFile->addError($error, $stackPtr, 'ScopeNotCamelCaps', $data); + } else { + $error = 'Method name "%s" is not in camel caps format'; + $phpcsFile->addError($error, $stackPtr, 'NotCamelCaps', $errorData); + } + + return; + } + + }//end processTokenWithinScope() + + + /** + * Processes the tokens outside the scope. + * + * @param PHP_CodeSniffer_File $phpcsFile The file being processed. + * @param int $stackPtr The position where this token was + * found. + * + * @return void + */ + protected function processTokenOutsideScope(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + $functionName = $phpcsFile->getDeclarationName($stackPtr); + if ($functionName === null) { + // Ignore closures. + return; + } + + $errorData = array($functionName); + + // Is this a magic function. i.e., it is prefixed with "__". + if (preg_match('|^__|', $functionName) !== 0) { + $magicPart = strtolower(substr($functionName, 2)); + if (in_array($magicPart, $this->magicFunctions) === false) { + $error = 'Function name "%s" is invalid; only PHP magic methods should be prefixed with a double underscore'; + $phpcsFile->addError($error, $stackPtr, 'FunctionDoubleUnderscore', $errorData); + } + + return; + } + + if (PHP_CodeSniffer::isCamelCaps($functionName, false, true, $this->strict) === false) { + $error = 'Function name "%s" is not in camel caps format'; + $phpcsFile->addError($error, $stackPtr, 'NotCamelCaps', $errorData); + } + + + }//end processTokenOutsideScope() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/NamingConventions/ConstructorNameSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/NamingConventions/ConstructorNameSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/NamingConventions/ConstructorNameSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/NamingConventions/ConstructorNameSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,101 @@ + + * @author Leif Wickland + * @copyright 2006-2012 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 + */ + +if (class_exists('PHP_CodeSniffer_Standards_AbstractScopeSniff', true) === false) { + $error = 'Class PHP_CodeSniffer_Standards_AbstractScopeSniff not found'; + throw new PHP_CodeSniffer_Exception($error); +} + +/** + * Generic_Sniffs_NamingConventions_ConstructorNameSniff. + * + * Favor PHP 5 constructor syntax, which uses "function __construct()". + * Avoid PHP 4 constructor syntax, which uses "function ClassName()". + * + * @category PHP + * @package PHP_CodeSniffer + * @author Leif Wickland + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Sniffs_NamingConventions_ConstructorNameSniff extends PHP_CodeSniffer_Standards_AbstractScopeSniff +{ + + + /** + * Constructs the test with the tokens it wishes to listen for. + * + * @return void + */ + public function __construct() + { + parent::__construct(array(T_CLASS, T_INTERFACE), array(T_FUNCTION), true); + + }//end __construct() + + + /** + * Processes this test when one of its tokens is encountered. + * + * @param PHP_CodeSniffer_File $phpcsFile The current file being scanned. + * @param int $stackPtr The position of the current token + * in the stack passed in $tokens. + * @param int $currScope A pointer to the start of the scope. + * + * @return void + */ + protected function processTokenWithinScope( + PHP_CodeSniffer_File $phpcsFile, + $stackPtr, + $currScope + ) { + $className = $phpcsFile->getDeclarationName($currScope); + $methodName = $phpcsFile->getDeclarationName($stackPtr); + + if (strcasecmp($methodName, $className) === 0) { + $error = 'PHP4 style constructors are not allowed; use "__construct()" instead'; + $phpcsFile->addError($error, $stackPtr, 'OldStyle'); + } else if (strcasecmp($methodName, '__construct') !== 0) { + // Not a constructor. + return; + } + + $tokens = $phpcsFile->getTokens(); + + $parentClassName = $phpcsFile->findExtendedClassName($currScope); + if ($parentClassName === false) { + return; + } + + $endFunctionIndex = $tokens[$stackPtr]['scope_closer']; + $startIndex = $stackPtr; + while ($doubleColonIndex = $phpcsFile->findNext(array(T_DOUBLE_COLON), $startIndex, $endFunctionIndex)) { + if ($tokens[($doubleColonIndex + 1)]['code'] === T_STRING + && $tokens[($doubleColonIndex + 1)]['content'] === $parentClassName + ) { + $error = 'PHP4 style calls to parent constructors are not allowed; use "parent::__construct()" instead'; + $phpcsFile->addError($error, ($doubleColonIndex + 1), 'OldStyleCall'); + } + + $startIndex = ($doubleColonIndex + 1); + } + + }//end processTokenWithinScope() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,226 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Generic_Sniffs_NamingConventions_UpperCaseConstantNameSniff. + * + * Ensures that constant names are all uppercase. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Sniffs_NamingConventions_UpperCaseConstantNameSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array(T_STRING); + + }//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(); + $constName = $tokens[$stackPtr]['content']; + + // If this token is in a heredoc, ignore it. + if ($phpcsFile->hasCondition($stackPtr, T_START_HEREDOC) === true) { + return; + } + + // Special case for PHPUnit. + if ($constName === 'PHPUnit_MAIN_METHOD') { + return; + } + + // If the next non-whitespace token after this token + // is not an opening parenthesis then it is not a function call. + $openBracket = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); + if ($tokens[$openBracket]['code'] !== T_OPEN_PARENTHESIS) { + $functionKeyword = $phpcsFile->findPrevious( + array(T_WHITESPACE, T_COMMA, T_COMMENT, T_STRING, T_NS_SEPARATOR), + ($stackPtr - 1), + null, + true + ); + + $declarations = array( + T_FUNCTION, + T_CLASS, + T_INTERFACE, + T_TRAIT, + T_IMPLEMENTS, + T_EXTENDS, + T_INSTANCEOF, + T_NEW, + T_NAMESPACE, + T_USE, + T_AS, + T_GOTO, + T_INSTEADOF, + ); + + if (in_array($tokens[$functionKeyword]['code'], $declarations) === true) { + // This is just a declaration; no constants here. + return; + } + + if ($tokens[$functionKeyword]['code'] === T_CONST) { + // This is a class constant. + if (strtoupper($constName) !== $constName) { + $error = 'Class constants must be uppercase; expected %s but found %s'; + $data = array( + strtoupper($constName), + $constName, + ); + $phpcsFile->addError($error, $stackPtr, 'ClassConstantNotUpperCase', $data); + } + + return; + } + + // Is this a class name? + $nextPtr = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); + if ($tokens[$nextPtr]['code'] === T_DOUBLE_COLON) { + return; + } + + // Is this a namespace name? + if ($tokens[$nextPtr]['code'] === T_NS_SEPARATOR) { + return; + } + + // Is this an insteadof name? + if ($tokens[$nextPtr]['code'] === T_INSTEADOF) { + return; + } + + // Is this a type hint? + if ($tokens[$nextPtr]['code'] === T_VARIABLE + || $phpcsFile->isReference($nextPtr) === true + ) { + return; + } + + // Is this a member var name? + $prevPtr = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); + if ($tokens[$prevPtr]['code'] === T_OBJECT_OPERATOR) { + return; + } + + // Is this a variable name, in the form ${varname} ? + if ($tokens[$prevPtr]['code'] === T_OPEN_CURLY_BRACKET) { + $nextPtr = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); + if ($tokens[$nextPtr]['code'] === T_CLOSE_CURLY_BRACKET) { + return; + } + } + + // Is this a namespace name? + if ($tokens[$prevPtr]['code'] === T_NS_SEPARATOR) { + return; + } + + // Is this an instance of declare() + $prevPtrDeclare = $phpcsFile->findPrevious(array(T_WHITESPACE, T_OPEN_PARENTHESIS), ($stackPtr - 1), null, true); + if ($tokens[$prevPtrDeclare]['code'] === T_DECLARE) { + return; + } + + // Is this a goto label target? + if ($tokens[$nextPtr]['code'] === T_COLON) { + if (in_array($tokens[$prevPtr]['code'], array(T_SEMICOLON, T_OPEN_CURLY_BRACKET, T_COLON), true)) { + return; + } + } + + // This is a real constant. + if (strtoupper($constName) !== $constName) { + $error = 'Constants must be uppercase; expected %s but found %s'; + $data = array( + strtoupper($constName), + $constName, + ); + $phpcsFile->addError($error, $stackPtr, 'ConstantNotUpperCase', $data); + } + + } else if (strtolower($constName) === 'define' || strtolower($constName) === 'constant') { + + /* + This may be a "define" or "constant" function call. + */ + + // Make sure this is not a method call. + $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); + if ($tokens[$prev]['code'] === T_OBJECT_OPERATOR + || $tokens[$prev]['code'] === T_DOUBLE_COLON + ) { + return; + } + + // The next non-whitespace token must be the constant name. + $constPtr = $phpcsFile->findNext(T_WHITESPACE, ($openBracket + 1), null, true); + if ($tokens[$constPtr]['code'] !== T_CONSTANT_ENCAPSED_STRING) { + return; + } + + $constName = $tokens[$constPtr]['content']; + + // Check for constants like self::CONSTANT. + $prefix = ''; + $splitPos = strpos($constName, '::'); + if ($splitPos !== false) { + $prefix = substr($constName, 0, ($splitPos + 2)); + $constName = substr($constName, ($splitPos + 2)); + } + + if (strtoupper($constName) !== $constName) { + $error = 'Constants must be uppercase; expected %s but found %s'; + $data = array( + $prefix.strtoupper($constName), + $prefix.$constName, + ); + $phpcsFile->addError($error, $stackPtr, 'ConstantNotUpperCase', $data); + } + }//end if + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/PHP/CharacterBeforePHPOpeningTagSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/PHP/CharacterBeforePHPOpeningTagSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/PHP/CharacterBeforePHPOpeningTagSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/PHP/CharacterBeforePHPOpeningTagSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,63 @@ + + * @copyright 2010 Andy Grunwald + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @link http://pear.php.net/package/PHP_CodeSniffer + */ + +/** + * Checks that the opening PHP tag is the first content in a file. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Andy Grunwald + * @copyright 2010 Andy Grunwald + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Sniffs_PHP_CharacterBeforePHPOpeningTagSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * 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 sniff, 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) + { + if ($stackPtr > 0) { + $error = 'The opening PHP tag must be the first content in the file'; + $phpcsFile->addError($error, $stackPtr, 'Found'); + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/PHP/ClosingPHPTagSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/PHP/ClosingPHPTagSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/PHP/ClosingPHPTagSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/PHP/ClosingPHPTagSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,64 @@ + + * @copyright 2010 Stefano Kowalke + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @link http://pear.php.net/package/PHP_CodeSniffer + */ + +/** + * Checks that the file does not end with a closing tag. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Stefano Kowalke + * @copyright 2010 Stefano Kowalke + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Sniffs_PHP_ClosingPHPTagSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * 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 sniff, 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) + { + $closeTag = $phpcsFile->findNext(T_CLOSE_TAG, $stackPtr); + if ($closeTag === false) { + $error = 'The PHP open tag does not have a corresponding PHP close tag'; + $phpcsFile->addError($error, $stackPtr, 'NotFound'); + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/PHP/DeprecatedFunctionsSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/PHP/DeprecatedFunctionsSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/PHP/DeprecatedFunctionsSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/PHP/DeprecatedFunctionsSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,94 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Generic_Sniffs_PHP_DeprecatedFunctionsSniff. + * + * Discourages the use of deprecated functions that are kept in PHP for + * compatibility with older versions. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Sebastian Bergmann + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Sniffs_PHP_DeprecatedFunctionsSniff extends Generic_Sniffs_PHP_ForbiddenFunctionsSniff +{ + + /** + * A list of forbidden functions with their alternatives. + * + * The value is NULL if no alternative exists. IE, the + * function should just not be used. + * + * @var array(string => string|null) + */ + protected $forbiddenFunctions = array(); + + + /** + * Constructor. + * + * Uses the Reflection API to get a list of deprecated functions. + */ + public function __construct() + { + $functions = get_defined_functions(); + + foreach ($functions['internal'] as $functionName) { + $function = new ReflectionFunction($functionName); + + if ($function->isDeprecated() === true) { + $this->forbiddenFunctions[$functionName] = null; + } + } + + }//end __construct() + + + /** + * Generates the error or warning for this sniff. + * + * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the forbidden function + * in the token array. + * @param string $function The name of the forbidden function. + * @param string $pattern The pattern used for the match. + * + * @return void + */ + protected function addError($phpcsFile, $stackPtr, $function, $pattern=null) + { + $data = array($function); + $error = 'Function %s() has been deprecated'; + $type = 'Deprecated'; + + if ($this->error === true) { + $phpcsFile->addError($error, $stackPtr, $type, $data); + } else { + $phpcsFile->addWarning($error, $stackPtr, $type, $data); + } + + }//end addError() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/PHP/DisallowShortOpenTagSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/PHP/DisallowShortOpenTagSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/PHP/DisallowShortOpenTagSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/PHP/DisallowShortOpenTagSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,85 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Generic_Sniffs_PHP_DisallowShortOpenTagSniff. + * + * Makes sure that shorthand PHP open tags are not used. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Sniffs_PHP_DisallowShortOpenTagSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array( + T_OPEN_TAG, + T_OPEN_TAG_WITH_ECHO, + ); + + }//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(); + $openTag = $tokens[$stackPtr]; + + if ($openTag['content'] === 'addError($error, $stackPtr, 'Found', $data); + } + + if ($openTag['code'] === T_OPEN_TAG_WITH_ECHO) { + $nextVar = $tokens[$phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr + 1), null, true)]; + $error = 'Short PHP opening tag used with echo; expected "addError($error, $stackPtr, 'EchoFound', $data); + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/PHP/ForbiddenFunctionsSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/PHP/ForbiddenFunctionsSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/PHP/ForbiddenFunctionsSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/PHP/ForbiddenFunctionsSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,191 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Generic_Sniffs_PHP_ForbiddenFunctionsSniff. + * + * Discourages the use of alias functions that are kept in PHP for compatibility + * with older versions. Can be used to forbid the use of any function. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Sniffs_PHP_ForbiddenFunctionsSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * A list of forbidden functions with their alternatives. + * + * The value is NULL if no alternative exists. IE, the + * function should just not be used. + * + * @var array(string => string|null) + */ + protected $forbiddenFunctions = array( + 'sizeof' => 'count', + 'delete' => 'unset', + ); + + /** + * A cache of forbidden function names, for faster lookups. + * + * @var array(string) + */ + protected $forbiddenFunctionNames = array(); + + /** + * If true, forbidden functions will be considered regular expressions. + * + * @var bool + */ + protected $patternMatch = false; + + /** + * If true, an error will be thrown; otherwise a warning. + * + * @var bool + */ + public $error = true; + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + // Everyone has had a chance to figure out what forbidden functions + // they want to check for, so now we can cache out the list. + $this->forbiddenFunctionNames = array_keys($this->forbiddenFunctions); + + if ($this->patternMatch === true) { + foreach ($this->forbiddenFunctionNames as $i => $name) { + $this->forbiddenFunctionNames[$i] = '/'.$name.'/i'; + } + } + + return array(T_STRING); + + }//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(); + + $ignore = array( + T_DOUBLE_COLON, + T_OBJECT_OPERATOR, + T_FUNCTION, + T_CONST, + ); + + $prevToken = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); + if (in_array($tokens[$prevToken]['code'], $ignore) === true) { + // Not a call to a PHP function. + return; + } + + $function = strtolower($tokens[$stackPtr]['content']); + $pattern = null; + + if ($this->patternMatch === true) { + $count = 0; + $pattern = preg_replace( + $this->forbiddenFunctionNames, + $this->forbiddenFunctionNames, + $function, + 1, + $count + ); + + if ($count === 0) { + return; + } + + // Remove the pattern delimiters and modifier. + $pattern = substr($pattern, 1, -2); + } else { + if (in_array($function, $this->forbiddenFunctionNames) === false) { + return; + } + } + + $this->addError($phpcsFile, $stackPtr, $function, $pattern); + + }//end process() + + + /** + * Generates the error or warning for this sniff. + * + * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the forbidden function + * in the token array. + * @param string $function The name of the forbidden function. + * @param string $pattern The pattern used for the match. + * + * @return void + */ + protected function addError($phpcsFile, $stackPtr, $function, $pattern=null) + { + $data = array($function); + $error = 'The use of function %s() is '; + if ($this->error === true) { + $type = 'Found'; + $error .= 'forbidden'; + } else { + $type = 'Discouraged'; + $error .= 'discouraged'; + } + + if ($pattern === null) { + $pattern = $function; + } + + if ($this->forbiddenFunctions[$pattern] !== null) { + $type .= 'WithAlternative'; + $data[] = $this->forbiddenFunctions[$pattern]; + $error .= '; use %s() instead'; + } + + if ($this->error === true) { + $phpcsFile->addError($error, $stackPtr, $type, $data); + } else { + $phpcsFile->addWarning($error, $stackPtr, $type, $data); + } + + }//end addError() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/PHP/LowerCaseConstantSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/PHP/LowerCaseConstantSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/PHP/LowerCaseConstantSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/PHP/LowerCaseConstantSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,106 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Generic_Sniffs_PHP_LowerCaseConstantSniff. + * + * Checks that all uses of true, false and null are lowercase. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Sniffs_PHP_LowerCaseConstantSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * A list of tokenizers this sniff supports. + * + * @var array + */ + public $supportedTokenizers = array( + 'PHP', + 'JS', + ); + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array( + T_TRUE, + T_FALSE, + T_NULL, + ); + + }//end register() + + + /** + * Processes this sniff, 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(); + + // Is this a member var name? + $prevPtr = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); + if ($tokens[$prevPtr]['code'] === T_OBJECT_OPERATOR) { + return; + } + + // Is this a class name? + if ($tokens[$prevPtr]['code'] === T_CLASS + || $tokens[$prevPtr]['code'] === T_EXTENDS + || $tokens[$prevPtr]['code'] === T_IMPLEMENTS + ) { + return; + } + + // Class or namespace? + if ($tokens[($stackPtr - 1)]['code'] === T_NS_SEPARATOR) { + return; + } + + $keyword = $tokens[$stackPtr]['content']; + if (strtolower($keyword) !== $keyword) { + $error = 'TRUE, FALSE and NULL must be lowercase; expected "%s" but found "%s"'; + $data = array( + strtolower($keyword), + $keyword, + ); + $phpcsFile->addError($error, $stackPtr, 'Found', $data); + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/PHP/LowerCaseKeywordSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/PHP/LowerCaseKeywordSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/PHP/LowerCaseKeywordSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/PHP/LowerCaseKeywordSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,137 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Generic_Sniffs_PHP_LowerCaseKeywordSniff. + * + * Checks that all PHP keywords are lowercase. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Sniffs_PHP_LowerCaseKeywordSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array( + T_HALT_COMPILER, + T_ABSTRACT, + T_ARRAY, + T_AS, + T_BREAK, + T_CALLABLE, + T_CASE, + T_CATCH, + T_CLASS, + T_CLONE, + T_CONST, + T_CONTINUE, + T_DECLARE, + T_DEFAULT, + T_DO, + T_ECHO, + T_ELSE, + T_ELSEIF, + T_EMPTY, + T_ENDDECLARE, + T_ENDFOR, + T_ENDFOREACH, + T_ENDIF, + T_ENDSWITCH, + T_ENDWHILE, + T_EVAL, + T_EXIT, + T_EXTENDS, + T_FINAL, + T_FINALLY, + T_FOR, + T_FOREACH, + T_FUNCTION, + T_GLOBAL, + T_GOTO, + T_IF, + T_IMPLEMENTS, + T_INCLUDE, + T_INCLUDE_ONCE, + T_INSTANCEOF, + T_INSTEADOF, + T_INTERFACE, + T_ISSET, + T_LIST, + T_LOGICAL_AND, + T_LOGICAL_OR, + T_LOGICAL_XOR, + T_NAMESPACE, + T_NEW, + T_PRINT, + T_PRIVATE, + T_PROTECTED, + T_PUBLIC, + T_REQUIRE, + T_REQUIRE_ONCE, + T_RETURN, + T_STATIC, + T_SWITCH, + T_THROW, + T_TRAIT, + T_TRY, + T_UNSET, + T_USE, + T_VAR, + T_WHILE, + ); + + }//end register() + + + /** + * Processes this sniff, 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(); + $keyword = $tokens[$stackPtr]['content']; + if (strtolower($keyword) !== $keyword) { + $error = 'PHP keywords must be lowercase; expected "%s" but found "%s"'; + $data = array( + strtolower($keyword), + $keyword, + ); + $phpcsFile->addError($error, $stackPtr, 'Found', $data); + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/PHP/NoSilencedErrorsSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/PHP/NoSilencedErrorsSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/PHP/NoSilencedErrorsSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/PHP/NoSilencedErrorsSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,81 @@ + + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @link http://pear.php.net/package/PHP_CodeSniffer + */ + +/** + * Generic_Sniffs_PHP_NoSilencedErrorsSniff. + * + * Throws an error or warning when any code prefixed with an asperand is encountered. + * + * + * if (@in_array($array, $needle)) + * { + * doSomething(); + * } + * + * + * @category PHP + * @package PHP_CodeSniffer + * @author Andy Brockhurst + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Sniffs_PHP_NoSilencedErrorsSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * If true, an error will be thrown; otherwise a warning. + * + * @var bool + */ + public $error = false; + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array(T_ASPERAND); + + }//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) + { + $error = 'Silencing errors is forbidden'; + if ($this->error === true) { + $error = 'Silencing errors is forbidden'; + $phpcsFile->addError($error, $stackPtr, 'Forbidden'); + } else { + $error = 'Silencing errors is discouraged'; + $phpcsFile->addWarning($error, $stackPtr, 'Discouraged'); + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/PHP/SAPIUsageSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/PHP/SAPIUsageSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/PHP/SAPIUsageSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/PHP/SAPIUsageSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,81 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Generic_Sniffs_PHP_SAPIUsageSniff. + * + * Ensures the PHP_SAPI constant is used instead of php_sapi_name(). + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Sniffs_PHP_SAPIUsageSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array(T_STRING); + + }//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(); + + $ignore = array( + T_DOUBLE_COLON, + T_OBJECT_OPERATOR, + T_FUNCTION, + T_CONST, + ); + + $prevToken = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); + if (in_array($tokens[$prevToken]['code'], $ignore) === true) { + // Not a call to a PHP function. + return; + } + + $function = strtolower($tokens[$stackPtr]['content']); + if ($function === 'php_sapi_name') { + $error = 'Use the PHP_SAPI constant instead of calling php_sapi_name()'; + $phpcsFile->addError($error, $stackPtr, 'FunctionFound'); + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/PHP/UpperCaseConstantSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/PHP/UpperCaseConstantSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/PHP/UpperCaseConstantSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/PHP/UpperCaseConstantSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,97 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Generic_Sniffs_PHP_UpperCaseConstantSniff. + * + * Checks that all uses of TRUE, FALSE and NULL are uppercase. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Sniffs_PHP_UpperCaseConstantSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array( + T_TRUE, + T_FALSE, + T_NULL, + ); + + }//end register() + + + /** + * Processes this sniff, 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(); + + // Is this a member var name? + $prevPtr = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); + if ($tokens[$prevPtr]['code'] === T_OBJECT_OPERATOR) { + return; + } + + // Is this a class name? + if ($tokens[$prevPtr]['code'] === T_CLASS + || $tokens[$prevPtr]['code'] === T_EXTENDS + || $tokens[$prevPtr]['code'] === T_IMPLEMENTS + ) { + return; + } + + // Class or namespace? + if ($tokens[($stackPtr - 1)]['code'] === T_NS_SEPARATOR) { + return; + } + + $keyword = $tokens[$stackPtr]['content']; + if (strtoupper($keyword) !== $keyword) { + $error = 'TRUE, FALSE and NULL must be uppercase; expected "%s" but found "%s"'; + $data = array( + strtoupper($keyword), + $keyword, + ); + $phpcsFile->addError($error, $stackPtr, 'Found', $data); + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Strings/UnnecessaryStringConcatSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Strings/UnnecessaryStringConcatSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Strings/UnnecessaryStringConcatSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/Strings/UnnecessaryStringConcatSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,125 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Generic_Sniffs_Strings_UnnecessaryStringConcatSniff. + * + * Checks that two strings are not concatenated together; suggests + * using one string instead. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Sniffs_Strings_UnnecessaryStringConcatSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * A list of tokenizers this sniff supports. + * + * @var array + */ + public $supportedTokenizers = array( + 'PHP', + 'JS', + ); + + /** + * If true, an error will be thrown; otherwise a warning. + * + * @var bool + */ + public $error = true; + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array( + T_STRING_CONCAT, + T_PLUS, + ); + + }//end register() + + + /** + * Processes this sniff, 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) + { + // Work out which type of file this is for. + $tokens = $phpcsFile->getTokens(); + if ($tokens[$stackPtr]['code'] === T_STRING_CONCAT) { + if ($phpcsFile->tokenizerType === 'JS') { + return; + } + } else { + if ($phpcsFile->tokenizerType === 'PHP') { + return; + } + } + + $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); + $next = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); + if ($prev === false || $next === false) { + return; + } + + $stringTokens = PHP_CodeSniffer_Tokens::$stringTokens; + if (in_array($tokens[$prev]['code'], $stringTokens) === true + && in_array($tokens[$next]['code'], $stringTokens) === true + ) { + if ($tokens[$prev]['content'][0] === $tokens[$next]['content'][0]) { + // Before we throw an error for PHP, allow strings to be + // combined if they would have < and ? next to each other because + // this trick is sometimes required in PHP strings. + if ($phpcsFile->tokenizerType === 'PHP') { + $prevChar = substr($tokens[$prev]['content'], -2, 1); + $nextChar = $tokens[$next]['content'][1]; + $combined = $prevChar.$nextChar; + if ($combined === '?'.'>' || $combined === '<'.'?') { + return; + } + } + + $error = 'String concat is not required here; use a single string instead'; + if ($this->error === true) { + $phpcsFile->addError($error, $stackPtr, 'Found'); + } else { + $phpcsFile->addWarning($error, $stackPtr, 'Found'); + } + } + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/VersionControl/SubversionPropertiesSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/VersionControl/SubversionPropertiesSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/VersionControl/SubversionPropertiesSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/VersionControl/SubversionPropertiesSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,206 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Generic_Sniffs_VersionControl_SubversionPropertiesSniff. + * + * Tests that the correct Subversion properties are set. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Jack Bates + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Sniffs_VersionControl_SubversionPropertiesSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * The Subversion properties that should be set. + * + * Key of array is the SVN property and the value is the + * exact value the property should have or NULL if the + * property should just be set but the value is not fixed. + * + * @var array + */ + protected $properties = array( + 'svn:keywords' => 'Author Id Revision', + 'svn:eol-style' => 'native', + ); + + + /** + * 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 void + */ + public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + $tokens = $phpcsFile->getTokens(); + + // Make sure this is the first PHP open tag so we don't process the + // same file twice. + $prevOpenTag = $phpcsFile->findPrevious(T_OPEN_TAG, ($stackPtr - 1)); + if ($prevOpenTag !== false) { + return; + } + + $path = $phpcsFile->getFileName(); + $properties = $this->getProperties($path); + if ($properties === null) { + // Not under version control. + return; + } + + $allProperties = $properties + $this->properties; + foreach ($allProperties as $key => $value) { + if (isset($properties[$key]) === true + && isset($this->properties[$key]) === false + ) { + $error = 'Unexpected Subversion property "%s" = "%s"'; + $data = array( + $key, + $properties[$key], + ); + $phpcsFile->addError($error, $stackPtr, 'Unexpected', $data); + continue; + } + + if (isset($properties[$key]) === false + && isset($this->properties[$key]) === true + ) { + $error = 'Missing Subversion property "%s" = "%s"'; + $data = array( + $key, + $this->properties[$key], + ); + $phpcsFile->addError($error, $stackPtr, 'Missing', $data); + continue; + } + + if ($properties[$key] !== null + && $properties[$key] !== $this->properties[$key] + ) { + $error = 'Subversion property "%s" = "%s" does not match "%s"'; + $data = array( + $key, + $properties[$key], + $this->properties[$key], + ); + $phpcsFile->addError($error, $stackPtr, 'NoMatch', $data); + } + }//end foreach + + }//end process() + + + /** + * Returns the Subversion properties which are actually set on a path. + * + * Returns NULL if the file is not under version control. + * + * @param string $path The path to return Subversion properties on. + * + * @return array + * @throws PHP_CodeSniffer_Exception If Subversion properties file could + * not be opened. + */ + protected function getProperties($path) + { + $properties = array(); + + $paths = array(); + $paths[] = dirname($path).'/.svn/props/'.basename($path).'.svn-work'; + $paths[] = dirname($path).'/.svn/prop-base/'.basename($path).'.svn-base'; + + $foundPath = false; + foreach ($paths as $path) { + if (file_exists($path) === true) { + $foundPath = true; + + $handle = fopen($path, 'r'); + if ($handle === false) { + $error = 'Error opening file; could not get Subversion properties'; + throw new PHP_CodeSniffer_Exception($error); + } + + while (feof($handle) === false) { + // Read a key length line. Might be END, though. + $buffer = trim(fgets($handle)); + + // Check for the end of the hash. + if ($buffer === 'END') { + break; + } + + // Now read that much into a buffer. + $key = fread($handle, substr($buffer, 2)); + + // Suck up extra newline after key data. + fgetc($handle); + + // Read a value length line. + $buffer = trim(fgets($handle)); + + // Now read that much into a buffer. + $length = substr($buffer, 2); + if ($length === '0') { + // Length of value is ZERO characters, so + // value is actually empty. + $value = ''; + } else { + $value = fread($handle, $length); + } + + // Suck up extra newline after value data. + fgetc($handle); + + $properties[$key] = $value; + }//end while + + fclose($handle); + }//end if + }//end foreach + + if ($foundPath === false) { + return null; + } + + return $properties; + + }//end getProperties() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/WhiteSpace/DisallowSpaceIndentSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/WhiteSpace/DisallowSpaceIndentSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/WhiteSpace/DisallowSpaceIndentSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/WhiteSpace/DisallowSpaceIndentSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,86 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Generic_Sniffs_WhiteSpace_DisallowSpaceIndentSniff. + * + * Throws errors if tabs are used for indentation. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Sniffs_WhiteSpace_DisallowSpaceIndentSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * A list of tokenizers this sniff supports. + * + * @var array + */ + public $supportedTokenizers = array( + 'PHP', + 'JS', + 'CSS', + ); + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array(T_WHITESPACE); + + }//end register() + + + /** + * Processes this test, when one of its tokens is encountered. + * + * @param PHP_CodeSniffer_File $phpcsFile All the tokens found in the document. + * @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(); + + // Make sure this is whitespace used for indentation. + $line = $tokens[$stackPtr]['line']; + if ($stackPtr > 0 && $tokens[($stackPtr - 1)]['line'] === $line) { + return; + } + + if (strpos($tokens[$stackPtr]['content'], ' ') !== false) { + // Space are considered ok if they are proceeded by tabs and not followed + // by tabs, as is the case with standard docblock comments. + $error = 'Tabs must be used to indent lines; spaces are not allowed'; + $phpcsFile->addError($error, $stackPtr, 'TabsUsed'); + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/WhiteSpace/DisallowTabIndentSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/WhiteSpace/DisallowTabIndentSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/WhiteSpace/DisallowTabIndentSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/WhiteSpace/DisallowTabIndentSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,86 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Generic_Sniffs_WhiteSpace_DisallowTabIndentSniff. + * + * Throws errors if tabs are used for indentation. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Sniffs_WhiteSpace_DisallowTabIndentSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * A list of tokenizers this sniff supports. + * + * @var array + */ + public $supportedTokenizers = array( + 'PHP', + 'JS', + 'CSS', + ); + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array(T_WHITESPACE); + + }//end register() + + + /** + * Processes this test, when one of its tokens is encountered. + * + * @param PHP_CodeSniffer_File $phpcsFile All the tokens found in the document. + * @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(); + + // Make sure this is whitespace used for indentation. + $line = $tokens[$stackPtr]['line']; + if ($stackPtr > 0 && $tokens[($stackPtr - 1)]['line'] === $line) { + return; + } + + if (strpos($tokens[$stackPtr]['content'], "\t") !== false) { + $error = 'Spaces must be used to indent lines; tabs are not allowed'; + $phpcsFile->addError($error, $stackPtr, 'TabsUsed'); + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,414 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Generic_Sniffs_Whitespace_ScopeIndentSniff. + * + * Checks that control structures are structured correctly, and their content + * is indented correctly. This sniff will throw errors if tabs are used + * for indentation rather than spaces. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Sniffs_WhiteSpace_ScopeIndentSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * The number of spaces code should be indented. + * + * @var int + */ + public $indent = 4; + + /** + * Does the indent need to be exactly right. + * + * If TRUE, indent needs to be exactly $indent spaces. If FALSE, + * indent needs to be at least $indent spaces (but can be more). + * + * @var bool + */ + public $exact = false; + + /** + * List of tokens not needing to be checked for indentation. + * + * Useful to allow Sniffs based on this to easily ignore/skip some + * tokens from verification. For example, inline html sections + * or php open/close tags can escape from here and have their own + * rules elsewhere. + * + * @var array + */ + public $ignoreIndentationTokens = array(); + + /** + * Any scope openers that should not cause an indent. + * + * @var array(int) + */ + protected $nonIndentingScopes = array(); + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return PHP_CodeSniffer_Tokens::$scopeOpeners; + + }//end register() + + + /** + * Processes this test, when one of its tokens is encountered. + * + * @param PHP_CodeSniffer_File $phpcsFile All the tokens found in the document. + * @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(); + + // If this is an inline condition (ie. there is no scope opener), then + // return, as this is not a new scope. + if (isset($tokens[$stackPtr]['scope_opener']) === false) { + return; + } + + if ($tokens[$stackPtr]['code'] === T_ELSE) { + $next = $phpcsFile->findNext( + PHP_CodeSniffer_Tokens::$emptyTokens, + ($stackPtr + 1), + null, + true + ); + + // We will handle the T_IF token in another call to process. + if ($tokens[$next]['code'] === T_IF) { + return; + } + } + + // Find the first token on this line. + $firstToken = $stackPtr; + for ($i = $stackPtr; $i >= 0; $i--) { + // Record the first code token on the line. + if (in_array($tokens[$i]['code'], PHP_CodeSniffer_Tokens::$emptyTokens) === false) { + $firstToken = $i; + } + + // It's the start of the line, so we've found our first php token. + if ($tokens[$i]['column'] === 1) { + break; + } + } + + // Based on the conditions that surround this token, determine the + // indent that we expect this current content to be. + $expectedIndent = $this->calculateExpectedIndent($tokens, $firstToken); + + // Don't process the first token if it is a closure because they have + // different indentation rules as they are often used as function arguments + // for multi-line function calls. But continue to process the content of the + // closure because it should be indented as normal. + if ($tokens[$firstToken]['code'] !== T_CLOSURE + && $tokens[$firstToken]['column'] !== $expectedIndent + ) { + // If the scope opener is a closure but it is not the first token on the + // line, then the first token may be a variable or array index as so + // should not require exact indentation unless the exact member var + // is set to TRUE. + $exact = true; + if ($tokens[$stackPtr]['code'] === T_CLOSURE) { + $exact = $this->exact; + } + + if ($exact === true || $tokens[$firstToken]['column'] < $expectedIndent) { + $error = 'Line indented incorrectly; expected %s spaces, found %s'; + $data = array( + ($expectedIndent - 1), + ($tokens[$firstToken]['column'] - 1), + ); + $phpcsFile->addError($error, $stackPtr, 'Incorrect', $data); + } + }//end if + + $scopeOpener = $tokens[$stackPtr]['scope_opener']; + $scopeCloser = $tokens[$stackPtr]['scope_closer']; + + // Some scopes are expected not to have indents. + if (in_array($tokens[$firstToken]['code'], $this->nonIndentingScopes) === false) { + $indent = ($expectedIndent + $this->indent); + } else { + $indent = $expectedIndent; + } + + $newline = false; + $commentOpen = false; + $inHereDoc = false; + + // Only loop over the content between the opening and closing brace, not + // the braces themselves. + for ($i = ($scopeOpener + 1); $i < $scopeCloser; $i++) { + + // If this token is another scope, skip it as it will be handled by + // another call to this sniff. + if (in_array($tokens[$i]['code'], PHP_CodeSniffer_Tokens::$scopeOpeners) === true) { + if (isset($tokens[$i]['scope_opener']) === true) { + $i = $tokens[$i]['scope_closer']; + + // If the scope closer is followed by a semi-colon, the semi-colon is part + // of the closer and should also be ignored. This most commonly happens with + // CASE statements that end with "break;", where we don't want to stop + // ignoring at the break, but rather at the semi-colon. + $nextToken = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($i + 1), null, true); + if ($tokens[$nextToken]['code'] === T_SEMICOLON) { + $i = $nextToken; + } + } else { + // If this token does not have a scope_opener indice, then + // it's probably an inline scope, so let's skip to the next + // semicolon. Inline scopes include inline if's, abstract + // methods etc. + $nextToken = $phpcsFile->findNext(T_SEMICOLON, $i, $scopeCloser); + if ($nextToken !== false) { + $i = $nextToken; + } + } + + continue; + }//end if + + // If this is a HEREDOC then we need to ignore it as the + // whitespace before the contents within the HEREDOC are + // considered part of the content. + if ($tokens[$i]['code'] === T_START_HEREDOC + || $tokens[$i]['code'] === T_START_NOWDOC + ) { + $inHereDoc = true; + continue; + } else if ($inHereDoc === true) { + if ($tokens[$i]['code'] === T_END_HEREDOC + || $tokens[$i]['code'] === T_END_NOWDOC + ) { + $inHereDoc = false; + } + + continue; + } + + if ($tokens[$i]['column'] === 1) { + // We started a newline. + $newline = true; + } + + if ($newline === true && $tokens[$i]['code'] !== T_WHITESPACE) { + // If we started a newline and we find a token that is not + // whitespace, then this must be the first token on the line that + // must be indented. + $newline = false; + $firstToken = $i; + + $column = $tokens[$firstToken]['column']; + + // Ignore the token for indentation if it's in the ignore list. + if (in_array($tokens[$firstToken]['code'], $this->ignoreIndentationTokens)) { + continue; + } + + // Special case for non-PHP code. + if ($tokens[$firstToken]['code'] === T_INLINE_HTML) { + $trimmedContentLength + = strlen(ltrim($tokens[$firstToken]['content'])); + if ($trimmedContentLength === 0) { + continue; + } + + $contentLength = strlen($tokens[$firstToken]['content']); + $column = ($contentLength - $trimmedContentLength + 1); + } + + // Check to see if this constant string spans multiple lines. + // If so, then make sure that the strings on lines other than the + // first line are indented appropriately, based on their whitespace. + if (in_array($tokens[$firstToken]['code'], PHP_CodeSniffer_Tokens::$stringTokens) === true) { + if (in_array($tokens[($firstToken - 1)]['code'], PHP_CodeSniffer_Tokens::$stringTokens) === true) { + // If we find a string that directly follows another string + // then its just a string that spans multiple lines, so we + // don't need to check for indenting. + continue; + } + } + + // This is a special condition for T_DOC_COMMENT and C-style + // comments, which contain whitespace between each line. + if (in_array($tokens[$firstToken]['code'], PHP_CodeSniffer_Tokens::$commentTokens) === true) { + $content = trim($tokens[$firstToken]['content']); + if (preg_match('|^/\*|', $content) !== 0) { + // Check to see if the end of the comment is on the same line + // as the start of the comment. If it is, then we don't + // have to worry about opening a comment. + if (preg_match('|\*/$|', $content) === 0) { + // We don't have to calculate the column for the + // start of the comment as there is a whitespace + // token before it. + $commentOpen = true; + } + } else if ($commentOpen === true) { + if ($content === '') { + // We are in a comment, but this line has nothing on it + // so let's skip it. + continue; + } + + $contentLength = strlen($tokens[$firstToken]['content']); + $trimmedContentLength + = strlen(ltrim($tokens[$firstToken]['content'])); + + $column = ($contentLength - $trimmedContentLength + 1); + if (preg_match('|\*/$|', $content) !== 0) { + $commentOpen = false; + } + + // We are in a comment, so the indent does not have to + // be exact. The important thing is that the comment opens + // at the correct column and nothing sits closer to the left + // than that opening column. + if ($column > $indent) { + continue; + } + }//end if + }//end if + + // The token at the start of the line, needs to have its' column + // greater than the relative indent we set above. If it is less, + // an error should be shown. + if ($column !== $indent) { + if ($this->exact === true || $column < $indent) { + $type = 'IncorrectExact'; + $error = 'Line indented incorrectly; expected '; + if ($this->exact === false) { + $error .= 'at least '; + $type = 'Incorrect'; + } + + $error .= '%s spaces, found %s'; + $data = array( + ($indent - 1), + ($column - 1), + ); + $phpcsFile->addError($error, $firstToken, $type, $data); + } + }//end if + }//end if + }//end for + + }//end process() + + + /** + * Calculates the expected indent of a token. + * + * Returns the column at which the token should be indented to, so 1 means + * that the token should not be indented at all. + * + * @param array $tokens The stack of tokens for this file. + * @param int $stackPtr The position of the token to get indent for. + * + * @return int + */ + protected function calculateExpectedIndent(array $tokens, $stackPtr) + { + $conditionStack = array(); + + $inParenthesis = false; + if (isset($tokens[$stackPtr]['nested_parenthesis']) === true + && empty($tokens[$stackPtr]['nested_parenthesis']) === false + ) { + $inParenthesis = true; + } + + // Empty conditions array (top level structure). + if (empty($tokens[$stackPtr]['conditions']) === true) { + if ($inParenthesis === true) { + // Wrapped in parenthesis means it is probably in a + // function call (like a closure) so we have to assume indent + // is correct here and someone else will check it more + // carefully in another sniff. + return $tokens[$stackPtr]['column']; + } else { + return 1; + } + } + + $indent = 0; + + $tokenConditions = $tokens[$stackPtr]['conditions']; + foreach ($tokenConditions as $id => $condition) { + // If it's not an indenting scope i.e., it's in our array of + // scopes that don't indent, skip it. + if (in_array($condition, $this->nonIndentingScopes) === true) { + continue; + } + + if ($condition === T_CLOSURE && $inParenthesis === true) { + // Closures cause problems with indents when they are + // used as function arguments because the code inside them + // is not technically inside the function yet, so the indent + // is always off by one. So instead, use the + // indent of the closure as the base value. + $lastContent = $id; + for ($i = ($id - 1); $i > 0; $i--) { + if ($tokens[$i]['line'] !== $tokens[$id]['line']) { + // Changed lines, so the last content we saw is what + // we want. + break; + } + + if (in_array($tokens[$i]['code'], PHP_CodeSniffer_Tokens::$emptyTokens) === false) { + $lastContent = $i; + } + } + + $indent = ($tokens[$lastContent]['column'] - 1); + } + + $indent += $this->indent; + }//end foreach + + // Increase by 1 to indiciate that the code should start at a specific column. + // E.g., code indented 4 spaces should start at column 5. + $indent++; + return $indent; + + }//end calculateExpectedIndent() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Classes/DuplicateClassNameUnitTest.1.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Classes/DuplicateClassNameUnitTest.1.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Classes/DuplicateClassNameUnitTest.1.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Classes/DuplicateClassNameUnitTest.1.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,8 @@ + \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Classes/DuplicateClassNameUnitTest.2.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Classes/DuplicateClassNameUnitTest.2.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Classes/DuplicateClassNameUnitTest.2.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Classes/DuplicateClassNameUnitTest.2.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,4 @@ + \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Classes/DuplicateClassNameUnitTest.3.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Classes/DuplicateClassNameUnitTest.3.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Classes/DuplicateClassNameUnitTest.3.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Classes/DuplicateClassNameUnitTest.3.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,10 @@ + \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Classes/DuplicateClassNameUnitTest.4.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Classes/DuplicateClassNameUnitTest.4.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Classes/DuplicateClassNameUnitTest.4.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Classes/DuplicateClassNameUnitTest.4.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,5 @@ + \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Classes/DuplicateClassNameUnitTest.5.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Classes/DuplicateClassNameUnitTest.5.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Classes/DuplicateClassNameUnitTest.5.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Classes/DuplicateClassNameUnitTest.5.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,8 @@ + \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Classes/DuplicateClassNameUnitTest.6.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Classes/DuplicateClassNameUnitTest.6.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Classes/DuplicateClassNameUnitTest.6.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Classes/DuplicateClassNameUnitTest.6.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,12 @@ + +

some html here

+ + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the DuplicateClassName multi-file sniff. + * + * A multi-file sniff unit test checks a .1.inc and a .2.inc file for expected violations + * of a single coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Tests_Classes_DuplicateClassNameUnitTest 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 array(); + + }//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. + * + * @param string $testFile The name of the file being tested. + * + * @return array(int => int) + */ + public function getWarningList($testFile='') + { + switch ($testFile) { + case 'DuplicateClassNameUnitTest.1.inc': + return array( + 6 => 1, + 7 => 1, + ); + break; + case 'DuplicateClassNameUnitTest.2.inc': + return array( + 2 => 1, + 3 => 1, + ); + break; + case 'DuplicateClassNameUnitTest.5.inc': + return array( + 3 => 1, + 7 => 1, + ); + break; + case 'DuplicateClassNameUnitTest.6.inc': + return array( + 10 => 1, + ); + break; + default: + return array(); + break; + }//end switch + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/EmptyStatementUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/EmptyStatementUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/EmptyStatementUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/EmptyStatementUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,72 @@ +getTraceAsString(); + } +} + +try { + throw Exception('Error...'); +} catch (Exception $e) {} + +try { + throw Exception('Error...'); +} catch (Exception $e) { + // TODO: Handle this exception later :-) +} + +if (true) {} elseif (false) {} \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/EmptyStatementUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/EmptyStatementUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/EmptyStatementUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/EmptyStatementUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,81 @@ + + * @author Manuel Pichler + * @copyright 2007-2008 Manuel Pichler. All rights reserved. + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://pear.php.net/package/PHP_CodeSniffer + */ + +/** + * Unit test class for the EmptyStatement sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Manuel Pichler + * @copyright 2007-2008 Manuel Pichler. All rights reserved. + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Tests_CodeAnalysis_EmptyStatementUnitTest 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 array( + 3 => 1, + 15 => 1, + 17 => 1, + 19 => 1, + 30 => 1, + 35 => 1, + 41 => 1, + 47 => 1, + 52 => 1, + 55 => 1, + 72 => 2, + ); + + }//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 array( + 64 => 1, + 68 => 1, + ); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/ForLoopShouldBeWhileLoopUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/ForLoopShouldBeWhileLoopUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/ForLoopShouldBeWhileLoopUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/ForLoopShouldBeWhileLoopUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,13 @@ +valid();) { + $it->next(); +} + +for (;(($it1->valid() && $foo) || (!$it2->value && ($bar || false)));/*Could be ingored*/) { + $it1->next(); + $it2->next(); +} \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/ForLoopShouldBeWhileLoopUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/ForLoopShouldBeWhileLoopUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/ForLoopShouldBeWhileLoopUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/ForLoopShouldBeWhileLoopUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,69 @@ + + * @author Manuel Pichler + * @copyright 2007-2008 Manuel Pichler. All rights reserved. + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://pear.php.net/package/PHP_CodeSniffer + */ + +/** + * Unit test class for the ForLoopShouldBeWhileLoop sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Manuel Pichler + * @copyright 2007-2008 Manuel Pichler. All rights reserved. + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Tests_CodeAnalysis_ForLoopShouldBeWhileLoopUnitTest 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 array(); + + }//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 array( + 6 => 1, + 10 => 1, + ); + + }//end getWarningList() + + +}//end class + +?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,15 @@ +rewind(); $it->valid(); $it->next()) { + echo $it->current(); +} \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,69 @@ + + * @author Manuel Pichler + * @copyright 2007-2008 Manuel Pichler. All rights reserved. + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://pear.php.net/package/PHP_CodeSniffer + */ + +/** + * Unit test class for the ForLoopWithTestFunctionCall sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Manuel Pichler + * @copyright 2007-2008 Manuel Pichler. All rights reserved. + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Tests_CodeAnalysis_ForLoopWithTestFunctionCallUnitTest 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 array(); + + }//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 array( + 4 => 1, + 13 => 1, + ); + + }//end getWarningList() + + +}//end class + +?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/JumbledIncrementerUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/JumbledIncrementerUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/JumbledIncrementerUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/JumbledIncrementerUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,25 @@ + 3; $i++) { + + } + } +} + +for ($i = 0; $i < 20; $i++) { + for ($j = 0; $j < 5; $j += 2) { + for ($k = 0; $k > 3; $k++) { + + } + } +} + +for ($i = 0; $i < 20; $i++) { + for ($j = 0; $j < 5; $j += 2) { + for ($k = 0; $k > 3; $j++) { + + } + } +} \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/JumbledIncrementerUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/JumbledIncrementerUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/JumbledIncrementerUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/JumbledIncrementerUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,70 @@ + + * @author Manuel Pichler + * @copyright 2007-2008 Manuel Pichler. All rights reserved. + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://pear.php.net/package/PHP_CodeSniffer + */ + +/** + * Unit test class for the JumbledIncrementer sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Manuel Pichler + * @copyright 2007-2008 Manuel Pichler. All rights reserved. + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Tests_CodeAnalysis_JumbledIncrementerUnitTest 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 array(); + + }//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 array( + 3 => 2, + 4 => 1, + 20 => 1, + ); + + }//end getWarningList() + + +}//end class + +?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/UnconditionalIfStatementUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/UnconditionalIfStatementUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/UnconditionalIfStatementUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/UnconditionalIfStatementUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,13 @@ + + * @author Manuel Pichler + * @copyright 2007-2008 Manuel Pichler. All rights reserved. + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://pear.php.net/package/PHP_CodeSniffer + */ + +/** + * Unit test class for the UnconditionalIfStatement sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Manuel Pichler + * @copyright 2007-2008 Manuel Pichler. All rights reserved. + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Tests_CodeAnalysis_UnconditionalIfStatementUnitTest 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 array(); + + }//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 array( + 3 => 1, + 5 => 1, + 7 => 1, + ); + + }//end getWarningList() + + +}//end class + +?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/UnnecessaryFinalModifierUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/UnnecessaryFinalModifierUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/UnnecessaryFinalModifierUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/UnnecessaryFinalModifierUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,24 @@ + + * @author Manuel Pichler + * @copyright 2007-2008 Manuel Pichler. All rights reserved. + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://pear.php.net/package/PHP_CodeSniffer + */ + +/** + * Unit test class for the UnnecessaryFinalModifier sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Manuel Pichler + * @copyright 2007-2008 Manuel Pichler. All rights reserved. + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Tests_CodeAnalysis_UnnecessaryFinalModifierUnitTest 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 array(); + + }//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 array( + 11 => 1, + 14 => 1, + 17 => 1, + ); + + }//end getWarningList() + + +}//end class + +?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,76 @@ + +$parameter +HTML; +} + +print foo( 'PARAMETER' ); +print "\n"; + +function foo($bar) +{ + print "${bar} things\n"; +} + +function bar($x) +{ + return 2 * ${x}; +} \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,69 @@ + + * @author Manuel Pichler + * @copyright 2007-2008 Manuel Pichler. All rights reserved. + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://pear.php.net/package/PHP_CodeSniffer + */ + +/** + * Unit test class for the UnusedFunctionParameter sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Manuel Pichler + * @copyright 2007-2008 Manuel Pichler. All rights reserved. + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Tests_CodeAnalysis_UnusedFunctionParameterUnitTest 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 array(); + + }//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 array( + 3 => 1, + 7 => 1, + ); + + }//end getWarningList() + + +}//end class + +?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/UselessOverridingMethodUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/UselessOverridingMethodUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/UselessOverridingMethodUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/CodeAnalysis/UselessOverridingMethodUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,25 @@ + + * @author Manuel Pichler + * @copyright 2007-2008 Manuel Pichler. All rights reserved. + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://pear.php.net/package/PHP_CodeSniffer + */ + +/** + * Unit test class for the UselessOverridingMethod sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Manuel Pichler + * @copyright 2007-2008 Manuel Pichler. All rights reserved. + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Tests_CodeAnalysis_UselessOverridingMethodUnitTest 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 array(); + + }//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 array( + 4 => 1, + 16 => 1, + ); + + }//end getWarningList() + + +}//end class + +?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Commenting/FixmeUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Commenting/FixmeUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Commenting/FixmeUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Commenting/FixmeUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,22 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Commenting/FixmeUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Commenting/FixmeUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Commenting/FixmeUnitTest.js 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Commenting/FixmeUnitTest.js 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,22 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Commenting/FixmeUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Commenting/FixmeUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Commenting/FixmeUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Commenting/FixmeUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,99 @@ + + * @author Marc McIntyre + * @author Sam Graham + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the Fixme sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @author Sam Graham + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Tests_Commenting_FixmeUnitTest 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='FixmeUnitTest.inc') + { + switch ($testFile) { + case 'FixmeUnitTest.inc': + return array( + 3 => 1, + 7 => 1, + 10 => 1, + 13 => 1, + 16 => 1, + 18 => 1, + 21 => 1, + ); + break; + case 'FixmeUnitTest.js': + return array( + 3 => 1, + 7 => 1, + 10 => 1, + 13 => 1, + 16 => 1, + 18 => 1, + 21 => 1, + ); + break; + default: + return array(); + break; + }//end switch + + }//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. + * + * @param string $testFile The name of the file being tested. + * + * @return array(int => int) + */ + public function getWarningList($testFile='FixmeUnitTest.inc') + { + return array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Commenting/TodoUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Commenting/TodoUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Commenting/TodoUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Commenting/TodoUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,22 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Commenting/TodoUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Commenting/TodoUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Commenting/TodoUnitTest.js 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Commenting/TodoUnitTest.js 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,22 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Commenting/TodoUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Commenting/TodoUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Commenting/TodoUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Commenting/TodoUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,97 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the Todo sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Tests_Commenting_TodoUnitTest 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='TodoUnitTest.inc') + { + return array(); + + }//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. + * + * @param string $testFile The name of the file being tested. + * + * @return array(int => int) + */ + public function getWarningList($testFile='TodoUnitTest.inc') + { + switch ($testFile) { + case 'TodoUnitTest.inc': + return array( + 3 => 1, + 7 => 1, + 10 => 1, + 13 => 1, + 16 => 1, + 18 => 1, + 21 => 1, + ); + break; + case 'TodoUnitTest.js': + return array( + 3 => 1, + 7 => 1, + 10 => 1, + 13 => 1, + 16 => 1, + 18 => 1, + 21 => 1, + ); + break; + default: + return array(); + break; + }//end switch + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,42 @@ + 0; $i--) echo 'hello'; + +while ($something) echo 'hello'; + +do { + $i--; +} while ($something); + +if(true) + $someObject->{$name}; + +if (true) : + $foo = true; +endif; + +while (true) : + $foo = true; +endwhile; + +for ($i; $i > 0; $i--) : + echo 'hello'; +endfor; + +foreach ($array as $element) : + echo 'hello'; +endforeach; + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.js 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.js 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,21 @@ + 0; $i--) echo 'hello'; + +while ($something) echo 'hello'; + +do { + $i--; +} while ($something); + +?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,93 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the InlineControlStructure sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Tests_ControlStructures_InlineControlStructureUnitTest 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='InlineControlStructureUnitTest.inc') + { + switch ($testFile) { + case 'InlineControlStructureUnitTest.inc': + return array( + 3 => 1, + 7 => 1, + 11 => 1, + 13 => 1, + 15 => 1, + 17 => 1, + 23 => 1, + ); + break; + case 'InlineControlStructureUnitTest.js': + return array( + 3 => 1, + 7 => 1, + 11 => 1, + 13 => 1, + 15 => 1, + ); + break; + default: + return array(); + break; + }//end switch + + }//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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,3 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,67 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the ByteOrderMark sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Tests_Files_ByteOrderMarkUnitTest 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 array( + 1 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/EndFileNewlineUnitTest.1.css php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/EndFileNewlineUnitTest.1.css --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/EndFileNewlineUnitTest.1.css 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/EndFileNewlineUnitTest.1.css 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,3 @@ + +#login-container {} + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/EndFileNewlineUnitTest.1.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/EndFileNewlineUnitTest.1.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/EndFileNewlineUnitTest.1.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/EndFileNewlineUnitTest.1.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,3 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the EndFileNewline sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Tests_Files_EndFileNewlineUnitTest 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='') + { + switch ($testFile) { + case 'EndFileNewlineUnitTest.3.inc': + case 'EndFileNewlineUnitTest.3.js': + case 'EndFileNewlineUnitTest.3.css': + return array( + 2 => 1, + ); + break; + default: + return array(); + break; + }//end switch + + }//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. + * + * @param string $testFile The name of the file being tested. + * + * @return array(int => int) + */ + public function getWarningList($testFile='') + { + return array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.1.css php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.1.css --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.1.css 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.1.css 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,3 @@ + +#login-container {} + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.1.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.1.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.1.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.1.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,3 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.2.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.2.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.2.js 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.2.js 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,2 @@ + +alert('hi); diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.3.css php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.3.css --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.3.css 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.3.css 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,2 @@ + +#login-container {} \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.3.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.3.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.3.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.3.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,2 @@ + \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,89 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the EndFileNoNewline sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Tests_Files_EndFileNoNewlineUnitTest 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='') + { + switch ($testFile) { + case 'EndFileNoNewlineUnitTest.1.inc': + case 'EndFileNoNewlineUnitTest.1.css': + case 'EndFileNoNewlineUnitTest.1.js': + case 'EndFileNoNewlineUnitTest.2.inc': + return array( + 3 => 1, + ); + break; + + + case 'EndFileNoNewlineUnitTest.2.css': + case 'EndFileNoNewlineUnitTest.2.js': + return array( + 2 => 1, + ); + break; + default: + return array(); + break; + }//end switch + + }//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. + * + * @param string $testFile The name of the file being tested. + * + * @return array(int => int) + */ + public function getWarningList($testFile='') + { + return array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/LineEndingsUnitTest.css php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/LineEndingsUnitTest.css --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/LineEndingsUnitTest.css 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/LineEndingsUnitTest.css 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,3 @@ +#login-container { + margin-left: -225px; +} diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/LineEndingsUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/LineEndingsUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/LineEndingsUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/LineEndingsUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,7 @@ + + + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/LineEndingsUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/LineEndingsUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/LineEndingsUnitTest.js 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/LineEndingsUnitTest.js 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,2 @@ +alert('hi'); +alert('hi'); diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/LineEndingsUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/LineEndingsUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/LineEndingsUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/LineEndingsUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,69 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the LineEndings sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Tests_Files_LineEndingsUnitTest 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 array( + 1 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/LineLengthUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/LineLengthUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/LineLengthUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/LineLengthUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,54 @@ + +Hellob> + + + + + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the LineLength sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Tests_Files_LineLengthUnitTest 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 array( + 31 => 1, + 34 => 1, + 54 => 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 array( + 9 => 1, + 15 => 1, + 21 => 1, + 24 => 1, + 29 => 1, + 37 => 1, + ); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/OneClassPerFileUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/OneClassPerFileUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/OneClassPerFileUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/OneClassPerFileUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,13 @@ + \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/OneClassPerFileUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/OneClassPerFileUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/OneClassPerFileUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/OneClassPerFileUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,68 @@ + + * @copyright 2010 Andy Grunwald + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @link http://pear.php.net/package/PHP_CodeSniffer + */ + +/** + * Unit test class for the OneClassPerFile sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Andy Grunwald + * @copyright 2010 Andy Grunwald + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Tests_Files_OneClassPerFileUnitTest 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 array( + 6 => 1, + 10 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/OneInterfacePerFileUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/OneInterfacePerFileUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/OneInterfacePerFileUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/OneInterfacePerFileUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,13 @@ + \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/OneInterfacePerFileUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/OneInterfacePerFileUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/OneInterfacePerFileUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Files/OneInterfacePerFileUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,68 @@ + + * @copyright 2010 Andy Grunwald + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @link http://pear.php.net/package/PHP_CodeSniffer + */ + +/** + * Unit test class for the OneInterfacePerFile sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Andy Grunwald + * @copyright 2010 Andy Grunwald + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Tests_Files_OneInterfacePerFileUnitTest 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 array( + 6 => 1, + 10 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Formatting/DisallowMultipleStatementsUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Formatting/DisallowMultipleStatementsUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Formatting/DisallowMultipleStatementsUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Formatting/DisallowMultipleStatementsUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,9 @@ +wizardid = 10; $this->paint(); echo 'x'; +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Formatting/DisallowMultipleStatementsUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Formatting/DisallowMultipleStatementsUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Formatting/DisallowMultipleStatementsUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Formatting/DisallowMultipleStatementsUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,72 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the DisallowMultipleStatements sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Tests_Formatting_DisallowMultipleStatementsUnitTest 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 array( + 2 => 1, + 6 => 1, + 7 => 1, + 8 => 2, + ); + + }//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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,203 @@ +findPrevious(); +$commentEnd = $this->_phpcsFile; +$expected .= '...'; + +// Invalid +$this->okButton = new Button(); +$content = new MyClass(); + + +$GLOBALS['_PEAR_ERRORSTACK_SINGLETON'] = array(); + +class MyClass +{ + const MODE_DEBUG = 'debug'; + const MODE_DEBUG2 = 'debug'; + + $array[$test] = 'anything'; + $var = 'anything'; + + const MODE_DEBUG2 = 'debug'; + $array[$test] = 'anything'; + $var = 'anything'; + $array[($test + 1)] = 'anything'; + $array[($blah + (10 - $test))] = 'anything'; +} + +function myFunction($var=true) +{ + if ($strict === true) { + $length = strlen($string); + $lastCharWasCaps = ($classFormat === false) ? false : true; + + for ($i = 1; $i < $length; $i++) { + $isCaps = (strtoupper($string{$i}) === $string{$i}) ? true : false; + if ($isCaps === true && $lastCharWasCaps === true) { + return false; + } + + $lastCharWasCaps = $isCaps; + } + } +} + +// Valid +for ($i = 0; $i < 10; $i += 2) { + $i = ($i - 1); +} + +// Invalid +foreach ($files as $file) { + $saves[$file] = array(); + $contents = stripslashes(file_get_contents($file)); + list($assetid, $time, $content) = explode("\n", $contents); + $saves[$file]['assetid'] = $assetid; +} + +$i = ($i - 10); +$ip = ($i - 10); +for ($i = 0; $i < 10; $i += 2) { + $i = ($i - 10); +} + +// Valid +$variable = 12; +$var = a_very(long_line('that', 'contains'), + a_bunch('of long', 'parameters'), + 'that_need to be aligned with the equal sign'); +$var2 = 12; + +// Valid +$variable = 12; +$var = 'a very long line of text that contains ' + .$someVar + .' and some other stuff that is too long to fit on one line'; +$var2 = 12; + +// Invalid +$variable = 12; +$var = a_very(long_line('that', 'contains'), + a_bunch('of long', 'parameters'), + 'that_need to be aligned with the equal sign'); +$var2 = 12; + +// Invalid +$variable = 12; +$var = 'a very long line of text that contains ' + .$someVar + .' and some other stuff that is too long to fit on one line'; +$var2 = 12; + +// Valid +$variable = 12; +$var .= 'a very long line of text that contains ' + .$someVar + .' and some other stuff that is too long to fit on one line'; +$var2 = 12; + +// Valid +$variable += 12; +$var .= 'a very long line of text that contains ' + .$someVar + .' and some other stuff that is too long to fit on one line'; +$var2 = 12; + +// Invalid +$variable = 12; +$var .= 'a very long line of text that contains ' + .$someVar + .' and some other stuff that is too long to fit on one line'; +$var2 = 12; + +// Valid +$error = false; +while (list($h, $f) = each($handle)) { + $error = true; +} + +// Valid +$value = false; +function blah ($value = true) { + $value = false; + if ($value === true) { + $value = false; + } +} + +if (TRUE) { + $args = array('foo' => 'foo'); + $res = 'bar'; +} +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.js 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.js 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,93 @@ + + +// Valid +var1 = 'var1'; +var10 = 'var1'; +var100 = 'var1'; +var1000 = 'var1'; + +// Invalid +var1 = 'var1'; +var10 = 'var1'; +var100 = 'var1'; +var1000 = 'var1'; + +// Valid +var1 = 'var1'; +var10 = 'var1'; + +var100 = 'var1'; +var1000 = 'var1'; + +// Invalid +var1 = 'var1'; +var10 = 'var1'; + +var100 = 'var1'; +var1000 = 'var1'; + +// Valid +var1 += 'var1'; +var10 += 'var1'; +var100 += 'var1'; +var1000 += 'var1'; + +// Invalid +var1 += 'var1'; +var10 += 'var1'; +var100 += 'var1'; +var1000 += 'var1'; + +// Valid +var1 = 'var1'; +var10 += 'var1'; +var100 = 'var1'; +var1000 += 'var1'; + +// Invalid +var1 = 'var1'; +var10 += 'var1'; +var100 = 'var1'; +var1000 += 'var1'; + +// Valid +var1 += 'var1'; +var10 += 'var1'; + +var100 += 'var1'; +var1000 += 'var1'; + +// Invalid +var1 += 'var1'; +var10 += 'var1'; + +var100 += 'var1'; +var1000 += 'var1'; + +// Valid +var test = 100; + +// InValid +var test = 100; + +commentStart = phpcsFile.findPrevious(); +commentEnd = this._phpcsFile; +expected += '...'; + +// Invalid +this.okButton = {}; +content = {}; + +var buttonid = [this.id, '-positionFormats-add'].join(''); +var buttonWidget = WidgetStore.get(buttonid); +var spinButtonid = [this.id, '-positionFormats-spinButton'].join(''); +var spinButtonWidget = WidgetStore.get(spinButtonid); +var position = spinButtonWidget.getValue(); +var posForamatsList = WidgetStore.get([self.id, '-positionFormats-list'].join('')); + +dfx.stripTags = function(content, allowedTags) +{ + var match; + var re = 'blah'; +}; + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,134 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the MultipleStatementAlignment sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Tests_Formatting_MultipleStatementAlignmentUnitTest 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 array(); + + }//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. + * + * @param string $testFile The name of the file being tested. + * + * @return array(int => int) + */ + public function getWarningList($testFile='MultipleStatementAlignmentUnitTest.inc') + { + switch ($testFile) { + case 'MultipleStatementAlignmentUnitTest.inc': + return array( + 11 => 1, + 12 => 1, + 23 => 1, + 24 => 1, + 26 => 1, + 27 => 1, + 37 => 1, + 38 => 1, + 48 => 1, + 50 => 1, + 61 => 1, + 62 => 1, + 64 => 1, + 65 => 1, + 71 => 1, + 78 => 1, + 79 => 1, + 86 => 1, + 92 => 1, + 93 => 1, + 94 => 1, + 95 => 1, + 123 => 1, + 124 => 1, + 126 => 1, + 129 => 1, + 154 => 1, + 161 => 1, + 178 => 1, + 179 => 1, + 182 => 1, + ); + break; + case 'MultipleStatementAlignmentUnitTest.js': + return array( + 11 => 1, + 12 => 1, + 23 => 1, + 24 => 1, + 26 => 1, + 27 => 1, + 37 => 1, + 38 => 1, + 48 => 1, + 50 => 1, + 61 => 1, + 62 => 1, + 64 => 1, + 65 => 1, + 71 => 1, + 78 => 1, + 79 => 1, + 81 => 1, + 82 => 1, + 83 => 1, + 85 => 1, + 86 => 1, + ); + break; + default: + return array(); + break; + } + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Formatting/NoSpaceAfterCastUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Formatting/NoSpaceAfterCastUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Formatting/NoSpaceAfterCastUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Formatting/NoSpaceAfterCastUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,47 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Formatting/NoSpaceAfterCastUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Formatting/NoSpaceAfterCastUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Formatting/NoSpaceAfterCastUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Formatting/NoSpaceAfterCastUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,90 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the NoSpaceAfterCast sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Tests_Formatting_NoSpaceAfterCastUnitTest 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 array( + 3 => 1, + 5 => 1, + 7 => 1, + 9 => 1, + 11 => 1, + 13 => 1, + 15 => 1, + 17 => 1, + 19 => 1, + 21 => 1, + 23 => 1, + 25 => 1, + 27 => 1, + 29 => 1, + 31 => 1, + 33 => 1, + 35 => 1, + 37 => 1, + 39 => 1, + 41 => 1, + 43 => 1, + 45 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Formatting/SpaceAfterCastUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Formatting/SpaceAfterCastUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Formatting/SpaceAfterCastUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Formatting/SpaceAfterCastUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,47 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Formatting/SpaceAfterCastUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Formatting/SpaceAfterCastUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Formatting/SpaceAfterCastUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Formatting/SpaceAfterCastUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,90 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the SpaceAfterCast sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Tests_Formatting_SpaceAfterCastUnitTest 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 array( + 4 => 1, + 5 => 1, + 8 => 1, + 9 => 1, + 12 => 1, + 13 => 1, + 16 => 1, + 17 => 1, + 20 => 1, + 21 => 1, + 24 => 1, + 25 => 1, + 28 => 1, + 29 => 1, + 32 => 1, + 33 => 1, + 36 => 1, + 37 => 1, + 40 => 1, + 41 => 1, + 44 => 1, + 45 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Functions/CallTimePassByReferenceUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Functions/CallTimePassByReferenceUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Functions/CallTimePassByReferenceUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Functions/CallTimePassByReferenceUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,22 @@ +myfunc(&$myvar); +$this->myfunc($myvar); + +myclass::myfunc(&$myvar); +myclass::myfunc($myvar); + +while(testfunc($var1, &$var2, $var3, &$var4) === false) { +} + +sprintf("0%o", 0777 & $p); +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Functions/CallTimePassByReferenceUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Functions/CallTimePassByReferenceUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Functions/CallTimePassByReferenceUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Functions/CallTimePassByReferenceUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,72 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the CallTimePassByReference sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Tests_Functions_CallTimePassByReferenceUnitTest 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 array( + 9 => 1, + 12 => 1, + 15 => 1, + 18 => 2, + ); + + }//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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,68 @@ +getArray($one, $two,$three),$this->arrayMap); +$this->error($obj->getCode(),$obj->getMessage(),$obj->getFile(),$obj->getLine()); + +make_foo($string /*the string*/ , true /*test*/); +make_foo($string/*the string*/ , /*test*/ true); +make_foo($string /*the string*/, /*test*/ true); + +class MyClass { + function myFunction() { + blah($foo, "{{$config['host']}}", "{$config}", "hi there{}{}{{{}{}{}}"); + } +} + +// Function definition, not function call, so should be ignored +function &myFunction($arg1=1,$arg2=2) +{ +} + +return array_udiff( + $foo, + $bar, + function($a, $b) { + $foo='bar'; + return $foo; + } +); +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,79 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the FunctionCallArgumentSpacing sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Tests_Functions_FunctionCallArgumentSpacingUnitTest 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 array( + 5 => 1, + 6 => 1, + 7 => 2, + 8 => 1, + 11 => 2, + 12 => 2, + 13 => 3, + 42 => 3, + 43 => 3, + 45 => 1, + 46 => 2, + ); + + }//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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Functions/OpeningFunctionBraceBsdAllmanUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Functions/OpeningFunctionBraceBsdAllmanUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Functions/OpeningFunctionBraceBsdAllmanUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Functions/OpeningFunctionBraceBsdAllmanUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,157 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Functions/OpeningFunctionBraceBsdAllmanUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Functions/OpeningFunctionBraceBsdAllmanUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Functions/OpeningFunctionBraceBsdAllmanUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Functions/OpeningFunctionBraceBsdAllmanUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,87 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the OpeningFunctionBraceBsdAllman sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Tests_Functions_OpeningFunctionBraceBsdAllmanUnitTest 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 array( + 4 => 1, + 13 => 1, + 19 => 1, + 24 => 1, + 30 => 1, + 40 => 1, + 44 => 1, + 50 => 1, + 55 => 1, + 67 => 1, + 78 => 1, + 85 => 1, + 91 => 1, + 98 => 1, + 110 => 1, + 115 => 1, + 122 => 1, + 128 => 1, + 155 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,117 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,81 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the OpeningFunctionBraceKernighanRitchie sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Tests_Functions_OpeningFunctionBraceKernighanRitchieUnitTest 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 array( + 9 => 1, + 13 => 1, + 17 => 1, + 29 => 1, + 33 => 1, + 37 => 1, + 53 => 1, + 58 => 1, + 63 => 1, + 77 => 1, + 82 => 1, + 87 => 1, + 104 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Metrics/CyclomaticComplexityUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Metrics/CyclomaticComplexityUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Metrics/CyclomaticComplexityUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Metrics/CyclomaticComplexityUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,160 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Metrics/CyclomaticComplexityUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Metrics/CyclomaticComplexityUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Metrics/CyclomaticComplexityUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Metrics/CyclomaticComplexityUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,72 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the CyclomaticComplexity sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Tests_Metrics_CyclomaticComplexityUnitTest 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 array( + 116 => 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 array( + 45 => 1, + 72 => 1, + ); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Metrics/NestingLevelUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Metrics/NestingLevelUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Metrics/NestingLevelUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Metrics/NestingLevelUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,102 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Metrics/NestingLevelUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Metrics/NestingLevelUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Metrics/NestingLevelUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Metrics/NestingLevelUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,72 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the NestingLevel sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Tests_Metrics_NestingLevelUnitTest 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 array( + 73 => 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 array( + 27 => 1, + 46 => 1, + ); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/NamingConventions/CamelCapsFunctionNameUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/NamingConventions/CamelCapsFunctionNameUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/NamingConventions/CamelCapsFunctionNameUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/NamingConventions/CamelCapsFunctionNameUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,117 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/NamingConventions/CamelCapsFunctionNameUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/NamingConventions/CamelCapsFunctionNameUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/NamingConventions/CamelCapsFunctionNameUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/NamingConventions/CamelCapsFunctionNameUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,106 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the CamelCapsFunctionName sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Tests_NamingConventions_CamelCapsFunctionNameUnitTest 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() + { + $errors = array( + 10 => 1, + 11 => 1, + 12 => 1, + 13 => 1, + 16 => 1, + 17 => 1, + 20 => 1, + 21 => 1, + 24 => 1, + 25 => 1, + 30 => 1, + 31 => 1, + 50 => 1, + 52 => 1, + 53 => 1, + 57 => 1, + 58 => 1, + 59 => 1, + 60 => 1, + 61 => 1, + 62 => 1, + 63 => 1, + 64 => 1, + 65 => 1, + 66 => 1, + 67 => 1, + 68 => 1, + 69 => 1, + 71 => 1, + 72 => 1, + 73 => 1, + 74 => 1, + ); + + // The trait tests will only work in PHP version where traits exist and + // will throw errors in earlier versions. + if (version_compare(PHP_VERSION, '5.4.0') < 0) { + $errors[95] = 1; + } + + return $errors; + + }//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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,39 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,70 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the ConstructorName sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Tests_NamingConventions_ConstructorNameUnitTest 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 array( + 5 => 1, + 6 => 1, + 11 => 1, + 20 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,134 @@ +define('bar'); +$foo->getBar()->define('foo'); + +// This is allowed as it is required for PHPUnit. +if (PHPUnit_MAIN_METHOD == 'PHP_Shell_AllTests::main') { + PHP_Shell_AllTests::main(); +} + +class ConstTest { + const TESTER = '1'; + public function __construct() { + echo constant('self::TESTER'); + echo constant('self::tester'); + } +} + +class A { + public static function constant($x) {} +} + +A::constant('anything-not-in-uppercase'); + +// goto +goto gotolabel; + +gototarget1: + +function ConstTest() { + gototarget2: +} + +switch($foo) +{ + case $bar: + gototarget3: +} + +$a = 2 * ${x} - ${minus}; + +class Object implements IObject +{ + use TProperties; + use TReflected { + TReflected::reflect insteadof TProperties; + } +} +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,87 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the ValidConstantName sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Tests_NamingConventions_UpperCaseConstantNameUnitTest 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() + { + $errors = array( + 8 => 1, + 10 => 1, + 15 => 1, + 25 => 1, + 26 => 1, + 27 => 1, + 28 => 1, + 29 => 1, + 32 => 1, + 35 => 1, + 100 => 1, + ); + + // The trait insteadof test will only work in PHP version where traits exist + // and will throw errors in earlier versions. + if (version_compare(PHP_VERSION, '5.4.0') < 0) { + $errors[131] = 3; + } + + return $errors; + + }//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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/CharacterBeforePHPOpeningTagUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/CharacterBeforePHPOpeningTagUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/CharacterBeforePHPOpeningTagUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/CharacterBeforePHPOpeningTagUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,9 @@ +Foo + + + + \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/CharacterBeforePHPOpeningTagUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/CharacterBeforePHPOpeningTagUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/CharacterBeforePHPOpeningTagUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/CharacterBeforePHPOpeningTagUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,68 @@ + + * @copyright 2010 Andy Grunwald + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @link http://pear.php.net/package/PHP_CodeSniffer + */ + +/** + * Unit test class for the CharacterBeforePHPOpeningTag sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Andy Grunwald + * @copyright 2010 Andy Grunwald + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Tests_PHP_CharacterBeforePHPOpeningTagUnitTest 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 array( + 2 => 1, + 7 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/ClosingPHPTagUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/ClosingPHPTagUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/ClosingPHPTagUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/ClosingPHPTagUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,10 @@ + +Bold text + +Italic text + + * @copyright 2010 Andy Grunwald + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @link http://pear.php.net/package/PHP_CodeSniffer + */ + +/** + * Unit test class for the ClosingPHPTag sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Andy Grunwald + * @copyright 2010 Andy Grunwald + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Tests_PHP_ClosingPHPTagUnitTest 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 array( + 9 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/DisallowShortOpenTagUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/DisallowShortOpenTagUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/DisallowShortOpenTagUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/DisallowShortOpenTagUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,6 @@ +
+ +Some content here. + + +
diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/DisallowShortOpenTagUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/DisallowShortOpenTagUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/DisallowShortOpenTagUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/DisallowShortOpenTagUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,81 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the DisallowShortOpenTag sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Tests_PHP_DisallowShortOpenTagUnitTest 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() + { + $option = (boolean) ini_get('short_open_tag'); + if ($option === true) { + return array( + 4 => 1, + 5 => 1, + ); + } else if (version_compare(PHP_VERSION, '5.4.0RC1') >= 0) { + // Shorthand echo is always available from PHP 5.4.0 but needed the + // short_open_tag ini var to be set for versions before this. + return array( + 4 => 1, + ); + } + + return array(); + + }//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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/ForbiddenFunctionsUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/ForbiddenFunctionsUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/ForbiddenFunctionsUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/ForbiddenFunctionsUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,22 @@ +sizeof($array); +$size = $class->count($array); +$class->delete($filepath); +$class->unset($filepath); + +function delete() {} +function unset() {} +function sizeof() {} +function count() {} +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/ForbiddenFunctionsUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/ForbiddenFunctionsUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/ForbiddenFunctionsUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/ForbiddenFunctionsUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,70 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the ForbiddenFunctions sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Tests_PHP_ForbiddenFunctionsUnitTest 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 array( + 2 => 1, + 4 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,57 @@ +NULL = 7; + +use Zend\Log\Writer\NULL as NullWriter; +new \Zend\Log\Writer\NULL() + +class True extends Null implements False {} +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.js 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.js 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,14 @@ +if (variable === true) { } +if (variable === TRUE) { } +if (variable === True) { } +variable = True; + +if (variable === false) { } +if (variable === FALSE) { } +if (variable === False) { } +variable = false; + +if (variable === null) { } +if (variable === NULL) { } +if (variable === Null) { } +variable = NULL; diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,101 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the LowerCaseConstant sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Tests_PHP_LowerCaseConstantUnitTest 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='LowerCaseConstantUnitTest.inc') + { + switch ($testFile) { + case 'LowerCaseConstantUnitTest.inc': + return array( + 7 => 1, + 10 => 1, + 15 => 1, + 16 => 1, + 23 => 1, + 26 => 1, + 31 => 1, + 32 => 1, + 39 => 1, + 42 => 1, + 47 => 1, + 48 => 1, + ); + break; + case 'LowerCaseConstantUnitTest.js': + return array( + 2 => 1, + 3 => 1, + 4 => 1, + 7 => 1, + 8 => 1, + 12 => 1, + 13 => 1, + 14 => 1, + ); + break; + default: + return array(); + break; + } + + }//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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/LowerCaseKeywordUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/LowerCaseKeywordUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/LowerCaseKeywordUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/LowerCaseKeywordUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,16 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/LowerCaseKeywordUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/LowerCaseKeywordUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/LowerCaseKeywordUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/LowerCaseKeywordUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,72 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the LowerCaseKeyword sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Tests_PHP_LowerCaseKeywordUnitTest 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 array( + 10 => 3, + 11 => 4, + 12 => 1, + 13 => 3, + 14 => 7, + 15 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/NoSilencedErrorsUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/NoSilencedErrorsUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/NoSilencedErrorsUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/NoSilencedErrorsUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,9 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/NoSilencedErrorsUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/NoSilencedErrorsUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/NoSilencedErrorsUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/NoSilencedErrorsUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,67 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the NoSilencedErrors sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Tests_PHP_NoSilencedErrorsUnitTest 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 array(); + + }//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 array( + 5 => 1, + ); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/SAPIUsageUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/SAPIUsageUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/SAPIUsageUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/SAPIUsageUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,4 @@ +php_sapi_name() === true) {} diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/SAPIUsageUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/SAPIUsageUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/SAPIUsageUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/SAPIUsageUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,67 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the SAPIUsage sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Tests_PHP_SAPIUsageUnitTest 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 array( + 2 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/UpperCaseConstantUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/UpperCaseConstantUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/UpperCaseConstantUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/UpperCaseConstantUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,58 @@ +null = 7; + +use Zend\Log\Writer\Null as NullWriter; +new \Zend\Log\Writer\Null() + +class True extends Null implements False {} + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/UpperCaseConstantUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/UpperCaseConstantUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/UpperCaseConstantUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/PHP/UpperCaseConstantUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,80 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the UpperCaseConstant sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Tests_PHP_UpperCaseConstantUnitTest 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 array( + 7 => 1, + 10 => 1, + 15 => 1, + 16 => 1, + 23 => 1, + 26 => 1, + 31 => 1, + 32 => 1, + 39 => 1, + 42 => 1, + 47 => 1, + 48 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,17 @@ +'; +$code = '<'.'?php '; +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.js 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.js 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,11 @@ +var x = 'My ' + 'string'; +var x = 'My ' + 1234; +var x = 'My ' + y + ' test'; + +this.errors['test'] = x; +this.errors['test' + 10] = x; +this.errors['test' + y] = x; +this.errors['test' + 'blah'] = x; +this.errors[y] = x; +this.errors[y + z] = x; +this.errors[y + z + 'My' + 'String'] = x; diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,86 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the UnnecessaryStringConcat sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Tests_Strings_UnnecessaryStringConcatUnitTest 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='UnnecessaryStringConcatUnitTest.inc') + { + switch ($testFile) { + case 'UnnecessaryStringConcatUnitTest.inc': + return array( + 2 => 1, + 6 => 1, + 9 => 1, + 12 => 1, + ); + break; + case 'UnnecessaryStringConcatUnitTest.js': + return array( + 1 => 1, + 8 => 1, + 11 => 1, + ); + break; + default: + return array(); + break; + } + + }//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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.css php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.css --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.css 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.css 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,4 @@ +#login-container { + margin-left: -225px; + width: 450px; +} diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,36 @@ +"; + return "<$name$xmlns$type_str $atts xsi:nil=\"true\"/>"; +// [space][space][space][tab]return "<$name$xmlns$type_str $atts xsi:nil=\"true\"/>"; + return "<$name$xmlns$type_str $atts xsi:nil=\"true\"/>"; +// Doc comments are indent with tabs and one space +//[tab]/** +//[tab][space]* + /** + * CVS revision for HTTP headers. + * + * @var string + * @access private + */ + /** + * + */ diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.js 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.js 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,9 @@ +var x = { + abc: 1, + zyz: 2, + abc: 5, + mno: { + abc: 4 + }, + abc: 5 +} diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,93 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the DisallowSpaceIndent sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Tests_WhiteSpace_DisallowSpaceIndentUnitTest 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='DisallowSpaceIndentUnitTest.inc') + { + switch ($testFile) { + case 'DisallowSpaceIndentUnitTest.inc': + return array( + 5 => 1, + 9 => 1, + 15 => 1, + 18 => 1, + 19 => 1, + 22 => 1, + 24 => 1, + ); + break; + case 'DisallowSpaceIndentUnitTest.js': + return array( + 3 => 1, + 6 => 1, + ); + break; + case 'DisallowSpaceIndentUnitTest.css': + return array( + 2 => 1, + ); + break; + default: + return array(); + break; + }//end switch + + }//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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.css php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.css --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.css 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.css 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,5 @@ +#login-container { + margin-left: -225px; + width: 450px; +} + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,17 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.js 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.js 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,9 @@ +var x = { + abc: 1, + zyz: 2, + abc: 5, + mno: { + abc: 4 + }, + abc: 5 +} diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,91 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the DisallowTabIndent sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Tests_WhiteSpace_DisallowTabIndentUnitTest 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='DisallowTabIndentUnitTest.inc') + { + switch ($testFile) { + case 'DisallowTabIndentUnitTest.inc': + return array( + 5 => 1, + 9 => 1, + 15 => 1, + ); + break; + case 'DisallowTabIndentUnitTest.js': + return array( + 3 => 1, + 6 => 1, + ); + break; + case 'DisallowTabIndentUnitTest.css': + return array( + 2 => 1, + ); + break; + default: + return array(); + break; + }//end switch + + }//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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,439 @@ +hello(); // error here + } + + function hello() // error here + { // no error here as brackets can be put anywhere in the pear standard + echo 'hello'; + } + + function hello2() + { + if (TRUE) { // error here + echo 'hello'; // no error here as its more than 4 spaces. + } else { + echo 'bye'; // error here + } + + while (TRUE) { + echo 'hello'; // error here + }// no error here as its handled by another test. + + do { // error here + echo 'hello'; // error here + } while (TRUE); // no error here as its aligned with the do. + }// no error here as its handled by another test. + + function hello3() + { + switch ($hello) { + case 'hello': + break; + } + } + +} + +?> +
+
+
+validate()) {
+    $safe = $form->getSubmitValues();
+}
+?>
+
+open(); // error here + } + + public function open() + { + // Some inline stuff that shouldn't error + if (TRUE) echo 'hello'; + foreach ($tokens as $token) echo $token; + } + + /** + * This is a comment 1. + * This is a comment 2. + * This is a comment 3. + * This is a comment 4. + */ + public function close() + { + // All ok. + if (TRUE) { + if (TRUE) { + } else if (FALSE) { + foreach ($tokens as $token) { + switch ($token) { + case '1': + case '2': + if (true) { + if (false) { + if (false) { + if (false) { + echo 'hello'; + } + } + } + } + break; + case '5': + break; + } + do { + while (true) { + foreach ($tokens as $token) { + for ($i = 0; $i < $token; $i++) { + echo 'hello'; + } + } + } + } while (true); + } + } + } + } + + /* + This is another c style comment 1. + This is another c style comment 2. + This is another c style comment 3. + This is another c style comment 4. + This is another c style comment 5. + */ + + /* + * + * + * + */ + + /** + */ + + /* + This comment has a newline in it. + + */ + + public function read() + { + echo 'hello'; + + // no errors below. + $array = array( + 'this', + 'that' => array( + 'hello', + 'hello again' => array( + 'hello', + ), + ), + ); + } +} + +abstract class Test3 +{ + public function parse() + { + + foreach ($t as $ndx => $token) { + if (is_array($token)) { + echo 'here'; + } else { + $ts[] = array("token" => $token, "value" => ''); + + $last = count($ts) - 1; + + switch ($token) { + case '(': + + if ($last >= 3 && + $ts[0]['token'] != T_CLASS && + $ts[$last - 2]['token'] == T_OBJECT_OPERATOR && + $ts[$last - 3]['token'] == T_VARIABLE ) { + + + if (true) { + echo 'hello'; + } + } + array_push($braces, $token); + break; + } + } + } + } +} + +public function test() +{ + $o = << + + + + doSomething( + function () { + echo 123; + } + ); + } +} + +some_function( + function() { + $a = 403; + if ($a === 404) { + $a = 403; + } + } +); + +some_function( + function() { + $a = 403; + if ($a === 404) { + $a = 403; + } + } +); + +$myFunction = function() { + $a = 403; + if ($a === 404) { + $a = 403; + } +} + +class Whatever +{ + protected $_protectedArray = array( + 'normalString' => 'That email address is already in use!', + 'offendingString' => <<<'STRING' +Each line of this string is always said to be at column 0, + no matter how many spaces are placed + at the beginning of each line +and the ending STRING on the next line is reported as having to be indented. +STRING + ); +} + +$var = call_user_func( + $new_var = function () use (&$a) { + if ($a > 0) { + return $a++; + } else { + return $a--; + } + } +); + +class AnonymousFn +{ + public function getAnonFn() + { + return array( + 'functions' => Array( + 'function1' => function ($a, $b, $c) { + $a = $b + $c; + $b = $c / 2; + return Array($a, $b, $c); + }, + ), + ); + } +} +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,92 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the ScopeIndent sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Generic_Tests_WhiteSpace_ScopeIndentUnitTest 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 array( + 7 => 1, + 10 => 1, + 17 => 1, + 20 => 1, + 24 => 1, + 27 => 1, + 28 => 1, + 58 => 1, + 123 => 1, + 126 => 1, + 224 => 1, + 225 => 1, + 279 => 1, + 280 => 1, + 281 => 1, + 282 => 1, + 283 => 1, + 284 => 1, + 311 => 1, + 336 => 1, + 349 => 1, + 380 => 1, + 387 => 1, + 397 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/ruleset.xml php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/ruleset.xml --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/ruleset.xml 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Generic/ruleset.xml 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,4 @@ + + + A collection of generic sniffs. This standard is not designed to be used to check code. + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/IncorrectPatternException.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/IncorrectPatternException.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/IncorrectPatternException.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/IncorrectPatternException.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,35 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * An exception thrown if the pattern being processed is not supposed to be + * validating the code in question. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PHP_CodeSniffer_Standards_IncorrectPatternException extends Exception +{ + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/CSS/BrowserSpecificStylesSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/CSS/BrowserSpecificStylesSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/CSS/BrowserSpecificStylesSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/CSS/BrowserSpecificStylesSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,102 @@ + + * @copyright 2006-2012 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 + */ + +/** + * MySource_Sniffs_CSS_BrowserSpecificStylesSniff. + * + * Ensure that browser-specific styles are not used. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class MySource_Sniffs_CSS_BrowserSpecificStylesSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * A list of tokenizers this sniff supports. + * + * @var array + */ + public $supportedTokenizers = array('CSS'); + + /** + * A list of specific stylesheet suffixes we allow. + * + * These stylesheets contain browser specific styles + * so this sniff ignore them files in the form: + * *_moz.css and *_ie7.css etc. + * + * @var array + */ + protected $specificStylesheets = array( + 'moz', + 'ie', + 'ie7', + 'ie8', + 'webkit', + ); + + + /** + * Returns the token types that this sniff is interested in. + * + * @return array(int) + */ + public function register() + { + return array(T_STYLE); + + }//end 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. + * + * @return void + */ + public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + // Ignore files with browser-specific suffixes. + $filename = $phpcsFile->getFilename(); + $breakChar = strrpos($filename, '_'); + if ($breakChar !== false && substr($filename, -4) === '.css') { + $specific = substr($filename, ($breakChar + 1), -4); + if (in_array($specific, $this->specificStylesheets) === true) { + return; + } + } + + $tokens = $phpcsFile->getTokens(); + $content = $tokens[$stackPtr]['content']; + + if ($content{0} === '-') { + $error = 'Browser-specific styles are not allowed'; + $phpcsFile->addError($error, $stackPtr, 'ForbiddenStyle'); + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/Channels/ChannelExceptionSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/Channels/ChannelExceptionSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/Channels/ChannelExceptionSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/Channels/ChannelExceptionSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,76 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Ensures that all action classes throw ChannelExceptions only. + * + * @category PHP + * @package PHP_CodeSniffer_MySource + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class MySource_Sniffs_Channels_ChannelExceptionSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array(T_THROW); + + }//end register() + + + /** + * Processes this sniff, 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) + { + $fileName = strtolower($phpcsFile->getFilename()); + $matches = array(); + if (preg_match('|/systems/(.*)/([^/]+)?actions.inc$|', $fileName, $matches) === 0) { + // This is not an actions.inc file. + return; + } + + $tokens = $phpcsFile->getTokens(); + + $exception = $phpcsFile->findNext(array(T_STRING, T_VARIABLE), ($stackPtr + 1)); + $exceptionName = $tokens[$exception]['content']; + + if ($exceptionName !== 'ChannelException') { + $data = array($exceptionName); + $error = 'Channel actions can only throw ChannelException; found "%s"'; + $phpcsFile->addError($error, $exception, 'WrongExceptionType', $data); + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/Channels/DisallowSelfActionsSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/Channels/DisallowSelfActionsSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/Channels/DisallowSelfActionsSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/Channels/DisallowSelfActionsSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,131 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Ensures that self is not used to call public method in action classes. + * + * @category PHP + * @package PHP_CodeSniffer_MySource + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class MySource_Sniffs_Channels_DisallowSelfActionsSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array(T_CLASS); + + }//end register() + + + /** + * Processes this sniff, 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(); + + // We are not interested in abstract classes. + $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); + if ($prev !== false && $tokens[$prev]['code'] === T_ABSTRACT) { + return; + } + + // We are only interested in Action classes. + $classNameToken = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); + $className = $tokens[$classNameToken]['content']; + if (substr($className, -7) !== 'Actions') { + return; + } + + $foundFunctions = array(); + $foundCalls = array(); + + // Find all static method calls in the form self::method() in the class. + $classEnd = $tokens[$stackPtr]['scope_closer']; + for ($i = ($classNameToken + 1); $i < $classEnd; $i++) { + if ($tokens[$i]['code'] !== T_DOUBLE_COLON) { + if ($tokens[$i]['code'] === T_FUNCTION) { + // Cache the function information. + $funcName = $phpcsFile->findNext(T_STRING, ($i + 1)); + $funcScope = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$scopeModifiers, ($i - 1)); + + $foundFunctions[$tokens[$funcName]['content']] = strtolower($tokens[$funcScope]['content']); + } + + continue; + } + + $prevToken = $phpcsFile->findPrevious(T_WHITESPACE, ($i - 1), null, true); + if ($tokens[$prevToken]['content'] !== 'self') { + continue; + } + + $funcNameToken = $phpcsFile->findNext(T_WHITESPACE, ($i + 1), null, true); + if ($tokens[$funcNameToken]['code'] === T_VARIABLE) { + // We are only interested in function calls. + continue; + } + + $funcName = $tokens[$funcNameToken]['content']; + + // We've found the function, now we need to find it and see if it is + // public, private or protected. If it starts with an underscore we + // can assume it is private. + if ($funcName{0} === '_') { + continue; + } + + $foundCalls[$i] = $funcName; + }//end for + + $errorClassName = substr($className, 0, -7); + + foreach ($foundCalls as $token => $funcName) { + if (isset($foundFunctions[$funcName]) === false) { + // Function was not in this class, might have come from the parent. + // Either way, we can't really check this. + continue; + } else if ($foundFunctions[$funcName] === 'public') { + $error = 'Static calls to public methods in Action classes must not use the self keyword; use %s::%s() instead'; + $data = array( + $errorClassName, + $funcName, + ); + $phpcsFile->addError($error, $token, 'Found', $data); + } + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/Channels/IncludeSystemSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/Channels/IncludeSystemSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/Channels/IncludeSystemSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/Channels/IncludeSystemSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,329 @@ + + * @copyright 2006-2012 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 + */ + +if (class_exists('PHP_CodeSniffer_Standards_AbstractScopeSniff', true) === false) { + $error = 'Class PHP_CodeSniffer_Standards_AbstractScopeSniff not found'; + throw new PHP_CodeSniffer_Exception($error); +} + +/** + * Ensures that systems, asset types and libs are included before they are used. + * + * @category PHP + * @package PHP_CodeSniffer_MySource + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class MySource_Sniffs_Channels_IncludeSystemSniff extends PHP_CodeSniffer_Standards_AbstractScopeSniff +{ + + /** + * A list of classes that don't need to be included. + * + * @var array(string) + */ + private $_ignore = array( + 'self', + 'parent', + 'channels', + 'basesystem', + 'dal', + 'init', + 'pdo', + 'util', + 'ziparchive', + 'phpunit_framework_assert', + 'abstractmysourceunittest', + 'abstractdatacleanunittest', + 'exception', + 'abstractwidgetwidgettype', + 'domdocument', + ); + + + /** + * Constructs a Squiz_Sniffs_Scope_MethodScopeSniff. + */ + public function __construct() + { + parent::__construct(array(T_FUNCTION), array(T_DOUBLE_COLON, T_EXTENDS), true); + + }//end __construct() + + + /** + * Processes the function tokens within the class. + * + * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found. + * @param integer $stackPtr The position where the token was found. + * @param integer $currScope The current scope opener token. + * + * @return void + */ + protected function processTokenWithinScope( + PHP_CodeSniffer_File $phpcsFile, + $stackPtr, + $currScope + ) { + $tokens = $phpcsFile->getTokens(); + + // Determine the name of the class that the static function + // is being called on. + $classNameToken = $phpcsFile->findPrevious( + T_WHITESPACE, + ($stackPtr - 1), + null, + true + ); + + $className = $tokens[$classNameToken]['content']; + if (in_array(strtolower($className), $this->_ignore) === true) { + return; + } + + $includedClasses = array(); + + $fileName = strtolower($phpcsFile->getFilename()); + $matches = array(); + if (preg_match('|/systems/(.*)/([^/]+)?actions.inc$|', $fileName, $matches) !== 0) { + // This is an actions file, which means we don't + // have to include the system in which it exists. + $includedClasses[] = $matches[2]; + + // Or a system it implements. + $class = $phpcsFile->getCondition($stackPtr, T_CLASS); + $implements = $phpcsFile->findNext(T_IMPLEMENTS, $class, ($class + 10)); + if ($implements !== false) { + $implementsClass = $phpcsFile->findNext(T_STRING, $implements); + $implementsClassName = strtolower($tokens[$implementsClass]['content']); + if (substr($implementsClassName, -7) === 'actions') { + $includedClasses[] = substr($implementsClassName, 0, -7); + } + } + } + + // Go searching for includeSystem and includeAsset calls within this + // function, or the inclusion of .inc files, which + // would be library files. + for ($i = ($currScope + 1); $i < $stackPtr; $i++) { + $name = $this->getIncludedClassFromToken($phpcsFile, $tokens, $i); + if ($name !== false) { + $includedClasses[] = $name; + // Special case for Widgets cause they are, well, special. + } else if (strtolower($tokens[$i]['content']) === 'includewidget') { + $typeName = $phpcsFile->findNext(T_CONSTANT_ENCAPSED_STRING, ($i + 1)); + $typeName = trim($tokens[$typeName]['content'], " '"); + $includedClasses[] = strtolower($typeName).'widgettype'; + } + } + + // Now go searching for includeSystem, includeAsset or require/include + // calls outside our scope. If we are in a class, look outside the + // class. If we are not, look outside the function. + $condPtr = $currScope; + if ($phpcsFile->hasCondition($stackPtr, T_CLASS) === true) { + foreach ($tokens[$stackPtr]['conditions'] as $condPtr => $condType) { + if ($condType === T_CLASS) { + break; + } + } + } + + for ($i = 0; $i < $condPtr; $i++) { + // Skip other scopes. + if (isset($tokens[$i]['scope_closer']) === true) { + $i = $tokens[$i]['scope_closer']; + continue; + } + + $name = $this->getIncludedClassFromToken($phpcsFile, $tokens, $i); + if ($name !== false) { + $includedClasses[] = $name; + } + }//end for + + // If we are in a testing class, we might have also included + // some systems and classes in our setUp() method. + $setupFunction = null; + if ($phpcsFile->hasCondition($stackPtr, T_CLASS) === true) { + foreach ($tokens[$stackPtr]['conditions'] as $condPtr => $condType) { + if ($condType === T_CLASS) { + // Is this is a testing class? + $name = $phpcsFile->findNext(T_STRING, $condPtr); + $name = $tokens[$name]['content']; + if (substr($name, -8) === 'UnitTest') { + // Look for a method called setUp(). + $end = $tokens[$condPtr]['scope_closer']; + $function = $phpcsFile->findNext(T_FUNCTION, ($condPtr + 1), $end); + while ($function !== false) { + $name = $phpcsFile->findNext(T_STRING, $function); + if ($tokens[$name]['content'] === 'setUp') { + $setupFunction = $function; + break; + } + + $function = $phpcsFile->findNext(T_FUNCTION, ($function + 1), $end); + } + } + } + }//end foreach + }//end if + + if ($setupFunction !== null) { + $start = ($tokens[$setupFunction]['scope_opener'] + 1); + $end = $tokens[$setupFunction]['scope_closer']; + for ($i = $start; $i < $end; $i++) { + $name = $this->getIncludedClassFromToken($phpcsFile, $tokens, $i); + if ($name !== false) { + $includedClasses[] = $name; + } + } + }//end if + + if (in_array(strtolower($className), $includedClasses) === false) { + $error = 'Static method called on non-included class or system "%s"; include system with Channels::includeSystem() or include class with require_once'; + $data = array($className); + $phpcsFile->addError($error, $stackPtr, 'NotIncludedCall', $data); + } + + }//end processTokenWithinScope() + + + /** + * Processes a token within the scope that this test is listening to. + * + * @param PHP_CodeSniffer_File $phpcsFile The file where the token was found. + * @param int $stackPtr The position in the stack where + * this token was found. + * + * @return void + */ + protected function processTokenOutsideScope(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + $tokens = $phpcsFile->getTokens(); + + if ($tokens[$stackPtr]['code'] === T_EXTENDS) { + // Find the class name. + $classNameToken = $phpcsFile->findNext(T_STRING, ($stackPtr + 1)); + $className = $tokens[$classNameToken]['content']; + } else { + // Determine the name of the class that the static function + // is being called on. + $classNameToken = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); + $className = $tokens[$classNameToken]['content']; + } + + // Some systems are always available. + if (in_array(strtolower($className), $this->_ignore) === true) { + return; + } + + $includedClasses = array(); + + $fileName = strtolower($phpcsFile->getFilename()); + $matches = array(); + if (preg_match('|/systems/([^/]+)/([^/]+)?actions.inc$|', $fileName, $matches) !== 0) { + // This is an actions file, which means we don't + // have to include the system in which it exists + // We know the system from the path. + $includedClasses[] = $matches[1]; + } + + // Go searching for includeSystem, includeAsset or require/include + // calls outside our scope. + for ($i = 0; $i < $stackPtr; $i++) { + // Skip classes and functions as will we never get + // into their scopes when including this file, although + // we have a chance of getting into IF's, WHILE's etc. + $ignoreTokens = array( + T_CLASS, + T_INTERFACE, + T_FUNCTION, + ); + + if (in_array($tokens[$i]['code'], $ignoreTokens) === true + && isset($tokens[$i]['scope_closer']) === true + ) { + $i = $tokens[$i]['scope_closer']; + continue; + } + + $name = $this->getIncludedClassFromToken($phpcsFile, $tokens, $i); + if ($name !== false) { + $includedClasses[] = $name; + // Special case for Widgets cause they are, well, special. + } else if (strtolower($tokens[$i]['content']) === 'includewidget') { + $typeName = $phpcsFile->findNext(T_CONSTANT_ENCAPSED_STRING, ($i + 1)); + $typeName = trim($tokens[$typeName]['content'], " '"); + $includedClasses[] = strtolower($typeName).'widgettype'; + } + }//end for + + if (in_array(strtolower($className), $includedClasses) === false) { + if ($tokens[$stackPtr]['code'] === T_EXTENDS) { + $error = 'Class extends non-included class or system "%s"; include system with Channels::includeSystem() or include class with require_once'; + $data = array($className); + $phpcsFile->addError($error, $stackPtr, 'NotIncludedExtends', $data); + } else { + $error = 'Static method called on non-included class or system "%s"; include system with Channels::includeSystem() or include class with require_once'; + $data = array($className); + $phpcsFile->addError($error, $stackPtr, 'NotIncludedCall', $data); + } + } + + }//end processTokenOutsideScope() + + + /** + * Determines the included class name from given token. + * + * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found. + * @param array $tokens The array of file tokens. + * @param int $stackPtr The position in the tokens array of the + * potentially included class. + * + * @return string + */ + protected function getIncludedClassFromToken( + PHP_CodeSniffer_File $phpcsFile, + array $tokens, + $stackPtr + ) { + if (strtolower($tokens[$stackPtr]['content']) === 'includesystem') { + $systemName = $phpcsFile->findNext(T_CONSTANT_ENCAPSED_STRING, ($stackPtr + 1)); + $systemName = trim($tokens[$systemName]['content'], " '"); + return strtolower($systemName); + } else if (strtolower($tokens[$stackPtr]['content']) === 'includeasset') { + $typeName = $phpcsFile->findNext(T_CONSTANT_ENCAPSED_STRING, ($stackPtr + 1)); + $typeName = trim($tokens[$typeName]['content'], " '"); + return strtolower($typeName).'assettype'; + } else if (in_array($tokens[$stackPtr]['code'], PHP_CodeSniffer_Tokens::$includeTokens) === true) { + $filePath = $phpcsFile->findNext(T_CONSTANT_ENCAPSED_STRING, ($stackPtr + 1)); + $filePath = $tokens[$filePath]['content']; + $filePath = trim($filePath, " '"); + $filePath = basename($filePath, '.inc'); + return strtolower($filePath); + } + + return false; + + }//end getIncludedClassFromToken() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/Channels/UnusedSystemSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/Channels/UnusedSystemSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/Channels/UnusedSystemSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/Channels/UnusedSystemSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,157 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Ensures that systems and asset types are used if they are included. + * + * @category PHP + * @package PHP_CodeSniffer_MySource + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class MySource_Sniffs_Channels_UnusedSystemSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array(T_DOUBLE_COLON); + + }//end register() + + + /** + * Processes this sniff, 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(); + + // Check if this is a call to includeSystem, includeAsset or includeWidget. + $methodName = strtolower($tokens[($stackPtr + 1)]['content']); + if (in_array($methodName, array('includesystem', 'includeasset', 'includewidget')) === true) { + $systemName = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 3), null, true); + if ($systemName === false || $tokens[$systemName]['code'] !== T_CONSTANT_ENCAPSED_STRING) { + // Must be using a variable instead of a specific system name. + // We can't accurately check that. + return; + } + + $systemName = trim($tokens[$systemName]['content'], " '"); + } else { + return; + } + + if ($methodName === 'includeasset') { + $systemName .= 'assettype'; + } else if ($methodName === 'includewidget') { + $systemName .= 'widgettype'; + } + + $systemName = strtolower($systemName); + + // Now check if this system is used anywhere in this scope. + $level = $tokens[$stackPtr]['level']; + for ($i = ($stackPtr + 1); $i < $phpcsFile->numTokens; $i++) { + if ($tokens[$i]['level'] < $level) { + // We have gone out of scope. + // If the original include was inside an IF statement that + // is checking if the system exists, check the outer scope + // as well. + if ($tokens[$stackPtr]['level'] === $level) { + // We are still in the base level, so this is the first + // time we have got here. + $conditions = array_keys($tokens[$stackPtr]['conditions']); + if (empty($conditions) === false) { + $cond = array_pop($conditions); + if ($tokens[$cond]['code'] === T_IF) { + $i = $tokens[$cond]['scope_closer']; + $level--; + continue; + } + } + } + + break; + }//end if + + $validTokens = array( + T_DOUBLE_COLON, + T_EXTENDS, + T_IMPLEMENTS, + ); + + if (in_array($tokens[$i]['code'], $validTokens) === false) { + continue; + } + + switch ($tokens[$i]['code']) { + case T_DOUBLE_COLON: + $usedName = strtolower($tokens[($i - 1)]['content']); + if ($usedName === $systemName) { + // The included system was used, so it is fine. + return; + } + + break; + case T_EXTENDS: + $classNameToken = $phpcsFile->findNext(T_STRING, ($i + 1)); + $className = strtolower($tokens[$classNameToken]['content']); + if ($className === $systemName) { + // The included system was used, so it is fine. + return; + } + + break; + case T_IMPLEMENTS: + $endImplements = $phpcsFile->findNext(array(T_EXTENDS, T_OPEN_CURLY_BRACKET), ($i + 1)); + for ($x = ($i + 1); $x < $endImplements; $x++) { + if ($tokens[$x]['code'] === T_STRING) { + $className = strtolower($tokens[$x]['content']); + if ($className === $systemName) { + // The included system was used, so it is fine. + return; + } + } + } + + break; + }//end switch + }//end for + + // If we get to here, the system was not use. + $error = 'Included system "%s" is never used'; + $data = array($systemName); + $phpcsFile->addError($error, $stackPtr, 'Found', $data); + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/Commenting/FunctionCommentSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/Commenting/FunctionCommentSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/Commenting/FunctionCommentSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/Commenting/FunctionCommentSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,134 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +if (class_exists('Squiz_Sniffs_Commenting_FunctionCommentSniff', true) === false) { + $error = 'Class Squiz_Sniffs_Commenting_FunctionCommentSniff not found'; + throw new PHP_CodeSniffer_Exception($error); +} + +/** + * Parses and verifies the doc comments for functions. + * + * Same as the Squiz standard, but adds support for API tags. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class MySource_Sniffs_Commenting_FunctionCommentSniff extends Squiz_Sniffs_Commenting_FunctionCommentSniff +{ + + + /** + * Process a list of unknown tags. + * + * @param int $commentStart The position in the stack where the comment started. + * @param int $commentEnd The position in the stack where the comment ended. + * + * @return void + */ + protected function processUnknownTags($commentStart, $commentEnd) + { + $unknownTags = $this->commentParser->getUnknown(); + $words = $this->commentParser->getWords(); + $hasApiTag = false; + $apiLength = 3; + foreach ($unknownTags as $errorTag) { + $pos = $errorTag['pos']; + if ($errorTag['tag'] === 'api') { + if ($hasApiTag === true) { + // We've come across an API tag already, which means + // we were not the first tag in the API list. + $error = 'The @api tag must come first in the @api tag list in a function comment'; + $this->currentFile->addError($error, ($commentStart + $errorTag['line']), 'ApiNotFirst'); + } + + $hasApiTag = true; + + // There needs to be a blank line before the @api tag. + // So expect a single space before the tag, then 2 newlines before + // that, then some content. + if (trim($words[($pos - 2)]) !== '' + || strpos($words[($pos - 2)], $this->currentFile->eolChar) === false + || strpos($words[($pos - 3)], $this->currentFile->eolChar) === false + || trim($words[($pos - 4)]) === '' + ) { + $error = 'There must be one blank line before the @api tag in a function comment'; + $this->currentFile->addError($error, ($commentStart + $errorTag['line']), 'ApiSpacing'); + } + } else if (substr($errorTag['tag'], 0, 4) === 'api-') { + $hasApiTag = true; + + $tagLength = strlen($errorTag['tag']); + if ($tagLength > $apiLength) { + $apiLength = $tagLength; + } + + if (trim($words[($pos - 2)]) !== '' + || strpos($words[($pos - 2)], $this->currentFile->eolChar) === false + || trim($words[($pos - 3)]) === '' + ) { + $error = 'There must be no blank line before the @%s tag in a function comment'; + $data = array($errorTag['tag']); + $this->currentFile->addError($error, ($commentStart + $errorTag['line']), 'ApiTagSpacing', $data); + } + } else { + $error = '@%s tag is not allowed in function comment'; + $data = array($errorTag['tag']); + $this->currentFile->addWarning($error, ($commentStart + $errorTag['line']), 'TagNotAllowed', $data); + }//end if + }//end foreach + + if ($hasApiTag === true) { + // API tags must be the last tags in a function comment. + $order = $this->commentParser->getTagOrders(); + $lastTag = array_pop($order); + if ($lastTag !== 'api' + && substr($lastTag, 0, 4) !== 'api-' + ) { + $error = 'The @api tags must be the last tags in a function comment'; + $this->currentFile->addError($error, $commentEnd, 'ApiNotLast'); + } + + // Check API tag indenting. + foreach ($unknownTags as $errorTag) { + if ($errorTag['tag'] === 'api' + || substr($errorTag['tag'], 0, 4) === 'api-' + ) { + $expected = ($apiLength - strlen($errorTag['tag']) + 1); + $found = strlen($words[($errorTag['pos'] + 1)]); + if ($found !== $expected) { + $error = '@%s tag indented incorrectly; expected %s spaces but found %s'; + $data = array( + $errorTag['tag'], + $expected, + $found, + ); + $this->currentFile->addError($error, ($commentStart + $errorTag['line']), 'ApiTagIndent', $data); + } + } + } + }//end if + + }//end processUnknownTags() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/Debug/DebugCodeSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/Debug/DebugCodeSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/Debug/DebugCodeSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/Debug/DebugCodeSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,68 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Warns about the use of debug code. + * + * @category PHP + * @package PHP_CodeSniffer_MySource + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class MySource_Sniffs_Debug_DebugCodeSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array(T_DOUBLE_COLON); + + }//end register() + + + /** + * Processes this sniff, 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(); + + $className = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); + if (strtolower($tokens[$className]['content']) === 'debug') { + $method = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); + $error = 'Call to debug function Debug::%s() must be removed'; + $data = array($tokens[$method]['content']); + $phpcsFile->addError($error, $stackPtr, 'Found', $data); + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/Debug/FirebugConsoleSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/Debug/FirebugConsoleSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/Debug/FirebugConsoleSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/Debug/FirebugConsoleSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,77 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Ensures that console is not used for function or var names. + * + * @category PHP + * @package PHP_CodeSniffer_MySource + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class MySource_Sniffs_Debug_FirebugConsoleSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * A list of tokenizers this sniff supports. + * + * @var array + */ + public $supportedTokenizers = array('JS'); + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array( + T_STRING, + T_PROPERTY, + T_LABEL, + T_OBJECT, + ); + + }//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(); + + if (strtolower($tokens[$stackPtr]['content']) === 'console') { + $error = 'Variables, functions and labels must not be named "console"; name may conflict with Firebug internal variable'; + $phpcsFile->addError($error, $stackPtr, 'ConflictFound'); + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/Objects/AssignThisSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/Objects/AssignThisSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/Objects/AssignThisSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/Objects/AssignThisSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,94 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Ensures this is not assigned to any other var but self. + * + * @category PHP + * @package PHP_CodeSniffer_MySource + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class MySource_Sniffs_Objects_AssignThisSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * A list of tokenizers this sniff supports. + * + * @var array + */ + public $supportedTokenizers = array('JS'); + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array(T_THIS); + + }//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(); + + // Ignore this.something and other uses of "this" that are not + // direct assignments. + $next = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); + if ($tokens[$next]['code'] !== T_SEMICOLON) { + if ($tokens[$next]['line'] === $tokens[$stackPtr]['line']) { + return; + } + } + + // Something must be assigned to "this". + $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); + if ($tokens[$prev]['code'] !== T_EQUAL) { + return; + } + + // A variable needs to be assigned to "this". + $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($prev - 1), null, true); + if ($tokens[$prev]['code'] !== T_STRING) { + return; + } + + // We can only assign "this" to a var called "self". + if ($tokens[$prev]['content'] !== 'self' && $tokens[$prev]['content'] !== '_self') { + $error = 'Keyword "this" can only be assigned to a variable called "self" or "_self"'; + $phpcsFile->addError($error, $prev, 'NotSelf'); + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/Objects/CreateWidgetTypeCallbackSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/Objects/CreateWidgetTypeCallbackSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/Objects/CreateWidgetTypeCallbackSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/Objects/CreateWidgetTypeCallbackSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,228 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Ensures the create() method of widget types properly uses callbacks. + * + * @category PHP + * @package PHP_CodeSniffer_MySource + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class MySource_Sniffs_Objects_CreateWidgetTypeCallbackSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * A list of tokenizers this sniff supports. + * + * @var array + */ + public $supportedTokenizers = array('JS'); + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array(T_OBJECT); + + }//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(); + + $className = $tokens[$stackPtr]['content']; + if (substr(strtolower($className), -10) !== 'widgettype') { + return; + } + + // Search for a create method. + $start = ($tokens[$stackPtr]['scope_opener'] + 1); + $end = ($tokens[$stackPtr]['scope_closer'] - 1); + $create = $phpcsFile->findNext(T_PROPERTY, $start, $end, null, 'create'); + if ($create === false) { + return; + } + + $function = $phpcsFile->findNext(array(T_WHITESPACE, T_COLON), ($create + 1), null, true); + if ($tokens[$function]['code'] !== T_FUNCTION) { + continue; + } + + $start = ($tokens[$function]['scope_opener'] + 1); + $end = ($tokens[$function]['scope_closer'] - 1); + + // Check that the first argument is called "callback". + $arg = $phpcsFile->findNext(T_WHITESPACE, ($tokens[$function]['parenthesis_opener'] + 1), null, true); + if ($tokens[$arg]['content'] !== 'callback') { + $error = 'The first argument of the create() method of a widget type must be called "callback"'; + $phpcsFile->addError($error, $arg, 'FirstArgNotCallback'); + } + + /* + Look for return statements within the function. They cannot return + anything and must be preceded by the callback.call() line. The + callback itself must contain "self" or "this" as the first argument + and there needs to be a call to the callback function somewhere + in the create method. All calls to the callback function must be + followed by a return statement or the end of the method. + */ + + $foundCallback = false; + $passedCallback = false; + $nestedFunction = null; + for ($i = $start; $i <= $end; $i++) { + // Keep track of nested functions. + if ($nestedFunction !== null) { + if ($i === $nestedFunction) { + $nestedFunction = null; + continue; + } + } else if ($tokens[$i]['code'] === T_FUNCTION + && isset($tokens[$i]['scope_closer']) === true + ) { + $nestedFunction = $tokens[$i]['scope_closer']; + continue; + } + + if ($nestedFunction === null && $tokens[$i]['code'] === T_RETURN) { + // Make sure return statements are not returning anything. + if ($tokens[($i + 1)]['code'] !== T_SEMICOLON) { + $error = 'The create() method of a widget type must not return a value'; + $phpcsFile->addError($error, $i, 'ReturnValue'); + } + + continue; + } else if ($tokens[$i]['code'] !== T_STRING + || $tokens[$i]['content'] !== 'callback' + ) { + continue; + } + + // If this is the form "callback.call(" then it is a call + // to the callback function. + if ($tokens[($i + 1)]['code'] !== T_OBJECT_OPERATOR + || $tokens[($i + 2)]['content'] !== 'call' + || $tokens[($i + 3)]['code'] !== T_OPEN_PARENTHESIS + ) { + // One last chance; this might be the callback function + // being passed to another function, like this + // "this.init(something, callback, something)". + if (isset($tokens[$i]['nested_parenthesis']) === false) { + continue; + } + + // Just make sure those brackets dont belong to anyone, + // like an IF or FOR statement. + foreach ($tokens[$i]['nested_parenthesis'] as $bracket) { + if (isset($tokens[$bracket]['parenthesis_owner']) === true) { + continue(2); + } + } + + // Note that we use this endBracket down further when checking + // for a RETURN statement. + $endBracket = end($tokens[$i]['nested_parenthesis']); + $bracket = key($tokens[$i]['nested_parenthesis']); + + $prev = $phpcsFile->findPrevious( + PHP_CodeSniffer_Tokens::$emptyTokens, + ($bracket - 1), + null, + true + ); + + if ($tokens[$prev]['code'] !== T_STRING) { + // This is not a function passing the callback. + continue; + } + + $passedCallback = true; + }//end if + + $foundCallback = true; + + if ($passedCallback === false) { + // The first argument must be "this" or "self". + $arg = $phpcsFile->findNext(T_WHITESPACE, ($i + 4), null, true); + if ($tokens[$arg]['content'] !== 'this' + && $tokens[$arg]['content'] !== 'self' + ) { + $error = 'The first argument passed to the callback function must be "this" or "self"'; + $phpcsFile->addError($error, $arg, 'FirstArgNotSelf'); + } + } + + // Now it must be followed by a return statement or the end of the function. + if ($passedCallback === false) { + $endBracket = $tokens[($i + 3)]['parenthesis_closer']; + } + + for ($next = $endBracket; $next <= $end; $next++) { + // Skip whitespace so we find the next content after the call. + if (in_array($tokens[$next]['code'], PHP_CodeSniffer_Tokens::$emptyTokens) === true) { + continue; + } + + // Skip closing braces like END IF because it is not executable code. + if ($tokens[$next]['code'] === T_CLOSE_CURLY_BRACKET) { + continue; + } + + // We don't care about anything on the current line, like a + // semicolon. It doesn't matter if there are other statements on the + // line because another sniff will check for those. + if ($tokens[$next]['line'] === $tokens[$endBracket]['line']) { + continue; + } + + break; + } + + if ($next !== $tokens[$function]['scope_closer'] + && $tokens[$next]['code'] !== T_RETURN + ) { + $error = 'The call to the callback function must be followed by a return statement if it is not the last statement in the create() method'; + $phpcsFile->addError($error, $i, 'NoReturn'); + } + }//end for + + if ($foundCallback === false) { + $error = 'The create() method of a widget type must call the callback function'; + $phpcsFile->addError($error, $create, 'CallbackNotCalled'); + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/Objects/DisallowNewWidgetSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/Objects/DisallowNewWidgetSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/Objects/DisallowNewWidgetSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/Objects/DisallowNewWidgetSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,72 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Ensures that widgets are not manually created. + * + * @category PHP + * @package PHP_CodeSniffer_MySource + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class MySource_Sniffs_Objects_DisallowNewWidgetSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array(T_NEW); + + }//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(); + + $className = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); + if ($tokens[$className]['code'] !== T_STRING) { + return; + } + + if (substr(strtolower($tokens[$className]['content']), -10) === 'widgettype') { + $widgetType = substr($tokens[$className]['content'], 0, -10); + $error = 'Manual creation of widget objects is banned; use Widget::getWidget(\'%s\'); instead'; + $data = array($widgetType); + $phpcsFile->addError($error, $stackPtr, 'Found', $data); + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/PHP/AjaxNullComparisonSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/PHP/AjaxNullComparisonSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/PHP/AjaxNullComparisonSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/PHP/AjaxNullComparisonSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,113 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Ensures that values submitted via JS are not compared to NULL. + * + * jQuery 1.8 changed the behaviour of ajax requests so that null values are + * submitted as null= instead of null=null. + * + * @category PHP + * @package PHP_CodeSniffer_MySource + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class MySource_Sniffs_PHP_AjaxNullComparisonSniff 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 sniff, 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(); + + // Make sure it is an API function. We know this by the doc comment. + $commentEnd = $phpcsFile->findPrevious(T_DOC_COMMENT, $stackPtr); + $commentStart = $phpcsFile->findPrevious(T_DOC_COMMENT, ($commentEnd - 1), null, true); + $comment = $phpcsFile->getTokensAsString($commentStart, ($commentEnd - $commentStart)); + if (strpos($comment, '* @api') === false) { + return; + } + + + // Find all the vars passed in as we are only interested in comparisons + // to NULL for these specific variables. + $foundVars = array(); + $open = $tokens[$stackPtr]['parenthesis_opener']; + $close = $tokens[$stackPtr]['parenthesis_closer']; + for ($i = ($open + 1); $i < $close; $i++) { + if ($tokens[$i]['code'] === T_VARIABLE) { + $foundVars[] = $tokens[$i]['content']; + } + } + + if (empty($foundVars) === true) { + return; + } + + $start = $tokens[$stackPtr]['scope_opener']; + $end = $tokens[$stackPtr]['scope_closer']; + for ($i = ($start + 1); $i < $end; $i++) { + if ($tokens[$i]['code'] !== T_VARIABLE + || in_array($tokens[$i]['content'], $foundVars) === false + ) { + continue; + } + + $operator = $phpcsFile->findNext(T_WHITESPACE, ($i + 1), null, true); + if ($tokens[$operator]['code'] !== T_IS_IDENTICAL + && $tokens[$operator]['code'] !== T_IS_NOT_IDENTICAL + ) { + continue; + } + + $nullValue = $phpcsFile->findNext(T_WHITESPACE, ($operator + 1), null, true); + if ($tokens[$nullValue]['code'] !== T_NULL) { + continue; + } + + $error = 'Values submitted via Ajax requests must not be compared directly to NULL; use empty() instead'; + $phpcsFile->addError($error, $nullValue, 'Found'); + }//end for + + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/PHP/EvalObjectFactorySniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/PHP/EvalObjectFactorySniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/PHP/EvalObjectFactorySniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/PHP/EvalObjectFactorySniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,126 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Ensures that eval() is not used to create objects. + * + * @category PHP + * @package PHP_CodeSniffer_MySource + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class MySource_Sniffs_PHP_EvalObjectFactorySniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array(T_EVAL); + + }//end register() + + + /** + * Processes this sniff, 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(); + + /* + We need to find all strings that will be in the eval + to determine if the "new" keyword is being used. + */ + + $openBracket = $phpcsFile->findNext(T_OPEN_PARENTHESIS, ($stackPtr + 1)); + $closeBracket = $tokens[$openBracket]['parenthesis_closer']; + + $strings = array(); + $vars = array(); + + for ($i = ($openBracket + 1); $i < $closeBracket; $i++) { + if (in_array($tokens[$i]['code'], PHP_CodeSniffer_Tokens::$stringTokens) === true) { + $strings[$i] = $tokens[$i]['content']; + } else if ($tokens[$i]['code'] === T_VARIABLE) { + $vars[$i] = $tokens[$i]['content']; + } + } + + /* + We now have some variables that we need to expand into + the strings that were assigned to them, if any. + */ + + foreach ($vars as $varPtr => $varName) { + while (($prev = $phpcsFile->findPrevious(T_VARIABLE, ($varPtr - 1))) !== false) { + // Make sure this is an assignment of the variable. That means + // it will be the first thing on the line. + $prevContent = $phpcsFile->findPrevious(T_WHITESPACE, ($prev - 1), null, true); + if ($tokens[$prevContent]['line'] === $tokens[$prev]['line']) { + $varPtr = $prevContent; + continue; + } + + if ($tokens[$prev]['content'] !== $varName) { + // This variable has a different name. + $varPtr = $prevContent; + continue; + } + + // We found one. + break; + }//end while + + if ($prev !== false) { + // Find all strings on the line. + $lineEnd = $phpcsFile->findNext(T_SEMICOLON, ($prev + 1)); + for ($i = ($prev + 1); $i < $lineEnd; $i++) { + if (in_array($tokens[$i]['code'], PHP_CodeSniffer_Tokens::$stringTokens) === true) { + $strings[$i] = $tokens[$i]['content']; + } + } + } + }//end foreach + + foreach ($strings as $string) { + // If the string has "new" in it, it is not allowed. + // We don't bother checking if the word "new" is echo'd + // because that is unlikely to happen. We assume the use + // of "new" is for object instantiation. + if (strstr($string, ' new ') !== false) { + $error = 'Do not use eval() to create objects dynamically; use reflection instead'; + $phpcsFile->addWarning($error, $stackPtr, 'Found'); + } + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/PHP/GetRequestDataSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/PHP/GetRequestDataSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/PHP/GetRequestDataSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/PHP/GetRequestDataSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,119 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Ensures that getRequestData() is used to access super globals. + * + * @category PHP + * @package PHP_CodeSniffer_MySource + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class MySource_Sniffs_PHP_GetRequestDataSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array(T_VARIABLE); + + }//end register() + + + /** + * Processes this sniff, 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(); + + $varName = $tokens[$stackPtr]['content']; + if ($varName !== '$_REQUEST' + && $varName !== '$_GET' + && $varName !== '$_POST' + && $varName !== '$_FILES' + ) { + return; + } + + // The only place these super globals can be accessed directly is + // in the getRequestData() method of the Security class. + $inClass = false; + foreach ($tokens[$stackPtr]['conditions'] as $i => $type) { + if ($tokens[$i]['code'] === T_CLASS) { + $className = $phpcsFile->findNext(T_STRING, $i); + $className = $tokens[$className]['content']; + if (strtolower($className) === 'security') { + $inClass = true; + } else { + // We don't have nested classes. + break; + } + } else if ($inClass === true && $tokens[$i]['code'] === T_FUNCTION) { + $funcName = $phpcsFile->findNext(T_STRING, $i); + $funcName = $tokens[$funcName]['content']; + if (strtolower($funcName) === 'getrequestdata') { + // This is valid. + return; + } else { + // We don't have nested functions. + break; + } + }//end if + }//end foreach + + // If we get to here, the super global was used incorrectly. + // First find out how it is being used. + $globalName = strtolower(substr($varName, 2)); + $usedVar = ''; + + $openBracket = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); + if ($tokens[$openBracket]['code'] === T_OPEN_SQUARE_BRACKET) { + $closeBracket = $tokens[$openBracket]['bracket_closer']; + $usedVar = $phpcsFile->getTokensAsString(($openBracket + 1), ($closeBracket - $openBracket - 1)); + } + + $type = 'SuperglobalAccessed'; + $error = 'The %s super global must not be accessed directly; use Security::getRequestData('; + $data = array($varName); + if ($usedVar !== '') { + $type .= 'WithVar'; + $error .= '%s, \'%s\''; + $data[] = $usedVar; + $data[] = $globalName; + } + + $error .= ') instead'; + $phpcsFile->addError($error, $stackPtr, $type, $data); + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/PHP/ReturnFunctionValueSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/PHP/ReturnFunctionValueSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/PHP/ReturnFunctionValueSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/PHP/ReturnFunctionValueSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,76 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Warns when function values are returned directly. + * + * @category PHP + * @package PHP_CodeSniffer_MySource + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class MySource_Sniffs_PHP_ReturnFunctionValueSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array(T_RETURN); + + }//end register() + + + /** + * Processes this sniff, 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(); + + $functionName = $phpcsFile->findNext(T_STRING, ($stackPtr + 1), null, false, null, true); + + while ($functionName !== false) { + // Check if this is really a function. + $bracket = $phpcsFile->findNext(T_WHITESPACE, ($functionName + 1), null, true); + if ($tokens[$bracket]['code'] !== T_OPEN_PARENTHESIS) { + // Not a function call. + $functionName = $phpcsFile->findNext(T_STRING, ($functionName + 1), null, false, null, true); + continue; + } + + $error = 'The result of a function call should be assigned to a variable before being returned'; + $phpcsFile->addWarning($error, $stackPtr, 'NotAssigned'); + break; + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/Strings/JoinStringsSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/Strings/JoinStringsSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/Strings/JoinStringsSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Sniffs/Strings/JoinStringsSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,88 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Ensures that strings are not joined using array.join(). + * + * @category PHP + * @package PHP_CodeSniffer_MySource + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class MySource_Sniffs_Strings_JoinStringsSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * A list of tokenizers this sniff supports. + * + * @var array + */ + public $supportedTokenizers = array('JS'); + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array(T_STRING); + + }//end register() + + + /** + * 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(); + + if ($tokens[$stackPtr]['content'] !== 'join') { + return; + } + + $prev = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true); + if ($tokens[$prev]['code'] !== T_OBJECT_OPERATOR) { + return; + } + + $prev = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($prev - 1), null, true); + if ($tokens[$prev]['code'] === T_CLOSE_SQUARE_BRACKET) { + $opener = $tokens[$prev]['bracket_opener']; + if ($tokens[($opener - 1)]['code'] !== T_STRING) { + // This means the array is declared inline, like x = [a,b,c].join() + // and not elsewhere, like x = y[a].join() + // The first is not allowed while the second is. + $error = 'Joining strings using inline arrays is not allowed; use the + operator instead'; + $phpcsFile->addError($error, $stackPtr, 'ArrayNotAllowed'); + } + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/CSS/BrowserSpecificStylesUnitTest.css php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/CSS/BrowserSpecificStylesUnitTest.css --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/CSS/BrowserSpecificStylesUnitTest.css 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/CSS/BrowserSpecificStylesUnitTest.css 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,13 @@ +.SettingsTabPaneWidgetType-tab-mid { + background: transparent url(tab_inact_mid.png) repeat-x; + line-height: -25px; + cursor: pointer; + -moz-user-select: none; +} + +.AssetLineageWidgetType-item { + float: left; + list-style: none; + height: 22px; + cursor: pointer; +} diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/CSS/BrowserSpecificStylesUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/CSS/BrowserSpecificStylesUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/CSS/BrowserSpecificStylesUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/CSS/BrowserSpecificStylesUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,66 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the BrowserSpecificStyles sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class MySource_Tests_CSS_BrowserSpecificStylesUnitTest 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 array( + 5 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Channels/DisallowSelfActionsUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Channels/DisallowSelfActionsUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Channels/DisallowSelfActionsUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Channels/DisallowSelfActionsUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,49 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Channels/DisallowSelfActionsUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Channels/DisallowSelfActionsUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Channels/DisallowSelfActionsUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Channels/DisallowSelfActionsUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,69 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the DisallowSelfActionsUnitTest sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer_MySource + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class MySource_Tests_Channels_DisallowSelfActionsUnitTest 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 array( + 12 => 1, + 26 => 1, + 27 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Channels/IncludeSystemUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Channels/IncludeSystemUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Channels/IncludeSystemUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Channels/IncludeSystemUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,107 @@ +fetch(PDO::FETCH_NUM) +BaseSystem::getDataDir(); +Util::getArrayIndex(array(), ''); + + +Channels::includeSystem('Widget'); +Widget::includeWidget('AbstractContainer'); +class MyWidget extends AbstractContainerWidgetType {} +class MyOtherWidget extends BookWidgetType {} + +$zip = new ZipArchive(); +$res = $zip->open($path, ZipArchive::CREATE); + +class AssetListingUnitTest extends AbstractMySourceUnitTest +{ + function setUp() { + parent::setUp(); + Channels::includeSystem('MySystem2'); + include_once 'Libs/FileSystem.inc'; + } + + function two() { + $siteid = MySystem2::getCurrentSiteId(); + $parserFiles = FileSystem::listDirectory(); + } + + function three() { + $siteid = MySystem3::getCurrentSiteId(); + $parserFiles = FileSystem::listDirectory(); + } +} + +if (Channels::systemExists('Log') === TRUE) { + Channels::includeSystem('Log'); +} else { + return; +} + +Log::addProjectLog('metadata.field.update', $msg); + +function two() { + Widget::includeWidget('CacheAdminScreen'); + $barChart = CacheAdminScreenWidgetType::constructBarchart($data); +} + +$adjustDialog->setOrientation(AbstractWidgetWidgetType::CENTER); +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Channels/IncludeSystemUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Channels/IncludeSystemUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Channels/IncludeSystemUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Channels/IncludeSystemUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,77 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the IncludeSystem sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer_MySource + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class MySource_Tests_Channels_IncludeSystemUnitTest 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 array( + 9 => 1, + 14 => 1, + 24 => 1, + 27 => 1, + 28 => 1, + 31 => 1, + 36 => 1, + 41 => 1, + 60 => 1, + 69 => 1, + 88 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Channels/UnusedSystemUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Channels/UnusedSystemUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Channels/UnusedSystemUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Channels/UnusedSystemUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,67 @@ + \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Channels/UnusedSystemUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Channels/UnusedSystemUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Channels/UnusedSystemUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Channels/UnusedSystemUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,72 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the UnusedSystem sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer_MySource + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class MySource_Tests_Channels_UnusedSystemUnitTest 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 array( + 2 => 1, + 5 => 1, + 8 => 1, + 24 => 1, + 34 => 1, + 54 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Commenting/FunctionCommentUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Commenting/FunctionCommentUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Commenting/FunctionCommentUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Commenting/FunctionCommentUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,101 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Commenting/FunctionCommentUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Commenting/FunctionCommentUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Commenting/FunctionCommentUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Commenting/FunctionCommentUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,74 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for FunctionCommentSniff. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class MySource_Tests_Commenting_FunctionCommentUnitTest 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 array( + 28 => 1, + 36 => 1, + 37 => 2, + 49 => 1, + 58 => 1, + 65 => 1, + 77 => 1, + 79 => 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 array( + 67 => 1, + 68 => 1, + ); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Debug/DebugCodeUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Debug/DebugCodeUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Debug/DebugCodeUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Debug/DebugCodeUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,4 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Debug/DebugCodeUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Debug/DebugCodeUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Debug/DebugCodeUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Debug/DebugCodeUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,68 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the DebugCode sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer_MySource + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class MySource_Tests_Debug_DebugCodeUnitTest 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 array( + 2 => 1, + 3 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Debug/FirebugConsoleUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Debug/FirebugConsoleUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Debug/FirebugConsoleUnitTest.js 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Debug/FirebugConsoleUnitTest.js 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,8 @@ +console.info(); +console.warn(); +console.test(); +con.sole(); +var console = { + console: 'string'; +}; +function console() {} \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Debug/FirebugConsoleUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Debug/FirebugConsoleUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Debug/FirebugConsoleUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Debug/FirebugConsoleUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,78 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the FirebugConsole sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer_MySource + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class MySource_Tests_Debug_FirebugConsoleUnitTest 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='FirebugConsoleUnitTest.js') + { + if ($testFile !== 'FirebugConsoleUnitTest.js') { + return array(); + } + + return array( + 1 => 1, + 2 => 1, + 3 => 1, + 5 => 1, + 6 => 1, + 8 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Objects/AssignThisUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Objects/AssignThisUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Objects/AssignThisUnitTest.js 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Objects/AssignThisUnitTest.js 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,20 @@ +var self = this; +buttonWidget.addClickEvent(function() { + self.addDynamicSouce(); +}); + +var x = self; +var y = this; + +var test = ''; +if (true) { + test = this +} + +var itemid = this.items[i].getAttribute('itemid'); + +for (var x = this; y < 10; y++) { + var x = this + 1; +} + +var _self = this; \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Objects/AssignThisUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Objects/AssignThisUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Objects/AssignThisUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Objects/AssignThisUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,75 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the AssignThis sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer_MySource + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class MySource_Tests_Objects_AssignThisUnitTest 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='AssignThisUnitTest.js') + { + if ($testFile !== 'AssignThisUnitTest.js') { + return array(); + } + + return array( + 7 => 1, + 11 => 1, + 16 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Objects/CreateWidgetTypeCallbackUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Objects/CreateWidgetTypeCallbackUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Objects/CreateWidgetTypeCallbackUnitTest.js 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Objects/CreateWidgetTypeCallbackUnitTest.js 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,186 @@ +SampleWidgetType.prototype = { + + create: function(callback) + { + if (x === 1) { + return; + } + + if (y === 1) { + callback.call(this); + // A comment here to explain the return is okay. + return; + } + + if (a === 1) { + // Cant return value even after calling callback. + callback.call(this); + return something; + } + + if (a === 1) { + // Need to pass self or this to callback function. + callback.call(a); + } + + callback.call(self); + + var self = this; + this.createChildren(null, function() { + callback.call(self, div); + }); + + // Never good to return a vaue. + return something; + + callback.call(self); + } + +}; + +AnotherSampleWidgetType.prototype = { + + create: function(input) + { + return; + } + + getSomething: function(input) + { + return 1; + } + +}; + + +NoCreateWidgetType.prototype = { + + getSomething: function(input) + { + return; + } + +}; + + +SomeRandom.prototype = { + + create: function(input) + { + return; + } + +}; + +SampleWidgetType.prototype = { + + create: function(callback) + { + if (a === 1) { + // This is ok because it is the last statement, + // even though it is conditional. + callback.call(self); + } + + } + +}; + +SampleWidgetType.prototype = { + + create: function(callback) + { + var something = callback; + + } + +}; + +SampleWidgetType.prototype = { + + create: function(callback) + { + // Also valid because we are passing the callback to + // someone else to call. + if (y === 1) { + this.something(callback); + return; + } + + this.init(callback); + + } + +}; + +SampleWidgetType.prototype = { + + create: function(callback) + { + // Also valid because we are passing the callback to + // someone else to call. + if (y === 1) { + this.something(callback); + } + + this.init(callback); + + } + +}; + +SampleWidgetType.prototype = { + + create: function(callback) + { + if (a === 1) { + // This is ok because it is the last statement, + // even though it is conditional. + this.something(callback); + } + + } + +}; + + +SampleWidgetType.prototype = { + + create: function(callback) + { + if (dfx.isFn(callback) === true) { + callback.call(this, cont); + return; + } + } + +}; + + +SampleWidgetType.prototype = { + + create: function(callback) + { + dfx.foreach(items, function(item) { + return true; + }); + + if (dfx.isFn(callback) === true) { + callback.call(this); + } + } + +}; + +SampleWidgetType.prototype = { + + create: function(callback) + { + var self = this; + this.createChildren(null, function() { + callback.call(self, div); + return; + }); + } + +}; \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Objects/CreateWidgetTypeCallbackUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Objects/CreateWidgetTypeCallbackUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Objects/CreateWidgetTypeCallbackUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Objects/CreateWidgetTypeCallbackUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,80 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the CreateWidgetTypeCallback sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer_MySource + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class MySource_Tests_Objects_CreateWidgetTypeCallbackUnitTest 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='CreateWidgetTypeCallbackUnitTest.js') + { + if ($testFile !== 'CreateWidgetTypeCallbackUnitTest.js') { + return array(); + } + + return array( + 18 => 1, + 23 => 2, + 26 => 1, + 30 => 1, + 34 => 1, + 43 => 2, + 91 => 1, + 123 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Objects/DisallowNewWidgetUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Objects/DisallowNewWidgetUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Objects/DisallowNewWidgetUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Objects/DisallowNewWidgetUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,6 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Objects/DisallowNewWidgetUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Objects/DisallowNewWidgetUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Objects/DisallowNewWidgetUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Objects/DisallowNewWidgetUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,67 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the DisallowNewWidget sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer_MySource + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class MySource_Tests_Objects_DisallowNewWidgetUnitTest 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 array( + 4 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/PHP/AjaxNullComparisonUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/PHP/AjaxNullComparisonUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/PHP/AjaxNullComparisonUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/PHP/AjaxNullComparisonUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,179 @@ +getMessage()); + }//end try + + if ($something === NULL) { + if ($bar !== NULL) { + } + } + + return $issueid; + +}//end addIssue() + +/** + * Adds a new issue. + * + * Returns the new issue id. + * + * @param string $title Title of the new issue. + * @param string $description The description of the issue. + * @param string $reporter Asset id of the reporter. + * @param integer $projectid Id of the project that the issue belongs to. + * @param array $tags Array of tags. + * @param string $status The status of the issue. + * @param string $assignedTo The asset id of the user that the issue is + * assigned to. + * @param string $reportedDate If set then this date will be used instead of the + * current date and time. + * @param integer $reportedMilestone Reported milestone. + * + * @return integer + * @throws ChannelException If there is an error. + * + */ +public static function addIssue( + $title, + $description, + $reporter=NULL, + $projectid=NULL, + array $tags=array(), + $status=NULL, + $assignedTo=NULL, + $reportedDate=NULL, + $reportedMilestone=NULL +) { + // Get current projectid if not specified. + if ($projectid === NULL) { + Channels::includeSystem('Project'); + $projectid = Project::getCurrentProjectId(); + Channels::modifyBasket('project', $projectid); + } + +}//end addIssue() +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/PHP/AjaxNullComparisonUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/PHP/AjaxNullComparisonUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/PHP/AjaxNullComparisonUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/PHP/AjaxNullComparisonUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,72 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the AjaxNullComparison sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer_MySource + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class MySource_Tests_PHP_AjaxNullComparisonUnitTest 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 array( + 37 => 1, + 49 => 1, + 60 => 1, + 73 => 1, + 88 => 1, + 118 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/PHP/EvalObjectFactoryUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/PHP/EvalObjectFactoryUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/PHP/EvalObjectFactoryUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/PHP/EvalObjectFactoryUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,26 @@ + \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/PHP/EvalObjectFactoryUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/PHP/EvalObjectFactoryUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/PHP/EvalObjectFactoryUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/PHP/EvalObjectFactoryUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,69 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the EvalObjectFactory sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer_MySource + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class MySource_Tests_PHP_EvalObjectFactoryUnitTest 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 array(); + + }//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 array( + 4 => 1, + 12 => 1, + 21 => 1, + ); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/PHP/GetRequestDataUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/PHP/GetRequestDataUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/PHP/GetRequestDataUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/PHP/GetRequestDataUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,30 @@ + \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/PHP/GetRequestDataUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/PHP/GetRequestDataUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/PHP/GetRequestDataUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/PHP/GetRequestDataUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,73 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the GetRequestData sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer_MySource + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class MySource_Tests_PHP_GetRequestDataUnitTest 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 array( + 2 => 1, + 5 => 1, + 8 => 1, + 21 => 1, + 26 => 1, + 27 => 1, + 28 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/PHP/ReturnFunctionValueUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/PHP/ReturnFunctionValueUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/PHP/ReturnFunctionValueUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/PHP/ReturnFunctionValueUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,9 @@ +myFunction(); +return $obj->variable; +return MyClass::VARIABLE; +return $variable; +return ($var + 1); +?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/PHP/ReturnFunctionValueUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/PHP/ReturnFunctionValueUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/PHP/ReturnFunctionValueUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/PHP/ReturnFunctionValueUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,69 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the ReturnFunctionValue sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer_MySource + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class MySource_Tests_PHP_ReturnFunctionValueUnitTest 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 array(); + + }//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 array( + 2 => 1, + 3 => 1, + 4 => 1, + ); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Strings/JoinStringsUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Strings/JoinStringsUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Strings/JoinStringsUnitTest.js 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Strings/JoinStringsUnitTest.js 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,18 @@ +one = (1 + 2); +two = (one + 2); +two = (one + one); +three = ('1' + 2); + +four = ['1', two].join(); +four = ['1', two].join(''); +four = ['1', [one, two].join(',')].join(' '); +four = ['1', [one, two].join()].join(' '); +four = ['1', [one, two].join()].join(); + +five = 'string' + ['1', [one, two].join()].join() + 'string'; + +six = myArray.join(' '); +six = [arrayOne, arrayTwo].join(); + +// This is fine because the array is not created inline. +var x = 'x' + test[x].join('p') + 't'; \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Strings/JoinStringsUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Strings/JoinStringsUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Strings/JoinStringsUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/Strings/JoinStringsUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,79 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the JoinStrings sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer_MySource + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class MySource_Tests_Strings_JoinStringsUnitTest 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='JoinStringsUnitTest.js') + { + if ($testFile !== 'JoinStringsUnitTest.js') { + return array(); + } + + return array( + 6 => 1, + 7 => 1, + 8 => 2, + 9 => 2, + 10 => 2, + 12 => 2, + 15 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/ruleset.xml php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/ruleset.xml --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/ruleset.xml 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/ruleset.xml 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,18 @@ + + + The MySource coding standard builds on the Squiz coding standard. Currently used for MySource Mini development. + + */Tests/* + */Oven/* + */data/* + */jquery.js + */jquery.*.js + */viper/* + DALConf.inc + + + + + + + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Docs/Files/IncludingFileStandard.xml php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Docs/Files/IncludingFileStandard.xml --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Docs/Files/IncludingFileStandard.xml 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Docs/Files/IncludingFileStandard.xml 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,24 @@ + + + require_once. Anywhere you are conditionally including a class file (for example, factory methods), use include_once. Either of these will ensure that class files are included only once. They share the same file list, so you don't need to worry about mixing them - a file included with require_once will not be included again by include_once. + ]]> + + + include_once and require_once are statements, not functions. Parentheses should not surround the subject filename. + ]]> + + + + + + + ('PHP/CodeSniffer.php'); + ]]> + + + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Docs/Files/LineLengthStandard.xml php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Docs/Files/LineLengthStandard.xml --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Docs/Files/LineLengthStandard.xml 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Docs/Files/LineLengthStandard.xml 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,7 @@ + + + + + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Docs/Functions/FunctionCallSignatureStandard.xml php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Docs/Functions/FunctionCallSignatureStandard.xml --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Docs/Functions/FunctionCallSignatureStandard.xml 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Docs/Functions/FunctionCallSignatureStandard.xml 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,19 @@ + + + + + + + + + + ( $bar, $baz, $quux ) ; + ]]> + + + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Docs/Functions/ValidDefaultValueStandard.xml php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Docs/Functions/ValidDefaultValueStandard.xml --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Docs/Functions/ValidDefaultValueStandard.xml 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Docs/Functions/ValidDefaultValueStandard.xml 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,25 @@ + + + + + + + $persistent = false) +{ + ... +} + ]]> + + + $persistent = false, $dsn) +{ + ... +} + ]]> + + + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Docs/NamingConventions/ValidClassNameStandard.xml php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Docs/NamingConventions/ValidClassNameStandard.xml --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Docs/NamingConventions/ValidClassNameStandard.xml 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Docs/NamingConventions/ValidClassNameStandard.xml 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,23 @@ + + + + + + + + + + + + + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Docs/NamingConventions/ValidFunctionNameStandard.xml php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Docs/NamingConventions/ValidFunctionNameStandard.xml --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Docs/NamingConventions/ValidFunctionNameStandard.xml 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Docs/NamingConventions/ValidFunctionNameStandard.xml 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,23 @@ + + + + + + + + + + + + + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/Classes/ClassDeclarationSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/Classes/ClassDeclarationSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/Classes/ClassDeclarationSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/Classes/ClassDeclarationSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,125 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Class Declaration Test. + * + * Checks the declaration of the class is correct. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PEAR_Sniffs_Classes_ClassDeclarationSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * The number of spaces code should be indented. + * + * @var int + */ + public $indent = 4; + + + /** + * 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 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(); + $errorData = array($tokens[$stackPtr]['content']); + + if (isset($tokens[$stackPtr]['scope_opener']) === false) { + $error = 'Possible parse error: %s missing opening or closing brace'; + $phpcsFile->addWarning($error, $stackPtr, 'MissingBrace', $errorData); + return; + } + + $curlyBrace = $tokens[$stackPtr]['scope_opener']; + $lastContent = $phpcsFile->findPrevious(T_WHITESPACE, ($curlyBrace - 1), $stackPtr, true); + $classLine = $tokens[$lastContent]['line']; + $braceLine = $tokens[$curlyBrace]['line']; + if ($braceLine === $classLine) { + $error = 'Opening brace of a %s must be on the line after the definition'; + $phpcsFile->addError($error, $curlyBrace, 'OpenBraceNewLine', $errorData); + return; + } else if ($braceLine > ($classLine + 1)) { + $error = 'Opening brace of a %s must be on the line following the %s declaration; found %s line(s)'; + $data = array( + $tokens[$stackPtr]['content'], + $tokens[$stackPtr]['content'], + ($braceLine - $classLine - 1), + ); + $phpcsFile->addError($error, $curlyBrace, 'OpenBraceWrongLine', $data); + return; + } + + if ($tokens[($curlyBrace + 1)]['content'] !== $phpcsFile->eolChar) { + $error = 'Opening %s brace must be on a line by itself'; + $phpcsFile->addError($error, $curlyBrace, 'OpenBraceNotAlone', $errorData); + } + + if ($tokens[($curlyBrace - 1)]['code'] === T_WHITESPACE) { + $prevContent = $tokens[($curlyBrace - 1)]['content']; + if ($prevContent === $phpcsFile->eolChar) { + $spaces = 0; + } else { + $blankSpace = substr($prevContent, strpos($prevContent, $phpcsFile->eolChar)); + $spaces = strlen($blankSpace); + } + + $expected = ($tokens[$stackPtr]['level'] * $this->indent); + if ($spaces !== $expected) { + $error = 'Expected %s spaces before opening brace; %s found'; + $data = array( + $expected, + $spaces, + ); + $phpcsFile->addError($error, $curlyBrace, 'SpaceBeforeBrace', $data); + } + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/Commenting/ClassCommentSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/Commenting/ClassCommentSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/Commenting/ClassCommentSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/Commenting/ClassCommentSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,233 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +if (class_exists('PHP_CodeSniffer_CommentParser_ClassCommentParser', true) === false) { + $error = 'Class PHP_CodeSniffer_CommentParser_ClassCommentParser not found'; + throw new PHP_CodeSniffer_Exception($error); +} + +if (class_exists('PEAR_Sniffs_Commenting_FileCommentSniff', true) === false) { + $error = 'Class PEAR_Sniffs_Commenting_FileCommentSniff not found'; + throw new PHP_CodeSniffer_Exception($error); +} + +/** + * Parses and verifies the doc comments for classes. + * + * Verifies that : + *
    + *
  • A doc comment exists.
  • + *
  • There is a blank newline after the short description.
  • + *
  • There is a blank newline between the long and short description.
  • + *
  • There is a blank newline between the long description and tags.
  • + *
  • Check the order of the tags.
  • + *
  • Check the indentation of each tag.
  • + *
  • Check required and optional tags and the format of their content.
  • + *
+ * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PEAR_Sniffs_Commenting_ClassCommentSniff extends PEAR_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 = array( + T_ABSTRACT, + T_WHITESPACE, + T_FINAL, + ); + + // Extract the class comment docblock. + $commentEnd = $phpcsFile->findPrevious($find, ($stackPtr - 1), null, true); + + if ($commentEnd !== false && $tokens[$commentEnd]['code'] === T_COMMENT) { + $error = 'You must use "/**" style comments for a %s comment'; + $phpcsFile->addError($error, $stackPtr, 'WrongStyle', $errorData); + return; + } else if ($commentEnd === false + || $tokens[$commentEnd]['code'] !== T_DOC_COMMENT + ) { + $phpcsFile->addError('Missing %s doc comment', $stackPtr, 'Missing', $errorData); + return; + } + + $commentStart = ($phpcsFile->findPrevious(T_DOC_COMMENT, ($commentEnd - 1), null, true) + 1); + $commentNext = $phpcsFile->findPrevious(T_WHITESPACE, ($commentEnd + 1), $stackPtr, false, $phpcsFile->eolChar); + + // Distinguish file and class comment. + $prevClassToken = $phpcsFile->findPrevious(T_CLASS, ($stackPtr - 1)); + if ($prevClassToken === false) { + // This is the first class token in this file, need extra checks. + $prevNonComment = $phpcsFile->findPrevious(T_DOC_COMMENT, ($commentStart - 1), null, true); + if ($prevNonComment !== false) { + $prevComment = $phpcsFile->findPrevious(T_DOC_COMMENT, ($prevNonComment - 1)); + if ($prevComment === false) { + // There is only 1 doc comment between open tag and class token. + $newlineToken = $phpcsFile->findNext(T_WHITESPACE, ($commentEnd + 1), $stackPtr, false, $phpcsFile->eolChar); + if ($newlineToken !== false) { + $newlineToken = $phpcsFile->findNext( + T_WHITESPACE, + ($newlineToken + 1), + $stackPtr, + false, + $phpcsFile->eolChar + ); + + if ($newlineToken !== false) { + // Blank line between the class and the doc block. + // The doc block is most likely a file comment. + $error = 'Missing %s doc comment'; + $phpcsFile->addError($error, ($stackPtr + 1), 'Missing', $errorData); + return; + } + }//end if + }//end if + }//end if + }//end if + + $comment = $phpcsFile->getTokensAsString( + $commentStart, + ($commentEnd - $commentStart + 1) + ); + + // Parse the class comment.docblock. + try { + $this->commentParser = new PHP_CodeSniffer_CommentParser_ClassCommentParser($comment, $phpcsFile); + $this->commentParser->parse(); + } catch (PHP_CodeSniffer_CommentParser_ParserException $e) { + $line = ($e->getLineWithinComment() + $commentStart); + $phpcsFile->addError($e->getMessage(), $line, 'FailedParse'); + return; + } + + $comment = $this->commentParser->getComment(); + if (is_null($comment) === true) { + $error = 'Doc comment is empty for %s'; + $phpcsFile->addError($error, $commentStart, 'Empty', $errorData); + return; + } + + // No extra newline before short description. + $short = $comment->getShortComment(); + $newlineCount = 0; + $newlineSpan = strspn($short, $phpcsFile->eolChar); + if ($short !== '' && $newlineSpan > 0) { + $error = 'Extra newline(s) found before %s comment short description'; + $phpcsFile->addError($error, ($commentStart + 1), 'SpacingBeforeShort', $errorData); + } + + $newlineCount = (substr_count($short, $phpcsFile->eolChar) + 1); + + // Exactly one blank line between short and long description. + $long = $comment->getLongComment(); + if (empty($long) === false) { + $between = $comment->getWhiteSpaceBetween(); + $newlineBetween = substr_count($between, $phpcsFile->eolChar); + if ($newlineBetween !== 2) { + $error = 'There must be exactly one blank line between descriptions in %s comments'; + $phpcsFile->addError($error, ($commentStart + $newlineCount + 1), 'SpacingAfterShort', $errorData); + } + + $newlineCount += $newlineBetween; + } + + // Exactly one blank line before tags. + $tags = $this->commentParser->getTagOrders(); + if (count($tags) > 1) { + $newlineSpan = $comment->getNewlineAfter(); + if ($newlineSpan !== 2) { + $error = 'There must be exactly one blank line before the tags in %s comments'; + if ($long !== '') { + $newlineCount += (substr_count($long, $phpcsFile->eolChar) - $newlineSpan + 1); + } + + $phpcsFile->addError($error, ($commentStart + $newlineCount), 'SpacingBeforeTags', $errorData); + $short = rtrim($short, $phpcsFile->eolChar.' '); + } + } + + // Check each tag. + $this->processTags($commentStart, $commentEnd); + + }//end process() + + + /** + * Process the version tag. + * + * @param int $errorPos The line number where the error occurs. + * + * @return void + */ + protected function processVersion($errorPos) + { + $version = $this->commentParser->getVersion(); + if ($version !== null) { + $content = $version->getContent(); + $matches = array(); + if (empty($content) === true) { + $error = 'Content missing for @version tag in doc comment'; + $this->currentFile->addError($error, $errorPos, 'EmptyVersion'); + } else if ((strstr($content, 'Release:') === false)) { + $error = 'Invalid version "%s" in doc comment; consider "Release: " instead'; + $data = array($content); + $this->currentFile->addWarning($error, $errorPos, 'InvalidVersion', $data); + } + } + + }//end processVersion() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/Commenting/FileCommentSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/Commenting/FileCommentSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/Commenting/FileCommentSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/Commenting/FileCommentSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,797 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +if (class_exists('PHP_CodeSniffer_CommentParser_ClassCommentParser', true) === false) { + throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_CommentParser_ClassCommentParser not found'); +} + +/** + * Parses and verifies the doc comments for files. + * + * Verifies that : + *
    + *
  • A doc comment exists.
  • + *
  • There is a blank newline after the short description.
  • + *
  • There is a blank newline between the long and short description.
  • + *
  • There is a blank newline between the long description and tags.
  • + *
  • A PHP version is specified.
  • + *
  • Check the order of the tags.
  • + *
  • Check the indentation of each tag.
  • + *
  • Check required and optional tags and the format of their content.
  • + *
+ * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ + +class PEAR_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * The header comment parser for the current file. + * + * @var PHP_CodeSniffer_Comment_Parser_ClassCommentParser + */ + protected $commentParser = null; + + /** + * The current PHP_CodeSniffer_File object we are processing. + * + * @var PHP_CodeSniffer_File + */ + protected $currentFile = null; + + /** + * Tags in correct order and related info. + * + * @var array + */ + protected $tags = array( + 'category' => array( + 'required' => true, + 'allow_multiple' => false, + 'order_text' => 'precedes @package', + ), + 'package' => array( + 'required' => true, + 'allow_multiple' => false, + 'order_text' => 'follows @category', + ), + 'subpackage' => array( + 'required' => false, + 'allow_multiple' => false, + 'order_text' => 'follows @package', + ), + 'author' => array( + 'required' => true, + 'allow_multiple' => true, + 'order_text' => 'follows @subpackage (if used) or @package', + ), + 'copyright' => array( + 'required' => false, + 'allow_multiple' => true, + 'order_text' => 'follows @author', + ), + 'license' => array( + 'required' => true, + 'allow_multiple' => false, + 'order_text' => 'follows @copyright (if used) or @author', + ), + 'version' => array( + 'required' => false, + 'allow_multiple' => false, + 'order_text' => 'follows @license', + ), + 'link' => array( + 'required' => true, + 'allow_multiple' => true, + 'order_text' => 'follows @version', + ), + 'see' => array( + 'required' => false, + 'allow_multiple' => true, + 'order_text' => 'follows @link', + ), + 'since' => array( + 'required' => false, + 'allow_multiple' => false, + 'order_text' => 'follows @see (if used) or @link', + ), + 'deprecated' => array( + 'required' => false, + 'allow_multiple' => false, + 'order_text' => 'follows @since (if used) or @see (if used) or @link', + ), + ); + + + /** + * 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 void + */ + public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + $this->currentFile = $phpcsFile; + + // We are only interested if this is the first open tag. + if ($stackPtr !== 0) { + if ($phpcsFile->findPrevious(T_OPEN_TAG, ($stackPtr - 1)) !== false) { + return; + } + } + + $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; + } else if ($tokens[$commentStart]['code'] === T_COMMENT) { + $error = 'You must use "/**" style comments for a file comment'; + $phpcsFile->addError($error, $errorToken, 'WrongStyle'); + return; + } else if ($commentStart === false + || $tokens[$commentStart]['code'] !== T_DOC_COMMENT + ) { + $phpcsFile->addError('Missing file doc comment', $errorToken, 'Missing'); + return; + } else { + + // Extract the header comment docblock. + $commentEnd = $phpcsFile->findNext( + T_DOC_COMMENT, + ($commentStart + 1), + null, + true + ); + + $commentEnd--; + + // Check if there is only 1 doc comment between the + // open tag and class token. + $nextToken = array( + T_ABSTRACT, + T_CLASS, + T_FUNCTION, + T_DOC_COMMENT, + ); + + $commentNext = $phpcsFile->findNext($nextToken, ($commentEnd + 1)); + if ($commentNext !== false + && $tokens[$commentNext]['code'] !== T_DOC_COMMENT + ) { + // Found a class token right after comment doc block. + $newlineToken = $phpcsFile->findNext( + T_WHITESPACE, + ($commentEnd + 1), + $commentNext, + false, + $phpcsFile->eolChar + ); + + if ($newlineToken !== false) { + $newlineToken = $phpcsFile->findNext( + T_WHITESPACE, + ($newlineToken + 1), + $commentNext, + false, + $phpcsFile->eolChar + ); + + if ($newlineToken === false) { + // No blank line between the class token and the doc block. + // The doc block is most likely a class comment. + $error = 'Missing file doc comment'; + $phpcsFile->addError($error, $errorToken, 'Missing'); + return; + } + } + }//end if + + $comment = $phpcsFile->getTokensAsString( + $commentStart, + ($commentEnd - $commentStart + 1) + ); + + // Parse the header comment docblock. + try { + $this->commentParser = new PHP_CodeSniffer_CommentParser_ClassCommentParser($comment, $phpcsFile); + $this->commentParser->parse(); + } catch (PHP_CodeSniffer_CommentParser_ParserException $e) { + $line = ($e->getLineWithinComment() + $commentStart); + $phpcsFile->addError($e->getMessage(), $line, 'FailedParse'); + return; + } + + $comment = $this->commentParser->getComment(); + if (is_null($comment) === true) { + $error = 'File doc comment is empty'; + $phpcsFile->addError($error, $commentStart, 'Empty'); + return; + } + + // No extra newline before short description. + $short = $comment->getShortComment(); + $newlineCount = 0; + $newlineSpan = strspn($short, $phpcsFile->eolChar); + if ($short !== '' && $newlineSpan > 0) { + $error = 'Extra newline(s) found before file comment short description'; + $phpcsFile->addError($error, ($commentStart + 1), 'SpacingBefore'); + } + + $newlineCount = (substr_count($short, $phpcsFile->eolChar) + 1); + + // Exactly one blank line between short and long description. + $long = $comment->getLongComment(); + if (empty($long) === false) { + $between = $comment->getWhiteSpaceBetween(); + $newlineBetween = substr_count($between, $phpcsFile->eolChar); + if ($newlineBetween !== 2) { + $error = 'There must be exactly one blank line between descriptions in file comment'; + $phpcsFile->addError($error, ($commentStart + $newlineCount + 1), 'DescriptionSpacing'); + } + + $newlineCount += $newlineBetween; + } + + // Exactly one blank line before tags. + $tags = $this->commentParser->getTagOrders(); + if (count($tags) > 1) { + $newlineSpan = $comment->getNewlineAfter(); + if ($newlineSpan !== 2) { + $error = 'There must be exactly one blank line before the tags in file comment'; + if ($long !== '') { + $newlineCount += (substr_count($long, $phpcsFile->eolChar) - $newlineSpan + 1); + } + + $phpcsFile->addError($error, ($commentStart + $newlineCount), 'SpacingBeforeTags'); + $short = rtrim($short, $phpcsFile->eolChar.' '); + } + } + + // Check the PHP Version. + $this->processPHPVersion($commentStart, $commentEnd, $long); + + // Check each tag. + $this->processTags($commentStart, $commentEnd); + }//end if + + }//end process() + + + /** + * Check that the PHP version is specified. + * + * @param int $commentStart Position in the stack where the comment started. + * @param int $commentEnd Position in the stack where the comment ended. + * @param string $commentText The text of the function comment. + * + * @return void + */ + protected function processPHPVersion($commentStart, $commentEnd, $commentText) + { + if (strstr(strtolower($commentText), 'php version') === false) { + $error = 'PHP version not specified'; + $this->currentFile->addWarning($error, $commentEnd, 'MissingVersion'); + } + + }//end processPHPVersion() + + + /** + * Processes each required or optional tag. + * + * @param int $commentStart Position in the stack where the comment started. + * @param int $commentEnd Position in the stack where the comment ended. + * + * @return void + */ + protected function processTags($commentStart, $commentEnd) + { + $docBlock = (get_class($this) === 'PEAR_Sniffs_Commenting_FileCommentSniff') ? 'file' : 'class'; + $foundTags = $this->commentParser->getTagOrders(); + $orderIndex = 0; + $indentation = array(); + $longestTag = 0; + $errorPos = 0; + + foreach ($this->tags as $tag => $info) { + + // Required tag missing. + if ($info['required'] === true && in_array($tag, $foundTags) === false) { + $error = 'Missing @%s tag in %s comment'; + $data = array( + $tag, + $docBlock, + ); + $this->currentFile->addError($error, $commentEnd, 'MissingTag', $data); + continue; + } + + // Get the line number for current tag. + $tagName = ucfirst($tag); + if ($info['allow_multiple'] === true) { + $tagName .= 's'; + } + + $getMethod = 'get'.$tagName; + $tagElement = $this->commentParser->$getMethod(); + if (is_null($tagElement) === true || empty($tagElement) === true) { + continue; + } + + $errorPos = $commentStart; + if (is_array($tagElement) === false) { + $errorPos = ($commentStart + $tagElement->getLine()); + } + + // Get the tag order. + $foundIndexes = array_keys($foundTags, $tag); + + if (count($foundIndexes) > 1) { + // Multiple occurrence not allowed. + if ($info['allow_multiple'] === false) { + $error = 'Only 1 @%s tag is allowed in a %s comment'; + $data = array( + $tag, + $docBlock, + ); + $this->currentFile->addError($error, $errorPos, 'DuplicateTag', $data); + } else { + // Make sure same tags are grouped together. + $i = 0; + $count = $foundIndexes[0]; + foreach ($foundIndexes as $index) { + if ($index !== $count) { + $errorPosIndex + = ($errorPos + $tagElement[$i]->getLine()); + $error = '@%s tags must be grouped together'; + $data = array($tag); + $this->currentFile->addError($error, $errorPosIndex, 'TagsNotGrouped', $data); + } + + $i++; + $count++; + } + } + }//end if + + // Check tag order. + if ($foundIndexes[0] > $orderIndex) { + $orderIndex = $foundIndexes[0]; + } else { + if (is_array($tagElement) === true && empty($tagElement) === false) { + $errorPos += $tagElement[0]->getLine(); + } + + $error = 'The @%s tag is in the wrong order; the tag %s'; + $data = array( + $tag, + $info['order_text'], + ); + $this->currentFile->addError($error, $errorPos, 'WrongTagOrder', $data); + } + + // Store the indentation for checking. + $len = strlen($tag); + if ($len > $longestTag) { + $longestTag = $len; + } + + if (is_array($tagElement) === true) { + foreach ($tagElement as $key => $element) { + $indentation[] = array( + 'tag' => $tag, + 'space' => $this->getIndentation($tag, $element), + 'line' => $element->getLine(), + ); + } + } else { + $indentation[] = array( + 'tag' => $tag, + 'space' => $this->getIndentation($tag, $tagElement), + ); + } + + $method = 'process'.$tagName; + if (method_exists($this, $method) === true) { + // Process each tag if a method is defined. + call_user_func(array($this, $method), $errorPos); + } else { + if (is_array($tagElement) === true) { + foreach ($tagElement as $key => $element) { + $element->process( + $this->currentFile, + $commentStart, + $docBlock + ); + } + } else { + $tagElement->process( + $this->currentFile, + $commentStart, + $docBlock + ); + } + } + }//end foreach + + foreach ($indentation as $indentInfo) { + if ($indentInfo['space'] !== 0 + && $indentInfo['space'] !== ($longestTag + 1) + ) { + $expected = (($longestTag - strlen($indentInfo['tag'])) + 1); + $space = ($indentInfo['space'] - strlen($indentInfo['tag'])); + $error = '@%s tag comment indented incorrectly; expected %s spaces but found %s'; + $data = array( + $indentInfo['tag'], + $expected, + $space, + ); + + $getTagMethod = 'get'.ucfirst($indentInfo['tag']); + + if ($this->tags[$indentInfo['tag']]['allow_multiple'] === true) { + $line = $indentInfo['line']; + } else { + $tagElem = $this->commentParser->$getTagMethod(); + $line = $tagElem->getLine(); + } + + $this->currentFile->addError($error, ($commentStart + $line), 'TagIndent', $data); + } + } + + }//end processTags() + + + /** + * Get the indentation information of each tag. + * + * @param string $tagName The name of the + * doc comment + * element. + * @param PHP_CodeSniffer_CommentParser_DocElement $tagElement The doc comment + * element. + * + * @return void + */ + protected function getIndentation($tagName, $tagElement) + { + if ($tagElement instanceof PHP_CodeSniffer_CommentParser_SingleElement) { + if ($tagElement->getContent() !== '') { + return (strlen($tagName) + substr_count($tagElement->getWhitespaceBeforeContent(), ' ')); + } + } else if ($tagElement instanceof PHP_CodeSniffer_CommentParser_PairElement) { + if ($tagElement->getValue() !== '') { + return (strlen($tagName) + substr_count($tagElement->getWhitespaceBeforeValue(), ' ')); + } + } + + return 0; + + }//end getIndentation() + + + /** + * Process the category tag. + * + * @param int $errorPos The line number where the error occurs. + * + * @return void + */ + protected function processCategory($errorPos) + { + $category = $this->commentParser->getCategory(); + if ($category !== null) { + $content = $category->getContent(); + if ($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) { + $newName .= ucfirst($bit).'_'; + } + + $error = 'Category name "%s" is not valid; consider "%s" instead'; + $validName = trim($newName, '_'); + $data = array( + $content, + $validName, + ); + $this->currentFile->addError($error, $errorPos, 'InvalidCategory', $data); + } + } else { + $error = '@category tag must contain a name'; + $this->currentFile->addError($error, $errorPos, 'EmptyCategory'); + } + } + + }//end processCategory() + + + /** + * Process the package tag. + * + * @param int $errorPos The line number where the error occurs. + * + * @return void + */ + protected function processPackage($errorPos) + { + $package = $this->commentParser->getPackage(); + if ($package === null) { + return; + } + + $content = $package->getContent(); + if ($content === '') { + $error = '@package tag must contain a name'; + $this->currentFile->addError($error, $errorPos, 'EmptyPackage'); + return; + } + + if (PHP_CodeSniffer::isUnderscoreName($content) === true) { + return; + } + + $newContent = str_replace(' ', '_', $content); + $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) { + $newName .= strtoupper($bit{0}).substr($bit, 1).'_'; + } + + $error = 'Package name "%s" is not valid; consider "%s" instead'; + $validName = trim($newName, '_'); + $data = array( + $content, + $validName, + ); + $this->currentFile->addError($error, $errorPos, 'InvalidPackage', $data); + + }//end processPackage() + + + /** + * Process the subpackage tag. + * + * @param int $errorPos The line number where the error occurs. + * + * @return void + */ + protected function processSubpackage($errorPos) + { + $package = $this->commentParser->getSubpackage(); + if ($package !== null) { + $content = $package->getContent(); + if ($content !== '') { + if (PHP_CodeSniffer::isUnderscoreName($content) !== true) { + $newContent = str_replace(' ', '_', $content); + $nameBits = explode('_', $newContent); + $firstBit = array_shift($nameBits); + $newName = strtoupper($firstBit{0}).substr($firstBit, 1).'_'; + foreach ($nameBits as $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, + ); + $this->currentFile->addError($error, $errorPos, 'InvalidSubpackage', $data); + } + } else { + $error = '@subpackage tag must contain a name'; + $this->currentFile->addError($error, $errorPos, 'EmptySubpackage'); + } + } + + }//end processSubpackage() + + + /** + * Process the author tag(s) that this header comment has. + * + * This function is different from other _process functions + * as $authors is an array of SingleElements, so we work out + * the errorPos for each element separately + * + * @param int $commentStart The position in the stack where + * the comment started. + * + * @return void + */ + protected function processAuthors($commentStart) + { + $authors = $this->commentParser->getAuthors(); + // Report missing return. + if (empty($authors) === false) { + foreach ($authors as $author) { + $errorPos = ($commentStart + $author->getLine()); + $content = $author->getContent(); + if ($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 "'; + $this->currentFile->addError($error, $errorPos, 'InvalidAuthors'); + } + } else { + $error = 'Content missing for @author tag in %s comment'; + $docBlock = (get_class($this) === 'PEAR_Sniffs_Commenting_FileCommentSniff') ? 'file' : 'class'; + $data = array($docBlock); + $this->currentFile->addError($error, $errorPos, 'EmptyAuthors', $data); + } + } + } + + }//end processAuthors() + + + /** + * Process the copyright tags. + * + * @param int $commentStart The position in the stack where + * the comment started. + * + * @return void + */ + protected function processCopyrights($commentStart) + { + $copyrights = $this->commentParser->getCopyrights(); + foreach ($copyrights as $copyright) { + $errorPos = ($commentStart + $copyright->getLine()); + $content = $copyright->getContent(); + if ($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'; + $this->currentFile->addError($error, $errorPos, '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"; + $this->currentFile->addWarning($error, $errorPos, 'InvalidCopyright'); + } + } + } else { + $error = '@copyright tag must contain a year and the name of the copyright holder'; + $this->currentFile->addError($error, $errorPos, 'EmptyCopyright'); + } + } else { + $error = '@copyright tag must contain a year and the name of the copyright holder'; + $this->currentFile->addError($error, $errorPos, 'EmptyCopyright'); + }//end if + }//end if + + }//end processCopyrights() + + + /** + * Process the license tag. + * + * @param int $errorPos The line number where the error occurs. + * + * @return void + */ + protected function processLicense($errorPos) + { + $license = $this->commentParser->getLicense(); + if ($license !== null) { + $value = $license->getValue(); + $comment = $license->getComment(); + if ($value === '' || $comment === '') { + $error = '@license tag must contain a URL and a license name'; + $this->currentFile->addError($error, $errorPos, 'EmptyLicense'); + } + } + + }//end processLicense() + + + /** + * Process the version tag. + * + * @param int $errorPos The line number where the error occurs. + * + * @return void + */ + protected function processVersion($errorPos) + { + $version = $this->commentParser->getVersion(); + if ($version !== null) { + $content = $version->getContent(); + $matches = array(); + if (empty($content) === true) { + $error = 'Content missing for @version tag in file comment'; + $this->currentFile->addError($error, $errorPos, 'EmptyVersion'); + } else if (strstr($content, 'CVS:') === false + && strstr($content, 'SVN:') === false + && strstr($content, 'GIT:') === false + ) { + $error = 'Invalid version "%s" in file comment; consider "CVS: " or "SVN: " or "GIT: " instead'; + $data = array($content); + $this->currentFile->addWarning($error, $errorPos, 'InvalidVersion', $data); + } + } + + }//end processVersion() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/Commenting/FunctionCommentSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/Commenting/FunctionCommentSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/Commenting/FunctionCommentSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/Commenting/FunctionCommentSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,490 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +if (class_exists('PHP_CodeSniffer_CommentParser_FunctionCommentParser', true) === false) { + throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_CommentParser_FunctionCommentParser not found'); +} + +/** + * Parses and verifies the doc comments for functions. + * + * Verifies that : + *
    + *
  • A comment exists
  • + *
  • There is a blank newline after the short description.
  • + *
  • There is a blank newline between the long and short description.
  • + *
  • There is a blank newline between the long description and tags.
  • + *
  • Parameter names represent those in the method.
  • + *
  • Parameter comments are in the correct order
  • + *
  • Parameter comments are complete
  • + *
  • A space is present before the first and after the last parameter
  • + *
  • A return type exists
  • + *
  • There must be one blank line between body and headline comments.
  • + *
  • Any throw tag must have an exception class.
  • + *
+ * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PEAR_Sniffs_Commenting_FunctionCommentSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * The name of the method that we are currently processing. + * + * @var string + */ + private $_methodName = ''; + + /** + * The position in the stack where the function token was found. + * + * @var int + */ + private $_functionToken = null; + + /** + * The position in the stack where the class token was found. + * + * @var int + */ + private $_classToken = null; + + /** + * The function comment parser for the current method. + * + * @var PHP_CodeSniffer_Comment_Parser_FunctionCommentParser + */ + protected $commentParser = null; + + /** + * The current PHP_CodeSniffer_File object we are processing. + * + * @var PHP_CodeSniffer_File + */ + protected $currentFile = null; + + + /** + * 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) + { + $find = array( + T_COMMENT, + T_DOC_COMMENT, + T_CLASS, + T_FUNCTION, + T_OPEN_TAG, + ); + + $commentEnd = $phpcsFile->findPrevious($find, ($stackPtr - 1)); + + if ($commentEnd === false) { + return; + } + + $this->currentFile = $phpcsFile; + $tokens = $phpcsFile->getTokens(); + + // If the token that we found was a class or a function, then this + // function has no doc comment. + $code = $tokens[$commentEnd]['code']; + + if ($code === T_COMMENT) { + $error = 'You must use "/**" style comments for a function comment'; + $phpcsFile->addError($error, $stackPtr, 'WrongStyle'); + return; + } else if ($code !== T_DOC_COMMENT) { + $phpcsFile->addError('Missing function doc comment', $stackPtr, 'Missing'); + return; + } + + // If there is any code between the function keyword and the doc block + // then the doc block is not for us. + $ignore = PHP_CodeSniffer_Tokens::$scopeModifiers; + $ignore[] = T_STATIC; + $ignore[] = T_WHITESPACE; + $ignore[] = T_ABSTRACT; + $ignore[] = T_FINAL; + $prevToken = $phpcsFile->findPrevious($ignore, ($stackPtr - 1), null, true); + if ($prevToken !== $commentEnd) { + $phpcsFile->addError('Missing function doc comment', $stackPtr, 'Missing'); + return; + } + + $this->_functionToken = $stackPtr; + + $this->_classToken = null; + foreach ($tokens[$stackPtr]['conditions'] as $condPtr => $condition) { + if ($condition === T_CLASS || $condition === T_INTERFACE) { + $this->_classToken = $condPtr; + break; + } + } + + // If the first T_OPEN_TAG is right before the comment, it is probably + // a file comment. + $commentStart = ($phpcsFile->findPrevious(T_DOC_COMMENT, ($commentEnd - 1), null, true) + 1); + $prevToken = $phpcsFile->findPrevious(T_WHITESPACE, ($commentStart - 1), null, true); + if ($tokens[$prevToken]['code'] === T_OPEN_TAG) { + // Is this the first open tag? + if ($stackPtr === 0 || $phpcsFile->findPrevious(T_OPEN_TAG, ($prevToken - 1)) === false) { + $phpcsFile->addError('Missing function doc comment', $stackPtr, 'Missing'); + return; + } + } + + $comment = $phpcsFile->getTokensAsString($commentStart, ($commentEnd - $commentStart + 1)); + $this->_methodName = $phpcsFile->getDeclarationName($stackPtr); + + try { + $this->commentParser = new PHP_CodeSniffer_CommentParser_FunctionCommentParser($comment, $phpcsFile); + $this->commentParser->parse(); + } catch (PHP_CodeSniffer_CommentParser_ParserException $e) { + $line = ($e->getLineWithinComment() + $commentStart); + $phpcsFile->addError($e->getMessage(), $line, 'FailedParse'); + return; + } + + $comment = $this->commentParser->getComment(); + if (is_null($comment) === true) { + $error = 'Function doc comment is empty'; + $phpcsFile->addError($error, $commentStart, 'Empty'); + return; + } + + $this->processParams($commentStart); + $this->processReturn($commentStart, $commentEnd); + $this->processThrows($commentStart); + + // No extra newline before short description. + $short = $comment->getShortComment(); + $newlineCount = 0; + $newlineSpan = strspn($short, $phpcsFile->eolChar); + if ($short !== '' && $newlineSpan > 0) { + $error = 'Extra newline(s) found before function comment short description'; + $phpcsFile->addError($error, ($commentStart + 1), 'SpacingBeforeShort'); + } + + $newlineCount = (substr_count($short, $phpcsFile->eolChar) + 1); + + // Exactly one blank line between short and long description. + $long = $comment->getLongComment(); + if (empty($long) === false) { + $between = $comment->getWhiteSpaceBetween(); + $newlineBetween = substr_count($between, $phpcsFile->eolChar); + if ($newlineBetween !== 2) { + $error = 'There must be exactly one blank line between descriptions in function comment'; + $phpcsFile->addError($error, ($commentStart + $newlineCount + 1), 'SpacingAfterShort'); + } + + $newlineCount += $newlineBetween; + } + + // Exactly one blank line before tags. + $params = $this->commentParser->getTagOrders(); + if (count($params) > 1) { + $newlineSpan = $comment->getNewlineAfter(); + if ($newlineSpan !== 2) { + $error = 'There must be exactly one blank line before the tags in function comment'; + if ($long !== '') { + $newlineCount += (substr_count($long, $phpcsFile->eolChar) - $newlineSpan + 1); + } + + $phpcsFile->addError($error, ($commentStart + $newlineCount), 'SpacingBeforeTags'); + $short = rtrim($short, $phpcsFile->eolChar.' '); + } + } + + }//end process() + + + /** + * Process any throw tags that this function comment has. + * + * @param int $commentStart The position in the stack where the + * comment started. + * + * @return void + */ + protected function processThrows($commentStart) + { + if (count($this->commentParser->getThrows()) === 0) { + return; + } + + foreach ($this->commentParser->getThrows() as $throw) { + + $exception = $throw->getValue(); + $errorPos = ($commentStart + $throw->getLine()); + + if ($exception === '') { + $error = '@throws tag must contain the exception class name'; + $this->currentFile->addError($error, $errorPos, 'EmptyThrows'); + } + } + + }//end processThrows() + + + /** + * Process the return comment of this function comment. + * + * @param int $commentStart The position in the stack where the comment started. + * @param int $commentEnd The position in the stack where the comment ended. + * + * @return void + */ + protected function processReturn($commentStart, $commentEnd) + { + // Skip constructor and destructor. + $className = ''; + if ($this->_classToken !== null) { + $className = $this->currentFile->getDeclarationName($this->_classToken); + $className = strtolower(ltrim($className, '_')); + } + + $methodName = strtolower(ltrim($this->_methodName, '_')); + $isSpecialMethod = ($this->_methodName === '__construct' || $this->_methodName === '__destruct'); + + if ($isSpecialMethod === false && $methodName !== $className) { + // Report missing return tag. + if ($this->commentParser->getReturn() === null) { + $error = 'Missing @return tag in function comment'; + $this->currentFile->addError($error, $commentEnd, 'MissingReturn'); + } else if (trim($this->commentParser->getReturn()->getRawContent()) === '') { + $error = '@return tag is empty in function comment'; + $errorPos = ($commentStart + $this->commentParser->getReturn()->getLine()); + $this->currentFile->addError($error, $errorPos, 'EmptyReturn'); + } + } + + }//end processReturn() + + + /** + * Process the function parameter comments. + * + * @param int $commentStart The position in the stack where + * the comment started. + * + * @return void + */ + protected function processParams($commentStart) + { + $realParams = $this->currentFile->getMethodParameters($this->_functionToken); + + $params = $this->commentParser->getParams(); + $foundParams = array(); + + if (empty($params) === false) { + + $lastParm = (count($params) - 1); + if (substr_count($params[$lastParm]->getWhitespaceAfter(), $this->currentFile->eolChar) !== 2) { + $error = 'Last parameter comment requires a blank newline after it'; + $errorPos = ($params[$lastParm]->getLine() + $commentStart); + $this->currentFile->addError($error, $errorPos, 'SpacingAfterParams'); + } + + // Parameters must appear immediately after the comment. + if ($params[0]->getOrder() !== 2) { + $error = 'Parameters must appear immediately after the comment'; + $errorPos = ($params[0]->getLine() + $commentStart); + $this->currentFile->addError($error, $errorPos, 'SpacingBeforeParams'); + } + + $previousParam = null; + $spaceBeforeVar = 10000; + $spaceBeforeComment = 10000; + $longestType = 0; + $longestVar = 0; + + foreach ($params as $param) { + + $paramComment = trim($param->getComment()); + $errorPos = ($param->getLine() + $commentStart); + + // Make sure that there is only one space before the var type. + if ($param->getWhitespaceBeforeType() !== ' ') { + $error = 'Expected 1 space before variable type'; + $this->currentFile->addError($error, $errorPos, 'SpacingBeforeParamType'); + } + + $spaceCount = substr_count($param->getWhitespaceBeforeVarName(), ' '); + if ($spaceCount < $spaceBeforeVar) { + $spaceBeforeVar = $spaceCount; + $longestType = $errorPos; + } + + $spaceCount = substr_count($param->getWhitespaceBeforeComment(), ' '); + + if ($spaceCount < $spaceBeforeComment && $paramComment !== '') { + $spaceBeforeComment = $spaceCount; + $longestVar = $errorPos; + } + + // Make sure they are in the correct order, + // and have the correct name. + $pos = $param->getPosition(); + + $paramName = ($param->getVarName() !== '') ? $param->getVarName() : '[ UNKNOWN ]'; + + if ($previousParam !== null) { + $previousName = ($previousParam->getVarName() !== '') ? $previousParam->getVarName() : 'UNKNOWN'; + + // Check to see if the parameters align properly. + if ($param->alignsVariableWith($previousParam) === false) { + $error = 'The variable names for parameters %s (%s) and %s (%s) do not align'; + $data = array( + $previousName, + ($pos - 1), + $paramName, + $pos, + ); + $this->currentFile->addError($error, $errorPos, 'ParameterNamesNotAligned', $data); + } + + if ($param->alignsCommentWith($previousParam) === false) { + $error = 'The comments for parameters %s (%s) and %s (%s) do not align'; + $data = array( + $previousName, + ($pos - 1), + $paramName, + $pos, + ); + $this->currentFile->addError($error, $errorPos, 'ParameterCommentsNotAligned', $data); + } + }//end if + + // Make sure the names of the parameter comment matches the + // actual parameter. + if (isset($realParams[($pos - 1)]) === true) { + $realName = $realParams[($pos - 1)]['name']; + $foundParams[] = $realName; + + // Append ampersand to name if passing by reference. + if ($realParams[($pos - 1)]['pass_by_reference'] === true) { + $realName = '&'.$realName; + } + + if ($realName !== $paramName) { + $code = 'ParamNameNoMatch'; + $data = array( + $paramName, + $realName, + $pos, + ); + + $error = 'Doc comment for var %s does not match '; + if (strtolower($paramName) === strtolower($realName)) { + $error .= 'case of '; + $code = 'ParamNameNoCaseMatch'; + } + + $error .= 'actual variable name %s at position %s'; + + $this->currentFile->addError($error, $errorPos, $code, $data); + } + } else { + // We must have an extra parameter comment. + $error = 'Superfluous doc comment at position '.$pos; + $this->currentFile->addError($error, $errorPos, 'ExtraParamComment'); + } + + if ($param->getVarName() === '') { + $error = 'Missing parameter name at position '.$pos; + $this->currentFile->addError($error, $errorPos, 'MissingParamName'); + } + + if ($param->getType() === '') { + $error = 'Missing type at position '.$pos; + $this->currentFile->addError($error, $errorPos, 'MissingParamType'); + } + + if ($paramComment === '') { + $error = 'Missing comment for param "%s" at position %s'; + $data = array( + $paramName, + $pos, + ); + $this->currentFile->addError($error, $errorPos, 'MissingParamComment', $data); + } + + $previousParam = $param; + + }//end foreach + + if ($spaceBeforeVar !== 1 && $spaceBeforeVar !== 10000 && $spaceBeforeComment !== 10000) { + $error = 'Expected 1 space after the longest type'; + $this->currentFile->addError($error, $longestType, 'SpacingAfterLongType'); + } + + if ($spaceBeforeComment !== 1 && $spaceBeforeComment !== 10000) { + $error = 'Expected 1 space after the longest variable name'; + $this->currentFile->addError($error, $longestVar, 'SpacingAfterLongName'); + } + + }//end if + + $realNames = array(); + foreach ($realParams as $realParam) { + $realNames[] = $realParam['name']; + } + + // Report and missing comments. + $diff = array_diff($realNames, $foundParams); + foreach ($diff as $neededParam) { + if (count($params) !== 0) { + $errorPos = ($params[(count($params) - 1)]->getLine() + $commentStart); + } else { + $errorPos = $commentStart; + } + + $error = 'Doc comment for "%s" missing'; + $data = array($neededParam); + $this->currentFile->addError($error, $errorPos, 'MissingParamTag', $data); + } + + }//end processParams() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/Commenting/InlineCommentSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/Commenting/InlineCommentSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/Commenting/InlineCommentSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/Commenting/InlineCommentSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,70 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * PHP_CodeSniffer_Sniffs_PEAR_Commenting_InlineCommentSniff. + * + * Checks that no perl-style comments are used. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PEAR_Sniffs_Commenting_InlineCommentSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array(T_COMMENT); + + }//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(); + + if ($tokens[$stackPtr]['content']{0} === '#') { + $error = 'Perl-style comments are not allowed. Use "// Comment."'; + $error .= ' or "/* comment */" instead.'; + $phpcsFile->addError($error, $stackPtr, 'WrongStyle'); + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/ControlStructures/ControlSignatureSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/ControlStructures/ControlSignatureSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/ControlStructures/ControlSignatureSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/ControlStructures/ControlSignatureSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,67 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +if (class_exists('PHP_CodeSniffer_Standards_AbstractPatternSniff', true) === false) { + throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_Standards_AbstractPatternSniff not found'); +} + +/** + * Verifies that control statements conform to their coding standards. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PEAR_Sniffs_ControlStructures_ControlSignatureSniff extends PHP_CodeSniffer_Standards_AbstractPatternSniff +{ + + /** + * If true, comments will be ignored if they are found in the code. + * + * @var boolean + */ + public $ignoreComments = true; + + + /** + * Returns the patterns that this test wishes to verify. + * + * @return array(string) + */ + protected function getPatterns() + { + return array( + 'do {EOL...} while (...);EOL', + 'while (...) {EOL', + 'for (...) {EOL', + 'if (...) {EOL', + 'foreach (...) {EOL', + '} else if (...) {EOL', + '} elseif (...) {EOL', + '} else {EOL', + 'do {EOL', + ); + + }//end getPatterns() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/ControlStructures/MultiLineConditionSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/ControlStructures/MultiLineConditionSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/ControlStructures/MultiLineConditionSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/ControlStructures/MultiLineConditionSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,179 @@ + + * @copyright 2006-2012 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 + */ + +/** + * PEAR_Sniffs_ControlStructures_MultiLineConditionSniff. + * + * Ensure multi-line IF conditions are defined correctly. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PEAR_Sniffs_ControlStructures_MultiLineConditionSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array(T_IF); + + }//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(); + + // We need to work out how far indented the if statement + // itself is, so we can work out how far to indent conditions. + $statementIndent = 0; + for ($i = ($stackPtr - 1); $i >= 0; $i--) { + if ($tokens[$i]['line'] !== $tokens[$stackPtr]['line']) { + $i++; + break; + } + } + + if ($i >= 0 && $tokens[$i]['code'] === T_WHITESPACE) { + $statementIndent = strlen($tokens[$i]['content']); + } + + // Each line between the parenthesis should be indented 4 spaces + // and start with an operator, unless the line is inside a + // function call, in which case it is ignored. + $openBracket = $tokens[$stackPtr]['parenthesis_opener']; + $closeBracket = $tokens[$stackPtr]['parenthesis_closer']; + $lastLine = $tokens[$openBracket]['line']; + for ($i = ($openBracket + 1); $i < $closeBracket; $i++) { + if ($tokens[$i]['line'] !== $lastLine) { + if ($tokens[$i]['line'] === $tokens[$closeBracket]['line']) { + $next = $phpcsFile->findNext(T_WHITESPACE, $i, null, true); + if ($next !== $closeBracket) { + // Closing bracket is on the same line as a condition. + $error = 'Closing parenthesis of a multi-line IF statement must be on a new line'; + $phpcsFile->addError($error, $i, 'CloseBracketNewLine'); + $expectedIndent = ($statementIndent + 4); + } else { + // Closing brace needs to be indented to the same level + // as the function. + $expectedIndent = $statementIndent; + } + } else { + $expectedIndent = ($statementIndent + 4); + } + + // We changed lines, so this should be a whitespace indent token. + if ($tokens[$i]['code'] !== T_WHITESPACE) { + $foundIndent = 0; + } else { + $foundIndent = strlen($tokens[$i]['content']); + } + + if ($expectedIndent !== $foundIndent) { + $error = 'Multi-line IF statement not indented correctly; expected %s spaces but found %s'; + $data = array( + $expectedIndent, + $foundIndent, + ); + $phpcsFile->addError($error, $i, 'Alignment', $data); + } + + if ($tokens[$i]['line'] !== $tokens[$closeBracket]['line']) { + $next = $phpcsFile->findNext(T_WHITESPACE, $i, null, true); + if (in_array($tokens[$next]['code'], PHP_CodeSniffer_Tokens::$booleanOperators) === false) { + $error = 'Each line in a multi-line IF statement must begin with a boolean operator'; + $phpcsFile->addError($error, $i, 'StartWithBoolean'); + } + } + + $lastLine = $tokens[$i]['line']; + }//end if + + if ($tokens[$i]['code'] === T_STRING) { + $next = $phpcsFile->findNext(T_WHITESPACE, ($i + 1), null, true); + if ($tokens[$next]['code'] === T_OPEN_PARENTHESIS) { + // This is a function call, so skip to the end as they + // have their own indentation rules. + $i = $tokens[$next]['parenthesis_closer']; + $lastLine = $tokens[$i]['line']; + continue; + } + } + }//end for + + // From here on, we are checking the spacing of the opening and closing + // braces. If this IF statement does not use braces, we end here. + if (isset($tokens[$stackPtr]['scope_opener']) === false) { + return; + } + + // The opening brace needs to be one space away from the closing parenthesis. + if ($tokens[($closeBracket + 1)]['code'] !== T_WHITESPACE) { + $length = 0; + } else if ($tokens[($closeBracket + 1)]['content'] === $phpcsFile->eolChar) { + $length = -1; + } else { + $length = strlen($tokens[($closeBracket + 1)]['content']); + } + + if ($length !== 1) { + $data = array($length); + $code = 'SpaceBeforeOpenBrace'; + + $error = 'There must be a single space between the closing parenthesis and the opening brace of a multi-line IF statement; found '; + if ($length === -1) { + $error .= 'newline'; + $code = 'NewlineBeforeOpenBrace'; + } else { + $error .= '%s spaces'; + } + + $phpcsFile->addError($error, ($closeBracket + 1), $code, $data); + } + + // And just in case they do something funny before the brace... + $next = $phpcsFile->findNext(T_WHITESPACE, ($closeBracket + 1), null, true); + if ($next !== false + && $tokens[$next]['code'] !== T_OPEN_CURLY_BRACKET + && $tokens[$next]['code'] !== T_COLON + ) { + $error = 'There must be a single space between the closing parenthesis and the opening brace of a multi-line IF statement'; + $phpcsFile->addError($error, $next, 'NoSpaceBeforeOpenBrace'); + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/Files/IncludingFileSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/Files/IncludingFileSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/Files/IncludingFileSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/Files/IncludingFileSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,137 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * PEAR_Sniffs_Files_IncludingFileSniff. + * + * Checks that the include_once is used in conditional situations, and + * require_once is used elsewhere. Also checks that brackets do not surround + * the file being included. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PEAR_Sniffs_Files_IncludingFileSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * Conditions that should use include_once + * + * @var array(int) + */ + private static $_conditions = array( + T_IF, + T_ELSE, + T_ELSEIF, + T_SWITCH, + ); + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array( + T_INCLUDE_ONCE, + T_REQUIRE_ONCE, + T_REQUIRE, + T_INCLUDE, + ); + + }//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(); + + $nextToken = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr + 1), null, true); + if ($tokens[$nextToken]['code'] === T_OPEN_PARENTHESIS) { + $error = '"%s" is a statement not a function; no parentheses are required'; + $data = array($tokens[$stackPtr]['content']); + $phpcsFile->addError($error, $stackPtr, 'BracketsNotRequired', $data); + } + + $inCondition = (count($tokens[$stackPtr]['conditions']) !== 0) ? true : false; + + // Check to see if this including statement is within the parenthesis + // of a condition. If that's the case then we need to process it as being + // within a condition, as they are checking the return value. + if (isset($tokens[$stackPtr]['nested_parenthesis']) === true) { + foreach ($tokens[$stackPtr]['nested_parenthesis'] as $left => $right) { + if (isset($tokens[$left]['parenthesis_owner']) === true) { + $inCondition = true; + } + } + } + + // Check to see if they are assigning the return value of this + // including call. If they are then they are probably checking it, so + // it's conditional. + $previous = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true); + if (in_array($tokens[$previous]['code'], PHP_CodeSniffer_Tokens::$assignmentTokens) === true) { + // The have assigned the return value to it, so its conditional. + $inCondition = true; + } + + $tokenCode = $tokens[$stackPtr]['code']; + if ($inCondition === true) { + // We are inside a conditional statement. We need an include_once. + if ($tokenCode === T_REQUIRE_ONCE) { + $error = 'File is being conditionally included; '; + $error .= 'use "include_once" instead'; + $phpcsFile->addError($error, $stackPtr, 'UseIncludeOnce'); + } else if ($tokenCode === T_REQUIRE) { + $error = 'File is being conditionally included; '; + $error .= 'use "include" instead'; + $phpcsFile->addError($error, $stackPtr, 'UseInclude'); + } + } else { + // We are unconditionally including, we need a require_once. + if ($tokenCode === T_INCLUDE_ONCE) { + $error = 'File is being unconditionally included; '; + $error .= 'use "require_once" instead'; + $phpcsFile->addError($error, $stackPtr, 'UseRequireOnce'); + } else if ($tokenCode === T_INCLUDE) { + $error = 'File is being unconditionally included; '; + $error .= 'use "require" instead'; + $phpcsFile->addError($error, $stackPtr, 'UseRequire'); + } + }//end if + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/Formatting/MultiLineAssignmentSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/Formatting/MultiLineAssignmentSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/Formatting/MultiLineAssignmentSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/Formatting/MultiLineAssignmentSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,113 @@ + + * @copyright 2006-2012 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 + */ + +/** + * PEAR_Sniffs_Formatting_MultiLineAssignmentSniff. + * + * If an assignment goes over two lines, ensure the equal sign is indented. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PEAR_Sniffs_Formatting_MultiLineAssignmentSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array(T_EQUAL); + + }//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(); + + // Equal sign can't be the last thing on the line. + $next = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); + if ($next === false) { + // Bad assignment. + return; + } + + if ($tokens[$next]['line'] !== $tokens[$stackPtr]['line']) { + $error = 'Multi-line assignments must have the equal sign on the second line'; + $phpcsFile->addError($error, $stackPtr, 'EqualSignLine'); + return; + } + + // Make sure it is the first thing on the line, otherwise we ignore it. + $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), false, true); + if ($prev === false) { + // Bad assignment. + return; + } + + if ($tokens[$prev]['line'] === $tokens[$stackPtr]['line']) { + return; + } + + // Find the required indent based on the ident of the previous line. + $assignmentIndent = 0; + $prevLine = $tokens[$prev]['line']; + for ($i = ($prev - 1); $i >= 0; $i--) { + if ($tokens[$i]['line'] !== $prevLine) { + $i++; + break; + } + } + + if ($tokens[$i]['code'] === T_WHITESPACE) { + $assignmentIndent = strlen($tokens[$i]['content']); + } + + // Find the actual indent. + $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1)); + + $expectedIndent = ($assignmentIndent + 4); + $foundIndent = strlen($tokens[$prev]['content']); + if ($foundIndent !== $expectedIndent) { + $error = 'Multi-line assignment not indented correctly; expected %s spaces but found %s'; + $data = array( + $expectedIndent, + $foundIndent, + ); + $phpcsFile->addError($error, $stackPtr, 'Indent', $data); + } + + }//end process() + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,310 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * PEAR_Sniffs_Functions_FunctionCallSignatureSniff. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PEAR_Sniffs_Functions_FunctionCallSignatureSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * The number of spaces code should be indented. + * + * @var int + */ + public $indent = 4; + + /** + * If TRUE, multiple arguments can be defined per line in a multi-line call. + * + * @var bool + */ + public $allowMultipleArguments = true; + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array(T_STRING); + + }//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 the next non-empty token. + $openBracket = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr + 1), null, true); + + if ($tokens[$openBracket]['code'] !== T_OPEN_PARENTHESIS) { + // Not a function call. + return; + } + + if (isset($tokens[$openBracket]['parenthesis_closer']) === false) { + // Not a function call. + return; + } + + // Find the previous non-empty token. + $search = PHP_CodeSniffer_Tokens::$emptyTokens; + $search[] = T_BITWISE_AND; + $previous = $phpcsFile->findPrevious($search, ($stackPtr - 1), null, true); + if ($tokens[$previous]['code'] === T_FUNCTION) { + // It's a function definition, not a function call. + return; + } + + $closeBracket = $tokens[$openBracket]['parenthesis_closer']; + + if (($stackPtr + 1) !== $openBracket) { + // Checking this: $value = my_function[*](...). + $error = 'Space before opening parenthesis of function call prohibited'; + $phpcsFile->addError($error, $stackPtr, 'SpaceBeforeOpenBracket'); + } + + $next = $phpcsFile->findNext(T_WHITESPACE, ($closeBracket + 1), null, true); + if ($tokens[$next]['code'] === T_SEMICOLON) { + if (in_array($tokens[($closeBracket + 1)]['code'], PHP_CodeSniffer_Tokens::$emptyTokens) === true) { + $error = 'Space after closing parenthesis of function call prohibited'; + $phpcsFile->addError($error, $closeBracket, 'SpaceAfterCloseBracket'); + } + } + + // Check if this is a single line or multi-line function call. + if ($tokens[$openBracket]['line'] === $tokens[$closeBracket]['line']) { + $this->processSingleLineCall($phpcsFile, $stackPtr, $openBracket, $tokens); + } else { + $this->processMultiLineCall($phpcsFile, $stackPtr, $openBracket, $tokens); + } + + }//end process() + + + /** + * Processes single-line calls. + * + * @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 $openBracket The position of the opening bracket + * in the stack passed in $tokens. + * @param array $tokens The stack of tokens that make up + * the file. + * + * @return void + */ + public function processSingleLineCall(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $openBracket, $tokens) + { + if ($tokens[($openBracket + 1)]['code'] === T_WHITESPACE) { + // Checking this: $value = my_function([*]...). + $error = 'Space after opening parenthesis of function call prohibited'; + $phpcsFile->addError($error, $stackPtr, 'SpaceAfterOpenBracket'); + } + + $closer = $tokens[$openBracket]['parenthesis_closer']; + + if ($tokens[($closer - 1)]['code'] === T_WHITESPACE) { + // Checking this: $value = my_function(...[*]). + $between = $phpcsFile->findNext(T_WHITESPACE, ($openBracket + 1), null, true); + + // Only throw an error if there is some content between the parenthesis. + // i.e., Checking for this: $value = my_function(). + // If there is no content, then we would have thrown an error in the + // previous IF statement because it would look like this: + // $value = my_function( ). + if ($between !== $closer) { + $error = 'Space before closing parenthesis of function call prohibited'; + $phpcsFile->addError($error, $closer, 'SpaceBeforeCloseBracket'); + } + } + + }//end processSingleLineCall() + + + /** + * Processes multi-line calls. + * + * @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 $openBracket The position of the openning bracket + * in the stack passed in $tokens. + * @param array $tokens The stack of tokens that make up + * the file. + * + * @return void + */ + public function processMultiLineCall(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $openBracket, $tokens) + { + // We need to work out how far indented the function + // call itself is, so we can work out how far to + // indent the arguments. + $functionIndent = 0; + for ($i = ($stackPtr - 1); $i >= 0; $i--) { + if ($tokens[$i]['line'] !== $tokens[$stackPtr]['line']) { + $i++; + break; + } + } + + if ($tokens[$i]['code'] === T_WHITESPACE) { + $functionIndent = strlen($tokens[$i]['content']); + } + + // Each line between the parenthesis should be indented n spaces. + $closeBracket = $tokens[$openBracket]['parenthesis_closer']; + $lastLine = $tokens[$openBracket]['line']; + for ($i = ($openBracket + 1); $i < $closeBracket; $i++) { + // Skip nested function calls. + if ($tokens[$i]['code'] === T_OPEN_PARENTHESIS) { + $i = $tokens[$i]['parenthesis_closer']; + $lastLine = $tokens[$i]['line']; + continue; + } + + if ($tokens[$i]['line'] !== $lastLine) { + $lastLine = $tokens[$i]['line']; + + // Ignore heredoc indentation. + if (in_array($tokens[$i]['code'], PHP_CodeSniffer_Tokens::$heredocTokens) === true) { + continue; + } + + // Ignore multi-line string indentation. + if (in_array($tokens[$i]['code'], PHP_CodeSniffer_Tokens::$stringTokens) === true) { + if ($tokens[$i]['code'] === $tokens[($i - 1)]['code']) { + continue; + } + } + + // We changed lines, so this should be a whitespace indent token, but first make + // sure it isn't a blank line because we don't need to check indent unless there + // is actually some code to indent. + if ($tokens[$i]['code'] === T_WHITESPACE) { + $nextCode = $phpcsFile->findNext(T_WHITESPACE, ($i + 1), ($closeBracket + 1), true); + if ($tokens[$nextCode]['line'] !== $lastLine) { + $error = 'Empty lines are not allowed in multi-line function calls'; + $phpcsFile->addError($error, $i, 'EmptyLine'); + continue; + } + } else { + $nextCode = $i; + } + + // Check if the next line contains an object operator, if so rely on + // the ObjectOperatorIndentSniff to test the indent. + if ($tokens[$nextCode]['type'] === 'T_OBJECT_OPERATOR') { + continue; + } + + if ($nextCode === $closeBracket) { + // Closing brace needs to be indented to the same level + // as the function call. + $expectedIndent = $functionIndent; + } else { + $expectedIndent = ($functionIndent + $this->indent); + } + + if ($tokens[$i]['code'] !== T_WHITESPACE) { + // Just check if it is a multi-line block comment. If so, we can + // calculate the indent from the whitespace before the content. + if ($tokens[$i]['code'] === T_COMMENT + && $tokens[($i - 1)]['code'] === T_COMMENT + ) { + $trimmed = ltrim($tokens[$i]['content']); + $foundIndent = (strlen($tokens[$i]['content']) - strlen($trimmed)); + } else { + $foundIndent = 0; + } + } else { + $foundIndent = strlen($tokens[$i]['content']); + } + + if ($expectedIndent !== $foundIndent) { + $error = 'Multi-line function call not indented correctly; expected %s spaces but found %s'; + $data = array( + $expectedIndent, + $foundIndent, + ); + $phpcsFile->addError($error, $i, 'Indent', $data); + } + }//end if + + // Skip the rest of a closure. + if ($tokens[$i]['code'] === T_CLOSURE) { + $i = $tokens[$i]['scope_closer']; + $lastLine = $tokens[$i]['line']; + continue; + } + + // Skip the rest of a short array. + if ($tokens[$i]['code'] === T_OPEN_SHORT_ARRAY) { + $i = $tokens[$i]['bracket_closer']; + $lastLine = $tokens[$i]['line']; + continue; + } + + if ($this->allowMultipleArguments === false && $tokens[$i]['code'] === T_COMMA) { + // Comma has to be the last token on the line. + $next = $phpcsFile->findNext(array(T_WHITESPACE, T_COMMENT), ($i + 1), $closeBracket, true); + if ($next !== false + && $tokens[$i]['line'] === $tokens[$next]['line'] + ) { + $error = 'Only one argument is allowed per line in a multi-line function call'; + $phpcsFile->addError($error, $next, 'MultipleArguments'); + } + } + }//end for + + if ($tokens[($openBracket + 1)]['content'] !== $phpcsFile->eolChar) { + $error = 'Opening parenthesis of a multi-line function call must be the last content on the line'; + $phpcsFile->addError($error, $stackPtr, 'ContentAfterOpenBracket'); + } + + $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($closeBracket - 1), null, true); + if ($tokens[$prev]['line'] === $tokens[$closeBracket]['line']) { + $error = 'Closing parenthesis of a multi-line function call must be on a line by itself'; + $phpcsFile->addError($error, $closeBracket, 'CloseBracketLine'); + } + + }//end processMultiLineCall() + + +}//end class +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,329 @@ + + * @copyright 2006-2012 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 + */ + +/** + * PEAR_Sniffs_Functions_FunctionDeclarationSniff. + * + * Ensure single and multi-line function declarations are defined correctly. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PEAR_Sniffs_Functions_FunctionDeclarationSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array( + T_FUNCTION, + T_CLOSURE, + ); + + }//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(); + + $spaces = 0; + if ($tokens[($stackPtr + 1)]['code'] === T_WHITESPACE) { + $spaces = strlen($tokens[($stackPtr + 1)]['content']); + } + + if ($spaces !== 1) { + $error = 'Expected 1 space after FUNCTION keyword; %s found'; + $data = array($spaces); + $phpcsFile->addError($error, $stackPtr, 'SpaceAfterFunction', $data); + } + + // Must be one space before and after USE keyword for closures. + $openBracket = $tokens[$stackPtr]['parenthesis_opener']; + $closeBracket = $tokens[$stackPtr]['parenthesis_closer']; + if ($tokens[$stackPtr]['code'] === T_CLOSURE) { + $use = $phpcsFile->findNext(T_USE, ($closeBracket + 1), $tokens[$stackPtr]['scope_opener']); + if ($use !== false) { + if ($tokens[($use + 1)]['code'] !== T_WHITESPACE) { + $length = 0; + } else if ($tokens[($use + 1)]['content'] === "\t") { + $length = '\t'; + } else { + $length = strlen($tokens[($use + 1)]['content']); + } + + if ($length !== 1) { + $error = 'Expected 1 space after USE keyword; found %s'; + $data = array($length); + $phpcsFile->addError($error, $use, 'SpaceAfterUse', $data); + } + + if ($tokens[($use - 1)]['code'] !== T_WHITESPACE) { + $length = 0; + } else if ($tokens[($use - 1)]['content'] === "\t") { + $length = '\t'; + } else { + $length = strlen($tokens[($use - 1)]['content']); + } + + if ($length !== 1) { + $error = 'Expected 1 space before USE keyword; found %s'; + $data = array($length); + $phpcsFile->addError($error, $use, 'SpaceBeforeUse', $data); + } + }//end if + }//end if + + // Check if this is a single line or multi-line declaration. + $singleLine = true; + if ($tokens[$openBracket]['line'] === $tokens[$closeBracket]['line']) { + // Closures may use the USE keyword and so be multi-line in this way. + if ($tokens[$stackPtr]['code'] === T_CLOSURE) { + if ($use !== false) { + // If the opening and closing parenthesis of the use statement + // are also on the same line, this is a single line declaration. + $open = $phpcsFile->findNext(T_OPEN_PARENTHESIS, ($use + 1)); + $close = $tokens[$open]['parenthesis_closer']; + if ($tokens[$open]['line'] !== $tokens[$close]['line']) { + $singleLine = false; + } + } + } + } else { + $singleLine = false; + } + + if ($singleLine === true) { + $this->processSingleLineDeclaration($phpcsFile, $stackPtr, $tokens); + } else { + $this->processMultiLineDeclaration($phpcsFile, $stackPtr, $tokens); + } + + }//end process() + + + /** + * Processes single-line declarations. + * + * Just uses the Generic BSD-Allman brace sniff. + * + * @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 array $tokens The stack of tokens that make up + * the file. + * + * @return void + */ + public function processSingleLineDeclaration(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $tokens) + { + if ($tokens[$stackPtr]['code'] === T_CLOSURE) { + if (class_exists('Generic_Sniffs_Functions_OpeningFunctionBraceKernighanRitchieSniff', true) === false) { + throw new PHP_CodeSniffer_Exception('Class Generic_Sniffs_Functions_OpeningFunctionBraceKernighanRitchieSniff not found'); + } + + $sniff = new Generic_Sniffs_Functions_OpeningFunctionBraceKernighanRitchieSniff(); + } else { + if (class_exists('Generic_Sniffs_Functions_OpeningFunctionBraceBsdAllmanSniff', true) === false) { + throw new PHP_CodeSniffer_Exception('Class Generic_Sniffs_Functions_OpeningFunctionBraceBsdAllmanSniff not found'); + } + + $sniff = new Generic_Sniffs_Functions_OpeningFunctionBraceBsdAllmanSniff(); + } + + $sniff->process($phpcsFile, $stackPtr); + + }//end processSingleLineDeclaration() + + + /** + * Processes mutli-line declarations. + * + * @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 array $tokens The stack of tokens that make up + * the file. + * + * @return void + */ + public function processMultiLineDeclaration(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $tokens) + { + // We need to work out how far indented the function + // declaration itself is, so we can work out how far to + // indent parameters. + $functionIndent = 0; + for ($i = ($stackPtr - 1); $i >= 0; $i--) { + if ($tokens[$i]['line'] !== $tokens[$stackPtr]['line']) { + $i++; + break; + } + } + + if ($tokens[$i]['code'] === T_WHITESPACE) { + $functionIndent = strlen($tokens[$i]['content']); + } + + // The closing parenthesis must be on a new line, even + // when checking abstract function definitions. + $closeBracket = $tokens[$stackPtr]['parenthesis_closer']; + $prev = $phpcsFile->findPrevious( + T_WHITESPACE, + ($closeBracket - 1), + null, + true + ); + + if ($tokens[$closeBracket]['line'] !== $tokens[$tokens[$closeBracket]['parenthesis_opener']]['line']) { + if ($tokens[$prev]['line'] === $tokens[$closeBracket]['line']) { + $error = 'The closing parenthesis of a multi-line function declaration must be on a new line'; + $phpcsFile->addError($error, $closeBracket, 'CloseBracketLine'); + } + } + + // If this is a closure and is using a USE statement, the closing + // parenthesis we need to look at from now on is the closing parenthesis + // of the USE statement. + if ($tokens[$stackPtr]['code'] === T_CLOSURE) { + $use = $phpcsFile->findNext(T_USE, ($closeBracket + 1), $tokens[$stackPtr]['scope_opener']); + if ($use !== false) { + $open = $phpcsFile->findNext(T_OPEN_PARENTHESIS, ($use + 1)); + $closeBracket = $tokens[$open]['parenthesis_closer']; + + $prev = $phpcsFile->findPrevious( + T_WHITESPACE, + ($closeBracket - 1), + null, + true + ); + + if ($tokens[$closeBracket]['line'] !== $tokens[$tokens[$closeBracket]['parenthesis_opener']]['line']) { + if ($tokens[$prev]['line'] === $tokens[$closeBracket]['line']) { + $error = 'The closing parenthesis of a multi-line use declaration must be on a new line'; + $phpcsFile->addError($error, $closeBracket, 'CloseBracketLine'); + } + } + }//end if + }//end if + + // Each line between the parenthesis should be indented 4 spaces. + $openBracket = $tokens[$stackPtr]['parenthesis_opener']; + $lastLine = $tokens[$openBracket]['line']; + for ($i = ($openBracket + 1); $i < $closeBracket; $i++) { + if ($tokens[$i]['line'] !== $lastLine) { + if ($i === $tokens[$stackPtr]['parenthesis_closer'] + || ($tokens[$i]['code'] === T_WHITESPACE + && ($i + 1) === $tokens[$stackPtr]['parenthesis_closer']) + ) { + // Closing braces need to be indented to the same level + // as the function. + $expectedIndent = $functionIndent; + } else { + $expectedIndent = ($functionIndent + 4); + } + + // We changed lines, so this should be a whitespace indent token. + if ($tokens[$i]['code'] !== T_WHITESPACE) { + $foundIndent = 0; + } else { + $foundIndent = strlen($tokens[$i]['content']); + } + + if ($expectedIndent !== $foundIndent) { + $error = 'Multi-line function declaration not indented correctly; expected %s spaces but found %s'; + $data = array( + $expectedIndent, + $foundIndent, + ); + $phpcsFile->addError($error, $i, 'Indent', $data); + } + + $lastLine = $tokens[$i]['line']; + }//end if + + if ($tokens[$i]['code'] === T_ARRAY) { + // Skip arrays as they have their own indentation rules. + $i = $tokens[$i]['parenthesis_closer']; + $lastLine = $tokens[$i]['line']; + continue; + } + }//end for + + if (isset($tokens[$stackPtr]['scope_opener']) === true) { + // The openning brace needs to be one space away + // from the closing parenthesis. + $next = $tokens[($closeBracket + 1)]; + if ($next['code'] !== T_WHITESPACE) { + $length = 0; + } else if ($next['content'] === $phpcsFile->eolChar) { + $length = -1; + } else { + $length = strlen($next['content']); + } + + if ($length !== 1) { + $data = array($length); + $code = 'SpaceBeforeOpenBrace'; + + $error = 'There must be a single space between the closing parenthesis and the opening brace of a multi-line function declaration; found '; + if ($length === -1) { + $error .= 'newline'; + $code = 'NewlineBeforeOpenBrace'; + } else { + $error .= '%s spaces'; + } + + $phpcsFile->addError($error, ($closeBracket + 1), $code, $data); + return; + } + + // And just in case they do something funny before the brace... + $next = $phpcsFile->findNext( + T_WHITESPACE, + ($closeBracket + 1), + null, + true + ); + + if ($next !== false && $tokens[$next]['code'] !== T_OPEN_CURLY_BRACKET) { + $error = 'There must be a single space between the closing parenthesis and the opening brace of a multi-line function declaration'; + $phpcsFile->addError($error, $next, 'NoSpaceBeforeOpenBrace'); + } + }//end if + + }//end processMultiLineDeclaration() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/Functions/ValidDefaultValueSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/Functions/ValidDefaultValueSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/Functions/ValidDefaultValueSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/Functions/ValidDefaultValueSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,108 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * PEAR_Sniffs_Functions_ValidDefaultValueSniff. + * + * A Sniff to ensure that parameters defined for a function that have a default + * value come at the end of the function signature. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PEAR_Sniffs_Functions_ValidDefaultValueSniff 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(); + + $argStart = $tokens[$stackPtr]['parenthesis_opener']; + $argEnd = $tokens[$stackPtr]['parenthesis_closer']; + + // Flag for when we have found a default in our arg list. + // If there is a value without a default after this, it is an error. + $defaultFound = false; + + $nextArg = $argStart; + while (($nextArg = $phpcsFile->findNext(T_VARIABLE, ($nextArg + 1), $argEnd)) !== false) { + $argHasDefault = self::_argHasDefault($phpcsFile, $nextArg); + if (($argHasDefault === false) && ($defaultFound === true)) { + $error = 'Arguments with default values must be at the end of the argument list'; + $phpcsFile->addError($error, $nextArg, 'NotAtEnd'); + return; + } + + if ($argHasDefault === true) { + $defaultFound = true; + } + } + + }//end process() + + + /** + * Returns true if the passed argument has a default value. + * + * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. + * @param int $argPtr The position of the argument + * in the stack. + * + * @return bool + */ + private static function _argHasDefault(PHP_CodeSniffer_File $phpcsFile, $argPtr) + { + $tokens = $phpcsFile->getTokens(); + $nextToken = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($argPtr + 1), null, true); + if ($tokens[$nextToken]['code'] !== T_EQUAL) { + return false; + } + + return true; + + }//end _argHasDefault() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/NamingConventions/ValidClassNameSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/NamingConventions/ValidClassNameSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/NamingConventions/ValidClassNameSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/NamingConventions/ValidClassNameSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,115 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * PEAR_Sniffs_NamingConventions_ValidClassNameSniff. + * + * Ensures class and interface names start with a capital letter + * and use _ separators. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PEAR_Sniffs_NamingConventions_ValidClassNameSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * 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 current file being processed. + * @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(); + + $className = $phpcsFile->findNext(T_STRING, $stackPtr); + $name = trim($tokens[$className]['content']); + $errorData = array(ucfirst($tokens[$stackPtr]['content'])); + + // Make sure the first letter is a capital. + if (preg_match('|^[A-Z]|', $name) === 0) { + $error = '%s name must begin with a capital letter'; + $phpcsFile->addError($error, $stackPtr, 'StartWithCapital', $errorData); + } + + // Check that each new word starts with a capital as well, but don't + // check the first word, as it is checked above. + $validName = true; + $nameBits = explode('_', $name); + $firstBit = array_shift($nameBits); + foreach ($nameBits as $bit) { + if ($bit === '' || $bit{0} !== strtoupper($bit{0})) { + $validName = false; + break; + } + } + + if ($validName === false) { + // Strip underscores because they cause the suggested name + // to be incorrect. + $nameBits = explode('_', trim($name, '_')); + $firstBit = array_shift($nameBits); + if ($firstBit === '') { + $error = '%s name is not valid'; + $phpcsFile->addError($error, $stackPtr, 'Invalid', $errorData); + } else { + $newName = strtoupper($firstBit{0}).substr($firstBit, 1).'_'; + foreach ($nameBits as $bit) { + if ($bit !== '') { + $newName .= strtoupper($bit{0}).substr($bit, 1).'_'; + } + } + + $newName = rtrim($newName, '_'); + $error = '%s name is not valid; consider %s instead'; + $data = $errorData; + $data[] = $newName; + $phpcsFile->addError($error, $stackPtr, 'Invalid', $data); + } + }//end if + + }//end process() + + +}//end class + + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/NamingConventions/ValidFunctionNameSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/NamingConventions/ValidFunctionNameSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/NamingConventions/ValidFunctionNameSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/NamingConventions/ValidFunctionNameSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,285 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +if (class_exists('PHP_CodeSniffer_Standards_AbstractScopeSniff', true) === false) { + throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_Standards_AbstractScopeSniff not found'); +} + +/** + * PEAR_Sniffs_NamingConventions_ValidFunctionNameSniff. + * + * Ensures method names are correct depending on whether they are public + * or private, and that functions are named correctly. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PEAR_Sniffs_NamingConventions_ValidFunctionNameSniff extends PHP_CodeSniffer_Standards_AbstractScopeSniff +{ + + /** + * A list of all PHP magic methods. + * + * @var array + */ + protected $magicMethods = array( + 'construct', + 'destruct', + 'call', + 'callstatic', + 'get', + 'set', + 'isset', + 'unset', + 'sleep', + 'wakeup', + 'tostring', + 'set_state', + 'clone', + 'invoke', + 'call', + ); + + /** + * A list of all PHP magic functions. + * + * @var array + */ + protected $magicFunctions = array('autoload'); + + + /** + * Constructs a PEAR_Sniffs_NamingConventions_ValidFunctionNameSniff. + */ + public function __construct() + { + parent::__construct(array(T_CLASS, T_INTERFACE, T_TRAIT), array(T_FUNCTION), true); + + }//end __construct() + + + /** + * Processes the tokens within the scope. + * + * @param PHP_CodeSniffer_File $phpcsFile The file being processed. + * @param int $stackPtr The position where this token was + * found. + * @param int $currScope The position of the current scope. + * + * @return void + */ + protected function processTokenWithinScope(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $currScope) + { + $methodName = $phpcsFile->getDeclarationName($stackPtr); + if ($methodName === null) { + // Ignore closures. + return; + } + + $className = $phpcsFile->getDeclarationName($currScope); + $errorData = array($className.'::'.$methodName); + + // Is this a magic method. i.e., is prefixed with "__" ? + if (preg_match('|^__|', $methodName) !== 0) { + $magicPart = strtolower(substr($methodName, 2)); + if (in_array($magicPart, $this->magicMethods) === false) { + $error = 'Method name "%s" is invalid; only PHP magic methods should be prefixed with a double underscore'; + $phpcsFile->addError($error, $stackPtr, 'MethodDoubleUnderscore', $errorData); + } + + return; + } + + // PHP4 constructors are allowed to break our rules. + if ($methodName === $className) { + return; + } + + // PHP4 destructors are allowed to break our rules. + if ($methodName === '_'.$className) { + return; + } + + $methodProps = $phpcsFile->getMethodProperties($stackPtr); + $isPublic = ($methodProps['scope'] === 'private') ? false : true; + $scope = $methodProps['scope']; + $scopeSpecified = $methodProps['scope_specified']; + + // If it's a private method, it must have an underscore on the front. + if ($isPublic === false && $methodName{0} !== '_') { + $error = 'Private method name "%s" must be prefixed with an underscore'; + $phpcsFile->addError($error, $stackPtr, 'PrivateNoUnderscore', $errorData); + return; + } + + // If it's not a private method, it must not have an underscore on the front. + if ($isPublic === true && $scopeSpecified === true && $methodName{0} === '_') { + $error = '%s method name "%s" must not be prefixed with an underscore'; + $data = array( + ucfirst($scope), + $errorData[0], + ); + $phpcsFile->addError($error, $stackPtr, 'PublicUnderscore', $data); + return; + } + + // If the scope was specified on the method, then the method must be + // camel caps and an underscore should be checked for. If it wasn't + // specified, treat it like a public method and remove the underscore + // prefix if there is one because we cant determine if it is private or + // public. + $testMethodName = $methodName; + if ($scopeSpecified === false && $methodName{0} === '_') { + $testMethodName = substr($methodName, 1); + } + + if (PHP_CodeSniffer::isCamelCaps($testMethodName, false, $isPublic, false) === false) { + if ($scopeSpecified === true) { + $error = '%s method name "%s" is not in camel caps format'; + $data = array( + ucfirst($scope), + $errorData[0], + ); + $phpcsFile->addError($error, $stackPtr, 'ScopeNotCamelCaps', $data); + } else { + $error = 'Method name "%s" is not in camel caps format'; + $phpcsFile->addError($error, $stackPtr, 'NotCamelCaps', $errorData); + } + + return; + } + + }//end processTokenWithinScope() + + + /** + * Processes the tokens outside the scope. + * + * @param PHP_CodeSniffer_File $phpcsFile The file being processed. + * @param int $stackPtr The position where this token was + * found. + * + * @return void + */ + protected function processTokenOutsideScope(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + $functionName = $phpcsFile->getDeclarationName($stackPtr); + if ($functionName === null) { + // Ignore closures. + return; + } + + $errorData = array($functionName); + + // Is this a magic function. i.e., it is prefixed with "__". + if (preg_match('|^__|', $functionName) !== 0) { + $magicPart = strtolower(substr($functionName, 2)); + if (in_array($magicPart, $this->magicFunctions) === false) { + $error = 'Function name "%s" is invalid; only PHP magic methods should be prefixed with a double underscore'; + $phpcsFile->addError($error, $stackPtr, 'FunctionDoubleUnderscore', $errorData); + } + + return; + } + + // Function names can be in two parts; the package name and + // the function name. + $packagePart = ''; + $camelCapsPart = ''; + $underscorePos = strrpos($functionName, '_'); + if ($underscorePos === false) { + $camelCapsPart = $functionName; + } else { + $packagePart = substr($functionName, 0, $underscorePos); + $camelCapsPart = substr($functionName, ($underscorePos + 1)); + + // We don't care about _'s on the front. + $packagePart = ltrim($packagePart, '_'); + } + + // If it has a package part, make sure the first letter is a capital. + if ($packagePart !== '') { + if ($functionName{0} === '_') { + $error = 'Function name "%s" is invalid; only private methods should be prefixed with an underscore'; + $phpcsFile->addError($error, $stackPtr, 'FunctionUnderscore', $errorData); + return; + } + + if ($functionName{0} !== strtoupper($functionName{0})) { + $error = 'Function name "%s" is prefixed with a package name but does not begin with a capital letter'; + $phpcsFile->addError($error, $stackPtr, 'FunctionNoCapital', $errorData); + return; + } + } + + // If it doesn't have a camel caps part, it's not valid. + if (trim($camelCapsPart) === '') { + $error = 'Function name "%s" is not valid; name appears incomplete'; + $phpcsFile->addError($error, $stackPtr, 'FunctionInvalid', $errorData); + return; + } + + $validName = true; + $newPackagePart = $packagePart; + $newCamelCapsPart = $camelCapsPart; + + // Every function must have a camel caps part, so check that first. + if (PHP_CodeSniffer::isCamelCaps($camelCapsPart, false, true, false) === false) { + $validName = false; + $newCamelCapsPart = strtolower($camelCapsPart{0}).substr($camelCapsPart, 1); + } + + if ($packagePart !== '') { + // Check that each new word starts with a capital. + $nameBits = explode('_', $packagePart); + foreach ($nameBits as $bit) { + if ($bit{0} !== strtoupper($bit{0})) { + $newPackagePart = ''; + foreach ($nameBits as $bit) { + $newPackagePart .= strtoupper($bit{0}).substr($bit, 1).'_'; + } + + $validName = false; + break; + } + } + } + + if ($validName === false) { + $newName = rtrim($newPackagePart, '_').'_'.$newCamelCapsPart; + if ($newPackagePart === '') { + $newName = $newCamelCapsPart; + } else { + $newName = rtrim($newPackagePart, '_').'_'.$newCamelCapsPart; + } + + $error = 'Function name "%s" is invalid; consider "%s" instead'; + $data = $errorData; + $data[] = $newName; + $phpcsFile->addError($error, $stackPtr, 'FunctionNameInvalid', $data); + } + + }//end processTokenOutsideScope() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/NamingConventions/ValidVariableNameSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/NamingConventions/ValidVariableNameSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/NamingConventions/ValidVariableNameSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/NamingConventions/ValidVariableNameSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,114 @@ + + * @copyright 2006-2012 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 + */ + +if (class_exists('PHP_CodeSniffer_Standards_AbstractVariableSniff', true) === false) { + $error = 'Class PHP_CodeSniffer_Standards_AbstractVariableSniff not found'; + throw new PHP_CodeSniffer_Exception($error); +} + +/** + * PEAR_Sniffs_NamingConventions_ValidVariableNameSniff. + * + * Checks the naming of member variables. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PEAR_Sniffs_NamingConventions_ValidVariableNameSniff extends PHP_CodeSniffer_Standards_AbstractVariableSniff +{ + + + /** + * Processes class member variables. + * + * @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 + */ + protected function processMemberVar(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + $tokens = $phpcsFile->getTokens(); + + $memberProps = $phpcsFile->getMemberProperties($stackPtr); + if (empty($memberProps) === true) { + return; + } + + $memberName = ltrim($tokens[$stackPtr]['content'], '$'); + $isPublic = ($memberProps['scope'] === 'private') ? false : true; + $scope = $memberProps['scope']; + $scopeSpecified = $memberProps['scope_specified']; + + // If it's a private member, it must have an underscore on the front. + if ($isPublic === false && $memberName{0} !== '_') { + $error = 'Private member variable "%s" must be prefixed with an underscore'; + $data = array($memberName); + $phpcsFile->addError($error, $stackPtr, 'PrivateNoUnderscore', $data); + return; + } + + // If it's not a private member, it must not have an underscore on the front. + if ($isPublic === true && $scopeSpecified === true && $memberName{0} === '_') { + $error = '%s member variable "%s" must not be prefixed with an underscore'; + $data = array( + ucfirst($scope), + $memberName, + ); + $phpcsFile->addError($error, $stackPtr, 'PublicUnderscore', $data); + return; + } + + }//end processMemberVar() + + + /** + * Processes normal variables. + * + * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found. + * @param int $stackPtr The position where the token was found. + * + * @return void + */ + protected function processVariable(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + // We don't care about normal variables. + + }//end processVariable() + + + /** + * Processes variables in double quoted strings. + * + * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found. + * @param int $stackPtr The position where the token was found. + * + * @return void + */ + protected function processVariableInString(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + // We don't care about normal variables. + + }//end processVariableInString() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/WhiteSpace/ObjectOperatorIndentSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/WhiteSpace/ObjectOperatorIndentSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/WhiteSpace/ObjectOperatorIndentSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/WhiteSpace/ObjectOperatorIndentSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,167 @@ + + * @copyright 2006-2012 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 + */ + +/** + * PEAR_Sniffs_WhiteSpace_ObjectOperatorIndentSniff. + * + * Checks that object operators are indented 4 spaces if they are the first + * thing on a line. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PEAR_Sniffs_WhiteSpace_ObjectOperatorIndentSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array(T_OBJECT_OPERATOR); + + }//end register() + + + /** + * Processes this test, when one of its tokens is encountered. + * + * @param PHP_CodeSniffer_File $phpcsFile All the tokens found in the document. + * @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(); + + // Make sure this is the first object operator in a chain of them. + $varToken = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); + if ($varToken === false || $tokens[$varToken]['code'] !== T_VARIABLE) { + return; + } + + // Make sure this is a chained call. + $next = $phpcsFile->findNext( + T_OBJECT_OPERATOR, + ($stackPtr + 1), + null, + false, + null, + true + ); + + if ($next === false) { + // Not a chained call. + return; + } + + // Determine correct indent. + for ($i = ($varToken - 1); $i >= 0; $i--) { + if ($tokens[$i]['line'] !== $tokens[$varToken]['line']) { + $i++; + break; + } + } + + $requiredIndent = 0; + if ($i >= 0 && $tokens[$i]['code'] === T_WHITESPACE) { + $requiredIndent = strlen($tokens[$i]['content']); + } + + $requiredIndent += 4; + + // Determine the scope of the original object operator. + $origBrackets = null; + if (isset($tokens[$stackPtr]['nested_parenthesis']) === true) { + $origBrackets = $tokens[$stackPtr]['nested_parenthesis']; + } + + $origConditions = null; + if (isset($tokens[$stackPtr]['conditions']) === true) { + $origConditions = $tokens[$stackPtr]['conditions']; + } + + // Check indentation of each object operator in the chain. + // If the first object operator is on a different line than + // the variable, make sure we check its indentation too. + if ($tokens[$stackPtr]['line'] > $tokens[$varToken]['line']) { + $next = $stackPtr; + } + + while ($next !== false) { + // Make sure it is in the same scope, otherwise don't check indent. + $brackets = null; + if (isset($tokens[$next]['nested_parenthesis']) === true) { + $brackets = $tokens[$next]['nested_parenthesis']; + } + + $conditions = null; + if (isset($tokens[$next]['conditions']) === true) { + $conditions = $tokens[$next]['conditions']; + } + + if ($origBrackets === $brackets && $origConditions === $conditions) { + // Make sure it starts a line, otherwise dont check indent. + $indent = $tokens[($next - 1)]; + if ($indent['code'] === T_WHITESPACE) { + if ($indent['line'] === $tokens[$next]['line']) { + $foundIndent = strlen($indent['content']); + } else { + $foundIndent = 0; + } + + if ($foundIndent !== $requiredIndent) { + $error = 'Object operator not indented correctly; expected %s spaces but found %s'; + $data = array( + $requiredIndent, + $foundIndent, + ); + $phpcsFile->addError($error, $next, 'Incorrect', $data); + } + } + + // It cant be the last thing on the line either. + $content = $phpcsFile->findNext(T_WHITESPACE, ($next + 1), null, true); + if ($tokens[$content]['line'] !== $tokens[$next]['line']) { + $error = 'Object operator must be at the start of the line, not the end'; + $phpcsFile->addError($error, $next, 'StartOfLine'); + } + }//end if + + $next = $phpcsFile->findNext( + T_OBJECT_OPERATOR, + ($next + 1), + null, + false, + null, + true + ); + }//end while + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,147 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * PEAR_Sniffs_Whitespace_ScopeClosingBraceSniff. + * + * Checks that the closing braces of scopes are aligned correctly. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PEAR_Sniffs_WhiteSpace_ScopeClosingBraceSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * The number of spaces code should be indented. + * + * @var int + */ + public $indent = 4; + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return PHP_CodeSniffer_Tokens::$scopeOpeners; + + }//end register() + + + /** + * Processes this test, when one of its tokens is encountered. + * + * @param PHP_CodeSniffer_File $phpcsFile All the tokens found in the document. + * @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(); + + // If this is an inline condition (ie. there is no scope opener), then + // return, as this is not a new scope. + if (isset($tokens[$stackPtr]['scope_closer']) === false) { + return; + } + + $scopeStart = $tokens[$stackPtr]['scope_opener']; + $scopeEnd = $tokens[$stackPtr]['scope_closer']; + + // If the scope closer doesn't think it belongs to this scope opener + // then the opener is sharing its closer ith other tokens. We only + // want to process the closer once, so skip this one. + if ($tokens[$scopeEnd]['scope_condition'] !== $stackPtr) { + return; + } + + // We need to actually find the first piece of content on this line, + // because if this is a method with tokens before it (public, static etc) + // or an if with an else before it, then we need to start the scope + // checking from there, rather than the current token. + $lineStart = ($stackPtr - 1); + for ($lineStart; $lineStart > 0; $lineStart--) { + if (strpos($tokens[$lineStart]['content'], $phpcsFile->eolChar) !== false) { + break; + } + } + + // We found a new line, now go forward and find the first non-whitespace + // token. + $lineStart= $phpcsFile->findNext( + array(T_WHITESPACE), + ($lineStart + 1), + null, + true + ); + + $startColumn = $tokens[$lineStart]['column']; + + // Check that the closing brace is on it's own line. + $lastContent = $phpcsFile->findPrevious( + array(T_WHITESPACE), + ($scopeEnd - 1), + $scopeStart, + true + ); + + if ($tokens[$lastContent]['line'] === $tokens[$scopeEnd]['line']) { + $error = 'Closing brace must be on a line by itself'; + $phpcsFile->addError($error, $scopeEnd, 'Line'); + return; + } + + // Check now that the closing brace is lined up correctly. + $braceIndent = $tokens[$scopeEnd]['column']; + if (in_array($tokens[$stackPtr]['code'], array(T_CASE, T_DEFAULT)) === true) { + // BREAK statements should be indented n spaces from the + // CASE or DEFAULT statement. + if ($braceIndent !== ($startColumn + $this->indent)) { + $error = 'Case breaking statement indented incorrectly; expected %s spaces, found %s'; + $data = array( + ($startColumn + $this->indent - 1), + ($braceIndent - 1), + ); + $phpcsFile->addError($error, $scopeEnd, 'BreakIdent', $data); + } + } else { + if ($braceIndent !== $startColumn) { + $error = 'Closing brace indented incorrectly; expected %s spaces, found %s'; + $data = array( + ($startColumn - 1), + ($braceIndent - 1), + ); + $phpcsFile->addError($error, $scopeEnd, 'Indent', $data); + } + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/WhiteSpace/ScopeIndentSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/WhiteSpace/ScopeIndentSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/WhiteSpace/ScopeIndentSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Sniffs/WhiteSpace/ScopeIndentSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,48 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +if (class_exists('Generic_Sniffs_WhiteSpace_ScopeIndentSniff', true) === false) { + $error = 'Class Generic_Sniffs_WhiteSpace_ScopeIndentSniff not found'; + throw new PHP_CodeSniffer_Exception($error); +} + +/** + * PEAR_Sniffs_Whitespace_ScopeIndentSniff. + * + * Checks that control structures are structured correctly, and their content + * is indented correctly. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PEAR_Sniffs_WhiteSpace_ScopeIndentSniff extends Generic_Sniffs_WhiteSpace_ScopeIndentSniff +{ + + /** + * Any scope openers that should not cause an indent. + * + * @var array(int) + */ + protected $nonIndentingScopes = array(T_SWITCH); + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Classes/ClassDeclarationUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Classes/ClassDeclarationUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Classes/ClassDeclarationUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Classes/ClassDeclarationUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,71 @@ + \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Classes/ClassDeclarationUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Classes/ClassDeclarationUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Classes/ClassDeclarationUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Classes/ClassDeclarationUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,75 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the ClassDeclaration sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PEAR_Tests_Classes_ClassDeclarationUnitTest 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 array( + 21 => 1, + 22 => 1, + 23 => 1, + 27 => 1, + 33 => 1, + 38 => 1, + 49 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Commenting/ClassCommentUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Commenting/ClassCommentUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Commenting/ClassCommentUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Commenting/ClassCommentUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,111 @@ + + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.0 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Extra_Description_Newlines +{ + +}//end class + + +/** + * Sample class comment + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Missing_Newlines_Before_Tags +{ + +}//end class + + +/** + * Simple class comment + * + * @category _wrong_category + * @package PHP_CodeSniffer + * @package ADDITIONAL PACKAGE TAG + * @subpackage SUBPACKAGE TAG + * @author Original Author + * @author Greg Sherwood gsherwood@squiz.net + * @author Mr T + * @author + * @copyright 1997~1994 The PHP Group + * @license http://www.php.net/license/3_0.txt + * @version INVALID VERSION CONTENT + * @see + * @see + * @link sdfsdf + * @see Net_Sample::Net_Sample() + * @see Net_Other + * @deprecated asd + * @unknown Unknown tag + * @since Class available since Release 1.2.0 + */ +class Checking_Tags +{ + class Sub_Class { + + }//end class + + +}//end class + + +/** + * + * + */ +class Empty_Class_Doc +{ + +}//end class + + +/** + * + * + */ +interface Empty_Interface_Doc +{ + +}//end interface +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Commenting/ClassCommentUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Commenting/ClassCommentUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Commenting/ClassCommentUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Commenting/ClassCommentUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,90 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for ClassCommentSniff. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PEAR_Tests_Commenting_ClassCommentUnitTest 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 array( + 4 => 1, + 15 => 1, + 22 => 1, + 25 => 1, + 28 => 1, + 46 => 1, + 51 => 1, + 63 => 1, + 65 => 2, + 66 => 1, + 68 => 2, + 70 => 1, + 71 => 1, + 72 => 1, + 74 => 2, + 75 => 1, + 77 => 1, + 78 => 1, + 79 => 1, + 85 => 1, + 93 => 1, + 103 => 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 array( + 71 => 1, + 73 => 1, + ); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Commenting/FileCommentUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Commenting/FileCommentUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Commenting/FileCommentUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Commenting/FileCommentUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,49 @@ + +* @author Greg Sherwood gsherwood@squiz.net +* @author Mr T +* @author +* @copyright 1997~1994 The PHP Group +* @copyright 1997~1994 The PHP Group +* @license http://www.php.net/license/3_0.txt +* @see +* @see +* @version INVALID VERSION CONTENT +* @see Net_Sample::Net_Sample() +* @see Net_Other +* @deprecated asd +* @since Class available since Release 1.2.0 +* @summary An unknown summary tag +*/ +?> + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Commenting/FileCommentUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Commenting/FileCommentUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Commenting/FileCommentUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Commenting/FileCommentUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,97 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for FunctionCommentSniff. + * + * Verifies that : + *
    + *
  • A doc comment exists.
  • + *
  • Short description must start with a capital letter and end with a period.
  • + *
  • There must be one blank newline after the short description.
  • + *
  • A PHP version is specified.
  • + *
  • Check the order of the tags.
  • + *
  • Check the indentation of each tag.
  • + *
  • Check required and optional tags and the format of their content.
  • + *
+ * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PEAR_Tests_Commenting_FileCommentUnitTest 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 array( + 6 => 1, + 8 => 1, + 21 => 2, + 23 => 2, + 24 => 1, + 26 => 2, + 28 => 1, + 29 => 1, + 30 => 1, + 31 => 1, + 32 => 2, + 33 => 1, + 35 => 1, + 36 => 1, + 37 => 1, + 40 => 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 array( + 29 => 1, + 30 => 1, + 34 => 1, + 40 => 1, + ); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Commenting/FunctionCommentUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Commenting/FunctionCommentUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Commenting/FunctionCommentUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Commenting/FunctionCommentUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,254 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Commenting/FunctionCommentUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Commenting/FunctionCommentUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Commenting/FunctionCommentUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Commenting/FunctionCommentUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,91 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for FunctionCommentSniff. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PEAR_Tests_Commenting_FunctionCommentUnitTest 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 array( + 10 => 1, + 12 => 2, + 13 => 2, + 14 => 1, + 15 => 1, + 28 => 1, + 35 => 1, + 38 => 1, + 41 => 1, + 53 => 1, + 103 => 1, + 109 => 1, + 112 => 1, + 122 => 1, + 123 => 3, + 124 => 3, + 125 => 4, + 126 => 6, + 139 => 1, + 155 => 1, + 165 => 1, + 172 => 1, + 183 => 1, + 193 => 2, + 204 => 1, + 234 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Commenting/InlineCommentUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Commenting/InlineCommentUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Commenting/InlineCommentUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Commenting/InlineCommentUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,27 @@ + \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Commenting/InlineCommentUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Commenting/InlineCommentUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Commenting/InlineCommentUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Commenting/InlineCommentUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,71 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the InlineComment sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PEAR_Tests_Commenting_InlineCommentUnitTest 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 array( + 15 => 1, + 24 => 1, + 25 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/ControlStructures/ControlSignatureUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/ControlStructures/ControlSignatureUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/ControlStructures/ControlSignatureUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/ControlStructures/ControlSignatureUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,159 @@ + 0); + +do +{ + echo $i; +} while ($i > 0); + +do +{ + echo $i; +} +while ($i > 0); + +do { echo $i; } while ($i > 0); + +do{ + echo $i; +}while($i > 0); + + +// while +while ($i < 1) { + echo $i; +} + +while($i < 1){ + echo $i; +} + +while ($i < 1) { echo $i; } + + +// for +for ($i = 1; $i < 1; $i++) { + echo $i; +} + +for($i = 1; $i < 1; $i++){ + echo $i; +} + +for ($i = 1; $i < 1; $i++) { echo $i; } + + +// foreach +foreach ($items as $item) { + echo $item; +} + +foreach($items as $item){ + echo $item; +} + +for ($items as $item) { echo $item; } + + +// if +if ($i == 0) { + $i = 1; +} + +if($i == 0){ + $i = 1; +} + +if ($i == 0) { $i = 1; } + + +// else +if ($i == 0) { + $i = 1; +} else { + $i = 0; +} + +if ($i == 0) { + $i = 1; +}else{ + $i = 0; +} + +if ($i == 0) { $i = 1; } else { $i = 0; } + + +// else +if ($i == 0) { + $i = 1; +} else { + $i = 0; +} + +if ($i == 0) { + $i = 1; +}else{ + $i = 0; +} + +if ($i == 0) { $i = 1; } else { $i = 0; } + + +// else if +if ($i == 0) { + $i = 1; +} else if ($i == 2) { + $i = 0; +} + +if ($i == 0) { + $i = 1; +} elseif ($i == 2) { + $i = 0; +} + +if ($i == 0) { + $i = 1; +}else if($i == 2){ + $i = 0; +} + +if ($i == 0) { + $i = 1; +}elseif($i == 2){ + $i = 0; +} + +if ($i == 0) { $i = 1; } else if ($i == 2) { $i = 0; } +if ($i == 0) { $i = 1; } elseif ($1 == 2) { $i = 0; } + +if ($i == 0) { // this is ok because comments are allowed + $i = 1; +} + +if ($i == 0) {// this is ok because comments are allowed + $i = 1; +} + +if ($i == 0) { /* this is ok because comments are allowed*/ + $i = 1; +} + +if ($i == 0) +{ // this is not ok + $i = 1; +} + +if ($i == 0) /* this is ok */ { +} + +if ($i == 0) { +} +else { +} +?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/ControlStructures/ControlSignatureUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/ControlStructures/ControlSignatureUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/ControlStructures/ControlSignatureUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/ControlStructures/ControlSignatureUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,90 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the ControlSignature sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PEAR_Tests_ControlStructures_ControlSignatureUnitTest 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 array( + 9 => 1, + 14 => 1, + 20 => 1, + 22 => 1, + 32 => 1, + 36 => 1, + 44 => 1, + 48 => 1, + 56 => 1, + 60 => 1, + 68 => 1, + 72 => 1, + 84 => 1, + 88 => 2, + 100 => 1, + 104 => 2, + 122 => 2, + 128 => 1, + 132 => 3, + 133 => 2, + 147 => 1, + 157 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/ControlStructures/MultiLineConditionUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/ControlStructures/MultiLineConditionUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/ControlStructures/MultiLineConditionUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/ControlStructures/MultiLineConditionUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,143 @@ + +

some text

+ diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/ControlStructures/MultiLineConditionUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/ControlStructures/MultiLineConditionUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/ControlStructures/MultiLineConditionUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/ControlStructures/MultiLineConditionUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,85 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the MultiLineCondition sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PEAR_Tests_ControlStructures_MultiLineConditionUnitTest 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 array( + 22 => 1, + 35 => 1, + 40 => 1, + 41 => 1, + 42 => 1, + 43 => 1, + 49 => 1, + 54 => 1, + 58 => 1, + 59 => 1, + 61 => 1, + 88 => 1, + 89 => 1, + 90 => 1, + 96 => 2, + 109 => 2, + 125 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Files/IncludingFileUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Files/IncludingFileUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Files/IncludingFileUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Files/IncludingFileUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,98 @@ + +
+Some content goes here.
+
+
+ +
+    Some content goes here.
+    
+    
+ diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Files/IncludingFileUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Files/IncludingFileUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Files/IncludingFileUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Files/IncludingFileUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,84 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the IncludingFile sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PEAR_Tests_Files_IncludingFileUnitTest 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 array( + 4 => 1, + 5 => 1, + 11 => 1, + 12 => 1, + 16 => 1, + 17 => 1, + 33 => 1, + 34 => 1, + 47 => 1, + 48 => 1, + 64 => 1, + 65 => 1, + 73 => 1, + 74 => 1, + 85 => 1, + 86 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Formatting/MultiLineAssignmentUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Formatting/MultiLineAssignmentUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Formatting/MultiLineAssignmentUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Formatting/MultiLineAssignmentUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,22 @@ +additionalHeaderData[$this->strApplicationName] + = $this->xajax->getJavascript(t3lib_extMgm::siteRelPath('nr_xajax')); + +$GLOBALS['TSFE']->additionalHeaderData[$this->strApplicationName] + = $this->xajax->getJavascript(t3lib_extMgm::siteRelPath('nr_xajax')); + +$GLOBALS['TSFE']->additionalHeaderData[$this->strApplicationName] = + $this->xajax->getJavascript(t3lib_extMgm::siteRelPath('nr_xajax')); + +$GLOBALS['TSFE']->additionalHeaderData[$this->strApplicationName] + = $this->xajax->getJavascript(t3lib_extMgm::siteRelPath('nr_xajax')); +$GLOBALS['TSFE']->additionalHeaderData[$this->strApplicationName] = 'boo' + +$var='string'; + +function getInstalledStandards( + $includeGeneric=false, + $standardsDir='' +) { +} +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Formatting/MultiLineAssignmentUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Formatting/MultiLineAssignmentUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Formatting/MultiLineAssignmentUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Formatting/MultiLineAssignmentUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,69 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the MultiLineAssignment sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PEAR_Tests_Formatting_MultiLineAssignmentUnitTest 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 array( + 3 => 1, + 6 => 1, + 8 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,208 @@ +getFoo() + ->doBar( + $this->getX() // no comma here + ->doY() // this is still the first method argument + ->doZ() // this is still the first method argument + ); +} + +$var = myFunction( +$foo, +$bar +); + +// @codingStandardsChangeSetting PEAR.Functions.FunctionCallSignature allowMultipleArguments false + +fputs( + STDOUT, + "Examples: + $ {$app} , --all + $ {$app} --all", $something +); + +$array = array(); +array_map( + function($x) + { + return trim($x, $y); + }, $foo + $array +); + +$bar = new stdClass( + 4, 5, 6 +); + +public function doSomething() +{ + return $this->getFoo() + ->doBar( + $this->getX() // no comma here + ->doY() // this is still the first method argument + ->doZ() // this is still the first method argument + ); +} + +doError( + 404, // status code + 'Not Found', // error name + 'Check your id' // fix +); + +// @codingStandardsChangeSetting PEAR.Functions.FunctionCallSignature allowMultipleArguments true + +// Don't report errors for closing braces. Leave that to other sniffs. +foo( + [ + 'this', + 'is', + 'an', + 'array' + ], +[ + 'this', + 'is', + 'an', + 'array' + ], + array( + 'this', + 'is', + 'an', + 'array' + ), + array( + 'this', + 'is', + 'an', + 'array' + ), + function($x) + { + return trim($x); + } +); + +function foo() +{ + myFunction( + 'string'. + // comment + // comment + 'string'. + /* comment + * comment + */ + 'string'. + ); +} +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,94 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the FunctionCallSignature sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PEAR_Tests_Functions_FunctionCallSignatureUnitTest 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 array( + 5 => 1, + 6 => 1, + 7 => 1, + 8 => 1, + 9 => 2, + 10 => 3, + 17 => 1, + 18 => 1, + 31 => 1, + 34 => 1, + 43 => 1, + 57 => 1, + 59 => 1, + 63 => 1, + 64 => 1, + 82 => 1, + 93 => 1, + 100 => 1, + 106 => 1, + 119 => 1, + 120 => 1, + 129 => 1, + 137 => 1, + 142 => 2, + 171 => 1, + 203 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,112 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,84 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the FunctionDeclaration sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PEAR_Tests_Functions_FunctionDeclarationUnitTest 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 array( + 3 => 1, + 4 => 1, + 5 => 1, + 9 => 1, + 10 => 1, + 11 => 1, + 14 => 1, + 17 => 1, + 27 => 1, + 44 => 1, + 51 => 1, + 61 => 2, + 86 => 1, + 98 => 2, + 108 => 1, + 109 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Functions/ValidDefaultValueUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Functions/ValidDefaultValueUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Functions/ValidDefaultValueUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Functions/ValidDefaultValueUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,86 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Functions/ValidDefaultValueUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Functions/ValidDefaultValueUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Functions/ValidDefaultValueUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/Functions/ValidDefaultValueUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,74 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the ValidDefaultValue sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PEAR_Tests_Functions_ValidDefaultValueUnitTest 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 array( + 29 => 1, + 34 => 1, + 39 => 1, + 71 => 1, + 76 => 1, + 81 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/NamingConventions/ValidClassNameUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/NamingConventions/ValidClassNameUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/NamingConventions/ValidClassNameUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/NamingConventions/ValidClassNameUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,48 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/NamingConventions/ValidClassNameUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/NamingConventions/ValidClassNameUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/NamingConventions/ValidClassNameUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/NamingConventions/ValidClassNameUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,80 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the ValidClassName sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PEAR_Tests_NamingConventions_ValidClassNameUnitTest 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 array( + 5 => 1, + 7 => 2, + 9 => 1, + 19 => 1, + 24 => 1, + 26 => 2, + 28 => 1, + 38 => 1, + 40 => 2, + 42 => 2, + 44 => 1, + 46 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/NamingConventions/ValidFunctionNameUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/NamingConventions/ValidFunctionNameUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/NamingConventions/ValidFunctionNameUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/NamingConventions/ValidFunctionNameUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,205 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/NamingConventions/ValidFunctionNameUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/NamingConventions/ValidFunctionNameUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/NamingConventions/ValidFunctionNameUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/NamingConventions/ValidFunctionNameUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,184 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the ValidFunctionName sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PEAR_Tests_NamingConventions_ValidFunctionNameUnitTest 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() + { + $errors = array( + 11 => 1, + 12 => 1, + 13 => 1, + 14 => 1, + 15 => 1, + 16 => 1, + 17 => 1, + 18 => 1, + 19 => 1, + 20 => 1, + 24 => 1, + 25 => 1, + 26 => 1, + 27 => 1, + 28 => 1, + 29 => 1, + 30 => 1, + 31 => 1, + 32 => 1, + 33 => 1, + 35 => 1, + 36 => 1, + 37 => 1, + 38 => 1, + 39 => 1, + 40 => 1, + 43 => 1, + 44 => 1, + 45 => 1, + 46 => 1, + 50 => 1, + 51 => 1, + 52 => 1, + 53 => 1, + 56 => 1, + 57 => 1, + 58 => 1, + 59 => 1, + 67 => 1, + 68 => 1, + 69 => 1, + 70 => 1, + 71 => 1, + 72 => 1, + 73 => 1, + 74 => 1, + 75 => 1, + 76 => 1, + 80 => 1, + 81 => 1, + 82 => 1, + 83 => 1, + 84 => 1, + 85 => 1, + 86 => 1, + 87 => 1, + 88 => 1, + 89 => 1, + 91 => 1, + 92 => 1, + 93 => 1, + 94 => 1, + 95 => 1, + 96 => 1, + 99 => 1, + 100 => 1, + 101 => 1, + 102 => 1, + 106 => 1, + 107 => 1, + 108 => 1, + 109 => 1, + 112 => 1, + 113 => 1, + 114 => 1, + 115 => 1, + 121 => 1, + 122 => 1, + 123 => 1, + 124 => 1, + 125 => 1, + 126 => 1, + 127 => 1, + 128 => 1, + 129 => 1, + 130 => 1, + 149 => 1, + 151 => 1, + 152 => 1, + 155 => 1, + 156 => 1, + 157 => 1, + 158 => 1, + 159 => 1, + 160 => 1, + 161 => 1, + 162 => 1, + 163 => 1, + 164 => 1, + 165 => 1, + 166 => 1, + 167 => 1, + 169 => 1, + 170 => 1, + 171 => 1, + 173 => 1, + 174 => 1, + 175 => 1, + ); + + // The trait tests will only work in PHP version where traits exist and + // will throw errors in earlier versions. + if (version_compare(PHP_VERSION, '5.4.0') < 0) { + $errors[196] = 1; + } + + return $errors; + + }//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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/NamingConventions/ValidVariableNameUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/NamingConventions/ValidVariableNameUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/NamingConventions/ValidVariableNameUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/NamingConventions/ValidVariableNameUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,96 @@ +def["POP_{$cc}_A"]}' + and POP_{$cc}_B = +'{$this->def["POP_{$cc}_B"]}')"; + } +} + +class mpgResponse{ + var $term_id; + var $currentTag; + function characterHandler($parser,$data){ + switch($this->currentTag) + { + case "term_id": { + $this->term_id=$data; + break; + } + } + }//end characterHandler +}//end class mpgResponse + +class foo +{ + const bar = << diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/NamingConventions/ValidVariableNameUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/NamingConventions/ValidVariableNameUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/NamingConventions/ValidVariableNameUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/NamingConventions/ValidVariableNameUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,72 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the ValidVariableName sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PEAR_Tests_NamingConventions_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 array( + 12 => 1, + 17 => 1, + 22 => 1, + 92 => 1, + 93 => 1, + 94 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/WhiteSpace/ObjectOperatorIndentUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/WhiteSpace/ObjectOperatorIndentUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/WhiteSpace/ObjectOperatorIndentUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/WhiteSpace/ObjectOperatorIndentUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,40 @@ +someFunction("some", "parameter") +->someOtherFunc(23, 42)-> + someOtherFunc2($one, $two) + + ->someOtherFunc3(23, 42) + ->andAThirdFunction(); + + $someObject->someFunction("some", "parameter") + ->someOtherFunc(23, 42); + +$someObject->someFunction("some", "parameter")->someOtherFunc(23, 42); + +$someObject->someFunction("some", "parameter") + ->someOtherFunc(23, 42); + +func( + $bar->foo() +) + ->bar(); + +func( + $bar->foo() +) + ->bar( + $bar->foo() + ->bar() + ->func() + ); + +$object + ->setBar($foo) + ->setFoo($bar); + +if ($bar) { + $object + ->setBar($foo) + ->setFoo($bar); +} +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/WhiteSpace/ObjectOperatorIndentUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/WhiteSpace/ObjectOperatorIndentUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/WhiteSpace/ObjectOperatorIndentUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/WhiteSpace/ObjectOperatorIndentUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,72 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the ObjectOperatorIndent sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PEAR_Tests_WhiteSpace_ObjectOperatorIndentUnitTest 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 array( + 3 => 2, + 6 => 1, + 15 => 1, + 27 => 1, + 37 => 1, + 38 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/WhiteSpace/ScopeClosingBraceUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/WhiteSpace/ScopeClosingBraceUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/WhiteSpace/ScopeClosingBraceUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/WhiteSpace/ScopeClosingBraceUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,91 @@ +{$property} =& new $class_name($this->db_index); + $this->modules[$module] =& $this->{$property}; +} + +foreach ($elements as $element) { + if ($something) { + // Do IF. + } else if ($somethingElse) { + // Do ELSE. + } +} + +switch ($foo) { +case 1: + switch ($bar) { + default: + if ($something) { + echo $string{1}; + } else if ($else) { + switch ($else) { + case 1: + // Do something. + break; + default: + // Do something. + break; + } + } + } +break; +case 2: + // Do something; + break; +} + +switch ($httpResponseCode) { + case 100: + case 101: + case 102: + default: + return 'Unknown'; +} + +switch ($httpResponseCode) { + case 100: + case 101: + case 102: + return 'Processing.'; + default: + return 'Unknown'; +} + +switch($i) { +case 1: {} +} +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/WhiteSpace/ScopeClosingBraceUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/WhiteSpace/ScopeClosingBraceUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/WhiteSpace/ScopeClosingBraceUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/WhiteSpace/ScopeClosingBraceUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,75 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the ScopeClosingBrace sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PEAR_Tests_WhiteSpace_ScopeClosingBraceUnitTest 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 array( + 11 => 1, + 13 => 1, + 24 => 1, + 61 => 1, + 65 => 1, + 85 => 1, + 89 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/WhiteSpace/ScopeIndentUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/WhiteSpace/ScopeIndentUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/WhiteSpace/ScopeIndentUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/WhiteSpace/ScopeIndentUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,315 @@ +hello(); // error here + } + + function hello() // error here + { // no error here as brackets can be put anywhere in the pear standard + echo 'hello'; + } + + function hello2() + { + if (TRUE) { // error here + echo 'hello'; // no error here as its more than 4 spaces. + } else { + echo 'bye'; // error here + } + + while (TRUE) { + echo 'hello'; // error here + }// no error here as its handled by another test. + + do { // error here + echo 'hello'; // error here + } while (TRUE); // no error here as its aligned with the do. + }// no error here as its handled by another test. + + function hello3() + { + switch ($hello) { + case 'hello': // no error here as switch statements shouldn't be indented ??? + break; + } + } + +} + +?> +
+
+
+validate()) {
+    $safe = $form->getSubmitValues();
+}
+?>
+
+open(); // error here + } + + public function open() + { + // Some inline stuff that shouldn't error + if (TRUE) echo 'hello'; + foreach ($tokens as $token) echo $token; + } + + /** + * This is a comment 1. + * This is a comment 2. + * This is a comment 3. + * This is a comment 4. + */ + public function close() + { + // All ok. + if (TRUE) { + if (TRUE) { + } else if (FALSE) { + foreach ($tokens as $token) { + switch ($token) { + case '1': + case '2': + if (true) { + if (false) { + if (false) { + if (false) { + echo 'hello'; + } + } + } + } + break; + case '5': + break; + } + do { + while (true) { + foreach ($tokens as $token) { + for ($i = 0; $i < $token; $i++) { + echo 'hello'; + } + } + } + } while (true); + } + } + } + } + + /* + This is another c style comment 1. + This is another c style comment 2. + This is another c style comment 3. + This is another c style comment 4. + This is another c style comment 5. + */ + + /* + * + * + * + */ + + /** + */ + + /* + This comment has a newline in it. + + */ + + public function read() + { + echo 'hello'; + + // no errors below. + $array = array( + 'this', + 'that' => array( + 'hello', + 'hello again' => array( + 'hello', + ), + ), + ); + } +} + +abstract class Test3 +{ + public function parse() + { + + foreach ($t as $ndx => $token) { + if (is_array($token)) { + echo 'here'; + } else { + $ts[] = array("token" => $token, "value" => ''); + + $last = count($ts) - 1; + + switch ($token) { + case '(': + + if ($last >= 3 && + $ts[0]['token'] != T_CLASS && + $ts[$last - 2]['token'] == T_OBJECT_OPERATOR && + $ts[$last - 3]['token'] == T_VARIABLE ) { + + + if (true) { + echo 'hello'; + } + } + array_push($braces, $token); + break; + } + } + } + } +} + +public function test() +{ + $o = << diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/WhiteSpace/ScopeIndentUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/WhiteSpace/ScopeIndentUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/WhiteSpace/ScopeIndentUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/Tests/WhiteSpace/ScopeIndentUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,83 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the ScopeIndent sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PEAR_Tests_WhiteSpace_ScopeIndentUnitTest 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 array( + 7 => 1, + 10 => 1, + 17 => 1, + 20 => 1, + 24 => 1, + 27 => 1, + 28 => 1, + 58 => 1, + 123 => 1, + 126 => 1, + 224 => 1, + 225 => 1, + 279 => 1, + 284 => 1, + 311 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/ruleset.xml php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/ruleset.xml --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/ruleset.xml 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PEAR/ruleset.xml 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,39 @@ + + + The PEAR coding standard. + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + + + + + + + + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PHPCS/ruleset.xml php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PHPCS/ruleset.xml --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PHPCS/ruleset.xml 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PHPCS/ruleset.xml 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,27 @@ + + + The coding standard for PHP_CodeSniffer itself. + */Tests/* + + + + + + + + + + + + + + + + + + + + 0 + + + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR1/Sniffs/Classes/ClassDeclarationSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR1/Sniffs/Classes/ClassDeclarationSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR1/Sniffs/Classes/ClassDeclarationSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR1/Sniffs/Classes/ClassDeclarationSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,78 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Class Declaration Test. + * + * Checks the declaration of the class is correct. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PSR1_Sniffs_Classes_ClassDeclarationSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * 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 integer $stackPtr The position of the current token in + * the token stack. + * + * @return void + */ + public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + $tokens = $phpcsFile->getTokens(); + $nextClass = $phpcsFile->findNext(array(T_CLASS, T_INTERFACE), ($stackPtr + 1)); + if ($nextClass !== false) { + $error = 'Each class must be in a file by itself'; + $phpcsFile->addError($error, $nextClass, 'MultipleClasses'); + } + + if (version_compare(PHP_VERSION, '5.3.0') >= 0) { + $namespace = $phpcsFile->findPrevious(T_NAMESPACE, ($stackPtr - 1)); + if ($namespace === false) { + $error = 'Each class must be in a namespace of at least one level (a top-level vendor name)'; + $phpcsFile->addError($error, $stackPtr, 'MissingNamespace'); + } + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR1/Sniffs/Files/SideEffectsSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR1/Sniffs/Files/SideEffectsSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR1/Sniffs/Files/SideEffectsSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR1/Sniffs/Files/SideEffectsSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,226 @@ + + * @copyright 2006-2012 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 + */ + +/** + * PSR1_Sniffs_Files_SideEffectsSniff. + * + * Ensures a file declare new symbols and causes no other side effects, or executes + * logic with side effects, but not both. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PSR1_Sniffs_Files_SideEffectsSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * 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 sniff, 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 token stack. + * + * @return void + */ + public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + // We are only interested if this is the first open tag. + if ($stackPtr !== 0) { + if ($phpcsFile->findPrevious(T_OPEN_TAG, ($stackPtr - 1)) !== false) { + return; + } + } + + $tokens = $phpcsFile->getTokens(); + $result = $this->_searchForConflict($phpcsFile, 0, ($phpcsFile->numTokens - 1), $tokens); + + if ($result['symbol'] !== null && $result['effect'] !== null) { + $error = 'A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line %s and the first side effect is on line %s.'; + $data = array( + $tokens[$result['symbol']]['line'], + $tokens[$result['effect']]['line'], + ); + $phpcsFile->addWarning($error, 0, 'FoundWithSymbols', $data); + } + + }//end process() + + + /** + * Searches for symbol declarations and side effects. + * + * Returns the positions of both the first symbol declared and the first + * side effect in the file. A NULL value for either indicates nothing was + * found. + * + * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. + * @param int $start The token to start searching from. + * @param int $end The token to search to. + * @param array $tokens The stack of tokens that make up + * the file. + * + * @return array + */ + private function _searchForConflict(PHP_CodeSniffer_File $phpcsFile, $start, $end, $tokens) + { + $symbols = array( + T_CLASS, + T_INTERFACE, + T_TRAIT, + T_FUNCTION, + ); + + $conditions = array( + T_IF, + T_ELSE, + T_ELSEIF, + ); + + $firstSymbol = null; + $firstEffect = null; + for ($i = $start; $i <= $end; $i++) { + // Ignore whitespace and comments. + if (in_array($tokens[$i]['code'], PHP_CodeSniffer_Tokens::$emptyTokens) === true) { + continue; + } + + // Ignore PHP tags. + if ($tokens[$i]['code'] === T_OPEN_TAG + || $tokens[$i]['code'] === T_CLOSE_TAG + ) { + continue; + } + + // Ignore entire namespace, const and use statements. + if ($tokens[$i]['code'] === T_NAMESPACE) { + $next = $phpcsFile->findNext(array(T_SEMICOLON, T_OPEN_CURLY_BRACKET), ($i + 1)); + if ($next === false) { + $next = $i++; + } else if ($tokens[$next]['code'] === T_OPEN_CURLY_BRACKET) { + $next = $tokens[$next]['bracket_closer']; + } + + $i = $next; + continue; + } else if ($tokens[$i]['code'] === T_USE + || $tokens[$i]['code'] === T_CONST + ) { + $semicolon = $phpcsFile->findNext(T_SEMICOLON, ($i + 1)); + if ($semicolon !== false) { + $i = $semicolon; + } + + continue; + } + + // Ignore function/class prefixes. + if (in_array($tokens[$i]['code'], PHP_CodeSniffer_Tokens::$methodPrefixes) === true) { + continue; + } + + // Detect and skip over symbols. + if (in_array($tokens[$i]['code'], $symbols) === true + && isset($tokens[$i]['scope_closer']) === true + ) { + if ($firstSymbol === null) { + $firstSymbol = $i; + } + + $i = $tokens[$i]['scope_closer']; + continue; + } else if ($tokens[$i]['code'] === T_STRING + && strtolower($tokens[$i]['content']) === 'define' + ) { + if ($firstSymbol === null) { + $firstSymbol = $i; + } + + $i = $phpcsFile->findNext(T_SEMICOLON, ($i + 1)); + continue; + } + + // Conditional statements are allowed in symbol files as long as the + // contents is only a symbol definition. So don't count these as effects + // in this case. + if (in_array($tokens[$i]['code'], $conditions) === true) { + if (isset($tokens[$i]['scope_opener']) === false) { + // Probably an "else if", so just ignore. + continue; + } + + $result = $this->_searchForConflict( + $phpcsFile, + ($tokens[$i]['scope_opener'] + 1), + ($tokens[$i]['scope_closer'] - 1), + $tokens + ); + + if ($result['symbol'] !== null) { + if ($firstSymbol === null) { + $firstSymbol = $result['symbol']; + } + + if ($result['effect'] !== null) { + // Found a conflict. + $firstEffect = $result['effect']; + break; + } + } + + if ($firstEffect === null) { + $firstEffect = $result['effect']; + } + + $i = $tokens[$i]['scope_closer']; + continue; + }//end if + + if ($firstEffect === null) { + $firstEffect = $i; + } + + if ($firstSymbol !== null) { + // We have a conflict we have to report, so no point continuing. + break; + } + }//end for + + return array( + 'symbol' => $firstSymbol, + 'effect' => $firstEffect, + ); + + }//end _searchForConflict() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR1/Tests/Classes/ClassDeclarationUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR1/Tests/Classes/ClassDeclarationUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR1/Tests/Classes/ClassDeclarationUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR1/Tests/Classes/ClassDeclarationUnitTest.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,4 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR1/Tests/Classes/ClassDeclarationUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR1/Tests/Classes/ClassDeclarationUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR1/Tests/Classes/ClassDeclarationUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR1/Tests/Classes/ClassDeclarationUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,74 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the ClassDeclaration sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PSR1_Tests_Classes_ClassDeclarationUnitTest 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() + { + if (version_compare(PHP_VERSION, '5.3.0') >= 0) { + return array( + 2 => 1, + 3 => 2, + ); + } else { + return array( + 3 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR1/Tests/Files/SideEffectsUnitTest.1.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR1/Tests/Files/SideEffectsUnitTest.1.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR1/Tests/Files/SideEffectsUnitTest.1.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR1/Tests/Files/SideEffectsUnitTest.1.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,60 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR1/Tests/Files/SideEffectsUnitTest.2.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR1/Tests/Files/SideEffectsUnitTest.2.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR1/Tests/Files/SideEffectsUnitTest.2.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR1/Tests/Files/SideEffectsUnitTest.2.inc 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,12 @@ + +'; +} + +printHead(); +?> + + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR1/Tests/Files/SideEffectsUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR1/Tests/Files/SideEffectsUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR1/Tests/Files/SideEffectsUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR1/Tests/Files/SideEffectsUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,77 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the SideEffects sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PSR1_Tests_Files_SideEffectsUnitTest 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='') + { + return array(); + + }//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. + * + * @param string $testFile The name of the file being tested. + * + * @return array(int => int) + */ + public function getWarningList($testFile='') + { + switch ($testFile) { + case 'SideEffectsUnitTest.3.inc': + case 'SideEffectsUnitTest.4.inc': + return array( + 1 => 1, + ); + default: + return array(); + }//end switch + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR1/ruleset.xml php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR1/ruleset.xml --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR1/ruleset.xml 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR1/ruleset.xml 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,48 @@ + + + The PSR1 coding standard. + + + + + + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Sniffs/Classes/ClassDeclarationSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Sniffs/Classes/ClassDeclarationSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Sniffs/Classes/ClassDeclarationSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Sniffs/Classes/ClassDeclarationSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,300 @@ + + * @copyright 2006-2012 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 + */ + +if (class_exists('PEAR_Sniffs_Classes_ClassDeclarationSniff', true) === false) { + $error = 'Class PEAR_Sniffs_Classes_ClassDeclarationSniff not found'; + throw new PHP_CodeSniffer_Exception($error); +} + +/** + * Class Declaration Test. + * + * Checks the declaration of the class and its inheritance is correct. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PSR2_Sniffs_Classes_ClassDeclarationSniff extends PEAR_Sniffs_Classes_ClassDeclarationSniff +{ + + + /** + * 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) + { + // We want all the errors from the PEAR standard, plus some of our own. + parent::process($phpcsFile, $stackPtr); + $this->processOpen($phpcsFile, $stackPtr); + $this->processClose($phpcsFile, $stackPtr); + + }//end process() + + + /** + * Processes the opening section of a class declaration. + * + * @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 processOpen(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + $tokens = $phpcsFile->getTokens(); + + // Check alignment of the keyword and braces. + if ($tokens[($stackPtr - 1)]['code'] === T_WHITESPACE) { + $prevContent = $tokens[($stackPtr - 1)]['content']; + if ($prevContent !== $phpcsFile->eolChar) { + $blankSpace = substr($prevContent, strpos($prevContent, $phpcsFile->eolChar)); + $spaces = strlen($blankSpace); + + if (in_array($tokens[($stackPtr - 2)]['code'], array(T_ABSTRACT, T_FINAL)) === true + && $spaces !== 1 + ) { + $type = strtolower($tokens[$stackPtr]['content']); + $prevContent = strtolower($tokens[($stackPtr - 2)]['content']); + $error = 'Expected 1 space between %s and %s keywords; %s found'; + $data = array( + $prevContent, + $type, + $spaces, + ); + $phpcsFile->addError($error, $stackPtr, 'SpaceBeforeKeyword', $data); + } + } + }//end if + + // We'll need the indent of the class/interface keyword for later. + $classIndent = 0; + if (strpos($tokens[($stackPtr - 1)]['content'], $phpcsFile->eolChar) === false) { + $classIndent = strlen($tokens[($stackPtr - 1)]['content']); + } + + $keyword = $stackPtr; + $openingBrace = $tokens[$stackPtr]['scope_opener']; + $className = $phpcsFile->findNext(T_STRING, $stackPtr); + + $classOrInterface = strtolower($tokens[$keyword]['content']); + + // Spacing of the keyword. + $gap = $tokens[($stackPtr + 1)]['content']; + if (strlen($gap) !== 1) { + $found = strlen($gap); + $error = 'Expected 1 space between %s keyword and %s name; %s found'; + $data = array( + $classOrInterface, + $classOrInterface, + $found, + ); + $phpcsFile->addError($error, $stackPtr, 'SpaceAfterKeyword', $data); + } + + // Check after the class/interface name. + $gap = $tokens[($className + 1)]['content']; + if (strlen($gap) !== 1) { + $found = strlen($gap); + $error = 'Expected 1 space after %s name; %s found'; + $data = array( + $classOrInterface, + $found, + ); + $phpcsFile->addError($error, $stackPtr, 'SpaceAfterName', $data); + } + + // Check positions of the extends and implements keywords. + foreach (array('extends', 'implements') as $keywordType) { + $keyword = $phpcsFile->findNext(constant('T_'.strtoupper($keywordType)), ($stackPtr + 1), $openingBrace); + if ($keyword !== false) { + if ($tokens[$keyword]['line'] !== $tokens[$stackPtr]['line']) { + $error = 'The '.$keywordType.' keyword must be on the same line as the %s name'; + $data = array($classOrInterface); + $phpcsFile->addError($error, $keyword, ucfirst($keywordType).'Line', $data); + } else { + // Check the whitespace before. Whitespace after is checked + // later by looking at the whitespace before the first class name + // in the list. + $gap = strlen($tokens[($keyword - 1)]['content']); + if ($gap !== 1) { + $error = 'Expected 1 space before '.$keywordType.' keyword; %s found'; + $data = array($gap); + $phpcsFile->addError($error, $keyword, 'SpaceBefore'.ucfirst($keywordType), $data); + } + } + } + }//end foreach + + // Check each of the extends/implements class names. If the implements + // keywords is the last content on the line, it means we need to check for + // the multi-line implements format, so we do not include the class names + // from the implements list in the following check. + $implements = $phpcsFile->findNext(T_IMPLEMENTS, ($stackPtr + 1), $openingBrace); + $multiLineImplements = false; + if ($implements !== false) { + $next = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($implements + 1), $openingBrace, true); + if ($tokens[$next]['line'] > $tokens[$implements]['line']) { + $multiLineImplements = true; + } + } + + $classNames = array(); + $find = array(T_STRING, T_IMPLEMENTS); + $nextClass = $phpcsFile->findNext($find, ($className + 2), ($openingBrace - 1)); + while ($nextClass !== false) { + $classNames[] = $nextClass; + $nextClass = $phpcsFile->findNext($find, ($nextClass + 1), ($openingBrace - 1)); + } + + $classCount = count($classNames); + $checkingImplements = false; + foreach ($classNames as $i => $className) { + if ($tokens[$className]['code'] == T_IMPLEMENTS) { + $checkingImplements = true; + continue; + } + + if ($checkingImplements === true + && $multiLineImplements === true + && ($tokens[($className - 1)]['code'] !== T_NS_SEPARATOR + || $tokens[($className - 2)]['code'] !== T_STRING) + ) { + $prev = $phpcsFile->findPrevious( + array(T_NS_SEPARATOR, T_WHITESPACE), + ($className - 1), + $implements, + true + ); + + if ($tokens[$prev]['line'] !== ($tokens[$className]['line'] - 1)) { + $error = 'Only one interface may be specified per line in a multi-line implements declaration'; + $phpcsFile->addError($error, $className, 'InterfaceSameLine'); + } else { + $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($className - 1), $implements); + $found = strlen($tokens[$prev]['content']); + $expected = ($classIndent + $this->indent); + if ($found !== $expected) { + $error = 'Expected %s spaces before interface name; %s found'; + $data = array( + $expected, + $found + ); + $phpcsFile->addError($error, $className, 'InterfaceWrongIndent', $data); + } + } + } else if ($tokens[($className - 1)]['code'] !== T_NS_SEPARATOR + || $tokens[($className - 2)]['code'] !== T_STRING + ) { + if ($tokens[($className - 1)]['code'] === T_COMMA + || ($tokens[($className - 1)]['code'] === T_NS_SEPARATOR + && $tokens[($className - 2)]['code'] === T_COMMA) + ) { + $error = 'Expected 1 space before "%s"; 0 found'; + $data = array($tokens[$className]['content']); + $phpcsFile->addError($error, ($nextComma + 1), 'NoSpaceBeforeName', $data); + } else { + if ($tokens[($className - 1)]['code'] === T_NS_SEPARATOR) { + $spaceBefore = strlen($tokens[($className - 2)]['content']); + } else { + $spaceBefore = strlen($tokens[($className - 1)]['content']); + } + + if ($spaceBefore !== 1) { + $error = 'Expected 1 space before "%s"; %s found'; + $data = array( + $tokens[$className]['content'], + $spaceBefore, + ); + $phpcsFile->addError($error, $className, 'SpaceBeforeName', $data); + } + }//end if + }//end if + + if ($tokens[($className + 1)]['code'] !== T_NS_SEPARATOR + && $tokens[($className + 1)]['code'] !== T_COMMA + ) { + if ($i !== ($classCount - 1)) { + // This is not the last class name, and the comma + // is not where we expect it to be. + if ($tokens[($className + 2)]['code'] !== T_IMPLEMENTS) { + $error = 'Expected 0 spaces between "%s" and comma; %s found'; + $data = array( + $tokens[$className]['content'], + strlen($tokens[($className + 1)]['content']), + ); + $phpcsFile->addError($error, $className, 'SpaceBeforeComma', $data); + } + } + + $nextComma = $phpcsFile->findNext(T_COMMA, $className); + } else { + $nextComma = ($className + 1); + } + }//end foreach + + }//end processOpen() + + + /** + * Processes the closing section of a class declaration. + * + * @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 processClose(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + $tokens = $phpcsFile->getTokens(); + + // Check that the closing brace comes right after the code body. + $closeBrace = $tokens[$stackPtr]['scope_closer']; + $prevContent = $phpcsFile->findPrevious(T_WHITESPACE, ($closeBrace - 1), null, true); + if ($tokens[$prevContent]['line'] !== ($tokens[$closeBrace]['line'] - 1)) { + $error = 'The closing brace for the %s must go on the next line after the body'; + $data = array($tokens[$stackPtr]['content']); + $phpcsFile->addError($error, $closeBrace, 'CloseBraceAfterBody', $data); + } + + // Check the closing brace is on it's own line, but allow + // for comments like "//end class". + $nextContent = $phpcsFile->findNext(T_COMMENT, ($closeBrace + 1), null, true); + if ($tokens[$nextContent]['content'] !== $phpcsFile->eolChar + && $tokens[$nextContent]['line'] === $tokens[$closeBrace]['line'] + ) { + $type = strtolower($tokens[$stackPtr]['content']); + $error = 'Closing %s brace must be on a line by itself'; + $data = array($tokens[$stackPtr]['content']); + $phpcsFile->addError($error, $closeBrace, 'CloseBraceSameLine', $data); + } + + }//end processClose() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Sniffs/Classes/PropertyDeclarationSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Sniffs/Classes/PropertyDeclarationSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Sniffs/Classes/PropertyDeclarationSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Sniffs/Classes/PropertyDeclarationSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,115 @@ + + * @copyright 2006-2012 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 + */ + +if (class_exists('PHP_CodeSniffer_Standards_AbstractVariableSniff', true) === false) { + throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_Standards_AbstractVariableSniff not found'); +} + +/** + * Verifies that properties are declared correctly. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PSR2_Sniffs_Classes_PropertyDeclarationSniff extends PHP_CodeSniffer_Standards_AbstractVariableSniff +{ + + + /** + * Processes the function tokens within the class. + * + * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found. + * @param int $stackPtr The position where the token was found. + * + * @return void + */ + protected function processMemberVar(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + $tokens = $phpcsFile->getTokens(); + + if ($tokens[$stackPtr]['content'][1] === '_') { + $error = 'Property name "%s" should not be prefixed with an underscore to indicate visibility'; + $data = array($tokens[$stackPtr]['content']); + $phpcsFile->addWarning($error, $stackPtr, 'Underscore', $data); + } + + // Detect multiple properties defined at the same time. Throw an error + // for this, but also only process the first property in the list so we don't + // repeat errors. + $find = PHP_CodeSniffer_Tokens::$scopeModifiers; + $find = array_merge($find, array(T_VARIABLE, T_VAR, T_SEMICOLON)); + $prev = $phpcsFile->findPrevious($find, ($stackPtr - 1)); + if ($tokens[$prev]['code'] === T_VARIABLE) { + return; + } + + if ($tokens[$prev]['code'] === T_VAR) { + $error = 'The var keyword must not be used to declare a property'; + $phpcsFile->addError($error, $stackPtr, 'VarUsed'); + } + + $next = $phpcsFile->findNext(array(T_VARIABLE, T_SEMICOLON), ($stackPtr + 1)); + if ($tokens[$next]['code'] === T_VARIABLE) { + $error = 'There must not be more than one property declared per statement'; + $phpcsFile->addError($error, $stackPtr, 'Multiple'); + } + + $modifier = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$scopeModifiers, $stackPtr); + if (($modifier === false) || ($tokens[$modifier]['line'] !== $tokens[$stackPtr]['line'])) { + $error = 'Visibility must be declared on property "%s"'; + $data = array($tokens[$stackPtr]['content']); + $phpcsFile->addError($error, $stackPtr, 'ScopeMissing', $data); + } + + }//end processMemberVar() + + + /** + * Processes normal variables. + * + * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found. + * @param int $stackPtr The position where the token was found. + * + * @return void + */ + protected function processVariable(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + // We don't care about normal variables. + + }//end processVariable() + + + /** + * Processes variables in double quoted strings. + * + * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found. + * @param int $stackPtr The position where the token was found. + * + * @return void + */ + protected function processVariableInString(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + // We don't care about normal variables. + + }//end processVariableInString() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Sniffs/ControlStructures/ControlStructureSpacingSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Sniffs/ControlStructures/ControlStructureSpacingSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Sniffs/ControlStructures/ControlStructureSpacingSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Sniffs/ControlStructures/ControlStructureSpacingSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,91 @@ + + * @copyright 2006-2012 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 + */ + +/** + * PSR2_Sniffs_WhiteSpace_ControlStructureSpacingSniff. + * + * Checks that control structures have the correct spacing around brackets. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PSR2_Sniffs_ControlStructures_ControlStructureSpacingSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array( + T_IF, + T_WHILE, + T_FOREACH, + T_FOR, + T_SWITCH, + T_DO, + T_ELSE, + T_ELSEIF, + ); + + }//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(); + + if (isset($tokens[$stackPtr]['parenthesis_opener']) === true) { + $parenOpener = $tokens[$stackPtr]['parenthesis_opener']; + $parenCloser = $tokens[$stackPtr]['parenthesis_closer']; + if ($tokens[($parenOpener + 1)]['code'] === T_WHITESPACE) { + $gap = strlen($tokens[($parenOpener + 1)]['content']); + $error = 'Expected 0 spaces after opening bracket; %s found'; + $data = array($gap); + $phpcsFile->addError($error, ($parenOpener + 1), 'SpacingAfterOpenBrace', $data); + } + + if ($tokens[$parenOpener]['line'] === $tokens[$parenCloser]['line'] + && $tokens[($parenCloser - 1)]['code'] === T_WHITESPACE + ) { + $gap = strlen($tokens[($parenCloser - 1)]['content']); + $error = 'Expected 0 spaces before closing bracket; %s found'; + $data = array($gap); + $phpcsFile->addError($error, ($parenCloser - 1), 'SpaceBeforeCloseBrace', $data); + } + }//end if + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Sniffs/ControlStructures/ElseIfDeclarationSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Sniffs/ControlStructures/ElseIfDeclarationSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Sniffs/ControlStructures/ElseIfDeclarationSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Sniffs/ControlStructures/ElseIfDeclarationSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,68 @@ + + * @copyright 2006-2012 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 + */ + +/** + * PSR2_Sniffs_ControlStructures_ElseIfDeclarationSniff. + * + * Verifies that there are no else if statements. Elseif should be used instead. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PSR2_Sniffs_ControlStructures_ElseIfDeclarationSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array(T_ELSE); + + }//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(); + $next = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); + if ($tokens[$next]['code'] === T_IF) { + $error = 'Usage of ELSE IF is discouraged; use ELSEIF instead'; + $phpcsFile->addWarning($error, $stackPtr, 'NotAllowed'); + } + + }//end process() + + +}//end class + + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Sniffs/ControlStructures/SwitchDeclarationSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Sniffs/ControlStructures/SwitchDeclarationSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Sniffs/ControlStructures/SwitchDeclarationSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Sniffs/ControlStructures/SwitchDeclarationSniff.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,200 @@ + + * @copyright 2006-2012 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 + */ + +/** + * PSR2_Sniffs_ControlStructures_SwitchDeclarationSniff. + * + * Ensures all switch statements are defined correctly. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PSR2_Sniffs_ControlStructures_SwitchDeclarationSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * The number of spaces code should be indented. + * + * @var int + */ + public $indent = 4; + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array(T_SWITCH); + + }//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(); + + // We can't process SWITCH statements unless we know where they start and end. + if (isset($tokens[$stackPtr]['scope_opener']) === false + || isset($tokens[$stackPtr]['scope_closer']) === false + ) { + return; + } + + $switch = $tokens[$stackPtr]; + $nextCase = $stackPtr; + $caseAlignment = ($switch['column'] + $this->indent); + $caseCount = 0; + $foundDefault = false; + + while (($nextCase = $this->_findNextCase($phpcsFile, ($nextCase + 1), $switch['scope_closer'])) !== false) { + if ($tokens[$nextCase]['code'] === T_DEFAULT) { + $type = 'default'; + $foundDefault = true; + } else { + $type = 'case'; + $caseCount++; + } + + if ($tokens[$nextCase]['content'] !== strtolower($tokens[$nextCase]['content'])) { + $expected = strtolower($tokens[$nextCase]['content']); + $error = strtoupper($type).' keyword must be lowercase; expected "%s" but found "%s"'; + $data = array( + $expected, + $tokens[$nextCase]['content'], + ); + $phpcsFile->addError($error, $nextCase, $type.'NotLower', $data); + } + + if ($tokens[$nextCase]['column'] !== $caseAlignment) { + $error = strtoupper($type).' keyword must be indented '.$this->indent.' spaces from SWITCH keyword'; + $phpcsFile->addError($error, $nextCase, $type.'Indent'); + } + + $prevCode = $phpcsFile->findPrevious(T_WHITESPACE, ($nextCase - 1), $stackPtr, true); + $blankLines = ($tokens[$nextCase]['line'] - $tokens[$prevCode]['line'] - 1); + if ($blankLines !== 0) { + $error = 'Blank lines are not allowed between case statements; found %s'; + $data = array($blankLines); + $phpcsFile->addError($error, $nextCase, 'SpaceBetweenCase', $data); + } + + if ($type === 'case' + && ($tokens[($nextCase + 1)]['code'] !== T_WHITESPACE + || $tokens[($nextCase + 1)]['content'] !== ' ') + ) { + $error = 'CASE keyword must be followed by a single space'; + $phpcsFile->addError($error, $nextCase, 'SpacingAfterCase'); + } + + $opener = $tokens[$nextCase]['scope_opener']; + if ($tokens[$opener]['code'] === T_COLON) { + if ($tokens[($opener - 1)]['code'] === T_WHITESPACE) { + $error = 'There must be no space before the colon in a '.strtoupper($type).' statement'; + $phpcsFile->addError($error, $nextCase, 'SpaceBeforeColon'.$type); + } + } else { + $error = strtoupper($type).' statements must not be defined using curly braces'; + $phpcsFile->addError($error, $nextCase, 'WrongOpener'.$type); + } + + $nextCloser = $tokens[$nextCase]['scope_closer']; + if ($tokens[$nextCloser]['scope_condition'] === $nextCase) { + // Only need to check some things once, even if the + // closer is shared between multiple case statements, or even + // the default case. + if ($tokens[$nextCloser]['column'] !== ($caseAlignment + $this->indent)) { + $error = 'Terminating statement must be indented to the same level as the CASE body'; + $phpcsFile->addError($error, $nextCloser, 'BreakIndent'); + } + } + + // We only want cases from here on in. + if ($type !== 'case') { + continue; + } + + $nextCode = $phpcsFile->findNext( + T_WHITESPACE, + ($tokens[$nextCase]['scope_opener'] + 1), + $nextCloser, + true + ); + + if ($tokens[$nextCode]['code'] !== T_CASE && $tokens[$nextCode]['code'] !== T_DEFAULT) { + // This case statement has content. If the next case or default comes + // before the closer, it means we dont have a terminating statement + // and instead need a comment. + $nextCode = $this->_findNextCase($phpcsFile, ($tokens[$nextCase]['scope_opener'] + 1), $nextCloser); + if ($nextCode !== false) { + $prevCode = $phpcsFile->findPrevious(T_WHITESPACE, ($nextCode - 1), $nextCase, true); + if ($tokens[$prevCode]['code'] !== T_COMMENT) { + $error = 'There must be a comment when fall-through is intentional in a non-empty case body'; + $phpcsFile->addError($error, $nextCase, 'TerminatingComment'); + } + } + } + }//end while + + }//end process() + + + /** + * Find the next CASE or DEFAULT statement from a point in the file. + * + * Note that nested switches are ignored. + * + * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. + * @param int $stackPtr The position to start looking at. + * @param int $end The position to stop looking at. + * + * @return int | bool + */ + private function _findNextCase(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $end) + { + $tokens = $phpcsFile->getTokens(); + while (($stackPtr = $phpcsFile->findNext(array(T_CASE, T_DEFAULT, T_SWITCH), $stackPtr, $end)) !== false) { + // Skip nested SWITCH statements; they are handled on their own. + if ($tokens[$stackPtr]['code'] === T_SWITCH) { + $stackPtr = $tokens[$stackPtr]['scope_closer']; + continue; + } + + break; + } + + return $stackPtr; + + }//end _findNextCase() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Sniffs/Files/EndFileNewlineSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Sniffs/Files/EndFileNewlineSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Sniffs/Files/EndFileNewlineSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Sniffs/Files/EndFileNewlineSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,97 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Generic_Sniffs_Files_EndFileNewlineSniff. + * + * Ensures the file ends with a newline character. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PSR2_Sniffs_Files_EndFileNewlineSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * 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 sniff, 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) + { + // We are only interested if this is the first open tag and in a file + // that only contains PHP code. + if ($stackPtr !== 0) { + if ($phpcsFile->findPrevious(array(T_OPEN_TAG, T_INLINE_HTML), ($stackPtr - 1)) !== false) { + return; + } + } + + if ($phpcsFile->findNext(T_INLINE_HTML, ($stackPtr + 1)) !== false) { + return; + } + + // Skip to the end of the file. + $tokens = $phpcsFile->getTokens(); + $stackPtr = ($phpcsFile->numTokens - 1); + + // Hard-coding the expected \n in this sniff as it is PSR-2 specific and + // PSR-2 enforces the use of unix style newlines. + if (substr($tokens[$stackPtr]['content'], -1) !== "\n") { + $error = 'Expected 1 newline at end of file; 0 found'; + $phpcsFile->addError($error, $stackPtr, 'NoneFound'); + return; + } + + // Go looking for the last non-empty line. + $lastLine = $tokens[$stackPtr]['line']; + while ($tokens[$stackPtr]['code'] === T_WHITESPACE) { + $stackPtr--; + } + + $lastCodeLine = $tokens[$stackPtr]['line']; + $blankLines = ($lastLine - $lastCodeLine); + if ($blankLines > 0) { + $error = 'Expected 1 blank line at end of file; %s found'; + $data = array($blankLines + 1); + $phpcsFile->addError($error, $stackPtr, 'TooMany', $data); + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Sniffs/Methods/MethodDeclarationSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Sniffs/Methods/MethodDeclarationSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Sniffs/Methods/MethodDeclarationSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Sniffs/Methods/MethodDeclarationSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,118 @@ + + * @copyright 2006-2012 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 + */ + +if (class_exists('PHP_CodeSniffer_Standards_AbstractScopeSniff', true) === false) { + throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_Standards_AbstractScopeSniff not found'); +} + +/** + * PSR2_Sniffs_Methods_MethodDeclarationSniff. + * + * Checks that the method declaration is correct. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PSR2_Sniffs_Methods_MethodDeclarationSniff extends PHP_CodeSniffer_Standards_AbstractScopeSniff +{ + + + /** + * Constructs a Squiz_Sniffs_Scope_MethodScopeSniff. + */ + public function __construct() + { + parent::__construct(array(T_CLASS, T_INTERFACE), array(T_FUNCTION)); + + }//end __construct() + + + /** + * Processes the function tokens within the class. + * + * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found. + * @param int $stackPtr The position where the token was found. + * @param int $currScope The current scope opener token. + * + * @return void + */ + protected function processTokenWithinScope(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $currScope) + { + $tokens = $phpcsFile->getTokens(); + + $methodName = $phpcsFile->getDeclarationName($stackPtr); + if ($methodName === null) { + // Ignore closures. + return; + } + + if ($methodName[0] === '_' && isset($methodName[1]) === true && $methodName[1] !== '_') { + $error = 'Method name "%s" should not be prefixed with an underscore to indicate visibility'; + $data = array($methodName); + $phpcsFile->addWarning($error, $stackPtr, 'Underscore', $data); + } + + $visibility = 0; + $static = 0; + $abstract = 0; + $final = 0; + + $find = PHP_CodeSniffer_Tokens::$methodPrefixes; + $find[] = T_WHITESPACE; + $prev = $phpcsFile->findPrevious($find, ($stackPtr - 1), null, true); + + $prefix = $stackPtr; + while (($prefix = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$methodPrefixes, ($prefix - 1), $prev)) !== false) { + switch ($tokens[$prefix]['code']) { + case T_STATIC: + $static = $prefix; + break; + case T_ABSTRACT: + $abstract = $prefix; + break; + case T_FINAL: + $final = $prefix; + break; + default: + $visibility = $prefix; + break; + } + } + + if ($static !== 0 && $static < $visibility) { + $error = 'The static declaration must come after the visibility declaration'; + $phpcsFile->addError($error, $static, 'StaticBeforeVisibility'); + } + + if ($visibility !== 0 && $final > $visibility) { + $error = 'The final declaration must precede the visibility declaration'; + $phpcsFile->addError($error, $final, 'FinalAfterVisibility'); + } + + if ($visibility !== 0 && $abstract > $visibility) { + $error = 'The abstract declaration must precede the visibility declaration'; + $phpcsFile->addError($error, $abstract, 'AbstractAfterVisibility'); + } + + }//end processTokenWithinScope() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Sniffs/Namespaces/NamespaceDeclarationSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Sniffs/Namespaces/NamespaceDeclarationSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Sniffs/Namespaces/NamespaceDeclarationSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Sniffs/Namespaces/NamespaceDeclarationSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,79 @@ + + * @copyright 2006-2012 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 + */ + +/** + * PSR2_Sniffs_Namespaces_NamespaceDeclarationSniff. + * + * Ensures namespaces are declared correctly. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PSR2_Sniffs_Namespaces_NamespaceDeclarationSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array(T_NAMESPACE); + + }//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(); + + for ($i = ($stackPtr + 1); $i < $phpcsFile->numTokens; $i++) { + if ($tokens[$i]['line'] === $tokens[$stackPtr]['line']) { + continue; + } + + break; + } + + // The $i var now points to the first token on the line after the + // namespace declaration, which must be a blank line. + $next = $phpcsFile->findNext(T_WHITESPACE, $i, $phpcsFile->numTokens, true); + if ($tokens[$next]['line'] === $tokens[$i]['line']) { + $error = 'There must be one blank line after the namespace declaration'; + $phpcsFile->addError($error, $stackPtr, 'BlankLineAfter'); + } + + }//end process() + + +}//end class + + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Sniffs/Namespaces/UseDeclarationSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Sniffs/Namespaces/UseDeclarationSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Sniffs/Namespaces/UseDeclarationSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Sniffs/Namespaces/UseDeclarationSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,139 @@ + + * @copyright 2006-2012 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 + */ + +/** + * PSR2_Sniffs_Namespaces_UseDeclarationSniff. + * + * Ensures USE blocks are declared correctly. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PSR2_Sniffs_Namespaces_UseDeclarationSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array(T_USE); + + }//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) + { + if ($this->_shouldIgnoreUse($phpcsFile, $stackPtr) === true) { + return; + } + + $tokens = $phpcsFile->getTokens(); + + // Only one USE declaration allowed per statement. + $next = $phpcsFile->findNext(array(T_COMMA, T_SEMICOLON), ($stackPtr + 1)); + if ($tokens[$next]['code'] === T_COMMA) { + $error = 'There must be one USE keyword per declaration'; + $phpcsFile->addError($error, $stackPtr, 'MultipleDeclarations'); + } + + // Make sure this USE comes after the first namespace declaration. + $prev = $phpcsFile->findPrevious(T_NAMESPACE, ($stackPtr - 1)); + if ($prev !== false) { + $first = $phpcsFile->findNext(T_NAMESPACE, 1); + if ($prev !== $first) { + $error = 'USE declarations must go after the first namespace declaration'; + $phpcsFile->addError($error, $stackPtr, 'UseAfterNamespace'); + } + } + + // Only interested in the last USE statement from here onwards. + $nextUse = $phpcsFile->findNext(T_USE, ($stackPtr + 1)); + while ($this->_shouldIgnoreUse($phpcsFile, $nextUse) === true) { + $nextUse = $phpcsFile->findNext(T_USE, ($nextUse + 1)); + if ($nextUse === false) { + break; + } + } + + if ($nextUse !== false) { + return; + } + + $end = $phpcsFile->findNext(T_SEMICOLON, ($stackPtr + 1)); + $next = $phpcsFile->findNext(T_WHITESPACE, ($end + 1), null, true); + $diff = ($tokens[$next]['line'] - $tokens[$end]['line'] - 1); + if ($diff !== 1) { + if ($diff < 0) { + $diff = 0; + } + + $error = 'There must be one blank line after the last USE statement; %s found;'; + $data = array($diff); + $phpcsFile->addError($error, $stackPtr, 'SpaceAfterLastUse', $data); + } + + }//end process() + + + /** + * Check if this use statement is part of the namespace block. + * + * @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 + */ + private function _shouldIgnoreUse(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + $tokens = $phpcsFile->getTokens(); + + // Ignore USE keywords inside closures. + $next = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); + if ($tokens[$next]['code'] === T_OPEN_PARENTHESIS) { + return true; + } + + // Ignore USE keywords for traits. + if ($phpcsFile->hasCondition($stackPtr, T_CLASS) === true) { + return true; + } + + return false; + + }//end _shouldIgnoreUse() + + +}//end class + + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,77 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,84 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the ClassDeclaration sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PSR2_Tests_Classes_ClassDeclarationUnitTest 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 array( + 2 => 1, + 7 => 3, + 12 => 1, + 13 => 1, + 17 => 1, + 19 => 2, + 20 => 1, + 21 => 1, + 22 => 1, + 25 => 1, + 27 => 1, + 28 => 1, + 29 => 1, + 34 => 1, + 35 => 2, + 44 => 1, + 45 => 1, + 63 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/Classes/PropertyDeclarationUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/Classes/PropertyDeclarationUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/Classes/PropertyDeclarationUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/Classes/PropertyDeclarationUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,28 @@ + \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/Classes/PropertyDeclarationUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/Classes/PropertyDeclarationUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/Classes/PropertyDeclarationUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/Classes/PropertyDeclarationUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,75 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the PropertyDeclaration sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PSR2_Tests_Classes_PropertyDeclarationUnitTest 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 array( + 7 => 1, + 9 => 2, + 10 => 1, + 16 => 1, + 17 => 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 array( + 12 => 1, + 13 => 1, + 14 => 1, + ); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/ControlStructures/ControlStructureSpacingUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/ControlStructures/ControlStructureSpacingUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/ControlStructures/ControlStructureSpacingUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/ControlStructures/ControlStructureSpacingUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,38 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/ControlStructures/ControlStructureSpacingUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/ControlStructures/ControlStructureSpacingUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/ControlStructures/ControlStructureSpacingUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/ControlStructures/ControlStructureSpacingUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,73 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the FunctionSpacing sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PSR2_Tests_ControlStructures_ControlStructureSpacingUnitTest 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 array( + 4 => 1, + 14 => 2, + 26 => 2, + 27 => 2, + 31 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/ControlStructures/ElseIfDeclarationUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/ControlStructures/ElseIfDeclarationUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/ControlStructures/ElseIfDeclarationUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/ControlStructures/ElseIfDeclarationUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,17 @@ + \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/ControlStructures/ElseIfDeclarationUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/ControlStructures/ElseIfDeclarationUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/ControlStructures/ElseIfDeclarationUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/ControlStructures/ElseIfDeclarationUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,68 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the ElseIfDeclaration sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PSR2_Tests_ControlStructures_ElseIfDeclarationUnitTest 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 array(); + + }//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 array( + 4 => 1, + 12 => 1, + ); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/ControlStructures/SwitchDeclarationUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/ControlStructures/SwitchDeclarationUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/ControlStructures/SwitchDeclarationUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/ControlStructures/SwitchDeclarationUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,70 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/ControlStructures/SwitchDeclarationUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/ControlStructures/SwitchDeclarationUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/ControlStructures/SwitchDeclarationUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/ControlStructures/SwitchDeclarationUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,73 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the SwitchDeclaration sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PSR2_Tests_ControlStructures_SwitchDeclarationUnitTest 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 array( + 20 => 1, + 23 => 2, + 26 => 1, + 29 => 1, + 31 => 1, + 33 => 1, + 37 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/Files/EndFileNewlineUnitTest.1.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/Files/EndFileNewlineUnitTest.1.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/Files/EndFileNewlineUnitTest.1.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/Files/EndFileNewlineUnitTest.1.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,3 @@ + + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/Files/EndFileNewlineUnitTest.5.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/Files/EndFileNewlineUnitTest.5.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/Files/EndFileNewlineUnitTest.5.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/Files/EndFileNewlineUnitTest.5.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,6 @@ + + + + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the EndFileNewline sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PSR2_Tests_Files_EndFileNewlineUnitTest 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='') + { + switch ($testFile) { + case 'EndFileNewlineUnitTest.1.inc': + case 'EndFileNewlineUnitTest.3.inc': + case 'EndFileNewlineUnitTest.6.inc': + case 'EndFileNewlineUnitTest.7.inc': + return array( + 2 => 1, + ); + break; + default: + return array(); + break; + }//end switch + + }//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. + * + * @param string $testFile The name of the file being tested. + * + * @return array(int => int) + */ + public function getWarningList($testFile='') + { + return array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/Methods/MethodDeclarationUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/Methods/MethodDeclarationUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/Methods/MethodDeclarationUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/Methods/MethodDeclarationUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,19 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/Methods/MethodDeclarationUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/Methods/MethodDeclarationUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/Methods/MethodDeclarationUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/Methods/MethodDeclarationUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,72 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the MethodDeclaration sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PSR2_Tests_Methods_MethodDeclarationUnitTest 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 array( + 9 => 1, + 11 => 1, + 13 => 1, + 15 => 3, + ); + + }//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 array( + 5 => 1, + ); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/Namespaces/NamespaceDeclarationUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/Namespaces/NamespaceDeclarationUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/Namespaces/NamespaceDeclarationUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/Namespaces/NamespaceDeclarationUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,9 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/Namespaces/NamespaceDeclarationUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/Namespaces/NamespaceDeclarationUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/Namespaces/NamespaceDeclarationUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/Namespaces/NamespaceDeclarationUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,67 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the NamespaceDeclaration sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PSR2_Tests_Namespaces_NamespaceDeclarationUnitTest 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 array( + 6 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/Namespaces/UseDeclarationUnitTest.1.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/Namespaces/UseDeclarationUnitTest.1.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/Namespaces/UseDeclarationUnitTest.1.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/Namespaces/UseDeclarationUnitTest.1.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,26 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/Namespaces/UseDeclarationUnitTest.3.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/Namespaces/UseDeclarationUnitTest.3.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/Namespaces/UseDeclarationUnitTest.3.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/Tests/Namespaces/UseDeclarationUnitTest.3.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,15 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the UseDeclaration sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PSR2_Tests_Namespaces_UseDeclarationUnitTest 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($testFile='') + { + switch ($testFile) { + case 'UseDeclarationUnitTest.2.inc': + return array( + 5 => 1, + 10 => 2, + ); + break; + case 'UseDeclarationUnitTest.3.inc': + return array( + 5 => 1, + ); + break; + default: + return array(); + break; + }//end switch + + }//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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/ruleset.xml php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/ruleset.xml --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/ruleset.xml 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/PSR2/ruleset.xml 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,185 @@ + + + The PSR-2 coding standard. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + 0 + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Docs/Arrays/ArrayDeclarationStandard.xml php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Docs/Arrays/ArrayDeclarationStandard.xml --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Docs/Arrays/ArrayDeclarationStandard.xml 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Docs/Arrays/ArrayDeclarationStandard.xml 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,117 @@ + + + + + + array keyword must be lowercase. + ]]> + + + + array('val1', 'val2'); + ]]> + + + Array('val1', 'val2'); + ]]> + + + + array keyword. + ]]> + + + + 'key1' => 'value1', + 'key2' => 'value2', + ); + ]]> + + + 'key1' => 'value1', + 'key2' => 'value2', + ); + ]]> + + + + array keyword. The closing parenthesis must be aligned with the start of the array keyword. + ]]> + + + + 'key1' => 'value1', + 'key2' => 'value2', + ); + ]]> + + + 'key1' => 'value1', + 'key2' => 'value2', +); + ]]> + + + + + + + + => 'ValueTen', + 'keyTwenty' => 'ValueTwenty', + ); + ]]> + + + => 'ValueTen', + 'keyTwenty' => 'ValueTwenty', + ); + ]]> + + + + + + + + 'value1', + 'key2' => 'value2', + 'key3' => 'value3', + ); + ]]> + + + 'value1', + 'key2' => 'value2', + 'key3' => 'value3' + ); + ]]> + + + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Arrays/ArrayBracketSpacingSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Arrays/ArrayBracketSpacingSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Arrays/ArrayBracketSpacingSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Arrays/ArrayBracketSpacingSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,111 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_Arrays_ArrayBracketSpacingSniff. + * + * Ensure that there are no spaces around square brackets. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_Arrays_ArrayBracketSpacingSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array( + T_OPEN_SQUARE_BRACKET, + T_CLOSE_SQUARE_BRACKET, + ); + + }//end register() + + + /** + * Processes this sniff, when one of its tokens is encountered. + * + * @param PHP_CodeSniffer_File $phpcsFile The current file being checked. + * @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(); + + // PHP 5.4 introduced a shorthand array declaration syntax, so we need + // to ignore the these type of array declarations because this sniff is + // only dealing with array usage. + if ($tokens[$stackPtr]['code'] === T_OPEN_SQUARE_BRACKET) { + $openBracket = $stackPtr; + } else { + $openBracket = $tokens[$stackPtr]['bracket_opener']; + } + + $prev = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($openBracket - 1), null, true); + if ($tokens[$prev]['code'] === T_EQUAL) { + return; + } + + // Square brackets can not have a space before them. + $prevType = $tokens[($stackPtr - 1)]['code']; + if (in_array($prevType, PHP_CodeSniffer_Tokens::$emptyTokens) === true) { + $nonSpace = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 2), null, true); + $expected = $tokens[$nonSpace]['content'].$tokens[$stackPtr]['content']; + $found = $phpcsFile->getTokensAsString($nonSpace, ($stackPtr - $nonSpace)).$tokens[$stackPtr]['content']; + $error = 'Space found before square bracket; expected "%s" but found "%s"'; + $data = array( + $expected, + $found, + ); + $phpcsFile->addError($error, $stackPtr, 'SpaceBeforeBracket', $data); + } + + // Open square brackets can't ever have spaces after them. + if ($tokens[$stackPtr]['code'] === T_OPEN_SQUARE_BRACKET) { + $nextType = $tokens[($stackPtr + 1)]['code']; + if (in_array($nextType, PHP_CodeSniffer_Tokens::$emptyTokens) === true) { + $nonSpace = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr + 2), null, true); + $expected = $tokens[$stackPtr]['content'].$tokens[$nonSpace]['content']; + $found = $phpcsFile->getTokensAsString($stackPtr, ($nonSpace - $stackPtr + 1)); + $error = 'Space found after square bracket; expected "%s" but found "%s"'; + $data = array( + $expected, + $found, + ); + $phpcsFile->addError($error, $stackPtr, 'SpaceAfterBracket', $data); + } + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,513 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * A test to ensure that arrays conform to the array coding standard. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_Arrays_ArrayDeclarationSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array(T_ARRAY); + + }//end register() + + + /** + * Processes this sniff, when one of its tokens is encountered. + * + * @param PHP_CodeSniffer_File $phpcsFile The current file being checked. + * @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(); + + // Array keyword should be lower case. + if (strtolower($tokens[$stackPtr]['content']) !== $tokens[$stackPtr]['content']) { + $error = 'Array keyword should be lower case; expected "array" but found "%s"'; + $data = array($tokens[$stackPtr]['content']); + $phpcsFile->addError($error, $stackPtr, 'NotLowerCase', $data); + } + + $arrayStart = $tokens[$stackPtr]['parenthesis_opener']; + $arrayEnd = $tokens[$arrayStart]['parenthesis_closer']; + $keywordStart = $tokens[$stackPtr]['column']; + + if ($arrayStart != ($stackPtr + 1)) { + $error = 'There must be no space between the Array keyword and the opening parenthesis'; + $phpcsFile->addError($error, $stackPtr, 'SpaceAfterKeyword'); + } + + // Check for empty arrays. + $content = $phpcsFile->findNext(array(T_WHITESPACE), ($arrayStart + 1), ($arrayEnd + 1), true); + if ($content === $arrayEnd) { + // Empty array, but if the brackets aren't together, there's a problem. + if (($arrayEnd - $arrayStart) !== 1) { + $error = 'Empty array declaration must have no space between the parentheses'; + $phpcsFile->addError($error, $stackPtr, 'SpaceInEmptyArray'); + + // We can return here because there is nothing else to check. All code + // below can assume that the array is not empty. + return; + } + } + + if ($tokens[$arrayStart]['line'] === $tokens[$arrayEnd]['line']) { + // Single line array. + // Check if there are multiple values. If so, then it has to be multiple lines + // unless it is contained inside a function call or condition. + $valueCount = 0; + $commas = array(); + for ($i = ($arrayStart + 1); $i < $arrayEnd; $i++) { + // Skip bracketed statements, like function calls. + if ($tokens[$i]['code'] === T_OPEN_PARENTHESIS) { + $i = $tokens[$i]['parenthesis_closer']; + continue; + } + + if ($tokens[$i]['code'] === T_COMMA) { + $valueCount++; + $commas[] = $i; + } + } + + // Now check each of the double arrows (if any). + $nextArrow = $arrayStart; + while (($nextArrow = $phpcsFile->findNext(T_DOUBLE_ARROW, ($nextArrow + 1), $arrayEnd)) !== false) { + if ($tokens[($nextArrow - 1)]['code'] !== T_WHITESPACE) { + $content = $tokens[($nextArrow - 1)]['content']; + $error = 'Expected 1 space between "%s" and double arrow; 0 found'; + $data = array($content); + $phpcsFile->addError($error, $nextArrow, 'NoSpaceBeforeDoubleArrow', $data); + } else { + $spaceLength = strlen($tokens[($nextArrow - 1)]['content']); + if ($spaceLength !== 1) { + $content = $tokens[($nextArrow - 2)]['content']; + $error = 'Expected 1 space between "%s" and double arrow; %s found'; + $data = array( + $content, + $spaceLength, + ); + $phpcsFile->addError($error, $nextArrow, 'SpaceBeforeDoubleArrow', $data); + } + } + + if ($tokens[($nextArrow + 1)]['code'] !== T_WHITESPACE) { + $content = $tokens[($nextArrow + 1)]['content']; + $error = 'Expected 1 space between double arrow and "%s"; 0 found'; + $data = array($content); + $phpcsFile->addError($error, $nextArrow, 'NoSpaceAfterDoubleArrow', $data); + } else { + $spaceLength = strlen($tokens[($nextArrow + 1)]['content']); + if ($spaceLength !== 1) { + $content = $tokens[($nextArrow + 2)]['content']; + $error = 'Expected 1 space between double arrow and "%s"; %s found'; + $data = array( + $content, + $spaceLength, + ); + $phpcsFile->addError($error, $nextArrow, 'SpaceAfterDoubleArrow', $data); + } + } + }//end while + + if ($valueCount > 0) { + $conditionCheck = $phpcsFile->findPrevious(array(T_OPEN_PARENTHESIS, T_SEMICOLON), ($stackPtr - 1), null, false); + + if (($conditionCheck === false) || ($tokens[$conditionCheck]['line'] !== $tokens[$stackPtr]['line'])) { + $error = 'Array with multiple values cannot be declared on a single line'; + $phpcsFile->addError($error, $stackPtr, 'SingleLineNotAllowed'); + return; + } + + // We have a multiple value array that is inside a condition or + // function. Check its spacing is correct. + foreach ($commas as $comma) { + if ($tokens[($comma + 1)]['code'] !== T_WHITESPACE) { + $content = $tokens[($comma + 1)]['content']; + $error = 'Expected 1 space between comma and "%s"; 0 found'; + $data = array($content); + $phpcsFile->addError($error, $comma, 'NoSpaceAfterComma', $data); + } else { + $spaceLength = strlen($tokens[($comma + 1)]['content']); + if ($spaceLength !== 1) { + $content = $tokens[($comma + 2)]['content']; + $error = 'Expected 1 space between comma and "%s"; %s found'; + $data = array( + $content, + $spaceLength, + ); + $phpcsFile->addError($error, $comma, 'SpaceAfterComma', $data); + } + } + + if ($tokens[($comma - 1)]['code'] === T_WHITESPACE) { + $content = $tokens[($comma - 2)]['content']; + $spaceLength = strlen($tokens[($comma - 1)]['content']); + $error = 'Expected 0 spaces between "%s" and comma; %s found'; + $data = array( + $content, + $spaceLength, + ); + $phpcsFile->addError($error, $comma, 'SpaceBeforeComma', $data); + } + }//end foreach + }//end if + + return; + }//end if + + // Check the closing bracket is on a new line. + $lastContent = $phpcsFile->findPrevious(T_WHITESPACE, ($arrayEnd - 1), $arrayStart, true); + if ($tokens[$lastContent]['line'] !== ($tokens[$arrayEnd]['line'] - 1)) { + $error = 'Closing parenthesis of array declaration must be on a new line'; + $phpcsFile->addError($error, $arrayEnd, 'CloseBraceNewLine'); + } else if ($tokens[$arrayEnd]['column'] !== $keywordStart) { + // Check the closing bracket is lined up under the a in array. + $expected = $keywordStart; + $found = $tokens[$arrayEnd]['column']; + $error = 'Closing parenthesis not aligned correctly; expected %s space(s) but found %s'; + $data = array( + $expected, + $found, + ); + $phpcsFile->addError($error, $arrayEnd, 'CloseBraceNotAligned', $data); + } + + $nextToken = $stackPtr; + $lastComma = $stackPtr; + $keyUsed = false; + $singleUsed = false; + $lastToken = ''; + $indices = array(); + $maxLength = 0; + + // Find all the double arrows that reside in this scope. + while (($nextToken = $phpcsFile->findNext(array(T_DOUBLE_ARROW, T_COMMA, T_ARRAY), ($nextToken + 1), $arrayEnd)) !== false) { + $currentEntry = array(); + + if ($tokens[$nextToken]['code'] === T_ARRAY) { + // Let subsequent calls of this test handle nested arrays. + $indices[] = array( + 'value' => $nextToken, + ); + $nextToken = $tokens[$tokens[$nextToken]['parenthesis_opener']]['parenthesis_closer']; + continue; + } + + if ($tokens[$nextToken]['code'] === T_COMMA) { + $stackPtrCount = 0; + if (isset($tokens[$stackPtr]['nested_parenthesis']) === true) { + $stackPtrCount = count($tokens[$stackPtr]['nested_parenthesis']); + } + + if (count($tokens[$nextToken]['nested_parenthesis']) > ($stackPtrCount + 1)) { + // This comma is inside more parenthesis than the ARRAY keyword, + // then there it is actually a comma used to separate arguments + // in a function call. + continue; + } + + if ($keyUsed === true && $lastToken === T_COMMA) { + $error = 'No key specified for array entry; first entry specifies key'; + $phpcsFile->addError($error, $nextToken, 'NoKeySpecified'); + return; + } + + if ($keyUsed === false) { + if ($tokens[($nextToken - 1)]['code'] === T_WHITESPACE) { + $content = $tokens[($nextToken - 2)]['content']; + $spaceLength = strlen($tokens[($nextToken - 1)]['content']); + $error = 'Expected 0 spaces between "%s" and comma; %s found'; + $data = array( + $content, + $spaceLength, + ); + $phpcsFile->addError($error, $nextToken, 'SpaceBeforeComma', $data); + } + + // Find the value, which will be the first token on the line, + // excluding the leading whitespace. + $valueContent = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($nextToken - 1), null, true); + while ($tokens[$valueContent]['line'] === $tokens[$nextToken]['line']) { + if ($valueContent === $arrayStart) { + // Value must have been on the same line as the array + // parenthesis, so we have reached the start of the value. + break; + } + + $valueContent--; + } + + $valueContent = $phpcsFile->findNext(T_WHITESPACE, ($valueContent + 1), $nextToken, true); + $indices[] = array('value' => $valueContent); + $singleUsed = true; + }//end if + + $lastToken = T_COMMA; + continue; + }//end if + + if ($tokens[$nextToken]['code'] === T_DOUBLE_ARROW) { + if ($singleUsed === true) { + $error = 'Key specified for array entry; first entry has no key'; + $phpcsFile->addError($error, $nextToken, 'KeySpecified'); + return; + } + + $currentEntry['arrow'] = $nextToken; + $keyUsed = true; + + // Find the start of index that uses this double arrow. + $indexEnd = $phpcsFile->findPrevious(T_WHITESPACE, ($nextToken - 1), $arrayStart, true); + $indexStart = $phpcsFile->findPrevious(T_WHITESPACE, $indexEnd, $arrayStart); + + if ($indexStart === false) { + $index = $indexEnd; + } else { + $index = ($indexStart + 1); + } + + $currentEntry['index'] = $index; + $currentEntry['index_content'] = $phpcsFile->getTokensAsString($index, ($indexEnd - $index + 1)); + + $indexLength = strlen($currentEntry['index_content']); + if ($maxLength < $indexLength) { + $maxLength = $indexLength; + } + + // Find the value of this index. + $nextContent = $phpcsFile->findNext(array(T_WHITESPACE), ($nextToken + 1), $arrayEnd, true); + $currentEntry['value'] = $nextContent; + $indices[] = $currentEntry; + $lastToken = T_DOUBLE_ARROW; + }//end if + }//end while + + // Check for mutli-line arrays that should be single-line. + $singleValue = false; + + if (empty($indices) === true) { + $singleValue = true; + } else if (count($indices) === 1) { + if ($lastToken === T_COMMA) { + // There may be another array value without a comma. + $exclude = PHP_CodeSniffer_Tokens::$emptyTokens; + $exclude[] = T_COMMA; + $nextContent = $phpcsFile->findNext($exclude, ($indices[0]['value'] + 1), $arrayEnd, true); + if ($nextContent === false) { + $singleValue = true; + } + } + + if ($singleValue === false && isset($indices[0]['arrow']) === false) { + // A single nested array as a value is fine. + if ($tokens[$indices[0]['value']]['code'] !== T_ARRAY) { + $singleValue === true; + } + } + } + + if ($singleValue === true) { + // Array cannot be empty, so this is a multi-line array with + // a single value. It should be defined on single line. + $error = 'Multi-line array contains a single value; use single-line array instead'; + $phpcsFile->addError($error, $stackPtr, 'MultiLineNotAllowed'); + return; + } + + /* + This section checks for arrays that don't specify keys. + + Arrays such as: + array( + 'aaa', + 'bbb', + 'd', + ); + */ + + if ($keyUsed === false && empty($indices) === false) { + $count = count($indices); + $lastIndex = $indices[($count - 1)]['value']; + + $trailingContent = $phpcsFile->findPrevious(T_WHITESPACE, ($arrayEnd - 1), $lastIndex, true); + if ($tokens[$trailingContent]['code'] !== T_COMMA) { + $error = 'Comma required after last value in array declaration'; + $phpcsFile->addError($error, $trailingContent, 'NoCommaAfterLast'); + } + + foreach ($indices as $value) { + if (empty($value['value']) === true) { + // Array was malformed and we couldn't figure out + // the array value correctly, so we have to ignore it. + // Other parts of this sniff will correct the error. + continue; + } + + if ($tokens[($value['value'] - 1)]['code'] === T_WHITESPACE) { + // A whitespace token before this value means that the value + // was indented and not flush with the opening parenthesis. + if ($tokens[$value['value']]['column'] !== ($keywordStart + 1)) { + $error = 'Array value not aligned correctly; expected %s spaces but found %s'; + $data = array( + ($keywordStart + 1), + $tokens[$value['value']]['column'], + ); + $phpcsFile->addError($error, $value['value'], 'ValueNotAligned', $data); + } + } + } + }//end if + + /* + Below the actual indentation of the array is checked. + Errors will be thrown when a key is not aligned, when + a double arrow is not aligned, and when a value is not + aligned correctly. + If an error is found in one of the above areas, then errors + are not reported for the rest of the line to avoid reporting + spaces and columns incorrectly. Often fixing the first + problem will fix the other 2 anyway. + + For example: + + $a = array( + 'index' => '2', + ); + + In this array, the double arrow is indented too far, but this + will also cause an error in the value's alignment. If the arrow were + to be moved back one space however, then both errors would be fixed. + */ + + $numValues = count($indices); + + $indicesStart = ($keywordStart + 1); + $arrowStart = ($indicesStart + $maxLength + 1); + $valueStart = ($arrowStart + 3); + foreach ($indices as $index) { + if (isset($index['index']) === false) { + // Array value only. + if (($tokens[$index['value']]['line'] === $tokens[$stackPtr]['line']) && ($numValues > 1)) { + $error = 'The first value in a multi-value array must be on a new line'; + $phpcsFile->addError($error, $stackPtr, 'FirstValueNoNewline'); + } + + continue; + } + + if (($tokens[$index['index']]['line'] === $tokens[$stackPtr]['line'])) { + $error = 'The first index in a multi-value array must be on a new line'; + $phpcsFile->addError($error, $stackPtr, 'FirstIndexNoNewline'); + continue; + } + + if ($tokens[$index['index']]['column'] !== $indicesStart) { + $error = 'Array key not aligned correctly; expected %s spaces but found %s'; + $data = array( + ($indicesStart - 1), + ($tokens[$index['index']]['column'] - 1), + ); + $phpcsFile->addError($error, $index['index'], 'KeyNotAligned', $data); + continue; + } + + if ($tokens[$index['arrow']]['column'] !== $arrowStart) { + $expected = ($arrowStart - (strlen($index['index_content']) + $tokens[$index['index']]['column'])); + $found = ($tokens[$index['arrow']]['column'] - (strlen($index['index_content']) + $tokens[$index['index']]['column'])); + + $error = 'Array double arrow not aligned correctly; expected %s space(s) but found %s'; + $data = array( + $expected, + $found, + ); + $phpcsFile->addError($error, $index['arrow'], 'DoubleArrowNotAligned', $data); + continue; + } + + if ($tokens[$index['value']]['column'] !== $valueStart) { + $expected = ($valueStart - (strlen($tokens[$index['arrow']]['content']) + $tokens[$index['arrow']]['column'])); + $found = ($tokens[$index['value']]['column'] - (strlen($tokens[$index['arrow']]['content']) + $tokens[$index['arrow']]['column'])); + + $error = 'Array value not aligned correctly; expected %s space(s) but found %s'; + $data = array( + $expected, + $found, + ); + $phpcsFile->addError($error, $index['arrow'], 'ValueNotAligned', $data); + } + + // Check each line ends in a comma. + if ($tokens[$index['value']]['code'] !== T_ARRAY) { + $nextComma = false; + for ($i = ($index['value'] + 1); $i < $arrayEnd; $i++) { + // Skip bracketed statements, like function calls. + if ($tokens[$i]['code'] === T_OPEN_PARENTHESIS) { + $i = $tokens[$i]['parenthesis_closer']; + continue; + } + + if ($tokens[$i]['code'] === T_COMMA) { + $nextComma = $i; + break; + } + } + + if (($nextComma === false) || ($tokens[$nextComma]['line'] !== $tokens[$index['value']]['line'])) { + $error = 'Each line in an array declaration must end in a comma'; + $phpcsFile->addError($error, $index['value'], 'NoComma'); + } + + // Check that there is no space before the comma. + if ($nextComma !== false && $tokens[($nextComma - 1)]['code'] === T_WHITESPACE) { + $content = $tokens[($nextComma - 2)]['content']; + $spaceLength = strlen($tokens[($nextComma - 1)]['content']); + $error = 'Expected 0 spaces between "%s" and comma; %s found'; + $data = array( + $content, + $spaceLength, + ); + $phpcsFile->addError($error, $nextComma, 'SpaceBeforeComma', $data); + } + } + }//end foreach + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CSS/ClassDefinitionClosingBraceSpaceSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CSS/ClassDefinitionClosingBraceSpaceSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CSS/ClassDefinitionClosingBraceSpaceSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CSS/ClassDefinitionClosingBraceSpaceSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,103 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_CSS_ClassDefinitionClosingBraceSpaceSniff. + * + * Ensure there is a single blank line after the closing brace of a class definition. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_CSS_ClassDefinitionClosingBraceSpaceSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * A list of tokenizers this sniff supports. + * + * @var array + */ + public $supportedTokenizers = array('CSS'); + + + /** + * Returns the token types that this sniff is interested in. + * + * @return array(int) + */ + public function register() + { + return array(T_CLOSE_CURLY_BRACKET); + + }//end 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. + * + * @return void + */ + public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + $tokens = $phpcsFile->getTokens(); + + $next = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); + if ($next === false) { + return; + } + + if ($tokens[$next]['code'] !== T_CLOSE_TAG) { + $found = (($tokens[$next]['line'] - $tokens[$stackPtr]['line']) - 1); + if ($found !== 1) { + $error = 'Expected one blank line after closing brace of class definition; %s found'; + $data = array($found); + $phpcsFile->addError($error, $stackPtr, 'SpacingAfterClose', $data); + } + } + + // Ignore nested style definitions from here on. The spacing before the closing brace + // (a single blank line) will be enforced by the above check, which ensures there is a + // blank line after the last nested class. + $found = $phpcsFile->findPrevious( + T_CLOSE_CURLY_BRACKET, + ($stackPtr - 1), + $tokens[$stackPtr]['bracket_opener'] + ); + if ($found !== false) { + return; + } + + $prev = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true); + if ($prev !== false && $tokens[$prev]['line'] !== ($tokens[$stackPtr]['line'] - 1)) { + $num = ($tokens[$stackPtr]['line'] - $tokens[$prev]['line'] - 1); + $error = 'Expected 0 blank lines before closing brace of class definition; %s found'; + $data = array($num); + $phpcsFile->addError($error, $stackPtr, 'SpacingBeforeClose', $data); + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CSS/ClassDefinitionNameSpacingSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CSS/ClassDefinitionNameSpacingSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CSS/ClassDefinitionNameSpacingSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CSS/ClassDefinitionNameSpacingSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,118 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_CSS_ClassDefinitionNameSpacingSniff. + * + * Ensure there are no blank lines between the names of classes/IDs. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_CSS_ClassDefinitionNameSpacingSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * A list of tokenizers this sniff supports. + * + * @var array + */ + public $supportedTokenizers = array('CSS'); + + + /** + * Returns the token types that this sniff is interested in. + * + * @return array(int) + */ + public function register() + { + return array(T_OPEN_CURLY_BRACKET); + + }//end 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. + * + * @return void + */ + public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + $tokens = $phpcsFile->getTokens(); + + // Do not check nested style definitions as, for example, in @media style rules. + $nested = $phpcsFile->findNext(T_OPEN_CURLY_BRACKET, ($stackPtr + 1), $tokens[$stackPtr]['bracket_closer']); + if ($nested !== false) { + return; + } + + // Find the first blank line before this opening brace, unless we get + // to another style definition, comment or the start of the file. + $endTokens = array( + T_OPEN_CURLY_BRACKET, + T_CLOSE_CURLY_BRACKET, + T_COMMENT, + T_DOC_COMMENT, + T_OPEN_TAG, + ); + + $foundContent = false; + $currentLine = $tokens[$stackPtr]['line']; + for ($i = ($stackPtr - 1); $i >= 0; $i--) { + if (in_array($tokens[$i]['code'], $endTokens) === true) { + break; + } + + if ($tokens[$i]['line'] === $currentLine) { + if ($tokens[$i]['code'] !== T_WHITESPACE) { + $foundContent = true; + } + + continue; + } + + // We changed lines. + if ($foundContent === false) { + // Before we throw an error, make sure we are not looking + // at a gap before the style definition. + $prev = $phpcsFile->findPrevious(T_WHITESPACE, $i, null, true); + if ($prev !== false + && in_array($tokens[$prev]['code'], $endTokens) === false + ) { + $error = 'Blank lines are not allowed between class names'; + $phpcsFile->addError($error, ($i + 1), 'BlankLinesFound'); + } + break; + } + + $foundContent = false; + $currentLine = $tokens[$i]['line']; + }//end for + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CSS/ClassDefinitionOpeningBraceSpaceSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CSS/ClassDefinitionOpeningBraceSpaceSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CSS/ClassDefinitionOpeningBraceSpaceSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CSS/ClassDefinitionOpeningBraceSpaceSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,118 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_CSS_ClassDefinitionOpeningBraceSpaceSniff. + * + * Ensure there is a single space before the opening brace in a class definition + * and the content starts on the next line. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_CSS_ClassDefinitionOpeningBraceSpaceSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * A list of tokenizers this sniff supports. + * + * @var array + */ + public $supportedTokenizers = array('CSS'); + + + /** + * Returns the token types that this sniff is interested in. + * + * @return array(int) + */ + public function register() + { + return array(T_OPEN_CURLY_BRACKET); + + }//end 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. + * + * @return void + */ + public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + $tokens = $phpcsFile->getTokens(); + + if ($tokens[($stackPtr - 1)]['code'] !== T_WHITESPACE) { + $error = 'Expected 1 space before opening brace of class definition; 0 found'; + $phpcsFile->addError($error, $stackPtr, 'NoneBefore'); + } else { + $content = $tokens[($stackPtr - 1)]['content']; + if ($content !== ' ') { + $length = strlen($content); + if ($length === 1) { + $length = 'tab'; + } + + $error = 'Expected 1 space before opening brace of class definition; %s found'; + $data = array($length); + $phpcsFile->addError($error, $stackPtr, 'Before', $data); + } + }//end if + + $next = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr + 1), null, true); + if ($next === false) { + return; + } + + // Check for nested class definitions. + $nested = false; + $found = $phpcsFile->findNext( + T_OPEN_CURLY_BRACKET, + ($stackPtr + 1), + $tokens[$stackPtr]['bracket_closer'] + ); + if ($found !== false) { + $nested = true; + } + + $foundLines = ($tokens[$next]['line'] - $tokens[$stackPtr]['line'] - 1); + if ($nested === true) { + if ($foundLines !== 1) { + $error = 'Expected 1 blank line after opening brace of nesting class definition; %s found'; + $data = array($foundLines); + $phpcsFile->addError($error, $stackPtr, 'AfterNesting', $data); + } + } else { + if ($foundLines !== 0) { + $error = 'Expected 0 blank lines after opening brace of class definition; %s found'; + $data = array($foundLines); + $phpcsFile->addError($error, $stackPtr, 'After', $data); + } + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CSS/ColonSpacingSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CSS/ColonSpacingSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CSS/ColonSpacingSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CSS/ColonSpacingSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,96 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_CSS_ColonSpacingSniff. + * + * Ensure there is no space before a colon and one space after it. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_CSS_ColonSpacingSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * A list of tokenizers this sniff supports. + * + * @var array + */ + public $supportedTokenizers = array('CSS'); + + + /** + * Returns the token types that this sniff is interested in. + * + * @return array(int) + */ + public function register() + { + return array(T_COLON); + + }//end 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. + * + * @return void + */ + public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + $tokens = $phpcsFile->getTokens(); + + $prev = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true); + if ($tokens[$prev]['code'] !== T_STYLE) { + // The colon is not part of a style definition. + return; + } + + if ($tokens[($stackPtr - 1)]['code'] === T_WHITESPACE) { + $error = 'There must be no space before a colon in a style definition'; + $phpcsFile->addError($error, $stackPtr, 'Before'); + } + + if ($tokens[($stackPtr + 1)]['code'] !== T_WHITESPACE) { + $error = 'Expected 1 space after colon in style definition; 0 found'; + $phpcsFile->addError($error, $stackPtr, 'NoneAfter'); + } else { + $content = $tokens[($stackPtr + 1)]['content']; + if (strpos($content, $phpcsFile->eolChar) === false) { + $length = strlen($content); + if ($length !== 1) { + $error = 'Expected 1 space after colon in style definition; %s found'; + $data = array($length); + $phpcsFile->addError($error, $stackPtr, 'After', $data); + } + } else { + $error = 'Expected 1 space after colon in style definition; newline found'; + $phpcsFile->addError($error, $stackPtr, 'AfterNewline'); + } + }//end if + + }//end process() + +}//end class +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CSS/ColourDefinitionSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CSS/ColourDefinitionSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CSS/ColourDefinitionSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CSS/ColourDefinitionSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,93 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_CSS_ColourDefinitionSniff. + * + * Ensure colours are defined in upper-case and use shortcuts where possible. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_CSS_ColourDefinitionSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * A list of tokenizers this sniff supports. + * + * @var array + */ + public $supportedTokenizers = array('CSS'); + + + /** + * Returns the token types that this sniff is interested in. + * + * @return array(int) + */ + public function register() + { + return array(T_COLOUR); + + }//end 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. + * + * @return void + */ + public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + $tokens = $phpcsFile->getTokens(); + $colour = $tokens[$stackPtr]['content']; + + $expected = strtoupper($colour); + if ($colour !== $expected) { + $error = 'CSS colours must be defined in uppercase; expected %s but found %s'; + $data = array( + $expected, + $colour, + ); + $phpcsFile->addError($error, $stackPtr, 'NotUpper', $data); + } + + // Now check if shorthand can be used. + if (strlen($colour) !== 7) { + return; + } + + if ($colour{1} === $colour{2} && $colour{3} === $colour{4} && $colour{5} === $colour{6}) { + $expected = '#'.$colour{1}.$colour{3}.$colour{5}; + $error = 'CSS colours must use shorthand if available; expected %s but found %s'; + $data = array( + $expected, + $colour, + ); + $phpcsFile->addError($error, $stackPtr, 'Shorthand', $data); + } + + }//end process() + +}//end class +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CSS/DisallowMultipleStyleDefinitionsSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CSS/DisallowMultipleStyleDefinitionsSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CSS/DisallowMultipleStyleDefinitionsSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CSS/DisallowMultipleStyleDefinitionsSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,76 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_CSS_DisallowMultipleStyleDefinitionsSniff. + * + * Ensure that each style definition is on a line by itself. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_CSS_DisallowMultipleStyleDefinitionsSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * A list of tokenizers this sniff supports. + * + * @var array + */ + public $supportedTokenizers = array('CSS'); + + + /** + * Returns the token types that this sniff is interested in. + * + * @return array(int) + */ + public function register() + { + return array(T_STYLE); + + }//end 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. + * + * @return void + */ + public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + $tokens = $phpcsFile->getTokens(); + $next = $phpcsFile->findNext(T_STYLE, ($stackPtr + 1)); + if ($next === false) { + return; + } + + if ($tokens[$next]['line'] === $tokens[$stackPtr]['line']) { + $error = 'Each style definition must be on a line by itself'; + $phpcsFile->addError($error, $next, 'Found'); + } + + }//end process() + +}//end class +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CSS/DuplicateClassDefinitionSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CSS/DuplicateClassDefinitionSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CSS/DuplicateClassDefinitionSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CSS/DuplicateClassDefinitionSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,113 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_CSS_DuplicateClassDefinitionSniff. + * + * Check for duplicate class definitions that can be merged into one. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_CSS_DuplicateClassDefinitionSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * A list of tokenizers this sniff supports. + * + * @var array + */ + public $supportedTokenizers = array('CSS'); + + + /** + * Returns the token types that this sniff is interested in. + * + * @return array(int) + */ + public function register() + { + return array(T_OPEN_TAG); + + }//end 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. + * + * @return void + */ + public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + $tokens = $phpcsFile->getTokens(); + + // Find the content of each class definition name. + $classNames = array(); + $next = $phpcsFile->findNext(T_OPEN_CURLY_BRACKET, ($stackPtr + 1)); + if ($next === false) { + // No class definitions in the file. + return; + } + + $find = array( + T_CLOSE_CURLY_BRACKET, + T_COMMENT, + T_OPEN_TAG, + ); + + while ($next !== false) { + $prev = $phpcsFile->findPrevious($find, ($next - 1)); + + // Create a sorted name for the class so we can compare classes + // even when the individual names are all over the place. + $name = ''; + for ($i = ($prev + 1); $i < $next; $i++) { + $name .= $tokens[$i]['content']; + } + + $name = trim($name); + $name = str_replace("\n", ' ', $name); + $name = preg_replace('|[\s]+|', ' ', $name); + $name = str_replace(', ', ',', $name); + + $names = explode(',', $name); + sort($names); + $name = implode(',', $names); + + if (isset($classNames[$name]) === true) { + $first = $classNames[$name]; + $error = 'Duplicate class definition found; first defined on line %s'; + $data = array($tokens[$first]['line']); + $phpcsFile->addError($error, $next, 'Found', $data); + } else { + $classNames[$name] = $next; + } + + $next = $phpcsFile->findNext(T_OPEN_CURLY_BRACKET, ($next + 1)); + }//end while + + }//end process() + + +}//end class +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CSS/DuplicateStyleDefinitionSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CSS/DuplicateStyleDefinitionSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CSS/DuplicateStyleDefinitionSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CSS/DuplicateStyleDefinitionSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,93 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_CSS_DuplicateStyleDefinitionSniff. + * + * Check for duplicate style definitions in the same class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_CSS_DuplicateStyleDefinitionSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * A list of tokenizers this sniff supports. + * + * @var array + */ + public $supportedTokenizers = array('CSS'); + + + /** + * Returns the token types that this sniff is interested in. + * + * @return array(int) + */ + public function register() + { + return array(T_OPEN_CURLY_BRACKET); + + }//end 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. + * + * @return void + */ + public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + $tokens = $phpcsFile->getTokens(); + + // Find the content of each style definition name. + $end = $tokens[$stackPtr]['bracket_closer']; + $next = $phpcsFile->findNext(T_STYLE, ($stackPtr + 1), $end); + if ($next === false) { + // Class definition is empty. + return; + } + + $styleNames = array(); + + while ($next !== false) { + $name = $tokens[$next]['content']; + if (isset($styleNames[$name]) === true) { + $first = $styleNames[$name]; + $error = 'Duplicate style definition found; first defined on line %s'; + $data = array($tokens[$first]['line']); + $phpcsFile->addError($error, $next, 'Found', $data); + } else { + $styleNames[$name] = $next; + } + + $next = $phpcsFile->findNext(T_STYLE, ($next + 1), $end); + }//end while + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CSS/EmptyClassDefinitionSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CSS/EmptyClassDefinitionSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CSS/EmptyClassDefinitionSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CSS/EmptyClassDefinitionSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,73 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_CSS_EmptyClassDefinitionSniff. + * + * Ensure that class definitions are not empty. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_CSS_EmptyClassDefinitionSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * A list of tokenizers this sniff supports. + * + * @var array + */ + public $supportedTokenizers = array('CSS'); + + + /** + * Returns the token types that this sniff is interested in. + * + * @return array(int) + */ + public function register() + { + return array(T_OPEN_CURLY_BRACKET); + + }//end 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. + * + * @return void + */ + public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + $tokens = $phpcsFile->getTokens(); + $next = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr + 1), null, true); + + if ($next === false || $tokens[$next]['code'] === T_CLOSE_CURLY_BRACKET) { + $error = 'Class definition is empty'; + $phpcsFile->addError($error, $stackPtr, 'Found'); + } + + }//end process() + +}//end class +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CSS/EmptyStyleDefinitionSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CSS/EmptyStyleDefinitionSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CSS/EmptyStyleDefinitionSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CSS/EmptyStyleDefinitionSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,73 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_CSS_EmptyStyleDefinitionSniff. + * + * Ensure that style definitions are not empty. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_CSS_EmptyStyleDefinitionSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * A list of tokenizers this sniff supports. + * + * @var array + */ + public $supportedTokenizers = array('CSS'); + + + /** + * Returns the token types that this sniff is interested in. + * + * @return array(int) + */ + public function register() + { + return array(T_STYLE); + + }//end 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. + * + * @return void + */ + public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + $tokens = $phpcsFile->getTokens(); + $next = $phpcsFile->findNext(array(T_WHITESPACE, T_COLON), ($stackPtr + 1), null, true); + + if ($next === false || $tokens[$next]['code'] === T_SEMICOLON || $tokens[$next]['line'] !== $tokens[$stackPtr]['line']) { + $error = 'Style definition is empty'; + $phpcsFile->addError($error, $stackPtr, 'Found'); + } + + }//end process() + +}//end class +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CSS/IndentationSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CSS/IndentationSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CSS/IndentationSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CSS/IndentationSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,124 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_CSS_IndentationSniff. + * + * Ensures styles are indented 4 spaces. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_CSS_IndentationSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * A list of tokenizers this sniff supports. + * + * @var array + */ + public $supportedTokenizers = array('CSS'); + + + /** + * Returns the token types that this sniff is interested in. + * + * @return array(int) + */ + public function register() + { + return array(T_OPEN_TAG); + + }//end 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. + * + * @return void + */ + public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + $tokens = $phpcsFile->getTokens(); + + $numTokens = (count($tokens) - 2); + $currentLine = 0; + $indentLevel = 0; + $nestingLevel = 0; + for ($i = 1; $i < $numTokens; $i++) { + if ($tokens[$i]['code'] === T_COMMENT) { + // Don't check the indent of comments. + continue; + } + + if ($tokens[$i]['code'] === T_OPEN_CURLY_BRACKET) { + $indentLevel++; + + // Check for nested class definitions. + $found = $phpcsFile->findNext( + T_OPEN_CURLY_BRACKET, + ($i + 1), + $tokens[$i]['bracket_closer'] + ); + if ($found !== false) { + $nestingLevel = $indentLevel; + } + } else if ($tokens[($i + 1)]['code'] === T_CLOSE_CURLY_BRACKET) { + $indentLevel--; + } + + if ($tokens[$i]['line'] === $currentLine) { + continue; + } + + // We started a new line, so check indent. + if ($tokens[$i]['code'] === T_WHITESPACE) { + $content = str_replace($phpcsFile->eolChar, '', $tokens[$i]['content']); + $foundIndent = strlen($content); + } else { + $foundIndent = 0; + } + + $expectedIndent = ($indentLevel * 4); + if ($expectedIndent > 0 && strpos($tokens[$i]['content'], $phpcsFile->eolChar) !== false + ) { + if ($nestingLevel !== $indentLevel) { + $error = 'Blank lines are not allowed in class definitions'; + $phpcsFile->addError($error, $i, 'BlankLine'); + } + } else if ($foundIndent !== $expectedIndent) { + $error = 'Line indented incorrectly; expected %s spaces, found %s'; + $data = array( + $expectedIndent, + $foundIndent, + ); + $phpcsFile->addError($error, $i, 'Incorrect', $data); + } + + $currentLine = $tokens[$i]['line']; + }//end foreach + + }//end process() + +}//end class +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CSS/LowercaseStyleDefinitionSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CSS/LowercaseStyleDefinitionSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CSS/LowercaseStyleDefinitionSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CSS/LowercaseStyleDefinitionSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,83 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_CSS_LowercaseStyleDefinitionSniff. + * + * Ensure that all style definitions are in lowercase. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_CSS_LowercaseStyleDefinitionSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * A list of tokenizers this sniff supports. + * + * @var array + */ + public $supportedTokenizers = array('CSS'); + + + /** + * Returns the token types that this sniff is interested in. + * + * @return array(int) + */ + public function register() + { + return array(T_OPEN_CURLY_BRACKET); + + }//end 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. + * + * @return void + */ + public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + $tokens = $phpcsFile->getTokens(); + $start = ($stackPtr + 1); + $end = ($tokens[$stackPtr]['bracket_closer'] - 1); + + for ($i = $start; $i <= $end; $i++) { + if ($tokens[$i]['code'] === T_STRING || $tokens[$i]['code'] === T_STYLE) { + $expected = strtolower($tokens[$i]['content']); + if ($expected !== $tokens[$i]['content']) { + $error = 'Style definitions must be lowercase; expected %s but found %s'; + $data = array( + $expected, + $tokens[$i]['content'], + ); + $phpcsFile->addError($error, $i, 'FoundUpper', $data); + } + } + } + + }//end process() + +}//end class +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CSS/MissingColonSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CSS/MissingColonSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CSS/MissingColonSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CSS/MissingColonSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,101 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_CSS_MissingColonSniff. + * + * Ensure that all style definitions have a colon. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_CSS_MissingColonSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * A list of tokenizers this sniff supports. + * + * @var array + */ + public $supportedTokenizers = array('CSS'); + + + /** + * Returns the token types that this sniff is interested in. + * + * @return array(int) + */ + public function register() + { + return array(T_OPEN_CURLY_BRACKET); + + }//end 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. + * + * @return void + */ + public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + $tokens = $phpcsFile->getTokens(); + $lastLine = $tokens[$stackPtr]['line']; + $end = $tokens[$stackPtr]['bracket_closer']; + $endLine = $tokens[$end]['line']; + + // Do not check nested style definitions as, for example, in @media style rules. + $nested = $phpcsFile->findNext(T_OPEN_CURLY_BRACKET, ($stackPtr + 1), $end); + if ($nested !== false) { + return; + } + + $foundColon = false; + $foundString = false; + for ($i = ($stackPtr + 1); $i <= $end; $i++) { + if ($tokens[$i]['line'] !== $lastLine) { + // We changed lines. + if ($foundColon === false && $foundString !== false) { + // We didn't find a colon on the previous line. + $error = 'No style definition found on line; check for missing colon'; + $phpcsFile->addError($error, $foundString, 'Found'); + } + + $foundColon = false; + $foundString = false; + $lastLine = $tokens[$i]['line']; + } + + if ($tokens[$i]['code'] === T_STRING) { + $foundString = $i; + } else if ($tokens[$i]['code'] === T_COLON) { + $foundColon = $i; + } + }//end for + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CSS/OpacitySniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CSS/OpacitySniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CSS/OpacitySniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CSS/OpacitySniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,107 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_CSS_OpacitySniff. + * + * Ensure that opacity values start with a 0 if it is not a whole number. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_CSS_OpacitySniff implements PHP_CodeSniffer_Sniff +{ + + /** + * A list of tokenizers this sniff supports. + * + * @var array + */ + public $supportedTokenizers = array('CSS'); + + + /** + * Returns the token types that this sniff is interested in. + * + * @return array(int) + */ + public function register() + { + return array(T_STYLE); + + }//end 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. + * + * @return void + */ + public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + $tokens = $phpcsFile->getTokens(); + + if ($tokens[$stackPtr]['content'] !== 'opacity') { + return; + } + + $next = $phpcsFile->findNext(array(T_COLON, T_WHITESPACE), ($stackPtr + 1), null, true); + $numbers = array( + T_DNUMBER, + T_LNUMBER, + ); + + if ($next === false || in_array($tokens[$next]['code'], $numbers) === false) { + return; + } + + $value = $tokens[$next]['content']; + if ($tokens[$next]['code'] === T_LNUMBER) { + if ($value !== '0' && $value !== '1') { + $error = 'Opacity values must be between 0 and 1'; + $phpcsFile->addError($error, $next, 'Invalid'); + } + } else { + if (strlen($value) > 3) { + $error = 'Opacity values must have a single value after the decimal point'; + $phpcsFile->addError($error, $next, 'SpacingAfterPoint'); + } else if ($value === '0.0' || $value === '1.0') { + $error = 'Opacity value does not require decimal point; use %s instead'; + $data = array($value{0}); + $phpcsFile->addError($error, $next, 'PointNotRequired', $data); + } else if ($value{0} === '.') { + $error = 'Opacity values must not start with a decimal point; use 0%s instead'; + $data = array($value); + $phpcsFile->addError($error, $next, 'StartWithPoint', $data); + } else if ($value{0} !== '0') { + $error = 'Opacity values must be between 0 and 1'; + $phpcsFile->addError($error, $next, 'Invalid'); + } + }//end if + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CSS/SemicolonSpacingSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CSS/SemicolonSpacingSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CSS/SemicolonSpacingSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CSS/SemicolonSpacingSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,81 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_CSS_SemicolonSpacingSniff. + * + * Ensure each style definition has a semi-colon and it is spaced correctly. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_CSS_SemicolonSpacingSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * A list of tokenizers this sniff supports. + * + * @var array + */ + public $supportedTokenizers = array('CSS'); + + + /** + * Returns the token types that this sniff is interested in. + * + * @return array(int) + */ + public function register() + { + return array(T_STYLE); + + }//end 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. + * + * @return void + */ + public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + $tokens = $phpcsFile->getTokens(); + + $semicolon = $phpcsFile->findNext(T_SEMICOLON, ($stackPtr + 1)); + if ($semicolon === false || $tokens[$semicolon]['line'] !== $tokens[$stackPtr]['line']) { + $error = 'Style definitions must end with a semicolon'; + $phpcsFile->addError($error, $stackPtr, 'NotAtEnd'); + return; + } + + if ($tokens[($semicolon - 1)]['code'] === T_WHITESPACE) { + $length = strlen($tokens[($semicolon - 1)]['content']); + $error = 'Expected 0 spaces before semicolon in style definition; %s found'; + $data = array($length); + $phpcsFile->addError($error, $stackPtr, 'SpaceFound', $data); + } + + }//end process() + +}//end class +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Classes/ClassDeclarationSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Classes/ClassDeclarationSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Classes/ClassDeclarationSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Classes/ClassDeclarationSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,177 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +if (class_exists('PSR2_Sniffs_Classes_ClassDeclarationSniff', true) === false) { + $error = 'Class PSR2_Sniffs_Classes_ClassDeclarationSniff not found'; + throw new PHP_CodeSniffer_Exception($error); +} + +/** + * Class Declaration Test. + * + * Checks the declaration of the class and its inheritance is correct. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_Classes_ClassDeclarationSniff extends PSR2_Sniffs_Classes_ClassDeclarationSniff +{ + + + /** + * 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) + { + // We want all the errors from the PSR2 standard, plus some of our own. + parent::process($phpcsFile, $stackPtr); + + $tokens = $phpcsFile->getTokens(); + + // Check that this is the only class or interface in the file. + $nextClass = $phpcsFile->findNext(array(T_CLASS, T_INTERFACE), ($stackPtr + 1)); + if ($nextClass !== false) { + // We have another, so an error is thrown. + $error = 'Only one interface or class is allowed in a file'; + $phpcsFile->addError($error, $nextClass, 'MultipleClasses'); + } + + }//end process() + + + /** + * Processes the opening section of a class declaration. + * + * @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 processOpen(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + parent::processOpen($phpcsFile, $stackPtr); + + $tokens = $phpcsFile->getTokens(); + + if ($tokens[($stackPtr - 1)]['code'] === T_WHITESPACE) { + $prevContent = $tokens[($stackPtr - 1)]['content']; + if ($prevContent !== $phpcsFile->eolChar) { + $blankSpace = substr($prevContent, strpos($prevContent, $phpcsFile->eolChar)); + $spaces = strlen($blankSpace); + + if (in_array($tokens[($stackPtr - 2)]['code'], array(T_ABSTRACT, T_FINAL)) === false) { + if ($spaces !== 0) { + $type = strtolower($tokens[$stackPtr]['content']); + $error = 'Expected 0 spaces before %s keyword; %s found'; + $data = array( + $type, + $spaces, + ); + $phpcsFile->addError($error, $stackPtr, 'SpaceBeforeKeyword', $data); + } + } + } + }//end if + + }//end processOpen() + + + /** + * Processes the closing section of a class declaration. + * + * @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 processClose(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + $tokens = $phpcsFile->getTokens(); + + $closeBrace = $tokens[$stackPtr]['scope_closer']; + if ($tokens[($closeBrace - 1)]['code'] === T_WHITESPACE) { + $prevContent = $tokens[($closeBrace - 1)]['content']; + if ($prevContent !== $phpcsFile->eolChar) { + $blankSpace = substr($prevContent, strpos($prevContent, $phpcsFile->eolChar)); + $spaces = strlen($blankSpace); + if ($spaces !== 0) { + if ($tokens[($closeBrace - 1)]['line'] !== $tokens[$closeBrace]['line']) { + $error = 'Expected 0 spaces before closing brace; newline found'; + $phpcsFile->addError($error, $closeBrace, 'NewLineBeforeCloseBrace'); + } else { + $error = 'Expected 0 spaces before closing brace; %s found'; + $data = array($spaces); + $phpcsFile->addError($error, $closeBrace, 'SpaceBeforeCloseBrace', $data); + } + } + } + } + + // Check that the closing brace has one blank line after it. + $nextContent = $phpcsFile->findNext(array(T_WHITESPACE, T_COMMENT), ($closeBrace + 1), null, true); + if ($nextContent === false) { + // No content found, so we reached the end of the file. + // That means there was no closing tag either. + $error = 'Closing brace of a %s must be followed by a blank line and then a closing PHP tag'; + $data = array($tokens[$stackPtr]['content']); + $phpcsFile->addError($error, $closeBrace, 'EndFileAfterCloseBrace', $data); + } else { + $nextLine = $tokens[$nextContent]['line']; + $braceLine = $tokens[$closeBrace]['line']; + if ($braceLine === $nextLine) { + $error = 'Closing brace of a %s must be followed by a single blank line'; + $data = array($tokens[$stackPtr]['content']); + $phpcsFile->addError($error, $closeBrace, 'NoNewlineAfterCloseBrace', $data); + } else if ($nextLine !== ($braceLine + 2)) { + $difference = ($nextLine - $braceLine - 1); + $error = 'Closing brace of a %s must be followed by a single blank line; found %s'; + $data = array( + $tokens[$stackPtr]['content'], + $difference, + ); + $phpcsFile->addError($error, $closeBrace, 'NewlinesAfterCloseBrace', $data); + } + }//end if + + // Check the closing brace is on it's own line, but allow + // for comments like "//end class". + $nextContent = $phpcsFile->findNext(T_COMMENT, ($closeBrace + 1), null, true); + if ($tokens[$nextContent]['content'] !== $phpcsFile->eolChar && $tokens[$nextContent]['line'] === $tokens[$closeBrace]['line']) { + $type = strtolower($tokens[$stackPtr]['content']); + $error = 'Closing %s brace must be on a line by itself'; + $data = array($tokens[$stackPtr]['content']); + $phpcsFile->addError($error, $closeBrace, 'CloseBraceSameLine', $data); + } + + }//end processClose() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Classes/ClassFileNameSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Classes/ClassFileNameSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Classes/ClassFileNameSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Classes/ClassFileNameSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,81 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_Classes_ClassFileNameSniff. + * + * Tests that the file name and the name of the class contained within the file + * match. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_Classes_ClassFileNameSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * 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) + { + $tokens = $phpcsFile->getTokens(); + $decName = $phpcsFile->findNext(T_STRING, $stackPtr); + $fullPath = basename($phpcsFile->getFilename()); + $fileName = substr($fullPath, 0, strrpos($fullPath, '.')); + + if ($tokens[$decName]['content'] !== $fileName) { + $error = '%s name doesn\'t match filename; expected "%s %s"'; + $data = array( + ucfirst($tokens[$stackPtr]['content']), + $tokens[$stackPtr]['content'], + $fileName, + ); + $phpcsFile->addError($error, $stackPtr, 'NoMatch', $data); + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Classes/DuplicatePropertySniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Classes/DuplicatePropertySniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Classes/DuplicatePropertySniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Classes/DuplicatePropertySniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,100 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_Classes_DuplicatePropertySniff. + * + * Ensures JS classes don't contain duplicate property names. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_Classes_DuplicatePropertySniff implements PHP_CodeSniffer_Sniff +{ + + /** + * A list of tokenizers this sniff supports. + * + * @var array + */ + public $supportedTokenizers = array('JS'); + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array(T_OBJECT); + + }//end register() + + + /** + * Processes this test, when one of its tokens is encountered. + * + * @param PHP_CodeSniffer_File $phpcsFile The current file being processed. + * @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(); + $start = $tokens[$stackPtr]['scope_opener']; + $end = $tokens[$stackPtr]['scope_closer']; + + $properties = array(); + $wantedTokens = array( + T_PROPERTY, + T_OPEN_CURLY_BRACKET, + ); + + $next = $phpcsFile->findNext($wantedTokens, ($start + 1), $end); + while ($next !== false && $next < $end) { + // Skip nested objects. + if ($tokens[$next]['code'] === T_OPEN_CURLY_BRACKET) { + $next = $tokens[$next]['bracket_closer']; + } else { + $propName = $tokens[$next]['content']; + if (isset($properties[$propName]) === true) { + $error = 'Duplicate property definition found for "%s"; previously defined on line %s'; + $data = array( + $propName, + $tokens[$properties[$propName]]['line'], + ); + $phpcsFile->addError($error, $next, 'Found', $data); + } + + $properties[$propName] = $next; + }//end if + + $next = $phpcsFile->findNext($wantedTokens, ($next + 1), $end); + }//end while + + }//end process() + + +}//end class + + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Classes/LowercaseClassKeywordsSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Classes/LowercaseClassKeywordsSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Classes/LowercaseClassKeywordsSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Classes/LowercaseClassKeywordsSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,85 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_Classes_LowercaseClassKeywordsSniff. + * + * Ensures all class keywords are lowercase. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_Classes_LowercaseClassKeywordsSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array( + T_CLASS, + T_INTERFACE, + T_TRAIT, + T_EXTENDS, + T_IMPLEMENTS, + T_ABSTRACT, + T_FINAL, + T_VAR, + T_CONST, + ); + + }//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(); + + $content = $tokens[$stackPtr]['content']; + if ($content !== strtolower($content)) { + $error = '%s keyword must be lowercase; expected "%s" but found "%s"'; + $data = array( + strtoupper($content), + strtolower($content), + $content, + ); + $phpcsFile->addError($error, $stackPtr, 'FoundUppercase', $data); + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Classes/SelfMemberReferenceSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Classes/SelfMemberReferenceSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Classes/SelfMemberReferenceSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Classes/SelfMemberReferenceSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,171 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +if (class_exists('PHP_CodeSniffer_Standards_AbstractScopeSniff', true) === false) { + $error = 'Class PHP_CodeSniffer_Standards_AbstractScopeSniff not found'; + throw new PHP_CodeSniffer_Exception($error); +} + +/** + * Tests self member references. + * + * Verifies that : + *
    + *
  • self:: is used instead of Self::
  • + *
  • self:: is used for local static member reference
  • + *
  • self:: is used instead of self ::
  • + *
+ * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_Classes_SelfMemberReferenceSniff extends PHP_CodeSniffer_Standards_AbstractScopeSniff +{ + + + /** + * Constructs a Squiz_Sniffs_Classes_SelfMemberReferenceSniff. + */ + public function __construct() + { + parent::__construct(array(T_CLASS), array(T_DOUBLE_COLON)); + + }//end __construct() + + + /** + * Processes the function tokens within the class. + * + * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found. + * @param int $stackPtr The position where the token was found. + * @param int $currScope The current scope opener token. + * + * @return void + */ + protected function processTokenWithinScope(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $currScope) + { + $tokens = $phpcsFile->getTokens(); + + $className = ($stackPtr - 1); + if ($tokens[$className]['code'] === T_SELF) { + if (strtolower($tokens[$className]['content']) !== $tokens[$className]['content']) { + $error = 'Must use "self::" for local static member reference; found "%s::"'; + $data = array($tokens[$className]['content']); + $phpcsFile->addError($error, $className, 'IncorrectCase', $data); + return; + } + } else if ($tokens[$className]['code'] === T_STRING) { + // Make sure this is another class reference. + $declarationName = $phpcsFile->getDeclarationName($currScope); + $fullQualifiedClassName = $tokens[$className]['content']; + + // If the class is called with a namespace prefix, build fully qualified + // namespace calls for both current scope class and requested class. + if ($tokens[($className - 1)]['code'] === T_NS_SEPARATOR) { + $declarationName = $this->getDeclarationNameWithNamespace($tokens, $className); + $declarationName = substr($declarationName, 1); + $fullQualifiedClassName = $this->getNamespaceOfScope($phpcsFile, $currScope); + $fullQualifiedClassName .= '\\'.$tokens[$className]['content']; + } + + if ($declarationName === $fullQualifiedClassName) { + // Class name is the same as the current class, which is not allowed + // except if being used inside a closure. + if ($phpcsFile->hasCondition($stackPtr, T_CLOSURE) === false) { + $error = 'Must use "self::" for local static member reference'; + $phpcsFile->addError($error, $className, 'NotUsed'); + return; + } + } + }//end if + + if ($tokens[($stackPtr - 1)]['code'] === T_WHITESPACE) { + $found = strlen($tokens[($stackPtr - 1)]['content']); + $error = 'Expected 0 spaces before double colon; %s found'; + $data = array($found); + $phpcsFile->addError($error, $className, 'SpaceBefore', $data); + } + + if ($tokens[($stackPtr + 1)]['code'] === T_WHITESPACE) { + $found = strlen($tokens[($stackPtr + 1)]['content']); + $error = 'Expected 0 spaces after double colon; %s found'; + $data = array($found); + $phpcsFile->addError($error, $className, 'SpaceAfter', $data); + } + + }//end processTokenWithinScope() + + + /** + * Returns the declaration names for classes/interfaces/functions with a namespace. + * + * @param array $tokens Token stack for this file + * @param int $stackPtr The position where the namespace building will start. + * + * @return string + */ + protected function getDeclarationNameWithNamespace(array $tokens, $stackPtr) + { + $nameParts = array(); + $currentPointer = $stackPtr; + while ($tokens[$currentPointer]['code'] === T_NS_SEPARATOR + || $tokens[$currentPointer]['code'] === T_STRING + ) { + $nameParts[] = $tokens[$currentPointer]['content']; + $currentPointer--; + } + + $nameParts = array_reverse($nameParts); + return implode('', $nameParts); + + }//end getDeclarationNameWithNamespace() + + + /** + * Returns the namespace declaration of a file. + * + * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found. + * @param int $stackPtr The position where the search for the + * namespace declaration will start. + * + * @return string + */ + protected function getNamespaceOfScope(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + $namespace = '\\'; + $namespaceDeclaration = $phpcsFile->findPrevious(T_NAMESPACE, $stackPtr); + + if ($namespaceDeclaration !== false) { + $endOfNamespaceDeclaration = $phpcsFile->findNext(T_SEMICOLON, $namespaceDeclaration); + $namespace = $this->getDeclarationNameWithNamespace( + $phpcsFile->getTokens(), + ($endOfNamespaceDeclaration - 1) + ); + } + + return $namespace; + + }//end getNamespaceOfScope + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Classes/ValidClassNameSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Classes/ValidClassNameSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Classes/ValidClassNameSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Classes/ValidClassNameSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,95 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_Classes_ValidClassNameSniff. + * + * Ensures classes are in camel caps, and the first letter is capitalised + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_Classes_ValidClassNameSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * 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 current file being processed. + * @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(); + + if (isset($tokens[$stackPtr]['scope_opener']) === false) { + $error = 'Possible parse error: %s missing opening or closing brace'; + $data = array($tokens[$stackPtr]['content']); + $phpcsFile->addWarning($error, $stackPtr, 'MissingBrace', $data); + return; + } + + // Determine the name of the class or interface. Note that we cannot + // simply look for the first T_STRING because a class name + // starting with the number will be multiple tokens. + $opener = $tokens[$stackPtr]['scope_opener']; + $nameStart = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), $opener, true); + $nameEnd = $phpcsFile->findNext(T_WHITESPACE, $nameStart, $opener); + $name = trim($phpcsFile->getTokensAsString($nameStart, ($nameEnd - $nameStart))); + + // Check for camel caps format. + $valid = PHP_CodeSniffer::isCamelCaps($name, true, true, false); + if ($valid === false) { + $type = ucfirst($tokens[$stackPtr]['content']); + $error = '%s name "%s" is not in camel caps format'; + $data = array( + $type, + $name, + ); + $phpcsFile->addError($error, $stackPtr, 'NotCamelCaps', $data); + } + + }//end process() + + +}//end class + + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CodeAnalysis/EmptyStatementSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CodeAnalysis/EmptyStatementSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CodeAnalysis/EmptyStatementSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/CodeAnalysis/EmptyStatementSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,54 @@ + + * @copyright 2006-2012 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 + */ + +if (class_exists('Generic_Sniffs_CodeAnalysis_EmptyStatementSniff', true) === false) { + throw new PHP_CodeSniffer_Exception('Class Generic_Sniffs_CodeAnalysis_EmptyStatementSniff not found'); +} + +/** + * This sniff class detects empty statement. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_CodeAnalysis_EmptyStatementSniff extends Generic_Sniffs_CodeAnalysis_EmptyStatementSniff +{ + + /** + * List of block tokens that this sniff covers. + * + * The key of this hash identifies the required token while the boolean + * value says mark an error or mark a warning. + * + * @var array + */ + protected $checkedTokens = array( + T_DO => true, + T_ELSE => true, + T_ELSEIF => true, + T_FOR => true, + T_FOREACH => true, + T_IF => true, + T_SWITCH => true, + T_WHILE => true, + ); + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Commenting/BlockCommentSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Commenting/BlockCommentSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Commenting/BlockCommentSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Commenting/BlockCommentSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,246 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_Commenting_BlockCommentSniff. + * + * Verifies that block comments are used appropriately. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_Commenting_BlockCommentSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array( + T_COMMENT, + T_DOC_COMMENT, + ); + + }//end register() + + + /** + * Processes this test, when one of its tokens is encountered. + * + * @param PHP_CodeSniffer_File $phpcsFile The current 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(); + + // If its an inline comment return. + if (substr($tokens[$stackPtr]['content'], 0, 2) !== '/*') { + return; + } + + // If this is a function/class/interface doc block comment, skip it. + // We are only interested in inline doc block comments. + if ($tokens[$stackPtr]['code'] === T_DOC_COMMENT) { + $nextToken = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr + 1), null, true); + $ignore = array( + T_CLASS, + T_INTERFACE, + T_TRAIT, + T_FUNCTION, + T_PUBLIC, + T_PRIVATE, + T_FINAL, + T_PROTECTED, + T_STATIC, + T_ABSTRACT, + T_CONST, + ); + if (in_array($tokens[$nextToken]['code'], $ignore) === true) { + return; + } + + $prevToken = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true); + if ($tokens[$prevToken]['code'] === T_OPEN_TAG) { + return; + } + }//end if + + $commentLines = array($stackPtr); + $nextComment = $stackPtr; + $lastLine = $tokens[$stackPtr]['line']; + + // Construct the comment into an array. + while (($nextComment = $phpcsFile->findNext($tokens[$stackPtr]['code'], ($nextComment + 1), null, false)) !== false) { + if (($tokens[$nextComment]['line'] - 1) !== $lastLine) { + // Not part of the block. + break; + } + + $lastLine = $tokens[$nextComment]['line']; + $commentLines[] = $nextComment; + } + + if (count($commentLines) <= 2) { + // Small comment. Can't be right. + if (count($commentLines) === 1) { + $error = 'Single line block comment not allowed; use inline ("// text") comment instead'; + $phpcsFile->addError($error, $stackPtr, 'SingleLine'); + return; + } + + if (trim($tokens[$commentLines[1]]['content']) === '*/') { + if (trim($tokens[$stackPtr]['content']) === '/*') { + $error = 'Empty block comment not allowed'; + $phpcsFile->addError($error, $stackPtr, 'Empty'); + return; + } + } + } + + $content = trim($tokens[$stackPtr]['content']); + if ($content !== '/*' && $content !== '/**') { + $error = 'Block comment text must start on a new line'; + $phpcsFile->addError($error, $stackPtr, 'NoNewLine'); + return; + } + + $starColumn = ($tokens[$stackPtr]['column'] + 3); + + // Make sure first line isn't blank. + if (trim($tokens[$commentLines[1]]['content']) === '') { + $error = 'Empty line not allowed at start of comment'; + $phpcsFile->addError($error, $commentLines[1], 'HasEmptyLine'); + } else { + // Check indentation of first line. + $content = $tokens[$commentLines[1]]['content']; + $commentText = ltrim($content); + $leadingSpace = (strlen($content) - strlen($commentText)); + if ($leadingSpace !== $starColumn) { + $expected = $starColumn; + $expected .= ($starColumn === 1) ? ' space' : ' spaces'; + $data = array( + $expected, + $leadingSpace, + ); + + $error = 'First line of comment not aligned correctly; expected %s but found %s'; + $phpcsFile->addError($error, $commentLines[1], 'FirstLineIndent', $data); + } + + if (preg_match('|\p{Lu}|u', $commentText[0]) === 0) { + $error = 'Block comments must start with a capital letter'; + $phpcsFile->addError($error, $commentLines[1], 'NoCapital'); + } + } + + // Check that each line of the comment is indented past the star. + foreach ($commentLines as $line) { + $leadingSpace = (strlen($tokens[$line]['content']) - strlen(ltrim($tokens[$line]['content']))); + // First and last lines (comment opener and closer) are handled separately. + if ($line === $commentLines[(count($commentLines) - 1)] || $line === $commentLines[0]) { + continue; + } + + // First comment line was handled above. + if ($line === $commentLines[1]) { + continue; + } + + // If it's empty, continue. + if (trim($tokens[$line]['content']) === '') { + continue; + } + + if ($leadingSpace < $starColumn) { + $expected = $starColumn; + $expected .= ($starColumn === 1) ? ' space' : ' spaces'; + $data = array( + $expected, + $leadingSpace, + ); + + $error = 'Comment line indented incorrectly; expected at least %s but found %s'; + $phpcsFile->addError($error, $line, 'LineIndent', $data); + } + }//end foreach + + // Finally, test the last line is correct. + $lastIndex = (count($commentLines) - 1); + $content = trim($tokens[$commentLines[$lastIndex]]['content']); + if ($content !== '*/' && $content !== '**/') { + $error = 'Comment closer must be on a new line'; + $phpcsFile->addError($error, $commentLines[$lastIndex]); + } else { + $content = $tokens[$commentLines[$lastIndex]]['content']; + $commentText = ltrim($content); + $leadingSpace = (strlen($content) - strlen($commentText)); + if ($leadingSpace !== ($tokens[$stackPtr]['column'] - 1)) { + $expected = ($tokens[$stackPtr]['column'] - 1); + $expected .= ($expected === 1) ? ' space' : ' spaces'; + $data = array( + $expected, + $leadingSpace, + ); + + $error = 'Last line of comment aligned incorrectly; expected %s but found %s'; + $phpcsFile->addError($error, $commentLines[$lastIndex], 'LastLineIndent', $data); + } + + } + + // Check that the lines before and after this comment are blank. + $contentBefore = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); + if (isset($tokens[$contentBefore]['scope_closer']) === true + && $tokens[$contentBefore]['scope_opener'] === $contentBefore + ) { + if (($tokens[$stackPtr]['line'] - $tokens[$contentBefore]['line']) !== 1) { + $error = 'Empty line not required before block comment'; + $phpcsFile->addError($error, $stackPtr, 'HasEmptyLineBefore'); + } + } else { + if (($tokens[$stackPtr]['line'] - $tokens[$contentBefore]['line']) < 2) { + $error = 'Empty line required before block comment'; + $phpcsFile->addError($error, $stackPtr, 'NoEmptyLineBefore'); + } + } + + $commentCloser = $commentLines[$lastIndex]; + $contentAfter = $phpcsFile->findNext(T_WHITESPACE, ($commentCloser + 1), null, true); + if (($tokens[$contentAfter]['line'] - $tokens[$commentCloser]['line']) < 2) { + $error = 'Empty line required after block comment'; + $phpcsFile->addError($error, $commentCloser, 'NoEmptyLineAfter'); + } + + }//end process() + + +}//end class + + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Commenting/ClassCommentSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Commenting/ClassCommentSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Commenting/ClassCommentSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Commenting/ClassCommentSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,254 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +if (class_exists('PHP_CodeSniffer_CommentParser_ClassCommentParser', true) === false) { + throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_CommentParser_ClassCommentParser not found'); +} + +/** + * Parses and verifies the class doc comment. + * + * Verifies that : + *
    + *
  • A class doc comment exists.
  • + *
  • There is exactly one blank line before the class comment.
  • + *
  • Short description ends with a full stop.
  • + *
  • There is a blank line after the short description.
  • + *
  • Each paragraph of the long description ends with a full stop.
  • + *
  • There is a blank line between the description and the tags.
  • + *
  • Check the format of the since tag (x.x.x).
  • + *
+ * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_Commenting_ClassCommentSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array(T_CLASS); + + }//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(); + $find = array ( + T_ABSTRACT, + T_WHITESPACE, + T_FINAL, + ); + + // Extract the class comment docblock. + $commentEnd = $phpcsFile->findPrevious($find, ($stackPtr - 1), null, true); + + if ($commentEnd !== false && $tokens[$commentEnd]['code'] === T_COMMENT) { + $phpcsFile->addError('You must use "/**" style comments for a class comment', $stackPtr, 'WrongStyle'); + return; + } else if ($commentEnd === false || $tokens[$commentEnd]['code'] !== T_DOC_COMMENT) { + $phpcsFile->addError('Missing class doc comment', $stackPtr, 'Missing'); + return; + } + + $commentStart = ($phpcsFile->findPrevious(T_DOC_COMMENT, ($commentEnd - 1), null, true) + 1); + $commentNext = $phpcsFile->findPrevious(T_WHITESPACE, ($commentEnd + 1), $stackPtr, false, $phpcsFile->eolChar); + + // Distinguish file and class comment. + $prevClassToken = $phpcsFile->findPrevious(T_CLASS, ($stackPtr - 1)); + if ($prevClassToken === false) { + // This is the first class token in this file, need extra checks. + $prevNonComment = $phpcsFile->findPrevious(T_DOC_COMMENT, ($commentStart - 1), null, true); + if ($prevNonComment !== false) { + $prevComment = $phpcsFile->findPrevious(T_DOC_COMMENT, ($prevNonComment - 1)); + if ($prevComment === false) { + // There is only 1 doc comment between open tag and class token. + $newlineToken = $phpcsFile->findNext(T_WHITESPACE, ($commentEnd + 1), $stackPtr, false, $phpcsFile->eolChar); + if ($newlineToken !== false) { + $newlineToken = $phpcsFile->findNext(T_WHITESPACE, ($newlineToken + 1), $stackPtr, false, $phpcsFile->eolChar); + if ($newlineToken !== false) { + // Blank line between the class and the doc block. + // The doc block is most likely a file comment. + $phpcsFile->addError('Missing class doc comment', ($stackPtr + 1), 'Missing'); + return; + } + }//end if + }//end if + + // Exactly one blank line before the class comment. + $prevTokenEnd = $phpcsFile->findPrevious(T_WHITESPACE, ($commentStart - 1), null, true); + if ($prevTokenEnd !== false) { + $blankLineBefore = 0; + for ($i = ($prevTokenEnd + 1); $i < $commentStart; $i++) { + if ($tokens[$i]['code'] === T_WHITESPACE && $tokens[$i]['content'] === $phpcsFile->eolChar) { + $blankLineBefore++; + } + } + + if ($blankLineBefore !== 2) { + $error = 'There must be exactly one blank line before the class comment'; + $phpcsFile->addError($error, ($commentStart - 1), 'SpacingBefore'); + } + } + + }//end if + }//end if + + $commentString = $phpcsFile->getTokensAsString($commentStart, ($commentEnd - $commentStart + 1)); + + // Parse the class comment docblock. + try { + $this->commentParser = new PHP_CodeSniffer_CommentParser_ClassCommentParser($commentString, $phpcsFile); + $this->commentParser->parse(); + } catch (PHP_CodeSniffer_CommentParser_ParserException $e) { + $line = ($e->getLineWithinComment() + $commentStart); + $phpcsFile->addError($e->getMessage(), $line, 'FailedParse'); + return; + } + + $comment = $this->commentParser->getComment(); + if (is_null($comment) === true) { + $error = 'Class doc comment is empty'; + $phpcsFile->addError($error, $commentStart, 'Empty'); + return; + } + + // The first line of the comment should just be the /** code. + $eolPos = strpos($commentString, $phpcsFile->eolChar); + $firstLine = substr($commentString, 0, $eolPos); + if ($firstLine !== '/**') { + $error = 'The open comment tag must be the only content on the line'; + $phpcsFile->addError($error, $commentStart, 'SpacingAfterOpen'); + } + + // Check for a comment description. + $short = rtrim($comment->getShortComment(), $phpcsFile->eolChar); + if (trim($short) === '') { + $error = 'Missing short description in class doc comment'; + $phpcsFile->addError($error, $commentStart, 'MissingShort'); + return; + } + + // No extra newline before short description. + $newlineCount = 0; + $newlineSpan = strspn($short, $phpcsFile->eolChar); + if ($short !== '' && $newlineSpan > 0) { + $error = 'Extra newline(s) found before class comment short description'; + $phpcsFile->addError($error, ($commentStart + 1), 'SpacingBeforeShort'); + } + + $newlineCount = (substr_count($short, $phpcsFile->eolChar) + 1); + + // Exactly one blank line between short and long description. + $long = $comment->getLongComment(); + if (empty($long) === false) { + $between = $comment->getWhiteSpaceBetween(); + $newlineBetween = substr_count($between, $phpcsFile->eolChar); + if ($newlineBetween !== 2) { + $error = 'There must be exactly one blank line between descriptions in class comment'; + $phpcsFile->addError($error, ($commentStart + $newlineCount + 1), 'SpacingBetween'); + } + + $newlineCount += $newlineBetween; + + $testLong = trim($long); + if (preg_match('|\p{Lu}|u', $testLong[0]) === 0) { + $error = 'Class comment long description must start with a capital letter'; + $phpcsFile->addError($error, ($commentStart + $newlineCount), 'LongNotCapital'); + } + } + + // Exactly one blank line before tags. + $tags = $this->commentParser->getTagOrders(); + if (count($tags) > 1) { + $newlineSpan = $comment->getNewlineAfter(); + if ($newlineSpan !== 2) { + $error = 'There must be exactly one blank line before the tags in class comment'; + if ($long !== '') { + $newlineCount += (substr_count($long, $phpcsFile->eolChar) - $newlineSpan + 1); + } + + $phpcsFile->addError($error, ($commentStart + $newlineCount), 'SpacingBeforeTags'); + $short = rtrim($short, $phpcsFile->eolChar.' '); + } + } + + // Short description must be single line and end with a full stop. + $testShort = trim($short); + $lastChar = $testShort[(strlen($testShort) - 1)]; + if (substr_count($testShort, $phpcsFile->eolChar) !== 0) { + $error = 'Class comment short description must be on a single line'; + $phpcsFile->addError($error, ($commentStart + 1), 'ShortSingleLine'); + } + if (preg_match('|\p{Lu}|u', $testShort[0]) === 0) { + $error = 'Class comment short description must start with a capital letter'; + $phpcsFile->addError($error, ($commentStart + 1), 'ShortNotCapital'); + } + + if ($lastChar !== '.') { + $error = 'Class comment short description must end with a full stop'; + $phpcsFile->addError($error, ($commentStart + 1), 'ShortFullStop'); + } + + // No tags are allowed in the class comment. + $tags = $this->commentParser->getTags(); + foreach ($tags as $errorTag) { + $error = '@%s tag is not allowed in class comment'; + $data = array($errorTag['tag']); + $phpcsFile->addWarning($error, ($commentStart + $errorTag['line']), 'TagNotAllowed', $data); + } + + // The last content should be a newline and the content before + // that should not be blank. If there is more blank space + // then they have additional blank lines at the end of the comment. + $words = $this->commentParser->getWords(); + $lastPos = (count($words) - 1); + if (trim($words[($lastPos - 1)]) !== '' + || strpos($words[($lastPos - 1)], $this->currentFile->eolChar) === false + || trim($words[($lastPos - 2)]) === '' + ) { + $error = 'Additional blank lines found at end of class comment'; + $this->currentFile->addError($error, $commentEnd, 'SpacingAfter'); + } + + }//end process() + + +}//end class +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Commenting/ClosingDeclarationCommentSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Commenting/ClosingDeclarationCommentSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Commenting/ClosingDeclarationCommentSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Commenting/ClosingDeclarationCommentSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,127 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_Commenting_ClosingDeclarationCommentSniff. + * + * Checks the //end ... comments on classes, interfaces and functions. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_Commenting_ClosingDeclarationCommentSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array( + T_FUNCTION, + 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) + { + $tokens = $phpcsFile->getTokens(); + + if ($tokens[$stackPtr]['code'] === T_FUNCTION) { + + $methodProps = $phpcsFile->getMethodProperties($stackPtr); + + // Abstract methods do not require a closing comment. + if ($methodProps['is_abstract'] === true) { + return; + } + + // Closures do not require a closing comment. + if ($methodProps['is_closure'] === true) { + return; + } + + // If this function is in an interface then we don't require + // a closing comment. + if ($phpcsFile->hasCondition($stackPtr, T_INTERFACE) === true) { + return; + } + + if (isset($tokens[$stackPtr]['scope_closer']) === false) { + $error = 'Possible parse error: non-abstract method defined as abstract'; + $phpcsFile->addWarning($error, $stackPtr, 'Abstract'); + return; + } + + $decName = $phpcsFile->getDeclarationName($stackPtr); + $comment = '//end '.$decName.'()'; + } else if ($tokens[$stackPtr]['code'] === T_CLASS) { + $comment = '//end class'; + } else { + $comment = '//end interface'; + }//end if + + if (isset($tokens[$stackPtr]['scope_closer']) === false) { + $error = 'Possible parse error: %s missing opening or closing brace'; + $data = array($tokens[$stackPtr]['content']); + $phpcsFile->addWarning($error, $stackPtr, 'MissingBrace', $data); + return; + } + + $closingBracket = $tokens[$stackPtr]['scope_closer']; + + if ($closingBracket === null) { + // Possible inline structure. Other tests will handle it. + return; + } + + $error = 'Expected '.$comment; + if (isset($tokens[($closingBracket + 1)]) === false || $tokens[($closingBracket + 1)]['code'] !== T_COMMENT) { + $phpcsFile->addError($error, $closingBracket, 'Missing'); + return; + } + + if (rtrim($tokens[($closingBracket + 1)]['content']) !== $comment) { + $phpcsFile->addError($error, $closingBracket, 'Incorrect'); + return; + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Commenting/DocCommentAlignmentSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Commenting/DocCommentAlignmentSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Commenting/DocCommentAlignmentSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Commenting/DocCommentAlignmentSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,151 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_Commenting_DocCommentAlignmentSniff. + * + * Tests that the stars in a doc comment align correctly. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_Commenting_DocCommentAlignmentSniff 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); + + }//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(); + + // We are only interested in function/class/interface doc block comments. + $nextToken = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr + 1), null, true); + $ignore = array( + T_CLASS, + T_INTERFACE, + T_FUNCTION, + T_PUBLIC, + T_PRIVATE, + T_PROTECTED, + T_STATIC, + T_ABSTRACT, + ); + + if (in_array($tokens[$nextToken]['code'], $ignore) === false) { + // Could be a file comment. + $prevToken = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true); + if ($tokens[$prevToken]['code'] !== T_OPEN_TAG) { + return; + } + } + + // We only want to get the first comment in a block. If there is + // a comment on the line before this one, return. + $docComment = $phpcsFile->findPrevious(T_DOC_COMMENT, ($stackPtr - 1)); + if ($docComment !== false) { + if ($tokens[$docComment]['line'] === ($tokens[$stackPtr]['line'] - 1)) { + return; + } + } + + $comments = array($stackPtr); + $currentComment = $stackPtr; + $lastComment = $stackPtr; + while (($currentComment = $phpcsFile->findNext(T_DOC_COMMENT, ($currentComment + 1))) !== false) { + if ($tokens[$lastComment]['line'] === ($tokens[$currentComment]['line'] - 1)) { + $comments[] = $currentComment; + $lastComment = $currentComment; + } else { + break; + } + } + + // The $comments array now contains pointers to each token in the + // comment block. + $requiredColumn = strpos($tokens[$stackPtr]['content'], '*'); + $requiredColumn += $tokens[$stackPtr]['column']; + + foreach ($comments as $commentPointer) { + // Check the spacing after each asterisk. + $content = $tokens[$commentPointer]['content']; + $firstChar = substr($content, 0, 1); + $lastChar = substr($content, -1); + if ($firstChar !== '/' && $lastChar !== '/') { + $matches = array(); + preg_match('|^(\s+)?\*(\s+)?@|', $content, $matches); + if (empty($matches) === false) { + if (isset($matches[2]) === false) { + $error = 'Expected 1 space between asterisk and tag; 0 found'; + $phpcsFile->addError($error, $commentPointer, 'NoSpaceBeforeTag'); + } else { + $length = strlen($matches[2]); + if ($length !== 1) { + $error = 'Expected 1 space between asterisk and tag; %s found'; + $data = array($length); + $phpcsFile->addError($error, $commentPointer, 'SpaceBeforeTag', $data); + } + } + } + }//end foreach + + // Check the alignment of each asterisk. + $currentColumn = strpos($content, '*'); + $currentColumn += $tokens[$commentPointer]['column']; + + if ($currentColumn === $requiredColumn) { + // Star is aligned correctly. + continue; + } + + $error = 'Expected %s space(s) before asterisk; %s found'; + $data = array( + ($requiredColumn - 1), + ($currentColumn - 1), + ); + $phpcsFile->addError($error, $commentPointer, 'SpaceBeforeAsterisk', $data); + }//end foreach + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Commenting/EmptyCatchCommentSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Commenting/EmptyCatchCommentSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Commenting/EmptyCatchCommentSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Commenting/EmptyCatchCommentSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,73 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_Commenting_EmptyCatchCommentSniff. + * + * Checks for empty Catch clause. Catch clause must at least have comment + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_Commenting_EmptyCatchCommentSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array(T_CATCH); + + }//end register() + + + /** + * Processes this test, when one of its tokens is encountered. + * + * @param PHP_CodeSniffer_File $phpcsFile All the tokens found in the document. + * @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(); + + $scopeStart = $tokens[$stackPtr]['scope_opener']; + $firstContent = $phpcsFile->findNext(T_WHITESPACE, ($scopeStart + 1), $tokens[$stackPtr]['scope_closer'], true); + + if ($firstContent === false) { + $error = 'Empty CATCH statement must have a comment to explain why the exception is not handled'; + $phpcsFile->addError($error, $scopeStart, 'Missing'); + } + + }//end process() + + +}//end class + + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Commenting/FileCommentSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Commenting/FileCommentSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Commenting/FileCommentSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Commenting/FileCommentSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,614 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +if (class_exists('PHP_CodeSniffer_CommentParser_ClassCommentParser', true) === false) { + throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_CommentParser_ClassCommentParser not found'); +} + +/** + * Parses and verifies the file doc comment. + * + * Verifies that : + *
    + *
  • A file doc comment exists.
  • + *
  • There is no blank line between the open tag and the file comment.
  • + *
  • Short description ends with a full stop.
  • + *
  • There is a blank line after the short description.
  • + *
  • Each paragraph of the long description ends with a full stop.
  • + *
  • There is a blank line between the description and the tags.
  • + *
  • Check the order, indentation and content of each tag.
  • + *
  • There is exactly one blank line after the file comment.
  • + *
+ * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ + +class Squiz_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * A list of tokenizers this sniff supports. + * + * @var array + */ + public $supportedTokenizers = array( + 'PHP', + 'JS', + ); + + /** + * The header comment parser for the current file. + * + * @var PHP_CodeSniffer_Comment_Parser_ClassCommentParser + */ + protected $commentParser = null; + + /** + * The current PHP_CodeSniffer_File object we are processing. + * + * @var PHP_CodeSniffer_File + */ + protected $currentFile = null; + + + /** + * 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 void + */ + public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + $this->currentFile = $phpcsFile; + + // We are only interested if this is the first open tag. + if ($stackPtr !== 0) { + if ($phpcsFile->findPrevious(T_OPEN_TAG, ($stackPtr - 1)) !== false) { + return; + } + } + + $tokens = $phpcsFile->getTokens(); + + $errorToken = ($stackPtr + 1); + if (isset($tokens[$errorToken]) === false) { + $errorToken--; + } + + // Find the next non whitespace token. + $commentStart = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); + + if ($tokens[$commentStart]['code'] === T_CLOSE_TAG) { + // We are only interested if this is the first open tag. + return; + } else if ($tokens[$commentStart]['code'] === T_COMMENT) { + $phpcsFile->addError('You must use "/**" style comments for a file comment', $errorToken, 'WrongStyle'); + return; + } else if ($commentStart === false || $tokens[$commentStart]['code'] !== T_DOC_COMMENT) { + $phpcsFile->addError('Missing file doc comment', $errorToken, 'Missing'); + return; + } + + // Extract the header comment docblock. + $commentEnd = ($phpcsFile->findNext(T_DOC_COMMENT, ($commentStart + 1), null, true) - 1); + + // Check if there is only 1 doc comment between the open tag and class token. + $nextToken = array( + T_ABSTRACT, + T_CLASS, + T_DOC_COMMENT, + ); + + $commentNext = $phpcsFile->findNext($nextToken, ($commentEnd + 1)); + if ($commentNext !== false && $tokens[$commentNext]['code'] !== T_DOC_COMMENT) { + // Found a class token right after comment doc block. + $newlineToken = $phpcsFile->findNext(T_WHITESPACE, ($commentEnd + 1), $commentNext, false, $phpcsFile->eolChar); + if ($newlineToken !== false) { + $newlineToken = $phpcsFile->findNext(T_WHITESPACE, ($newlineToken + 1), $commentNext, false, $phpcsFile->eolChar); + if ($newlineToken === false) { + // No blank line between the class token and the doc block. + // The doc block is most likely a class comment. + $phpcsFile->addError('Missing file doc comment', $errorToken, 'Missing'); + return; + } + } + } + + // No blank line between the open tag and the file comment. + $blankLineBefore = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, false, $phpcsFile->eolChar); + if ($blankLineBefore !== false && $blankLineBefore < $commentStart) { + $error = 'Extra newline found after the open tag'; + $phpcsFile->addError($error, $stackPtr, 'SpacingAfterOpen'); + } + + // Exactly one blank line after the file comment. + $nextTokenStart = $phpcsFile->findNext(T_WHITESPACE, ($commentEnd + 1), null, true); + if ($nextTokenStart !== false) { + $blankLineAfter = 0; + for ($i = ($commentEnd + 1); $i < $nextTokenStart; $i++) { + if ($tokens[$i]['code'] === T_WHITESPACE && $tokens[$i]['content'] === $phpcsFile->eolChar) { + $blankLineAfter++; + } + } + + if ($blankLineAfter !== 2) { + $error = 'There must be exactly one blank line after the file comment'; + $phpcsFile->addError($error, ($commentEnd + 1), 'SpacingAfterComment'); + } + } + + $commentString = $phpcsFile->getTokensAsString($commentStart, ($commentEnd - $commentStart + 1)); + + // Parse the header comment docblock. + try { + $this->commentParser = new PHP_CodeSniffer_CommentParser_ClassCommentParser($commentString, $phpcsFile); + $this->commentParser->parse(); + } catch (PHP_CodeSniffer_CommentParser_ParserException $e) { + $line = ($e->getLineWithinComment() + $commentStart); + $phpcsFile->addError($e->getMessage(), $line, 'Exception'); + return; + } + + $comment = $this->commentParser->getComment(); + if (is_null($comment) === true) { + $error = 'File doc comment is empty'; + $phpcsFile->addError($error, $commentStart, 'Empty'); + return; + } + + // The first line of the comment should just be the /** code. + $eolPos = strpos($commentString, $phpcsFile->eolChar); + $firstLine = substr($commentString, 0, $eolPos); + if ($firstLine !== '/**') { + $error = 'The open comment tag must be the only content on the line'; + $phpcsFile->addError($error, $commentStart, 'ContentAfterOpen'); + } + + // No extra newline before short description. + $short = $comment->getShortComment(); + $newlineCount = 0; + $newlineSpan = strspn($short, $phpcsFile->eolChar); + if ($short !== '' && $newlineSpan > 0) { + $error = 'Extra newline(s) found before file comment short description'; + $phpcsFile->addError($error, ($commentStart + 1), 'SpacingBeforeShort'); + } + + $newlineCount = (substr_count($short, $phpcsFile->eolChar) + 1); + + // Exactly one blank line between short and long description. + $long = $comment->getLongComment(); + if (empty($long) === false) { + $between = $comment->getWhiteSpaceBetween(); + $newlineBetween = substr_count($between, $phpcsFile->eolChar); + if ($newlineBetween !== 2) { + $error = 'There must be exactly one blank line between descriptions in file comment'; + $phpcsFile->addError($error, ($commentStart + $newlineCount + 1), 'SpacingBetween'); + } + + $newlineCount += $newlineBetween; + + $testLong = trim($long); + if (preg_match('|\p{Lu}|u', $testLong[0]) === 0) { + $error = 'File comment long description must start with a capital letter'; + $phpcsFile->addError($error, ($commentStart + $newlineCount), 'LongNotCapital'); + } + }//end if + + // Exactly one blank line before tags. + $tags = $this->commentParser->getTagOrders(); + if (count($tags) > 1) { + $newlineSpan = $comment->getNewlineAfter(); + if ($newlineSpan !== 2) { + $error = 'There must be exactly one blank line before the tags in file comment'; + if ($long !== '') { + $newlineCount += (substr_count($long, $phpcsFile->eolChar) - $newlineSpan + 1); + } + + $phpcsFile->addError($error, ($commentStart + $newlineCount), 'SpacingBeforeTags'); + $short = rtrim($short, $phpcsFile->eolChar.' '); + } + } + + // Short description must be single line and end with a full stop. + $testShort = trim($short); + if ($testShort === '') { + $error = 'Missing short description in file comment'; + $phpcsFile->addError($error, ($commentStart + 1), 'MissingShort'); + } else { + $lastChar = $testShort[(strlen($testShort) - 1)]; + if (substr_count($testShort, $phpcsFile->eolChar) !== 0) { + $error = 'File comment short description must be on a single line'; + $phpcsFile->addError($error, ($commentStart + 1), 'ShortSingleLine'); + } + + if (preg_match('|\p{Lu}|u', $testShort[0]) === 0) { + $error = 'File comment short description must start with a capital letter'; + $phpcsFile->addError($error, ($commentStart + 1), 'ShortNotCapital'); + } + + if ($lastChar !== '.') { + $error = 'File comment short description must end with a full stop'; + $phpcsFile->addError($error, ($commentStart + 1), 'ShortFullStop'); + } + }//end if + + // Check for unknown/deprecated tags. + $unknownTags = $this->commentParser->getUnknown(); + foreach ($unknownTags as $errorTag) { + // Unknown tags are not parsed, do not process further. + $error = '@%s tag is not allowed in file comment'; + $data = array($errorTag['tag']); + $phpcsFile->addWarning($error, ($commentStart + $errorTag['line']), 'TagNotAllowed', $data); + } + + // Check each tag. + $this->processTags($commentStart, $commentEnd); + + // The last content should be a newline and the content before + // that should not be blank. If there is more blank space + // then they have additional blank lines at the end of the comment. + $words = $this->commentParser->getWords(); + $lastPos = (count($words) - 1); + if (trim($words[($lastPos - 1)]) !== '' + || strpos($words[($lastPos - 1)], $this->currentFile->eolChar) === false + || trim($words[($lastPos - 2)]) === '' + ) { + $error = 'Additional blank lines found at end of file comment'; + $this->currentFile->addError($error, $commentEnd, 'SpacingAfter'); + } + + }//end process() + + + /** + * Processes each required or optional tag. + * + * @param int $commentStart The position in the stack where the comment started. + * @param int $commentEnd The position in the stack where the comment ended. + * + * @return void + */ + protected function processTags($commentStart, $commentEnd) + { + // Required tags in correct order. + $tags = array( + 'package' => 'precedes @subpackage', + 'subpackage' => 'follows @package', + 'author' => 'follows @subpackage', + 'copyright' => 'follows @author', + 'license' => 'follows @copyright', + ); + + $foundTags = $this->commentParser->getTagOrders(); + $errorPos = 0; + $orderIndex = 0; + $longestTag = 0; + $indentation = array(); + foreach ($tags as $tag => $orderText) { + + // Required tag missing. + if (in_array($tag, $foundTags) === false) { + $error = 'Missing @%s tag in file comment'; + $data = array($tag); + $this->currentFile->addError($error, $commentEnd, 'Missing'.ucfirst($tag).'Tag', $data); + continue; + } + + // Get the line number for current tag. + $tagName = ucfirst($tag); + if ($tagName === 'Author' || $tagName === 'Copyright') { + // These tags are different because they return an array. + $tagName .= 's'; + } + + // Work out the line number for this tag. + $getMethod = 'get'.$tagName; + $tagElement = $this->commentParser->$getMethod(); + if (is_null($tagElement) === true || empty($tagElement) === true) { + continue; + } else if (is_array($tagElement) === true && empty($tagElement) === false) { + $tagElement = $tagElement[0]; + } + + $errorPos = ($commentStart + $tagElement->getLine()); + + // Make sure there is no duplicate tag. + $foundIndexes = array_keys($foundTags, $tag); + if (count($foundIndexes) > 1) { + $error = 'Only 1 @%s tag is allowed in file comment'; + $data = array($tag); + $this->currentFile->addError($error, $errorPos, 'Duplicate'.ucfirst($tag).'Tag', $data); + } + + // Check tag order. + if ($foundIndexes[0] > $orderIndex) { + $orderIndex = $foundIndexes[0]; + } else { + $error = 'The @%s tag is in the wrong order; the tag %s'; + $data = array( + $tag, + $orderText, + ); + $this->currentFile->addError($error, $errorPos, ucfirst($tag).'TagOrder', $data); + } + + // Store the indentation of each tag. + $len = strlen($tag); + if ($len > $longestTag) { + $longestTag = $len; + } + + $indentation[] = array( + 'tag' => $tag, + 'errorPos' => $errorPos, + 'space' => $this->getIndentation($tag, $tagElement), + ); + + $method = 'process'.$tagName; + if (method_exists($this, $method) === true) { + // Process each tag if a method is defined. + call_user_func(array($this, $method), $errorPos); + } else { + $tagElement->process($this->currentFile, $commentStart, 'file'); + } + }//end foreach + + // Check tag indentation. + foreach ($indentation as $indentInfo) { + $tagName = ucfirst($indentInfo['tag']); + if ($tagName === 'Author') { + $tagName .= 's'; + } + + if ($indentInfo['space'] !== 0 && $indentInfo['space'] !== ($longestTag + 1)) { + $expected = ($longestTag - strlen($indentInfo['tag']) + 1); + $space = ($indentInfo['space'] - strlen($indentInfo['tag'])); + $error = '@%s tag comment indented incorrectly; expected %s spaces but found %s'; + $data = array( + $indentInfo['tag'], + $expected, + $space, + ); + $this->currentFile->addError($error, $indentInfo['errorPos'], ucfirst($indentInfo['tag']).'TagIndent', $data); + } + } + + }//end processTags() + + + /** + * Get the indentation information of each tag. + * + * @param string $tagName The name of the doc comment element. + * @param PHP_CodeSniffer_CommentParser_DocElement $tagElement The doc comment element. + * + * @return void + */ + protected function getIndentation($tagName, $tagElement) + { + if ($tagElement instanceof PHP_CodeSniffer_CommentParser_SingleElement) { + if ($tagElement->getContent() !== '') { + return (strlen($tagName) + substr_count($tagElement->getWhitespaceBeforeContent(), ' ')); + } + } else if ($tagElement instanceof PHP_CodeSniffer_CommentParser_PairElement) { + if ($tagElement->getValue() !== '') { + return (strlen($tagName) + substr_count($tagElement->getWhitespaceBeforeValue(), ' ')); + } + } + + return 0; + + }//end getIndentation() + + + /** + * The package name must be camel-cased. + * + * @param int $errorPos The line number where the error occurs. + * + * @return void + */ + protected function processPackage($errorPos) + { + $package = $this->commentParser->getPackage(); + if ($package !== null) { + $content = $package->getContent(); + if (empty($content) === true) { + $error = 'Content missing for @package tag in file comment'; + $this->currentFile->addError($error, $errorPos, 'MissingPackage'); + } else if (PHP_CodeSniffer::isUnderscoreName($content) !== true) { + // Package name must be properly camel-cased. + $nameBits = explode('_', str_replace(' ', '', $content)); + $firstBit = array_shift($nameBits); + $newName = strtoupper($firstBit{0}).substr($firstBit, 1).'_'; + foreach ($nameBits as $bit) { + $newName .= strtoupper($bit{0}).substr($bit, 1).'_'; + } + + $error = 'Package name "%s" is not valid; consider "%s" instead'; + $data = array( + $content, + trim($newName, '_'), + ); + $this->currentFile->addError($error, $errorPos, 'IncorrectPackage', $data); + } else if (strpos($content, 'Squiz') === 0) { + // Package name must not start with Squiz. + $newName = substr($content, 5); + $error = 'Package name "%s" is not valid; consider "%s" instead'; + $data = array( + $content, + $newName, + ); + $this->currentFile->addError($error, $errorPos, 'SquizPackage', $data); + } + } + + }//end processPackage() + + + /** + * The subpackage name must be camel-cased. + * + * @param int $errorPos The line number where the error occurs. + * + * @return void + */ + protected function processSubpackage($errorPos) + { + $subpackage = $this->commentParser->getSubpackage(); + if ($subpackage !== null) { + $content = $subpackage->getContent(); + if (empty($content) === true) { + $error = 'Content missing for @subpackage tag in file comment'; + $this->currentFile->addError($error, $errorPos, 'MissingSubpackage'); + } else if (PHP_CodeSniffer::isUnderscoreName($content) !== true) { + // Subpackage name must be properly camel-cased. + $nameBits = explode('_', $content); + $firstBit = array_shift($nameBits); + $newName = strtoupper($firstBit{0}).substr($firstBit, 1).'_'; + foreach ($nameBits as $bit) { + $newName .= strtoupper($bit{0}).substr($bit, 1).'_'; + } + + $error = 'Subpackage name "%s" is not valid; consider "%s" instead'; + $data = array( + $content, + trim($newName, '_'), + ); + $this->currentFile->addError($error, $errorPos, 'IncorrectSubpackage', $data); + } + } + + }//end processSubpackage() + + + /** + * Author tag must be 'Squiz Pty Ltd '. + * + * @param int $errorPos The line number where the error occurs. + * + * @return void + */ + protected function processAuthors($errorPos) + { + $authors = $this->commentParser->getAuthors(); + if (empty($authors) === false) { + $author = $authors[0]; + $content = $author->getContent(); + if (empty($content) === true) { + $error = 'Content missing for @author tag in file comment'; + $this->currentFile->addError($error, $errorPos, 'MissingAuthor'); + } else if ($content !== 'Squiz Pty Ltd ') { + $error = 'Expected "Squiz Pty Ltd " for author tag'; + $this->currentFile->addError($error, $errorPos, 'IncorrectAuthor'); + } + } + + }//end processAuthors() + + + /** + * Copyright tag must be in the form '2006-YYYY Squiz Pty Ltd (ABN 77 084 670 600)'. + * + * @param int $errorPos The line number where the error occurs. + * + * @return void + */ + protected function processCopyrights($errorPos) + { + $copyrights = $this->commentParser->getCopyrights(); + $copyright = $copyrights[0]; + + if ($copyright !== null) { + $content = $copyright->getContent(); + if (empty($content) === true) { + $error = 'Content missing for @copyright tag in file comment'; + $this->currentFile->addError($error, $errorPos, 'MissingCopyright'); + + } else if (preg_match('/^([0-9]{4})(-[0-9]{4})? (Squiz Pty Ltd \(ACN 084 670 600\))$/', $content) === 0) { + $error = 'Expected "xxxx-xxxx Squiz Pty Ltd (ACN 084 670 600)" for copyright declaration'; + $this->currentFile->addError($error, $errorPos, 'IncorrectCopyright'); + } + } + + }//end processCopyrights() + + + /** + * License tag must be 'http://matrix.squiz.net/licence Squiz.Net Open Source Licence'. + * + * @param int $errorPos The line number where the error occurs. + * + * @return void + */ + protected function processLicense($errorPos) + { + $license = $this->commentParser->getLicense(); + if ($license !== null) { + $url = $license->getValue(); + $content = $license->getComment(); + if (empty($url) === true && empty($content) === true) { + $error = 'Content missing for @license tag in file comment'; + $this->currentFile->addError($error, $errorPos, 'MissingLicense'); + } else { + // Check for license URL. + if (empty($url) === true) { + $error = 'License URL missing for @license tag in file comment'; + $this->currentFile->addError($error, $errorPos, 'MissingLicenseURL'); + } else if ($url !== 'http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt') { + $error = 'Expected "http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt" for license URL'; + $this->currentFile->addError($error, $errorPos, 'IncorrectLicenseURL'); + } + + // Check for license name. + if (empty($content) === true) { + $error = 'License name missing for @license tag in file comment'; + $this->currentFile->addError($error, $errorPos, 'MissingLicenseName'); + } else if ($content !== 'GPLv2') { + $error = 'Expected "GPLv2" for license name'; + $this->currentFile->addError($error, $errorPos, 'IncorrectLicenseName'); + } + }//end if + }//end if + + }//end processLicense() + + +}//end class + + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,810 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +if (class_exists('PHP_CodeSniffer_CommentParser_FunctionCommentParser', true) === false) { + $error = 'Class PHP_CodeSniffer_CommentParser_FunctionCommentParser not found'; + throw new PHP_CodeSniffer_Exception($error); +} + +/** + * Parses and verifies the doc comments for functions. + * + * Verifies that : + *
    + *
  • A comment exists
  • + *
  • There is a blank newline after the short description
  • + *
  • There is a blank newline between the long and short description
  • + *
  • There is a blank newline between the long description and tags
  • + *
  • Parameter names represent those in the method
  • + *
  • Parameter comments are in the correct order
  • + *
  • Parameter comments are complete
  • + *
  • A type hint is provided for array and custom class
  • + *
  • Type hint matches the actual variable/class type
  • + *
  • A blank line is present before the first and after the last parameter
  • + *
  • A return type exists
  • + *
  • Any throw tag must have a comment
  • + *
  • The tag order and indentation are correct
  • + *
+ * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_Commenting_FunctionCommentSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * The name of the method that we are currently processing. + * + * @var string + */ + private $_methodName = ''; + + /** + * The position in the stack where the function token was found. + * + * @var int + */ + private $_functionToken = null; + + /** + * The position in the stack where the class token was found. + * + * @var int + */ + private $_classToken = null; + + /** + * The index of the current tag we are processing. + * + * @var int + */ + private $_tagIndex = 0; + + /** + * The function comment parser for the current method. + * + * @var PHP_CodeSniffer_Comment_Parser_FunctionCommentParser + */ + protected $commentParser = null; + + /** + * The current PHP_CodeSniffer_File object we are processing. + * + * @var PHP_CodeSniffer_File + */ + protected $currentFile = null; + + + /** + * 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) + { + $this->currentFile = $phpcsFile; + + $tokens = $phpcsFile->getTokens(); + + $find = array( + T_COMMENT, + T_DOC_COMMENT, + T_CLASS, + T_FUNCTION, + T_OPEN_TAG, + ); + + $commentEnd = $phpcsFile->findPrevious($find, ($stackPtr - 1)); + + if ($commentEnd === false) { + return; + } + + // If the token that we found was a class or a function, then this + // function has no doc comment. + $code = $tokens[$commentEnd]['code']; + + if ($code === T_COMMENT) { + // The function might actually be missing a comment, and this last comment + // found is just commenting a bit of code on a line. So if it is not the + // only thing on the line, assume we found nothing. + $prevContent = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, $commentEnd); + if ($tokens[$commentEnd]['line'] === $tokens[$commentEnd]['line']) { + $error = 'Missing function doc comment'; + $phpcsFile->addError($error, $stackPtr, 'Missing'); + } else { + $error = 'You must use "/**" style comments for a function comment'; + $phpcsFile->addError($error, $stackPtr, 'WrongStyle'); + } + return; + } else if ($code !== T_DOC_COMMENT) { + $error = 'Missing function doc comment'; + $phpcsFile->addError($error, $stackPtr, 'Missing'); + return; + } else if (trim($tokens[$commentEnd]['content']) !== '*/') { + $error = 'You must use "*/" to end a function comment; found "%s"'; + $phpcsFile->addError($error, $commentEnd, 'WrongEnd', array(trim($tokens[$commentEnd]['content']))); + return; + } + + // If there is any code between the function keyword and the doc block + // then the doc block is not for us. + $ignore = PHP_CodeSniffer_Tokens::$scopeModifiers; + $ignore[] = T_STATIC; + $ignore[] = T_WHITESPACE; + $ignore[] = T_ABSTRACT; + $ignore[] = T_FINAL; + $prevToken = $phpcsFile->findPrevious($ignore, ($stackPtr - 1), null, true); + if ($prevToken !== $commentEnd) { + $phpcsFile->addError('Missing function doc comment', $stackPtr, 'Missing'); + return; + } + + $this->_functionToken = $stackPtr; + + $this->_classToken = null; + foreach ($tokens[$stackPtr]['conditions'] as $condPtr => $condition) { + if ($condition === T_CLASS || $condition === T_INTERFACE) { + $this->_classToken = $condPtr; + break; + } + } + + // Find the first doc comment. + $commentStart = ($phpcsFile->findPrevious(T_DOC_COMMENT, ($commentEnd - 1), null, true) + 1); + $commentString = $phpcsFile->getTokensAsString($commentStart, ($commentEnd - $commentStart + 1)); + $this->_methodName = $phpcsFile->getDeclarationName($stackPtr); + + try { + $this->commentParser = new PHP_CodeSniffer_CommentParser_FunctionCommentParser($commentString, $phpcsFile); + $this->commentParser->parse(); + } catch (PHP_CodeSniffer_CommentParser_ParserException $e) { + $line = ($e->getLineWithinComment() + $commentStart); + $phpcsFile->addError($e->getMessage(), $line, 'FailedParse'); + return; + } + + $comment = $this->commentParser->getComment(); + if (is_null($comment) === true) { + $error = 'Function doc comment is empty'; + $phpcsFile->addError($error, $commentStart, 'Empty'); + return; + } + + // The first line of the comment should just be the /** code. + $eolPos = strpos($commentString, $phpcsFile->eolChar); + $firstLine = substr($commentString, 0, $eolPos); + if ($firstLine !== '/**') { + $error = 'The open comment tag must be the only content on the line'; + $phpcsFile->addError($error, $commentStart, 'ContentAfterOpen'); + } + + $this->processParams($commentStart, $commentEnd); + $this->processSees($commentStart); + $this->processReturn($commentStart, $commentEnd); + $this->processThrows($commentStart); + + // Check for a comment description. + $short = $comment->getShortComment(); + if (trim($short) === '') { + $error = 'Missing short description in function doc comment'; + $phpcsFile->addError($error, $commentStart, 'MissingShort'); + return; + } + + // No extra newline before short description. + $newlineCount = 0; + $newlineSpan = strspn($short, $phpcsFile->eolChar); + if ($short !== '' && $newlineSpan > 0) { + $error = 'Extra newline(s) found before function comment short description'; + $phpcsFile->addError($error, ($commentStart + 1), 'SpacingBeforeShort'); + } + + $newlineCount = (substr_count($short, $phpcsFile->eolChar) + 1); + + // Exactly one blank line between short and long description. + $long = $comment->getLongComment(); + if (empty($long) === false) { + $between = $comment->getWhiteSpaceBetween(); + $newlineBetween = substr_count($between, $phpcsFile->eolChar); + if ($newlineBetween !== 2) { + $error = 'There must be exactly one blank line between descriptions in function comment'; + $phpcsFile->addError($error, ($commentStart + $newlineCount + 1), 'SpacingBetween'); + } + + $newlineCount += $newlineBetween; + + $testLong = trim($long); + if (preg_match('|\p{Lu}|u', $testLong[0]) === 0) { + $error = 'Function comment long description must start with a capital letter'; + $phpcsFile->addError($error, ($commentStart + $newlineCount), 'LongNotCapital'); + } + }//end if + + // Exactly one blank line before tags. + $params = $this->commentParser->getTagOrders(); + if (count($params) > 1) { + $newlineSpan = $comment->getNewlineAfter(); + if ($newlineSpan !== 2) { + $error = 'There must be exactly one blank line before the tags in function comment'; + if ($long !== '') { + $newlineCount += (substr_count($long, $phpcsFile->eolChar) - $newlineSpan + 1); + } + + $phpcsFile->addError($error, ($commentStart + $newlineCount), 'SpacingBeforeTags'); + $short = rtrim($short, $phpcsFile->eolChar.' '); + } + } + + // Short description must be single line and end with a full stop. + $testShort = trim($short); + $lastChar = $testShort[(strlen($testShort) - 1)]; + if (substr_count($testShort, $phpcsFile->eolChar) !== 0) { + $error = 'Function comment short description must be on a single line'; + $phpcsFile->addError($error, ($commentStart + 1), 'ShortSingleLine'); + } + + if (preg_match('|\p{Lu}|u', $testShort[0]) === 0) { + $error = 'Function comment short description must start with a capital letter'; + $phpcsFile->addError($error, ($commentStart + 1), 'ShortNotCapital'); + } + + if ($lastChar !== '.') { + $error = 'Function comment short description must end with a full stop'; + $phpcsFile->addError($error, ($commentStart + 1), 'ShortFullStop'); + } + + // Check for unknown/deprecated tags. + $this->processUnknownTags($commentStart, $commentEnd); + + // The last content should be a newline and the content before + // that should not be blank. If there is more blank space + // then they have additional blank lines at the end of the comment. + $words = $this->commentParser->getWords(); + $lastPos = (count($words) - 1); + if (trim($words[($lastPos - 1)]) !== '' + || strpos($words[($lastPos - 1)], $this->currentFile->eolChar) === false + || trim($words[($lastPos - 2)]) === '' + ) { + $error = 'Additional blank lines found at end of function comment'; + $this->currentFile->addError($error, $commentEnd, 'SpacingAfter'); + } + + }//end process() + + + /** + * Process the see tags. + * + * @param int $commentStart The position in the stack where the comment started. + * + * @return void + */ + protected function processSees($commentStart) + { + $sees = $this->commentParser->getSees(); + if (empty($sees) === false) { + $tagOrder = $this->commentParser->getTagOrders(); + $index = array_keys($this->commentParser->getTagOrders(), 'see'); + foreach ($sees as $i => $see) { + $errorPos = ($commentStart + $see->getLine()); + $since = array_keys($tagOrder, 'since'); + if (count($since) === 1 && $this->_tagIndex !== 0) { + $this->_tagIndex++; + if ($index[$i] !== $this->_tagIndex) { + $error = 'The @see tag is in the wrong order; the tag precedes @return'; + $this->currentFile->addError($error, $errorPos, 'SeeOrder'); + } + } + + $content = $see->getContent(); + if (empty($content) === true) { + $error = 'Content missing for @see tag in function comment'; + $this->currentFile->addError($error, $errorPos, 'EmptySee'); + continue; + } + + $spacing = substr_count($see->getWhitespaceBeforeContent(), ' '); + if ($spacing !== 4) { + $error = '@see tag indented incorrectly; expected 4 spaces but found %s'; + $data = array($spacing); + $this->currentFile->addError($error, $errorPos, 'SeeIndent', $data); + } + }//end foreach + }//end if + + }//end processSees() + + + /** + * Process the return comment of this function comment. + * + * @param int $commentStart The position in the stack where the comment started. + * @param int $commentEnd The position in the stack where the comment ended. + * + * @return void + */ + protected function processReturn($commentStart, $commentEnd) + { + // Skip constructor and destructor. + $className = ''; + if ($this->_classToken !== null) { + $className = $this->currentFile->getDeclarationName($this->_classToken); + $className = strtolower(ltrim($className, '_')); + } + + $methodName = strtolower(ltrim($this->_methodName, '_')); + $isSpecialMethod = ($this->_methodName === '__construct' || $this->_methodName === '__destruct'); + $return = $this->commentParser->getReturn(); + + if ($isSpecialMethod === false && $methodName !== $className) { + if ($return !== null) { + $tagOrder = $this->commentParser->getTagOrders(); + $index = array_keys($tagOrder, 'return'); + $errorPos = ($commentStart + $return->getLine()); + $content = trim($return->getRawContent()); + + if (count($index) > 1) { + $error = 'Only 1 @return tag is allowed in function comment'; + $this->currentFile->addError($error, $errorPos, 'DuplicateReturn'); + return; + } + + $since = array_keys($tagOrder, 'since'); + if (count($since) === 1 && $this->_tagIndex !== 0) { + $this->_tagIndex++; + if ($index[0] !== $this->_tagIndex) { + $error = 'The @return tag is in the wrong order; the tag follows @see (if used)'; + $this->currentFile->addError($error, $errorPos, 'ReturnOrder'); + } + } + + if (empty($content) === true) { + $error = 'Return type missing for @return tag in function comment'; + $this->currentFile->addError($error, $errorPos, 'MissingReturnType'); + } else { + // Check return type (can be multiple, separated by '|'). + $typeNames = explode('|', $content); + $suggestedNames = array(); + foreach ($typeNames as $i => $typeName) { + $suggestedName = PHP_CodeSniffer::suggestType($typeName); + if (in_array($suggestedName, $suggestedNames) === false) { + $suggestedNames[] = $suggestedName; + } + } + + $suggestedType = implode('|', $suggestedNames); + if ($content !== $suggestedType) { + $error = 'Function return type "%s" is invalid'; + $data = array($content); + $this->currentFile->addError($error, $errorPos, 'InvalidReturn', $data); + } + + $tokens = $this->currentFile->getTokens(); + + // If the return type is void, make sure there is + // no return statement in the function. + if ($content === 'void') { + if (isset($tokens[$this->_functionToken]['scope_closer']) === true) { + $endToken = $tokens[$this->_functionToken]['scope_closer']; + $returnToken = $this->currentFile->findNext(T_RETURN, $this->_functionToken, $endToken); + if ($returnToken !== false) { + // If the function is not returning anything, just + // exiting, then there is no problem. + $semicolon = $this->currentFile->findNext(T_WHITESPACE, ($returnToken + 1), null, true); + if ($tokens[$semicolon]['code'] !== T_SEMICOLON) { + $error = 'Function return type is void, but function contains return statement'; + $this->currentFile->addError($error, $errorPos, 'InvalidReturnVoid'); + } + } + } + } else if ($content !== 'mixed') { + // If return type is not void, there needs to be a + // returns statement somewhere in the function that + // returns something. + if (isset($tokens[$this->_functionToken]['scope_closer']) === true) { + $endToken = $tokens[$this->_functionToken]['scope_closer']; + $returnToken = $this->currentFile->findNext(T_RETURN, $this->_functionToken, $endToken); + if ($returnToken === false) { + $error = 'Function return type is not void, but function has no return statement'; + $this->currentFile->addError($error, $errorPos, 'InvalidNoReturn'); + } else { + $semicolon = $this->currentFile->findNext(T_WHITESPACE, ($returnToken + 1), null, true); + if ($tokens[$semicolon]['code'] === T_SEMICOLON) { + $error = 'Function return type is not void, but function is returning void here'; + $this->currentFile->addError($error, $returnToken, 'InvalidReturnNotVoid'); + } + } + } + }//end if + + $spacing = substr_count($return->getWhitespaceBeforeValue(), ' '); + if ($spacing !== 1) { + $error = '@return tag indented incorrectly; expected 1 space but found %s'; + $data = array($spacing); + $this->currentFile->addError($error, $errorPos, 'ReturnIndent', $data); + } + }//end if + } else { + $error = 'Missing @return tag in function comment'; + $this->currentFile->addError($error, $commentEnd, 'MissingReturn'); + }//end if + + } else { + // No return tag for constructor and destructor. + if ($return !== null) { + $errorPos = ($commentStart + $return->getLine()); + $error = '@return tag is not required for constructor and destructor'; + $this->currentFile->addError($error, $errorPos, 'ReturnNotRequired'); + } + }//end if + + }//end processReturn() + + + /** + * Process any throw tags that this function comment has. + * + * @param int $commentStart The position in the stack where the comment started. + * + * @return void + */ + protected function processThrows($commentStart) + { + if (count($this->commentParser->getThrows()) === 0) { + return; + } + + $tagOrder = $this->commentParser->getTagOrders(); + $index = array_keys($this->commentParser->getTagOrders(), 'throws'); + + foreach ($this->commentParser->getThrows() as $i => $throw) { + $exception = $throw->getValue(); + $content = trim($throw->getComment()); + $errorPos = ($commentStart + $throw->getLine()); + if (empty($exception) === true) { + $error = 'Exception type and comment missing for @throws tag in function comment'; + $this->currentFile->addError($error, $errorPos, 'InvalidThrows'); + } else if (empty($content) === true) { + $error = 'Comment missing for @throws tag in function comment'; + $this->currentFile->addError($error, $errorPos, 'EmptyThrows'); + } else { + // Starts with a capital letter and ends with a fullstop. + $firstChar = $content{0}; + if (strtoupper($firstChar) !== $firstChar) { + $error = '@throws tag comment must start with a capital letter'; + $this->currentFile->addError($error, $errorPos, 'ThrowsNotCapital'); + } + + $lastChar = $content[(strlen($content) - 1)]; + if ($lastChar !== '.') { + $error = '@throws tag comment must end with a full stop'; + $this->currentFile->addError($error, $errorPos, 'ThrowsNoFullStop'); + } + } + + $since = array_keys($tagOrder, 'since'); + if (count($since) === 1 && $this->_tagIndex !== 0) { + $this->_tagIndex++; + if ($index[$i] !== $this->_tagIndex) { + $error = 'The @throws tag is in the wrong order; the tag follows @return'; + $this->currentFile->addError($error, $errorPos, 'ThrowsOrder'); + } + } + }//end foreach + + }//end processThrows() + + + /** + * Process the function parameter comments. + * + * @param int $commentStart The position in the stack where + * the comment started. + * @param int $commentEnd The position in the stack where + * the comment ended. + * + * @return void + */ + protected function processParams($commentStart, $commentEnd) + { + $realParams = $this->currentFile->getMethodParameters($this->_functionToken); + $params = $this->commentParser->getParams(); + $foundParams = array(); + + if (empty($params) === false) { + + if (substr_count($params[(count($params) - 1)]->getWhitespaceAfter(), $this->currentFile->eolChar) !== 2) { + $error = 'Last parameter comment requires a blank newline after it'; + $errorPos = ($params[(count($params) - 1)]->getLine() + $commentStart); + $this->currentFile->addError($error, $errorPos, 'SpacingAfterParams'); + } + + // Parameters must appear immediately after the comment. + if ($params[0]->getOrder() !== 2) { + $error = 'Parameters must appear immediately after the comment'; + $errorPos = ($params[0]->getLine() + $commentStart); + $this->currentFile->addError($error, $errorPos, 'SpacingBeforeParams'); + } + + $previousParam = null; + $spaceBeforeVar = 10000; + $spaceBeforeComment = 10000; + $longestType = 0; + $longestVar = 0; + + foreach ($params as $param) { + + $paramComment = trim($param->getComment()); + $errorPos = ($param->getLine() + $commentStart); + + // Make sure that there is only one space before the var type. + if ($param->getWhitespaceBeforeType() !== ' ') { + $error = 'Expected 1 space before variable type'; + $this->currentFile->addError($error, $errorPos, 'SpacingBeforeParamType'); + } + + $spaceCount = substr_count($param->getWhitespaceBeforeVarName(), ' '); + if ($spaceCount < $spaceBeforeVar) { + $spaceBeforeVar = $spaceCount; + $longestType = $errorPos; + } + + $spaceCount = substr_count($param->getWhitespaceBeforeComment(), ' '); + + if ($spaceCount < $spaceBeforeComment && $paramComment !== '') { + $spaceBeforeComment = $spaceCount; + $longestVar = $errorPos; + } + + // Make sure they are in the correct order, and have the correct name. + $pos = $param->getPosition(); + $paramName = ($param->getVarName() !== '') ? $param->getVarName() : '[ UNKNOWN ]'; + + if ($previousParam !== null) { + $previousName = ($previousParam->getVarName() !== '') ? $previousParam->getVarName() : 'UNKNOWN'; + + // Check to see if the parameters align properly. + if ($param->alignsVariableWith($previousParam) === false) { + $error = 'The variable names for parameters %s (%s) and %s (%s) do not align'; + $data = array( + $previousName, + ($pos - 1), + $paramName, + $pos, + ); + $this->currentFile->addError($error, $errorPos, 'ParameterNamesNotAligned', $data); + } + + if ($param->alignsCommentWith($previousParam) === false) { + $error = 'The comments for parameters %s (%s) and %s (%s) do not align'; + $data = array( + $previousName, + ($pos - 1), + $paramName, + $pos, + ); + $this->currentFile->addError($error, $errorPos, 'ParameterCommentsNotAligned', $data); + } + } + + // Variable must be one of the supported standard type. + $typeNames = explode('|', $param->getType()); + foreach ($typeNames as $typeName) { + $suggestedName = PHP_CodeSniffer::suggestType($typeName); + if ($typeName !== $suggestedName) { + $error = 'Expected "%s"; found "%s" for %s at position %s'; + $data = array( + $suggestedName, + $typeName, + $paramName, + $pos, + ); + $this->currentFile->addError($error, $errorPos, 'IncorrectParamVarName', $data); + } else if (count($typeNames) === 1) { + // Check type hint for array and custom type. + $suggestedTypeHint = ''; + if (strpos($suggestedName, 'array') !== false) { + $suggestedTypeHint = 'array'; + } else if (in_array($typeName, PHP_CodeSniffer::$allowedTypes) === false) { + $suggestedTypeHint = $suggestedName; + } + + if ($suggestedTypeHint !== '' && isset($realParams[($pos - 1)]) === true) { + $typeHint = $realParams[($pos - 1)]['type_hint']; + if ($typeHint === '') { + $error = 'Type hint "%s" missing for %s at position %s'; + $data = array( + $suggestedTypeHint, + $paramName, + $pos, + ); + $this->currentFile->addError($error, ($commentEnd + 2), 'TypeHintMissing', $data); + } else if ($typeHint !== $suggestedTypeHint) { + $error = 'Expected type hint "%s"; found "%s" for %s at position %s'; + $data = array( + $suggestedTypeHint, + $typeHint, + $paramName, + $pos, + ); + $this->currentFile->addError($error, ($commentEnd + 2), 'IncorrectTypeHint', $data); + } + } else if ($suggestedTypeHint === '' && isset($realParams[($pos - 1)]) === true) { + $typeHint = $realParams[($pos - 1)]['type_hint']; + if ($typeHint !== '') { + $error = 'Unknown type hint "%s" found for %s at position %s'; + $data = array( + $typeHint, + $paramName, + $pos, + ); + $this->currentFile->addError($error, ($commentEnd + 2), 'InvalidTypeHint', $data); + } + } + }//end if + }//end foreach + + // Make sure the names of the parameter comment matches the + // actual parameter. + if (isset($realParams[($pos - 1)]) === true) { + $realName = $realParams[($pos - 1)]['name']; + $foundParams[] = $realName; + + // Append ampersand to name if passing by reference. + if ($realParams[($pos - 1)]['pass_by_reference'] === true) { + $realName = '&'.$realName; + } + + if ($realName !== $paramName) { + $code = 'ParamNameNoMatch'; + $data = array( + $paramName, + $realName, + $pos, + ); + + $error = 'Doc comment for var %s does not match '; + if (strtolower($paramName) === strtolower($realName)) { + $error .= 'case of '; + $code = 'ParamNameNoCaseMatch'; + } + + $error .= 'actual variable name %s at position %s'; + + $this->currentFile->addError($error, $errorPos, $code, $data); + } + } else if (substr($paramName, -4) !== ',...') { + // We must have an extra parameter comment. + $error = 'Superfluous doc comment at position '.$pos; + $this->currentFile->addError($error, $errorPos, 'ExtraParamComment'); + } + + if ($param->getVarName() === '') { + $error = 'Missing parameter name at position '.$pos; + $this->currentFile->addError($error, $errorPos, 'MissingParamName'); + } + + if ($param->getType() === '') { + $error = 'Missing type at position '.$pos; + $this->currentFile->addError($error, $errorPos, 'MissingParamType'); + } + + if ($paramComment === '') { + $error = 'Missing comment for param "%s" at position %s'; + $data = array( + $paramName, + $pos, + ); + $this->currentFile->addError($error, $errorPos, 'MissingParamComment', $data); + } else { + // Param comments must start with a capital letter and + // end with the full stop. + $firstChar = $paramComment{0}; + if (preg_match('|\p{Lu}|u', $firstChar) === 0) { + $error = 'Param comment must start with a capital letter'; + $this->currentFile->addError($error, $errorPos, 'ParamCommentNotCapital'); + } + + $lastChar = $paramComment[(strlen($paramComment) - 1)]; + if ($lastChar !== '.') { + $error = 'Param comment must end with a full stop'; + $this->currentFile->addError($error, $errorPos, 'ParamCommentFullStop'); + } + } + + $previousParam = $param; + + }//end foreach + + if ($spaceBeforeVar !== 1 && $spaceBeforeVar !== 10000 && $spaceBeforeComment !== 10000) { + $error = 'Expected 1 space after the longest type'; + $this->currentFile->addError($error, $longestType, 'SpacingAfterLongType'); + } + + if ($spaceBeforeComment !== 1 && $spaceBeforeComment !== 10000) { + $error = 'Expected 1 space after the longest variable name'; + $this->currentFile->addError($error, $longestVar, 'SpacingAfterLongName'); + } + + }//end if + + $realNames = array(); + foreach ($realParams as $realParam) { + $realNames[] = $realParam['name']; + } + + // Report missing comments. + $diff = array_diff($realNames, $foundParams); + foreach ($diff as $neededParam) { + if (count($params) !== 0) { + $errorPos = ($params[(count($params) - 1)]->getLine() + $commentStart); + } else { + $errorPos = $commentStart; + } + + $error = 'Doc comment for "%s" missing'; + $data = array($neededParam); + $this->currentFile->addError($error, $errorPos, 'MissingParamTag', $data); + } + + }//end processParams() + + + /** + * Process a list of unknown tags. + * + * @param int $commentStart The position in the stack where the comment started. + * @param int $commentEnd The position in the stack where the comment ended. + * + * @return void + */ + protected function processUnknownTags($commentStart, $commentEnd) + { + $unknownTags = $this->commentParser->getUnknown(); + foreach ($unknownTags as $errorTag) { + $error = '@%s tag is not allowed in function comment'; + $data = array($errorTag['tag']); + $this->currentFile->addWarning($error, ($commentStart + $errorTag['line']), 'TagNotAllowed', $data); + } + + }//end processUnknownTags + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Commenting/FunctionCommentThrowTagSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Commenting/FunctionCommentThrowTagSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Commenting/FunctionCommentThrowTagSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Commenting/FunctionCommentThrowTagSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,215 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +if (class_exists('PHP_CodeSniffer_Standards_AbstractScopeSniff', true) === false) { + $error = 'Class PHP_CodeSniffer_Standards_AbstractScopeSniff not found'; + throw new PHP_CodeSniffer_Exception($error); +} + +/** + * Verifies that a @throws tag exists for a function that throws exceptions. + * Verifies the number of @throws tags and the number of throw tokens matches. + * Verifies the exception type. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_Commenting_FunctionCommentThrowTagSniff extends PHP_CodeSniffer_Standards_AbstractScopeSniff +{ + + + /** + * Constructs a Squiz_Sniffs_Commenting_FunctionCommentThrowTagSniff. + */ + public function __construct() + { + parent::__construct(array(T_FUNCTION), array(T_THROW)); + + }//end __construct() + + + /** + * Processes the function tokens within the class. + * + * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found. + * @param int $stackPtr The position where the token was found. + * @param int $currScope The current scope opener token. + * + * @return void + */ + protected function processTokenWithinScope(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $currScope) + { + // Is this the first throw token within the current function scope? + // If so, we have to validate other throw tokens within the same scope. + $previousThrow = $phpcsFile->findPrevious(T_THROW, ($stackPtr - 1), $currScope); + if ($previousThrow !== false) { + return; + } + + $tokens = $phpcsFile->getTokens(); + + $find = array( + T_COMMENT, + T_DOC_COMMENT, + T_CLASS, + T_FUNCTION, + T_OPEN_TAG, + ); + + $commentEnd = $phpcsFile->findPrevious($find, ($currScope - 1)); + + if ($commentEnd === false) { + return; + } + + if ($tokens[$commentEnd]['code'] !== T_DOC_COMMENT) { + // Function doesn't have a comment. Let someone else warn about that. + return; + } + + $commentStart = ($phpcsFile->findPrevious(T_DOC_COMMENT, ($commentEnd - 1), null, true) + 1); + $comment = $phpcsFile->getTokensAsString($commentStart, ($commentEnd - $commentStart + 1)); + + try { + $this->commentParser = new PHP_CodeSniffer_CommentParser_FunctionCommentParser($comment, $phpcsFile); + $this->commentParser->parse(); + } catch (PHP_CodeSniffer_CommentParser_ParserException $e) { + $line = ($e->getLineWithinComment() + $commentStart); + $phpcsFile->addError($e->getMessage(), $line, 'FailedParse'); + return; + } + + // Find the position where the current function scope ends. + $currScopeEnd = 0; + if (isset($tokens[$currScope]['scope_closer']) === true) { + $currScopeEnd = $tokens[$currScope]['scope_closer']; + } + + // Find all the exception type token within the current scope. + $throwTokens = array(); + $currPos = $stackPtr; + if ($currScopeEnd !== 0) { + while ($currPos < $currScopeEnd && $currPos !== false) { + + /* + If we can't find a NEW, we are probably throwing + a variable, so we ignore it, but they still need to + provide at least one @throws tag, even through we + don't know the exception class. + */ + + $nextToken = $phpcsFile->findNext(T_WHITESPACE, ($currPos + 1), null, true); + if ($tokens[$nextToken]['code'] === T_NEW) { + $currException = $phpcsFile->findNext( + array( + T_NS_SEPARATOR, + T_STRING, + ), + $currPos, + $currScopeEnd, + false, + null, + true + ); + + if ($currException !== false) { + $endException = $phpcsFile->findNext( + array( + T_NS_SEPARATOR, + T_STRING, + ), + ($currException + 1), + $currScopeEnd, + true, + null, + true + ); + + if ($endException === false) { + $throwTokens[] = $tokens[$currException]['content']; + } else { + $throwTokens[] = $phpcsFile->getTokensAsString($currException, ($endException - $currException)); + } + }//end if + }//end if + + $currPos = $phpcsFile->findNext(T_THROW, ($currPos + 1), $currScopeEnd); + }//end while + }//end if + + // Only need one @throws tag for each type of exception thrown. + $throwTokens = array_unique($throwTokens); + sort($throwTokens); + + $throws = $this->commentParser->getThrows(); + if (empty($throws) === true) { + $error = 'Missing @throws tag in function comment'; + $phpcsFile->addError($error, $commentEnd, 'Missing'); + } else if (empty($throwTokens) === true) { + // If token count is zero, it means that only variables are being + // thrown, so we need at least one @throws tag (checked above). + // Nothing more to do. + return; + } else { + $throwTags = array(); + $lineNumber = array(); + foreach ($throws as $throw) { + $throwTags[] = $throw->getValue(); + $lineNumber[$throw->getValue()] = $throw->getLine(); + } + + $throwTags = array_unique($throwTags); + sort($throwTags); + + // Make sure @throws tag count matches throw token count. + $tokenCount = count($throwTokens); + $tagCount = count($throwTags); + if ($tokenCount !== $tagCount) { + $error = 'Expected %s @throws tag(s) in function comment; %s found'; + $data = array( + $tokenCount, + $tagCount, + ); + $phpcsFile->addError($error, $commentEnd, 'WrongNumber', $data); + return; + } else { + // Exception type in @throws tag must be thrown in the function. + foreach ($throwTags as $i => $throwTag) { + $errorPos = ($commentStart + $lineNumber[$throwTag]); + if (empty($throwTag) === false && $throwTag !== $throwTokens[$i]) { + $error = 'Expected "%s" but found "%s" for @throws tag exception'; + $data = array( + $throwTokens[$i], + $throwTag, + ); + $phpcsFile->addError($error, $errorPos, 'WrongType', $data); + } + } + } + }//end if + + }//end processTokenWithinScope() + + +}//end class +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Commenting/InlineCommentSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Commenting/InlineCommentSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Commenting/InlineCommentSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Commenting/InlineCommentSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,272 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_Commenting_InlineCommentSniff. + * + * Checks that there is adequate spacing between comments. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_Commenting_InlineCommentSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * A list of tokenizers this sniff supports. + * + * @var array + */ + public $supportedTokenizers = array( + 'PHP', + 'JS', + ); + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array( + T_COMMENT, + T_DOC_COMMENT, + ); + + }//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(); + + // If this is a function/class/interface doc block comment, skip it. + // We are only interested in inline doc block comments, which are + // not allowed. + if ($tokens[$stackPtr]['code'] === T_DOC_COMMENT) { + $nextToken = $phpcsFile->findNext( + PHP_CodeSniffer_Tokens::$emptyTokens, + ($stackPtr + 1), + null, + true + ); + + $ignore = array( + T_CLASS, + T_INTERFACE, + T_TRAIT, + T_FUNCTION, + T_PUBLIC, + T_PRIVATE, + T_PROTECTED, + T_FINAL, + T_STATIC, + T_ABSTRACT, + T_CONST, + T_OBJECT, + T_PROPERTY, + ); + + if (in_array($tokens[$nextToken]['code'], $ignore) === true) { + return; + } else { + if ($phpcsFile->tokenizerType === 'JS') { + // We allow block comments if a function is being assigned + // to a variable. + $ignore = PHP_CodeSniffer_Tokens::$emptyTokens; + $ignore[] = T_EQUAL; + $ignore[] = T_STRING; + $ignore[] = T_OBJECT_OPERATOR; + $nextToken = $phpcsFile->findNext($ignore, ($nextToken + 1), null, true); + if ($tokens[$nextToken]['code'] === T_FUNCTION) { + return; + } + } + + $prevToken = $phpcsFile->findPrevious( + PHP_CodeSniffer_Tokens::$emptyTokens, + ($stackPtr - 1), + null, + true + ); + + if ($tokens[$prevToken]['code'] === T_OPEN_TAG) { + return; + } + + // Only error once per comment. + if (substr($tokens[$stackPtr]['content'], 0, 3) === '/**') { + $error = 'Inline doc block comments are not allowed; use "/* Comment */" or "// Comment" instead'; + $phpcsFile->addError($error, $stackPtr, 'DocBlock'); + } + }//end if + }//end if + + if ($tokens[$stackPtr]['content']{0} === '#') { + $error = 'Perl-style comments are not allowed; use "// Comment" instead'; + $phpcsFile->addError($error, $stackPtr, 'WrongStyle'); + } + + // We don't want end of block comments. If the last comment is a closing + // curly brace. + $previousContent = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); + if ($tokens[$previousContent]['line'] === $tokens[$stackPtr]['line']) { + if ($tokens[$previousContent]['code'] === T_CLOSE_CURLY_BRACKET) { + return; + } + + // Special case for JS files. + if ($tokens[$previousContent]['code'] === T_COMMA + || $tokens[$previousContent]['code'] === T_SEMICOLON + ) { + $lastContent = $phpcsFile->findPrevious(T_WHITESPACE, ($previousContent - 1), null, true); + if ($tokens[$lastContent]['code'] === T_CLOSE_CURLY_BRACKET) { + return; + } + } + } + + $comment = rtrim($tokens[$stackPtr]['content']); + + // Only want inline comments. + if (substr($comment, 0, 2) !== '//') { + return; + } + + $spaceCount = 0; + for ($i = 2; $i < strlen($comment); $i++) { + if ($comment[$i] !== ' ') { + break; + } + + $spaceCount++; + } + + if ($spaceCount === 0) { + $error = 'No space before comment text; expected "// %s" but found "%s"'; + $data = array( + substr($comment, 2), + $comment, + ); + $phpcsFile->addError($error, $stackPtr, 'NoSpaceBefore', $data); + } + + if ($spaceCount > 1) { + $error = '%s spaces found before inline comment line; use block comment if you need indentation'; + $data = array( + $spaceCount, + substr($comment, (2 + $spaceCount)), + $comment, + ); + $phpcsFile->addError($error, $stackPtr, 'SpacingBefore', $data); + } + + + // The below section determines if a comment block is correctly capitalised, + // and ends in a full-stop. It will find the last comment in a block, and + // work its way up. + $nextComment = $phpcsFile->findNext(array(T_COMMENT), ($stackPtr + 1), null, false); + + if (($nextComment !== false) && (($tokens[$nextComment]['line']) === ($tokens[$stackPtr]['line'] + 1))) { + return; + } + + $topComment = $stackPtr; + $lastComment = $stackPtr; + while (($topComment = $phpcsFile->findPrevious(array(T_COMMENT), ($lastComment - 1), null, false)) !== false) { + if ($tokens[$topComment]['line'] !== ($tokens[$lastComment]['line'] - 1)) { + break; + } + + $lastComment = $topComment; + } + + $topComment = $lastComment; + $commentText = ''; + + for ($i = $topComment; $i <= $stackPtr; $i++) { + if ($tokens[$i]['code'] === T_COMMENT) { + $commentText .= trim(substr($tokens[$i]['content'], 2)); + } + } + + if ($commentText === '') { + $error = 'Blank comments are not allowed'; + $phpcsFile->addError($error, $stackPtr, 'Empty'); + return; + } + + if (preg_match('|\p{Lu}|u', $commentText[0]) === 0) { + $error = 'Inline comments must start with a capital letter'; + $phpcsFile->addError($error, $topComment, 'NotCapital'); + } + + $commentCloser = $commentText[(strlen($commentText) - 1)]; + $acceptedClosers = array( + 'full-stops' => '.', + 'exclamation marks' => '!', + 'or question marks' => '?', + ); + + if (in_array($commentCloser, $acceptedClosers) === false) { + $error = 'Inline comments must end in %s'; + $ender = ''; + foreach ($acceptedClosers as $closerName => $symbol) { + $ender .= ' '.$closerName.','; + } + + $ender = rtrim($ender, ','); + $data = array($ender); + $phpcsFile->addError($error, $stackPtr, 'InvalidEndChar', $data); + } + + // Finally, the line below the last comment cannot be empty. + $start = false; + for ($i = ($stackPtr + 1); $i < $phpcsFile->numTokens; $i++) { + if ($tokens[$i]['line'] === ($tokens[$stackPtr]['line'] + 1)) { + if ($tokens[$i]['code'] !== T_WHITESPACE) { + return; + } + } else if ($tokens[$i]['line'] > ($tokens[$stackPtr]['line'] + 1)) { + break; + } + } + + $error = 'There must be no blank line following an inline comment'; + $phpcsFile->addError($error, $stackPtr, 'SpacingAfter'); + + }//end process() + + +}//end class + + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Commenting/LongConditionClosingCommentSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Commenting/LongConditionClosingCommentSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Commenting/LongConditionClosingCommentSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Commenting/LongConditionClosingCommentSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,191 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_ControlStructures_LongConditionClosingCommentSniff. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_Commenting_LongConditionClosingCommentSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * A list of tokenizers this sniff supports. + * + * @var array + */ + public $supportedTokenizers = array( + 'PHP', + 'JS', + ); + + /** + * The openers that we are interested in. + * + * @var array(int) + */ + private static $_openers = array( + T_SWITCH, + T_IF, + T_FOR, + T_FOREACH, + T_WHILE, + T_TRY, + T_CASE, + ); + + /** + * The length that a code block must be before + * requiring a closing comment. + * + * @var int + */ + protected $lineLimit = 20; + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array(T_CLOSE_CURLY_BRACKET); + + }//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(); + + if (isset($tokens[$stackPtr]['scope_condition']) === false) { + // No scope condition. It is a function closer. + return; + } + + $startCondition = $tokens[$tokens[$stackPtr]['scope_condition']]; + $startBrace = $tokens[$tokens[$stackPtr]['scope_opener']]; + $endBrace = $tokens[$stackPtr]; + + // We are only interested in some code blocks. + if (in_array($startCondition['code'], self::$_openers) === false) { + return; + } + + if ($startCondition['code'] === T_IF) { + // If this is actually and ELSE IF, skip it as the brace + // will be checked by the original IF. + $else = $phpcsFile->findPrevious(T_WHITESPACE, ($tokens[$stackPtr]['scope_condition'] - 1), null, true); + if ($tokens[$else]['code'] === T_ELSE) { + return; + } + + // IF statements that have an ELSE block need to use + // "end if" rather than "end else" or "end elseif". + do { + $nextToken = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); + if ($tokens[$nextToken]['code'] === T_ELSE || $tokens[$nextToken]['code'] === T_ELSEIF) { + // Check for ELSE IF (2 tokens) as opposed to ELSEIF (1 token). + if ($tokens[$nextToken]['code'] === T_ELSE + && isset($tokens[$nextToken]['scope_closer']) === false + ) { + $nextToken = $phpcsFile->findNext(T_WHITESPACE, ($nextToken + 1), null, true); + if ($tokens[$nextToken]['code'] !== T_IF + || isset($tokens[$nextToken]['scope_closer']) === false + ) { + // Not an ELSE IF or is an inline ELSE IF. + break; + } + } + + // The end brace becomes the ELSE's end brace. + $stackPtr = $tokens[$nextToken]['scope_closer']; + $endBrace = $tokens[$stackPtr]; + } else { + break; + } + } while (isset($tokens[$nextToken]['scope_closer']) === true); + }//end if + + if ($startCondition['code'] === T_TRY) { + // TRY statements need to check until the end of all CATCH statements. + do { + $nextToken = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); + if ($tokens[$nextToken]['code'] === T_CATCH) { + // The end brace becomes the CATCH's end brace. + $stackPtr = $tokens[$nextToken]['scope_closer']; + $endBrace = $tokens[$stackPtr]; + } else { + break; + } + } while (isset($tokens[$nextToken]['scope_closer']) === true); + } + + $lineDifference = ($endBrace['line'] - $startBrace['line']); + + $expected = '//end '.$startCondition['content']; + $comment = $phpcsFile->findNext(array(T_COMMENT), $stackPtr, null, false); + + if (($comment === false) || ($tokens[$comment]['line'] !== $endBrace['line'])) { + if ($lineDifference >= $this->lineLimit) { + $error = 'End comment for long condition not found; expected "%s"'; + $data = array($expected); + $phpcsFile->addError($error, $stackPtr, 'Missing', $data); + } + + return; + } + + if (($comment - $stackPtr) !== 1) { + $error = 'Space found before closing comment; expected "%s"'; + $data = array($expected); + $phpcsFile->addError($error, $stackPtr, 'SpacingBefore', $data); + } + + if (trim($tokens[$comment]['content']) !== $expected) { + $found = trim($tokens[$comment]['content']); + $error = 'Incorrect closing comment; expected "%s" but found "%s"'; + $data = array( + $expected, + $found, + ); + $phpcsFile->addError($error, $stackPtr, 'Invalid', $data); + return; + } + + }//end process() + + +}//end class + + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Commenting/PostStatementCommentSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Commenting/PostStatementCommentSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Commenting/PostStatementCommentSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Commenting/PostStatementCommentSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,103 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_Commenting_PostStatementCommentSniff. + * + * Checks to ensure that there are no comments after statements. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_Commenting_PostStatementCommentSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * A list of tokenizers this sniff supports. + * + * @var array + */ + public $supportedTokenizers = array( + 'PHP', + 'JS', + ); + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array(T_COMMENT); + + }//end register() + + + /** + * Processes this sniff, 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(); + + if (substr($tokens[$stackPtr]['content'], 0, 2) !== '//') { + return; + } + + $commentLine = $tokens[$stackPtr]['line']; + $lastContent = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); + + if ($tokens[$lastContent]['line'] !== $commentLine) { + return; + } + + if ($tokens[$lastContent]['code'] === T_CLOSE_CURLY_BRACKET) { + return; + } + + // Special case for JS files. + if ($tokens[$lastContent]['code'] === T_COMMA + || $tokens[$lastContent]['code'] === T_SEMICOLON + ) { + $lastContent = $phpcsFile->findPrevious(T_WHITESPACE, ($lastContent - 1), null, true); + if ($tokens[$lastContent]['code'] === T_CLOSE_CURLY_BRACKET) { + return; + } + } + + $error = 'Comments may not appear after statements.'; + $phpcsFile->addError($error, $stackPtr, 'Found'); + + }//end process() + + +}//end class + + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,345 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +if (class_exists('PHP_CodeSniffer_Standards_AbstractVariableSniff', true) === false) { + throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_Standards_AbstractVariableSniff not found'); +} + +if (class_exists('PHP_CodeSniffer_CommentParser_MemberCommentParser', true) === false) { + throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_CommentParser_MemberCommentParser not found'); +} + +/** + * Parses and verifies the variable doc comment. + * + * Verifies that : + *
    + *
  • A variable doc comment exists.
  • + *
  • Short description ends with a full stop.
  • + *
  • There is a blank line after the short description.
  • + *
  • There is a blank line between the description and the tags.
  • + *
  • Check the order, indentation and content of each tag.
  • + *
+ * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ + +class Squiz_Sniffs_Commenting_VariableCommentSniff extends PHP_CodeSniffer_Standards_AbstractVariableSniff +{ + + /** + * The header comment parser for the current file. + * + * @var PHP_CodeSniffer_Comment_Parser_ClassCommentParser + */ + protected $commentParser = null; + + + /** + * Called to process class member vars. + * + * @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 processMemberVar(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + $this->currentFile = $phpcsFile; + $tokens = $phpcsFile->getTokens(); + $commentToken = array( + T_COMMENT, + T_DOC_COMMENT, + ); + + // Extract the var comment docblock. + $commentEnd = $phpcsFile->findPrevious($commentToken, ($stackPtr - 3)); + if ($commentEnd !== false && $tokens[$commentEnd]['code'] === T_COMMENT) { + $phpcsFile->addError('You must use "/**" style comments for a variable comment', $stackPtr, 'WrongStyle'); + return; + } else if ($commentEnd === false || $tokens[$commentEnd]['code'] !== T_DOC_COMMENT) { + $phpcsFile->addError('Missing variable doc comment', $stackPtr, 'Missing'); + return; + } else { + // Make sure the comment we have found belongs to us. + $commentFor = $phpcsFile->findNext(array(T_VARIABLE, T_CLASS, T_INTERFACE), ($commentEnd + 1)); + if ($commentFor !== $stackPtr) { + $phpcsFile->addError('Missing variable doc comment', $stackPtr, 'Missing'); + return; + } + } + + $commentStart = ($phpcsFile->findPrevious(T_DOC_COMMENT, ($commentEnd - 1), null, true) + 1); + $commentString = $phpcsFile->getTokensAsString($commentStart, ($commentEnd - $commentStart + 1)); + + // Parse the header comment docblock. + try { + $this->commentParser = new PHP_CodeSniffer_CommentParser_MemberCommentParser($commentString, $phpcsFile); + $this->commentParser->parse(); + } catch (PHP_CodeSniffer_CommentParser_ParserException $e) { + $line = ($e->getLineWithinComment() + $commentStart); + $phpcsFile->addError($e->getMessage(), $line, 'ErrorParsing'); + return; + } + + $comment = $this->commentParser->getComment(); + if (is_null($comment) === true) { + $error = 'Variable doc comment is empty'; + $phpcsFile->addError($error, $commentStart, 'Empty'); + return; + } + + // The first line of the comment should just be the /** code. + $eolPos = strpos($commentString, $phpcsFile->eolChar); + $firstLine = substr($commentString, 0, $eolPos); + if ($firstLine !== '/**') { + $error = 'The open comment tag must be the only content on the line'; + $phpcsFile->addError($error, $commentStart, 'ContentAfterOpen'); + } + + // Check for a comment description. + $short = $comment->getShortComment(); + $long = ''; + if (trim($short) === '') { + $error = 'Missing short description in variable doc comment'; + $phpcsFile->addError($error, $commentStart, 'MissingShort'); + $newlineCount = 1; + } else { + // No extra newline before short description. + $newlineCount = 0; + $newlineSpan = strspn($short, $phpcsFile->eolChar); + if ($short !== '' && $newlineSpan > 0) { + $error = 'Extra newline(s) found before variable comment short description'; + $phpcsFile->addError($error, ($commentStart + 1), 'SpacingBeforeShort'); + } + + $newlineCount = (substr_count($short, $phpcsFile->eolChar) + 1); + + // Exactly one blank line between short and long description. + $long = $comment->getLongComment(); + if (empty($long) === false) { + $between = $comment->getWhiteSpaceBetween(); + $newlineBetween = substr_count($between, $phpcsFile->eolChar); + if ($newlineBetween !== 2) { + $error = 'There must be exactly one blank line between descriptions in variable comment'; + $phpcsFile->addError($error, ($commentStart + $newlineCount + 1), 'SpacingBetween'); + } + + $newlineCount += $newlineBetween; + + $testLong = trim($long); + if (preg_match('|\p{Lu}|u', $testLong[0]) === 0) { + $error = 'Variable comment long description must start with a capital letter'; + $phpcsFile->addError($error, ($commentStart + $newlineCount), 'LongNotCapital'); + } + }//end if + + // Short description must be single line and end with a full stop. + $testShort = trim($short); + $lastChar = $testShort[(strlen($testShort) - 1)]; + if (substr_count($testShort, $phpcsFile->eolChar) !== 0) { + $error = 'Variable comment short description must be on a single line'; + $phpcsFile->addError($error, ($commentStart + 1), 'ShortSingleLine'); + } + + if (preg_match('|\p{Lu}|u', $testShort[0]) === 0) { + $error = 'Variable comment short description must start with a capital letter'; + $phpcsFile->addError($error, ($commentStart + 1), 'ShortNotCapital'); + } + + if ($lastChar !== '.') { + $error = 'Variable comment short description must end with a full stop'; + $phpcsFile->addError($error, ($commentStart + 1), 'ShortFullStop'); + } + }//end if + + // Exactly one blank line before tags. + $tags = $this->commentParser->getTagOrders(); + if (count($tags) > 1) { + $newlineSpan = $comment->getNewlineAfter(); + if ($newlineSpan !== 2) { + $error = 'There must be exactly one blank line before the tags in variable comment'; + if ($long !== '') { + $newlineCount += (substr_count($long, $phpcsFile->eolChar) - $newlineSpan + 1); + } + + $phpcsFile->addError($error, ($commentStart + $newlineCount), 'SpacingBeforeTags'); + $short = rtrim($short, $phpcsFile->eolChar.' '); + } + } + + // Check for unknown/deprecated tags. + $unknownTags = $this->commentParser->getUnknown(); + foreach ($unknownTags as $errorTag) { + // Unknown tags are not parsed, do not process further. + $error = '@%s tag is not allowed in variable comment'; + $data = array($errorTag['tag']); + $phpcsFile->addWarning($error, ($commentStart + $errorTag['line']), 'TagNotAllowed', $data); + } + + // Check each tag. + $this->processVar($commentStart, $commentEnd); + $this->processSees($commentStart); + + // The last content should be a newline and the content before + // that should not be blank. If there is more blank space + // then they have additional blank lines at the end of the comment. + $words = $this->commentParser->getWords(); + $lastPos = (count($words) - 1); + if (trim($words[($lastPos - 1)]) !== '' + || strpos($words[($lastPos - 1)], $this->currentFile->eolChar) === false + || trim($words[($lastPos - 2)]) === '' + ) { + $error = 'Additional blank lines found at end of variable comment'; + $this->currentFile->addError($error, $commentEnd, 'SpacingAfter'); + } + + }//end processMemberVar() + + + /** + * Process the var tag. + * + * @param int $commentStart The position in the stack where the comment started. + * @param int $commentEnd The position in the stack where the comment ended. + * + * @return void + */ + protected function processVar($commentStart, $commentEnd) + { + $var = $this->commentParser->getVar(); + + if ($var !== null) { + $errorPos = ($commentStart + $var->getLine()); + $index = array_keys($this->commentParser->getTagOrders(), 'var'); + + if (count($index) > 1) { + $error = 'Only 1 @var tag is allowed in variable comment'; + $this->currentFile->addError($error, $errorPos, 'DuplicateVar'); + return; + } + + if ($index[0] !== 1) { + $error = 'The @var tag must be the first tag in a variable comment'; + $this->currentFile->addError($error, $errorPos, 'VarOrder'); + } + + $content = $var->getContent(); + if (empty($content) === true) { + $error = 'Var type missing for @var tag in variable comment'; + $this->currentFile->addError($error, $errorPos, 'MissingVarType'); + return; + } else { + $suggestedType = PHP_CodeSniffer::suggestType($content); + if ($content !== $suggestedType) { + $error = 'Expected "%s"; found "%s" for @var tag in variable comment'; + $data = array( + $suggestedType, + $content, + ); + $this->currentFile->addError($error, $errorPos, 'IncorrectVarType', $data); + } + } + + $spacing = substr_count($var->getWhitespaceBeforeContent(), ' '); + if ($spacing !== 1) { + $error = '@var tag indented incorrectly; expected 1 space but found %s'; + $data = array($spacing); + $this->currentFile->addError($error, $errorPos, 'VarIndent', $data); + } + } else { + $error = 'Missing @var tag in variable comment'; + $this->currentFile->addError($error, $commentEnd, 'MissingVar'); + }//end if + + }//end processVar() + + + /** + * Process the see tags. + * + * @param int $commentStart The position in the stack where the comment started. + * + * @return void + */ + protected function processSees($commentStart) + { + $sees = $this->commentParser->getSees(); + if (empty($sees) === false) { + foreach ($sees as $see) { + $errorPos = ($commentStart + $see->getLine()); + $content = $see->getContent(); + if (empty($content) === true) { + $error = 'Content missing for @see tag in variable comment'; + $this->currentFile->addError($error, $errorPos, 'EmptySees'); + continue; + } + + $spacing = substr_count($see->getWhitespaceBeforeContent(), ' '); + if ($spacing !== 1) { + $error = '@see tag indented incorrectly; expected 1 spaces but found %s'; + $data = array($spacing); + $this->currentFile->addError($error, $errorPos, 'SeesIndent', $data); + } + } + } + + }//end processSees() + + + /** + * Called to process a normal variable. + * + * Not required for this sniff. + * + * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where this token was found. + * @param int $stackPtr The position where the double quoted + * string was found. + * + * @return void + */ + protected function processVariable(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + + }//end processVariable() + + + /** + * Called to process variables found in double quoted strings. + * + * Not required for this sniff. + * + * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where this token was found. + * @param int $stackPtr The position where the double quoted + * string was found. + * + * @return void + */ + protected function processVariableInString(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + + }//end processVariableInString() + + +}//end class +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/ControlSignatureSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/ControlSignatureSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/ControlSignatureSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/ControlSignatureSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,70 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +if (class_exists('PHP_CodeSniffer_Standards_AbstractPatternSniff', true) === false) { + throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_Standards_AbstractPatternSniff not found'); +} + +/** + * Verifies that control statements conform to their coding standards. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_ControlStructures_ControlSignatureSniff extends PHP_CodeSniffer_Standards_AbstractPatternSniff +{ + + /** + * A list of tokenizers this sniff supports. + * + * @var array + */ + public $supportedTokenizers = array( + 'PHP', + 'JS', + ); + + + /** + * Returns the patterns that this test wishes to verify. + * + * @return array(string) + */ + protected function getPatterns() + { + return array( + 'try {EOL...} catch (...) {EOL', + 'do {EOL...} while (...);EOL', + 'while (...) {EOL', + 'for (...) {EOL', + 'if (...) {EOL', + 'foreach (...) {EOL', + '} else if (...) {EOL', + '} elseif (...) {EOL', + '} else {EOL', + ); + + }//end getPatterns() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/ElseIfDeclarationSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/ElseIfDeclarationSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/ElseIfDeclarationSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/ElseIfDeclarationSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,67 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_ControlStructures_ElseIfDeclarationSniff. + * + * Verifies that there are not elseif statements. The else and the if should + * be separated by a space. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_ControlStructures_ElseIfDeclarationSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array(T_ELSEIF); + + }//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) + { + $error = 'Usage of ELSEIF not allowed; use ELSE IF instead'; + $phpcsFile->addError($error, $stackPtr, 'NotAllowed'); + + }//end process() + + +}//end class + + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/ForEachLoopDeclarationSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/ForEachLoopDeclarationSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/ForEachLoopDeclarationSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/ForEachLoopDeclarationSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,144 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_ControlStructures_ForEachLoopDeclarationSniff. + * + * Verifies that there is a space between each condition of foreach loops. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_ControlStructures_ForEachLoopDeclarationSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array(T_FOREACH); + + }//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(); + + $openingBracket = $phpcsFile->findNext(T_OPEN_PARENTHESIS, $stackPtr); + $closingBracket = $tokens[$openingBracket]['parenthesis_closer']; + + if ($tokens[($openingBracket + 1)]['code'] === T_WHITESPACE) { + $error = 'Space found after opening bracket of FOREACH loop'; + $phpcsFile->addError($error, $stackPtr, 'SpaceAfterOpen'); + } + + if ($tokens[($closingBracket - 1)]['code'] === T_WHITESPACE) { + $error = 'Space found before closing bracket of FOREACH loop'; + $phpcsFile->addError($error, $stackPtr, 'SpaceBeforeClose'); + } + + $asToken = $phpcsFile->findNext(T_AS, $openingBracket); + $content = $tokens[$asToken]['content']; + if ($content !== strtolower($content)) { + $expected = strtolower($content); + $error = 'AS keyword must be lowercase; expected "%s" but found "%s"'; + $data = array( + $expected, + $content, + ); + $phpcsFile->addError($error, $stackPtr, 'AsNotLower', $data); + } + + $doubleArrow = $phpcsFile->findNext(T_DOUBLE_ARROW, $openingBracket, $closingBracket); + + if ($doubleArrow !== false) { + if ($tokens[($doubleArrow - 1)]['code'] !== T_WHITESPACE) { + $error = 'Expected 1 space before "=>"; 0 found'; + $phpcsFile->addError($error, $stackPtr, 'NoSpaceBeforeArrow'); + } else { + if (strlen($tokens[($doubleArrow - 1)]['content']) !== 1) { + $spaces = strlen($tokens[($doubleArrow - 1)]['content']); + $error = 'Expected 1 space before "=>"; %s found'; + $data = array($spaces); + $phpcsFile->addError($error, $stackPtr, 'SpacingBeforeArrow', $data); + } + + } + + if ($tokens[($doubleArrow + 1)]['code'] !== T_WHITESPACE) { + $error = 'Expected 1 space after "=>"; 0 found'; + $phpcsFile->addError($error, $stackPtr, 'NoSpaceAfterArrow'); + } else { + if (strlen($tokens[($doubleArrow + 1)]['content']) !== 1) { + $spaces = strlen($tokens[($doubleArrow + 1)]['content']); + $error = 'Expected 1 space after "=>"; %s found'; + $data = array($spaces); + $phpcsFile->addError($error, $stackPtr, 'SpacingAfterArrow', $data); + } + + } + + }//end if + + if ($tokens[($asToken - 1)]['code'] !== T_WHITESPACE) { + $error = 'Expected 1 space before "as"; 0 found'; + $phpcsFile->addError($error, $stackPtr, 'NoSpaceBeforeAs'); + } else { + if (strlen($tokens[($asToken - 1)]['content']) !== 1) { + $spaces = strlen($tokens[($asToken - 1)]['content']); + $error = 'Expected 1 space before "as"; %s found'; + $data = array($spaces); + $phpcsFile->addError($error, $stackPtr, 'SpacingBeforeAs', $data); + } + } + + if ($tokens[($asToken + 1)]['code'] !== T_WHITESPACE) { + $error = 'Expected 1 space after "as"; 0 found'; + $phpcsFile->addError($error, $stackPtr, 'NoSpaceAfterAs'); + } else { + if (strlen($tokens[($asToken + 1)]['content']) !== 1) { + $spaces = strlen($tokens[($asToken + 1)]['content']); + $error = 'Expected 1 space after "as"; %s found'; + $data = array($spaces); + $phpcsFile->addError($error, $stackPtr, 'SpacingAfterAs', $data); + } + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/ForLoopDeclarationSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/ForLoopDeclarationSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/ForLoopDeclarationSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/ForLoopDeclarationSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,143 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_ControlStructures_ForLoopDeclarationSniff. + * + * Verifies that there is a space between each condition of for loops. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_ControlStructures_ForLoopDeclarationSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * A list of tokenizers this sniff supports. + * + * @var array + */ + public $supportedTokenizers = array( + 'PHP', + 'JS', + ); + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array(T_FOR); + + }//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(); + + $openingBracket = $phpcsFile->findNext(T_OPEN_PARENTHESIS, $stackPtr); + if ($openingBracket === false) { + $error = 'Possible parse error: no opening parenthesis for FOR keyword'; + $phpcsFile->addWarning($error, $stackPtr, 'NoOpenBracket'); + return; + } + + $closingBracket = $tokens[$openingBracket]['parenthesis_closer']; + + if ($tokens[($openingBracket + 1)]['code'] === T_WHITESPACE) { + $error = 'Space found after opening bracket of FOR loop'; + $phpcsFile->addError($error, $stackPtr, 'SpacingAfterOpen'); + } + + if ($tokens[($closingBracket - 1)]['code'] === T_WHITESPACE) { + $error = 'Space found before closing bracket of FOR loop'; + $phpcsFile->addError($error, $stackPtr, 'SpacingBeforeClose'); + } + + $firstSemicolon = $phpcsFile->findNext(T_SEMICOLON, $openingBracket, $closingBracket); + + // Check whitespace around each of the tokens. + if ($firstSemicolon !== false) { + if ($tokens[($firstSemicolon - 1)]['code'] === T_WHITESPACE) { + $error = 'Space found before first semicolon of FOR loop'; + $phpcsFile->addError($error, $stackPtr, 'SpacingBeforeFirst'); + } + + if ($tokens[($firstSemicolon + 1)]['code'] !== T_WHITESPACE) { + $error = 'Expected 1 space after first semicolon of FOR loop; 0 found'; + $phpcsFile->addError($error, $stackPtr, 'NoSpaceAfterFirst'); + } else { + if (strlen($tokens[($firstSemicolon + 1)]['content']) !== 1) { + $spaces = strlen($tokens[($firstSemicolon + 1)]['content']); + $error = 'Expected 1 space after first semicolon of FOR loop; %s found'; + $data = array($spaces); + $phpcsFile->addError($error, $stackPtr, 'SpacingAfterFirst', $data); + } + } + + $secondSemicolon = $phpcsFile->findNext(T_SEMICOLON, ($firstSemicolon + 1)); + + if ($secondSemicolon !== false) { + if ($tokens[($secondSemicolon - 1)]['code'] === T_WHITESPACE) { + $error = 'Space found before second semicolon of FOR loop'; + $phpcsFile->addError($error, $stackPtr, 'SpacingBeforeSecond'); + } + + if (($secondSemicolon + 1) !== $closingBracket + && $tokens[($secondSemicolon + 1)]['code'] !== T_WHITESPACE + ) { + $error = 'Expected 1 space after second semicolon of FOR loop; 0 found'; + $phpcsFile->addError($error, $stackPtr, 'NoSpaceAfterSecond'); + } else { + if (strlen($tokens[($secondSemicolon + 1)]['content']) !== 1) { + $spaces = strlen($tokens[($secondSemicolon + 1)]['content']); + $data = array($spaces); + if (($secondSemicolon + 2) === $closingBracket) { + $error = 'Expected no space after second semicolon of FOR loop; %s found'; + $phpcsFile->addError($error, $stackPtr, 'SpacingAfterSecondNoThird', $data); + } else { + $error = 'Expected 1 space after second semicolon of FOR loop; %s found'; + $phpcsFile->addError($error, $stackPtr, 'SpacingAfterSecond', $data); + } + } + } + }//end if + }//end if + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/InlineIfDeclarationSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/InlineIfDeclarationSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/InlineIfDeclarationSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/InlineIfDeclarationSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,136 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_ControlStructures_InlineIfDeclarationSniff. + * + * Tests the spacing of shorthand IF statements. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_ControlStructures_InlineIfDeclarationSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array(T_INLINE_THEN); + + }//end register() + + + /** + * Processes this sniff, 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 the opening bracket of the inline IF. + for ($i = ($stackPtr - 1); $i > 0; $i--) { + if (isset($tokens[$i]['parenthesis_opener']) === true + && $tokens[$i]['parenthesis_opener'] < $i + ) { + $i = $tokens[$i]['parenthesis_opener']; + continue; + } + + if ($tokens[$i]['code'] === T_OPEN_PARENTHESIS) { + break; + } + } + + if ($i <= 0) { + // Could not find the beginning of the statement. Probably not + // wrapped with brackets, so assume it ends with a semicolon. + $statementEnd = $phpcsFile->findNext(T_SEMICOLON, ($stackPtr + 1)); + } else { + $statementEnd = $tokens[$i]['parenthesis_closer']; + } + + // Make sure it's all on the same line. + if ($tokens[$statementEnd]['line'] !== $tokens[$stackPtr]['line']) { + $error = 'Inline shorthand IF statement must be declared on a single line'; + $phpcsFile->addError($error, $stackPtr, 'NotSingleLine'); + return; + } + + // Make sure there are spaces around the question mark. + $contentBefore = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); + $contentAfter = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); + if ($tokens[$contentBefore]['code'] !== T_CLOSE_PARENTHESIS) { + $error = 'Inline shorthand IF statement requires brackets around comparison'; + $phpcsFile->addError($error, $stackPtr, 'NoBrackets'); + return; + } + + $spaceBefore = ($tokens[$stackPtr]['column'] - ($tokens[$contentBefore]['column'] + strlen($tokens[$contentBefore]['content']))); + if ($spaceBefore !== 1) { + $error = 'Inline shorthand IF statement requires 1 space before THEN; %s found'; + $data = array($spaceBefore); + $phpcsFile->addError($error, $stackPtr, 'SpacingBeforeThen', $data); + } + + $spaceAfter = (($tokens[$contentAfter]['column']) - ($tokens[$stackPtr]['column'] + 1)); + if ($spaceAfter !== 1) { + $error = 'Inline shorthand IF statement requires 1 space after THEN; %s found'; + $data = array($spaceAfter); + $phpcsFile->addError($error, $stackPtr, 'SpacingAfterThen', $data); + } + + // Make sure the ELSE has the correct spacing. + $inlineElse = $phpcsFile->findNext(T_INLINE_ELSE, ($stackPtr + 1), $statementEnd, false); + $contentBefore = $phpcsFile->findPrevious(T_WHITESPACE, ($inlineElse - 1), null, true); + $contentAfter = $phpcsFile->findNext(T_WHITESPACE, ($inlineElse + 1), null, true); + + $spaceBefore = ($tokens[$inlineElse]['column'] - ($tokens[$contentBefore]['column'] + strlen($tokens[$contentBefore]['content']))); + if ($spaceBefore !== 1) { + $error = 'Inline shorthand IF statement requires 1 space before ELSE; %s found'; + $data = array($spaceBefore); + $phpcsFile->addError($error, $inlineElse, 'SpacingBeforeElse', $data); + } + + $spaceAfter = (($tokens[$contentAfter]['column']) - ($tokens[$inlineElse]['column'] + 1)); + if ($spaceAfter !== 1) { + $error = 'Inline shorthand IF statement requires 1 space after ELSE; %s found'; + $data = array($spaceAfter); + $phpcsFile->addError($error, $inlineElse, 'SpacingAfterElse', $data); + } + + }//end process() + + +}//end class + + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/LowercaseDeclarationSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/LowercaseDeclarationSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/LowercaseDeclarationSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/LowercaseDeclarationSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,86 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_ControlStructures_LowercaseDeclarationSniff. + * + * Ensures all control structure keywords are lowercase. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_ControlStructures_LowercaseDeclarationSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array( + T_IF, + T_ELSE, + T_ELSEIF, + T_FOREACH, + T_FOR, + T_DO, + T_SWITCH, + T_WHILE, + T_TRY, + T_CATCH, + ); + + }//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(); + + $content = $tokens[$stackPtr]['content']; + if ($content !== strtolower($content)) { + $error = '%s keyword must be lowercase; expected "%s" but found "%s"'; + $data = array( + strtoupper($content), + strtolower($content), + $content, + ); + $phpcsFile->addError($error, $stackPtr, 'FoundUppercase', $data); + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/SwitchDeclarationSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/SwitchDeclarationSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/SwitchDeclarationSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/SwitchDeclarationSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,259 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_ControlStructures_SwitchDeclarationSniff. + * + * Ensures all the breaks and cases are aligned correctly according to their + * parent switch's alignment and enforces other switch formatting. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_ControlStructures_SwitchDeclarationSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * A list of tokenizers this sniff supports. + * + * @var array + */ + public $supportedTokenizers = array( + 'PHP', + 'JS', + ); + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array(T_SWITCH); + + }//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(); + + // We can't process SWITCH statements unless we know where they start and end. + if (isset($tokens[$stackPtr]['scope_opener']) === false + || isset($tokens[$stackPtr]['scope_closer']) === false + ) { + return; + } + + $switch = $tokens[$stackPtr]; + $nextCase = $stackPtr; + $caseAlignment = ($switch['column'] + 4); + $caseCount = 0; + $foundDefault = false; + + while (($nextCase = $phpcsFile->findNext(array(T_CASE, T_DEFAULT, T_SWITCH), ($nextCase + 1), $switch['scope_closer'])) !== false) { + // Skip nested SWITCH statements; they are handled on their own. + if ($tokens[$nextCase]['code'] === T_SWITCH) { + $nextCase = $tokens[$nextCase]['scope_closer']; + continue; + } + + if ($tokens[$nextCase]['code'] === T_DEFAULT) { + $type = 'Default'; + $foundDefault = true; + } else { + $type = 'Case'; + $caseCount++; + } + + if ($tokens[$nextCase]['content'] !== strtolower($tokens[$nextCase]['content'])) { + $expected = strtolower($tokens[$nextCase]['content']); + $error = strtoupper($type).' keyword must be lowercase; expected "%s" but found "%s"'; + $data = array( + $expected, + $tokens[$nextCase]['content'], + ); + $phpcsFile->addError($error, $nextCase, $type.'NotLower', $data); + } + + if ($tokens[$nextCase]['column'] !== $caseAlignment) { + $error = strtoupper($type).' keyword must be indented 4 spaces from SWITCH keyword'; + $phpcsFile->addError($error, $nextCase, $type.'Indent'); + } + + if ($type === 'Case' + && ($tokens[($nextCase + 1)]['type'] !== 'T_WHITESPACE' + || $tokens[($nextCase + 1)]['content'] !== ' ') + ) { + $error = 'CASE keyword must be followed by a single space'; + $phpcsFile->addError($error, $nextCase, 'SpacingAfterCase'); + } + + $opener = $tokens[$nextCase]['scope_opener']; + if ($tokens[($opener - 1)]['type'] === 'T_WHITESPACE') { + $error = 'There must be no space before the colon in a '.strtoupper($type).' statement'; + $phpcsFile->addError($error, $nextCase, 'SpaceBeforeColon'.$type); + } + + $nextBreak = $tokens[$nextCase]['scope_closer']; + if ($tokens[$nextBreak]['code'] === T_BREAK || $tokens[$nextBreak]['code'] === T_RETURN) { + if ($tokens[$nextBreak]['scope_condition'] === $nextCase) { + // Only need to check a couple of things once, even if the + // break is shared between multiple case statements, or even + // the default case. + if ($tokens[$nextBreak]['column'] !== $caseAlignment) { + $error = 'Case breaking statement must be indented 4 spaces from SWITCH keyword'; + $phpcsFile->addError($error, $nextBreak, 'BreakIndent'); + } + + $breakLine = $tokens[$nextBreak]['line']; + $prevLine = 0; + for ($i = ($nextBreak - 1); $i > $stackPtr; $i--) { + if ($tokens[$i]['type'] !== 'T_WHITESPACE') { + $prevLine = $tokens[$i]['line']; + break; + } + } + + if ($prevLine !== ($breakLine - 1)) { + $error = 'Blank lines are not allowed before case breaking statements'; + $phpcsFile->addError($error, $nextBreak, 'SpacingBeforeBreak'); + } + + $breakLine = $tokens[$nextBreak]['line']; + $nextLine = $tokens[$tokens[$stackPtr]['scope_closer']]['line']; + $semicolon = $phpcsFile->findNext(T_SEMICOLON, $nextBreak); + for ($i = ($semicolon + 1); $i < $tokens[$stackPtr]['scope_closer']; $i++) { + if ($tokens[$i]['type'] !== 'T_WHITESPACE') { + $nextLine = $tokens[$i]['line']; + break; + } + } + + if ($type === 'Case') { + // Ensure the BREAK statement is followed by + // a single blank line, or the end switch brace. + if ($nextLine !== ($breakLine + 2) && $i !== $tokens[$stackPtr]['scope_closer']) { + $error = 'Case breaking statements must be followed by a single blank line'; + $phpcsFile->addError($error, $nextBreak, 'SpacingAfterBreak'); + } + } else { + // Ensure the BREAK statement is not followed by a blank line. + if ($nextLine !== ($breakLine + 1)) { + $error = 'Blank lines are not allowed after the DEFAULT case\'s breaking statement'; + $phpcsFile->addError($error, $nextBreak, 'SpacingAfterDefaultBreak'); + } + } + + $caseLine = $tokens[$nextCase]['line']; + $nextLine = $tokens[$nextBreak]['line']; + for ($i = ($opener + 1); $i < $nextBreak; $i++) { + if ($tokens[$i]['type'] !== 'T_WHITESPACE') { + $nextLine = $tokens[$i]['line']; + break; + } + } + + if ($nextLine !== ($caseLine + 1)) { + $error = 'Blank lines are not allowed after '.strtoupper($type).' statements'; + $phpcsFile->addError($error, $nextCase, 'SpacingAfter'.$type); + } + }//end if + + if ($tokens[$nextBreak]['code'] === T_BREAK) { + if ($type === 'Case') { + // Ensure empty CASE statements are not allowed. + // They must have some code content in them. A comment is not enough. + // But count RETURN statements as valid content if they also + // happen to close the CASE statement. + $foundContent = false; + for ($i = ($tokens[$nextCase]['scope_opener'] + 1); $i < $nextBreak; $i++) { + if ($tokens[$i]['code'] === T_CASE) { + $i = $tokens[$i]['scope_opener']; + continue; + } + + if (in_array($tokens[$i]['code'], PHP_CodeSniffer_Tokens::$emptyTokens) === false) { + $foundContent = true; + break; + } + } + + if ($foundContent === false) { + $error = 'Empty CASE statements are not allowed'; + $phpcsFile->addError($error, $nextCase, 'EmptyCase'); + } + } else { + // Ensure empty DEFAULT statements are not allowed. + // They must (at least) have a comment describing why + // the default case is being ignored. + $foundContent = false; + for ($i = ($tokens[$nextCase]['scope_opener'] + 1); $i < $nextBreak; $i++) { + if ($tokens[$i]['type'] !== 'T_WHITESPACE') { + $foundContent = true; + break; + } + } + + if ($foundContent === false) { + $error = 'Comment required for empty DEFAULT case'; + $phpcsFile->addError($error, $nextCase, 'EmptyDefault'); + } + }//end if + }//end if + } else if ($type === 'Default') { + $error = 'DEFAULT case must have a breaking statement'; + $phpcsFile->addError($error, $nextCase, 'DefaultNoBreak'); + }//end if + }//end while + + if ($foundDefault === false) { + $error = 'All SWITCH statements must contain a DEFAULT case'; + $phpcsFile->addError($error, $stackPtr, 'MissingDefault'); + } + + if ($tokens[$switch['scope_closer']]['column'] !== $switch['column']) { + $error = 'Closing brace of SWITCH statement must be aligned with SWITCH keyword'; + $phpcsFile->addError($error, $switch['scope_closer'], 'CloseBraceAlign'); + } + + if ($caseCount === 0) { + $error = 'SWITCH statements must contain at least one CASE statement'; + $phpcsFile->addError($error, $stackPtr, 'MissingCase'); + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Debug/JSLintSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Debug/JSLintSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Debug/JSLintSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Debug/JSLintSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,107 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_Debug_JSLintSniff. + * + * Runs jslint.js on the file. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_Debug_JSLintSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * A list of tokenizers this sniff supports. + * + * @var array + */ + public $supportedTokenizers = array('JS'); + + + /** + * Returns the token types that this sniff is interested in. + * + * @return array(int) + */ + public function register() + { + return array(T_OPEN_TAG); + + }//end 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. + * + * @return void + * @throws PHP_CodeSniffer_Exception If jslint.js could not be run + */ + public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + $fileName = $phpcsFile->getFilename(); + + $rhinoPath = PHP_CodeSniffer::getConfigData('rhino_path'); + $jslintPath = PHP_CodeSniffer::getConfigData('jslint_path'); + if ($rhinoPath === null || $jslintPath === null) { + return; + } + + $cmd = "$rhinoPath \"$jslintPath\" \"$fileName\""; + $msg = exec($cmd, $output, $retval); + + if (is_array($output) === true) { + $tokens = $phpcsFile->getTokens(); + + foreach ($output as $finding) { + $matches = array(); + $numMatches = preg_match('/Lint at line ([0-9]+).*:(.*)$/', $finding, $matches); + if ($numMatches === 0) { + continue; + } + + $line = (int) $matches[1]; + $message = 'jslint says: '.trim($matches[2]); + + // Find the token at the start of the line. + $lineToken = null; + foreach ($tokens as $ptr => $info) { + if ($info['line'] === $line) { + $lineToken = $ptr; + break; + } + } + + if ($lineToken !== null) { + $phpcsFile->addWarning($message, $lineToken, 'ExternalTool'); + } + }//end foreach + }//end if + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Debug/JavaScriptLintSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Debug/JavaScriptLintSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Debug/JavaScriptLintSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Debug/JavaScriptLintSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,110 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_Debug_JavaScriptLintSniff. + * + * Runs JavaScript Lint on the file. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_Debug_JavaScriptLintSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * A list of tokenizers this sniff supports. + * + * @var array + */ + public $supportedTokenizers = array('JS'); + + + /** + * Returns the token types that this sniff is interested in. + * + * @return array(int) + */ + public function register() + { + return array(T_OPEN_TAG); + + }//end 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. + * + * @return void + */ + public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + $fileName = $phpcsFile->getFilename(); + + $jslPath = PHP_CodeSniffer::getConfigData('jsl_path'); + if (is_null($jslPath) === true) { + return; + } + + $cmd = '"'.$jslPath.'" -nologo -nofilelisting -nocontext -nosummary -output-format __LINE__:__ERROR__ -process "'.$fileName.'"'; + $msg = exec($cmd, $output, $retval); + + // $exitCode is the last line of $output if no error occurs, on error it + // is numeric. Try to handle various error conditions and provide useful + // error reporting. + if ($retval === 2 || $retval === 4) { + if (is_array($output) === true) { + $msg = join('\n', $output); + } + + throw new PHP_CodeSniffer_Exception("Failed invoking JavaScript Lint, retval was [$retval], output was [$msg]"); + } + + + if (is_array($output) === true) { + $tokens = $phpcsFile->getTokens(); + + foreach ($output as $finding) { + $split = strpos($finding, ':'); + $line = substr($finding, 0, $split); + $message = substr($finding, ($split + 1)); + + // Find the token at the start of the line. + $lineToken = null; + foreach ($tokens as $ptr => $info) { + if ($info['line'] == $line) { + $lineToken = $ptr; + break; + } + } + + if ($lineToken !== null) { + $phpcsFile->addWarning(trim($message), $ptr, 'ExternalTool'); + } + }//end foreach + }//end if + + }//end process() + +}//end class +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Files/FileExtensionSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Files/FileExtensionSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Files/FileExtensionSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Files/FileExtensionSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,91 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_Files_FileExtensionSniff. + * + * Tests that the stars in a doc comment align correctly. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_Files_FileExtensionSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * 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 void + */ + public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + $tokens = $phpcsFile->getTokens(); + + // Make sure this is the first PHP open tag so we don't process + // the same file twice. + $prevOpenTag = $phpcsFile->findPrevious(T_OPEN_TAG, ($stackPtr - 1)); + if ($prevOpenTag !== false) { + return; + } + + $fileName = $phpcsFile->getFileName(); + $extension = substr($fileName, strrpos($fileName, '.')); + $nextClass = $phpcsFile->findNext(array(T_CLASS, T_INTERFACE), $stackPtr); + + if ($extension === '.php') { + if ($nextClass !== false) { + $error = '%s found in ".php" file; use ".inc" extension instead'; + $data = array(ucfirst($tokens[$nextClass]['content'])); + $phpcsFile->addError($error, $stackPtr, 'ClassFound', $data); + } + } else if ($extension === '.inc') { + if ($nextClass === false) { + $error = 'No interface or class found in ".inc" file; use ".php" extension instead'; + $phpcsFile->addError($error, $stackPtr, 'NoClass'); + } + } + + }//end process() + + +}//end class + + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Formatting/OperatorBracketSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Formatting/OperatorBracketSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Formatting/OperatorBracketSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Formatting/OperatorBracketSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,254 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_Formatting_OperationBracketSniff. + * + * Tests that all arithmetic operations are bracketed. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_Formatting_OperatorBracketSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * A list of tokenizers this sniff supports. + * + * @var array + */ + public $supportedTokenizers = array( + 'PHP', + 'JS', + ); + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return PHP_CodeSniffer_Tokens::$operators; + + }//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(); + + if ($phpcsFile->tokenizerType === 'JS' && $tokens[$stackPtr]['code'] === T_PLUS) { + // JavaScript uses the plus operator for string concatenation as well + // so we cannot accurately determine if it is a string concat or addition. + // So just ignore it. + return; + } + + // If the & is a reference, then we don't want to check for brackets. + if ($tokens[$stackPtr]['code'] === T_BITWISE_AND && $phpcsFile->isReference($stackPtr) === true) { + return; + } + + // There is one instance where brackets aren't needed, which involves + // the minus sign being used to assign a negative number to a variable. + if ($tokens[$stackPtr]['code'] === T_MINUS) { + // Check to see if we are trying to return -n. + $prev = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true); + if ($tokens[$prev]['code'] === T_RETURN) { + return; + } + + $number = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); + if ($tokens[$number]['code'] === T_LNUMBER || $tokens[$number]['code'] === T_DNUMBER) { + $previous = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); + if ($previous !== false) { + $isAssignment = in_array($tokens[$previous]['code'], PHP_CodeSniffer_Tokens::$assignmentTokens); + $isEquality = in_array($tokens[$previous]['code'], PHP_CodeSniffer_Tokens::$equalityTokens); + $isComparison = in_array($tokens[$previous]['code'], PHP_CodeSniffer_Tokens::$comparisonTokens); + if ($isAssignment === true || $isEquality === true || $isComparison === true) { + // This is a negative assignment or comparison. + // We need to check that the minus and the number are + // adjacent. + if (($number - $stackPtr) !== 1) { + $error = 'No space allowed between minus sign and number'; + $phpcsFile->addError($error, $stackPtr, 'SpacingAfterMinus'); + } + + return; + } + } + } + }//end if + + $lastBracket = false; + if (isset($tokens[$stackPtr]['nested_parenthesis']) === true) { + $parenthesis = array_reverse($tokens[$stackPtr]['nested_parenthesis'], true); + foreach ($parenthesis as $bracket => $endBracket) { + $prevToken = $phpcsFile->findPrevious(T_WHITESPACE, ($bracket - 1), null, true); + $prevCode = $tokens[$prevToken]['code']; + + if ($prevCode === T_ISSET) { + // This operation is inside an isset() call, but has + // no bracket of it's own. + break; + } + + if ($prevCode === T_STRING || $prevCode === T_SWITCH) { + // We allow very simple operations to not be bracketed. + // For example, ceil($one / $two). + $allowed = array( + T_VARIABLE, + T_LNUMBER, + T_DNUMBER, + T_STRING, + T_WHITESPACE, + T_THIS, + T_OBJECT_OPERATOR, + T_OPEN_SQUARE_BRACKET, + T_CLOSE_SQUARE_BRACKET, + T_MODULUS, + ); + + for ($prev = ($stackPtr - 1); $prev > $bracket; $prev--) { + if (in_array($tokens[$prev]['code'], $allowed) === true) { + continue; + } + + if ($tokens[$prev]['code'] === T_CLOSE_PARENTHESIS) { + $prev = $tokens[$prev]['parenthesis_opener']; + } else { + break; + } + } + + if ($prev !== $bracket) { + break; + } + + for ($next = ($stackPtr + 1); $next < $endBracket; $next++) { + if (in_array($tokens[$next]['code'], $allowed) === true) { + continue; + } + + if ($tokens[$next]['code'] === T_OPEN_PARENTHESIS) { + $next = $tokens[$next]['parenthesis_closer']; + } else { + break; + } + } + + if ($next !== $endBracket) { + break; + } + }//end if + + if (in_array($prevCode, PHP_CodeSniffer_Tokens::$scopeOpeners) === true) { + // This operation is inside a control structure like FOREACH + // or IF, but has no bracket of it's own. + // The only control structure allowed to do this is SWITCH. + if ($prevCode !== T_SWITCH) { + break; + } + } + + if ($prevCode === T_OPEN_PARENTHESIS) { + // These are two open parenthesis in a row. If the current + // one doesn't enclose the operator, go to the previous one. + if ($endBracket < $stackPtr) { + continue; + } + } + + $lastBracket = $bracket; + break; + }//end foreach + }//end if + + if ($lastBracket === false) { + // It is not in a bracketed statement at all. + $previousToken = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true, null, true); + if ($previousToken !== false) { + // A list of tokens that indicate that the token is not + // part of an arithmetic operation. + $invalidTokens = array( + T_COMMA, + T_COLON, + T_OPEN_PARENTHESIS, + T_OPEN_SQUARE_BRACKET, + T_CASE, + ); + + if (in_array($tokens[$previousToken]['code'], $invalidTokens) === false) { + $error = 'Arithmetic operation must be bracketed'; + $phpcsFile->addError($error, $stackPtr, 'MissingBrackets'); + } + + return; + } + } else if ($tokens[$lastBracket]['parenthesis_closer'] < $stackPtr) { + // There are a set of brackets in front of it that don't include it. + $error = 'Arithmetic operation must be bracketed'; + $phpcsFile->addError($error, $stackPtr, 'MissingBrackets'); + return; + } else { + // We are enclosed in a set of bracket, so the last thing to + // check is that we are not also enclosed in square brackets + // like this: ($array[$index + 1]), which is invalid. + $brackets = array( + T_OPEN_SQUARE_BRACKET, + T_CLOSE_SQUARE_BRACKET, + ); + + $squareBracket = $phpcsFile->findPrevious($brackets, ($stackPtr - 1), $lastBracket); + if ($squareBracket !== false && $tokens[$squareBracket]['code'] === T_OPEN_SQUARE_BRACKET) { + $closeSquareBracket = $phpcsFile->findNext($brackets, ($stackPtr + 1)); + if ($closeSquareBracket !== false && $tokens[$closeSquareBracket]['code'] === T_CLOSE_SQUARE_BRACKET) { + $error = 'Arithmetic operation must be bracketed'; + $phpcsFile->addError($error, $stackPtr, 'MissingBrackets'); + } + } + + return; + }//end if + + $lastAssignment = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$assignmentTokens, $stackPtr, null, false, null, true); + if ($lastAssignment !== false && $lastAssignment > $lastBracket) { + $error = 'Arithmetic operation must be bracketed'; + $phpcsFile->addError($error, $stackPtr, 'MissingBrackets'); + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Functions/FunctionDeclarationArgumentSpacingSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Functions/FunctionDeclarationArgumentSpacingSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Functions/FunctionDeclarationArgumentSpacingSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Functions/FunctionDeclarationArgumentSpacingSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,300 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_Functions_FunctionDeclarationArgumentSpacingSniff. + * + * Checks that arguments in function declarations are spaced correctly. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_Functions_FunctionDeclarationArgumentSpacingSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * How many spaces should surround the equals signs. + * + * @var int + */ + public $equalsSpacing = 0; + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array( + T_FUNCTION, + T_CLOSURE, + ); + + }//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->equalsSpacing = (int) $this->equalsSpacing; + + $tokens = $phpcsFile->getTokens(); + $openBracket = $tokens[$stackPtr]['parenthesis_opener']; + $this->processBracket($phpcsFile, $openBracket); + + if ($tokens[$stackPtr]['code'] === T_CLOSURE) { + $use = $phpcsFile->findNext(T_USE, ($tokens[$openBracket]['parenthesis_closer'] + 1), $tokens[$stackPtr]['scope_opener']); + if ($use !== false) { + $openBracket = $phpcsFile->findNext(T_OPEN_PARENTHESIS, ($use + 1), null); + $this->processBracket($phpcsFile, $openBracket); + } + } + + }//end process() + + + /** + * Processes the contents of a single set of brackets. + * + * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. + * @param int $openBracket The position of the open bracket + * in the stack passed in $tokens. + * + * @return void + */ + public function processBracket(PHP_CodeSniffer_File $phpcsFile, $openBracket) + { + $tokens = $phpcsFile->getTokens(); + $closeBracket = $tokens[$openBracket]['parenthesis_closer']; + $multiLine = ($tokens[$openBracket]['line'] !== $tokens[$closeBracket]['line']); + + $nextParam = $openBracket; + $params = array(); + while (($nextParam = $phpcsFile->findNext(T_VARIABLE, ($nextParam + 1), $closeBracket)) !== false) { + + $nextToken = $phpcsFile->findNext(T_WHITESPACE, ($nextParam + 1), ($closeBracket + 1), true); + if ($nextToken === false) { + break; + } + + $nextCode = $tokens[$nextToken]['code']; + + if ($nextCode === T_EQUAL) { + // Check parameter default spacing. + $spacesBefore = 0; + if (($nextToken - $nextParam) > 1) { + $spacesBefore = strlen($tokens[($nextParam + 1)]['content']); + } + + if ($spacesBefore !== $this->equalsSpacing) { + $error = 'Incorrect spacing between argument "%s" and equals sign; expected '.$this->equalsSpacing.' but found %s'; + $data = array( + $tokens[$nextParam]['content'], + $spacesBefore, + ); + $phpcsFile->addError($error, $nextToken, 'SpaceBeforeEquals', $data); + } + + $spacesAfter = 0; + if ($tokens[($nextToken + 1)]['code'] === T_WHITESPACE) { + $spacesAfter = strlen($tokens[($nextToken + 1)]['content']); + } + + if ($spacesAfter !== $this->equalsSpacing) { + $error = 'Incorrect spacing between default value and equals sign for argument "%s"; expected '.$this->equalsSpacing.' but found %s'; + $data = array( + $tokens[$nextParam]['content'], + $spacesAfter, + ); + $phpcsFile->addError($error, $nextToken, 'SpaceAfterDefault', $data); + } + }//end if + + // Find and check the comma (if there is one). + $nextComma = $phpcsFile->findNext(T_COMMA, ($nextParam + 1), $closeBracket); + if ($nextComma !== false) { + // Comma found. + if ($tokens[($nextComma - 1)]['code'] === T_WHITESPACE) { + $error = 'Expected 0 spaces between argument "%s" and comma; %s found'; + $data = array( + $tokens[$nextParam]['content'], + strlen($tokens[($nextComma - 1)]['content']), + ); + $phpcsFile->addError($error, $nextToken, 'SpaceBeforeComma', $data); + } + } + + // Take references into account when expecting the + // location of whitespace. + if ($phpcsFile->isReference(($nextParam - 1)) === true) { + $whitespace = ($nextParam - 2); + } else { + $whitespace = ($nextParam - 1); + } + + if (empty($params) === false) { + // This is not the first argument in the function declaration. + $arg = $tokens[$nextParam]['content']; + + if ($tokens[$whitespace]['code'] === T_WHITESPACE) { + $gap = strlen($tokens[$whitespace]['content']); + + // Before we throw an error, make sure there is no type hint. + $comma = $phpcsFile->findPrevious(T_COMMA, ($nextParam - 1)); + $nextToken = $phpcsFile->findNext(T_WHITESPACE, ($comma + 1), null, true); + if ($phpcsFile->isReference($nextToken) === true) { + $nextToken++; + } + + if ($nextToken !== $nextParam) { + // There was a type hint, so check the spacing between + // the hint and the variable as well. + $hint = $tokens[$nextToken]['content']; + + if ($gap !== 1) { + $error = 'Expected 1 space between type hint and argument "%s"; %s found'; + $data = array( + $arg, + $gap, + ); + $phpcsFile->addError($error, $nextToken, 'SpacingAfterHint', $data); + } + + if ($multiLine === false) { + if ($tokens[($comma + 1)]['code'] !== T_WHITESPACE) { + $error = 'Expected 1 space between comma and type hint "%s"; 0 found'; + $data = array($hint); + $phpcsFile->addError($error, $nextToken, 'NoSpaceBeforeHint', $data); + } else { + $gap = strlen($tokens[($comma + 1)]['content']); + if ($gap !== 1) { + $error = 'Expected 1 space between comma and type hint "%s"; %s found'; + $data = array( + $hint, + $gap, + ); + $phpcsFile->addError($error, $nextToken, 'SpacingBeforeHint', $data); + } + } + } + } else if ($gap !== 1) { + // Just make sure this is not actually an indent. + if ($tokens[$whitespace]['line'] === $tokens[($whitespace - 1)]['line']) { + $error = 'Expected 1 space between comma and argument "%s"; %s found'; + $data = array( + $arg, + $gap, + ); + $phpcsFile->addError($error, $nextToken, 'SpacingBeforeArg', $data); + } + }//end if + } else { + $error = 'Expected 1 space between comma and argument "%s"; 0 found'; + $data = array($arg); + $phpcsFile->addError($error, $nextToken, 'NoSpaceBeforeArg', $data); + }//end if + } else { + // First argument in function declaration. + if ($tokens[$whitespace]['code'] === T_WHITESPACE) { + $gap = strlen($tokens[$whitespace]['content']); + $arg = $tokens[$nextParam]['content']; + + // Before we throw an error, make sure there is no type hint. + $bracket = $phpcsFile->findPrevious(T_OPEN_PARENTHESIS, ($nextParam - 1)); + $nextToken = $phpcsFile->findNext(T_WHITESPACE, ($bracket + 1), null, true); + if ($phpcsFile->isReference($nextToken) === true) { + $nextToken++; + } + + if ($nextToken !== $nextParam) { + // There was a type hint, so check the spacing between + // the hint and the variable as well. + $hint = $tokens[$nextToken]['content']; + + if ($gap !== 1) { + $error = 'Expected 1 space between type hint and argument "%s"; %s found'; + $data = array( + $arg, + $gap, + ); + $phpcsFile->addError($error, $nextToken, 'SpacingAfterHint', $data); + } + + if ($multiLine === false + && $tokens[($bracket + 1)]['code'] === T_WHITESPACE + ) { + $error = 'Expected 0 spaces between opening bracket and type hint "%s"; %s found'; + $data = array( + $hint, + strlen($tokens[($bracket + 1)]['content']), + ); + $phpcsFile->addError($error, $nextToken, 'SpacingAfterOpenHint', $data); + } + } else if ($multiLine === false) { + $error = 'Expected 0 spaces between opening bracket and argument "%s"; %s found'; + $data = array( + $arg, + $gap, + ); + $phpcsFile->addError($error, $nextToken, 'SpacingAfterOpen', $data); + } + }//end if + }//end if + + $params[] = $nextParam; + + }//end while + + if (empty($params) === true) { + // There are no parameters for this function. + if (($closeBracket - $openBracket) !== 1) { + $error = 'Expected 0 spaces between brackets of function declaration; %s found'; + $data = array(strlen($tokens[($closeBracket - 1)]['content'])); + $phpcsFile->addError($error, $openBracket, 'SpacingBetween', $data); + } + } else if ($multiLine === false + && $tokens[($closeBracket - 1)]['code'] === T_WHITESPACE + ) { + $lastParam = array_pop($params); + $error = 'Expected 0 spaces between argument "%s" and closing bracket; %s found'; + $data = array( + $tokens[$lastParam]['content'], + strlen($tokens[($closeBracket - 1)]['content']), + ); + $phpcsFile->addError($error, $closeBracket, 'SpacingBeforeClose', $data); + } + + }//end processBracket() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Functions/FunctionDeclarationSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Functions/FunctionDeclarationSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Functions/FunctionDeclarationSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Functions/FunctionDeclarationSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,55 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +if (class_exists('PHP_CodeSniffer_Standards_AbstractPatternSniff', true) === false) { + throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_Standards_AbstractPatternSniff not found'); +} + +/** + * Squiz_Sniffs_Functions_FunctionDeclarationSniff. + * + * Checks the function declaration is correct. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_Functions_FunctionDeclarationSniff extends PHP_CodeSniffer_Standards_AbstractPatternSniff +{ + + + /** + * Returns an array of patterns to check are correct. + * + * @return array + */ + protected function getPatterns() + { + return array( + 'function abc(...);', + 'abstract function abc(...);', + ); + + }//end getPatterns() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Functions/FunctionDuplicateArgumentSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Functions/FunctionDuplicateArgumentSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Functions/FunctionDuplicateArgumentSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Functions/FunctionDuplicateArgumentSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,81 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_Functions_FunctionDuplicateArgumentSpacingSniff. + * + * Checks that duplicate arguments are not used in function declarations. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_Functions_FunctionDuplicateArgumentSniff 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(); + + $openBracket = $tokens[$stackPtr]['parenthesis_opener']; + $closeBracket = $tokens[$stackPtr]['parenthesis_closer']; + + $foundVariables = array(); + for ($i = ($openBracket + 1); $i < $closeBracket; $i++) { + if ($tokens[$i]['code'] === T_VARIABLE) { + $variable = $tokens[$i]['content']; + if (in_array($variable, $foundVariables) === true) { + $error = 'Variable "%s" appears more than once in function declaration'; + $data = array($variable); + $phpcsFile->addError($error, $i, 'Found', $data); + } else { + $foundVariables[] = $variable; + } + } + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Functions/GlobalFunctionSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Functions/GlobalFunctionSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Functions/GlobalFunctionSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Functions/GlobalFunctionSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,78 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_Functions_GlobalFunctionSniff. + * + * Tests for functions outside of classes. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_Functions_GlobalFunctionSniff 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(); + + if (empty($tokens[$stackPtr]['conditions']) === true) { + $functionName = $phpcsFile->getDeclarationName($stackPtr); + if ($functionName === null) { + return; + } + + // Special exception for __autoload as it needs to be global. + if ($functionName !== '__autoload') { + $error = 'Consider putting global function "%s" in a static class'; + $data = array($functionName); + $phpcsFile->addWarning($error, $stackPtr, 'Found', $data); + } + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Functions/LowercaseFunctionKeywordsSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Functions/LowercaseFunctionKeywordsSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Functions/LowercaseFunctionKeywordsSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Functions/LowercaseFunctionKeywordsSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,81 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_Functions_LowercaseFunctionKeywordsSniff. + * + * Ensures all class keywords are lowercase. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_Functions_LowercaseFunctionKeywordsSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array( + T_FUNCTION, + T_PUBLIC, + T_PRIVATE, + T_PROTECTED, + T_STATIC, + ); + + }//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(); + + $content = $tokens[$stackPtr]['content']; + if ($content !== strtolower($content)) { + $error = '%s keyword must be lowercase; expected "%s" but found "%s"'; + $data = array( + strtoupper($content), + strtolower($content), + $content, + ); + $phpcsFile->addError($error, $stackPtr, 'FoundUppercase', $data); + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Functions/MultiLineFunctionDeclarationSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Functions/MultiLineFunctionDeclarationSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Functions/MultiLineFunctionDeclarationSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Functions/MultiLineFunctionDeclarationSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,140 @@ + + * @copyright 2006-2012 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 + */ + +if (class_exists('PEAR_Sniffs_Functions_FunctionDeclarationSniff', true) === false) { + $error = 'Class PEAR_Sniffs_Functions_FunctionDeclarationSniff not found'; + throw new PHP_CodeSniffer_Exception($error); +} + +/** + * Squiz_Sniffs_Functions_MultiLineFunctionDeclarationSniff. + * + * Ensure single and multi-line function declarations are defined correctly. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_Functions_MultiLineFunctionDeclarationSniff extends PEAR_Sniffs_Functions_FunctionDeclarationSniff +{ + + + /** + * Processes multi-line declarations. + * + * @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 array $tokens The stack of tokens that make up + * the file. + * + * @return void + */ + public function processMultiLineDeclaration(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $tokens) + { + // We do everything the parent sniff does, and a bit more. + parent::processMultiLineDeclaration($phpcsFile, $stackPtr, $tokens); + + $openBracket = $tokens[$stackPtr]['parenthesis_opener']; + $this->processBracket($phpcsFile, $openBracket, $tokens, 'function'); + + if ($tokens[$stackPtr]['code'] !== T_CLOSURE) { + return; + } + + $use = $phpcsFile->findNext(T_USE, ($tokens[$stackPtr]['parenthesis_closer'] + 1), $tokens[$stackPtr]['scope_opener']); + if ($use === false) { + return; + } + + $openBracket = $phpcsFile->findNext(T_OPEN_PARENTHESIS, ($use + 1), null); + $this->processBracket($phpcsFile, $openBracket, $tokens, 'use'); + + // Also check spacing. + if ($tokens[($use - 1)]['code'] === T_WHITESPACE) { + $gap = strlen($tokens[($use - 1)]['content']); + } else { + $gap = 0; + } + + }//end processMultiLineDeclaration() + + + /** + * Processes the contents of a single set of brackets. + * + * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. + * @param int $openBracket The position of the open bracket + * in the stack passed in $tokens. + * @param array $tokens The stack of tokens that make up + * the file. + * @param string $type The type of the token the brackets + * belong to (function or use). + * + * @return void + */ + public function processBracket(PHP_CodeSniffer_File $phpcsFile, $openBracket, $tokens, $type='function') + { + $errorPrefix = ''; + if ($type === 'use') { + $errorPrefix = 'Use'; + } + + $closeBracket = $tokens[$openBracket]['parenthesis_closer']; + + // The open bracket should be the last thing on the line. + if ($tokens[$openBracket]['line'] !== $tokens[$closeBracket]['line']) { + $next = $phpcsFile->findNext(T_WHITESPACE, ($openBracket + 1), null, true); + if ($tokens[$next]['line'] !== ($tokens[$openBracket]['line'] + 1)) { + $error = 'The first parameter of a multi-line '.$type.' declaration must be on the line after the opening bracket'; + $phpcsFile->addError($error, $next, $errorPrefix.'FirstParamSpacing'); + } + } + + // Each line between the brackets should contain a single parameter. + $lastCommaLine = null; + for ($i = ($openBracket + 1); $i < $closeBracket; $i++) { + // Skip brackets, like arrays, as they can contain commas. + if (isset($tokens[$i]['parenthesis_opener']) === true) { + $i = $tokens[$i]['parenthesis_closer']; + continue; + } + + if ($tokens[$i]['code'] === T_COMMA) { + if ($lastCommaLine !== null && $lastCommaLine === $tokens[$i]['line']) { + $error = 'Multi-line '.$type.' declarations must define one parameter per line'; + $phpcsFile->addError($error, $i, $errorPrefix.'OneParamPerLine'); + } else { + // Comma must be the last thing on the line. + $next = $phpcsFile->findNext(T_WHITESPACE, ($i + 1), null, true); + if ($tokens[$next]['line'] !== ($tokens[$i]['line'] + 1)) { + $error = 'Commas in multi-line '.$type.' declarations must be the last content on a line'; + $phpcsFile->addError($error, $next, $errorPrefix.'ContentAfterComma'); + } + } + + $lastCommaLine = $tokens[$i]['line']; + } + } + + }//end processBracket() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/NamingConventions/ConstantCaseSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/NamingConventions/ConstantCaseSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/NamingConventions/ConstantCaseSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/NamingConventions/ConstantCaseSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,65 @@ + + * @copyright 2006-2012 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 + */ + +if (class_exists('Generic_Sniffs_PHP_LowerCaseConstantSniff', true) === false) { + $error = 'Class Generic_Sniffs_PHP_LowerCaseConstantSniff not found'; + throw new PHP_CodeSniffer_Exception($error); +} + +if (class_exists('Generic_Sniffs_PHP_UpperCaseConstantSniff', true) === false) { + $error = 'Class Generic_Sniffs_PHP_UpperCaseConstantSniff not found'; + throw new PHP_CodeSniffer_Exception($error); +} + +/** + * Squiz_Sniffs_NamingConventions_ConstantCaseSniff. + * + * Ensures TRUE, FALSE and NULL are uppercase for PHP and lowercase for JS. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_NamingConventions_ConstantCaseSniff extends Generic_Sniffs_PHP_LowerCaseConstantSniff +{ + + + /** + * Processes this sniff, 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) + { + if ($phpcsFile->tokenizerType === 'JS') { + parent::process($phpcsFile, $stackPtr); + } else { + $sniff = new Generic_Sniffs_PHP_UpperCaseConstantSniff; + $sniff->process($phpcsFile, $stackPtr); + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/NamingConventions/ValidFunctionNameSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/NamingConventions/ValidFunctionNameSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/NamingConventions/ValidFunctionNameSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/NamingConventions/ValidFunctionNameSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,74 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +if (class_exists('PEAR_Sniffs_NamingConventions_ValidFunctionNameSniff', true) === false) { + throw new PHP_CodeSniffer_Exception('Class PEAR_Sniffs_NamingConventions_ValidFunctionNameSniff not found'); +} + +/** + * Squiz_Sniffs_NamingConventions_ValidFunctionNameSniff. + * + * Ensures method names are correct depending on whether they are public + * or private, and that functions are named correctly. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_NamingConventions_ValidFunctionNameSniff extends PEAR_Sniffs_NamingConventions_ValidFunctionNameSniff +{ + + + /** + * Processes the tokens outside the scope. + * + * @param PHP_CodeSniffer_File $phpcsFile The file being processed. + * @param int $stackPtr The position where this token was + * found. + * + * @return void + */ + protected function processTokenOutsideScope(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + $functionName = $phpcsFile->getDeclarationName($stackPtr); + if ($functionName === null) { + return; + } + + $errorData = array($functionName); + + // Does this function claim to be magical? + if (preg_match('|^__|', $functionName) !== 0) { + $error = 'Function name "%s" is invalid; only PHP magic methods should be prefixed with a double underscore'; + $phpcsFile->addError($error, $stackPtr, 'DoubleUnderscore', $errorData); + return; + } + + if (PHP_CodeSniffer::isCamelCaps($functionName, false, true, false) === false) { + $error = 'Function name "%s" is not in camel caps format'; + $phpcsFile->addError($error, $stackPtr, 'NotCamelCaps', $errorData); + } + + }//end processTokenOutsideScope() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/NamingConventions/ValidVariableNameSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/NamingConventions/ValidVariableNameSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/NamingConventions/ValidVariableNameSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/NamingConventions/ValidVariableNameSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,241 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +if (class_exists('PHP_CodeSniffer_Standards_AbstractVariableSniff', true) === false) { + throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_Standards_AbstractVariableSniff not found'); +} + +/** + * Squiz_Sniffs_NamingConventions_ValidVariableNameSniff. + * + * Checks the naming of variables and member variables. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_NamingConventions_ValidVariableNameSniff extends PHP_CodeSniffer_Standards_AbstractVariableSniff +{ + + /** + * Tokens to ignore so that we can find a DOUBLE_COLON. + * + * @var array + */ + private $_ignore = array( + T_WHITESPACE, + T_COMMENT, + ); + + + /** + * 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 + */ + protected function processVariable(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + $tokens = $phpcsFile->getTokens(); + $varName = ltrim($tokens[$stackPtr]['content'], '$'); + + $phpReservedVars = array( + '_SERVER', + '_GET', + '_POST', + '_REQUEST', + '_SESSION', + '_ENV', + '_COOKIE', + '_FILES', + 'GLOBALS', + ); + + // If it's a php reserved var, then its ok. + if (in_array($varName, $phpReservedVars) === true) { + return; + } + + $objOperator = $phpcsFile->findNext(array(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(array(T_WHITESPACE), ($objOperator + 1), null, true); + if ($tokens[$var]['code'] === T_STRING) { + $bracket = $objOperator = $phpcsFile->findNext(array(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 (PHP_CodeSniffer::isCamelCaps($objVarName, false, true, false) === false) { + $error = 'Variable "%s" is not in valid camel caps format'; + $data = array($originalVarName); + $phpcsFile->addError($error, $var, 'NotCamelCaps', $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(array(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, array(T_CLASS, T_INTERFACE)); + } + + if ($inClass === true) { + $varName = substr($varName, 1); + } + } + + if (PHP_CodeSniffer::isCamelCaps($varName, false, true, false) === false) { + $error = 'Variable "%s" is not in valid camel caps format'; + $data = array($originalVarName); + $phpcsFile->addError($error, $stackPtr, 'NotCamelCaps', $data); + } + + }//end processVariable() + + + /** + * Processes class member variables. + * + * @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 + */ + protected function processMemberVar(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + $tokens = $phpcsFile->getTokens(); + + $varName = ltrim($tokens[$stackPtr]['content'], '$'); + $memberProps = $phpcsFile->getMemberProperties($stackPtr); + if (empty($memberProps) === true) { + // Couldn't get any info about this variable, which + // generally means it is invalid or possibly has a parse + // error. Any errors will be reported by the core, so + // we can ignore it. + return; + } + + $public = ($memberProps['scope'] !== 'private'); + $errorData = array($varName); + + if ($public === true) { + if (substr($varName, 0, 1) === '_') { + $error = '%s member variable "%s" must not contain a leading underscore'; + $data = array( + ucfirst($memberProps['scope']), + $errorData[0], + ); + $phpcsFile->addError($error, $stackPtr, 'PublicHasUnderscore', $data); + return; + } + } else { + if (substr($varName, 0, 1) !== '_') { + $error = 'Private member variable "%s" must contain a leading underscore'; + $phpcsFile->addError($error, $stackPtr, 'PrivateNoUnderscore', $errorData); + return; + } + } + + if (PHP_CodeSniffer::isCamelCaps($varName, false, $public, false) === false) { + $error = 'Variable "%s" is not in valid camel caps format'; + $phpcsFile->addError($error, $stackPtr, 'MemberNotCamelCaps', $errorData); + } + + }//end processMemberVar() + + + /** + * Processes the variable found within a double quoted string. + * + * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the double quoted + * string. + * + * @return void + */ + protected function processVariableInString(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + $tokens = $phpcsFile->getTokens(); + + $phpReservedVars = array( + '_SERVER', + '_GET', + '_POST', + '_REQUEST', + '_SESSION', + '_ENV', + '_COOKIE', + '_FILES', + 'GLOBALS', + ); + 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; + } + + // 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) === '_') { + if ($phpcsFile->hasCondition($stackPtr, array(T_CLASS, T_INTERFACE)) === true) { + $varName = substr($varName, 1); + } + } + + if (PHP_CodeSniffer::isCamelCaps($varName, false, true, false) === false) { + $varName = $matches[0]; + $error = 'Variable "%s" is not in valid camel caps format'; + $data = array($originalVarName); + $phpcsFile->addError($error, $stackPtr, 'StringNotCamelCaps', $data); + + } + } + }//end if + + }//end processVariableInString() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Objects/DisallowObjectStringIndexSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Objects/DisallowObjectStringIndexSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Objects/DisallowObjectStringIndexSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Objects/DisallowObjectStringIndexSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,98 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Ensures that object indexes are written in dot notation. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Sertan Danis + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_Objects_DisallowObjectStringIndexSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * A list of tokenizers this sniff supports. + * + * @var array + */ + public $supportedTokenizers = array('JS'); + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array(T_OPEN_SQUARE_BRACKET); + + }//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(); + + // Check if the next non whitespace token is a string. + $index = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); + if ($tokens[$index]['code'] !== T_CONSTANT_ENCAPSED_STRING) { + return; + } + + // Make sure it is the only thing in the square brackets. + $next = $phpcsFile->findNext(T_WHITESPACE, ($index + 1), null, true); + if ($tokens[$next]['code'] !== T_CLOSE_SQUARE_BRACKET) { + return; + } + + // Allow indexes that have dots in them because we can't write + // them in dot notation. + $content = trim($tokens[$index]['content'], '"\' '); + if (strpos($content, '.') !== false) { + return; + } + + // Also ignore reserved words. + if ($content === 'super') { + return; + } + + // Token before the opening square bracket cannot be a var name. + $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); + if ($tokens[$prev]['code'] === T_STRING) { + $error = 'Object indexes must be written in dot notation'; + $phpcsFile->addError($error, $prev, 'Found'); + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Objects/ObjectInstantiationSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Objects/ObjectInstantiationSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Objects/ObjectInstantiationSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Objects/ObjectInstantiationSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,83 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_Objects_ObjectInstantiationSniff. + * + * Ensures objects are assigned to a variable when instantiated. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_Objects_ObjectInstantiationSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Registers the token types that this sniff wishes to listen to. + * + * @return array + */ + public function register() + { + return array(T_NEW); + + }//end register() + + + /** + * Process the tokens that this sniff is listening for. + * + * @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(); + + $allowedTokens = PHP_CodeSniffer_Tokens::$emptyTokens; + $allowedTokens[] = T_BITWISE_AND; + + $prev = $phpcsFile->findPrevious($allowedTokens, ($stackPtr - 1), null, true); + + $allowedTokens = array( + T_EQUAL, + T_DOUBLE_ARROW, + T_THROW, + T_RETURN, + T_INLINE_THEN, + T_INLINE_ELSE, + ); + + if (in_array($tokens[$prev]['code'], $allowedTokens) === false) { + $error = 'New objects must be assigned to a variable'; + $phpcsFile->addError($error, $stackPtr, 'NotAssigned'); + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Objects/ObjectMemberCommaSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Objects/ObjectMemberCommaSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Objects/ObjectMemberCommaSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Objects/ObjectMemberCommaSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,84 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_Objects_ObjectInstantiationSniff. + * + * Ensures objects are assigned to a variable when instantiated. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_Objects_ObjectMemberCommaSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * A list of tokenizers this sniff supports. + * + * @var array + */ + public $supportedTokenizers = array('JS'); + + + /** + * Registers the token types that this sniff wishes to listen to. + * + * @return array + */ + public function register() + { + return array(T_CLOSE_CURLY_BRACKET); + + }//end register() + + + /** + * Process the tokens that this sniff is listening for. + * + * @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(); + + // Only interested in orphaned braces (which are objects) + // and object definitions. + if (isset($tokens[$stackPtr]['scope_condition']) === true) { + $condition = $tokens[$stackPtr]['scope_condition']; + if ($tokens[$condition]['code'] !== T_OBJECT) { + return; + } + } + + $prev = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true); + if ($tokens[$prev]['code'] === T_COMMA) { + $error = 'Last member of object must not be followed by a comma'; + $phpcsFile->addError($error, $prev, 'Missing'); + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Operators/ComparisonOperatorUsageSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Operators/ComparisonOperatorUsageSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Operators/ComparisonOperatorUsageSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Operators/ComparisonOperatorUsageSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,209 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * A Sniff to enforce the use of IDENTICAL type operators rather than EQUAL operators. + * + * The use of === true is enforced over implicit true statements, + * for example: + * + * + * if ($a) + * { + * ... + * } + * + * + * should be: + * + * + * if ($a === true) + * { + * ... + * } + * + * + * It also enforces the use of === false over ! operators. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_Operators_ComparisonOperatorUsageSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * A list of tokenizers this sniff supports. + * + * @var array + */ + public $supportedTokenizers = array( + 'PHP', + 'JS', + ); + + /** + * A list of valid comparison operators. + * + * @var array + */ + private static $_validOps = array( + T_IS_IDENTICAL, + T_IS_NOT_IDENTICAL, + T_LESS_THAN, + T_GREATER_THAN, + T_IS_GREATER_OR_EQUAL, + T_IS_SMALLER_OR_EQUAL, + T_INSTANCEOF, + ); + + /** + * A list of invalid operators with their alternatives. + * + * @var array(int => string) + */ + private static $_invalidOps = array( + 'PHP' => array( + T_IS_EQUAL => '===', + T_IS_NOT_EQUAL => '!==', + T_BOOLEAN_NOT => '=== FALSE', + ), + 'JS' => array( + T_IS_EQUAL => '===', + T_IS_NOT_EQUAL => '!==', + ), + ); + + + /** + * Registers the token types that this sniff wishes to listen to. + * + * @return array + */ + public function register() + { + return array( + T_IF, + T_INLINE_THEN, + ); + + }//end register() + + + /** + * Process the tokens that this sniff is listening for. + * + * @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(); + $tokenizer = $phpcsFile->tokenizerType; + + if ($tokens[$stackPtr]['code'] === T_INLINE_THEN) { + $end = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true); + if ($tokens[$end]['code'] !== T_CLOSE_PARENTHESIS) { + // This inline IF statement does not have its condition + // bracketed, so we need to guess where it starts. + for ($i = ($end - 1); $i >= 0; $i--) { + if ($tokens[$i]['code'] === T_SEMICOLON) { + // Stop here as we assume it is the end + // of the previous statement. + break; + } else if ($tokens[$i]['code'] === T_OPEN_TAG) { + // Stop here as this is the start of the file. + break; + } else if ($tokens[$i]['code'] === T_CLOSE_CURLY_BRACKET) { + // Stop if this is the closing brace of + // a code block. + if (isset($tokens[$i]['scope_opener']) === true) { + break; + } + } else if ($tokens[$i]['code'] === T_OPEN_CURLY_BRACKET) { + // Stop if this is the opening brace of + // a code block. + if (isset($tokens[$i]['scope_closer']) === true) { + break; + } + } + }//end for + + $start = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($i + 1), null, true); + } else { + $start = $tokens[$end]['parenthesis_opener']; + } + } else { + $start = $tokens[$stackPtr]['parenthesis_opener']; + $end = $tokens[$stackPtr]['parenthesis_closer']; + } + + $requiredOps = 0; + $foundOps = 0; + + for ($i = $start; $i <= $end; $i++) { + $type = $tokens[$i]['code']; + if (in_array($type, array_keys(self::$_invalidOps[$tokenizer])) === true) { + $error = 'Operator %s prohibited; use %s instead'; + $data = array( + $tokens[$i]['content'], + self::$_invalidOps[$tokenizer][$type], + ); + $phpcsFile->addError($error, $i, 'NotAllowed', $data); + $foundOps++; + } else if (in_array($type, self::$_validOps) === true) { + $foundOps++; + } + + if ($phpcsFile->tokenizerType !== 'JS') { + if ($tokens[$i]['code'] === T_BOOLEAN_AND || $tokens[$i]['code'] === T_BOOLEAN_OR) { + $requiredOps++; + + // If we get to here and we have not found the right number of + // comparison operators, then we must have had an implicit + // true operation ie. if ($a) instead of the required + // if ($a === true), so let's add an error. + if ($requiredOps !== $foundOps) { + $error = 'Implicit true comparisons prohibited; use === TRUE instead'; + $phpcsFile->addError($error, $stackPtr, 'ImplicitTrue'); + $foundOps++; + } + } + }//end if + }//end for + + $requiredOps++; + + if ($phpcsFile->tokenizerType !== 'JS') { + if ($foundOps < $requiredOps) { + $error = 'Implicit true comparisons prohibited; use === TRUE instead'; + $phpcsFile->addError($error, $stackPtr, 'ImplicitTrue'); + } + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,234 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_Operators_IncrementDecrementUsageSniff. + * + * Tests that the ++ operators are used when possible and not + * used when it makes the code confusing. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_Operators_IncrementDecrementUsageSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array( + T_EQUAL, + T_PLUS_EQUAL, + T_MINUS_EQUAL, + T_INC, + T_DEC, + ); + + }//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(); + + if ($tokens[$stackPtr]['code'] === T_INC || $tokens[$stackPtr]['code'] === T_DEC) { + $this->processIncDec($phpcsFile, $stackPtr); + } else { + $this->processAssignment($phpcsFile, $stackPtr); + } + + }//end process() + + + /** + * Checks to ensure increment and decrement operators are not confusing. + * + * @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 + */ + protected function processIncDec(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + $tokens = $phpcsFile->getTokens(); + + // Work out where the variable is so we know where to + // start looking for other operators. + if ($tokens[($stackPtr - 1)]['code'] === T_VARIABLE) { + $start = ($stackPtr + 1); + } else { + $start = ($stackPtr + 2); + } + + $next = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $start, null, true); + if ($next === false) { + return; + } + + if (in_array($tokens[$next]['code'], PHP_CodeSniffer_Tokens::$arithmeticTokens) === true) { + $error = 'Increment and decrement operators cannot be used in an arithmetic operation'; + $phpcsFile->addError($error, $stackPtr, 'NotAllowed'); + return; + } + + $prev = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($start - 3), null, true); + if ($prev === false) { + return; + } + + // Check if this is in a string concat. + if ($tokens[$next]['code'] === T_STRING_CONCAT || $tokens[$prev]['code'] === T_STRING_CONCAT) { + $error = 'Increment and decrement operators must be bracketed when used in string concatenation'; + $phpcsFile->addError($error, $stackPtr, 'NoBrackets'); + } + + }//end processIncDec() + + + /** + * Checks to ensure increment and decrement operators are used. + * + * @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 + */ + protected function processAssignment(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + $tokens = $phpcsFile->getTokens(); + + $assignedVar = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); + // Not an assignment, return. + if ($tokens[$assignedVar]['code'] !== T_VARIABLE) { + return; + } + + $statementEnd = $phpcsFile->findNext(array(T_SEMICOLON, T_CLOSE_PARENTHESIS, T_CLOSE_SQUARE_BRACKET, T_CLOSE_CURLY_BRACKET), $stackPtr); + + // If there is anything other than variables, numbers, spaces or operators we need to return. + $noiseTokens = $phpcsFile->findNext(array(T_LNUMBER, T_VARIABLE, T_WHITESPACE, T_PLUS, T_MINUS, T_OPEN_PARENTHESIS), ($stackPtr + 1), $statementEnd, true); + + if ($noiseTokens !== false) { + return; + } + + // If we are already using += or -=, we need to ignore + // the statement if a variable is being used. + if ($tokens[$stackPtr]['code'] !== T_EQUAL) { + $nextVar = $phpcsFile->findNext(T_VARIABLE, ($stackPtr + 1), $statementEnd); + if ($nextVar !== false) { + return; + } + } + + if ($tokens[$stackPtr]['code'] === T_EQUAL) { + $nextVar = ($stackPtr + 1); + $previousVariable = ($stackPtr + 1); + $variableCount = 0; + while (($nextVar = $phpcsFile->findNext(T_VARIABLE, ($nextVar + 1), $statementEnd)) !== false) { + $previousVariable = $nextVar; + $variableCount++; + } + + if ($variableCount !== 1) { + return; + } + + $nextVar = $previousVariable; + if ($tokens[$nextVar]['content'] !== $tokens[$assignedVar]['content']) { + return; + } + } + + // We have only one variable, and it's the same as what is being assigned, + // so we need to check what is being added or subtracted. + $nextNumber = ($stackPtr + 1); + $previousNumber = ($stackPtr + 1); + $numberCount = 0; + while (($nextNumber = $phpcsFile->findNext(array(T_LNUMBER), ($nextNumber + 1), $statementEnd, false)) !== false) { + $previousNumber = $nextNumber; + $numberCount++; + } + + if ($numberCount !== 1) { + return; + } + + $nextNumber = $previousNumber; + if ($tokens[$nextNumber]['content'] === '1') { + if ($tokens[$stackPtr]['code'] === T_EQUAL) { + $opToken = $phpcsFile->findNext(array(T_PLUS, T_MINUS), ($nextVar + 1), $statementEnd); + if ($opToken === false) { + // Operator was before the variable, like: + // $var = 1 + $var; + // So we ignore it. + return; + } + + $operator = $tokens[$opToken]['content']; + } else { + $operator = substr($tokens[$stackPtr]['content'], 0, 1); + } + + // If we are adding or subtracting negative value, the operator + // needs to be reversed. + if ($tokens[$stackPtr]['code'] !== T_EQUAL) { + $negative = $phpcsFile->findPrevious(T_MINUS, ($nextNumber - 1), $stackPtr); + if ($negative !== false) { + $operator = ($operator === '+') ? '-' : '+'; + } + } + + $expected = $tokens[$assignedVar]['content'].$operator.$operator; + $found = $phpcsFile->getTokensAsString($assignedVar, ($statementEnd - $assignedVar + 1)); + + if ($operator === '+') { + $error = 'Increment'; + } else { + $error = 'Decrement'; + } + + $error .= " operators should be used where possible; found \"$found\" but expected \"$expected\""; + $phpcsFile->addError($error, $stackPtr); + }//end if + + }//end processAssignment() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Operators/ValidLogicalOperatorsSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Operators/ValidLogicalOperatorsSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Operators/ValidLogicalOperatorsSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Operators/ValidLogicalOperatorsSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,87 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_Operators_ValidLogicalOperatorsSniff. + * + * Checks to ensure that the logical operators 'and' and 'or' are not used. + * Use the && and || operators instead. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_Operators_ValidLogicalOperatorsSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array( + T_LOGICAL_AND, + T_LOGICAL_OR, + T_LOGICAL_XOR, + ); + + }//end register() + + + /** + * Processes this test, when one of its tokens is encountered. + * + * @param PHP_CodeSniffer_File $phpcsFile The current 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(); + + $replacements = array( + 'and' => '&&', + 'or' => '||', + 'xor' => '^', + ); + + $operator = strtolower($tokens[$stackPtr]['content']); + if (isset($replacements[$operator]) === false) { + return; + } + + $error = 'Logical operator "%s" is prohibited; use "%s" instead'; + $data = array( + $operator, + $replacements[$operator], + ); + $phpcsFile->addError($error, $stackPtr, 'NotAllowed', $data); + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/PHP/CommentedOutCodeSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/PHP/CommentedOutCodeSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/PHP/CommentedOutCodeSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/PHP/CommentedOutCodeSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,214 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_PHP_CommentedOutCodeSniff. + * + * Warn about commented out code. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_PHP_CommentedOutCodeSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * A list of tokenizers this sniff supports. + * + * @var array + */ + public $supportedTokenizers = array( + 'PHP', + 'CSS', + ); + + /** + * If a comment is more than $maxPercentage% code, a warning will be shown. + * + * @var int + */ + public $maxPercentage = 35; + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return PHP_CodeSniffer_Tokens::$commentTokens; + + }//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(); + + // Process whole comment blocks at once, so skip all but the first token. + if ($stackPtr > 0 && $tokens[$stackPtr]['code'] === $tokens[($stackPtr - 1)]['code']) { + return; + } + + // Ignore comments at the end of code blocks. + if (substr($tokens[$stackPtr]['content'], 0, 6) === '//end ') { + return; + } + + $content = ''; + if ($phpcsFile->tokenizerType === 'PHP') { + $content = 'numTokens; $i++) { + if ($tokens[$stackPtr]['code'] !== $tokens[$i]['code']) { + break; + } + + /* + Trim as much off the comment as possible so we don't + have additional whitespace tokens or comment tokens + */ + + $tokenContent = trim($tokens[$i]['content']); + + if (substr($tokenContent, 0, 2) === '//') { + $tokenContent = substr($tokenContent, 2); + } + + if (substr($tokenContent, 0, 1) === '#') { + $tokenContent = substr($tokenContent, 1); + } + + if (substr($tokenContent, 0, 3) === '/**') { + $tokenContent = substr($tokenContent, 3); + } + + if (substr($tokenContent, 0, 2) === '/*') { + $tokenContent = substr($tokenContent, 2); + } + + if (substr($tokenContent, -2) === '*/') { + $tokenContent = substr($tokenContent, 0, -2); + } + + if (substr($tokenContent, 0, 1) === '*') { + $tokenContent = substr($tokenContent, 1); + } + + $content .= $tokenContent.$phpcsFile->eolChar; + }//end for + + $content = trim($content); + + if ($phpcsFile->tokenizerType === 'PHP') { + $content .= ' ?>'; + } + + // Quite a few comments use multiple dashes, equals signs etc + // to frame comments and licence headers. + $content = preg_replace('/[-=*]+/', '-', $content); + + $stringTokens = PHP_CodeSniffer_File::tokenizeString($content, $phpcsFile->tokenizer, $phpcsFile->eolChar); + + $emptyTokens = array( + T_WHITESPACE, + T_STRING, + T_STRING_CONCAT, + T_ENCAPSED_AND_WHITESPACE, + T_NONE, + ); + + $numTokens = count($stringTokens); + + /* + We know what the first two and last two tokens should be + (because we put them there) so ignore this comment if those + tokens were not parsed correctly. It obviously means this is not + valid code. + */ + + // First token is always the opening PHP tag. + if ($stringTokens[0]['code'] !== T_OPEN_TAG) { + return; + } + + // Last token is always the closing PHP tag. + if ($stringTokens[($numTokens - 1)]['code'] !== T_CLOSE_TAG) { + return; + } + + // Second last token is always whitespace or a comment, depending + // on the code inside the comment. + if (in_array($stringTokens[($numTokens - 2)]['code'], PHP_CodeSniffer_Tokens::$emptyTokens) === false) { + return; + } + + $numComment = 0; + $numCode = 0; + + for ($i = 0; $i < $numTokens; $i++) { + if (in_array($stringTokens[$i]['code'], $emptyTokens) === true) { + // Looks like comment. + $numComment++; + } else { + // Looks like code. + $numCode++; + } + } + + // We subtract 3 from the token number so we ignore the start/end tokens + // and their surrounding whitespace. We take 2 off the number of code + // tokens so we ignore the start/end tokens. + if ($numTokens > 3) { + $numTokens -= 3; + } + + if ($numCode >= 2) { + $numCode -= 2; + } + + $percentCode = ceil((($numCode / $numTokens) * 100)); + if ($percentCode > $this->maxPercentage) { + // Just in case. + $percentCode = min(100, $percentCode); + + $error = 'This comment is %s%% valid code; is this commented out code?'; + $data = array($percentCode); + $phpcsFile->addWarning($error, $stackPtr, 'Found', $data); + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/PHP/DisallowComparisonAssignmentSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/PHP/DisallowComparisonAssignmentSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/PHP/DisallowComparisonAssignmentSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/PHP/DisallowComparisonAssignmentSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,119 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_PHP_DisallowComparisonAssignmentSniff. + * + * Ensures that the value of a comparison is not assigned to a variable. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_PHP_DisallowComparisonAssignmentSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array(T_EQUAL); + + }//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(); + + // Ignore default value assignments in function definitions. + $function = $phpcsFile->findPrevious(T_FUNCTION, ($stackPtr - 1)); + if ($function !== false) { + $opener = $tokens[$function]['parenthesis_opener']; + $closer = $tokens[$function]['parenthesis_closer']; + if ($opener < $stackPtr && $closer > $stackPtr) { + return; + } + } + + // Ignore values in array definitions. + $array = $phpcsFile->findNext( + T_ARRAY, + ($stackPtr + 1), + null, + false, + null, + true + ); + + if ($array !== false) { + return; + } + + // Ignore function calls. + $ignore = array( + T_STRING, + T_WHITESPACE, + T_OBJECT_OPERATOR, + ); + + $next = $phpcsFile->findNext($ignore, ($stackPtr + 1), null, true); + if ($tokens[$next]['code'] === T_OPEN_PARENTHESIS + && $tokens[($next - 1)]['code'] === T_STRING + ) { + // Code will look like: $var = myFunction( + // and will be ignored. + return; + } + + $endStatement = $phpcsFile->findNext(T_SEMICOLON, ($stackPtr + 1)); + for ($i = ($stackPtr + 1); $i < $endStatement; $i++) { + if (in_array($tokens[$i]['code'], PHP_CodeSniffer_Tokens::$comparisonTokens) === true) { + $error = 'The value of a comparison must not be assigned to a variable'; + $phpcsFile->addError($error, $stackPtr, 'AssignedComparison'); + break; + } + + if (in_array($tokens[$i]['code'], PHP_CodeSniffer_Tokens::$booleanOperators) === true + || $tokens[$i]['code'] === T_BOOLEAN_NOT + ) { + $error = 'The value of a boolean operation must not be assigned to a variable'; + $phpcsFile->addError($error, $stackPtr, 'AssignedBool'); + break; + } + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/PHP/DisallowInlineIfSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/PHP/DisallowInlineIfSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/PHP/DisallowInlineIfSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/PHP/DisallowInlineIfSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,74 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_Formatting_DisallowInlineIfSniff. + * + * Stops inline IF statements from being used. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_PHP_DisallowInlineIfSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * A list of tokenizers this sniff supports. + * + * @var array + */ + public $supportedTokenizers = array( + 'PHP', + 'JS', + ); + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array(T_INLINE_THEN); + + }//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) + { + $phpcsFile->addError('Inline IF statements are not allowed', $stackPtr, 'Found'); + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/PHP/DisallowMultipleAssignmentsSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/PHP/DisallowMultipleAssignmentsSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/PHP/DisallowMultipleAssignmentsSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/PHP/DisallowMultipleAssignmentsSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,180 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_PHP_DisallowMultipleAssignmentsSniff. + * + * Ensures that there is only one value assignment on a line, and that it is + * the first thing on the line. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_PHP_DisallowMultipleAssignmentsSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array(T_EQUAL); + + }//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(); + + // Ignore default value assignments in function definitions. + $function = $phpcsFile->findPrevious(array(T_FUNCTION, T_CLOSURE), ($stackPtr - 1)); + if ($function !== false) { + $opener = $tokens[$function]['parenthesis_opener']; + $closer = $tokens[$function]['parenthesis_closer']; + if ($opener < $stackPtr && $closer > $stackPtr) { + return; + } + } + + /* + The general rule is: + Find an equal sign and go backwards along the line. If you hit an + end bracket, skip to the opening bracket. When you find a variable, + stop. That variable must be the first non-empty token on the line + or in the statement. If not, throw an error. + */ + + for ($varToken = ($stackPtr - 1); $varToken >= 0; $varToken--) { + // Skip brackets. + if (isset($tokens[$varToken]['parenthesis_opener']) === true && $tokens[$varToken]['parenthesis_opener'] < $varToken) { + $varToken = $tokens[$varToken]['parenthesis_opener']; + continue; + } + + if (isset($tokens[$varToken]['bracket_opener']) === true) { + $varToken = $tokens[$varToken]['bracket_opener']; + continue; + } + + if ($tokens[$varToken]['code'] === T_SEMICOLON) { + // We've reached the next statement, so we + // didn't find a variable. + return; + } + + if ($tokens[$varToken]['code'] === T_VARIABLE) { + // We found our variable. + break; + } + } + + if ($varToken <= 0) { + // Didn't find a variable. + return; + } + + // Deal with this type of variable: self::$var by setting the var + // token to be "self" rather than "$var". + if ($tokens[($varToken - 1)]['code'] === T_DOUBLE_COLON) { + $varToken = ($varToken - 2); + } + + // Deal with this type of variable: $obj->$var by setting the var + // token to be "$obj" rather than "$var". + if ($tokens[($varToken - 1)]['code'] === T_OBJECT_OPERATOR) { + $varToken = ($varToken - 2); + } + + // Deal with this type of variable: $$var by setting the var + // token to be "$" rather than "$var". + if ($tokens[($varToken - 1)]['content'] === '$') { + $varToken--; + } + + // Ignore member var definitions. + $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($varToken - 1), null, true); + if (in_array($tokens[$prev]['code'], PHP_CodeSniffer_Tokens::$scopeModifiers) === true) { + return; + } + + if ($tokens[$prev]['code'] === T_STATIC) { + return; + } + + // Make sure this variable is the first thing in the statement. + $varLine = $tokens[$varToken]['line']; + $prevLine = 0; + for ($i = ($varToken - 1); $i >= 0; $i--) { + if ($tokens[$i]['code'] === T_SEMICOLON) { + // We reached the end of the statement. + return; + } + + if ($tokens[$i]['code'] === T_INLINE_THEN) { + // We reached the end of the inline THEN statement. + return; + } + + if ($tokens[$i]['code'] === T_INLINE_ELSE) { + // We reached the end of the inline ELSE statement. + return; + } + + if (in_array($tokens[$i]['code'], PHP_CodeSniffer_Tokens::$emptyTokens) === false) { + $prevLine = $tokens[$i]['line']; + break; + } + } + + // Ignore the first part of FOR loops as we are allowed to + // assign variables there even though the variable is not the + // first thing on the line. Also ignore WHILE loops. + if ($tokens[$i]['code'] === T_OPEN_PARENTHESIS && isset($tokens[$i]['parenthesis_owner']) === true) { + $owner = $tokens[$i]['parenthesis_owner']; + if ($tokens[$owner]['code'] === T_FOR || $tokens[$owner]['code'] === T_WHILE) { + return; + } + } + + if ($prevLine === $varLine) { + $error = 'Assignments must be the first block of code on a line'; + $phpcsFile->addError($error, $stackPtr, 'Found'); + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/PHP/DisallowObEndFlushSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/PHP/DisallowObEndFlushSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/PHP/DisallowObEndFlushSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/PHP/DisallowObEndFlushSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,68 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_Formatting_DisallowObEndFlushSniff. + * + * Checks the indenting used when an ob_start() call occurs. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_PHP_DisallowObEndFlushSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array(T_STRING); + + }//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(); + + if ($tokens[$stackPtr]['content'] === 'ob_end_flush') { + $phpcsFile->addError('Use of ob_end_flush() is not allowed; use ob_get_contents() and ob_end_clean() instead', $stackPtr, 'Found'); + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/PHP/DisallowSizeFunctionsInLoopsSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/PHP/DisallowSizeFunctionsInLoopsSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/PHP/DisallowSizeFunctionsInLoopsSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/PHP/DisallowSizeFunctionsInLoopsSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,126 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_PHP_DisallowSizeFunctionsInLoopsSniff. + * + * Bans the use of size-based functions in loop conditions. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_PHP_DisallowSizeFunctionsInLoopsSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * A list of tokenizers this sniff supports. + * + * @var array + */ + public $supportedTokenizers = array( + 'PHP', + 'JS', + ); + + /** + * An array of functions we don't want in the condition of loops. + * + * @return array + */ + protected $forbiddenFunctions = array( + 'PHP' => array( + 'sizeof', + 'strlen', + 'count', + ), + 'JS' => array( + 'length', + ), + ); + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array(T_WHILE, T_FOR); + + }//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(); + $tokenizer = $phpcsFile->tokenizerType; + $openBracket = $tokens[$stackPtr]['parenthesis_opener']; + $closeBracket = $tokens[$stackPtr]['parenthesis_closer']; + + if ($tokens[$stackPtr]['code'] === T_FOR) { + // We only want to check the condition in FOR loops. + $start = $phpcsFile->findNext(T_SEMICOLON, ($openBracket + 1)); + $end = $phpcsFile->findPrevious(T_SEMICOLON, ($closeBracket - 1)); + } else { + $start = $openBracket; + $end = $closeBracket; + } + + for ($i = ($start + 1); $i < $end; $i++) { + if ($tokens[$i]['code'] === T_STRING && in_array($tokens[$i]['content'], $this->forbiddenFunctions[$tokenizer])) { + $functionName = $tokens[$i]['content']; + if ($tokenizer === 'JS') { + // Needs to be in the form object.function to be valid. + $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($i - 1), null, true); + if ($prev === false || $tokens[$prev]['code'] !== T_OBJECT_OPERATOR) { + continue; + } + + $functionName = 'object.'.$functionName; + } else { + // Make sure it isn't a member var. + if ($tokens[($i - 1)]['code'] === T_OBJECT_OPERATOR) { + continue; + } + + $functionName .= '()'; + } + + $error = 'The use of %s inside a loop condition is not allowed; assign the return value to a variable and use the variable in the loop condition instead'; + $data = array($functionName); + $phpcsFile->addError($error, $i, 'Found', $data); + }//end if + }//end for + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/PHP/DiscouragedFunctionsSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/PHP/DiscouragedFunctionsSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/PHP/DiscouragedFunctionsSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/PHP/DiscouragedFunctionsSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,57 @@ + + * @copyright 2006-2012 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 + */ + +if (class_exists('Generic_Sniffs_PHP_ForbiddenFunctionsSniff', true) === false) { + throw new PHP_CodeSniffer_Exception('Class Generic_Sniffs_PHP_ForbiddenFunctionsSniff not found'); +} + +/** + * Squiz_Sniffs_PHP_DiscouragedFunctionsSniff. + * + * Discourages the use of debug functions. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_PHP_DiscouragedFunctionsSniff extends Generic_Sniffs_PHP_ForbiddenFunctionsSniff +{ + + /** + * A list of forbidden functions with their alternatives. + * + * The value is NULL if no alternative exists. IE, the + * function should just not be used. + * + * @var array(string => string|null) + */ + protected $forbiddenFunctions = array( + 'error_log' => null, + 'print_r' => null, + ); + + /** + * If true, an error will be thrown; otherwise a warning. + * + * @var bool + */ + public $error = false; + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,263 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_PHP_EmbeddedPhpSniff. + * + * Checks the indentation of embedded PHP code segments. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_PHP_EmbeddedPhpSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * 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 void + */ + public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + $tokens = $phpcsFile->getTokens(); + + // If the close php tag is on the same line as the opening + // then we have an inline embedded PHP block. + $closeTag = $phpcsFile->findNext(array(T_CLOSE_TAG), $stackPtr); + if ($closeTag === false) { + return; + } + + if ($tokens[$stackPtr]['line'] !== $tokens[$closeTag]['line']) { + $this->_validateMultilineEmbeddedPhp($phpcsFile, $stackPtr); + } else { + $this->_validateInlineEmbeddedPhp($phpcsFile, $stackPtr); + } + + }//end process() + + + /** + * Validates embedded PHP that exists on multiple lines. + * + * @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 + */ + private function _validateMultilineEmbeddedPhp(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + $tokens = $phpcsFile->getTokens(); + + $prevTag = $phpcsFile->findPrevious(T_OPEN_TAG, ($stackPtr - 1)); + if ($prevTag === false) { + // This is the first open tag. + return; + } + + // This isn't the first opening tag. + $closingTag = $phpcsFile->findNext(T_CLOSE_TAG, $stackPtr); + if ($closingTag === false) { + // No closing tag? Problem. + return; + } + + $nextContent = $phpcsFile->findNext(T_WHITESPACE, ($closingTag + 1), $phpcsFile->numTokens, true); + if ($nextContent === false) { + // Final closing tag. It will be handled elsewhere. + return; + } + + // Make sure the lines are opening and closing on different lines. + if ($tokens[$stackPtr]['line'] === $tokens[$closingTag]['line']) { + return; + } + + // We have an opening and a closing tag, that lie within other content. + // They are also on different lines. + $firstContent = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), $closingTag, true); + if ($firstContent === false) { + $error = 'Empty embedded PHP tag found'; + $phpcsFile->addError($error, $stackPtr, 'Empty'); + return; + } + + // Check for a blank line at the top. + if ($tokens[$firstContent]['line'] > ($tokens[$stackPtr]['line'] + 1)) { + // Find a token on the blank line to throw the error on. + $i = $stackPtr; + do { + $i++; + } while ($tokens[$i]['line'] !== ($tokens[$stackPtr]['line'] + 1)); + + $error = 'Blank line found at start of embedded PHP content'; + $phpcsFile->addError($error, $i, 'SpacingBefore'); + } else if ($tokens[$firstContent]['line'] === $tokens[$stackPtr]['line']) { + $error = 'Opening PHP tag must be on a line by itself'; + $phpcsFile->addError($error, $stackPtr, 'ContentAfterOpen'); + } + + // Check the indent of the first line. + $startColumn = $tokens[$stackPtr]['column']; + $contentColumn = $tokens[$firstContent]['column']; + if ($contentColumn !== $startColumn) { + $error = 'First line of embedded PHP code must be indented %s spaces; %s found'; + $data = array( + $startColumn, + $contentColumn, + ); + $phpcsFile->addError($error, $firstContent, 'Indent', $data); + } + + // Check for a blank line at the bottom. + $lastContent = $phpcsFile->findPrevious(T_WHITESPACE, ($closingTag - 1), ($stackPtr + 1), true); + if ($tokens[$lastContent]['line'] < ($tokens[$closingTag]['line'] - 1)) { + // Find a token on the blank line to throw the error on. + $i = $closingTag; + do { + $i--; + } while ($tokens[$i]['line'] !== ($tokens[$closingTag]['line'] - 1)); + + $error = 'Blank line found at end of embedded PHP content'; + $phpcsFile->addError($error, $i, 'SpacingAfter'); + } else if ($tokens[$lastContent]['line'] === $tokens[$closingTag]['line']) { + $error = 'Closing PHP tag must be on a line by itself'; + $phpcsFile->addError($error, $closingTag, 'ContentAfterEnd'); + } + + }//end _validateMultilineEmbeddedPhp() + + + /** + * Validates embedded PHP that exists on one line. + * + * @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 + */ + private function _validateInlineEmbeddedPhp(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + $tokens = $phpcsFile->getTokens(); + + // We only want one line PHP sections, so return if the closing tag is + // on the next line. + $closeTag = $phpcsFile->findNext(array(T_CLOSE_TAG), $stackPtr, null, false); + if ($tokens[$stackPtr]['line'] !== $tokens[$closeTag]['line']) { + return; + } + + // Check that there is one, and only one space at the start of the statement. + $firstContent = $phpcsFile->findNext(array(T_WHITESPACE), ($stackPtr + 1), null, true); + + if ($firstContent === false || $tokens[$firstContent]['code'] === T_CLOSE_TAG) { + $error = 'Empty embedded PHP tag found'; + $phpcsFile->addError($error, $stackPtr, 'Empty'); + return; + } + + $leadingSpace = ''; + for ($i = ($stackPtr + 1); $i < $firstContent; $i++) { + $leadingSpace .= $tokens[$i]['content']; + } + + if (strlen($leadingSpace) >= 1) { + $error = 'Expected 1 space after opening PHP tag; %s found'; + $data = array((strlen($leadingSpace) + 1)); + $phpcsFile->addError($error, $stackPtr, 'SpacingAfterOpen', $data); + } + + $semiColonCount = 0; + $semiColon = $stackPtr; + $lastSemiColon = $semiColon; + + while (($semiColon = $phpcsFile->findNext(array(T_SEMICOLON), ($semiColon + 1), $closeTag)) !== false) { + $lastSemiColon = $semiColon; + $semiColonCount++; + } + + $semiColon = $lastSemiColon; + $error = ''; + + // Make sure there is atleast 1 semicolon. + if ($semiColonCount === 0) { + $error = 'Inline PHP statement must end with a semicolon'; + $phpcsFile->addError($error, $stackPtr, 'NoSemicolon'); + return; + } + + // Make sure that there aren't more semicolons than are allowed. + if ($semiColonCount > 1) { + $error = 'Inline PHP statement must contain one statement per line; %s found'; + $data = array($semiColonCount); + $phpcsFile->addError($error, $stackPtr, 'MultipleStatements', $data); + } + + // The statement contains only 1 semicolon, now it must be spaced properly. + $whitespace = ''; + for ($i = ($semiColon + 1); $i < $closeTag; $i++) { + if ($tokens[$i]['code'] !== T_WHITESPACE) { + $error = 'Expected 1 space before closing PHP tag; 0 found'; + $phpcsFile->addError($error, $stackPtr, 'NoSpaceBeforeClose'); + return; + } + + $whitespace .= $tokens[$i]['content']; + } + + if (strlen($whitespace) === 1) { + return; + } + + if (strlen($whitespace) === 0) { + $error = 'Expected 1 space before closing PHP tag; 0 found'; + $phpcsFile->addError($error, $stackPtr, 'NoSpaceBeforeClose'); + } else { + $error = 'Expected 1 space before closing PHP tag; %s found'; + $data = array(strlen($whitespace)); + $phpcsFile->addError($error, $stackPtr, 'SpacingBeforeClose', $data); + } + + }//end _validateInlineEmbeddedPhp() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/PHP/EvalSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/PHP/EvalSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/PHP/EvalSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/PHP/EvalSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,65 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_PHP_EvalSniff. + * + * The use of eval() is discouraged. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_PHP_EvalSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array(T_EVAL); + + }//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) + { + $error = 'Use of eval() is discouraged'; + $phpcsFile->addWarning($error, $stackPtr, 'Discouraged'); + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/PHP/ForbiddenFunctionsSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/PHP/ForbiddenFunctionsSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/PHP/ForbiddenFunctionsSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/PHP/ForbiddenFunctionsSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,71 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +if (class_exists('Generic_Sniffs_PHP_ForbiddenFunctionsSniff', true) === false) { + throw new PHP_CodeSniffer_Exception('Class Generic_Sniffs_PHP_ForbiddenFunctionsSniff not found'); +} + +/** + * Squiz_Sniffs_PHP_ForbiddenFunctionsSniff. + * + * Discourages the use of alias functions that are kept in PHP for compatibility + * with older versions. Can be used to forbid the use of any function. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_PHP_ForbiddenFunctionsSniff extends Generic_Sniffs_PHP_ForbiddenFunctionsSniff +{ + + /** + * A list of forbidden functions with their alternatives. + * + * The value is NULL if no alternative exists. IE, the + * function should just not be used. + * + * @var array(string => string|null) + */ + protected $forbiddenFunctions = array( + 'sizeof' => 'count', + 'delete' => 'unset', + 'print' => 'echo', + 'is_null' => null, + 'create_function' => null, + ); + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + $tokens = parent::register(); + $tokens[] = T_PRINT; + return $tokens; + + }//end register() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/PHP/GlobalKeywordSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/PHP/GlobalKeywordSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/PHP/GlobalKeywordSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/PHP/GlobalKeywordSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,70 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_PHP_GlobalKeywordSniff. + * + * Stops the usage of the "global" keyword. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_PHP_GlobalKeywordSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array(T_GLOBAL); + + }//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(); + + $nextVar = $tokens[$phpcsFile->findNext(array(T_VARIABLE), $stackPtr)]; + $varName = str_replace('$', '', $nextVar['content']); + $error = 'Use of the "global" keyword is forbidden; use "$GLOBALS[\'%s\']" instead'; + $data = array($varName); + $phpcsFile->addError($error, $stackPtr, 'NotAllowed', $data); + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/PHP/HeredocSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/PHP/HeredocSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/PHP/HeredocSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/PHP/HeredocSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,68 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_PHP_HeredocSniff. + * + * Heredocs are prohibited. This test enforces that. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_PHP_HeredocSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array( + T_START_HEREDOC, + T_START_NOWDOC, + ); + + }//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) + { + $error = 'Use of heredoc and nowdoc syntax ("<<<") is not allowed; use standard strings or inline HTML instead'; + $phpcsFile->addError($error, $stackPtr, 'NotAllowed'); + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/PHP/InnerFunctionsSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/PHP/InnerFunctionsSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/PHP/InnerFunctionsSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/PHP/InnerFunctionsSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,75 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_PHP_InnerFunctionsSniff. + * + * Ensures that functions within functions are never used. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_PHP_InnerFunctionsSniff 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(); + + if ($phpcsFile->hasCondition($stackPtr, T_FUNCTION) === true) { + $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); + if ($tokens[$prev]['code'] === T_EQUAL) { + // Ignore closures. + return; + } + + $error = 'The use of inner functions is forbidden'; + $phpcsFile->addError($error, $stackPtr, 'NotAllowed'); + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/PHP/LowercasePHPFunctionsSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/PHP/LowercasePHPFunctionsSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/PHP/LowercasePHPFunctionsSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/PHP/LowercasePHPFunctionsSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,115 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_PHP_LowercasePHPFunctionsSniff. + * + * Ensures all calls to inbuilt PHP functions are lowercase. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_PHP_LowercasePHPFunctionsSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array(T_STRING); + + }//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(); + + // Make sure this is a function call. + $next = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); + if ($next === false) { + // Not a function call. + return; + } + + if ($tokens[$next]['code'] !== T_OPEN_PARENTHESIS) { + // Not a function call. + return; + } + + $prev = $phpcsFile->findPrevious(array(T_WHITESPACE, T_BITWISE_AND), ($stackPtr - 1), null, true); + if ($tokens[$prev]['code'] === T_FUNCTION) { + // Function declaration, not a function call. + return; + } + + if ($tokens[$prev]['code'] === T_NEW) { + // Object creation, not an inbuilt function. + return; + } + + if ($tokens[$prev]['code'] === T_OBJECT_OPERATOR) { + // Not an inbuilt function. + return; + } + + if ($tokens[$prev]['code'] === T_DOUBLE_COLON) { + // Not an inbuilt function. + return; + } + + // Make sure it is an inbuilt PHP function. + // PHP_CodeSniffer doesn't include/require any files, so no + // user defined global functions can exist, except for + // PHP_CodeSniffer ones. + $content = $tokens[$stackPtr]['content']; + if (function_exists($content) === false) { + return; + } + + if ($content !== strtolower($content)) { + $error = 'Calls to inbuilt PHP functions must be lowercase; expected "%s" but found "%s"'; + $data = array( + strtolower($content), + $content, + ); + $phpcsFile->addError($error, $stackPtr, 'CallUppercase', $data); + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/PHP/NonExecutableCodeSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/PHP/NonExecutableCodeSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/PHP/NonExecutableCodeSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/PHP/NonExecutableCodeSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,268 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_PHP_NonExecutableCodeSniff. + * + * Warns about code that can never been executed. This happens when a function + * returns before the code, or a break ends execution of a statement etc. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_PHP_NonExecutableCodeSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array( + T_BREAK, + T_CONTINUE, + T_RETURN, + T_THROW, + T_EXIT, + ); + + }//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(); + + // If this token is preceded with an "or", it only relates to one line + // and should be ignored. For example: fopen() or die(). + $prev = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true); + if ($tokens[$prev]['code'] === T_LOGICAL_OR) { + return; + } + + // Check if this token is actually part of a one-line IF or ELSE statement. + for ($i = ($stackPtr - 1); $i > 0; $i--) { + if ($tokens[$i]['code'] === T_CLOSE_PARENTHESIS) { + $i = $tokens[$i]['parenthesis_opener']; + continue; + } else if (in_array($tokens[$i]['code'], PHP_CodeSniffer_Tokens::$emptyTokens) === true) { + continue; + } + + break; + } + + if ($tokens[$i]['code'] === T_IF + || $tokens[$i]['code'] === T_ELSE + || $tokens[$i]['code'] === T_ELSEIF + ) { + return; + } + + if ($tokens[$stackPtr]['code'] === T_RETURN) { + $next = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); + if ($tokens[$next]['code'] === T_SEMICOLON) { + $next = $phpcsFile->findNext(T_WHITESPACE, ($next + 1), null, true); + if ($tokens[$next]['code'] === T_CLOSE_CURLY_BRACKET) { + // If this is the closing brace of a function + // then this return statement doesn't return anything + // and is not required anyway. + $owner = $tokens[$next]['scope_condition']; + if ($tokens[$owner]['code'] === T_FUNCTION) { + $warning = 'Empty return statement not required here'; + $phpcsFile->addWarning($warning, $stackPtr, 'ReturnNotRequired'); + return; + } + } + } + } + + if (isset($tokens[$stackPtr]['scope_opener']) === true) { + $owner = $tokens[$stackPtr]['scope_condition']; + if ($tokens[$owner]['code'] === T_CASE || $tokens[$owner]['code'] === T_DEFAULT) { + // This token closes the scope of a CASE or DEFAULT statement + // so any code between this token and the next CASE, DEFAULT or + // end of SWITCH token will not be executable. + $next = $phpcsFile->findNext( + array(T_CASE, T_DEFAULT, T_CLOSE_CURLY_BRACKET), + ($stackPtr + 1) + ); + + if ($next !== false) { + $end = $phpcsFile->findNext(array(T_SEMICOLON), ($stackPtr + 1)); + $lastLine = $tokens[$end]['line']; + for ($i = ($stackPtr + 1); $i < $next; $i++) { + if (in_array($tokens[$i]['code'], PHP_CodeSniffer_Tokens::$emptyTokens) === true) { + continue; + } + + $line = $tokens[$i]['line']; + if ($line > $lastLine) { + $type = substr($tokens[$stackPtr]['type'], 2); + $warning = 'Code after %s statement cannot be executed'; + $data = array($type); + $phpcsFile->addWarning($warning, $i, 'Unreachable', $data); + $lastLine = $line; + } + } + }//end if + + // That's all we have to check for these types of statements. + return; + } + }//end if + + // This token may be part of an inline condition. + // If we find a closing parenthesis that belongs to a condition + // we should ignore this token. + $prev = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true); + if (isset($tokens[$prev]['parenthesis_owner']) === true) { + $owner = $tokens[$prev]['parenthesis_owner']; + $ignore = array( + T_IF, + T_ELSE, + T_ELSEIF, + ); + if (in_array($tokens[$owner]['code'], $ignore) === true) { + return; + } + } + + $ourConditions = array_keys($tokens[$stackPtr]['conditions']); + + if (empty($ourConditions) === false) { + $condition = array_pop($ourConditions); + + if (isset($tokens[$condition]['scope_closer']) === false) { + return; + } + + // Special case for BREAK statements sitting directly inside SWITCH + // statements. If we get to this point, we know the BREAK is not being + // used to close a CASE statement, so it is most likely non-executable + // code itself (as is the case when you put return; break; at the end of + // a case). So we need to ignore this token. + if ($tokens[$condition]['code'] === T_SWITCH + && $tokens[$stackPtr]['code'] === T_BREAK + ) { + return; + } + + $closer = $tokens[$condition]['scope_closer']; + + // If the closer for our condition is shared with other openers, + // we will need to throw errors from this token to the next + // shared opener (if there is one), not to the scope closer. + $nextOpener = null; + for ($i = ($stackPtr + 1); $i < $closer; $i++) { + if (isset($tokens[$i]['scope_closer']) === true) { + if ($tokens[$i]['scope_closer'] === $closer) { + // We found an opener that shares the same + // closing token as us. + $nextOpener = $i; + break; + } + } + }//end for + + if ($nextOpener === null) { + $end = $closer; + } else { + $end = ($nextOpener - 1); + } + } else { + // This token is in the global scope. + if ($tokens[$stackPtr]['code'] === T_BREAK) { + return; + } + + // Throw an error for all lines until the end of the file. + $end = ($phpcsFile->numTokens - 1); + }//end if + + // Find the semicolon that ends this statement, skipping + // nested statements like FOR loops and closures. + for ($start = ($stackPtr + 1); $start < $phpcsFile->numTokens; $start++) { + if ($start === $end) { + break; + } + + if ($tokens[$start]['code'] === T_OPEN_PARENTHESIS) { + $start = $tokens[$start]['parenthesis_closer']; + continue; + } + + if ($tokens[$start]['code'] === T_OPEN_CURLY_BRACKET) { + $start = $tokens[$start]['bracket_closer']; + continue; + } + + if ($tokens[$start]['code'] === T_SEMICOLON) { + break; + } + }//end for + + $lastLine = $tokens[$start]['line']; + for ($i = ($start + 1); $i < $end; $i++) { + if (in_array($tokens[$i]['code'], PHP_CodeSniffer_Tokens::$emptyTokens) === true + || in_array($tokens[$i]['code'], PHP_CodeSniffer_Tokens::$bracketTokens) === true + ) { + continue; + } + + // Skip whole functions and classes/interfaces because they are not + // technically executed code, but rather declarations that may be used. + if ($tokens[$i]['code'] === T_FUNCTION + || $tokens[$i]['code'] === T_CLASS + || $tokens[$i]['code'] === T_INTERFACE + ) { + $i = $tokens[$i]['scope_closer']; + continue; + } + + $line = $tokens[$i]['line']; + if ($line > $lastLine) { + $type = substr($tokens[$stackPtr]['type'], 2); + $warning = 'Code after %s statement cannot be executed'; + $data = array($type); + $phpcsFile->addWarning($warning, $i, 'Unreachable', $data); + $lastLine = $line; + } + }//end for + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Scope/MemberVarScopeSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Scope/MemberVarScopeSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Scope/MemberVarScopeSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Scope/MemberVarScopeSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,90 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +if (class_exists('PHP_CodeSniffer_Standards_AbstractVariableSniff', true) === false) { + throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_Standards_AbstractVariableSniff not found'); +} + +/** + * Verifies that class members have scope modifiers. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_Scope_MemberVarScopeSniff extends PHP_CodeSniffer_Standards_AbstractVariableSniff +{ + + + /** + * Processes the function tokens within the class. + * + * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found. + * @param int $stackPtr The position where the token was found. + * + * @return void + */ + protected function processMemberVar(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + $tokens = $phpcsFile->getTokens(); + $modifier = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$scopeModifiers, $stackPtr); + + if (($modifier === false) || ($tokens[$modifier]['line'] !== $tokens[$stackPtr]['line'])) { + $error = 'Scope modifier not specified for member variable "%s"'; + $data = array($tokens[$stackPtr]['content']); + $phpcsFile->addError($error, $stackPtr, 'Missing', $data); + } + + }//end processMemberVar() + + + /** + * Processes normal variables. + * + * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found. + * @param int $stackPtr The position where the token was found. + * + * @return void + */ + protected function processVariable(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + // We don't care about normal variables. + + }//end processVariable() + + + /** + * Processes variables in double quoted strings. + * + * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found. + * @param int $stackPtr The position where the token was found. + * + * @return void + */ + protected function processVariableInString(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + // We don't care about normal variables. + + }//end processVariableInString() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Scope/MethodScopeSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Scope/MethodScopeSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Scope/MethodScopeSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Scope/MethodScopeSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,77 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +if (class_exists('PHP_CodeSniffer_Standards_AbstractScopeSniff', true) === false) { + throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_Standards_AbstractScopeSniff not found'); +} + +/** + * Verifies that class members have scope modifiers. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_Scope_MethodScopeSniff extends PHP_CodeSniffer_Standards_AbstractScopeSniff +{ + + + /** + * Constructs a Squiz_Sniffs_Scope_MethodScopeSniff. + */ + public function __construct() + { + parent::__construct(array(T_CLASS, T_INTERFACE), array(T_FUNCTION)); + + }//end __construct() + + + /** + * Processes the function tokens within the class. + * + * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found. + * @param int $stackPtr The position where the token was found. + * @param int $currScope The current scope opener token. + * + * @return void + */ + protected function processTokenWithinScope(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $currScope) + { + $tokens = $phpcsFile->getTokens(); + + $methodName = $phpcsFile->getDeclarationName($stackPtr); + if ($methodName === null) { + // Ignore closures. + return; + } + + $modifier = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$scopeModifiers, $stackPtr); + if (($modifier === false) || ($tokens[$modifier]['line'] !== $tokens[$stackPtr]['line'])) { + $error = 'No scope modifier specified for function "%s"'; + $data = array($methodName); + $phpcsFile->addError($error, $stackPtr, 'Missing', $data); + } + + }//end processTokenWithinScope() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Scope/StaticThisUsageSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Scope/StaticThisUsageSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Scope/StaticThisUsageSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Scope/StaticThisUsageSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,99 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +if (class_exists('PHP_CodeSniffer_Standards_AbstractScopeSniff', true) === false) { + throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_Standards_AbstractScopeSniff not found'); +} + +/** + * Squiz_Sniffs_Scope_StaticThisUsageSniff. + * + * Checks for usage of "$this" in static methods, which will cause + * runtime errors. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_Scope_StaticThisUsageSniff extends PHP_CodeSniffer_Standards_AbstractScopeSniff +{ + + + /** + * Constructs the test with the tokens it wishes to listen for. + * + * @return void + */ + public function __construct() + { + parent::__construct(array(T_CLASS), array(T_FUNCTION)); + + }//end __construct() + + + /** + * Processes this test, when one of its tokens is encountered. + * + * @param PHP_CodeSniffer_File $phpcsFile The current file being scanned. + * @param int $stackPtr The position of the current token in the + * stack passed in $tokens. + * @param int $currScope A pointer to the start of the scope. + * + * @return void + */ + public function processTokenWithinScope(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $currScope) + { + $tokens = $phpcsFile->getTokens(); + $function = $tokens[($stackPtr + 2)]; + + if ($function['code'] !== T_STRING) { + return; + } + + $functionName = $function['content']; + $classOpener = $tokens[$currScope]['scope_condition']; + $className = $tokens[($classOpener + 2)]['content']; + + $methodProps = $phpcsFile->getMethodProperties($stackPtr); + + if ($methodProps['is_static'] === true) { + if (isset($tokens[$stackPtr]['scope_closer']) === false) { + // There is no scope opener or closer, so the function + // must be abstract. + return; + } + + $thisUsage = $stackPtr; + while (($thisUsage = $phpcsFile->findNext(array(T_VARIABLE), ($thisUsage + 1), $tokens[$stackPtr]['scope_closer'], false, '$this')) !== false) { + if ($thisUsage === false) { + return; + } + + $error = 'Usage of "$this" in static methods will cause runtime errors'; + $phpcsFile->addError($error, $thisUsage, 'Found'); + } + }//end if + + }//end processTokenWithinScope() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Strings/ConcatenationSpacingSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Strings/ConcatenationSpacingSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Strings/ConcatenationSpacingSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Strings/ConcatenationSpacingSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,71 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_Strings_ConcatenationSpacingSniff. + * + * Makes sure there are no spaces between the concatenation operator (.) and + * the strings being concatenated. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_Strings_ConcatenationSpacingSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array(T_STRING_CONCAT); + + }//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(); + if ($tokens[($stackPtr - 1)]['code'] === T_WHITESPACE + || $tokens[($stackPtr + 1)]['code'] === T_WHITESPACE + ) { + $message = 'Concat operator must not be surrounded by spaces'; + $phpcsFile->addError($message, $stackPtr, 'Missing'); + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,135 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_Strings_DoubleQuoteUsageSniff. + * + * Makes sure that any use of Double Quotes ("") are warranted. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_Strings_DoubleQuoteUsageSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array( + T_CONSTANT_ENCAPSED_STRING, + T_DOUBLE_QUOTED_STRING, + ); + + }//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(); + + // We are only interested in the first token in a multi-line string. + if ($tokens[$stackPtr]['code'] === $tokens[($stackPtr - 1)]['code']) { + return; + } + + $workingString = $tokens[$stackPtr]['content']; + $i = ($stackPtr + 1); + while ($tokens[$i]['code'] === $tokens[$stackPtr]['code']) { + $workingString .= $tokens[$i]['content']; + $i++; + } + + // Check if it's a double quoted string. + if (strpos($workingString, '"') === false) { + return; + } + + // Make sure it's not a part of a string started in a previous line. + // If it is, then we have already checked it. + if ($workingString[0] !== '"') { + return; + } + + // The use of variables in double quoted strings is not allowed. + if ($tokens[$stackPtr]['code'] === T_DOUBLE_QUOTED_STRING) { + $stringTokens = token_get_all('addError($error, $stackPtr, 'ContainsVar', $data); + } + } + + return; + }//end if + + // Work through the following tokens, in case this string is stretched + // over multiple Lines. + for ($i = ($stackPtr + 1); $i < $phpcsFile->numTokens; $i++) { + if ($tokens[$i]['type'] !== 'T_CONSTANT_ENCAPSED_STRING') { + break; + } + + $workingString .= $tokens[$i]['content']; + } + + $allowedChars = array( + '\0', + '\n', + '\r', + '\f', + '\t', + '\v', + '\x', + '\'', + ); + + foreach ($allowedChars as $testChar) { + if (strpos($workingString, $testChar) !== false) { + return; + } + } + + $error = 'String %s does not require double quotes; use single quotes instead'; + $data = array($workingString); + $phpcsFile->addError($error, $stackPtr, 'NotRequired', $data); + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Strings/EchoedStringsSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Strings/EchoedStringsSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Strings/EchoedStringsSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/Strings/EchoedStringsSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,84 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_Strings_EchoedStringsSniff. + * + * Makes sure that any strings that are "echoed" are not enclosed in brackets + * like a function call. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_Strings_EchoedStringsSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array(T_ECHO); + + }//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(); + + $firstContent = $phpcsFile->findNext(array(T_WHITESPACE), ($stackPtr + 1), null, true); + // If the first non-whitespace token is not an opening parenthesis, then we are not concerned. + if ($tokens[$firstContent]['code'] !== T_OPEN_PARENTHESIS) { + return; + } + + $endOfStatement = $phpcsFile->findNext(array(T_SEMICOLON), $stackPtr, null, false); + + // If the token before the semi-colon is not a closing parenthesis, then we are not concerned. + if ($tokens[($endOfStatement - 1)]['code'] !== T_CLOSE_PARENTHESIS) { + return; + } + + if (($phpcsFile->findNext(PHP_CodeSniffer_Tokens::$operators, $stackPtr, $endOfStatement, false)) === false) { + // There are no arithmetic operators in this. + $error = 'Echoed strings should not be bracketed'; + $phpcsFile->addError($error, $stackPtr, 'HasBracket'); + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/CastSpacingSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/CastSpacingSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/CastSpacingSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/CastSpacingSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,77 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_WhiteSpace_CastSpacingSniff. + * + * Ensure cast statements don't contain whitespace. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_WhiteSpace_CastSpacingSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return PHP_CodeSniffer_Tokens::$castTokens; + + }//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(); + + $content = $tokens[$stackPtr]['content']; + $expected = str_replace(' ', '', $content); + $expected = str_replace("\t", '', $expected); + + if ($content !== $expected) { + $error = 'Cast statements must not contain whitespace; expected "%s" but found "%s"'; + $data = array( + $expected, + $content, + ); + $phpcsFile->addError($error, $stackPtr, 'ContainsWhiteSpace', $data); + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,211 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_WhiteSpace_ControlStructureSpacingSniff. + * + * Checks that control structures have the correct spacing around brackets. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_WhiteSpace_ControlStructureSpacingSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * A list of tokenizers this sniff supports. + * + * @var array + */ + public $supportedTokenizers = array( + 'PHP', + 'JS', + ); + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array( + T_IF, + T_WHILE, + T_FOREACH, + T_FOR, + T_SWITCH, + T_DO, + T_ELSE, + T_ELSEIF, + ); + + }//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(); + + if (isset($tokens[$stackPtr]['scope_closer']) === false) { + return; + } + + if (isset($tokens[$stackPtr]['parenthesis_opener']) === true) { + $parenOpener = $tokens[$stackPtr]['parenthesis_opener']; + $parenCloser = $tokens[$stackPtr]['parenthesis_closer']; + if ($tokens[($parenOpener + 1)]['code'] === T_WHITESPACE) { + $gap = strlen($tokens[($parenOpener + 1)]['content']); + $error = 'Expected 0 spaces after opening bracket; %s found'; + $data = array($gap); + $phpcsFile->addError($error, ($parenOpener + 1), 'SpacingAfterOpenBrace', $data); + } + + if ($tokens[$parenOpener]['line'] === $tokens[$parenCloser]['line'] + && $tokens[($parenCloser - 1)]['code'] === T_WHITESPACE + ) { + $gap = strlen($tokens[($parenCloser - 1)]['content']); + $error = 'Expected 0 spaces before closing bracket; %s found'; + $data = array($gap); + $phpcsFile->addError($error, ($parenCloser - 1), 'SpaceBeforeCloseBrace', $data); + } + }//end if + + $scopeOpener = $tokens[$stackPtr]['scope_opener']; + $scopeCloser = $tokens[$stackPtr]['scope_closer']; + + $firstContent = $phpcsFile->findNext( + T_WHITESPACE, + ($scopeOpener + 1), + null, + true + ); + + if ($tokens[$firstContent]['line'] !== ($tokens[$scopeOpener]['line'] + 1)) { + $error = 'Blank line found at start of control structure'; + $phpcsFile->addError($error, $scopeOpener, 'SpacingBeforeOpen'); + } + + $lastContent = $phpcsFile->findPrevious( + T_WHITESPACE, + ($scopeCloser - 1), + null, + true + ); + + if ($tokens[$lastContent]['line'] !== ($tokens[$scopeCloser]['line'] - 1)) { + $errorToken = $scopeCloser; + for ($i = ($scopeCloser - 1); $i > $lastContent; $i--) { + if ($tokens[$i]['line'] < $tokens[$scopeCloser]['line']) { + $errorToken = $i; + break; + } + } + + $error = 'Blank line found at end of control structure'; + $phpcsFile->addError($error, $errorToken, 'SpacingAfterClose'); + } + + $trailingContent = $phpcsFile->findNext( + T_WHITESPACE, + ($scopeCloser + 1), + null, + true + ); + + if ($tokens[$trailingContent]['code'] === T_ELSE) { + if ($tokens[$stackPtr]['code'] === T_IF) { + // IF with ELSE. + return; + } + } + + if ($tokens[$trailingContent]['code'] === T_COMMENT) { + if ($tokens[$trailingContent]['line'] === $tokens[$scopeCloser]['line']) { + if (substr($tokens[$trailingContent]['content'], 0, 5) === '//end') { + // There is an end comment, so we have to get the next piece + // of content. + $trailingContent = $phpcsFile->findNext( + T_WHITESPACE, + ($trailingContent + 1), + null, + true + ); + } + } + } + + if ($tokens[$trailingContent]['code'] === T_BREAK) { + // If this BREAK is closing a CASE, we don't need the + // blank line after this control structure. + if (isset($tokens[$trailingContent]['scope_condition']) === true) { + $condition = $tokens[$trailingContent]['scope_condition']; + if ($tokens[$condition]['code'] === T_CASE + || $tokens[$condition]['code'] === T_DEFAULT + ) { + return; + } + } + } + + if ($tokens[$trailingContent]['code'] === T_CLOSE_TAG) { + // At the end of the script or embedded code. + return; + } + + if ($tokens[$trailingContent]['code'] === T_CLOSE_CURLY_BRACKET) { + // Another control structure's closing brace. + if (isset($tokens[$trailingContent]['scope_condition']) === true) { + $owner = $tokens[$trailingContent]['scope_condition']; + if ($tokens[$owner]['code'] === T_FUNCTION) { + // The next content is the closing brace of a function + // so normal function rules apply and we can ignore it. + return; + } + } + + if ($tokens[$trailingContent]['line'] !== ($tokens[$scopeCloser]['line'] + 1)) { + $error = 'Blank line found after control structure'; + $phpcsFile->addError($error, $scopeCloser, 'LineAfterClose'); + } + } else { + if ($tokens[$trailingContent]['line'] === ($tokens[$scopeCloser]['line'] + 1)) { + $error = 'No blank line found after control structure'; + $phpcsFile->addError($error, $scopeCloser, 'NoLineAfterClose'); + } + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/FunctionClosingBraceSpaceSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/FunctionClosingBraceSpaceSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/FunctionClosingBraceSpaceSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/FunctionClosingBraceSpaceSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,116 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_WhiteSpace_FunctionClosingBraceSpaceSniff. + * + * Checks that there is one empty line before the closing brace of a function. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_WhiteSpace_FunctionClosingBraceSpaceSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * A list of tokenizers this sniff supports. + * + * @var array + */ + public $supportedTokenizers = array( + 'PHP', + 'JS', + ); + + + /** + * 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(); + + if (isset($tokens[$stackPtr]['scope_closer']) === false) { + // Probably an interface method. + return; + } + + $closeBrace = $tokens[$stackPtr]['scope_closer']; + $prevContent = $phpcsFile->findPrevious(T_WHITESPACE, ($closeBrace - 1), null, true); + + // Special case for empty JS functions + if ($phpcsFile->tokenizerType === 'JS' && $prevContent === $tokens[$stackPtr]['scope_opener']) { + // In this case, the opening and closing brace must be + // right next to each other. + if ($tokens[$stackPtr]['scope_closer'] !== ($tokens[$stackPtr]['scope_opener'] + 1)) { + $error = 'The opening and closing braces of empty functions must be directly next to each other; e.g., function () {}'; + $phpcsFile->addError($error, $closeBrace, 'SpacingBetween'); + } + + return; + } + + $braceLine = $tokens[$closeBrace]['line']; + $prevLine = $tokens[$prevContent]['line']; + + $found = ($braceLine - $prevLine - 1); + if ($phpcsFile->hasCondition($stackPtr, T_FUNCTION) === true || isset($tokens[$stackPtr]['nested_parenthesis']) === true) { + // Nested function. + if ($found < 0) { + $error = 'Closing brace of nested function must be on a new line'; + $phpcsFile->addError($error, $closeBrace, 'ContentBeforeClose'); + } else if ($found > 0) { + $error = 'Expected 0 blank lines before closing brace of nested function; %s found'; + $data = array($found); + $phpcsFile->addError($error, $closeBrace, 'SpacingBeforeNestedClose', $data); + } + } else { + if ($found !== 1) { + $error = 'Expected 1 blank line before closing function brace; %s found'; + $data = array($found); + $phpcsFile->addError($error, $closeBrace, 'SpacingBeforeClose', $data); + } + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/FunctionOpeningBraceSpaceSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/FunctionOpeningBraceSpaceSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/FunctionOpeningBraceSpaceSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/FunctionOpeningBraceSpaceSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,128 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_WhiteSpace_FunctionOpeningBraceSpaceSniff. + * + * Checks that there is no empty line after the opening brace of a function. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_WhiteSpace_FunctionOpeningBraceSpaceSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * A list of tokenizers this sniff supports. + * + * @var array + */ + public $supportedTokenizers = array( + 'PHP', + 'JS', + ); + + + /** + * 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(); + + if (isset($tokens[$stackPtr]['scope_opener']) === false) { + // Probably an interface method. + return; + } + + $openBrace = $tokens[$stackPtr]['scope_opener']; + $nextContent = $phpcsFile->findNext(T_WHITESPACE, ($openBrace + 1), null, true); + + if ($nextContent === $tokens[$stackPtr]['scope_closer']) { + // The next bit of content is the closing brace, so this + // is an empty function and should have a blank line + // between the opening and closing braces. + return; + } + + $braceLine = $tokens[$openBrace]['line']; + $nextLine = $tokens[$nextContent]['line']; + + $found = ($nextLine - $braceLine - 1); + if ($found > 0) { + $error = 'Expected 0 blank lines after opening function brace; %s found'; + $data = array($found); + $phpcsFile->addError($error, $openBrace, 'SpacingAfter', $data); + } + + if ($phpcsFile->tokenizerType === 'JS') { + // Do some additional checking before the function brace. + $nestedFunction = ($phpcsFile->hasCondition($stackPtr, T_FUNCTION) === true || isset($tokens[$stackPtr]['nested_parenthesis']) === true); + + $functionLine = $tokens[$tokens[$stackPtr]['parenthesis_closer']]['line']; + $lineDifference = ($braceLine - $functionLine); + + if ($nestedFunction === true) { + if ($lineDifference > 0) { + $error = 'Expected 0 blank lines before opening brace of nested function; %s found'; + $data = array($found); + $phpcsFile->addError($error, $openBrace, 'SpacingAfterNested', $data); + } + } else { + if ($lineDifference === 0) { + $error = 'Opening brace should be on a new line'; + $phpcsFile->addError($error, $openBrace, 'ContentBefore'); + return; + } + + if ($lineDifference > 1) { + $error = 'Opening brace should be on the line after the declaration; found %s blank line(s)'; + $data = array(($lineDifference - 1)); + $phpcsFile->addError($error, $openBrace, 'SpacingBefore', $data); + return; + } + }//end if + }//end if + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/FunctionSpacingSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/FunctionSpacingSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/FunctionSpacingSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/FunctionSpacingSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,193 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_WhiteSpace_FunctionSpacingSniff. + * + * Checks the separation between methods in a class or interface. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_WhiteSpace_FunctionSpacingSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * The number of blank lines between functions. + * + * @var int + */ + public $spacing = 2; + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array(T_FUNCTION); + + }//end register() + + + /** + * Processes this sniff 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(); + $this->spacing = (int) $this->spacing; + + /* + Check the number of blank lines + after the function. + */ + + if (isset($tokens[$stackPtr]['scope_closer']) === false) { + // Must be an interface method, so the closer is the semi-colon. + $closer = $phpcsFile->findNext(T_SEMICOLON, $stackPtr); + } else { + $closer = $tokens[$stackPtr]['scope_closer']; + } + + $nextLineToken = null; + for ($i = $closer; $i < $phpcsFile->numTokens; $i++) { + if (strpos($tokens[$i]['content'], $phpcsFile->eolChar) === false) { + continue; + } else { + $nextLineToken = ($i + 1); + break; + } + } + + if (is_null($nextLineToken) === true) { + // Never found the next line, which means + // there are 0 blank lines after the function. + $foundLines = 0; + } else { + $nextContent = $phpcsFile->findNext(array(T_WHITESPACE), ($nextLineToken + 1), null, true); + if ($nextContent === false) { + // We are at the end of the file. + $foundLines = 0; + } else { + $foundLines = ($tokens[$nextContent]['line'] - $tokens[$nextLineToken]['line']); + } + } + + if ($foundLines !== $this->spacing) { + $error = 'Expected %s blank line'; + if ($this->spacing !== 1) { + $error .= 's'; + } + + $error .= ' after function; %s found'; + $data = array( + $this->spacing, + $foundLines + ); + $phpcsFile->addError($error, $closer, 'After', $data); + } + + /* + Check the number of blank lines + before the function. + */ + + $prevLineToken = null; + for ($i = $stackPtr; $i > 0; $i--) { + if (strpos($tokens[$i]['content'], $phpcsFile->eolChar) === false) { + continue; + } else { + $prevLineToken = $i; + break; + } + } + + if (is_null($prevLineToken) === true) { + // Never found the previous line, which means + // there are 0 blank lines before the function. + $foundLines = 0; + } else { + $prevContent = $phpcsFile->findPrevious(array(T_WHITESPACE, T_DOC_COMMENT), $prevLineToken, null, true); + + // Before we throw an error, check that we are not throwing an error + // for another function. We don't want to error for no blank lines after + // the previous function and no blank lines before this one as well. + $currentLine = $tokens[$stackPtr]['line']; + $prevLine = ($tokens[$prevContent]['line'] - 1); + $i = ($stackPtr - 1); + $foundLines = 0; + while ($currentLine != $prevLine && $currentLine > 1 && $i > 0) { + if (isset($tokens[$i]['scope_condition']) === true) { + $scopeCondition = $tokens[$i]['scope_condition']; + if ($tokens[$scopeCondition]['code'] === T_FUNCTION) { + // Found a previous function. + return; + } + } else if ($tokens[$i]['code'] === T_FUNCTION) { + // Found another interface function. + return; + } + + $currentLine = $tokens[$i]['line']; + if ($currentLine === $prevLine) { + break; + } + + if ($tokens[($i - 1)]['line'] < $currentLine && $tokens[($i + 1)]['line'] > $currentLine) { + // This token is on a line by itself. If it is whitespace, the line is empty. + if ($tokens[$i]['code'] === T_WHITESPACE) { + $foundLines++; + } + } + + $i--; + }//end while + }//end if + + if ($foundLines !== $this->spacing) { + $error = 'Expected %s blank line'; + if ($this->spacing !== 1) { + $error .= 's'; + } + + $error .= ' before function; %s found'; + $data = array( + $this->spacing, + $foundLines + ); + $phpcsFile->addError($error, $stackPtr, 'Before', $data); + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/LanguageConstructSpacingSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/LanguageConstructSpacingSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/LanguageConstructSpacingSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/LanguageConstructSpacingSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,96 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_WhiteSpace_LanguageConstructSpacingSniff. + * + * Ensures all language constructs (without brackets) contain a + * single space between themselves and their content. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_WhiteSpace_LanguageConstructSpacingSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array( + T_ECHO, + T_PRINT, + T_RETURN, + T_INCLUDE, + T_INCLUDE_ONCE, + T_REQUIRE, + T_REQUIRE_ONCE, + T_NEW, + ); + + }//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(); + + if ($tokens[($stackPtr + 1)]['code'] === T_SEMICOLON) { + // No content for this language construct. + return; + } + + if ($tokens[($stackPtr + 1)]['code'] === T_WHITESPACE) { + $content = $tokens[($stackPtr + 1)]['content']; + $contentLength = strlen($content); + if ($contentLength !== 1) { + $error = 'Language constructs must be followed by a single space; expected 1 space but found %s'; + $data = array($contentLength); + $phpcsFile->addError($error, $stackPtr, 'IncorrectSingle', $data); + } + } else { + $error = 'Language constructs must be followed by a single space; expected "%s" but found "%s"'; + $data = array( + $tokens[$stackPtr]['content'].' '.$tokens[($stackPtr + 1)]['content'], + $tokens[$stackPtr]['content'].$tokens[($stackPtr + 1)]['content'], + ); + $phpcsFile->addError($error, $stackPtr, 'Incorrect', $data); + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/LogicalOperatorSpacingSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/LogicalOperatorSpacingSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/LogicalOperatorSpacingSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/LogicalOperatorSpacingSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,106 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Sniffs_Squiz_WhiteSpace_OperatorSpacingSniff. + * + * Verifies that operators have valid spacing surrounding them. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_WhiteSpace_LogicalOperatorSpacingSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * A list of tokenizers this sniff supports. + * + * @var array + */ + public $supportedTokenizers = array( + 'PHP', + 'JS', + ); + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return PHP_CodeSniffer_Tokens::$booleanOperators; + + }//end register() + + + /** + * Processes this sniff, when one of its tokens is encountered. + * + * @param PHP_CodeSniffer_File $phpcsFile The current file being checked. + * @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(); + + // Check there is one space before the operator. + if ($tokens[($stackPtr - 1)]['code'] !== T_WHITESPACE) { + $error = 'Expected 1 space before logical operator; 0 found'; + $phpcsFile->addError($error, $stackPtr, 'NoSpaceBefore'); + } else { + $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); + if ($tokens[$stackPtr]['line'] === $tokens[$prev]['line'] + && strlen($tokens[($stackPtr - 1)]['content']) !== 1 + ) { + $found = strlen($tokens[($stackPtr - 1)]['content']); + $error = 'Expected 1 space before logical operator; %s found'; + $data = array($found); + $phpcsFile->addError($error, $stackPtr, 'TooMuchSpaceBefore', $data); + } + } + + // Check there is one space after the operator. + if ($tokens[($stackPtr + 1)]['code'] !== T_WHITESPACE) { + $error = 'Expected 1 space after logical operator; 0 found'; + $phpcsFile->addError($error, $stackPtr, 'NoSpaceAfter'); + } else { + $next = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr - 1), null, true); + if ($tokens[$stackPtr]['line'] === $tokens[$next]['line'] + && strlen($tokens[($stackPtr + 1)]['content']) !== 1 + ) { + $found = strlen($tokens[($stackPtr + 1)]['content']); + $error = 'Expected 1 space after logical operator; %s found'; + $data = array($found); + $phpcsFile->addError($error, $stackPtr, 'TooMuchSpaceAfter', $data); + } + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/MemberVarSpacingSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/MemberVarSpacingSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/MemberVarSpacingSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/MemberVarSpacingSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,120 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +if (class_exists('PHP_CodeSniffer_Standards_AbstractVariableSniff', true) === false) { + throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_Standards_AbstractVariableSniff not found'); +} + +/** + * Verifies that class members are spaced correctly. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_WhiteSpace_MemberVarSpacingSniff extends PHP_CodeSniffer_Standards_AbstractVariableSniff +{ + + + /** + * Processes the function tokens within the class. + * + * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found. + * @param int $stackPtr The position where the token was found. + * + * @return void + */ + protected function processMemberVar(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + $tokens = $phpcsFile->getTokens(); + + // There needs to be 1 blank line before the var, not counting comments. + $prevLineToken = null; + for ($i = ($stackPtr - 1); $i > 0; $i--) { + if (in_array($tokens[$i]['code'], PHP_CodeSniffer_Tokens::$commentTokens) === true) { + // Skip comments. + continue; + } else if (strpos($tokens[$i]['content'], $phpcsFile->eolChar) === false) { + // Not the end of the line. + continue; + } else { + // If this is a WHITESPACE token, and the token right before + // it is a DOC_COMMENT, then it is just the newline after the + // member var's comment, and can be skipped. + if ($tokens[$i]['code'] === T_WHITESPACE && in_array($tokens[($i - 1)]['code'], PHP_CodeSniffer_Tokens::$commentTokens) === true) { + continue; + } + + $prevLineToken = $i; + break; + } + } + + if (is_null($prevLineToken) === true) { + // Never found the previous line, which means + // there are 0 blank lines before the member var. + $foundLines = 0; + } else { + $prevContent = $phpcsFile->findPrevious(array(T_WHITESPACE, T_DOC_COMMENT), $prevLineToken, null, true); + $foundLines = ($tokens[$prevLineToken]['line'] - $tokens[$prevContent]['line']); + }//end if + + if ($foundLines !== 1) { + $error = 'Expected 1 blank line before member var; %s found'; + $data = array($foundLines); + $phpcsFile->addError($error, $stackPtr, 'After', $data); + } + + }//end processMemberVar() + + + /** + * Processes normal variables. + * + * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found. + * @param int $stackPtr The position where the token was found. + * + * @return void + */ + protected function processVariable(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + // We don't care about normal variables. + + }//end processVariable() + + + /** + * Processes variables in double quoted strings. + * + * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found. + * @param int $stackPtr The position where the token was found. + * + * @return void + */ + protected function processVariableInString(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + // We don't care about normal variables. + + }//end processVariableInString() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/ObjectOperatorSpacingSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/ObjectOperatorSpacingSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/ObjectOperatorSpacingSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/ObjectOperatorSpacingSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,76 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_WhiteSpace_ObjectOperatorSpacingSniff. + * + * Ensure there is no whitespace before a semicolon. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_WhiteSpace_ObjectOperatorSpacingSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array(T_OBJECT_OPERATOR); + + }//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(); + + $prevType = $tokens[($stackPtr - 1)]['code']; + if (in_array($prevType, PHP_CodeSniffer_Tokens::$emptyTokens) === true) { + $error = 'Space found before object operator'; + $phpcsFile->addError($error, $stackPtr, 'Before'); + } + + $nextType = $tokens[($stackPtr + 1)]['code']; + if (in_array($nextType, PHP_CodeSniffer_Tokens::$emptyTokens) === true) { + $error = 'Space found after object operator'; + $phpcsFile->addError($error, $stackPtr, 'After'); + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,214 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Sniffs_Squiz_WhiteSpace_OperatorSpacingSniff. + * + * Verifies that operators have valid spacing surrounding them. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_WhiteSpace_OperatorSpacingSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * A list of tokenizers this sniff supports. + * + * @var array + */ + public $supportedTokenizers = array( + 'PHP', + 'JS', + ); + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + $comparison = PHP_CodeSniffer_Tokens::$comparisonTokens; + $operators = PHP_CodeSniffer_Tokens::$operators; + $assignment = PHP_CodeSniffer_Tokens::$assignmentTokens; + + return array_unique(array_merge($comparison, $operators, $assignment)); + + }//end register() + + + /** + * Processes this sniff, when one of its tokens is encountered. + * + * @param PHP_CodeSniffer_File $phpcsFile The current file being checked. + * @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(); + + // Skip default values in function declarations. + if ($tokens[$stackPtr]['code'] === T_EQUAL + || $tokens[$stackPtr]['code'] === T_MINUS + ) { + if (isset($tokens[$stackPtr]['nested_parenthesis']) === true) { + $parenthesis = array_keys($tokens[$stackPtr]['nested_parenthesis']); + $bracket = array_pop($parenthesis); + if (isset($tokens[$bracket]['parenthesis_owner']) === true) { + $function = $tokens[$bracket]['parenthesis_owner']; + if ($tokens[$function]['code'] === T_FUNCTION + || $tokens[$function]['code'] === T_CLOSURE + ) { + return; + } + } + } + } + + if ($tokens[$stackPtr]['code'] === T_EQUAL) { + // Skip for '=&' case. + if (isset($tokens[($stackPtr + 1)]) === true && $tokens[($stackPtr + 1)]['code'] === T_BITWISE_AND) { + return; + } + } + + if ($tokens[$stackPtr]['code'] === T_BITWISE_AND) { + // If it's not a reference, then we expect one space either side of the + // bitwise operator. + if ($phpcsFile->isReference($stackPtr) === true) { + return; + } + + // Check there is one space before the & operator. + if ($tokens[($stackPtr - 1)]['code'] !== T_WHITESPACE) { + $error = 'Expected 1 space before "&" operator; 0 found'; + $phpcsFile->addError($error, $stackPtr, 'NoSpaceBeforeAmp'); + } else { + if (strlen($tokens[($stackPtr - 1)]['content']) !== 1) { + $found = strlen($tokens[($stackPtr - 1)]['content']); + $error = 'Expected 1 space before "&" operator; %s found'; + $data = array($found); + $phpcsFile->addError($error, $stackPtr, 'SpacingBeforeAmp', $data); + } + } + + // Check there is one space after the & operator. + if ($tokens[($stackPtr + 1)]['code'] !== T_WHITESPACE) { + $error = 'Expected 1 space after "&" operator; 0 found'; + $phpcsFile->addError($error, $stackPtr, 'NoSpaceAfterAmp'); + } else { + if (strlen($tokens[($stackPtr + 1)]['content']) !== 1) { + $found = strlen($tokens[($stackPtr + 1)]['content']); + $error = 'Expected 1 space after "&" operator; %s found'; + $data = array($found); + $phpcsFile->addError($error, $stackPtr, 'SpacingAfterAmp', $data); + } + } + + return; + }//end if + + if ($tokens[$stackPtr]['code'] === T_MINUS) { + // Check minus spacing, but make sure we aren't just assigning + // a minus value or returning one. + $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); + if ($tokens[$prev]['code'] === T_RETURN) { + // Just returning a negative value; eg. (return -1). + return; + } + + if (in_array($tokens[$prev]['code'], PHP_CodeSniffer_Tokens::$operators) === true) { + // Just trying to operate on a negative value; eg. ($var * -1). + return; + } + + if (in_array($tokens[$prev]['code'], PHP_CodeSniffer_Tokens::$comparisonTokens) === true) { + // Just trying to compare a negative value; eg. ($var === -1). + return; + } + + if (in_array($tokens[$prev]['code'], PHP_CodeSniffer_Tokens::$assignmentTokens) === true) { + // Just trying to assign a negative value; eg. ($var = -1). + return; + } + + // A list of tokens that indicate that the token is not + // part of an arithmetic operation. + $invalidTokens = array( + T_COMMA, + T_OPEN_PARENTHESIS, + T_OPEN_SQUARE_BRACKET, + T_DOUBLE_ARROW, + T_COLON, + T_INLINE_THEN, + T_INLINE_ELSE, + T_CASE, + ); + + if (in_array($tokens[$prev]['code'], $invalidTokens) === true) { + // Just trying to use a negative value; eg. myFunction($var, -2). + return; + } + }//end if + + $operator = $tokens[$stackPtr]['content']; + + if ($tokens[($stackPtr - 1)]['code'] !== T_WHITESPACE) { + $error = "Expected 1 space before \"$operator\"; 0 found"; + $phpcsFile->addError($error, $stackPtr, 'NoSpaceBefore'); + } else if (strlen($tokens[($stackPtr - 1)]['content']) !== 1) { + // Don't throw an error for assignments, because other standards allow + // multiple spaces there to align multiple assignments. + if (in_array($tokens[$stackPtr]['code'], PHP_CodeSniffer_Tokens::$assignmentTokens) === false) { + $found = strlen($tokens[($stackPtr - 1)]['content']); + $error = 'Expected 1 space before "%s"; %s found'; + $data = array( + $operator, + $found, + ); + $phpcsFile->addError($error, $stackPtr, 'SpacingBefore', $data); + } + } + + if ($tokens[($stackPtr + 1)]['code'] !== T_WHITESPACE) { + $error = "Expected 1 space after \"$operator\"; 0 found"; + $phpcsFile->addError($error, $stackPtr, 'NoSpaceAfter'); + } else if (strlen($tokens[($stackPtr + 1)]['content']) !== 1) { + $found = strlen($tokens[($stackPtr + 1)]['content']); + $error = 'Expected 1 space after "%s"; %s found'; + $data = array( + $operator, + $found, + ); + $phpcsFile->addError($error, $stackPtr, 'SpacingAfter', $data); + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/PropertyLabelSpacingSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/PropertyLabelSpacingSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/PropertyLabelSpacingSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/PropertyLabelSpacingSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,85 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_WhiteSpace_PropertyLabelSpacingSniff. + * + * Ensures that the colon in a property or label definition has a single + * space after it and no space before it. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_WhiteSpace_PropertyLabelSpacingSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * A list of tokenizers this sniff supports. + * + * @var array + */ + public $supportedTokenizers = array('JS'); + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array( + T_PROPERTY, + T_LABEL, + ); + + }//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(); + + $colon = $phpcsFile->findNext(T_COLON, ($stackPtr + 1)); + + if ($colon !== ($stackPtr + 1)) { + $error = 'There must be no space before the colon in a property/label declaration'; + $phpcsFile->addError($error, $stackPtr, 'Before'); + } + + if ($tokens[($colon + 1)]['code'] !== T_WHITESPACE || $tokens[($colon + 1)]['content'] !== ' ') { + $error = 'There must be a single space after the colon in a property/label declaration'; + $phpcsFile->addError($error, $stackPtr, 'After'); + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,110 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_Whitespace_ScopeClosingBraceSniff. + * + * Checks that the closing braces of scopes are aligned correctly. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_WhiteSpace_ScopeClosingBraceSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return PHP_CodeSniffer_Tokens::$scopeOpeners; + + }//end register() + + + /** + * Processes this test, when one of its tokens is encountered. + * + * @param PHP_CodeSniffer_File $phpcsFile All the tokens found in the document. + * @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(); + + // If this is an inline condition (ie. there is no scope opener), then + // return, as this is not a new scope. + if (isset($tokens[$stackPtr]['scope_closer']) === false) { + return; + } + + // We need to actually find the first piece of content on this line, + // as if this is a method with tokens before it (public, static etc) + // or an if with an else before it, then we need to start the scope + // checking from there, rather than the current token. + $lineStart = ($stackPtr - 1); + for ($lineStart; $lineStart > 0; $lineStart--) { + if (strpos($tokens[$lineStart]['content'], $phpcsFile->eolChar) !== false) { + break; + } + } + + // We found a new line, now go forward and find the + // first non-whitespace token. + $lineStart = $phpcsFile->findNext(array(T_WHITESPACE), ($lineStart + 1), null, true); + + $startColumn = $tokens[$lineStart]['column']; + $scopeStart = $tokens[$stackPtr]['scope_opener']; + $scopeEnd = $tokens[$stackPtr]['scope_closer']; + + // Check that the closing brace is on it's own line. + $lastContent = $phpcsFile->findPrevious(array(T_WHITESPACE), ($scopeEnd - 1), $scopeStart, true); + if ($tokens[$lastContent]['line'] === $tokens[$scopeEnd]['line']) { + $error = 'Closing brace must be on a line by itself'; + $phpcsFile->addError($error, $scopeEnd, 'ContentBefore'); + return; + } + + // Check now that the closing brace is lined up correctly. + $braceIndent = $tokens[$scopeEnd]['column']; + if (in_array($tokens[$stackPtr]['code'], array(T_CASE, T_DEFAULT)) === false) { + if ($braceIndent !== $startColumn) { + $error = 'Closing brace indented incorrectly; expected %s spaces, found %s'; + $data = array( + ($startColumn - 1), + ($braceIndent - 1), + ); + $phpcsFile->addError($error, $scopeEnd, 'Indent', $data); + } + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/ScopeKeywordSpacingSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/ScopeKeywordSpacingSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/ScopeKeywordSpacingSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/ScopeKeywordSpacingSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,87 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_WhiteSpace_ScopeKeywordSpacingSniff. + * + * Ensure there is a single space after scope keywords. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_WhiteSpace_ScopeKeywordSpacingSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + $register = PHP_CodeSniffer_Tokens::$scopeModifiers; + $register[] = T_STATIC; + return $register; + + }//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(); + + $prevToken = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); + $nextToken = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); + + if ($tokens[$stackPtr]['code'] === T_STATIC + && ($tokens[$nextToken]['code'] === T_DOUBLE_COLON + || $tokens[$prevToken]['code'] === T_NEW) + ) { + // Late static binding, e.g., static:: OR new static() usage. + return; + } + + $nextToken = $tokens[($stackPtr + 1)]; + if ($nextToken['code'] !== T_WHITESPACE + || strlen($nextToken['content']) !== 1 + || $nextToken['content'] === $phpcsFile->eolChar + ) { + $error = 'Scope keyword "%s" must be followed by a single space'; + $data = array($tokens[$stackPtr]['content']); + $phpcsFile->addError($error, $stackPtr, 'Incorrect', $data); + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/SemicolonSpacingSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/SemicolonSpacingSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/SemicolonSpacingSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/SemicolonSpacingSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,86 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_WhiteSpace_SemicolonSpacingSniff. + * + * Ensure there is no whitespace before a semicolon. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_WhiteSpace_SemicolonSpacingSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * A list of tokenizers this sniff supports. + * + * @var array + */ + public $supportedTokenizers = array( + 'PHP', + 'JS', + ); + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array(T_SEMICOLON); + + }//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(); + + $prevType = $tokens[($stackPtr - 1)]['code']; + if (in_array($prevType, PHP_CodeSniffer_Tokens::$emptyTokens) === true) { + $nonSpace = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 2), null, true); + $expected = $tokens[$nonSpace]['content'].';'; + $found = $phpcsFile->getTokensAsString($nonSpace, ($stackPtr - $nonSpace)).';'; + $error = 'Space found before semicolon; expected "%s" but found "%s"'; + $data = array( + $expected, + $found, + ); + $phpcsFile->addError($error, $stackPtr, 'Incorrect', $data); + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/SuperfluousWhitespaceSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/SuperfluousWhitespaceSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/SuperfluousWhitespaceSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/SuperfluousWhitespaceSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,231 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Squiz_Sniffs_WhiteSpace_SuperfluousWhitespaceSniff. + * + * Checks that no whitespace proceeds the first content of the file, exists + * after the last content of the file, resides after content on any line, or + * are two empty lines in functions. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Sniffs_WhiteSpace_SuperfluousWhitespaceSniff implements PHP_CodeSniffer_Sniff +{ + + /** + * A list of tokenizers this sniff supports. + * + * @var array + */ + public $supportedTokenizers = array( + 'PHP', + 'JS', + 'CSS', + ); + + /** + * If TRUE, whitespace rules are not checked for blank lines. + * + * Blank lines are those that contain only whitespace. + * + * @var boolean + */ + public $ignoreBlankLines = false; + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array( + T_OPEN_TAG, + T_CLOSE_TAG, + T_WHITESPACE, + T_COMMENT, + ); + + }//end register() + + + /** + * Processes this sniff, 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(); + + if ($tokens[$stackPtr]['code'] === T_OPEN_TAG) { + + /* + Check for start of file whitespace. + */ + + if ($phpcsFile->tokenizerType !== 'PHP') { + // The first token is always the open tag inserted when tokenizsed + // and the second token is always the first piece of content in + // the file. If the second token is whitespace, there was + // whitespace at the start of the file. + if ($tokens[($stackPtr + 1)]['code'] !== T_WHITESPACE) { + return; + } + } else { + // If its the first token, then there is no space. + if ($stackPtr === 0) { + return; + } + + for ($i = ($stackPtr - 1); $i >= 0; $i--) { + // If we find something that isn't inline html then there is something previous in the file. + if ($tokens[$i]['type'] !== 'T_INLINE_HTML') { + return; + } + + // If we have ended up with inline html make sure it isn't just whitespace. + $tokenContent = trim($tokens[$i]['content']); + if ($tokenContent !== '') { + return; + } + } + }//end if + + $phpcsFile->addError('Additional whitespace found at start of file', $stackPtr, 'StartFile'); + + } else if ($tokens[$stackPtr]['code'] === T_CLOSE_TAG) { + + /* + Check for end of file whitespace. + */ + + if ($phpcsFile->tokenizerType === 'JS') { + // The last token is always the close tag inserted when tokenized + // and the second last token is always the last piece of content in + // the file. If the second last token is whitespace, there was + // whitespace at the end of the file. + $stackPtr--; + } else if ($phpcsFile->tokenizerType === 'CSS') { + // The last two tokens are always the close tag and whitespace + // inserted when tokenizsed and the third last token is always the + // last piece of content in the file. If the third last token is + // whitespace, there was whitespace at the end of the file. + $stackPtr -= 2; + } + + if ($phpcsFile->tokenizerType === 'PHP') { + if (isset($tokens[($stackPtr + 1)]) === false) { + // The close PHP token is the last in the file. + return; + } + + for ($i = ($stackPtr + 1); $i < $phpcsFile->numTokens; $i++) { + // If we find something that isn't inline html then there + // is more to the file. + if ($tokens[$i]['type'] !== 'T_INLINE_HTML') { + return; + } + + // If we have ended up with inline html make sure it + // isn't just whitespace. + $tokenContent = trim($tokens[$i]['content']); + if (empty($tokenContent) === false) { + return; + } + } + } else { + // The pointer is now looking at the last content in the file and + // not the fake PHP end tag the tokenizer inserted. + if ($tokens[$stackPtr]['code'] !== T_WHITESPACE) { + return; + } + + // Allow a single newline at the end of the last line in the file. + if ($tokens[($stackPtr - 1)]['code'] !== T_WHITESPACE + && $tokens[$stackPtr]['content'] === $phpcsFile->eolChar + ) { + return; + } + + } + + $phpcsFile->addError('Additional whitespace found at end of file', $stackPtr, 'EndFile'); + + } else { + + /* + Check for end of line whitespace. + */ + + // Ignore whitespace that is not at the end of a line. + if (strpos($tokens[$stackPtr]['content'], $phpcsFile->eolChar) === false) { + return; + } + + // Ignore blank lines if required. + if ($this->ignoreBlankLines === true + && $tokens[($stackPtr - 1)]['line'] !== $tokens[$stackPtr]['line'] + ) { + return; + } + + $tokenContent = rtrim($tokens[$stackPtr]['content'], $phpcsFile->eolChar); + if (empty($tokenContent) === false) { + if (preg_match('|^.*\s+$|', $tokenContent) !== 0) { + $phpcsFile->addError('Whitespace found at end of line', $stackPtr, 'EndLine'); + } + } + + /* + Check for multiple blanks lines in a function. + */ + + if ($phpcsFile->hasCondition($stackPtr, T_FUNCTION) === true) { + if ($tokens[($stackPtr - 1)]['line'] < $tokens[$stackPtr]['line'] && $tokens[($stackPtr - 2)]['line'] === $tokens[($stackPtr - 1)]['line']) { + // This is an empty line and the line before this one is not + // empty, so this could be the start of a multiple empty + // line block. + $next = $phpcsFile->findNext(T_WHITESPACE, $stackPtr, null, true); + $lines = $tokens[$next]['line'] - $tokens[$stackPtr]['line']; + if ($lines > 1) { + $error = 'Functions must not contain multiple empty lines in a row; found %s empty lines'; + $data = array($lines); + $phpcsFile->addError($error, $stackPtr, 'EmptyLines', $data); + } + } + } + + }//end if + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Arrays/ArrayBracketSpacingUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Arrays/ArrayBracketSpacingUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Arrays/ArrayBracketSpacingUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Arrays/ArrayBracketSpacingUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,15 @@ + 'bar', + 'bar' => 'foo', +]; + +$array = []; +?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Arrays/ArrayBracketSpacingUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Arrays/ArrayBracketSpacingUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Arrays/ArrayBracketSpacingUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Arrays/ArrayBracketSpacingUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,72 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the ArrayBracketSpacing sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_Arrays_ArrayBracketSpacingUnitTest 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 array( + 3 => 1, + 4 => 2, + 5 => 3, + 7 => 3, + ); + + }//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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,181 @@ + 1, + ); +} + + +class TestClass +{ + public $good = array( + 'width' => '', + 'height' => '', + ); + + private $_bad = Array( + 'width' => '', + 'height' => '' + ); + + + public function test() + { + $truck = array( + 'width' => '', + 'height' => '', + ); + + $plane = Array( + 'width' => '', + 'height' => '', + ); + + $car = array( + 'width' => '', + 'height' => '', + ); + + $bus = array( + 'width' => '', + 'height' => '' + ); + + $train = array ( + TRUE, + FALSE, + 'aaa' + ); + + $inline = array('aaa', 'bbb', 'ccc'); + $inline = array('aaa'); + $inline = Array('aaa'); + + $bigone = array( + 'name' => 'bigone', + 'children' => Array( + '1a' => 'child', + '11b' => 'child', + '111c' => 'child', + 'children' => Array( + 'child' => 'aaa', + ), + ), + 'short_name' => 'big' + ); + } + +}//end class + +$value = array ( ); +$value = array( ); +$value = array('1'=>$one, '2' => $two, '3'=> $three, '4' =>$four); +$value = array('1'=>$one); + +if (in_array('1', array('1','2','3')) === TRUE) { + $value = in_array('1', array('1' , '2', '3','4')); +} + +$value = array( + '1'=> TRUE, + FALSE, + '3' => 'aaa',); + +$value = array( + '1'=> TRUE, + FALSE, + ); + +$value = array( + TRUE, + '1' => FALSE, + ); + +$value = array(1, + 2 , + 3 , + ); + +$value = array(1 => $one, + 2 => $two , + 3 => $three , + ); + +$value = array( + 'tag' => $tag, + 'space' => $this->_getIndentation($tag, $tagElement), + ); + +$expected = array( + array( + '1' => 1, + '1' => 2, + ), + ); + +$expected = array( + array( + '1' => 1, + '1' => 2 + ) + ); + +// Space in second arg. +$args = array( + '"'.$this->id.'"', + (int) $hasSessions, + ); + +// No errors. +$paths = array( + Init::ROOT_DIR.'/Systems' => 'Systems', + Init::ROOT_DIR.'/Installer' => 'Systems', + ); + +$x = array( + ); + +$x = array('test' + ); +$x = array('test', + ); +$x = array('name' => 'test', + ); + +$x = array( + $x, + ); + +$func = array( + $x, + 'get'.$x.'Replacement' + ); + +$array = array( + 'input_one' => 'one', + 'inputTwo' => 'two', + 'input_3' => 3, + ); + +$array = array( + 'input_one', + 'inputTwo', + 'input_3', + ); + +// Malformed +$foo = array(1 +, 2); + +$listItems[$aliasPath] = array('itemContent' => implode('
', $aliases)); + +$listItems[$aliasPath] = array( + 'itemContent' => implode('
', $aliases) + ); +?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,118 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the ArrayDeclaration sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_Arrays_ArrayDeclarationUnitTest 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 array( + 7 => 2, + 9 => 2, + 22 => 1, + 23 => 1, + 24 => 1, + 25 => 1, + 31 => 1, + 35 => 1, + 36 => 1, + 41 => 1, + 46 => 1, + 47 => 1, + 50 => 1, + 51 => 1, + 53 => 1, + 56 => 1, + 58 => 1, + 61 => 1, + 62 => 1, + 63 => 1, + 64 => 1, + 65 => 1, + 66 => 3, + 70 => 1, + 76 => 2, + 77 => 1, + 78 => 7, + 79 => 2, + 81 => 2, + 82 => 4, + 87 => 1, + 88 => 1, + 92 => 1, + 97 => 1, + 100 => 1, + 101 => 1, + 102 => 1, + 105 => 1, + 106 => 1, + 107 => 1, + 125 => 1, + 126 => 1, + 141 => 1, + 144 => 1, + 146 => 1, + 148 => 1, + 151 => 1, + 157 => 1, + 174 => 3, + 179 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/ClassDefinitionClosingBraceSpaceUnitTest.css php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/ClassDefinitionClosingBraceSpaceUnitTest.css --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/ClassDefinitionClosingBraceSpaceUnitTest.css 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/ClassDefinitionClosingBraceSpaceUnitTest.css 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,45 @@ +.my-style { +} + + +.my-style { +} + +/* Comment */ + +.my-style { +} + + +/* Comment */ + +.my-style { + float: left; + +} + +.AssetLineageWidgetType-item { + color: #CCC; +} + +/*.AssetLineageWidgetType-item2 .selected, +.AssetLineageWidgetType-item .selected { +}*/ + +.AssetLineageWidgetType-item.selected { +} + +@media screen and (max-device-width: 769px) { + + header #logo img { + max-width: 100%; + } + +} + +@media screen and (max-device-width: 769px) { + + header #logo img { + max-width: 100%; + } +} diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/ClassDefinitionClosingBraceSpaceUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/ClassDefinitionClosingBraceSpaceUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/ClassDefinitionClosingBraceSpaceUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/ClassDefinitionClosingBraceSpaceUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,70 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the ClassDefinitionClosingBraceSpace sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_CSS_ClassDefinitionClosingBraceSpaceUnitTest 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 array( + 2 => 1, + 11 => 1, + 19 => 1, + 44 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/ClassDefinitionNameSpacingUnitTest.css php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/ClassDefinitionNameSpacingUnitTest.css --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/ClassDefinitionNameSpacingUnitTest.css 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/ClassDefinitionNameSpacingUnitTest.css 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,57 @@ +.AssetListingEditWidgetType-BottomPanel select, +#EditEditingModeWidgetType-assetEditor-filters-assetTypes-addNew { + float: left; +} + +.AssetListingEditWidgetType-BottomPanel select, + +#EditEditingModeWidgetType-assetEditor-filters-assetTypes-addNew { + float: left; +} + +.AssetListingEditWidgetType-BottomPanel select, +/*.AssetListingEditWidgetType-BottomPanel ul,*/ +#EditEditingModeWidgetType-assetEditor-filters-assetTypes-addNew { + float: left; +} + +.AssetListingEditWidgetType-BottomPanel select, + +.AssetListingEditWidgetType-BottomPanel ul, +#EditEditingModeWidgetType-assetEditor-filters-assetTypes-addNew { + float: left; +} + +#SuperUsersSystemConfigScreen-table { + display: block; + left: 50%; + margin-left: -500px; + margin-top: 180px; + position: relative; + width: 1000px; +} + +/** + * More styles below here. + */ + +td.TableWidgetType-header.TableWidgetType-header-lastLogin, +td.TableWidgetType-header.TableWidgetType-header-remove, +td.TableWidgetType-header.TableWidgetType-header-email, +td.TableWidgetType-header.TableWidgetType-header-userName { + background: url(images/ScreenImages/table_header_bg.png) repeat-x; + border-top: 1px solid #D4D4D4; + color: #787878; + height: 33px; + padding-left: 12px; + width: 150px; +} + +@media screen and (max-device-width: 769px) { + + header #logo img { + max-width: 100%; + padding: 20px; + margin: 40px; + } +} diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/ClassDefinitionNameSpacingUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/ClassDefinitionNameSpacingUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/ClassDefinitionNameSpacingUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/ClassDefinitionNameSpacingUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,68 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the ClassDefinitionNameSpacing sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_CSS_ClassDefinitionNameSpacingUnitTest 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 array( + 7 => 1, + 19 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/ClassDefinitionOpeningBraceSpaceUnitTest.css php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/ClassDefinitionOpeningBraceSpaceUnitTest.css --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/ClassDefinitionOpeningBraceSpaceUnitTest.css 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/ClassDefinitionOpeningBraceSpaceUnitTest.css 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,31 @@ +.HelpWidgetType-new-bug-title { + float: left; +} +.HelpWidgetType-new-bug-title { + float: left; +} +.HelpWidgetType-new-bug-title { + float: left; +} +.HelpWidgetType-new-bug-title{ + float: left; +} +.HelpWidgetType-new-bug-title { + + float: left; +} + +@media screen and (max-device-width: 769px) { + + header #logo img { + max-width: 100%; + } + +} + +@media screen and (max-device-width: 769px) { + header #logo img { + max-width: 100%; + } + +} diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/ClassDefinitionOpeningBraceSpaceUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/ClassDefinitionOpeningBraceSpaceUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/ClassDefinitionOpeningBraceSpaceUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/ClassDefinitionOpeningBraceSpaceUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,71 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the ClassDefinitionOpeningBraceSpace sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_CSS_ClassDefinitionOpeningBraceSpaceUnitTest 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 array( + 4 => 1, + 7 => 1, + 10 => 1, + 13 => 1, + 26 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/ColonSpacingUnitTest.css php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/ColonSpacingUnitTest.css --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/ColonSpacingUnitTest.css 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/ColonSpacingUnitTest.css 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,32 @@ +body { +font-family: Arial, Helvetica, sans-serif; +margin : 40px 0 0 0; +padding : 0; +background: #8FB7DB url(diag_lines_bg.gif) top left; +margin-top: +10px; +margin-bottom: +0px; +} + +.TableWidgetType .recover:hover { + background-color: #FFF; +} + +#clearCache-settings:rootNodes-list_0 { + border-top: none; +} + +.LookupEditScreenWidgetType-urls a, .LookupEditScreenWidgetType-urls a:visited { + text-decoration: none; + color: #444; +} + +/* checking embedded PHP */ +li { + background:url(/images//bullet.gif) left px no-repeat; + margin:0px; + padding-left:10px; + margin-bottom:px; + line-height:13px; +} diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/ColonSpacingUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/ColonSpacingUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/ColonSpacingUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/ColonSpacingUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,75 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the ColonSpacing sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_CSS_ColonSpacingUnitTest 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 array( + 3 => 1, + 4 => 2, + 5 => 1, + 6 => 1, + 8 => 1, + 27 => 1, + 28 => 1, + 29 => 1, + 30 => 1, + 31 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/ColourDefinitionUnitTest.css php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/ColourDefinitionUnitTest.css --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/ColourDefinitionUnitTest.css 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/ColourDefinitionUnitTest.css 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,7 @@ +#title-bar-bottom-right { + background-color: #333333; + padding: 10px; + border-bottom: 1px dotted #F0F0F0; + border-top: 1px dotted #FF00FF; + background: #8fb7db url(diag_lines_bg.gif) top left; +} diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/ColourDefinitionUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/ColourDefinitionUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/ColourDefinitionUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/ColourDefinitionUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,68 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the ColourDefinition sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_CSS_ColourDefinitionUnitTest 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 array( + 2 => 1, + 5 => 1, + 6 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/DisallowMultipleStyleDefinitionsUnitTest.css php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/DisallowMultipleStyleDefinitionsUnitTest.css --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/DisallowMultipleStyleDefinitionsUnitTest.css 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/DisallowMultipleStyleDefinitionsUnitTest.css 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,11 @@ +.SettingsTabPaneWidgetType-tab-mid { + background: transparent url(tab_inact_mid.png) repeat-x; + height: 100%;float: left; + line-height: -25px; + cursor: pointer; margin: 10px; float: right; +} + +/* testing embedded PHP */ +li { + background:url(/images//bullet.gif) left px no-repeat; margin:0px; padding-left:10px; margin-bottom:px; line-height:13px; +} diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/DisallowMultipleStyleDefinitionsUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/DisallowMultipleStyleDefinitionsUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/DisallowMultipleStyleDefinitionsUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/DisallowMultipleStyleDefinitionsUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,68 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the DisallowMultipleStyleDefinitions sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_CSS_DisallowMultipleStyleDefinitionsUnitTest 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 array( + 3 => 1, + 5 => 2, + 10 => 4, + ); + + }//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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/DuplicateClassDefinitionUnitTest.css php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/DuplicateClassDefinitionUnitTest.css --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/DuplicateClassDefinitionUnitTest.css 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/DuplicateClassDefinitionUnitTest.css 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,33 @@ +.AssetLineageWidgetType-item { + color: #FFF; +} + +.AssetLineageWidgetType-title { + color: #CCC; +} + +.AssetLineageWidgetType-item { + color: #CCC; +} + +.AssetLineageWidgetType-item .selected { +} + +.AssetLineageWidgetType-item.selected { +} + +#Blah .AssetLineageWidgetType-item { +} + +#X.selected, +.AssetLineageWidgetType-item { +} + +.MyClass, .YourClass { +} + +.YourClass, .MyClass { +} + +.YourClass, .MyClass, .OurClass { +} diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/DuplicateClassDefinitionUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/DuplicateClassDefinitionUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/DuplicateClassDefinitionUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/DuplicateClassDefinitionUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,68 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the DuplicateClassDefinition sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_CSS_DuplicateClassDefinitionUnitTest 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 array( + 9 => 1, + 29 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/DuplicateStyleDefinitionUnitTest.css php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/DuplicateStyleDefinitionUnitTest.css --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/DuplicateStyleDefinitionUnitTest.css 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/DuplicateStyleDefinitionUnitTest.css 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,18 @@ +.ViperSubToolbar-wrapper { + height: 34px; + left: 0; + position: fixed; + top: 60px; + z-index: 997; + left: 50%; +} + +.expandable { + -moz-transition-property: margin-left, margin-right; + -moz-transition-duration: 0.2s; + -moz-transition-timing-function: ease; + -webkit-transition-property: margin-left, margin-right; + -webkit-transition-duration: 0.2s; + -webkit-transition-timing-function: ease; + z-index: 2; +} diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/DuplicateStyleDefinitionUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/DuplicateStyleDefinitionUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/DuplicateStyleDefinitionUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/DuplicateStyleDefinitionUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,67 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the DuplicateStyleDefinition sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_CSS_DuplicateStyleDefinitionUnitTest 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 array( + 7 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/EmptyClassDefinitionUnitTest.css php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/EmptyClassDefinitionUnitTest.css --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/EmptyClassDefinitionUnitTest.css 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/EmptyClassDefinitionUnitTest.css 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,15 @@ +.HelpWidgetType-new-bug-title {} +.HelpWidgetType-new-bug-title { +} +.HelpWidgetType-new-bug-title { + +} +.HelpWidgetType-new-bug-title { + +} +.HelpWidgetType-new-bug-title { + /* Nothing to see here */ +} +.HelpWidgetType-new-bug-title { + float: left; +} diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/EmptyClassDefinitionUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/EmptyClassDefinitionUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/EmptyClassDefinitionUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/EmptyClassDefinitionUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,70 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the EmptyClassDefinition sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_CSS_EmptyClassDefinitionUnitTest 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 array( + 1 => 1, + 2 => 1, + 4 => 1, + 7 => 1, + 10 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/EmptyStyleDefinitionUnitTest.css php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/EmptyStyleDefinitionUnitTest.css --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/EmptyStyleDefinitionUnitTest.css 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/EmptyStyleDefinitionUnitTest.css 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,5 @@ +#MetadataAdminScreen-addField-fieldType { + margin-left: 10px; + margin-right: + float: ; +} diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/EmptyStyleDefinitionUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/EmptyStyleDefinitionUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/EmptyStyleDefinitionUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/EmptyStyleDefinitionUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,67 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the EmptyStyleDefinition sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_CSS_EmptyStyleDefinitionUnitTest 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 array( + 3 => 1, + 4 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/IndentationUnitTest.css php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/IndentationUnitTest.css --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/IndentationUnitTest.css 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/IndentationUnitTest.css 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,44 @@ +body { + + font-family: Arial, Helvetica, sans-serif; + margin: 40px 0 0 0; +padding: 0; + background: #8FB7DB url(diag_lines_bg.gif) top left; + +} + +td { + margin: 40px; + + padding: 20px; +} + +/* +#AdminScreenModeWidgetType-tab_pane-containers .TabPaneWidgetType-tab-selected-left { + background: transparent url(images/ScreenImages/tab_on_left.png) no-repeat; +} +#AdminScreenModeWidgetType-tab_pane-containers .TabPaneWidgetType-tab-selected-right { + background: transparent url(images/ScreenImages/tab_on_right.png) no-repeat; +} +*/ + +@media screen and (max-device-width: 769px) { + + header #logo img { + max-width: 100%; + padding: 20px; + margin: 40px; + } +} + +@media screen and (max-device-width: 769px) { + + header #logo img { + max-width: 100%; + } + + header #logo img { + min-width: 100%; + } + +} diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/IndentationUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/IndentationUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/IndentationUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/IndentationUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,73 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the Indentation sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_CSS_IndentationUnitTest 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 array( + 2 => 1, + 3 => 1, + 5 => 1, + 6 => 1, + 7 => 1, + 12 => 1, + 28 => 1, + 30 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/LowercaseStyleDefinitionUnitTest.css php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/LowercaseStyleDefinitionUnitTest.css --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/LowercaseStyleDefinitionUnitTest.css 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/LowercaseStyleDefinitionUnitTest.css 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,6 @@ +.SettingsTabPaneWidgetType-tab-mid { + font-family: Arial; + Font-Family: arial; + background-color: #DA9393; + BACKGROUND-IMAGE: URL(Warning_Close.png); +} diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/LowercaseStyleDefinitionUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/LowercaseStyleDefinitionUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/LowercaseStyleDefinitionUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/LowercaseStyleDefinitionUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,68 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the LowercaseStyleDefinition sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_CSS_LowercaseStyleDefinitionUnitTest 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 array( + 2 => 1, + 3 => 1, + 5 => 2, + ); + + }//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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/MissingColonUnitTest.css php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/MissingColonUnitTest.css --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/MissingColonUnitTest.css 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/MissingColonUnitTest.css 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,14 @@ +.my-style { + margin-right 15px; + float: left; + margin-left 15px; + margin-top: 15px; + margin-bottom 15px; +} + +@media screen and (max-device-width: 769px) { + header #logo img { + max-width: 100%; + margin-bottom 15px; + } +} diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/MissingColonUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/MissingColonUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/MissingColonUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/MissingColonUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,69 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the MissingColon sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_CSS_MissingColonUnitTest 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 array( + 2 => 1, + 4 => 1, + 6 => 1, + 12 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/OpacityUnitTest.css php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/OpacityUnitTest.css --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/OpacityUnitTest.css 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/OpacityUnitTest.css 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,12 @@ +.my-style { + opacity: 0; + opacity: 0.0; + opacity: 1; + opacity: 1.0; + opacity: 1.5; + opacity: .5; + opacity: 0.5; + opacity: 2; + opacity: -1; + opacity: 0.55; +} diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/OpacityUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/OpacityUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/OpacityUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/OpacityUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,72 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the Opacity sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_CSS_OpacityUnitTest 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 array( + 3 => 1, + 5 => 1, + 6 => 1, + 7 => 1, + 9 => 1, + 10 => 1, + 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/SemicolonSpacingUnitTest.css php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/SemicolonSpacingUnitTest.css --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/SemicolonSpacingUnitTest.css 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/SemicolonSpacingUnitTest.css 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,20 @@ +.HelpWidgetType-new-bug-title { + width: 308px + float: left; +} + +#MetadataAdminScreen-addField-add { + float: left ; +} + +.TableWidgetType .recover:hover { + background-color: #FFF; +} + +#clearCache-settings:rootNodes-list_0 { + border-top: none; +} + +.HelpWidgetType-list { + list-style-image: url(); +} diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/SemicolonSpacingUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/SemicolonSpacingUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/SemicolonSpacingUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CSS/SemicolonSpacingUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,67 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the SemicolonSpacing sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_CSS_SemicolonSpacingUnitTest 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 array( + 2 => 1, + 7 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Classes/ClassDeclarationUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Classes/ClassDeclarationUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Classes/ClassDeclarationUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Classes/ClassDeclarationUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,100 @@ + + + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the ClassDeclaration sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_Classes_ClassDeclarationUnitTest 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 array( + 10 => 1, + 15 => 2, + 18 => 1, + 22 => 3, + 23 => 3, + 24 => 3, + 27 => 2, + 28 => 1, + 30 => 2, + 34 => 1, + 35 => 1, + 39 => 1, + 42 => 2, + 45 => 1, + 48 => 1, + 50 => 2, + 55 => 1, + 59 => 4, + 63 => 1, + 65 => 1, + 69 => 3, + 74 => 2, + 77 => 1, + 80 => 1, + 85 => 3, + 89 => 1, + 92 => 1, + 97 => 1, + 100 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Classes/ClassFileNameUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Classes/ClassFileNameUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Classes/ClassFileNameUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Classes/ClassFileNameUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,21 @@ + \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Classes/ClassFileNameUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Classes/ClassFileNameUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Classes/ClassFileNameUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Classes/ClassFileNameUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,75 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the ClassFileName sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_Classes_ClassFileNameUnitTest 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 array( + 9 => 1, + 10 => 1, + 11 => 1, + 15 => 1, + 16 => 1, + 17 => 1, + 18 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Classes/DuplicatePropertyUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Classes/DuplicatePropertyUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Classes/DuplicatePropertyUnitTest.js 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Classes/DuplicatePropertyUnitTest.js 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,45 @@ +var x = { + abc: 1, + zyz: 2, + abc: 5, + mno: { + abc: 4 + }, + abc: 5 + + this.request({ + action: 'getSubmissions' + }); + + this.request({ + action: 'deleteSubmission' + }); +} + + +LinkingEditScreenWidgetType.prototype = { + + _addDeleteButtonEvent: function(parentid) + { + var params = { + screen: 'LinkingEditScreenWidget', + assetid: self.assetid, + parentid: parentid, + assetid: parentid, + op: 'deleteLink' + }; + + }, + + saveDesignEdit: function() + { + var params = { + screen: [this.id, 'Widget'].join(''), + assetid: this.assetid, + changes: dfx.jsonEncode(this.currnetLinksWdgt.getChanges()), + op: 'saveLinkEdit' + }; + + } + +}; \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Classes/DuplicatePropertyUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Classes/DuplicatePropertyUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Classes/DuplicatePropertyUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Classes/DuplicatePropertyUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,69 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the DuplicateProperty sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_Classes_DuplicatePropertyUnitTest 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 array( + 4 => 1, + 8 => 1, + 28 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Classes/LowercaseClassKeywordsUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Classes/LowercaseClassKeywordsUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Classes/LowercaseClassKeywordsUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Classes/LowercaseClassKeywordsUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,12 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Classes/LowercaseClassKeywordsUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Classes/LowercaseClassKeywordsUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Classes/LowercaseClassKeywordsUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Classes/LowercaseClassKeywordsUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,80 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the LowercaseClassKeywords sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_Classes_LowercaseClassKeywordsUnitTest 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() + { + $errors = array( + 2 => 3, + 3 => 3, + 4 => 1, + 9 => 1, + 10 => 1, + ); + + // The trait test will only work in PHP versions where traits exist. + if (version_compare(PHP_VERSION, '5.4.0') >= 0) { + $errors[5] = 1; + } + + return $errors; + + }//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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Classes/SelfMemberReferenceUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Classes/SelfMemberReferenceUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Classes/SelfMemberReferenceUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Classes/SelfMemberReferenceUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,92 @@ +testResults; + + + // Correct call to self. + $testResults[] = self::selfMemberReferenceUnitTestFunction(); + $testResults[] = parent::selfMemberReferenceUnitTestFunction(); + + // Incorrect case. + $testResults[] = Self::selfMemberReferenceUnitTestFunction(); + $testResults[] = SELF::selfMemberReferenceUnitTestFunction(); + $testResults[] = SelfMemberReferenceUnitTestExample::selfMemberReferenceUnitTestFunction(); + + + // Incorrect spacing. + $testResults[] = self ::selfMemberReferenceUnitTestFunction(); + $testResults[] = self:: selfMemberReferenceUnitTestFunction(); + $testResults[] = self :: selfMemberReferenceUnitTestFunction(); + + } + + + function selfMemberReferenceUnitTestFunction() + { + $this->testCount = $this->testCount + 1; + return $this->testCount; + + } + + +} + + +class MyClass { + + public static function test($value) { + echo "$value\n"; + } + + public static function walk() { + $callback = function($value, $key) { + // This is valid because you cant use self:: in a closure + MyClass::test($value); + }; + + $array = array(1,2,3); + array_walk($array, $callback); + } +} + +MyClass::walk(); + +class Controller +{ + public function Action() + { + Doctrine\Common\Util\Debug::dump(); + } +} + +namespace TYPO3\CMS\Reports; + +class Status { + const NOTICE = -2; + const INFO = -1; + const OK = 0; + const WARNING = 1; + const ERROR = 2; +} + +namespace TYPO3\CMS\Reports\Report\Status; + +class Status implements \TYPO3\CMS\Reports\ReportInterface { + public function getHighestSeverity(array $statusCollection) { + $highestSeverity = \TYPO3\CMS\Reports\Status::NOTICE; + } +} +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Classes/SelfMemberReferenceUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Classes/SelfMemberReferenceUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Classes/SelfMemberReferenceUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Classes/SelfMemberReferenceUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,74 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the SelfMemberReference sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_Classes_SelfMemberReferenceUnitTest 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 array( + 24 => 1, + 25 => 1, + 26 => 1, + 30 => 1, + 31 => 1, + 32 => 2, + ); + + }//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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Classes/ValidClassNameUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Classes/ValidClassNameUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Classes/ValidClassNameUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Classes/ValidClassNameUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,35 @@ + \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Classes/ValidClassNameUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Classes/ValidClassNameUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Classes/ValidClassNameUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Classes/ValidClassNameUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,75 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the ValidClassName sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_Classes_ValidClassNameUnitTest 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 array( + 9 => 1, + 10 => 1, + 14 => 1, + 15 => 1, + 20 => 1, + 30 => 1, + 32 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CodeAnalysis/EmptyStatementUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CodeAnalysis/EmptyStatementUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CodeAnalysis/EmptyStatementUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/CodeAnalysis/EmptyStatementUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,57 @@ + + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ + +/** + * Unit test class for the EmptyStatement sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_CodeAnalysis_EmptyStatementUnitTest 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 array( + 3 => 1, + 15 => 1, + 17 => 1, + 19 => 1, + 30 => 1, + 35 => 1, + 41 => 1, + 47 => 1, + 52 => 1, + 55 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/BlockCommentUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/BlockCommentUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/BlockCommentUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/BlockCommentUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,181 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/BlockCommentUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/BlockCommentUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/BlockCommentUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/BlockCommentUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,106 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the BlockComment sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_Commenting_BlockCommentUnitTest 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() + { + $errors = array( + 8 => 1, + 19 => 1, + 20 => 1, + 24 => 1, + 30 => 1, + 31 => 1, + 34 => 1, + 40 => 1, + 45 => 1, + 49 => 1, + 51 => 1, + 53 => 1, + 57 => 1, + 60 => 1, + 61 => 1, + 63 => 1, + 65 => 1, + 68 => 1, + 70 => 1, + 75 => 1, + 84 => 1, + 85 => 2, + 86 => 1, + 87 => 1, + 89 => 1, + 92 => 1, + 111 => 1, + 159 => 1, + ); + + // The trait tests will only work in PHP version where traits exist and + // will throw errors in earlier versions. + if (version_compare(PHP_VERSION, '5.4.0') < 0) { + $errors[170] = 2; + $errors[171] = 1; + $errors[172] = 2; + } + + return $errors; + + }//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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/ClassCommentUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/ClassCommentUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/ClassCommentUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/ClassCommentUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,133 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/ClassCommentUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/ClassCommentUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/ClassCommentUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/ClassCommentUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,87 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for ClassCommentSniff. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_Commenting_ClassCommentUnitTest 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 array( + 4 => 1, + 15 => 1, + 22 => 1, + 25 => 1, + 28 => 1, + 49 => 1, + 55 => 1, + 64 => 2, + 77 => 1, + 88 => 1, + 97 => 1, + 99 => 1, + 108 => 1, + 110 => 1, + 118 => 1, + 128 => 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 array( + 30 => 1, + 31 => 1, + 51 => 1, + 68 => 1, + 69 => 1, + ); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,77 @@ + \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,77 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the ClosingDeclarationComment sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_Commenting_ClosingDeclarationCommentUnitTest 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 array( + 13 => 1, + 17 => 1, + 31 => 1, + 41 => 1, + 59 => 1, + 63 => 1, + 67 => 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 array( + 71 => 1, + ); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,52 @@ + \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,80 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the DocCommentAlignment sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_Commenting_DocCommentAlignmentUnitTest 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 array( + 11 => 1, + 17 => 1, + 18 => 1, + 19 => 1, + 23 => 1, + 24 => 1, + 25 => 2, + 26 => 1, + 32 => 1, + 33 => 1, + 38 => 1, + 39 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/EmptyCatchCommentUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/EmptyCatchCommentUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/EmptyCatchCommentUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/EmptyCatchCommentUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,55 @@ + \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/EmptyCatchCommentUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/EmptyCatchCommentUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/EmptyCatchCommentUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/EmptyCatchCommentUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,74 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the EmptyCatchComment sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_Commenting_EmptyCatchCommentUnitTest 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 array( + 13 => 1, + 33 => 1, + 49 => 1, + 50 => 1, + 51 => 1, + 52 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,39 @@ + +* @author +* @copyright 1997~1994 The PHP Group +* @license http://www.php.net/license/3_0.txt +* @summary An unknown summary tag +* +*/ +?> + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.js 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.js 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,38 @@ + + + + +/** +* +* 0Multi-line short description without full stop +* +* +* asdasd +* long description for file (if any) +* asdasdadada +* +* PHP versio +* +* LICENSE: This source file is subject to version 3.0 of the PHP license +* that is available through the world-wide-web at the following URI: +* http://www.php.net/license/3_0.txt. If you did not receive a copy of +* the PHP License and are unable to obtain it through the web, please +* send a note to license@php.net so we can mail you a copy immediately. +* @package SquizCMS +* @package ADDITIONAL PACKAGE TAG +* @subpackage not_camelcased +* @author Antônio Carlos Venâncio Júnior +* @author +* @copyright 1997~1994 The PHP Group +* @license http://www.php.net/license/3_0.txt +* @summary An unknown summary tag +* +*/ + + +/** +* This bit here is not qualified as file comment +* +* as it is not the first comment in the file +* +*/ diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,89 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for FileCommentSniff. + * + * Verifies that : + *
    + *
  • A doc comment exists.
  • + *
  • Short description must start with a capital letter and end with a period.
  • + *
  • There must be one blank newline after the short description.
  • + *
  • A PHP version is specified.
  • + *
  • Check the order of the tags.
  • + *
  • Check the indentation of each tag.
  • + *
  • Check required and optional tags and the format of their content.
  • + *
+ * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_Commenting_FileCommentUnitTest 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 array( + 1 => 1, + 6 => 3, + 8 => 1, + 10 => 1, + 21 => 1, + 22 => 2, + 23 => 1, + 24 => 2, + 26 => 1, + 27 => 2, + 30 => 2, + ); + + }//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 array( + 28 => 1, + ); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/FunctionCommentThrowTagUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/FunctionCommentThrowTagUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/FunctionCommentThrowTagUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/FunctionCommentThrowTagUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,232 @@ +callSomeFunction(); + + }//end okFunction() + + + /** + * Comment inside function. + * + * @throws Exception + */ + function okFunction() + { + /** + * @var FooClass + */ + $foo = FooFactory::factory(); + throw new Exception; + + }//end okFunction + + +}//end class + +class NamespacedException { + /** + * @throws \Exception + */ + public function foo() { + throw new \Exception(); + } + + /** + * @throws \Foo\Bar\FooBarException + */ + public function fooBar2() { + throw new \Foo\Bar\FooBarException(); + } + + /** + * @throws FooBarException + */ + public function fooBar2() { + throw new \Foo\Bar\FooBarException(); + } +} + +class Foo { + /** + * Comment + */ + public function foo() { + }//end foo() + + public function bar() { + throw new Exception(); + } +} +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/FunctionCommentThrowTagUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/FunctionCommentThrowTagUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/FunctionCommentThrowTagUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/FunctionCommentThrowTagUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,81 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for FunctionCommentThrowTagSniff. + * + * Verifies that : + *
    + *
  • A @throws tag exists for a function that throws exceptions.
  • + *
  • The number of @throws tags and the number of throw tokens matches.
  • + *
  • The exception type in comment matches the token.
  • + *
+ * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_Commenting_FunctionCommentThrowTagUnitTest 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 array( + 9 => 1, + 21 => 1, + 35 => 1, + 46 => 1, + 59 => 1, + 60 => 1, + 106 => 1, + 123 => 1, + 214 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,578 @@ +MyClass) + */ +public function caseSensitive($a1, $a2, $a3, arRay $a4, $a5, $a6, myclas $a7) +{ + +}//end caseSensitive() + + +/** + * More type hint check for custom type and array. + * + * @param array $a1 Comment here. + * @param array $a2 Comment here. + * @param MyClass $a3 Comment here. + * @param MyClass $a4 Comment here. + * + * @return array(int => MyClass) + */ +public function typeHint(MyClass $a1, $a2, myclass $a3, $a4) +{ + return (3 => 'myclass obj'); + +}//end typeHint() + + +/** + * Mixed variable type separated by a '|'. + * + * @param array|string $a1 Comment here. + * @param mixed $a2 Comment here. + * @param string|array $a3 Comment here. + * @param MyClass|int $a4 Comment here. + * + * @return bool + */ +public function mixedType($a1, $a2, $a3, $a4) +{ + return true; + +}//end mixedType() + + +/** + * Array type. + * + * @param array(MyClass) $a1 OK. + * @param array() $a2 Invalid type. + * @param array( $a3 Typo. + * @param array(int) $a4 Use 'array(integer)' instead. + * @param array(int => integer) $a5 Use 'array(integer => integer)' instead. + * @param array(integer => bool) $a6 Use 'array(integer => boolean)' instead. + * @param aRRay $a7 Use 'array' instead. + * @param string $a8 String with unknown type hint. + * + * @return int + */ +public function mixedArrayType($a1, $a2, array $a3, $a4, $a5, $a6, $a7, unknownTypeHint $a8) +{ + return 1; + +}//end mixedArrayType() + + +/** + */ +function empty1() +{ +}//end empty1() + + +/** + * + */ +function empty2() +{ +}//end empty2() + + +/** + * + * + * + */ +function empty3() +{ +}//end empty3 + + +/** + * @return boolean + */ +public function missingShortDescriptionInFunctionComment() +{ + return true; + +}//end missingShortDescriptionInFunctionComment() + + +class Another_Class +{ + + /** + * Destructor should not include a return tag. + * + * @return void + */ + function __destruct() + { + return; + } + + /** + * Constructor should not include a return tag. + * + * @return void + */ + function __construct() + { + return; + } + +}//end class + + +/** + * Comment param alignment test. + * + * @param string $varrr1 Comment1.. + * @param string $vr2 Comment2. + * @param string $var3 Comment3.. + * + * @return void + */ +public static function paramAlign($varrr1, $vr2, $var3) +{ + +}//end paramAlign() + + +/** + * Comment. + * + * @param string $id Comment. + * @param array $design Comment. + * + * @return void + */ +public static function paint($id, array $design) +{ + +}//end paint() + + +/** + * Adds specified class name to class attribute of this widget. + * + * @since 4.0.0 + * @return string + */ +public function myFunction() +{ + if ($condition === FALSE) { + echo 'hi'; + } + +}//end myFunction() + + +/** + * Adds specified class name to class attribute of this widget. + * + * @return string + */ +public function myFunction() +{ + if ($condition === FALSE) { + echo 'hi'; + return; + } + + return 'blah'; + +}//end myFunction() + + +/** + * Adds specified class name to class attribute of this widget. + * + * @return string + */ +public function myFunction() +{ + if ($condition === FALSE) { + echo 'hi'; + } + + return 'blah'; + +}//end myFunction() + +/** + * Test function. + * + * @param string $arg1 An argument + * + * @access public + * @return bool + */ + +echo $blah; + +function myFunction($arg1) {} + +class MyClass() { + /** + * An abstract function. + * + * @return array(string) + */ + abstract final protected function myFunction(); +} + +/** + * Comment. + * + * @param mixed $test An argument. + * + * @return mixed + */ +function test($test) +{ + if ($test === TRUE) { + return; + } + + return $test; + +}//end test() + + +/** Comment. + * + * @return mixed + * + */ +function test() +{ + +}//end test() + +/** + * Comment. + * + * @param \other\ns\item $test An argument. + * + * @return mixed + */ +function test(\other\ns\item $test) +{ + return $test; + +}//end test() + +/** + * Comment. + * + * @param item $test An argument. + * + * @return mixed + */ +function test(\other\ns\item $test) +{ + return $test; + +}//end test() + +/** + * Comment. + * + * @param \first\ns\item $test An argument. + * + * @return mixed + */ +function test(\first\ns\item $test = \second\ns::CONSTANT) +{ + return $test; + +}//end test() + +/** + * Comment. + * + * @param \first\item $test An argument. + * + * @return mixed + */ +function test(\first\ns\item $test = \second\ns::CONSTANT) +{ + return $test; + +}//end test() + +// Closures should be ignored. +preg_replace_callback( + '~-([a-z])~', + function ($match) { + return strtoupper($match[1]); + }, + 'hello-world' +); + +$callback = function ($bar) use ($foo) + { + $bar += $foo; + }; + +/** + * Comment should end with '*', not '**' before the slash. + **/ +function test123() { + +} + +/** + * Variable number of args. + * + * @param string $a1 Comment here. + * @param string $a2 Comment here. + * @param string $a2,... Comment here. + * + * @return boolean + */ +public function variableArgs($a1, $a2) +{ + return true; + +}//end variableArgs() + +/** + * čż™ćŻä¸€ćťˇćµ‹čŻ•čŻ„论. + * + * @return void + */ +public function test() +{ + +}//end variableArgs() + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,144 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for FunctionCommentSniff. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_Commenting_FunctionCommentUnitTest 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 array( + 6 => 1, + 8 => 1, + 10 => 4, + 12 => 3, + 13 => 3, + 14 => 1, + 15 => 1, + 28 => 1, + 35 => 3, + 38 => 1, + 40 => 1, + 41 => 1, + 43 => 1, + 52 => 1, + 53 => 1, + 103 => 1, + 109 => 1, + 110 => 1, + 112 => 2, + 122 => 1, + 123 => 4, + 124 => 3, + 125 => 4, + 126 => 6, + 137 => 3, + 138 => 2, + 139 => 3, + 143 => 2, + 155 => 2, + 158 => 1, + 166 => 1, + 173 => 1, + 180 => 1, + 183 => 1, + 193 => 4, + 195 => 1, + 196 => 1, + 199 => 2, + 210 => 1, + 211 => 1, + 222 => 1, + 223 => 1, + 224 => 1, + 225 => 1, + 226 => 1, + 227 => 1, + 230 => 2, + 232 => 1, + 246 => 1, + 248 => 4, + 261 => 1, + 263 => 1, + 276 => 1, + 277 => 1, + 278 => 1, + 279 => 1, + 280 => 1, + 281 => 1, + 284 => 1, + 286 => 2, + 293 => 1, + 300 => 1, + 308 => 1, + 318 => 1, + 334 => 1, + 344 => 1, + 358 => 1, + 359 => 1, + 373 => 2, + 387 => 1, + 407 => 1, + 441 => 1, + 470 => 1, + 474 => 1, + 500 => 1, + 526 => 1, + 548 => 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 array( + 198 => 1, + ); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,113 @@ + One +// -> One.One +// -> Two + +/* + Here is some inline example code: + -> One + -> One.One + -> Two +*/ + +/** + * Comment should be ignored in PHP 5.4. + * + */ +trait MyTrait { + +} +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.js 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.js 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,111 @@ +// Some content here. +var code = 'hello'; + +// This comment contains # multiple +// hash signs (#). +code = 'hello'; + +/** + * This is the first line of a function comment. + * This is the second line. + */ +function testFunction() +{ + // Callback methods which are added by external objects. + this.callbacks = {}; + +}//end testFunction() + +/** + * This is the first line of a class comment. + * This is the second line. + */ +myClass.prototype = { + + /** + * This is the first line of a method comment. + * This is the second line. + */ + load: function(url, callback) + { + // Some code here. + + } +}; + +// some code goes here! + +/* + A longer comment goes here. + It spans multiple lines!! + Or does it? +*/ + +// 0This is a simple multi-line +// comment! +code = 'hello'; + +//This is not valid. +code = 'hello'; + +// Neither is this! +code = 'hello'; + +// +code = 'hello'; + +/** Neither is this! **/ +code = 'hello'; + +/** + * This is the first line of a function comment. + * This is the second line. + */ +var myFunction = function() { +} + +/** + * This is the first line of a function comment. + * This is the second line. + */ +myFunction = function() { +} + +/** + * This is the first line of a function comment. + * This is the second line. + */ +myClass.myFunction = function() { +} + +dfx.getIframeDocument = function(iframe) +{ + return doc; + +};//end dfx.getIframeDocument() + +mig.Gallery.prototype = { + + init: function(cb) + { + + },//end init() + + imageClicked: function(id) + { + + }//end imageClicked() + +}; + +// Here is some inline example code: +// -> One +// -> One.One +// -> Two + +/* + Here is some inline example code: + -> One + -> One.One + -> Two +*/ \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,110 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the InlineComment sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_Commenting_InlineCommentUnitTest 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='InlineCommentUnitTest.inc') + { + switch ($testFile) { + case 'InlineCommentUnitTest.inc': + $errors = array( + 17 => 1, + 27 => 1, + 28 => 1, + 32 => 2, + 36 => 1, + 44 => 2, + 54 => 1, + 58 => 1, + 61 => 1, + 64 => 2, + 67 => 1, + 95 => 1, + 96 => 1, + 97 => 3, + ); + + // The trait tests will only work in PHP version where traits exist and + // will throw errors in earlier versions. + if (version_compare(PHP_VERSION, '5.4.0') < 0) { + $errors[106] = 1; + } + + return $errors; + case 'InlineCommentUnitTest.js': + return array( + 31 => 1, + 36 => 2, + 44 => 1, + 48 => 1, + 51 => 1, + 54 => 2, + 57 => 1, + 102 => 1, + 103 => 1, + 104 => 3, + ); + default: + return array(); + }//end switch + + }//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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/LongConditionClosingCommentUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/LongConditionClosingCommentUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/LongConditionClosingCommentUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/LongConditionClosingCommentUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,696 @@ + \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/LongConditionClosingCommentUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/LongConditionClosingCommentUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/LongConditionClosingCommentUnitTest.js 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/LongConditionClosingCommentUnitTest.js 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,444 @@ +function long_function() +{ + if (longFunction) { + // This is a long + // IF statement + // that does + // not have + // and ELSE + // block on it + variable = 'hello'; + + if (variable === 'hello') { + // This is a short + // IF statement + } + + if (variable === 'hello') { + // This is a short + // IF statement + } else { + // This is a short ELSE + // statement + } + }//end if + + if (longFunction) { + // This is a long + // IF statement + // that does + // not have + // and ELSE + // block on it + variable = 'hello'; + + if (variable === 'hello') { + // This is a short + // IF statement + } + + if (variable === 'hello') { + // This is a short + // IF statement + } else { + // This is a short ELSE + // statement + } + } + + if (longFunction) { + // This is a long + // IF statement + // that does + // not have + // and ELSE + // block on it + variable = 'hello'; + + if (variable === 'hello') { + // This is a short + // IF statement + } + + if (variable === 'hello') { + // This is a short + // IF statement + } else { + // This is a short ELSE + // statement + } + } else { + // Short ELSE + }//end if + + if (longFunction) { + // This is a long + // IF statement + // that does + // not have + // and ELSE + // block on it + variable = 'hello'; + + if (variable === 'hello') { + // This is a short + // IF statement + } + + if (variable === 'hello') { + // This is a short + // IF statement + } else { + // This is a short ELSE + // statement + } + } else { + // Short ELSE + } +} + +for (variable=1; variable < 20; variable++) { + // Line 1 + // Line 2 + // Line 3 + // Line 4 + // Line 5 + // Line 6 + // Line 7 + // Line 8 + // Line 9 + // Line 10 + // Line 11 + // Line 12 + // Line 13 + // Line 14 + // Line 15 + // Line 16 + // Line 17 + // Line 18 + // Line 19 + // Line 20 +}//end for + +for (variable=1; variable < 20; variable++) { + // Line 1 + // Line 2 + // Line 3 + // Line 4 + // Line 5 + // Line 6 + // Line 7 + // Line 8 + // Line 9 + for (val =1; val < 20; val++) { + // Short for. + } + // Line 13 + // Line 14 + // Line 15 + // Line 16 + // Line 17 + // Line 18 + // Line 19 + // Line 20 +} + +while (variable < 20) { + // Line 1 + // Line 2 + // Line 3 + // Line 4 + // Line 5 + // Line 6 + // Line 7 + // Line 8 + // Line 9 + // Line 10 + // Line 11 + // Line 12 + // Line 13 + // Line 14 + // Line 15 + // Line 16 + // Line 17 + // Line 18 + // Line 19 + // Line 20 +}//end while + +while (variable < 20) { + // Line 1 + // Line 2 + // Line 3 + // Line 4 + // Line 5 + // Line 6 + // Line 7 + // Line 8 + // Line 9 + while (something) { + // Short while. + } + // Line 13 + // Line 14 + // Line 15 + // Line 16 + // Line 17 + // Line 18 + // Line 19 + // Line 20 +} + +if (longFunction) { + // This is a long + // IF statement + // that does + // not have + // and ELSE + // block on it + variable = 'hello'; + + if (variable === 'hello') { + // This is a short + // IF statement + } + + if (variable === 'hello') { + // This is a short + // IF statement + } else { + // This is a short ELSE + // statement + } +} //end if + +if (longFunction) { + // This is a long + // IF statement + // that does + // not have + // and ELSE + // block on it + variable = 'hello'; + + if (variable === 'hello') { + // This is a short + // IF statement + } + + if (variable === 'hello') { + // This is a short + // IF statement + } else { + // This is a short ELSE + // statement + } +} else { + // Short ELSE +} //end if + +for (variable=1; variable < 20; variable++) { + // Line 1 + // Line 2 + // Line 3 + // Line 4 + // Line 5 + // Line 6 + // Line 7 + // Line 8 + // Line 9 + // Line 10 + // Line 11 + // Line 12 + // Line 13 + // Line 14 + // Line 15 + // Line 16 + // Line 17 + // Line 18 + // Line 19 + // Line 20 +} //end for + +while (variable < 20) { + // Line 1 + // Line 2 + // Line 3 + // Line 4 + // Line 5 + // Line 6 + // Line 7 + // Line 8 + // Line 9 + // Line 10 + // Line 11 + // Line 12 + // Line 13 + // Line 14 + // Line 15 + // Line 16 + // Line 17 + // Line 18 + // Line 19 + // Line 20 +} //end while + +while (variable < 20) { + // Line 1 + // Line 2 + // Line 3 + // Line 4 + // Line 5 + // Line 6 + // Line 7 + // Line 8 + // Line 9 + // Line 10 + // Line 11 + // Line 12 + // Line 13 + // Line 14 + // Line 15 + // Line 16 + // Line 17 + // Line 18 + // Line 19 + // Line 20 +}//end for + +if (true) { + // Line 1 + // Line 2 + // Line 3 + // Line 4 + // Line 5 + // Line 6 + // Line 7 + // Line 8 + // Line 9 + // Line 10 + // Line 11 + // Line 12 + // Line 13 + // Line 14 + // Line 15 + // Line 16 + // Line 17 + // Line 18 + // Line 19 + // Line 20 +} else if (condition) { + // Line 1 + // Line 2 + // Line 3 + // Line 4 + // Line 5 + // Line 6 + // Line 7 + // Line 8 + // Line 9 + // Line 10 + // Line 11 + // Line 12 + // Line 13 + // Line 14 + // Line 15 + // Line 16 + // Line 17 + // Line 18 + // Line 19 + // Line 20 +} else { + // Line 1 + // Line 2 + // Line 3 + // Line 4 + // Line 5 + // Line 6 + // Line 7 + // Line 8 + // Line 9 + // Line 10 + // Line 11 + // Line 12 + // Line 13 + // Line 14 + // Line 15 + // Line 16 + // Line 17 + // Line 18 + // Line 19 + // Line 20 +}//end if + +if (something) { + // Line 1 + // Line 2 +} else if (somethingElse) { + // Line 1 + // Line 2 +} else { + // Line 1 + // Line 2 + // Line 3 + // Line 4 + // Line 5 + // Line 6 + // Line 7 + // Line 8 + // Line 9 + // Line 10 + // Line 11 + // Line 12 + // Line 13 + // Line 14 + // Line 15 + // Line 16 + // Line 17 + // Line 18 + // Line 19 + // Line 20 +} + +switch (something) { + case '1': + // Line 1 + // Line 2 + // Line 3 + // Line 4 + // Line 5 + break; + case '2': + // Line 1 + // Line 2 + // Line 3 + // Line 4 + // Line 5 + break; + case '3': + // Line 1 + // Line 2 + // Line 3 + // Line 4 + // Line 5 + break; + case '4': + // Line 1 + // Line 2 + // Line 3 + // Line 4 + // Line 5 + break; + case '5': + // Line 1 + // Line 2 + // Line 3 + // Line 4 + // Line 5 + break; +} + +// Wrong comment +if (condition) { + condition = true; +}//end foreach \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/LongConditionClosingCommentUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/LongConditionClosingCommentUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/LongConditionClosingCommentUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/LongConditionClosingCommentUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,113 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the LongConditionClosingComment sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_Commenting_LongConditionClosingCommentUnitTest 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='LongConditionClosingCommentUnitTest.inc') + { + switch ($testFile) { + case 'LongConditionClosingCommentUnitTest.inc': + return array( + 49 => 1, + 99 => 1, + 146 => 1, + 192 => 1, + 215 => 1, + 238 => 1, + 261 => 1, + 286 => 1, + 309 => 1, + 332 => 1, + 355 => 1, + 378 => 1, + 493 => 1, + 531 => 1, + 536 => 1, + 540 => 1, + 562 => 1, + 601 => 1, + 629 => 1, + 663 => 1, + ); + break; + case 'LongConditionClosingCommentUnitTest.js': + return array( + 47 => 1, + 97 => 1, + 144 => 1, + 190 => 1, + 213 => 1, + 238 => 1, + 261 => 1, + 284 => 1, + 307 => 1, + 401 => 1, + 439 => 1, + 444 => 1, + ); + break; + default: + return array(); + break; + }//end switch + + }//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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,22 @@ + \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.js 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.js 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,30 @@ +function test(id, buttons) // cool function +{ + alert('hello'); + alert('hello again'); // And again. + // Valid comment. + +}//end test() + +var good = true; // Indeed. + +mig.Gallery.prototype = { + + init: function(cb) + { + + },//end init() + + imageClicked: function(id) + { + + }//end imageClicked() + +}; + +dfx.getIframeDocument = function(iframe) +{ + + return doc; + +};//end dfx.getIframeDocument() \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,87 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the PostStatementComment sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_Commenting_PostStatementCommentUnitTest 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='PostStatementCommentUnitTest.inc') + { + switch ($testFile) { + case 'PostStatementCommentUnitTest.inc': + return array( + 6 => 1, + 10 => 1, + 18 => 1, + ); + break; + case 'PostStatementCommentUnitTest.js': + return array( + 1 => 1, + 4 => 1, + 9 => 1, + ); + break; + default: + return array(); + break; + }//end switch + + }//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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,196 @@ + $content) { + echo $content; + } + + return $var1; + + }//end checkVariable() + + + /** + * + * + */ + $emptyVarDoc = ''; + + /** + * Var type checking (int v.s. integer). + * + * @var int + */ + private $_varSimpleTypeCheck; + + + /** + * Var type checking (array(int => string) v.s. array(int => string)). + * + * @var array(int => string) + */ + private $_varArrayTypeCheck; + + + /** + * Var type checking (STRING v.s. string). + * + * @var STRING + */ + private $_varCaseTypeCheck; + + + /** + * @var integer + */ + private $_varWithNoShortComment; + + protected $noComment2 = ''; + + +}//end class + + +/** + * VariableCommentUnitTest2. + * + * Long description goes here. + * + */ +class VariableCommentUnitTest2 +{ + + public $hello; + + /** Comment starts here. + * + * @var string + * + */ + private $_varCaseTypeCheck; + + /** + * čż™ćŻä¸€ćťˇćµ‹čŻ•čŻ„论. + * + * @var string + */ + public $foo; + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,95 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for VariableCommentSniff. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_Commenting_VariableCommentUnitTest 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 array( + 6 => 1, + 8 => 1, + 21 => 1, + 24 => 1, + 28 => 1, + 38 => 1, + 41 => 1, + 53 => 1, + 56 => 1, + 63 => 1, + 64 => 1, + 69 => 2, + 73 => 1, + 81 => 1, + 82 => 1, + 84 => 1, + 90 => 1, + 92 => 1, + 128 => 1, + 137 => 1, + 145 => 1, + 153 => 1, + 158 => 1, + 159 => 1, + 163 => 1, + 178 => 1, + 180 => 1, + 184 => 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 array( + 93 => 1, + ); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,161 @@ + 0); + +do +{ + echo $i; +} while ($i > 0); + +do +{ + echo $i; +} +while ($i > 0); + +do { echo $i; } while ($i > 0); + +do{ + echo $i; +}while($i > 0); + + +// while +while ($i < 1) { + echo $i; +} + +while($i < 1){ + echo $i; +} + +while ($i < 1) { echo $i; } + + +// for +for ($i = 1; $i < 1; $i++) { + echo $i; +} + +for($i = 1; $i < 1; $i++){ + echo $i; +} + +for ($i = 1; $i < 1; $i++) { echo $i; } + + +// foreach +foreach ($items as $item) { + echo $item; +} + +foreach($items as $item){ + echo $item; +} + +for ($items as $item) { echo $item; } + + +// if +if ($i == 0) { + $i = 1; +} + +if($i == 0){ + $i = 1; +} + +if ($i == 0) { $i = 1; } + + +// else +if ($i == 0) { + $i = 1; +} else { + $i = 0; +} + +if ($i == 0) { + $i = 1; +}else{ + $i = 0; +} + +if ($i == 0) { $i = 1; } else { $i = 0; } + + +// else +if ($i == 0) { + $i = 1; +} else { + $i = 0; +} + +if ($i == 0) { + $i = 1; +}else{ + $i = 0; +} + +if ($i == 0) { $i = 1; } else { $i = 0; } + + +// else if +if ($i == 0) { + $i = 1; +} else if ($i == 2) { + $i = 0; +} + +if ($i == 0) { + $i = 1; +}else if($i == 2){ + $i = 0; +} + +if ($i == 0) { $i = 1; } else if ($i == 2) { $i = 0; } + +if ($i == 0) { // comments are not allowed + $i = 1; +} + +if ($i == 0) {// comments are not allowed + $i = 1; +} + +if ($i == 0) { /* comments are not allowed*/ + $i = 1; +} + +if ($i == 0) +{ // this is not ok + $i = 1; +} + +if ($i == 0) /* this is not ok */ { +} + +try { + $code = 'this'; +} catch (Exception $e) { + // Caught! +} + +try { $code = 'this'; } catch (Exception $e) { + // Caught! +} + +do { echo $i; +} while ($i > 0); + +if ($a) { + +} +elseif ($b) { + +} +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.js 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.js 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,125 @@ +// do ... while +i = 0; +do { + i = 0; +} while (i > 0); + +do +{ + i = 0; +} while (i > 0); + +do +{ + i = 0; +} +while (i > 0); + +do { i = 0; } while (i > 0); + +do{ + i = 0; +}while(i > 0); + +// while +while (i < 1) { + i = 0; +} + +while(i < 1){ + i = 0; +} + +while (i < 1) { i = 0; } + +// for +for (i = 1; i < 1; i++) { + i = 0; +} + +for(i = 1; i < 1; i++){ + i = 0; +} + +for (i = 1; i < 1; i++) { i = 0; } + +// if +if (i == 0) { + i = 1; +} + +if(i == 0){ + i = 1; +} + +if (i == 0) { i = 1; } + +// else +if (i == 0) { + i = 1; +} else { + i = 0; +} + +if (i == 0) { + i = 1; +}else{ + i = 0; +} + +if (i == 0) { i = 1; } else { i = 0; } + +// else +if (i == 0) { + i = 1; +} else { + i = 0; +} + +// else if +if (i == 0) { + i = 1; +} else if (i == 2) { + i = 0; +} + +if (i == 0) { + i = 1; +}else if(i == 2){ + i = 0; +} + +if (i == 0) { i = 1; } else if (i == 2) { i = 0; } + +if (i == 0) { // comments are not allowed + i = 1; +} + +if (i == 0) {// comments are not allowed + i = 1; +} + +if (i == 0) { /* comments are not allowed*/ + i = 1; +} + +if (i == 0) +{ // this is not ok + i = 1; +} + +if (i == 0) /* this is not ok */ { +} + +try { + code = 'this'; +} catch (e) { + // Caught! +} + +try { code = 'this'; } catch (e) { + // Caught! +} + +do { i = 0; +} while (i > 0); \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,128 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the ControlSignature sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_ControlStructures_ControlSignatureUnitTest 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='ControlSignatureUnitTest.inc') + { + switch ($testFile) { + case 'ControlSignatureUnitTest.inc': + return array( + 9 => 1, + 14 => 1, + 20 => 1, + 22 => 1, + 32 => 1, + 36 => 1, + 44 => 1, + 48 => 1, + 56 => 1, + 60 => 1, + 68 => 1, + 72 => 1, + 84 => 1, + 88 => 2, + 100 => 1, + 104 => 2, + 116 => 2, + 120 => 3, + 122 => 1, + 126 => 1, + 130 => 1, + 134 => 1, + 139 => 1, + 148 => 1, + 152 => 1, + 158 => 1, + ); + break; + case 'ControlSignatureUnitTest.js': + return array( + 7 => 1, + 12 => 1, + 18 => 1, + 20 => 1, + 29 => 1, + 33 => 1, + 40 => 1, + 44 => 1, + 51 => 1, + 55 => 1, + 66 => 1, + 70 => 2, + 88 => 2, + 92 => 3, + 94 => 1, + 98 => 1, + 102 => 1, + 106 => 1, + 111 => 1, + 120 => 1, + 124 => 1, + ); + break; + default: + return array(); + break; + }//end switch + + }//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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ElseIfDeclarationUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ElseIfDeclarationUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ElseIfDeclarationUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ElseIfDeclarationUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,16 @@ + \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ElseIfDeclarationUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ElseIfDeclarationUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ElseIfDeclarationUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ElseIfDeclarationUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,70 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the ElseIfDeclaration sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_ControlStructures_ElseIfDeclarationUnitTest 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 array( + 8 => 1, + 13 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ForEachLoopDeclarationUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ForEachLoopDeclarationUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ForEachLoopDeclarationUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ForEachLoopDeclarationUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,24 @@ + $that) { +} + +// Invalid. +foreach ( $something as $blah => $that ) { +} + +foreach ($something as $blah => $that) { +} + +foreach ($something as $blah => $that) { +} + +foreach (${something}AS$blah=>$that) { +} + +// The works. +foreach ( $something aS $blah => $that ) { +} + +?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ForEachLoopDeclarationUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ForEachLoopDeclarationUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ForEachLoopDeclarationUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ForEachLoopDeclarationUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,73 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the ForEachLoopDeclaration sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_ControlStructures_ForEachLoopDeclarationUnitTest 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 array( + 8 => 2, + 11 => 2, + 14 => 2, + 17 => 5, + 21 => 7, + ); + + }//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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,30 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.js 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.js 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,34 @@ +// Valid. +for (var i = 0; i < 10; i++) { +} + +// Invalid. +for ( i = 0; i < 10; i++ ) { +} + +for (i = 0; i < 10; i++) { +} + +for (var i = 0 ; i < 10 ; i++) { +} + +for (i = 0;i < 10;i++) { +} + +// The works. +for ( var i = 0 ; i < 10 ; i++ ) { +} + +this.formats = {}; +dfx.inherits('ContentFormat', 'Widget'); + +for (var widgetid in this.loadedContents) { + if (dfx.isset(widget) === true) { + widget.loadAutoSaveCWidgetStore.setData('activeScreen', null);widget.getContents(this.loadedContents[widgetid], function() {self.widgetLoaded(widget.id);}); + } +} + +for (var i = 0; i < 10;) { +} +for (var i = 0; i < 10; ) { +} diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,93 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the ForEachLoopDeclaration sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_ControlStructures_ForLoopDeclarationUnitTest 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='ForLoopDeclarationUnitTest.inc') + { + switch ($testFile) { + case 'ForLoopDeclarationUnitTest.inc': + return array( + 8 => 2, + 11 => 2, + 14 => 2, + 17 => 2, + 21 => 6, + 27 => 1, + ); + break; + case 'ForLoopDeclarationUnitTest.js': + return array( + 6 => 2, + 9 => 2, + 12 => 2, + 15 => 2, + 19 => 6, + 33 => 1, + ); + break; + default: + return array(); + break; + }//end switch + + }//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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/InlineIfDeclarationUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/InlineIfDeclarationUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/InlineIfDeclarationUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/InlineIfDeclarationUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,26 @@ +id.'"', + '"'.$this->stepInfo['title'].'"', + '"'.((isset($this->stepInfo['description']) === TRUE) ? $this->stepInfo['description'] : '').'"', + '"'.(isset($this->stepInfo['description']) === TRUE ? $this->stepInfo['description'] : '').'"', + '"'.$this->stepInfo['title'].'"', + ); + +echo (TRUE)?'Hello':'Bye'; + +?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/InlineIfDeclarationUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/InlineIfDeclarationUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/InlineIfDeclarationUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/InlineIfDeclarationUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,78 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the InlineIfDeclaration sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_ControlStructures_InlineIfDeclarationUnitTest 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 array( + 4 => 1, + 5 => 1, + 6 => 1, + 7 => 1, + 8 => 1, + 9 => 1, + 10 => 1, + 13 => 1, + 20 => 1, + 24 => 4, + ); + + }//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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/LowercaseDeclarationUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/LowercaseDeclarationUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/LowercaseDeclarationUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/LowercaseDeclarationUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,23 @@ + \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/LowercaseDeclarationUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/LowercaseDeclarationUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/LowercaseDeclarationUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/LowercaseDeclarationUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,79 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the LowercaseDeclaration sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_ControlStructures_LowercaseDeclarationUnitTest 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 array( + 3 => 1, + 5 => 1, + 7 => 1, + 9 => 1, + 10 => 1, + 12 => 1, + 14 => 1, + 15 => 1, + 16 => 1, + 20 => 1, + 21 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,259 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.js 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.js 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,258 @@ + + +// Valid SWITCH statement. +switch (something) { + case '1': + myvar = '1'; + break; + + case '2': + case '3': + myvar = '5'; + break; + + case '4': + myvar = '4'; + break; + + default: + myvar = null; + break; +} + +// Alignment wrong. +switch (something) { + case '1': + myvar = '1'; + break; + +case '2': + case '3': + myvar = '5'; + break; + +case '4': + myvar = '4'; +break; + + default: + myvar = null; + break; +} + +// Closing brace wrong. +switch (something) { + case '1': + myvar = '1'; + break; + } + +// PEAR style. +switch (something) { +case '1': + myvar = '1'; + break; +case '2': +case '3': + myvar = '5'; + break; +case '4': + myvar = '4'; + break; +default: + myvar = null; + break; +} + +// Valid, but missing BREAKS. +switch (something) { + case '1': + myvar = '1'; + + case '2': + case '3': + myvar = '5'; + + case '4': + myvar = '4'; + + default: + myvar = null; +} + +// Invalid, and missing BREAKS. +switch (something) { + Case '1' : + myvar = '1'; + +case '2': + case '3' : + myvar = '5'; + + case'4': + myvar = '4'; + + Default : + myvar = null; + something = 'hello'; + other = 'hi'; + } + +// Valid +switch (condition) { + case 'string': + varStr = 'test'; + + default: + // Ignore the default. + break; +} + +// No default comment +switch (condition) { + case 'string': + varStr = 'test'; + + default: + break; +} + +// Break problems +switch (condition) { + case 'string': + + + varStr = 'test'; + + break; + + + case 'bool': + varStr = 'test'; + + + break; + default: + + varStr = 'test'; + break; + +} + +switch (var) { + case 'one': + case 'two': + break; + + case 'three': + // Nothing to do. + break; + + case 'four': + echo hi; + break; + + default: + // No default. + break; +} + +switch (var) { + case 'one': + if (blah) { + } + + break; + + default: + // No default. + break; +} + +switch (name) { + case "1": + switch (name2) { + case "1": + return true; + break; + + case "2": + return true; + break; + + default: + // No default. + break; + } + break; + + case "2": +switch (name2) { + case "1": + return true; + break; + + case "2": + return true; + break; + + default: + // No default. + break; +} + break; +} + +switch (name) { + case "1": + switch (name2) { + case "1": + return true; + + default: + // No default. + break; + } + break; + + default: + // No default. + break; +} + +switch (name2) { + default: + // No default. + break; +} + +switch (foo) { + case "1": + return true; + + default: + if (foo === false) { + break; + } + break; +} + +// Valid SWITCH statement. +switch (something) { + case '1': + myvar = '1'; + return '1'; + + case '2': + case '3': + myvar = '5'; + return '2'; + + case '4': + myvar = '4'; + return '3'; + + default: + myvar = null; + return '4'; +} diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,107 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the SwitchDeclaration sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_ControlStructures_SwitchDeclarationUnitTest 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='SwitchDeclarationUnitTest.inc') + { + return array( + 27 => 1, + 29 => 1, + 34 => 1, + 36 => 1, + 44 => 1, + 48 => 1, + 52 => 1, + 54 => 1, + 55 => 1, + 56 => 1, + 58 => 1, + 59 => 1, + 61 => 1, + 62 => 1, + 79 => 1, + 85 => 2, + 88 => 2, + 89 => 2, + 92 => 1, + 95 => 3, + 99 => 1, + 116 => 1, + 122 => 1, + 127 => 2, + 134 => 2, + 135 => 1, + 138 => 1, + 143 => 1, + 144 => 1, + 147 => 1, + 165 => 1, + 172 => 1, + 176 => 2, + 180 => 1, + 192 => 2, + 196 => 1, + 223 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Debug/JSLintUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Debug/JSLintUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Debug/JSLintUnitTest.js 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Debug/JSLintUnitTest.js 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,2 @@ +alert('hi') +alert('hi'); diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Debug/JSLintUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Debug/JSLintUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Debug/JSLintUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Debug/JSLintUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,81 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the JSLint sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_Debug_JSLintUnitTest extends AbstractSniffUnitTest +{ + + + /** + * Should this test be skipped for some reason. + * + * @return void + */ + protected function shouldSkipTest() + { + $jslPath = PHP_CodeSniffer::getConfigData('jslint_path'); + return (is_null($jslPath)); + + }//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 array(); + + }//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 array( + 1 => 2, + 2 => 1, + ); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Debug/JavaScriptLintUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Debug/JavaScriptLintUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Debug/JavaScriptLintUnitTest.js 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Debug/JavaScriptLintUnitTest.js 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,2 @@ +alert('hi') +alert('hi'); diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Debug/JavaScriptLintUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Debug/JavaScriptLintUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Debug/JavaScriptLintUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Debug/JavaScriptLintUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,80 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the JavaScriptLint sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_Debug_JavaScriptLintUnitTest extends AbstractSniffUnitTest +{ + + + /** + * Should this test be skipped for some reason. + * + * @return void + */ + protected function shouldSkipTest() + { + $jslPath = PHP_CodeSniffer::getConfigData('jsl_path'); + return (is_null($jslPath)); + + }//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 array(); + + }//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 array( + 2 => 1, + ); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Files/FileExtensionUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Files/FileExtensionUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Files/FileExtensionUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Files/FileExtensionUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,3 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Files/FileExtensionUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Files/FileExtensionUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Files/FileExtensionUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Files/FileExtensionUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,69 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the FileExtension sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_Files_FileExtensionUnitTest 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 array( + 1 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,133 @@ +words[$wordPos-1]) || $this->words[$wordPos-1] !== ' ') { +} else if ($this->tokens[$pos + 1] === "\n") { +} + +if ($pos === count($this->tokens) - 1) { + $file = '...'.substr($file, (($padding * -1) + 3)); +} + +if (substr($basename, -5) !== 'Sniff') { + $i = ($this->_tokens[$i]['parenthesis_closer'] + 1); +} + +$pos = $this->_getShortCommentEndPos(); +if ($pos === -1) { + $stackPtr = ($tokens[$next][$to] - 1); + $stackPtr = ($tokens[$next][$pattern[$i]['to']] + 1); + $var = (($var1 + $var2) + $var3 + $var4) +} + +$commentStart = ($phpcsFile->findPrevious(T_DOC_COMMENT, ($commentEnd - 1), null, true) + 1); +$commentEnd = ($this->_phpcsFile->findNext(T_DOC_COMMENT, ($commentStart + 1), null, true) - 1); +$expected .= '...'.substr($tokens[($stackPtr - 2)]['content'], -5).$tokens[$stackPtr]['content']; + +if (($tokens[$nextToken - 1]['code']) !== T_WHITESPACE) { + $errorPos = ($params[(count($params) - 1)]->getLine() + $commentStart); +} + +while (($nextSpace = $phpcsFile->findNext(T_WHITESPACE, $nextSpace + 1, $nextBreak)) !== false) { +} + +foreach ($attributes as $id => &$attribute) { +} + +class MyClass +{ + + + public function &myFunction(array &$one, array &$two) + { + + }//end myFunction() + + +}//end class + +if ($index < -1) $index = 0; +if ($index < - 1) $index = 0; + +$three = ceil($one / $two); +$three = ceil(($one / $two) / $four); +$three = ceil($one / ($two / $four)); + +$four = -0.25; + +$three = ceil($one[1] / $two); + +switch ($number % 10) { + case -1: + $suffix = 'st'; + break; +} + +$expectedPermission = array( + 'granted' => 4, + 'denied' => 1, + 'cascade' => TRUE, + 'blockergranted' => 2, + 'blockerdenied' => - 3, + 'effective' => TRUE, + ); +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.js 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.js 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,106 @@ +value = (one + two); +value = one + two; + +value = (one - two); +value = one - two; + +value = (one * two); +value = one * two; + +value = (one / two); +value = one / two; + +value = (one % two); +value = one % two; + +value = (one + two + three); +value = one + two + three; +value = (one + (two + three)); +value = one + (two + three); + +value++; +value--; +value = -1; +value = - 1; + +value = (1 + 2); +value = 1 + 2; + +value = (1 - 2); +value = 1 - 2; + +value = (1 * 2); +value = 1 * 2; + +value = (1 / 2); +value = 1 / 2; + +value = (1 % 2); +value = 1 % 2; + +value = (1 + 2 + 3); +value = 1 + 2 + 3; +value = (1 + (2 + 3)); +value = 1 + (2 + 3); + +value = one + 2 + 3 - (four * five * (6 + 7)) + nine + 2; +value = myFunction(tokens[stackPtr - 1]); + +for (i = 1 + 2; i < 4 + 5; i++) { +} + +function myFunction() +{ + value = (one + 1) + (two + 2) + (myFunction() + 2); + value = myFunction() + 2; + value = (myFunction(mvar) + myFunction2(mvar)); + return -1; +} + +params['mode'] = id.replace(/WidgetType/, ''); + +if (index < -1) index = 0; +if (index < - 1) index = 0; + +var classN = prvId.replace(/\./g, '-'); + +three = myFunction(one / two); +three = myFunction((one / two) / four); +three = myFunction(one / (two / four)); + +four = -0.25; + +id = id.replace(/row\/:/gi, ''); +return /MSIE/.test(navigator.userAgent); + +var re = new RegExp(/<\/?(\w+)((\s+\w+(\s*=\s*(?:".*?"|'.*?'|[^'">\s]+))?)+\s*|\s*)\/?>/gim); + +var options = { + minVal: -1, + maxVal: -1 +}; + +stepWidth = Math.round(this.width / 5); + +date.setMonth(d[2] - 1); + +switch (number % 10) { + case -1: + suffix = 'st'; + break; +} + +var pathSplit = ipt.value.split(/\/|\\/); + +if (pairs[i].search(/=/) !== -1) { +} + +if (urlValue.search(/[a-zA-z]+:\/\//) !== 0) { +} + +if (urlValue.search(/[a-zA-z]+:\/\/*/) !== 0) { +} + +if (!value || /^\s*$/.test(value)) { + return true; +} diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,120 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the OperatorBracket sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_Formatting_OperatorBracketUnitTest 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='OperatorBracketUnitTest.inc') + { + switch ($testFile) { + case 'OperatorBracketUnitTest.inc': + return array( + 3 => 1, + 6 => 1, + 9 => 1, + 12 => 1, + 15 => 1, + 18 => 2, + 20 => 1, + 25 => 1, + 28 => 1, + 31 => 1, + 34 => 1, + 37 => 1, + 40 => 1, + 43 => 2, + 45 => 1, + 47 => 5, + 48 => 1, + 50 => 2, + 55 => 2, + 56 => 1, + 63 => 2, + 64 => 1, + 67 => 1, + 86 => 1, + 90 => 1, + 109 => 1, + 130 => 1, + ); + break; + case 'OperatorBracketUnitTest.js': + return array( + 5 => 1, + 8 => 1, + 11 => 1, + 14 => 1, + 24 => 1, + 30 => 1, + 33 => 1, + 36 => 1, + 39 => 1, + 46 => 1, + 47 => 1, + 63 => 1, + ); + break; + default: + return array(); + break; + }//end switch + + }//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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Functions/FunctionDeclarationArgumentSpacingUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Functions/FunctionDeclarationArgumentSpacingUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Functions/FunctionDeclarationArgumentSpacingUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Functions/FunctionDeclarationArgumentSpacingUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,48 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Functions/FunctionDeclarationArgumentSpacingUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Functions/FunctionDeclarationArgumentSpacingUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Functions/FunctionDeclarationArgumentSpacingUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Functions/FunctionDeclarationArgumentSpacingUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,84 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the FunctionDeclarationArgumentSpacing sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_Functions_FunctionDeclarationArgumentSpacingUnitTest 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 array( + 3 => 1, + 5 => 2, + 7 => 2, + 8 => 2, + 9 => 2, + 11 => 2, + 13 => 7, + 14 => 2, + 15 => 2, + 16 => 4, + 18 => 2, + 35 => 2, + 36 => 3, + 44 => 2, + 45 => 1, + 46 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Functions/FunctionDeclarationUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Functions/FunctionDeclarationUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Functions/FunctionDeclarationUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Functions/FunctionDeclarationUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,66 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Functions/FunctionDeclarationUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Functions/FunctionDeclarationUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Functions/FunctionDeclarationUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Functions/FunctionDeclarationUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,69 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the FunctionDeclaration sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_Functions_FunctionDeclarationUnitTest 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 array( + 55 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Functions/FunctionDuplicateArgumentUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Functions/FunctionDuplicateArgumentUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Functions/FunctionDuplicateArgumentUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Functions/FunctionDuplicateArgumentUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,6 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Functions/FunctionDuplicateArgumentUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Functions/FunctionDuplicateArgumentUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Functions/FunctionDuplicateArgumentUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Functions/FunctionDuplicateArgumentUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,71 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the FunctionDuplicateArgument sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_Functions_FunctionDuplicateArgumentUnitTest 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 array( + 2 => 1, + 4 => 2, + 5 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Functions/GlobalFunctionUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Functions/GlobalFunctionUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Functions/GlobalFunctionUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Functions/GlobalFunctionUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,17 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Functions/GlobalFunctionUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Functions/GlobalFunctionUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Functions/GlobalFunctionUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Functions/GlobalFunctionUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,69 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the GlobalFunction sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_Functions_GlobalFunctionUnitTest 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 array(); + + }//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 array( + 2 => 1, + ); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Functions/LowercaseFunctionKeywordsUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Functions/LowercaseFunctionKeywordsUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Functions/LowercaseFunctionKeywordsUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Functions/LowercaseFunctionKeywordsUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,7 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Functions/LowercaseFunctionKeywordsUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Functions/LowercaseFunctionKeywordsUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Functions/LowercaseFunctionKeywordsUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Functions/LowercaseFunctionKeywordsUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,73 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the LowercaseFunctionKeywords sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_Functions_LowercaseFunctionKeywordsUnitTest 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 array( + 2 => 1, + 3 => 1, + 4 => 1, + 5 => 1, + 6 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,100 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,82 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the MultiLineFunctionDeclaration sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_Functions_MultiLineFunctionDeclarationUnitTest 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 array( + 2 => 1, + 3 => 1, + 4 => 3, + 5 => 1, + 7 => 1, + 11 => 1, + 12 => 1, + 13 => 1, + 16 => 1, + 33 => 1, + 36 => 1, + 43 => 2, + 48 => 1, + 81 => 1, + 82 => 2, + 88 => 2, + ); + + }//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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/NamingConventions/ConstantCaseUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/NamingConventions/ConstantCaseUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/NamingConventions/ConstantCaseUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/NamingConventions/ConstantCaseUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,52 @@ +null = 7; +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/NamingConventions/ConstantCaseUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/NamingConventions/ConstantCaseUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/NamingConventions/ConstantCaseUnitTest.js 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/NamingConventions/ConstantCaseUnitTest.js 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,14 @@ +if (variable === true) { } +if (variable === TRUE) { } +if (variable === True) { } +variable = True; + +if (variable === false) { } +if (variable === FALSE) { } +if (variable === False) { } +variable = false; + +if (variable === null) { } +if (variable === NULL) { } +if (variable === Null) { } +variable = NULL; diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/NamingConventions/ConstantCaseUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/NamingConventions/ConstantCaseUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/NamingConventions/ConstantCaseUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/NamingConventions/ConstantCaseUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,101 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the ConstantCase sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_NamingConventions_ConstantCaseUnitTest 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='ConstantCaseUnitTest.inc') + { + switch ($testFile) { + case 'ConstantCaseUnitTest.inc': + return array( + 7 => 1, + 10 => 1, + 15 => 1, + 16 => 1, + 23 => 1, + 26 => 1, + 31 => 1, + 32 => 1, + 39 => 1, + 42 => 1, + 47 => 1, + 48 => 1, + ); + break; + case 'ConstantCaseUnitTest.js': + return array( + 2 => 1, + 3 => 1, + 4 => 1, + 7 => 1, + 8 => 1, + 12 => 1, + 13 => 1, + 14 => 1, + ); + break; + default: + return array(); + break; + }//end switch + + }//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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/NamingConventions/ValidFunctionNameUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/NamingConventions/ValidFunctionNameUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/NamingConventions/ValidFunctionNameUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/NamingConventions/ValidFunctionNameUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,27 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/NamingConventions/ValidFunctionNameUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/NamingConventions/ValidFunctionNameUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/NamingConventions/ValidFunctionNameUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/NamingConventions/ValidFunctionNameUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,79 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the ValidFunctionName sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_NamingConventions_ValidFunctionNameUnitTest 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 array( + 4 => 1, + 5 => 1, + 6 => 1, + 7 => 1, + 8 => 1, + 9 => 1, + 11 => 1, + 12 => 1, + 13 => 1, + 14 => 1, + 16 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/NamingConventions/ValidVariableNameUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/NamingConventions/ValidVariableNameUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/NamingConventions/ValidVariableNameUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/NamingConventions/ValidVariableNameUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,110 @@ +varName2; +echo $this->var_name2; +echo $this->varname2; +echo $this->_varName2; +echo $object->varName2; +echo $object->var_name2; +echo $object_name->varname2; +echo $object_name->_varName2; + +echo $this->myFunction($one, $two); +echo $object->myFunction($one_two); + +$error = "format is \$GLOBALS['$varName']"; + +echo $_SESSION['var_name']; +echo $_FILES['var_name']; +echo $_ENV['var_name']; +echo $_COOKIE['var_name']; + +$XML = 'hello'; +$myXML = 'hello'; +$XMLParser = 'hello'; +$xmlParser = 'hello'; + +echo "{$_SERVER['HOSTNAME']} $var_name"; + +// Need to be the last thing in this test file. +$obj->$classVar = $prefix.'-'.$type; + +class foo +{ + const bar = << diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/NamingConventions/ValidVariableNameUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/NamingConventions/ValidVariableNameUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/NamingConventions/ValidVariableNameUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/NamingConventions/ValidVariableNameUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,97 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the ValidVariableName sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_NamingConventions_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 array( + 3 => 1, + 5 => 1, + 10 => 1, + 12 => 1, + 15 => 1, + 17 => 1, + 20 => 1, + 22 => 1, + 25 => 1, + 27 => 1, + 31 => 1, + 33 => 1, + 36 => 1, + 37 => 1, + 39 => 1, + 42 => 1, + 44 => 1, + 53 => 1, + 58 => 1, + 62 => 1, + 63 => 1, + 64 => 1, + 67 => 1, + 76 => 1, + 78 => 1, + 81 => 1, + 106 => 1, + 107 => 1, + 108 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Objects/DisallowObjectStringIndexUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Objects/DisallowObjectStringIndexUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Objects/DisallowObjectStringIndexUnitTest.js 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Objects/DisallowObjectStringIndexUnitTest.js 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,37 @@ +function test(id) +{ + + this.id = id; + +} +/**/ +test.prototype = { + init: function() + { + var x = {}; + x.name = 'test'; + x['phone'] = 123124324; + var t = ['test', 'this'].join(''); + var y = ['test'].join(''); + var a = x[0]; + var z = x[x['name']]; + var p = x[x.name]; + } + +}; + +function test() { + this.errors['step_' + step] = errors; + this.errors['test'] = x; + this.errors['test' + 10] = x; + this.errors['test' + y] = x; + this.errors['test' + 'blah'] = x; + this.errors[y] = x; + this.errors[y + z] = x; + this.permissions['workflow.cancel'] = x; +} + +if (child.prototype) { + above.prototype['constructor'] = parent; + child.prototype['super'] = new above(); +} diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Objects/DisallowObjectStringIndexUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Objects/DisallowObjectStringIndexUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Objects/DisallowObjectStringIndexUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Objects/DisallowObjectStringIndexUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,76 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the DisallowObjectStringIndex sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Sertan Danis + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_Objects_DisallowObjectStringIndexUnitTest 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='DisallowObjectStringIndexUnitTest.js') + { + if ($testFile !== 'DisallowObjectStringIndexUnitTest.js') { + return array(); + } + + return array( + 13 => 1, + 17 => 1, + 25 => 1, + 35 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Objects/ObjectInstantiationUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Objects/ObjectInstantiationUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Objects/ObjectInstantiationUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Objects/ObjectInstantiationUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,15 @@ + new MyClass()); +$object->myFunction(new MyClass()); + +throw new MyException($msg); + +function foo() { return new MyClass(); } + +$doodad = $x ? new Foo : new Bar; +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Objects/ObjectInstantiationUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Objects/ObjectInstantiationUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Objects/ObjectInstantiationUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Objects/ObjectInstantiationUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,70 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the ObjectInstantiation sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_Objects_ObjectInstantiationUnitTest 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 array( + 5 => 1, + 8 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Objects/ObjectMemberCommaUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Objects/ObjectMemberCommaUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Objects/ObjectMemberCommaUnitTest.js 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Objects/ObjectMemberCommaUnitTest.js 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,39 @@ +this.request({ action: 'getTypeFormatContents', }); + +addTypeFormatButton.addClickEvent(function() { + self.addNewTypeFormat(); +}); + +var x = {}; + +var y = { + VarOne : 'If you ask me, thats if you ask', + VarTwo : ['Alonzo played you', 'for a fool', 'esse'], + VarThree: function(arg) { + console.info(1); + } +}; + +var z = { + VarOne : 'If you ask me, thats if you ask', + VarTwo : ['Alonzo played you', 'for a fool', 'esse'], + VarThree: function(arg) { + console.info(1); + }, +}; + +var x = function() { + console.info(2); +}; + +AssetListingEditWidgetType.prototype = { + init: function(data, assetid, editables) + { + } +}; + +AssetListingEditWidgetType.prototype = { + init: function(data, assetid, editables) + { + }, +}; diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Objects/ObjectMemberCommaUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Objects/ObjectMemberCommaUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Objects/ObjectMemberCommaUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Objects/ObjectMemberCommaUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,75 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the ObjectMemberComma sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_Objects_ObjectMemberCommaUnitTest 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='ObjectMemberCommaUnitTest.js') + { + if ($testFile !== 'ObjectMemberCommaUnitTest.js') { + return array(); + } + + return array( + 1 => 1, + 22 => 1, + 38 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,81 @@ + + + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.js 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.js 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,38 @@ +if (value === TRUE) { +} else if (value === FALSE) { +} + +if (value == TRUE) { +} else if (value == FALSE) { +} + +if (value) { +} else if (!value) { +} + +if (value.isSomething === TRUE) { +} else if (myFunction(value) === FALSE) { +} + +if (value.isSomething == TRUE) { +} else if (myFunction(value) == FALSE) { +} + +if (value.isSomething) { +} else if (!myFunction(value)) { +} + +if (value === TRUE || other === FALSE) { +} + +if (value == TRUE || other == FALSE) { +} + +if (value || !other) { +} + +if (one === TRUE || two === TRUE || three === FALSE || four === TRUE) { +} + +if (one || two || !three || four) { +} diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,103 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the ComparisonOperatorUsage sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_Operators_ComparisonOperatorUsageUnitTest 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='ComparisonOperatorUsageUnitTest.inc') + { + switch ($testFile) { + case 'ComparisonOperatorUsageUnitTest.inc': + return array( + 6 => 1, + 7 => 1, + 10 => 1, + 11 => 1, + 18 => 1, + 19 => 1, + 22 => 1, + 23 => 1, + 29 => 2, + 32 => 2, + 38 => 4, + 47 => 2, + 69 => 1, + 72 => 1, + 75 => 1, + 78 => 1, + 80 => 1, + ); + break; + case 'ComparisonOperatorUsageUnitTest.js': + return array( + 5 => 1, + 6 => 1, + 17 => 1, + 18 => 1, + 28 => 2, + ); + break; + default: + return array(); + break; + }//end switch + + }//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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,39 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,77 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the IncrementDecrementUsage sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_Operators_IncrementDecrementUsageUnitTest 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 array( + 2 => 1, + 6 => 1, + 12 => 1, + 16 => 1, + 25 => 1, + 26 => 1, + 27 => 1, + 29 => 1, + 31 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Operators/ValidLogicalOperatorsUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Operators/ValidLogicalOperatorsUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Operators/ValidLogicalOperatorsUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Operators/ValidLogicalOperatorsUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,28 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Operators/ValidLogicalOperatorsUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Operators/ValidLogicalOperatorsUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Operators/ValidLogicalOperatorsUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Operators/ValidLogicalOperatorsUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,73 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the ValidLogicalOperators sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_Operators_ValidLogicalOperatorsUnitTest 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 array( + 5 => 1, + 11 => 1, + 17 => 2, + 23 => 1, + 26 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.css php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.css --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.css 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.css 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,23 @@ +/* CSS Document */ + +body { +font-family: Arial, Helvetica, sans-serif; +margin : 40px 0 0 0; +padding : 0; +/*background: #8FB7DB url(login_glow_bg.jpg) no-repeat 30% 0;*/ +background: #8FB7DB url(diag_lines_bg.gif) top left; +} + +#login-container { + margin-left: -225px; + margin-top: -161px; + position:absolute; + top :50%; + /*left :50%;*/ + width:450px; +} + +#cacheConfig-dayLabel, #cacheConfig-hourLabel, #cacheConfig-minuteLabel { + float: left; + padding-right: 8px; +} diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,61 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,85 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the CommentedOutCode sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_PHP_CommentedOutCodeUnitTest 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 array(); + + }//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($testFile='CommentedOutCodeUnitTest.inc') + { + switch ($testFile) { + case 'CommentedOutCodeUnitTest.inc': + return array( + 6 => 1, + 8 => 1, + 15 => 1, + 19 => 1, + ); + break; + case 'CommentedOutCodeUnitTest.css': + return array( + 7 => 1, + 16 => 1, + ); + break; + default: + return array(); + break; + }//end switch + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowComparisonAssignmentUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowComparisonAssignmentUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowComparisonAssignmentUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowComparisonAssignmentUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,39 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowComparisonAssignmentUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowComparisonAssignmentUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowComparisonAssignmentUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowComparisonAssignmentUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,74 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the DisallowComparisonAssignment sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_PHP_DisallowComparisonAssignmentUnitTest 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 array( + 3 => 1, + 5 => 1, + 6 => 1, + 7 => 1, + 8 => 1, + 10 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowInlineIfUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowInlineIfUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowInlineIfUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowInlineIfUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,9 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowInlineIfUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowInlineIfUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowInlineIfUnitTest.js 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowInlineIfUnitTest.js 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,2 @@ +x = (x?a:x); +id = id.replace(/row\/:/gi, ''); diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowInlineIfUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowInlineIfUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowInlineIfUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowInlineIfUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,81 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the DisallowInlineIf sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_PHP_DisallowInlineIfUnitTest 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($testFile='DisallowInlineIfUnitTest.inc') + { + switch ($testFile) { + case 'DisallowInlineIfUnitTest.inc': + return array( + 8 => 1, + ); + break; + case 'DisallowInlineIfUnitTest.js': + return array( + 1 => 1, + ); + break; + default: + return array(); + break; + }//end switch + + }//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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowMultipleAssignmentsUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowMultipleAssignmentsUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowMultipleAssignmentsUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowMultipleAssignmentsUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,42 @@ +fetch(PDO::FETCH_NUM)) { + $result[$row[0]] = array() + $result[$row[0]][] = $current; + + self::$_inTransaction = TRUE; + $$varName = $varValue; + } + +}//end getVar() + +class myClass +{ + private static $_dbh = NULL; + public $dbh = NULL; + protected $dbh = NULL; +} + +$var = $var2; +list ($a, $b) = explode(',', $c); +$var1 ? $var2 = 0 : $var2 = 1; + +$obj->$classVar = $prefix.'-'.$type; + +$closureWithDefaultParamter = function(array $testArray=array()) {}; +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowMultipleAssignmentsUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowMultipleAssignmentsUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowMultipleAssignmentsUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowMultipleAssignmentsUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,74 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the DisallowMultipleAssignments sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_PHP_DisallowMultipleAssignmentsUnitTest 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 array( + 4 => 1, + 5 => 2, + 7 => 1, + 9 => 1, + 12 => 1, + 14 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowObEndFlushUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowObEndFlushUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowObEndFlushUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowObEndFlushUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,10 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowObEndFlushUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowObEndFlushUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowObEndFlushUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowObEndFlushUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,69 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the DisallowObEndFlush sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_PHP_DisallowObEndFlushUnitTest 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 array( + 9 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowSizeFunctionsInLoopsUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowSizeFunctionsInLoopsUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowSizeFunctionsInLoopsUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowSizeFunctionsInLoopsUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,58 @@ +children); $i++) { +} + + + +for ($i = 0; $i < sizeof($array); $i++) { +} + +$num = sizeof($array); + +while ($i < sizeof($array)) { +} + +do { +} while ($i < sizeof($array)); + +for ($i = 0; $i < sizeof($this->children); $i++) { +} + + + + +for ($i = 0; $i < strlen($string); $i++) { +} + +$num = strlen($string); + +while ($i < strlen($string)) { +} + +do { +} while ($i < strlen($string)); + +for ($i = 0; $i < strlen($this->string); $i++) { +} + +for ($i = sizeof($array); $i > 0; $i--) { +} + +do { + echo $a->count; + $a->count--; +} while($a->count); + +for ($i = 0; $i < $a->count; $i++) {} +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowSizeFunctionsInLoopsUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowSizeFunctionsInLoopsUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowSizeFunctionsInLoopsUnitTest.js 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowSizeFunctionsInLoopsUnitTest.js 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,13 @@ +for (var i = 0; i < permissions.length; i++) { + // Code here. +} + +var permLen = permissions.length; +for (var length = 0; i < permLen; i++) { + // Code here. +} + +var myArray = [1, 2, 3, 4]; +for (var i = myArray.length; i >= 0; i--) { + var x = i; +} diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowSizeFunctionsInLoopsUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowSizeFunctionsInLoopsUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowSizeFunctionsInLoopsUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/DisallowSizeFunctionsInLoopsUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,94 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the DisallowSizeFunctionsInLoops sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_PHP_DisallowSizeFunctionsInLoopsUnitTest 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='DisallowSizeFunctionsInLoopsUnitTest.inc') + { + switch ($testFile) { + case 'DisallowSizeFunctionsInLoopsUnitTest.inc': + return array( + 2 => 1, + 7 => 1, + 11 => 1, + 13 => 1, + 18 => 1, + 23 => 1, + 27 => 1, + 29 => 1, + 35 => 1, + 40 => 1, + 44 => 1, + 46 => 1, + ); + break; + case 'DisallowSizeFunctionsInLoopsUnitTest.js': + return array( + 1 => 1, + ); + break; + default: + return array(); + break; + }//end switch + + }//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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/DiscouragedFunctionsUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/DiscouragedFunctionsUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/DiscouragedFunctionsUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/DiscouragedFunctionsUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,4 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/DiscouragedFunctionsUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/DiscouragedFunctionsUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/DiscouragedFunctionsUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/DiscouragedFunctionsUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,68 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the DiscouragedFunctions sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_PHP_DiscouragedFunctionsUnitTest 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 array(); + + }//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 array( + 2 => 1, + 3 => 1, + ); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,48 @@ + + + +<?php echo $title ?> + + + + + hello + + + + + + + + + + + + + + + + + + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,84 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the EmbeddedPhp sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_PHP_EmbeddedPhpUnitTest 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 array( + 7 => 1, + 12 => 1, + 18 => 1, + 19 => 2, + 20 => 1, + 21 => 1, + 22 => 3, + 24 => 1, + 26 => 1, + 29 => 1, + 30 => 1, + 31 => 1, + 34 => 1, + 36 => 1, + 40 => 1, + 41 => 2, + ); + + }//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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/EvalUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/EvalUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/EvalUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/EvalUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,5 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/EvalUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/EvalUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/EvalUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/EvalUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,70 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the Eval sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_PHP_EvalUnitTest 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 array(); + + }//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 array( + 2 => 1, + 4 => 1, + ); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/ForbiddenFunctionsUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/ForbiddenFunctionsUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/ForbiddenFunctionsUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/ForbiddenFunctionsUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,12 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/ForbiddenFunctionsUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/ForbiddenFunctionsUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/ForbiddenFunctionsUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/ForbiddenFunctionsUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,72 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the ForbiddenFunctions sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_PHP_ForbiddenFunctionsUnitTest 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 array( + 2 => 1, + 3 => 1, + 4 => 1, + 5 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/GlobalKeywordUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/GlobalKeywordUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/GlobalKeywordUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/GlobalKeywordUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,13 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/GlobalKeywordUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/GlobalKeywordUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/GlobalKeywordUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/GlobalKeywordUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,70 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the GlobalKeyword sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_PHP_GlobalKeywordUnitTest 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 array( + 8 => 1, + 9 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/HeredocUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/HeredocUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/HeredocUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/HeredocUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,13 @@ +foo. +Now, I am printing some {$foo->bar[1]}. +This should not print a capital 'A': \x41 +EOT; +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/HeredocUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/HeredocUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/HeredocUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/HeredocUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,70 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the Heredoc sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_PHP_HeredocUnitTest 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 array( + 2 => 1, + 8 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/InnerFunctionsUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/InnerFunctionsUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/InnerFunctionsUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/InnerFunctionsUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,18 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/InnerFunctionsUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/InnerFunctionsUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/InnerFunctionsUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/InnerFunctionsUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,69 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the InnerFunctions sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_PHP_InnerFunctionsUnitTest 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 array( + 5 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/LowercasePHPFunctionsUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/LowercasePHPFunctionsUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/LowercasePHPFunctionsUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/LowercasePHPFunctionsUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,22 @@ +Count(); +$count = $object::Count(); +$count = $object->count(); +$count = $object::count(); +class MyClass { + public function Count() {} +} + +function &Sort() { + +} +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/LowercasePHPFunctionsUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/LowercasePHPFunctionsUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/LowercasePHPFunctionsUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/LowercasePHPFunctionsUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,70 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the LowercasePHPFunctions sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_PHP_LowercasePHPFunctionsUnitTest 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 array( + 2 => 1, + 4 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,246 @@ +{$action . 'JsonAction'}(); +} + +exit(); + + +// Errors are thrown from here down from the exit() above. +foreach ($vars as $var) { + if ($something === TRUE) { + break; + break; + } +} + +exit(); + +function test() { + echo 'no error'; +} + +class myClass { + function myFunc() { + echo 'no error'; + } +} + +function bar() { + return function() { + echo "1"; + }; +} + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,96 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the NonExecutableCode sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_PHP_NonExecutableCodeUnitTest 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 array(); + + }//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 array( + 5 => 1, + 11 => 1, + 17 => 1, + 18 => 1, + 19 => 2, + 28 => 1, + 32 => 1, + 33 => 2, + 34 => 2, + 42 => 1, + 45 => 1, + 54 => 1, + 58 => 1, + 73 => 1, + 83 => 1, + 95 => 1, + 105 => 1, + 123 => 1, + 146 => 1, + 149 => 1, + 152 => 1, + 165 => 1, + 179 => 1, + 221 => 1, + 222 => 1, + 223 => 1, + 224 => 2, + 228 => 1, + ); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Scope/MemberVarScopeUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Scope/MemberVarScopeUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Scope/MemberVarScopeUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Scope/MemberVarScopeUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,16 @@ + \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Scope/MemberVarScopeUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Scope/MemberVarScopeUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Scope/MemberVarScopeUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Scope/MemberVarScopeUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,69 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the MemberVarScope sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_Scope_MemberVarScopeUnitTest 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 array( + 7 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Scope/MethodScopeUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Scope/MethodScopeUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Scope/MethodScopeUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Scope/MethodScopeUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,21 @@ + \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Scope/MethodScopeUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Scope/MethodScopeUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Scope/MethodScopeUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Scope/MethodScopeUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,69 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the MethodScope sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_Scope_MethodScopeUnitTest 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 array( + 6 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Scope/StaticThisUsageUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Scope/StaticThisUsageUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Scope/StaticThisUsageUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Scope/StaticThisUsageUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,28 @@ +func2()); + $result = $this->getValue($value); + return $this->setValue($result); + } + + public function func1() + { + $value = 'hello'; + $newValue = array($this->func2()); + $result = $this->getValue($value); + return $this->setValue($result); + } + + function func1() + { + $value = 'hello'; + $newValue = array($this->func2()); + $result = $this->getValue($value); + return $this->setValue($result); + } +} +?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Scope/StaticThisUsageUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Scope/StaticThisUsageUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Scope/StaticThisUsageUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Scope/StaticThisUsageUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,71 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the StaticThisUsage sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_Scope_StaticThisUsageUnitTest 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 array( + 7 => 1, + 8 => 1, + 9 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Strings/ConcatenationSpacingUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Strings/ConcatenationSpacingUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Strings/ConcatenationSpacingUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Strings/ConcatenationSpacingUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,8 @@ + \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Strings/ConcatenationSpacingUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Strings/ConcatenationSpacingUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Strings/ConcatenationSpacingUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Strings/ConcatenationSpacingUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,71 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the ConcatenationSpacing sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_Strings_ConcatenationSpacingUnitTest 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 array( + 4 => 5, + 6 => 1, + 7 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Strings/DoubleQuoteUsageUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Strings/DoubleQuoteUsageUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Strings/DoubleQuoteUsageUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Strings/DoubleQuoteUsageUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,19 @@ +"; +$string = "Value: $var[test]"; +$string = "\0"; + +$x = "bar = '$z', +baz = '" . $a . "'...$x"; +?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Strings/DoubleQuoteUsageUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Strings/DoubleQuoteUsageUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Strings/DoubleQuoteUsageUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Strings/DoubleQuoteUsageUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,76 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the DoubleQuoteUsage sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_Strings_DoubleQuoteUsageUnitTest 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 array( + 4 => 1, + 5 => 1, + 6 => 1, + 8 => 2, + 13 => 1, + 14 => 1, + 17 => 1, + 18 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Strings/EchoedStringsUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Strings/EchoedStringsUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Strings/EchoedStringsUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Strings/EchoedStringsUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,9 @@ + \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Strings/EchoedStringsUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Strings/EchoedStringsUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Strings/EchoedStringsUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/Strings/EchoedStringsUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,72 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the EchoedStrings sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_Strings_EchoedStringsUnitTest 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 array( + 5 => 1, + 6 => 1, + 7 => 1, + 8 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/CastSpacingUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/CastSpacingUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/CastSpacingUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/CastSpacingUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,7 @@ + \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/CastSpacingUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/CastSpacingUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/CastSpacingUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/CastSpacingUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,72 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the CastSpacing sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_WhiteSpace_CastSpacingUnitTest 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 array( + 3 => 1, + 4 => 1, + 5 => 1, + 6 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ControlStructureSpacingUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ControlStructureSpacingUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ControlStructureSpacingUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ControlStructureSpacingUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,125 @@ + + + + + +
+ children as $child) { + // There should be no error after this + // foreach, because it is followed by a + // close PHP tag. + } + ?> +
+children as $child) { + echo $child; + +} + +if ($defaultPageDesign === 0 + && $defaultCascade === TRUE + && $defaultChildDesign === 0 +) { + $settingsUpdated = FALSE; +} + +foreach ( $blah as $var ) { + if ( $blah ) { + } +} + +if ( + $defaultPageDesign === 0 + && $defaultCascade === TRUE + && $defaultChildDesign === 0 +) { + $settingsUpdated = FALSE; +} +?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ControlStructureSpacingUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ControlStructureSpacingUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ControlStructureSpacingUnitTest.js 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ControlStructureSpacingUnitTest.js 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,86 @@ + \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ControlStructureSpacingUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ControlStructureSpacingUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ControlStructureSpacingUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ControlStructureSpacingUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,106 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the ControlStructureSpacing sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_WhiteSpace_ControlStructureSpacingUnitTest 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='ControlStructureSpacingUnitTest.inc') + { + switch ($testFile) { + case 'ControlStructureSpacingUnitTest.inc': + return array( + 3 => 1, + 5 => 1, + 8 => 1, + 15 => 1, + 23 => 1, + 74 => 1, + 79 => 1, + 82 => 1, + 83 => 1, + 87 => 1, + 103 => 1, + 113 => 2, + 114 => 2, + 118 => 1, + ); + break; + case 'ControlStructureSpacingUnitTest.js': + return array( + 3 => 1, + 9 => 1, + 15 => 1, + 21 => 1, + 56 => 1, + 61 => 1, + 64 => 1, + 65 => 1, + 68 => 1, + 74 => 2, + 75 => 2, + ); + break; + default: + return array(); + break; + }//end switch + + }//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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionClosingBraceSpaceUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionClosingBraceSpaceUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionClosingBraceSpaceUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionClosingBraceSpaceUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,27 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionClosingBraceSpaceUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionClosingBraceSpaceUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionClosingBraceSpaceUnitTest.js 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionClosingBraceSpaceUnitTest.js 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,106 @@ +function FuncOne() +{ + // Code here. + +}//end AdjustModalDialogWidgetType + + +Testing.prototype = { + + doSomething: function() + { + // Code here. + }, + + doSomethingElse: function() + { + // Code here. + + }, +}; + +function FuncFour() +{ + // Code here. +} + +function FuncFive() +{ + // Code here. + + +} + +function valid() +{ + if (true) { + test = { + namespaces: {} + }; + } + +} + +dfx.addEvent(this.rightScroll, 'mousedown', function() { + t = setInterval(function() { + pos -= 10; + }, 30); +}); + +// Valid because function is empty. +if (dfx.isFn(callback) === false) { + callback = function() {}; + callback = function() { }; +} + +AbstractAttributeEditorWidgetType.prototype = { + isActive: function() { + return this.active; + }, + + activate: function(data) + { + var x = { + test: function () { + alert('This is ok'); + + } + }; + + this.active = true; + + } + +}; + +var myFunc = function() +{ + var x = 1; + + blah(function() { + alert(2); + }); + + blah(function() { alert(2); }); + + return x; + +} + +CustomFormEditWidgetType.prototype = { + + addQuestion: function() + { + var settings = { + default: '' + }; + + }, + + addQuestionRulesEvent: function() + { + var self = this; + + } + +}; diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionClosingBraceSpaceUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionClosingBraceSpaceUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionClosingBraceSpaceUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionClosingBraceSpaceUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,90 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the FunctionClosingBraceSpace sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_WhiteSpace_FunctionClosingBraceSpaceUnitTest 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='FunctionClosingBraceSpaceUnitTest.inc') + { + switch ($testFile) { + case 'FunctionClosingBraceSpaceUnitTest.inc': + return array( + 10 => 1, + 21 => 1, + ); + break; + case 'FunctionClosingBraceSpaceUnitTest.js': + return array( + 13 => 1, + 25 => 1, + 32 => 1, + 53 => 1, + 59 => 1, + 67 => 1, + 84 => 1, + ); + break; + default: + return array(); + break; + }//end switch + + }//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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionOpeningBraceSpaceUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionOpeningBraceSpaceUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionOpeningBraceSpaceUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionOpeningBraceSpaceUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,40 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionOpeningBraceSpaceUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionOpeningBraceSpaceUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionOpeningBraceSpaceUnitTest.js 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionOpeningBraceSpaceUnitTest.js 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,112 @@ +function FuncOne() +{ + // Code here. + +}//end AdjustModalDialogWidgetType + + +Testing.prototype = { + + doSomething: function() + { + + // Code here. + + }, + + doSomethingElse: function() + { + // Code here. + + }, + + start: function() + { + this.toolbarPlugin.addButton('Image', 'imageEditor', 'Insert/Edit Image', function () { self.editImage() }); + + }, +}; + +function FuncFour() +{ + + + // Code here. +} + +AbstractAttributeEditorWidgetType.prototype = { + isActive: function() { + return this.active; + + }, + + activate: function(data) + { + var x = { + test: function () { + alert('This is ok'); + } + }; + + this.active = true; + + } + +}; + +function test() { + var x = 1; + var y = function() + { + alert(1); + } + + return x; + +} + +var myFunc = function() +{ + var x = 1; + + blah(x, y, function() + { + alert(2); + }, z); + + blah(function() { alert(2); }); + + return x; + +} + +HelpWidgetType.prototype = { + init: function() { + var x = 1; + var y = { + test: function() { + alert(3); + } + } + return x; + + } +} + +CustomFormEditWidgetType.prototype = { + + addQuestion: function() + { + var settings = { + default: '' + }; + + }, + + addQuestionRulesEvent: function() + { + var self = this; + + } + +}; diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionOpeningBraceSpaceUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionOpeningBraceSpaceUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionOpeningBraceSpaceUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionOpeningBraceSpaceUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,91 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the FunctionOpeningBraceSpace sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_WhiteSpace_FunctionOpeningBraceSpaceUnitTest 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='FunctionOpeningBraceSpaceUnitTest.inc') + { + switch ($testFile) { + case 'FunctionOpeningBraceSpaceUnitTest.inc': + return array( + 10 => 1, + 25 => 1, + ); + break; + case 'FunctionOpeningBraceSpaceUnitTest.js': + return array( + 11 => 1, + 31 => 1, + 38 => 1, + 57 => 1, + 60 => 1, + 73 => 1, + 84 => 1, + ); + break; + default: + return array(); + break; + }//end switch + + + }//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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,252 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,88 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the FunctionSpacing sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_WhiteSpace_FunctionSpacingUnitTest 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 array( + 2 => 1, + 9 => 1, + 18 => 1, + 25 => 1, + 29 => 1, + 35 => 1, + 38 => 1, + 40 => 1, + 55 => 1, + 74 => 1, + 85 => 1, + 87 => 1, + 93 => 2, + 115 => 1, + 134 => 1, + 147 => 2, + 164 => 1, + 198 => 1, + 213 => 1, + 232 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,33 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,83 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the LanguageConstructSpacing sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_WhiteSpace_LanguageConstructSpacingUnitTest 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 array( + 3 => 1, + 4 => 1, + 7 => 1, + 8 => 1, + 11 => 1, + 12 => 1, + 15 => 1, + 16 => 1, + 19 => 1, + 20 => 1, + 23 => 1, + 24 => 1, + 27 => 1, + 31 => 1, + 32 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/LogicalOperatorSpacingUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/LogicalOperatorSpacingUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/LogicalOperatorSpacingUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/LogicalOperatorSpacingUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,20 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/LogicalOperatorSpacingUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/LogicalOperatorSpacingUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/LogicalOperatorSpacingUnitTest.js 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/LogicalOperatorSpacingUnitTest.js 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,18 @@ + + +if (foo || bar) {} +if (foo||bar && baz) {} +if (foo|| bar&&baz) {} +if (foo || bar && baz) {} + +if (foo || + bar + && baz +) { +} + +if (foo|| + bar + &&baz +) { +} diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/LogicalOperatorSpacingUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/LogicalOperatorSpacingUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/LogicalOperatorSpacingUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/LogicalOperatorSpacingUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,73 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the LogicalOperatorSpacing sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_WhiteSpace_LogicalOperatorSpacingUnitTest 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='LogicalOperatorSpacingUnitTest.inc') + { + return array( + 4 => 2, + 5 => 3, + 6 => 3, + 14 => 1, + 16 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/MemberVarSpacingUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/MemberVarSpacingUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/MemberVarSpacingUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/MemberVarSpacingUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,110 @@ + \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/MemberVarSpacingUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/MemberVarSpacingUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/MemberVarSpacingUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/MemberVarSpacingUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,77 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the MemberVarSpacing sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_WhiteSpace_MemberVarSpacingUnitTest 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 array( + 4 => 1, + 7 => 1, + 20 => 1, + 30 => 1, + 35 => 1, + 44 => 1, + 50 => 1, + 73 => 1, + 86 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ObjectOperatorSpacingUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ObjectOperatorSpacingUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ObjectOperatorSpacingUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ObjectOperatorSpacingUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,7 @@ +testThis(); +$this-> testThis(); +$this -> testThis(); +$this->/* comment here */testThis(); +$this/* comment here */ -> testThis(); +?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ObjectOperatorSpacingUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ObjectOperatorSpacingUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ObjectOperatorSpacingUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ObjectOperatorSpacingUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,72 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the ObjectOperatorSpacing sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_WhiteSpace_ObjectOperatorSpacingUnitTest 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 array( + 3 => 1, + 4 => 2, + 5 => 1, + 6 => 2, + ); + + }//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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,126 @@ + $j && $k< $l && $m>= $n && $o<= $p && $q<> $r; + +$a ==$b && $c !=$d && $e ===$f && $g !==$h; +$i >$j && $k <$l && $m >=$n && $o <=$p && $q <>$r; + +function myFunction($variable=0, $var2='string') {} + +if (index > -1) { +} + +array_walk_recursive($array, function(&$item) use (&$something) { +}); + +$var = saveFile(&$model, &$foo); + +// This is all valid. +$boo = -$foo; +function foo($boo = -1) {} +$foo = array('boo' => -1); +$x = $test ? -1 : 1; +$y = $test ? 1 : -1; + +$closureWithDefaultParamter = function (array $testArray=array()) {}; + +switch ($foo) { + case -1: + break; +} + +$y = 1 * -1; +$y = -1 * 1; +$y = -1 * $var; +$y = 10 / -2; +$y = -10 / 2; +$y = (-10 / 2); +$y = (-10 / $var); +$y = 10 + -2; +$y = -10 + 2; +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.js 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.js 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,53 @@ + + +result = 1 + 2; +result = 1 + 2; +result = 1 + 2; +result = 1 +2; +result = 1+ 2; +result = 1+2; + +result = 1 - 2; +result = 1 - 2; +result = 1 - 2; +result = 1 -2; +result = 1- 2; +result = 1-2; + +result = 1 * 2; +result = 1 * 2; +result = 1 * 2; +result = 1 *2; +result = 1* 2; +result = 1*2; + +result = 1 / 2; +result = 1 / 2; +result = 1 / 2; +result = 1 /2; +result = 1/ 2; +result = 1/2; + +result = 1 % 2; +result = 1 % 2; +result = 1 % 2; +result = 1 %2; +result = 1% 2; +result = 1%2; +result = '100%'; + +result += 4; +result+=4; +result -= 4; +result-=4; +result /= 4; +result/=4; +result *=4; +result*=4; + +$.localScroll({offset: {top: -32}}); + +switch (result) { + case -1: + break; +} \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,156 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the OperatorSpacing sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_WhiteSpace_OperatorSpacingUnitTest 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='OperatorSpacingUnitTest.inc') + { + switch ($testFile) { + case 'OperatorSpacingUnitTest.inc': + return array( + 4 => 1, + 5 => 2, + 6 => 1, + 7 => 1, + 8 => 2, + 11 => 1, + 12 => 2, + 13 => 1, + 14 => 1, + 15 => 2, + 18 => 1, + 19 => 2, + 20 => 1, + 21 => 1, + 22 => 2, + 25 => 1, + 26 => 2, + 27 => 1, + 28 => 1, + 29 => 2, + 32 => 1, + 33 => 2, + 34 => 1, + 35 => 1, + 36 => 2, + 40 => 2, + 42 => 2, + 44 => 2, + 45 => 1, + 46 => 2, + 53 => 2, + 54 => 1, + 59 => 10, + 64 => 1, + 77 => 4, + 78 => 1, + 79 => 1, + 80 => 2, + 81 => 1, + 84 => 6, + 85 => 6, + 87 => 4, + 88 => 5, + 90 => 4, + 91 => 5, + ); + break; + case 'OperatorSpacingUnitTest.js': + return array( + 4 => 1, + 5 => 2, + 6 => 1, + 7 => 1, + 8 => 2, + 11 => 1, + 12 => 2, + 13 => 1, + 14 => 1, + 15 => 2, + 18 => 1, + 19 => 2, + 20 => 1, + 21 => 1, + 22 => 2, + 25 => 1, + 26 => 2, + 27 => 1, + 28 => 1, + 29 => 2, + 32 => 1, + 33 => 2, + 34 => 1, + 35 => 1, + 36 => 2, + 40 => 2, + 42 => 2, + 44 => 2, + 45 => 1, + 46 => 2, + ); + break; + default: + return array(); + break; + }//end switch + + }//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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/PropertyLabelSpacingUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/PropertyLabelSpacingUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/PropertyLabelSpacingUnitTest.js 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/PropertyLabelSpacingUnitTest.js 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,39 @@ +var x = { + b: 'x', + xasd: x, + a: function () { + alert('thats right'); + x = (x?a:x); + }, + casdasd : 123123, + omgwtfbbq: { + a: 1, + b: 2 + } +}; + +id = id.replace(/row\/:/gi, ''); + +outer_loop: +for (i=0; i<3; i++) { + for (j=0; j<5; j++) { + if (j==x) + break outer_loop; + } +} +alert('hi'); + +even_number: if ((i % 2) == 0) { + if (i == 12) + break even_number; +} + +switch (blah) { + case dfx.DOM_VK_LEFT: + this.caretLeft(shiftKey); + break; + default: + if (blah) { + } + break; +} \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/PropertyLabelSpacingUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/PropertyLabelSpacingUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/PropertyLabelSpacingUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/PropertyLabelSpacingUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,73 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the PropertyLabel sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_WhiteSpace_PropertyLabelSpacingUnitTest 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 array( + 2 => 1, + 8 => 2, + 9 => 1, + 11 => 1, + 17 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ScopeClosingBraceUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ScopeClosingBraceUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ScopeClosingBraceUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ScopeClosingBraceUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,56 @@ +{$property} =& new $class_name($this->db_index); + $this->modules[$module] =& $this->{$property}; +} + +foreach ($elements as $element) { + if ($something) { + // Do IF. + } else if ($somethingElse) { + // Do ELSE. + } +} + +switch ($blah) { + case 'one': + echo 'one'; + break; + default: + echo 'another'; +} + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ScopeClosingBraceUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ScopeClosingBraceUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ScopeClosingBraceUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ScopeClosingBraceUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,71 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the ScopeClosingBrace sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_WhiteSpace_ScopeClosingBraceUnitTest 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 array( + 11 => 1, + 13 => 1, + 24 => 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,38 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,74 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the ScopeKeywordSpacing sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_WhiteSpace_ScopeKeywordSpacingUnitTest 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 array( + 7 => 2, + 8 => 1, + 13 => 1, + 14 => 1, + 15 => 1, + 17 => 2, + ); + + }//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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,10 @@ +testThis(); +$test = $this->testThis() ; +$test = $this->testThis() ; +for ($var = 1 ; $var < 10 ; $var++) { + echo $var ; +} +$test = $this->testThis() /* comment here */; +$test = $this->testThis() /* comment here */ ; +?> \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.js 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.js 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,16 @@ +var x = { + a: function () { + alert('thats right') ; + x = (x?a:x) ; + }, +} ; + +id = id.replace(/row\/:;/gi, ''); + +for (i=0 ; i<3 ; i++) { + for (j=0; j<5 ; j++) { + if (j==x) + break ; + } +} +alert('hi'); \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,93 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the SemicolonSpacing sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_WhiteSpace_SemicolonSpacingUnitTest 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='SemicolonSpacingUnitTest.inc') + { + switch ($testFile) { + case 'SemicolonSpacingUnitTest.inc': + return array( + 3 => 1, + 4 => 1, + 5 => 2, + 6 => 1, + 8 => 1, + 9 => 1, + ); + break; + case 'SemicolonSpacingUnitTest.js': + return array( + 3 => 1, + 4 => 1, + 6 => 1, + 10 => 2, + 11 => 1, + 13 => 1, + ); + break; + default: + return array(); + break; + }//end switch + + }//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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.1.css php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.1.css --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.1.css 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.1.css 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,25 @@ + +.HelpWidgetType-new-bug-title { + float: left; +} +.HelpWidgetType-new-bug-title { + float: left; +} +.HelpWidgetType-new-bug-title { + float: left; +} + +.HelpWidgetType-new-bug-title{ + float: left; +} + +/* @codingStandardsChangeSetting Squiz.WhiteSpace.SuperfluousWhitespace ignoreBlankLines true */ +.HelpWidgetType-new-bug-title{ + float: left; +} + +.HelpWidgetType-new-bug-title{ + float: left; +} +/* @codingStandardsChangeSetting Squiz.WhiteSpace.SuperfluousWhitespace ignoreBlankLines false */ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.1.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.1.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.1.js 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.1.js 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,47 @@ + +alert('hi'); +alert('hello'); + +if (something) { + +} + + +function myFunction() +{ + alert('code here'); + + alert('code here'); + + + // Hello. + + /* + HI + */ + + +} + +function myFunction2() +{ + alert('code here'); + + + alert('code here'); + +} + +// @codingStandardsChangeSetting Squiz.WhiteSpace.SuperfluousWhitespace ignoreBlankLines true + +function myFunction2() +{ + alert('code here'); + + alert('code here'); + +} + +// @codingStandardsChangeSetting Squiz.WhiteSpace.SuperfluousWhitespace ignoreBlankLines false + + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.2.css php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.2.css --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.2.css 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.2.css 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,3 @@ +.HelpWidgetType-new-bug-title { + float: left; +} \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.2.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.2.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.2.js 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.2.js 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1 @@ +alert('hi'); \ No newline at end of file diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.3.css php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.3.css --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.3.css 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.3.css 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,3 @@ +.HelpWidgetType-new-bug-title { + float: left; +} diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.3.js php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.3.js --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.3.js 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.3.js 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1 @@ +alert('hi'); diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,49 @@ + + + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,108 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the SuperfluousWhitespace sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Squiz_Tests_WhiteSpace_SuperfluousWhitespaceUnitTest 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='SuperfluousWhitespaceUnitTest.inc') + { + switch ($testFile) { + case 'SuperfluousWhitespaceUnitTest.inc': + return array( + 2 => 1, + 4 => 1, + 5 => 1, + 6 => 1, + 7 => 1, + 16 => 1, + 23 => 1, + 30 => 1, + 48 => 1, + ); + break; + case 'SuperfluousWhitespaceUnitTest.1.js': + return array( + 1 => 1, + 3 => 1, + 4 => 1, + 5 => 1, + 6 => 1, + 15 => 1, + 22 => 1, + 29 => 1, + 47 => 1, + ); + break; + case 'SuperfluousWhitespaceUnitTest.1.css': + return array( + 1 => 1, + 8 => 1, + 9 => 1, + 11 => 1, + 25 => 1, + ); + break; + default: + return array(); + break; + }//end switch + + }//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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/ruleset.xml php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/ruleset.xml --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/ruleset.xml 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Squiz/ruleset.xml 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,81 @@ + + + The Squiz coding standard. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + %2$s + + + + + + + + + + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Zend/Sniffs/Debug/CodeAnalyzerSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Zend/Sniffs/Debug/CodeAnalyzerSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Zend/Sniffs/Debug/CodeAnalyzerSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Zend/Sniffs/Debug/CodeAnalyzerSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,125 @@ + + * @author Greg Sherwood + * @copyright 2006-2012 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 + */ + +/** + * Zend_Sniffs_Debug_CodeAnalyzerSniff. + * + * Runs the Zend Code Analyzer (from Zend Studio) on the file. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Holger Kral + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Zend_Sniffs_Debug_CodeAnalyzerSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Returns the token types that this sniff is interested in. + * + * @return array(int) + */ + public function register() + { + return array(T_OPEN_TAG); + + }//end 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. + * + * @return void + */ + public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + // Because we are analyzing the whole file in one step, execute this method + // only on first occurrence of a T_OPEN_TAG. + $prevOpenTag = $phpcsFile->findPrevious(T_OPEN_TAG, ($stackPtr - 1)); + if ($prevOpenTag !== false) { + return; + } + + $fileName = $phpcsFile->getFilename(); + + $analyzerPath = PHP_CodeSniffer::getConfigData('zend_ca_path'); + if (is_null($analyzerPath) === true) { + return; + } + + // 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 = $analyzerPath.' '.$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); + + // $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 PHP_CodeSniffer_Exception("Failed invoking ZendCodeAnalyzer, exitcode was [$exitCode], retval was [$retval], output was [$msg]"); + } + + if (is_array($output) === true) { + $tokens = $phpcsFile->getTokens(); + + foreach ($output as $finding) { + // The first two lines of analyzer output contain + // something like this: + // > Zend Code Analyzer 1.2.2 + // > Analyzing ... + // So skip these... + $res = preg_match("/^.+\(line ([0-9]+)\):(.+)$/", $finding, $regs); + if (empty($regs) === true || $res === false) { + continue; + } + + // Find the token at the start of the line. + $lineToken = null; + foreach ($tokens as $ptr => $info) { + if ($info['line'] == $regs[1]) { + $lineToken = $ptr; + break; + } + } + + if ($lineToken !== null) { + $phpcsFile->addWarning(trim($regs[2]), $ptr, 'ExternalTool'); + } + }//end foreach + }//end if + + }//end process() + +}//end class +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Zend/Sniffs/Files/ClosingTagSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Zend/Sniffs/Files/ClosingTagSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Zend/Sniffs/Files/ClosingTagSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Zend/Sniffs/Files/ClosingTagSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,84 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Zend_Sniffs_Files_LineEndingsSniff. + * + * Checks that the file does not end with a closing tag. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Zend_Sniffs_Files_ClosingTagSniff implements PHP_CodeSniffer_Sniff +{ + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array(T_CLOSE_TAG); + + }//end register() + + + /** + * Processes this sniff, 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(); + + $next = $phpcsFile->findNext(T_INLINE_HTML, ($stackPtr + 1), null, true); + if ($next !== false) { + return; + } + + // We've found the last closing tag in the file so the only thing + // potentially remaining is inline HTML. Now we need to figure out + // whether or not it's just a bunch of whitespace. + $content = ''; + for ($i = ($stackPtr + 1); $i < $phpcsFile->numTokens; $i++) { + $content .= $tokens[$i]['content']; + } + + // Check if the remaining inline HTML is just whitespace. + $content = trim($content); + if (empty($content) === true) { + $error = 'A closing tag is not permitted at the end of a PHP file'; + $phpcsFile->addError($error, $stackPtr, 'NotAllowed'); + } + + }//end process() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Zend/Sniffs/NamingConventions/ValidVariableNameSniff.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Zend/Sniffs/NamingConventions/ValidVariableNameSniff.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Zend/Sniffs/NamingConventions/ValidVariableNameSniff.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Zend/Sniffs/NamingConventions/ValidVariableNameSniff.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,252 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +if (class_exists('PHP_CodeSniffer_Standards_AbstractVariableSniff', true) === false) { + throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_Standards_AbstractVariableSniff not found'); +} + +/** + * Squiz_Sniffs_NamingConventions_ValidVariableNameSniff. + * + * Checks the naming of variables and member variables. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Zend_Sniffs_NamingConventions_ValidVariableNameSniff extends PHP_CodeSniffer_Standards_AbstractVariableSniff +{ + + /** + * Tokens to ignore so that we can find a DOUBLE_COLON. + * + * @var array + */ + private $_ignore = array( + T_WHITESPACE, + T_COMMENT, + ); + + + /** + * 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 + */ + protected function processVariable(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + $tokens = $phpcsFile->getTokens(); + $varName = ltrim($tokens[$stackPtr]['content'], '$'); + + $phpReservedVars = array( + '_SERVER', + '_GET', + '_POST', + '_REQUEST', + '_SESSION', + '_ENV', + '_COOKIE', + '_FILES', + 'GLOBALS', + ); + + // If it's a php reserved var, then its ok. + if (in_array($varName, $phpReservedVars) === true) { + return; + } + + $objOperator = $phpcsFile->findNext(array(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(array(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(array(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 (PHP_CodeSniffer::isCamelCaps($objVarName, false, true, false) === false) { + $error = 'Variable "%s" is not in valid camel caps format'; + $data = array($originalVarName); + $phpcsFile->addError($error, $var, 'NotCamelCaps', $data); + } else if (preg_match('|\d|', $objVarName)) { + $warning = 'Variable "%s" contains numbers but this is discouraged'; + $data = array($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(array(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, array(T_CLASS, T_INTERFACE)); + } + + if ($inClass === true) { + $varName = substr($varName, 1); + } + } + + if (PHP_CodeSniffer::isCamelCaps($varName, false, true, false) === false) { + $error = 'Variable "%s" is not in valid camel caps format'; + $data = array($originalVarName); + $phpcsFile->addError($error, $stackPtr, 'NotCamelCaps', $data); + } else if (preg_match('|\d|', $varName)) { + $warning = 'Variable "%s" contains numbers but this is discouraged'; + $data = array($originalVarName); + $phpcsFile->addWarning($warning, $stackPtr, 'ContainsNumbers', $data); + } + + }//end processVariable() + + + /** + * Processes class member variables. + * + * @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 + */ + protected function processMemberVar(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + $tokens = $phpcsFile->getTokens(); + $varName = ltrim($tokens[$stackPtr]['content'], '$'); + $memberProps = $phpcsFile->getMemberProperties($stackPtr); + $public = ($memberProps['scope'] === 'public'); + + if ($public === true) { + if (substr($varName, 0, 1) === '_') { + $error = 'Public member variable "%s" must not contain a leading underscore'; + $data = array($varName); + $phpcsFile->addError($error, $stackPtr, 'PublicHasUnderscore', $data); + return; + } + } else { + if (substr($varName, 0, 1) !== '_') { + $scope = ucfirst($memberProps['scope']); + $error = '%s member variable "%s" must contain a leading underscore'; + $data = array( + $scope, + $varName, + ); + $phpcsFile->addError($error, $stackPtr, 'PrivateNoUnderscore', $data); + return; + } + } + + if (PHP_CodeSniffer::isCamelCaps($varName, false, $public, false) === false) { + $error = 'Variable "%s" is not in valid camel caps format'; + $data = array($varName); + $phpcsFile->addError($error, $stackPtr, 'MemberVarNotCamelCaps', $data); + } else if (preg_match('|\d|', $varName)) { + $warning = 'Variable "%s" contains numbers but this is discouraged'; + $data = array($varName); + $phpcsFile->addWarning($warning, $stackPtr, 'MemberVarContainsNumbers', $data); + } + + }//end processMemberVar() + + + /** + * Processes the variable found within a double quoted string. + * + * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the double quoted + * string. + * + * @return void + */ + protected function processVariableInString(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + $tokens = $phpcsFile->getTokens(); + + $phpReservedVars = array( + '_SERVER', + '_GET', + '_POST', + '_REQUEST', + '_SESSION', + '_ENV', + '_COOKIE', + '_FILES', + 'GLOBALS', + ); + + 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; + } + + // 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) === '_') { + if ($phpcsFile->hasCondition($stackPtr, array(T_CLASS, T_INTERFACE)) === true) { + $varName = substr($varName, 1); + } + } + + if (PHP_CodeSniffer::isCamelCaps($varName, false, true, false) === false) { + $varName = $matches[0]; + $error = 'Variable "%s" is not in valid camel caps format'; + $data = array($originalVarName); + $phpcsFile->addError($error, $stackPtr, 'StringVarNotCamelCaps', $data); + } else if (preg_match('|\d|', $varName)) { + $warning = 'Variable "%s" contains numbers but this is discouraged'; + $data = array($originalVarName); + $phpcsFile->addWarning($warning, $stackPtr, 'StringVarContainsNumbers', $data); + } + } + }//end if + + }//end processVariableInString() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Zend/Tests/Debug/CodeAnalyzerUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Zend/Tests/Debug/CodeAnalyzerUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Zend/Tests/Debug/CodeAnalyzerUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Zend/Tests/Debug/CodeAnalyzerUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,6 @@ + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Zend/Tests/Debug/CodeAnalyzerUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Zend/Tests/Debug/CodeAnalyzerUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Zend/Tests/Debug/CodeAnalyzerUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Zend/Tests/Debug/CodeAnalyzerUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,82 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the CodeAnalyzer sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Zend_Tests_Debug_CodeAnalyzerUnitTest extends AbstractSniffUnitTest +{ + + + /** + * Should this test be skipped for some reason. + * + * @return void + */ + protected function shouldSkipTest() + { + $analyzerPath = PHP_CodeSniffer::getConfigData('zend_ca_path'); + 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 array(); + + }//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 array( + 2 => 1, + ); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Zend/Tests/Files/ClosingTagUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Zend/Tests/Files/ClosingTagUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Zend/Tests/Files/ClosingTagUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Zend/Tests/Files/ClosingTagUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,12 @@ + + + + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Zend/Tests/Files/ClosingTagUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Zend/Tests/Files/ClosingTagUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Zend/Tests/Files/ClosingTagUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Zend/Tests/Files/ClosingTagUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,69 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the ClosingTag sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Zend_Tests_Files_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. + * + * @return array(int => int) + */ + public function getErrorList() + { + return array( + 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 array(); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Zend/Tests/NamingConventions/ValidVariableNameUnitTest.inc php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Zend/Tests/NamingConventions/ValidVariableNameUnitTest.inc --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Zend/Tests/NamingConventions/ValidVariableNameUnitTest.inc 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Zend/Tests/NamingConventions/ValidVariableNameUnitTest.inc 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,100 @@ +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); +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Zend/Tests/NamingConventions/ValidVariableNameUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Zend/Tests/NamingConventions/ValidVariableNameUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Zend/Tests/NamingConventions/ValidVariableNameUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Zend/Tests/NamingConventions/ValidVariableNameUnitTest.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,111 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Unit test class for the ValidVariableName sniff. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings are stored in this class. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Zend_Tests_NamingConventions_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 array( + 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, + 90 => 1, + 92 => 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 array( + 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, + ); + + }//end getWarningList() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Zend/ruleset.xml php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Zend/ruleset.xml --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Zend/ruleset.xml 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/Zend/ruleset.xml 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,32 @@ + + + A coding standard based on an early Zend Framework coding standard. Note that this standard is out of date. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Tokenizers/CSS.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Tokenizers/CSS.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Tokenizers/CSS.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Tokenizers/CSS.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,515 @@ + + * @copyright 2006-2012 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 + */ + +if (class_exists('PHP_CodeSniffer_Tokenizers_PHP', true) === false) { + throw new Exception('Class PHP_CodeSniffer_Tokenizers_PHP not found'); +} + +/** + * Tokenizes CSS code. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PHP_CodeSniffer_Tokenizers_CSS extends PHP_CodeSniffer_Tokenizers_PHP +{ + + + /** + * Creates an array of tokens when given some CSS code. + * + * Uses the PHP tokenizer to do all the tricky work + * + * @param string $string The string to tokenize. + * @param string $eolChar The EOL character to use for splitting strings. + * + * @return array + */ + public function tokenizeString($string, $eolChar='\n') + { + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo "\t*** START CSS TOKENIZING ***".PHP_EOL; + } + + // If the content doesn't have an EOl char on the end, add one so + // the open and close tags we add are parsed correctly. + if (substr($string, 0, (strlen($eolChar) * -1)) !== $eolChar) { + $string .= $eolChar; + } + + $tokens = parent::tokenizeString('', $eolChar); + $finalTokens = array(); + + $newStackPtr = 0; + $numTokens = count($tokens); + $multiLineComment = false; + for ($stackPtr = 0; $stackPtr < $numTokens; $stackPtr++) { + $token = $tokens[$stackPtr]; + + if (PHP_CODESNIFFER_VERBOSITY > 1) { + $type = $token['type']; + $content = str_replace($eolChar, '\n', $token['content']); + echo "\tProcess token $stackPtr: $type => $content".PHP_EOL; + } + + // Sometimes, there are PHP tags embedded in the code, which causes issues + // with how PHP tokenizeses the string. After the first closing tag is found, + // everything outside PHP tags is set as inline HTML tokens (1 for each line). + // So we need to go through and find these tokens so we can re-tokenize them. + if ($token['code'] === T_CLOSE_TAG && $stackPtr !== ($numTokens - 1)) { + $content = ''; + } + + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo "\t\t=> Found premature closing tag at $stackPtr".PHP_EOL; + $cleanContent = str_replace($eolChar, '\n', $content); + echo "\t\tcontent: $cleanContent".PHP_EOL; + $oldNumTokens = $numTokens; + } + + // Tokenize the string and remove the extra PHP tags we don't need. + $moreTokens = parent::tokenizeString($content, $eolChar); + array_shift($moreTokens); + array_pop($moreTokens); + array_pop($moreTokens); + + // Rebuild the tokens array. + array_splice($tokens, ($stackPtr + 1), ($x - $stackPtr), $moreTokens); + $numTokens = count($tokens); + if (PHP_CODESNIFFER_VERBOSITY > 1) { + $count = count($moreTokens); + $diff = ($x - $stackPtr); + echo "\t\t* added $count tokens, replaced $diff; size changed from $oldNumTokens to $numTokens *".PHP_EOL; + } + }//end if + + if ($token['code'] === T_FUNCTION) { + // There are no functions in CSS, so convert this to a string. + $finalTokens[$newStackPtr] = array( + 'type' => 'T_STRING', + 'code' => T_STRING, + 'content' => $token['content'], + ); + + $newStackPtr++; + continue; + } + + if ($token['code'] === T_COMMENT + && substr($token['content'], 0, 2) === '/*' + ) { + // Multi-line comment. Record it so we can ignore other + // comment tags until we get out of this one. + $multiLineComment = true; + } + + if ($token['code'] === T_COMMENT + && $multiLineComment === false + && (substr($token['content'], 0, 2) === '//' + || $token['content']{0} === '#') + ) { + $content = ltrim($token['content'], '#/'); + $commentTokens + = parent::tokenizeString('', $eolChar); + + // The first and last tokens are the open/close tags. + array_shift($commentTokens); + array_pop($commentTokens); + + if ($token['content']{0} === '#') { + // The # character is not a comment in CSS files, so + // determine what it means in this context. + $firstContent = $commentTokens[0]['content']; + + // If the first content is just a number, it is probably a + // colour like 8FB7DB, which PHP splits into 8 and FB7DB. + if (($commentTokens[0]['code'] === T_LNUMBER + || $commentTokens[0]['code'] === T_DNUMBER) + && $commentTokens[1]['code'] === T_STRING + ) { + $firstContent .= $commentTokens[1]['content']; + array_shift($commentTokens); + } + + // If the first content looks like a colour and not a class + // definition, join the tokens together. + if (preg_match('/^[ABCDEF0-9]+$/i', $firstContent) === 1) { + array_shift($commentTokens); + // Work out what we trimmed off above and remember to re-add it. + $trimmed = substr($token['content'], 0, (strlen($token['content']) - strlen($content))); + $finalTokens[$newStackPtr] = array( + 'type' => 'T_COLOUR', + 'code' => T_COLOUR, + 'content' => $trimmed.$firstContent, + ); + } else { + $finalTokens[$newStackPtr] = array( + 'type' => 'T_HASH', + 'code' => T_HASH, + 'content' => '#', + ); + } + } else { + $finalTokens[$newStackPtr] = array( + 'type' => 'T_STRING', + 'code' => T_STRING, + 'content' => '//', + ); + }//end if + + $newStackPtr++; + + foreach ($commentTokens as $tokenData) { + if ($tokenData['code'] === T_COMMENT + && (substr($tokenData['content'], 0, 2) === '//' + || $tokenData['content']{0} === '#') + ) { + // This is a comment in a comment, so it needs + // to go through the whole process again. + $tokens[$stackPtr]['content'] = $tokenData['content']; + $stackPtr--; + break; + } + + $finalTokens[$newStackPtr] = $tokenData; + $newStackPtr++; + } + + continue; + }//end if + + if ($token['code'] === T_COMMENT + && substr($token['content'], -2) === '*/' + ) { + // Multi-line comment is done. + $multiLineComment = false; + } + + $finalTokens[$newStackPtr] = $token; + $newStackPtr++; + }//end for + + // A flag to indicate if we are inside a style definition, + // which is defined using curly braces. I'm assuming you can't + // have nested curly brackets. + $inStyleDef = false; + + $numTokens = count($finalTokens); + for ($stackPtr = 0; $stackPtr < $numTokens; $stackPtr++) { + $token = $finalTokens[$stackPtr]; + + switch ($token['code']) { + case T_OPEN_CURLY_BRACKET: + $inStyleDef = true; + break; + case T_CLOSE_CURLY_BRACKET: + $inStyleDef = false; + break; + case T_MINUS: + // Minus signs are often used instead of spaces inside + // class names, IDs and styles. + if ($finalTokens[($stackPtr + 1)]['code'] === T_STRING) { + if ($finalTokens[($stackPtr - 1)]['code'] === T_STRING) { + $newContent = $finalTokens[($stackPtr - 1)]['content'].'-'.$finalTokens[($stackPtr + 1)]['content']; + + $finalTokens[($stackPtr - 1)]['content'] = $newContent; + unset($finalTokens[$stackPtr]); + unset($finalTokens[($stackPtr + 1)]); + $stackPtr -= 2; + } else { + $newContent = '-'.$finalTokens[($stackPtr + 1)]['content']; + + $finalTokens[($stackPtr + 1)]['content'] = $newContent; + unset($finalTokens[$stackPtr]); + $stackPtr--; + } + + $finalTokens = array_values($finalTokens); + $numTokens = count($finalTokens); + } else if ($finalTokens[($stackPtr + 1)]['code'] === T_LNUMBER) { + // They can also be used to provide negative numbers. + $finalTokens[($stackPtr + 1)]['content'] + = '-'.$finalTokens[($stackPtr + 1)]['content']; + unset($finalTokens[$stackPtr]); + + $finalTokens = array_values($finalTokens); + $numTokens = count($finalTokens); + } + + break; + case T_COLON: + // Only interested in colons that are defining styles. + if ($inStyleDef === false) { + break; + } + + for ($x = ($stackPtr - 1); $x >= 0; $x--) { + if (in_array($finalTokens[$x]['code'], PHP_CodeSniffer_Tokens::$emptyTokens) === false) { + break; + } + } + + $finalTokens[$x]['type'] = 'T_STYLE'; + $finalTokens[$x]['code'] = T_STYLE; + break; + case T_STRING: + if (strtolower($token['content']) === 'url') { + // Find the next content. + for ($x = ($stackPtr + 1); $x < $numTokens; $x++) { + if (in_array($finalTokens[$x]['code'], PHP_CodeSniffer_Tokens::$emptyTokens) === false) { + break; + } + } + + // Needs to be in the format "url(" for it to be a URL. + if ($finalTokens[$x]['code'] !== T_OPEN_PARENTHESIS) { + continue; + } + + // Make sure the content isn't empty. + for ($y = ($x + 1); $y < $numTokens; $y++) { + if (in_array($finalTokens[$y]['code'], PHP_CodeSniffer_Tokens::$emptyTokens) === false) { + break; + } + } + + if ($finalTokens[$y]['code'] === T_CLOSE_PARENTHESIS) { + continue; + } + + // Join all the content together inside the url() statement. + $newContent = ''; + for ($i = ($x + 2); $i < $numTokens; $i++) { + if ($finalTokens[$i]['code'] === T_CLOSE_PARENTHESIS) { + break; + } + + $newContent .= $finalTokens[$i]['content']; + unset($finalTokens[$i]); + } + + // If the content inside the "url()" is in double quotes + // there will only be one token and so we don't have to do + // anything except change its type. If it is not empty, + // we need to do some token merging. + $finalTokens[($x + 1)]['type'] = 'T_URL'; + $finalTokens[($x + 1)]['code'] = T_URL; + + if ($newContent !== '') { + $finalTokens[($x + 1)]['content'] .= $newContent; + + $finalTokens = array_values($finalTokens); + $numTokens = count($finalTokens); + } + }//end if + + break; + default: + // Nothing special to be done with this token. + break; + }//end switch + }//end for + + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo "\t*** END CSS TOKENIZING ***".PHP_EOL; + } + + return $finalTokens; + + }//end tokenizeString() + + + /** + * Performs additional processing after main tokenizing. + * + * This additional processing converts T_LIST tokens to T_STRING + * because there are no list constructs in CSS and list-* styles + * look like lists to the PHP tokenizer. + * + * @param array &$tokens The array of tokens to process. + * @param string $eolChar The EOL character to use for splitting strings. + * + * @return void + */ + public function processAdditional(&$tokens, $eolChar) + { + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo "\t*** START ADDITIONAL CSS PROCESSING ***".PHP_EOL; + } + + $numTokens = (count($tokens) - 1); + $changeMade = false; + + for ($i = 0; $i < $numTokens; $i++) { + if ($tokens[($i + 1)]['code'] !== T_STYLE) { + continue; + } + + $style = ($i + 1); + + if ($tokens[$i]['code'] === T_LIST) { + $tokens[$style]['content'] = $tokens[$i]['content'].$tokens[$style]['content']; + $tokens[$style]['column'] = $tokens[$i]['column']; + + if (PHP_CODESNIFFER_VERBOSITY > 1) { + $line = $tokens[$i]['line']; + echo "\t* T_LIST token $i on line $line merged into T_STYLE token $style *".PHP_EOL; + } + + // Now fix the brackets that surround this token as they will + // be pointing too far ahead now that we have removed a token. + for ($t = $i; $t >= 0; $t--) { + if (isset($tokens[$t]['bracket_closer']) === true) { + $old = $tokens[$t]['bracket_closer']; + $tokens[$t]['bracket_closer']--; + if (PHP_CODESNIFFER_VERBOSITY > 1) { + $new = $tokens[$t]['bracket_closer']; + $type = $tokens[$t]['type']; + $line = $tokens[$t]['line']; + echo "\t\t* $type token $t on line $line closer changed from $old to $new *".PHP_EOL; + } + + // Only need to fix one set of brackets. + break; + } + } + + // Now fix all future brackets as they are no longer pointing + // to the correct tokens either. + for ($t = $i; $t <= $numTokens; $t++) { + if (isset($tokens[$t]) === false) { + break; + } + + if ($tokens[$t]['code'] === T_OPEN_CURLY_BRACKET) { + $old = $tokens[$t]['bracket_closer']; + $tokens[$t]['bracket_closer']--; + if (PHP_CODESNIFFER_VERBOSITY > 1) { + $new = $tokens[$t]['bracket_closer']; + $type = $tokens[$t]['type']; + $line = $tokens[$t]['line']; + echo "\t\t* $type token $t on line $line closer changed from $old to $new *".PHP_EOL; + } + + $t = $old; + } + } + + unset($tokens[$i]); + $changeMade = true; + $i++; + } else if ($tokens[$i]['code'] === T_BREAK) { + // Break is sometimes used in style definitions, like page-break-inside + // so we need merge the elements around it into the next T_STYLE. + $newStyle = 'break'.$tokens[$style]['content']; + for ($x = ($i - 1); $x >= 0; $x--) { + if ($tokens[$x]['code'] !== T_STRING && $tokens[$x]['code'] !== T_MINUS) { + break; + } + + $newStyle = $tokens[$x]['content'].$newStyle; + } + + $x++; + $tokens[$style]['content'] = $newStyle; + $tokens[$style]['column'] = $tokens[$x]['column']; + + if (PHP_CODESNIFFER_VERBOSITY > 1) { + $line = $tokens[$i]['line']; + echo "\t* tokens $x - $i on line $line merged into T_STYLE token $style due to T_BREAK at token $i *".PHP_EOL; + } + + // Now fix the brackets that surround this token as they will + // be pointing too far ahead now that we have removed tokens. + $diff = ($style - $x); + for ($t = $style; $t >= 0; $t--) { + if (isset($tokens[$t]['bracket_closer']) === true) { + $old = $tokens[$t]['bracket_closer']; + $tokens[$t]['bracket_closer'] -= $diff; + if (PHP_CODESNIFFER_VERBOSITY > 1) { + $new = $tokens[$t]['bracket_closer']; + $type = $tokens[$t]['type']; + $line = $tokens[$t]['line']; + echo "\t\t* $type token $t on line $line closer changed from $old to $new *".PHP_EOL; + } + + // Only need to fix one set of brackets. + break; + } + } + + // Now fix all future brackets as they are no longer pointing + // to the correct tokens either. + for ($t = $style; $t <= $numTokens; $t++) { + if (isset($tokens[$t]) === false) { + break; + } + + if ($tokens[$t]['code'] === T_OPEN_CURLY_BRACKET) { + $old = $tokens[$t]['bracket_closer']; + $tokens[$t]['bracket_closer'] -= $diff; + if (PHP_CODESNIFFER_VERBOSITY > 1) { + $new = $tokens[$t]['bracket_closer']; + $type = $tokens[$t]['type']; + $line = $tokens[$t]['line']; + echo "\t\t* $type token $t on line $line closer changed from $old to $new *".PHP_EOL; + } + + $t = $old; + } + } + + for ($x; $x <= $i; $x++) { + unset($tokens[$x]); + } + + $changeMade = true; + $i++; + }//end if + }//end for + + if ($changeMade === true) { + $tokens = array_values($tokens); + } + + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo "\t*** END ADDITIONAL CSS PROCESSING ***".PHP_EOL; + } + + }//end processAdditional() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Tokenizers/JS.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Tokenizers/JS.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Tokenizers/JS.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Tokenizers/JS.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,1140 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +/** + * Tokenizes JS code. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PHP_CodeSniffer_Tokenizers_JS +{ + + /** + * A list of tokens that are allowed to open a scope. + * + * This array also contains information about what kind of token the scope + * opener uses to open and close the scope, if the token strictly requires + * an opener, if the token can share a scope closer, and who it can be shared + * with. An example of a token that shares a scope closer is a CASE scope. + * + * @var array + */ + public $scopeOpeners = array( + T_IF => array( + 'start' => array(T_OPEN_CURLY_BRACKET), + 'end' => array(T_CLOSE_CURLY_BRACKET), + 'strict' => false, + 'shared' => false, + 'with' => array(), + ), + T_TRY => array( + 'start' => array(T_OPEN_CURLY_BRACKET), + 'end' => array(T_CLOSE_CURLY_BRACKET), + 'strict' => true, + 'shared' => false, + 'with' => array(), + ), + T_CATCH => array( + 'start' => array(T_OPEN_CURLY_BRACKET), + 'end' => array(T_CLOSE_CURLY_BRACKET), + 'strict' => true, + 'shared' => false, + 'with' => array(), + ), + T_ELSE => array( + 'start' => array(T_OPEN_CURLY_BRACKET), + 'end' => array(T_CLOSE_CURLY_BRACKET), + 'strict' => false, + 'shared' => false, + 'with' => array(), + ), + T_FOR => array( + 'start' => array(T_OPEN_CURLY_BRACKET), + 'end' => array(T_CLOSE_CURLY_BRACKET), + 'strict' => false, + 'shared' => false, + 'with' => array(), + ), + T_FUNCTION => array( + 'start' => array(T_OPEN_CURLY_BRACKET), + 'end' => array(T_CLOSE_CURLY_BRACKET), + 'strict' => false, + 'shared' => false, + 'with' => array(), + ), + T_WHILE => array( + 'start' => array(T_OPEN_CURLY_BRACKET), + 'end' => array(T_CLOSE_CURLY_BRACKET), + 'strict' => false, + 'shared' => false, + 'with' => array(), + ), + T_DO => array( + 'start' => array(T_OPEN_CURLY_BRACKET), + 'end' => array(T_CLOSE_CURLY_BRACKET), + 'strict' => true, + 'shared' => false, + 'with' => array(), + ), + T_SWITCH => array( + 'start' => array(T_OPEN_CURLY_BRACKET), + 'end' => array(T_CLOSE_CURLY_BRACKET), + 'strict' => true, + 'shared' => false, + 'with' => array(), + ), + T_CASE => array( + 'start' => array(T_COLON), + 'end' => array( + T_BREAK, + T_RETURN, + T_CONTINUE, + T_THROW, + ), + 'strict' => true, + 'shared' => true, + 'with' => array( + T_DEFAULT, + T_CASE, + T_SWITCH, + ), + ), + T_DEFAULT => array( + 'start' => array(T_COLON), + 'end' => array( + T_BREAK, + T_RETURN, + T_CONTINUE, + T_THROW, + ), + 'strict' => true, + 'shared' => true, + 'with' => array( + T_CASE, + T_SWITCH, + ), + ), + ); + + /** + * A list of tokens that end the scope. + * + * This array is just a unique collection of the end tokens + * from the _scopeOpeners array. The data is duplicated here to + * save time during parsing of the file. + * + * @var array + */ + public $endScopeTokens = array( + T_CLOSE_CURLY_BRACKET, + T_BREAK, + ); + + /** + * A list of special JS tokens and their types. + * + * @var array + */ + protected $tokenValues = array( + 'function' => 'T_FUNCTION', + 'prototype' => 'T_PROTOTYPE', + 'try' => 'T_TRY', + 'catch' => 'T_CATCH', + 'return' => 'T_RETURN', + 'break' => 'T_BREAK', + 'switch' => 'T_SWITCH', + 'continue' => 'T_CONTINUE', + 'if' => 'T_IF', + 'else' => 'T_ELSE', + 'do' => 'T_DO', + 'while' => 'T_WHILE', + 'for' => 'T_FOR', + 'var' => 'T_VAR', + 'case' => 'T_CASE', + 'default' => 'T_DEFAULT', + 'true' => 'T_TRUE', + 'false' => 'T_FALSE', + 'null' => 'T_NULL', + 'this' => 'T_THIS', + 'typeof' => 'T_TYPEOF', + '(' => 'T_OPEN_PARENTHESIS', + ')' => 'T_CLOSE_PARENTHESIS', + '{' => 'T_OPEN_CURLY_BRACKET', + '}' => 'T_CLOSE_CURLY_BRACKET', + '[' => 'T_OPEN_SQUARE_BRACKET', + ']' => 'T_CLOSE_SQUARE_BRACKET', + '?' => 'T_INLINE_THEN', + '.' => 'T_OBJECT_OPERATOR', + '+' => 'T_PLUS', + '-' => 'T_MINUS', + '*' => 'T_MULTIPLY', + '%' => 'T_MODULUS', + '/' => 'T_DIVIDE', + '^' => 'T_POWER', + ',' => 'T_COMMA', + ';' => 'T_SEMICOLON', + ':' => 'T_COLON', + '<' => 'T_LESS_THAN', + '>' => 'T_GREATER_THAN', + '<=' => 'T_IS_SMALLER_OR_EQUAL', + '>=' => 'T_IS_GREATER_OR_EQUAL', + '!' => 'T_BOOLEAN_NOT', + '||' => 'T_BOOLEAN_OR', + '&&' => 'T_BOOLEAN_AND', + '|' => 'T_BITWISE_OR', + '&' => 'T_BITWISE_AND', + '!=' => 'T_IS_NOT_EQUAL', + '!==' => 'T_IS_NOT_IDENTICAL', + '=' => 'T_EQUAL', + '==' => 'T_IS_EQUAL', + '===' => 'T_IS_IDENTICAL', + '-=' => 'T_MINUS_EQUAL', + '+=' => 'T_PLUS_EQUAL', + '*=' => 'T_MUL_EQUAL', + '/=' => 'T_DIV_EQUAL', + '%=' => 'T_MOD_EQUAL', + '++' => 'T_INC', + '--' => 'T_DEC', + '//' => 'T_COMMENT', + '/*' => 'T_COMMENT', + '/**' => 'T_DOC_COMMENT', + '*/' => 'T_COMMENT', + ); + + /** + * A list string delimiters. + * + * @var array + */ + protected $stringTokens = array( + '\'', + '"', + ); + + /** + * A list tokens that start and end comments. + * + * @var array + */ + protected $commentTokens = array( + '//' => null, + '/*' => '*/', + '/**' => '*/', + ); + + + /** + * Creates an array of tokens when given some PHP code. + * + * Starts by using token_get_all() but does a lot of extra processing + * to insert information about the context of the token. + * + * @param string $string The string to tokenize. + * @param string $eolChar The EOL character to use for splitting strings. + * + * @return array + */ + public function tokenizeString($string, $eolChar='\n') + { + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo "\t*** START JS TOKENIZING ***".PHP_EOL; + } + + $tokenTypes = array_keys($this->tokenValues); + + $maxTokenLength = 0; + foreach ($tokenTypes as $token) { + if (strlen($token) > $maxTokenLength) { + $maxTokenLength = strlen($token); + } + } + + $tokens = array(); + $inString = ''; + $stringChar = null; + $inComment = ''; + $buffer = ''; + $preStringBuffer = ''; + $cleanBuffer = false; + + $tokens[] = array( + 'code' => T_OPEN_TAG, + 'type' => 'T_OPEN_TAG', + 'content' => '', + ); + + // Convert newlines to single characters for ease of + // processing. We will change them back later. + $string = str_replace($eolChar, "\n", $string); + + $chars = str_split($string); + $numChars = count($chars); + for ($i = 0; $i < $numChars; $i++) { + $char = $chars[$i]; + + if (PHP_CODESNIFFER_VERBOSITY > 1) { + $content = str_replace("\n", '\n', $char); + $bufferContent = str_replace("\n", '\n', $buffer); + if ($inString !== '') { + echo "\t"; + } + + if ($inComment !== '') { + echo "\t"; + } + + echo "\tProcess char $i => $content (buffer: $bufferContent)".PHP_EOL; + } + + if ($inString === '' && $inComment === '' && $buffer !== '') { + // If the buffer only has whitespace and we are about to + // add a character, store the whitespace first. + if (trim($char) !== '' && trim($buffer) === '') { + $tokens[] = array( + 'code' => T_WHITESPACE, + 'type' => 'T_WHITESPACE', + 'content' => str_replace("\n", $eolChar, $buffer), + ); + + if (PHP_CODESNIFFER_VERBOSITY > 1) { + $content = str_replace("\n", '\n', $buffer); + echo "\t=> Added token T_WHITESPACE ($content)".PHP_EOL; + } + + $buffer = ''; + } + + // If the buffer is not whitespace and we are about to + // add a whitespace character, store the content first. + if ($inString === '' + && $inComment === '' + && trim($char) === '' + && trim($buffer) !== '' + ) { + $tokens[] = array( + 'code' => T_STRING, + 'type' => 'T_STRING', + 'content' => str_replace("\n", $eolChar, $buffer), + ); + + if (PHP_CODESNIFFER_VERBOSITY > 1) { + $content = str_replace("\n", '\n', $buffer); + echo "\t=> Added token T_STRING ($content)".PHP_EOL; + } + + $buffer = ''; + } + }//end if + + // Process strings. + if ($inComment === '' && in_array($char, $this->stringTokens) === true) { + if ($inString === $char) { + // This could be the end of the string, but make sure it + // is not escaped first. + $escapes = 0; + for ($x = ($i - 1); $x >= 0; $x--) { + if ($chars[$x] !== '\\') { + break; + } + + $escapes++; + } + + if ($escapes === 0 || ($escapes % 2) === 0) { + // There is an even number escape chars, + // so this is not escaped, it is the end of the string. + $tokens[] = array( + 'code' => T_CONSTANT_ENCAPSED_STRING, + 'type' => 'T_CONSTANT_ENCAPSED_STRING', + 'content' => str_replace("\n", $eolChar, $buffer).$char, + ); + + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo "\t\t* found end of string *".PHP_EOL; + $content = str_replace("\n", '\n', $buffer.$char); + echo "\t=> Added token T_CONSTANT_ENCAPSED_STRING ($content)".PHP_EOL; + } + + $buffer = ''; + $preStringBuffer = ''; + $inString = ''; + $stringChar = null; + continue; + } + } else if ($inString === '') { + $inString = $char; + $stringChar = $i; + $preStringBuffer = $buffer; + + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo "\t\t* looking for string closer *".PHP_EOL; + } + }//end if + }//end if + + if ($inString !== '' && $char === "\n") { + // Unless this newline character is escaped, the string did not + // end before the end of the line, which means it probably + // wasn't a string at all (maybe a regex). + if ($chars[($i - 1)] !== '\\') { + $i = $stringChar; + $buffer = $preStringBuffer; + $preStringBuffer = ''; + $inString = ''; + $stringChar = null; + $char = $chars[$i]; + + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo "\t\t* found newline before end of string, bailing *".PHP_EOL; + } + } + } + + $buffer .= $char; + + // We don't look for special tokens inside strings, + // so if we are in a string, we can continue here now + // that the current char is in the buffer. + if ($inString !== '') { + continue; + } + + // Special case for T_DIVIDE which can actually be + // the start of a regular expression. + if ($char === '/') { + $regex = $this->getRegexToken( + $i, + $string, + $chars, + $tokens, + $eolChar + ); + + if ($regex !== null) { + $tokens[] = array( + 'code' => T_REGULAR_EXPRESSION, + 'type' => 'T_REGULAR_EXPRESSION', + 'content' => $regex['content'], + ); + + if (PHP_CODESNIFFER_VERBOSITY > 1) { + $content = str_replace("\n", '\n', $regex['content']); + echo "\t=> Added token T_REGULAR_EXPRESSION ($content)".PHP_EOL; + } + + $i = $regex['end']; + $buffer = ''; + $cleanBuffer = false; + continue; + } + }//end if + + // Check for known tokens, but ignore tokens found that are not at + // the end of a string, like FOR and this.FORmat. + if (in_array(strtolower($buffer), $tokenTypes) === true + && (preg_match('|[a-zA-z0-9_]|', $char) === 0 + || isset($chars[($i + 1)]) === false + || preg_match('|[a-zA-z0-9_]|', $chars[($i + 1)]) === 0) + ) { + $matchedToken = false; + $lookAheadLength = ($maxTokenLength - strlen($buffer)); + + if ($lookAheadLength > 0) { + // The buffer contains a token type, but we need + // to look ahead at the next chars to see if this is + // actually part of a larger token. For example, + // FOR and FOREACH. + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo "\t\t* buffer possibly contains token, looking ahead $lookAheadLength chars *".PHP_EOL; + } + + $charBuffer = $buffer; + for ($x = 1; $x <= $lookAheadLength; $x++) { + if (isset($chars[($i + $x)]) === false) { + break; + } + + $charBuffer .= $chars[($i + $x)]; + + if (PHP_CODESNIFFER_VERBOSITY > 1) { + $content = str_replace("\n", '\n', $charBuffer); + echo "\t\t=> Looking ahead $x chars => $content".PHP_EOL; + } + + if (in_array(strtolower($charBuffer), $tokenTypes) === true) { + // We've found something larger that matches + // so we can ignore this char. Except for 1 very specific + // case where a comment like /**/ needs to tokenize as + // T_COMMENT and not T_DOC_COMMENT. + $oldType = $this->tokenValues[strtolower($buffer)]; + $newType = $this->tokenValues[strtolower($charBuffer)]; + if ($oldType === 'T_COMMENT' + && $newType === 'T_DOC_COMMENT' + && $chars[($i + $x + 1)] === '/' + ) { + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo "\t\t* look ahead ignored T_DOC_COMMENT, continuing *".PHP_EOL; + } + } else { + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo "\t\t* look ahead found more specific token ($newType), ignoring $i *".PHP_EOL; + } + + $matchedToken = true; + break; + } + } + }//end for + }//end if + + if ($matchedToken === false) { + if (PHP_CODESNIFFER_VERBOSITY > 1 && $lookAheadLength > 0) { + echo "\t\t* look ahead found nothing *".PHP_EOL; + } + + $value = $this->tokenValues[strtolower($buffer)]; + $tokens[] = array( + 'code' => constant($value), + 'type' => $value, + 'content' => $buffer, + ); + + if (PHP_CODESNIFFER_VERBOSITY > 1) { + $content = str_replace("\n", '\n', $buffer); + echo "\t=> Added token $value ($content)".PHP_EOL; + } + + $cleanBuffer = true; + }//end if + } else if (in_array(strtolower($char), $tokenTypes) === true) { + // No matter what token we end up using, we don't + // need the content in the buffer any more because we have + // found a valid token. + $newContent = substr(str_replace("\n", $eolChar, $buffer), 0, -1); + if ($newContent !== '') { + $tokens[] = array( + 'code' => T_STRING, + 'type' => 'T_STRING', + 'content' => $newContent, + ); + + if (PHP_CODESNIFFER_VERBOSITY > 1) { + $content = str_replace("\n", '\n', substr($buffer, 0, -1)); + echo "\t=> Added token T_STRING ($content)".PHP_EOL; + } + } + + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo "\t\t* char is token, looking ahead ".($maxTokenLength - 1).' chars *'.PHP_EOL; + } + + // The char is a token type, but we need to look ahead at the + // next chars to see if this is actually part of a larger token. + // For example, = and ===. + $charBuffer = $char; + $matchedToken = false; + for ($x = 1; $x <= $maxTokenLength; $x++) { + if (isset($chars[($i + $x)]) === false) { + break; + } + + $charBuffer .= $chars[($i + $x)]; + + if (PHP_CODESNIFFER_VERBOSITY > 1) { + $content = str_replace("\n", '\n', $charBuffer); + echo "\t\t=> Looking ahead $x chars => $content".PHP_EOL; + } + + if (in_array(strtolower($charBuffer), $tokenTypes) === true) { + // We've found something larger that matches + // so we can ignore this char. + if (PHP_CODESNIFFER_VERBOSITY > 1) { + $type = $this->tokenValues[strtolower($charBuffer)]; + echo "\t\t* look ahead found more specific token ($type), ignoring $i *".PHP_EOL; + } + + $matchedToken = true; + break; + } + }//end for + + if ($matchedToken === false) { + $value = $this->tokenValues[strtolower($char)]; + $tokens[] = array( + 'code' => constant($value), + 'type' => $value, + 'content' => $char, + ); + + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo "\t\t* look ahead found nothing *".PHP_EOL; + $content = str_replace("\n", '\n', $char); + echo "\t=> Added token $value ($content)".PHP_EOL; + } + + $cleanBuffer = true; + } else { + $buffer = $char; + } + }//end if + + // Keep track of content inside comments. + if ($inComment === '' + && array_key_exists($buffer, $this->commentTokens) === true + ) { + // This is not really a comment if the content + // looks like \// (i.e., it is escaped). + if (isset($chars[($i - 2)]) === true && $chars[($i - 2)] === '\\') { + $lastToken = array_pop($tokens); + $lastContent = $lastToken['content']; + if (PHP_CODESNIFFER_VERBOSITY > 1) { + $value = $this->tokenValues[strtolower($lastContent)]; + $content = str_replace("\n", '\n', $lastContent); + echo "\t=> Removed token $value ($content)".PHP_EOL; + } + + $lastChars = str_split($lastContent); + $lastNumChars = count($lastChars); + for ($x = 0; $x < $lastNumChars; $x++) { + $lastChar = $lastChars[$x]; + $value = $this->tokenValues[strtolower($lastChar)]; + $tokens[] = array( + 'code' => constant($value), + 'type' => $value, + 'content' => $lastChar, + ); + + if (PHP_CODESNIFFER_VERBOSITY > 1) { + $content = str_replace("\n", '\n', $lastChar); + echo "\t=> Added token $value ($content)".PHP_EOL; + } + } + } else { + // We have started a comment. + $inComment = $buffer; + + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo "\t\t* looking for end of comment *".PHP_EOL; + } + } + } else if ($inComment !== '') { + if ($this->commentTokens[$inComment] === null) { + // Comment ends at the next newline. + if (strpos($buffer, "\n") !== false) { + $inComment = ''; + } + } else { + if ($this->commentTokens[$inComment] === $buffer) { + $inComment = ''; + } + } + + if (PHP_CODESNIFFER_VERBOSITY > 1) { + if ($inComment === '') { + echo "\t\t* found end of comment *".PHP_EOL; + } + } + + if ($inComment === '' && $cleanBuffer === false) { + $tokens[] = array( + 'code' => T_STRING, + 'type' => 'T_STRING', + 'content' => str_replace("\n", $eolChar, $buffer), + ); + + if (PHP_CODESNIFFER_VERBOSITY > 1) { + $content = str_replace("\n", '\n', $buffer); + echo "\t=> Added token T_STRING ($content)".PHP_EOL; + } + + $buffer = ''; + } + }//end if + + if ($cleanBuffer === true) { + $buffer = ''; + $cleanBuffer = false; + } + }//end foreach + + if (empty($buffer) === false) { + // Buffer contains whitespace from the end of the file. + $tokens[] = array( + 'code' => T_WHITESPACE, + 'type' => 'T_WHITESPACE', + 'content' => str_replace("\n", $eolChar, $buffer), + ); + + if (PHP_CODESNIFFER_VERBOSITY > 1) { + $content = str_replace($eolChar, '\n', $buffer); + echo "\t=> Added token T_WHITESPACE ($content)".PHP_EOL; + } + } + + $tokens[] = array( + 'code' => T_CLOSE_TAG, + 'type' => 'T_CLOSE_TAG', + 'content' => '', + ); + + /* + Now that we have done some basic tokenizing, we need to + modify the tokens to join some together and split some apart + so they match what the PHP tokenizer does. + */ + + $finalTokens = array(); + $newStackPtr = 0; + $numTokens = count($tokens); + for ($stackPtr = 0; $stackPtr < $numTokens; $stackPtr++) { + $token = $tokens[$stackPtr]; + + /* + Look for comments and join the tokens together. + */ + + if (array_key_exists($token['content'], $this->commentTokens) === true) { + $newContent = ''; + $tokenContent = $token['content']; + $endContent = $this->commentTokens[$tokenContent]; + while ($tokenContent !== $endContent) { + if ($endContent === null + && strpos($tokenContent, $eolChar) !== false + ) { + // A null end token means the comment ends at the end of + // the line so we look for newlines and split the token. + $tokens[$stackPtr]['content'] = substr( + $tokenContent, + (strpos($tokenContent, $eolChar) + strlen($eolChar)) + ); + + $tokenContent = substr( + $tokenContent, + 0, + (strpos($tokenContent, $eolChar) + strlen($eolChar)) + ); + + // If the substr failed, skip the token as the content + // will now be blank. + if ($tokens[$stackPtr]['content'] !== false) { + $stackPtr--; + } + + break; + }//end if + + $stackPtr++; + $newContent .= $tokenContent; + if (isset($tokens[$stackPtr]) === false) { + break; + } + + $tokenContent = $tokens[$stackPtr]['content']; + }//end while + + // Save the new content in the current token so + // the code below can chop it up on newlines. + $token['content'] = $newContent.$tokenContent; + }//end if + + /* + If this token has newlines in its content, split each line up + and create a new token for each line. We do this so it's easier + to ascertain where errors occur on a line. + Note that $token[1] is the token's content. + */ + + if (strpos($token['content'], $eolChar) !== false) { + $tokenLines = explode($eolChar, $token['content']); + $numLines = count($tokenLines); + + for ($i = 0; $i < $numLines; $i++) { + $newToken['content'] = $tokenLines[$i]; + if ($i === ($numLines - 1)) { + if ($tokenLines[$i] === '') { + break; + } + } else { + $newToken['content'] .= $eolChar; + } + + $newToken['type'] = $token['type']; + $newToken['code'] = $token['code']; + $finalTokens[$newStackPtr] = $newToken; + $newStackPtr++; + } + } else { + $finalTokens[$newStackPtr] = $token; + $newStackPtr++; + }//end if + + // Convert numbers, including decimals. + if ($token['code'] === T_STRING + || $token['code'] === T_OBJECT_OPERATOR + ) { + $newContent = ''; + $oldStackPtr = $stackPtr; + while (preg_match('|^[0-9\.]+$|', $tokens[$stackPtr]['content']) !== 0) { + $newContent .= $tokens[$stackPtr]['content']; + $stackPtr++; + } + + if ($newContent !== '' && $newContent !== '.') { + $finalTokens[($newStackPtr - 1)]['content'] = $newContent; + if (ctype_digit($newContent) === true) { + $finalTokens[($newStackPtr - 1)]['code'] + = constant('T_LNUMBER'); + $finalTokens[($newStackPtr - 1)]['type'] = 'T_LNUMBER'; + } else { + $finalTokens[($newStackPtr - 1)]['code'] + = constant('T_DNUMBER'); + $finalTokens[($newStackPtr - 1)]['type'] = 'T_DNUMBER'; + } + + $stackPtr--; + } else { + $stackPtr = $oldStackPtr; + } + }//end if + }//end for + + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo "\t*** END TOKENIZING ***".PHP_EOL; + } + + return $finalTokens; + + }//end tokenizeString() + + + /** + * Tokenizes a regular expression if one is found. + * + * If a regular expression is not found, NULL is returned. + * + * @param string $char The index of the possible regex start character. + * @param string $string The complete content of the string being tokenized. + * @param string $chars An array of characters being tokenized. + * @param string $tokens The current array of tokens found in the string. + * @param string $eolChar The EOL character to use for splitting strings. + * + * @return void + */ + public function getRegexToken($char, $string, $chars, $tokens, $eolChar) + { + $beforeTokens = array( + T_EQUAL, + T_OPEN_PARENTHESIS, + T_RETURN, + T_BOOLEAN_OR, + T_BOOLEAN_AND, + T_BITWISE_OR, + T_BITWISE_AND, + T_COMMA, + T_COLON, + T_TYPEOF, + ); + + $afterTokens = array( + ',', + ')', + ';', + ' ', + '.', + $eolChar, + ); + + // Find the last non-whitespace token that was added + // to the tokens array. + $numTokens = count($tokens); + for ($prev = ($numTokens - 1); $prev >= 0; $prev--) { + if (in_array($tokens[$prev]['code'], PHP_CodeSniffer_Tokens::$emptyTokens) === false) { + break; + } + } + + if (in_array($tokens[$prev]['code'], $beforeTokens) === false) { + return null; + } + + // This is probably a regular expression, so look for the end of it. + if (PHP_CODESNIFFER_VERBOSITY > 1) { + $content = str_replace("\n", '\n', $char); + echo "\t* token possibly starts a regular expression *".PHP_EOL; + } + + $numChars = count($chars); + for ($next = ($char + 1); $next < $numChars; $next++) { + if ($chars[$next] === '/') { + // Just make sure this is not escaped first. + if ($chars[($next - 1)] !== '\\') { + // In the simple form: /.../ so we found the end. + break; + } else if ($chars[($next - 2)] === '\\') { + // In the form: /...\\/ so we found the end. + break; + } + } else { + $possibleEolChar = substr($string, $next, strlen($eolChar)); + if ($possibleEolChar === $eolChar) { + // This is the last token on the line and regular + // expressions need to be defined on a single line, + // so this is not a regular expression. + break; + } + } + } + + if ($chars[$next] !== '/') { + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo "\t* could not find end of regular expression *".PHP_EOL; + } + + return null; + } + + while (preg_match('|[a-zA-Z]|', $chars[($next + 1)]) !== 0) { + // The token directly after the end of the regex can + // be modifiers like global and case insensitive + // (.e.g, /pattern/gi). + $next++; + } + + $regexEnd = $next; + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo "\t* found end of regular expression at token $regexEnd *".PHP_EOL; + } + + for ($next = ($next + 1); $next < $numChars; $next++) { + if ($chars[$next] !== ' ') { + break; + } else { + $possibleEolChar = substr($string, $next, strlen($eolChar)); + if ($possibleEolChar === $eolChar) { + // This is the last token on the line. + break; + } + } + } + + if (in_array($chars[$next], $afterTokens) === false) { + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo "\t* tokens after regular expression do not look correct *".PHP_EOL; + } + + return null; + } + + // This is a regular expression, so join all the tokens together. + $content = ''; + for ($x = $char; $x <= $regexEnd; $x++) { + $content .= $chars[$x]; + } + + $token = array( + 'start' => $char, + 'end' => $regexEnd, + 'content' => $content, + ); + + return $token; + + }//end getRegexToken() + + + /** + * Performs additional processing after main tokenizing. + * + * This additional processing looks for properties, labels and objects. + * + * @param array &$tokens The array of tokens to process. + * @param string $eolChar The EOL character to use for splitting strings. + * + * @return void + */ + public function processAdditional(&$tokens, $eolChar) + { + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo "\t*** START ADDITIONAL JS PROCESSING ***".PHP_EOL; + } + + $numTokens = count($tokens); + $classStack = array(); + + for ($i = 0; $i < $numTokens; $i++) { + if (PHP_CODESNIFFER_VERBOSITY > 1) { + $type = $tokens[$i]['type']; + $content = str_replace($eolChar, '\n', $tokens[$i]['content']); + echo str_repeat("\t", count($classStack)); + + echo "\tProcess token $i: $type => $content".PHP_EOL; + } + + if ($tokens[$i]['code'] === T_OPEN_CURLY_BRACKET + && isset($tokens[$i]['scope_condition']) === false + ) { + $classStack[] = $i; + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo str_repeat("\t", count($classStack)); + echo "\t=> Found property opener".PHP_EOL; + } + + // This could also be an object definition. + for ($x = ($i - 1); $x >= 0; $x--) { + if (in_array($tokens[$x]['code'], PHP_CodeSniffer_Tokens::$emptyTokens) === false) { + // Non-whitespace content. + break; + } + } + + if ($tokens[$x]['code'] === T_EQUAL) { + for ($x--; $x >= 0; $x--) { + if (in_array($tokens[$x]['code'], PHP_CodeSniffer_Tokens::$emptyTokens) === false) { + break; + } + } + + if ($tokens[$x]['code'] === T_STRING + || $tokens[$x]['code'] === T_PROTOTYPE + ) { + // Find the first string in this definition. + // E.g., WantedString.DontWantThis.prototype + for ($x--; $x >= 0; $x--) { + $wantedTokens = array( + T_STRING, + T_PROTOTYPE, + T_OBJECT_OPERATOR, + ); + + if (in_array($tokens[$x]['code'], $wantedTokens) === false) { + $x++; + break; + } + } + + $closer = $tokens[$i]['bracket_closer']; + $tokens[$i]['scope_condition'] = $x; + $tokens[$i]['scope_closer'] = $closer; + $tokens[$closer]['scope_condition'] = $x; + $tokens[$closer]['scope_opener'] = $i; + $tokens[$x]['scope_opener'] = $i; + $tokens[$x]['scope_closer'] = $closer; + $tokens[$x]['code'] = T_OBJECT; + $tokens[$x]['type'] = 'T_OBJECT'; + + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo str_repeat("\t", count($classStack)); + echo "\t* token $x converted from T_STRING to T_OBJECT *".PHP_EOL; + echo str_repeat("\t", count($classStack)); + echo "\t* set scope opener ($i) and closer ($closer) for token $x *".PHP_EOL; + } + }//end if + }//end if + } else if ($tokens[$i]['code'] === T_CLOSE_CURLY_BRACKET + && (isset($tokens[$i]['scope_condition']) === false + || $tokens[$tokens[$i]['scope_condition']]['code'] === T_OBJECT) + ) { + $opener = array_pop($classStack); + + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo str_repeat("\t", count($classStack)); + echo "\t\t=> Found property closer for $opener".PHP_EOL; + } + } else if ($tokens[$i]['code'] === T_COLON) { + // If it is a scope opener, it belongs to a + // DEFAULT or CASE statement. + if (isset($tokens[$i]['scope_condition']) === true) { + continue; + } + + // Make sure this is not part of an inline IF statement. + for ($x = ($i - 1); $x >= 0; $x--) { + if ($tokens[$x]['code'] === T_INLINE_THEN) { + continue(2); + } else if ($tokens[$x]['line'] < $tokens[$i]['line']) { + break; + } + } + + // The string to the left of the colon is either a property or label. + for ($label = ($i - 1); $label >= 0; $label--) { + if (in_array($tokens[$label]['code'], PHP_CodeSniffer_Tokens::$emptyTokens) === false) { + break; + } + } + + if ($tokens[$label]['code'] !== T_STRING) { + continue; + } + + if (empty($classStack) === false) { + $tokens[$label]['code'] = T_PROPERTY; + $tokens[$label]['type'] = 'T_PROPERTY'; + + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo str_repeat("\t", count($classStack)); + echo "\t* token $label converted from T_STRING to T_PROPERTY *".PHP_EOL; + } + + // If the net token after the colon is a curly brace, + // this property is actually an object, so we can give it + // and opener and closer. + for ($x = ($i + 1); $x < $numTokens; $x++) { + if (in_array($tokens[$x]['code'], PHP_CodeSniffer_Tokens::$emptyTokens) === false) { + break; + } + } + + if ($tokens[$x]['code'] === T_OPEN_CURLY_BRACKET) { + $closer = $tokens[$x]['bracket_closer']; + $tokens[$label]['scope_opener'] = $x; + $tokens[$label]['scope_closer'] = $closer; + $tokens[$x]['scope_condition'] = $label; + $tokens[$x]['scope_closer'] = $closer; + $tokens[$closer]['scope_condition'] = $label; + $tokens[$closer]['scope_opener'] = $x; + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo str_repeat("\t", count($classStack)); + echo "\t* set scope opener ($x) and closer ($closer) for token $label *".PHP_EOL; + } + } + } else { + $tokens[$label]['code'] = T_LABEL; + $tokens[$label]['type'] = 'T_LABEL'; + + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo str_repeat("\t", count($classStack)); + echo "\t* token $label converted from T_STRING to T_LABEL *".PHP_EOL; + } + } + }//end if + }//end for + + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo "\t*** END ADDITIONAL JS PROCESSING ***".PHP_EOL; + } + + }//end processAdditional() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Tokenizers/PHP.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Tokenizers/PHP.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Tokenizers/PHP.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Tokenizers/PHP.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,722 @@ + + * @copyright 2006-2012 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 + */ + +/** + * Tokenizes PHP code. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PHP_CodeSniffer_Tokenizers_PHP +{ + + /** + * A list of tokens that are allowed to open a scope. + * + * This array also contains information about what kind of token the scope + * opener uses to open and close the scope, if the token strictly requires + * an opener, if the token can share a scope closer, and who it can be shared + * with. An example of a token that shares a scope closer is a CASE scope. + * + * @var array + */ + public $scopeOpeners = array( + T_IF => array( + 'start' => array( + T_OPEN_CURLY_BRACKET, + T_COLON, + ), + 'end' => array( + T_CLOSE_CURLY_BRACKET, + T_ENDIF, + ), + 'strict' => false, + 'shared' => false, + 'with' => array(), + ), + T_TRY => array( + 'start' => array(T_OPEN_CURLY_BRACKET), + 'end' => array(T_CLOSE_CURLY_BRACKET), + 'strict' => true, + 'shared' => false, + 'with' => array(), + ), + T_CATCH => array( + 'start' => array(T_OPEN_CURLY_BRACKET), + 'end' => array(T_CLOSE_CURLY_BRACKET), + 'strict' => true, + 'shared' => false, + 'with' => array(), + ), + T_FINALLY => array( + 'start' => array(T_OPEN_CURLY_BRACKET), + 'end' => array(T_CLOSE_CURLY_BRACKET), + 'strict' => true, + 'shared' => false, + 'with' => array(), + ), + T_ELSE => array( + 'start' => array(T_OPEN_CURLY_BRACKET), + 'end' => array(T_CLOSE_CURLY_BRACKET), + 'strict' => false, + 'shared' => false, + 'with' => array(), + ), + T_ELSEIF => array( + 'start' => array(T_OPEN_CURLY_BRACKET), + 'end' => array(T_CLOSE_CURLY_BRACKET), + 'strict' => false, + 'shared' => false, + 'with' => array(), + ), + T_FOR => array( + 'start' => array( + T_OPEN_CURLY_BRACKET, + T_COLON, + ), + 'end' => array( + T_CLOSE_CURLY_BRACKET, + T_ENDFOR, + ), + 'strict' => false, + 'shared' => false, + 'with' => array(), + ), + T_FOREACH => array( + 'start' => array( + T_OPEN_CURLY_BRACKET, + T_COLON, + ), + 'end' => array( + T_CLOSE_CURLY_BRACKET, + T_ENDFOREACH, + ), + 'strict' => false, + 'shared' => false, + 'with' => array(), + ), + T_INTERFACE => array( + 'start' => array(T_OPEN_CURLY_BRACKET), + 'end' => array(T_CLOSE_CURLY_BRACKET), + 'strict' => true, + 'shared' => false, + 'with' => array(), + ), + T_FUNCTION => array( + 'start' => array(T_OPEN_CURLY_BRACKET), + 'end' => array(T_CLOSE_CURLY_BRACKET), + 'strict' => true, + 'shared' => false, + 'with' => array(), + ), + T_CLASS => array( + 'start' => array(T_OPEN_CURLY_BRACKET), + 'end' => array(T_CLOSE_CURLY_BRACKET), + 'strict' => true, + 'shared' => false, + 'with' => array(), + ), + T_TRAIT => array( + 'start' => array(T_OPEN_CURLY_BRACKET), + 'end' => array(T_CLOSE_CURLY_BRACKET), + 'strict' => true, + 'shared' => false, + 'with' => array(), + ), + T_NAMESPACE => array( + 'start' => array(T_OPEN_CURLY_BRACKET), + 'end' => array(T_CLOSE_CURLY_BRACKET), + 'strict' => false, + 'shared' => false, + 'with' => array(), + ), + T_WHILE => array( + 'start' => array( + T_OPEN_CURLY_BRACKET, + T_COLON, + ), + 'end' => array( + T_CLOSE_CURLY_BRACKET, + T_ENDWHILE, + ), + 'strict' => false, + 'shared' => false, + 'with' => array(), + ), + T_DO => array( + 'start' => array(T_OPEN_CURLY_BRACKET), + 'end' => array(T_CLOSE_CURLY_BRACKET), + 'strict' => true, + 'shared' => false, + 'with' => array(), + ), + T_SWITCH => array( + 'start' => array(T_OPEN_CURLY_BRACKET), + 'end' => array(T_CLOSE_CURLY_BRACKET), + 'strict' => true, + 'shared' => false, + 'with' => array(), + ), + T_CASE => array( + 'start' => array( + T_COLON, + T_SEMICOLON, + ), + 'end' => array( + T_BREAK, + T_RETURN, + T_CONTINUE, + T_THROW, + ), + 'strict' => true, + 'shared' => true, + 'with' => array( + T_DEFAULT, + T_CASE, + T_SWITCH, + ), + ), + T_DEFAULT => array( + 'start' => array(T_COLON), + 'end' => array( + T_BREAK, + T_RETURN, + T_CONTINUE, + T_THROW, + ), + 'strict' => true, + 'shared' => true, + 'with' => array( + T_CASE, + T_SWITCH, + ), + ), + T_START_HEREDOC => array( + 'start' => array(T_START_HEREDOC), + 'end' => array(T_END_HEREDOC), + 'strict' => true, + 'shared' => false, + 'with' => array(), + ), + ); + + /** + * A list of tokens that end the scope. + * + * This array is just a unique collection of the end tokens + * from the _scopeOpeners array. The data is duplicated here to + * save time during parsing of the file. + * + * @var array + */ + public $endScopeTokens = array( + T_CLOSE_CURLY_BRACKET, + T_BREAK, + T_END_HEREDOC, + ); + + + /** + * Creates an array of tokens when given some PHP code. + * + * Starts by using token_get_all() but does a lot of extra processing + * to insert information about the context of the token. + * + * @param string $string The string to tokenize. + * @param string $eolChar The EOL character to use for splitting strings. + * + * @return array + */ + public function tokenizeString($string, $eolChar='\n') + { + $tokens = @token_get_all($string); + $finalTokens = array(); + + $newStackPtr = 0; + $numTokens = count($tokens); + + $insideInlineIf = false; + + for ($stackPtr = 0; $stackPtr < $numTokens; $stackPtr++) { + $token = $tokens[$stackPtr]; + $tokenIsArray = is_array($token); + + /* + If we are using \r\n newline characters, the \r and \n are sometimes + split over two tokens. This normally occurs after comments. We need + to merge these two characters together so that our line endings are + consistent for all lines. + */ + + if ($tokenIsArray === true && substr($token[1], -1) === "\r") { + if (isset($tokens[($stackPtr + 1)]) === true + && is_array($tokens[($stackPtr + 1)]) === true + && $tokens[($stackPtr + 1)][1][0] === "\n" + ) { + $token[1] .= "\n"; + + if ($tokens[($stackPtr + 1)][1] === "\n") { + // The next token's content has been merged into this token, + // so we can skip it. + $stackPtr++; + } else { + $tokens[($stackPtr + 1)][1] + = substr($tokens[($stackPtr + 1)][1], 1); + } + } + }//end if + + /* + If this is a double quoted string, PHP will tokenise the whole + thing which causes problems with the scope map when braces are + within the string. So we need to merge the tokens together to + provide a single string. + */ + + if ($tokenIsArray === false && $token === '"') { + $tokenContent = '"'; + $nestedVars = array(); + for ($i = ($stackPtr + 1); $i < $numTokens; $i++) { + $subTokenIsArray = is_array($tokens[$i]); + + if ($subTokenIsArray === true) { + $tokenContent .= $tokens[$i][1]; + if ($tokens[$i][1] === '{' + && $tokens[$i][0] !== T_ENCAPSED_AND_WHITESPACE + ) { + $nestedVars[] = $i; + } + } else { + $tokenContent .= $tokens[$i]; + if ($tokens[$i] === '}') { + array_pop($nestedVars); + } + } + + if ($subTokenIsArray === false + && $tokens[$i] === '"' + && empty($nestedVars) === true + ) { + // We found the other end of the double quoted string. + break; + } + } + + $stackPtr = $i; + + // Convert each line within the double quoted string to a + // new token, so it conforms with other multiple line tokens. + $tokenLines = explode($eolChar, $tokenContent); + $numLines = count($tokenLines); + $newToken = array(); + + for ($j = 0; $j < $numLines; $j++) { + $newToken['content'] = $tokenLines[$j]; + if ($j === ($numLines - 1)) { + if ($tokenLines[$j] === '') { + break; + } + } else { + $newToken['content'] .= $eolChar; + } + + $newToken['code'] = T_DOUBLE_QUOTED_STRING; + $newToken['type'] = 'T_DOUBLE_QUOTED_STRING'; + $finalTokens[$newStackPtr] = $newToken; + $newStackPtr++; + } + + // Continue, as we're done with this token. + continue; + }//end if + + /* + If this is a heredoc, PHP will tokenise the whole + thing which causes problems when heredocs don't + contain real PHP code, which is almost never. + We want to leave the start and end heredoc tokens + alone though. + */ + + if ($tokenIsArray === true && $token[0] === T_START_HEREDOC) { + // Add the start heredoc token to the final array. + $finalTokens[$newStackPtr] + = PHP_CodeSniffer::standardiseToken($token); + + // Check if this is actually a nowdoc and use a different token + // to help the sniffs. + $nowdoc = false; + if ($token[1][3] === "'") { + $finalTokens[$newStackPtr]['code'] = T_START_NOWDOC; + $finalTokens[$newStackPtr]['type'] = 'T_START_NOWDOC'; + $nowdoc = true; + } + + $newStackPtr++; + + $tokenContent = ''; + for ($i = ($stackPtr + 1); $i < $numTokens; $i++) { + $subTokenIsArray = is_array($tokens[$i]); + if ($subTokenIsArray === true + && $tokens[$i][0] === T_END_HEREDOC + ) { + // We found the other end of the heredoc. + break; + } + + if ($subTokenIsArray === true) { + $tokenContent .= $tokens[$i][1]; + } else { + $tokenContent .= $tokens[$i]; + } + } + + $stackPtr = $i; + + // Convert each line within the heredoc to a + // new token, so it conforms with other multiple line tokens. + $tokenLines = explode($eolChar, $tokenContent); + $numLines = count($tokenLines); + $newToken = array(); + + for ($j = 0; $j < $numLines; $j++) { + $newToken['content'] = $tokenLines[$j]; + if ($j === ($numLines - 1)) { + if ($tokenLines[$j] === '') { + break; + } + } else { + $newToken['content'] .= $eolChar; + } + + if ($nowdoc === true) { + $newToken['code'] = T_NOWDOC; + $newToken['type'] = 'T_NOWDOC'; + } else { + $newToken['code'] = T_HEREDOC; + $newToken['type'] = 'T_HEREDOC'; + } + + $finalTokens[$newStackPtr] = $newToken; + $newStackPtr++; + } + + // Add the end heredoc token to the final array. + $finalTokens[$newStackPtr] + = PHP_CodeSniffer::standardiseToken($tokens[$stackPtr]); + + if ($nowdoc === true) { + $finalTokens[$newStackPtr]['code'] = T_END_NOWDOC; + $finalTokens[$newStackPtr]['type'] = 'T_END_NOWDOC'; + $nowdoc = true; + } + + $newStackPtr++; + + // Continue, as we're done with this token. + continue; + }//end if + + /* + If this token has newlines in its content, split each line up + and create a new token for each line. We do this so it's easier + to ascertain where errors occur on a line. + Note that $token[1] is the token's content. + */ + + if ($tokenIsArray === true && strpos($token[1], $eolChar) !== false) { + $tokenLines = explode($eolChar, $token[1]); + $numLines = count($tokenLines); + $tokenName = token_name($token[0]); + + for ($i = 0; $i < $numLines; $i++) { + $newToken['content'] = $tokenLines[$i]; + if ($i === ($numLines - 1)) { + if ($tokenLines[$i] === '') { + break; + } + } else { + $newToken['content'] .= $eolChar; + } + + $newToken['type'] = $tokenName; + $newToken['code'] = $token[0]; + $finalTokens[$newStackPtr] = $newToken; + $newStackPtr++; + } + } else { + $newToken = PHP_CodeSniffer::standardiseToken($token); + + // Convert colons that are actually the ELSE component of an + // inline IF statement. + if ($newToken['code'] === T_INLINE_THEN) { + $insideInlineIf = true; + } else if ($insideInlineIf === true && $newToken['code'] === T_COLON) { + $insideInlineIf = false; + $newToken['code'] = T_INLINE_ELSE; + $newToken['type'] = 'T_INLINE_ELSE'; + } + + // This is a special condition for T_ARRAY tokens used for + // type hinting function arguments as being arrays. We want to keep + // the parenthesis map clean, so let's tag these tokens as + // T_ARRAY_HINT. + if ($newToken['code'] === T_ARRAY) { + // Recalculate number of tokens. + $numTokens = count($tokens); + for ($i = $stackPtr; $i < $numTokens; $i++) { + if (is_array($tokens[$i]) === false) { + if ($tokens[$i] === '(') { + break; + } + } else if ($tokens[$i][0] === T_VARIABLE) { + $newToken['code'] = T_ARRAY_HINT; + $newToken['type'] = 'T_ARRAY_HINT'; + break; + } + } + } + + $finalTokens[$newStackPtr] = $newToken; + $newStackPtr++; + }//end if + }//end for + + return $finalTokens; + + }//end tokenizeString() + + + /** + * Performs additional processing after main tokenizing. + * + * This additional processing checks for CASE statements that are using curly + * braces for scope openers and closers. It also turns some T_FUNCTION tokens + * into T_CLOSURE when they are not standard function definitions. It also + * detects short array syntax and converts those square brackets into new tokens. + * It also corrects some usage of the static keyword. + * + * @param array &$tokens The array of tokens to process. + * @param string $eolChar The EOL character to use for splitting strings. + * + * @return void + */ + public function processAdditional(&$tokens, $eolChar) + { + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo "\t*** START ADDITIONAL PHP PROCESSING ***".PHP_EOL; + } + + $numTokens = count($tokens); + for ($i = ($numTokens - 1); $i >= 0; $i--) { + // Looking for functions that are actually closures. + if ($tokens[$i]['code'] === T_FUNCTION && isset($tokens[$i]['scope_opener']) === true) { + for ($x = ($i + 1); $x < $numTokens; $x++) { + if (in_array($tokens[$x]['code'], PHP_CodeSniffer_Tokens::$emptyTokens) === false) { + break; + } + } + + if ($tokens[$x]['code'] === T_OPEN_PARENTHESIS) { + $tokens[$i]['code'] = T_CLOSURE; + $tokens[$i]['type'] = 'T_CLOSURE'; + if (PHP_CODESNIFFER_VERBOSITY > 1) { + $line = $tokens[$i]['line']; + echo "\t* token $i on line $line changed from T_FUNCTION to T_CLOSURE".PHP_EOL; + } + + for ($x = ($tokens[$i]['scope_opener'] + 1); $x < $tokens[$i]['scope_closer']; $x++) { + if (isset($tokens[$x]['conditions'][$i]) === false) { + continue; + } + + $tokens[$x]['conditions'][$i] = T_CLOSURE; + if (PHP_CODESNIFFER_VERBOSITY > 1) { + $type = $tokens[$x]['type']; + echo "\t\t* cleaned $x ($type) *".PHP_EOL; + } + } + } + + continue; + } else if ($tokens[$i]['code'] === T_OPEN_SQUARE_BRACKET) { + // Unless there is a variable or a bracket before this token, + // it is the start of an array being defined using the short syntax. + for ($x = ($i - 1); $x > 0; $x--) { + if (in_array($tokens[$x]['code'], PHP_CodeSniffer_Tokens::$emptyTokens) === false) { + break; + } + } + + $allowed = array( + T_CLOSE_SQUARE_BRACKET, + T_CLOSE_PARENTHESIS, + T_VARIABLE, + T_STRING, + ); + + if (in_array($tokens[$x]['code'], $allowed) === false) { + $tokens[$i]['code'] = T_OPEN_SHORT_ARRAY; + $tokens[$i]['type'] = 'T_OPEN_SHORT_ARRAY'; + + $closer = $tokens[$i]['bracket_closer']; + $tokens[$closer]['code'] = T_CLOSE_SHORT_ARRAY; + $tokens[$closer]['type'] = 'T_CLOSE_SHORT_ARRAY'; + if (PHP_CODESNIFFER_VERBOSITY > 1) { + $line = $tokens[$i]['line']; + echo "\t* token $i on line $line changed from T_OPEN_SQUARE_BRACKET to T_OPEN_SHORT_ARRAY".PHP_EOL; + $line = $tokens[$closer]['line']; + echo "\t* token $closer on line $line changed from T_CLOSE_SQUARE_BRACKET to T_CLOSE_SHORT_ARRAY".PHP_EOL; + } + } + + continue; + } else if ($tokens[$i]['code'] === T_STATIC) { + for ($x = ($i - 1); $x > 0; $x--) { + if (in_array($tokens[$x]['code'], PHP_CodeSniffer_Tokens::$emptyTokens) === false) { + break; + } + } + + if ($tokens[$x]['code'] === T_INSTANCEOF) { + $tokens[$i]['code'] = T_STRING; + $tokens[$i]['type'] = 'T_STRING'; + + if (PHP_CODESNIFFER_VERBOSITY > 1) { + $line = $tokens[$i]['line']; + echo "\t* token $i on line $line changed from T_STATIC to T_STRING".PHP_EOL; + } + } + + continue; + }//end if + + if (($tokens[$i]['code'] !== T_CASE + && $tokens[$i]['code'] !== T_DEFAULT) + || isset($tokens[$i]['scope_opener']) === false + ) { + // Only interested in CASE and DEFAULT statements from here on in. + continue; + } + + $scopeOpener = $tokens[$i]['scope_opener']; + $scopeCloser = $tokens[$i]['scope_closer']; + + // If the first char after the opener is a curly brace + // and that brace has been ignored, it is actually + // opening this case statement and the opener and closer are + // probably set incorrectly. + for ($x = ($scopeOpener + 1); $x < $numTokens; $x++) { + if (in_array($tokens[$x]['code'], PHP_CodeSniffer_Tokens::$emptyTokens) === false) { + // Non-whitespace content. + break; + } + } + + if ($tokens[$x]['code'] === T_CASE) { + // Special case for multiple CASE statements that share the same + // closer. Because we are going backwards through the file, this next + // CASE statement is already fixed, so just use its closer and don't + // worry about fixing anything. + $newCloser = $tokens[$x]['scope_closer']; + $tokens[$i]['scope_closer'] = $newCloser; + if (PHP_CODESNIFFER_VERBOSITY > 1) { + $oldType = $tokens[$scopeCloser]['type']; + $newType = $tokens[$newCloser]['type']; + $line = $tokens[$i]['line']; + echo "\t* token $i (T_CASE) on line $line closer changed from $scopeCloser ($oldType) to $newCloser ($newType)".PHP_EOL; + } + + continue; + } + + if ($tokens[$x]['code'] !== T_OPEN_CURLY_BRACKET + || isset($tokens[$x]['scope_condition']) === true + ) { + // Not a CASE with a curly brace opener. + continue; + } + + // The closer for this CASE/DEFAULT should be the closing curly brace and + // not whatever it already is. The opener needs to be the opening curly + // brace so everything matches up. + $newCloser = $tokens[$x]['bracket_closer']; + $tokens[$i]['scope_closer'] = $newCloser; + $tokens[$x]['scope_closer'] = $newCloser; + $tokens[$i]['scope_opener'] = $x; + $tokens[$x]['scope_condition'] = $i; + $tokens[$newCloser]['scope_condition'] = $i; + $tokens[$newCloser]['scope_opener'] = $x; + if (PHP_CODESNIFFER_VERBOSITY > 1) { + $line = $tokens[$i]['line']; + $tokenType = $tokens[$i]['type']; + + $oldType = $tokens[$scopeOpener]['type']; + $newType = $tokens[$x]['type']; + echo "\t* token $i ($tokenType) on line $line opener changed from $scopeOpener ($oldType) to $x ($newType)".PHP_EOL; + + $oldType = $tokens[$scopeCloser]['type']; + $newType = $tokens[$newCloser]['type']; + echo "\t* token $i ($tokenType) on line $line closer changed from $scopeCloser ($oldType) to $newCloser ($newType)".PHP_EOL; + } + + // Now fix up all the tokens that think they are + // inside the CASE/DEFAULT statement when they are really outside. + for ($x = $newCloser; $x < $scopeCloser; $x++) { + foreach ($tokens[$x]['conditions'] as $num => $oldCond) { + if ($oldCond === $tokens[$i]['code']) { + $oldConditions = $tokens[$x]['conditions']; + unset($tokens[$x]['conditions'][$num]); + + if (PHP_CODESNIFFER_VERBOSITY > 1) { + $type = $tokens[$x]['type']; + $oldConds = ''; + foreach ($oldConditions as $condition) { + $oldConds .= token_name($condition).','; + } + + $oldConds = rtrim($oldConds, ','); + + $newConds = ''; + foreach ($tokens[$x]['conditions'] as $condition) { + $newConds .= token_name($condition).','; + } + + $newConds = rtrim($newConds, ','); + + echo "\t\t* cleaned $x ($type) *".PHP_EOL; + echo "\t\t\t=> conditions changed from $oldConds to $newConds".PHP_EOL; + } + + break; + } + } + } + }//end for + + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo "\t*** END ADDITIONAL PHP PROCESSING ***".PHP_EOL; + } + + }//end processAdditional() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Tokens.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Tokens.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Tokens.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Tokens.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,502 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +define('T_NONE', 0); +define('T_OPEN_CURLY_BRACKET', 1000); +define('T_CLOSE_CURLY_BRACKET', 1001); +define('T_OPEN_SQUARE_BRACKET', 1002); +define('T_CLOSE_SQUARE_BRACKET', 1003); +define('T_OPEN_PARENTHESIS', 1004); +define('T_CLOSE_PARENTHESIS', 1005); +define('T_COLON', 1006); +define('T_STRING_CONCAT', 1007); +define('T_INLINE_THEN', 1008); +define('T_INLINE_ELSE', 1009); +define('T_NULL', 1010); +define('T_FALSE', 1011); +define('T_TRUE', 1012); +define('T_SEMICOLON', 1013); +define('T_EQUAL', 1014); +define('T_MULTIPLY', 1015); +define('T_DIVIDE', 1016); +define('T_PLUS', 1017); +define('T_MINUS', 1018); +define('T_MODULUS', 1019); +define('T_POWER', 1020); +define('T_BITWISE_AND', 1021); +define('T_BITWISE_OR', 1022); +define('T_ARRAY_HINT', 1023); +define('T_GREATER_THAN', 1024); +define('T_LESS_THAN', 1025); +define('T_BOOLEAN_NOT', 1026); +define('T_SELF', 1027); +define('T_PARENT', 1028); +define('T_DOUBLE_QUOTED_STRING', 1029); +define('T_COMMA', 1030); +define('T_HEREDOC', 1031); +define('T_PROTOTYPE', 1032); +define('T_THIS', 1033); +define('T_REGULAR_EXPRESSION', 1034); +define('T_PROPERTY', 1035); +define('T_LABEL', 1036); +define('T_OBJECT', 1037); +define('T_COLOUR', 1038); +define('T_HASH', 1039); +define('T_URL', 1040); +define('T_STYLE', 1041); +define('T_ASPERAND', 1042); +define('T_DOLLAR', 1043); +define('T_TYPEOF', 1044); +define('T_CLOSURE', 1045); +define('T_BACKTICK', 1046); +define('T_START_NOWDOC', 1047); +define('T_NOWDOC', 1048); +define('T_END_NOWDOC', 1049); +define('T_OPEN_SHORT_ARRAY', 1050); +define('T_CLOSE_SHORT_ARRAY', 1051); + +// Some PHP 5.3 tokens, replicated for lower versions. +if (defined('T_NAMESPACE') === false) { + define('T_NAMESPACE', 1052); +} + +if (defined('T_NS_SEPARATOR') === false) { + define('T_NS_SEPARATOR', 1053); +} + +if (defined('T_GOTO') === false) { + define('T_GOTO', 1054); +} + +// Some PHP 5.4 tokens, replicated for lower versions. +if (defined('T_TRAIT') === false) { + define('T_TRAIT', 1055); +} + +if (defined('T_INSTEADOF') === false) { + define('T_INSTEADOF', 1056); +} + +if (defined('T_CALLABLE') === false) { + define('T_CALLABLE', 1057); +} + +// Some PHP 5.5 tokens, replicated for lower versions. +if (defined('T_FINALLY') === false) { + define('T_FINALLY', 1058); +} + +/** + * The Tokens class contains weightings for tokens based on their + * probability of occurrence in a file. + * + * The less the chance of a high occurrence of an arbitrary token, the higher + * the weighting. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +final class PHP_CodeSniffer_Tokens +{ + + /** + * The token weightings. + * + * @var array(int => int) + */ + public static $weightings = array( + T_CLASS => 1000, + T_INTERFACE => 1000, + T_TRAIT => 1000, + T_NAMESPACE => 1000, + T_FUNCTION => 100, + T_CLOSURE => 100, + + /* + Conditions. + */ + + T_WHILE => 50, + T_FOR => 50, + T_FOREACH => 50, + T_IF => 50, + T_ELSE => 50, + T_ELSEIF => 50, + T_WHILE => 50, + T_DO => 50, + T_TRY => 50, + T_CATCH => 50, + T_SWITCH => 50, + + T_SELF => 25, + T_PARENT => 25, + + /* + Operators and arithmetic. + */ + + T_BITWISE_AND => 8, + T_BITWISE_OR => 8, + + T_MULTIPLY => 5, + T_DIVIDE => 5, + T_PLUS => 5, + T_MINUS => 5, + T_MODULUS => 5, + T_POWER => 5, + + T_EQUAL => 5, + T_AND_EQUAL => 5, + T_CONCAT_EQUAL => 5, + T_DIV_EQUAL => 5, + T_MINUS_EQUAL => 5, + T_MOD_EQUAL => 5, + T_MUL_EQUAL => 5, + T_OR_EQUAL => 5, + T_PLUS_EQUAL => 5, + T_XOR_EQUAL => 5, + + T_BOOLEAN_AND => 5, + T_BOOLEAN_OR => 5, + + /* + Equality. + */ + + T_IS_EQUAL => 5, + T_IS_NOT_EQUAL => 5, + T_IS_IDENTICAL => 5, + T_IS_NOT_IDENTICAL => 5, + T_IS_SMALLER_OR_EQUAL => 5, + T_IS_GREATER_OR_EQUAL => 5, + ); + + /** + * Tokens that represent assignments. + * + * @var array(int) + */ + public static $assignmentTokens = array( + T_EQUAL, + T_AND_EQUAL, + T_CONCAT_EQUAL, + T_DIV_EQUAL, + T_MINUS_EQUAL, + T_MOD_EQUAL, + T_MUL_EQUAL, + T_PLUS_EQUAL, + T_XOR_EQUAL, + T_DOUBLE_ARROW, + ); + + /** + * Tokens that represent equality comparisons. + * + * @var array(int) + */ + public static $equalityTokens = array( + T_IS_EQUAL, + T_IS_NOT_EQUAL, + T_IS_IDENTICAL, + T_IS_NOT_IDENTICAL, + T_IS_SMALLER_OR_EQUAL, + T_IS_GREATER_OR_EQUAL, + ); + + /** + * Tokens that represent comparison operator. + * + * @var array(int) + */ + public static $comparisonTokens = array( + T_IS_EQUAL, + T_IS_IDENTICAL, + T_IS_NOT_EQUAL, + T_IS_NOT_IDENTICAL, + T_LESS_THAN, + T_GREATER_THAN, + T_IS_SMALLER_OR_EQUAL, + T_IS_GREATER_OR_EQUAL, + ); + + /** + * Tokens that represent arithmetic operators. + * + * @var array(int) + */ + public static $arithmeticTokens = array( + T_PLUS, + T_MINUS, + T_MULTIPLY, + T_DIVIDE, + T_MODULUS, + ); + + /** + * Tokens that represent casting. + * + * @var array(int) + */ + public static $castTokens = array( + T_INT_CAST, + T_STRING_CAST, + T_DOUBLE_CAST, + T_ARRAY_CAST, + T_BOOL_CAST, + T_OBJECT_CAST, + T_UNSET_CAST, + ); + + /** + * Token types that open parenthesis. + * + * @var array(int) + */ + public static $parenthesisOpeners = array( + T_ARRAY, + T_FUNCTION, + T_CLOSURE, + T_WHILE, + T_FOR, + T_FOREACH, + T_SWITCH, + T_IF, + T_ELSEIF, + T_CATCH, + ); + + /** + * Tokens that are allowed to open scopes. + * + * @var array(int) + */ + public static $scopeOpeners = array( + T_CLASS, + T_INTERFACE, + T_TRAIT, + T_NAMESPACE, + T_FUNCTION, + T_CLOSURE, + T_IF, + T_SWITCH, + T_CASE, + T_DEFAULT, + T_WHILE, + T_ELSE, + T_ELSEIF, + T_FOR, + T_FOREACH, + T_DO, + T_TRY, + T_CATCH, + ); + + /** + * Tokens that represent scope modifiers. + * + * @var array(int) + */ + public static $scopeModifiers = array( + T_PRIVATE, + T_PUBLIC, + T_PROTECTED, + ); + + /** + * Tokens that can prefix a method name + * + * @var array(int) + */ + public static $methodPrefixes = array( + T_PRIVATE, + T_PUBLIC, + T_PROTECTED, + T_ABSTRACT, + T_STATIC, + T_FINAL, + ); + + /** + * Tokens that perform operations. + * + * @var array(int) + */ + public static $operators = array( + T_MINUS, + T_PLUS, + T_MULTIPLY, + T_DIVIDE, + T_MODULUS, + T_POWER, + T_BITWISE_AND, + T_BITWISE_OR, + ); + + /** + * Tokens that perform boolean operations. + * + * @var array(int) + */ + public static $booleanOperators = array( + T_BOOLEAN_AND, + T_BOOLEAN_OR, + T_LOGICAL_AND, + T_LOGICAL_OR, + T_LOGICAL_XOR, + ); + + /** + * Tokens that open code blocks. + * + * @var array(int) + */ + public static $blockOpeners = array( + T_OPEN_CURLY_BRACKET, + T_OPEN_SQUARE_BRACKET, + T_OPEN_PARENTHESIS, + ); + + /** + * Tokens that don't represent code. + * + * @var array(int) + */ + public static $emptyTokens = array( + T_WHITESPACE, + T_COMMENT, + T_DOC_COMMENT, + ); + + /** + * Tokens that are comments. + * + * @var array(int) + */ + public static $commentTokens = array( + T_COMMENT, + T_DOC_COMMENT, + ); + + /** + * Tokens that represent strings. + * + * Note that T_STRINGS are NOT represented in this list. + * + * @var array(int) + */ + public static $stringTokens = array( + T_CONSTANT_ENCAPSED_STRING, + T_DOUBLE_QUOTED_STRING, + ); + + /** + * Tokens that represent brackets and parenthesis. + * + * @var array(int) + */ + public static $bracketTokens = array( + T_OPEN_CURLY_BRACKET, + T_CLOSE_CURLY_BRACKET, + T_OPEN_SQUARE_BRACKET, + T_CLOSE_SQUARE_BRACKET, + T_OPEN_PARENTHESIS, + T_CLOSE_PARENTHESIS, + ); + + /** + * Tokens that include files. + * + * @var array(int) + */ + public static $includeTokens = array( + T_REQUIRE_ONCE, + T_REQUIRE, + T_INCLUDE_ONCE, + T_INCLUDE, + ); + + /** + * Tokens that make up a heredoc string. + * + * @var array(int) + */ + public static $heredocTokens = array( + T_START_HEREDOC, + T_END_HEREDOC, + T_HEREDOC, + ); + + + /** + * A PHP_CodeSniffer_Tokens class cannot be constructed. + * + * Only static calls are allowed. + */ + private function __construct() + { + + }//end __construct() + + + /** + * Returns the highest weighted token type. + * + * Tokens are weighted by their approximate frequency of appearance in code + * - the less frequently they appear in the code, the higher the weighting. + * For example T_CLASS tokens appear very infrequently in a file, and + * therefore have a high weighting. + * + * Returns false if there are no weightings for any of the specified tokens. + * + * @param array(int) $tokens The token types to get the highest weighted + * type for. + * + * @return int The highest weighted token. + */ + public static function getHighestWeightedToken(array $tokens) + { + $highest = -1; + $highestType = false; + + $weights = self::$weightings; + + foreach ($tokens as $token) { + if (isset($weights[$token]) === true) { + $weight = $weights[$token]; + } else { + $weight = 0; + } + + if ($weight > $highest) { + $highest = $weight; + $highestType = $token; + } + } + + return $highestType; + + }//end getHighestWeightedToken() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer.conf.dist php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer.conf.dist --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer.conf.dist 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer.conf.dist 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,9 @@ + 'PSR2', + 'report_format' => 'summary', + 'show_warnings' => '0', + 'show_progress' => '1', + 'report_wdith' => '120', +) +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/CodeSniffer.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer.php 2013-04-03 23:21:41.000000000 +0000 @@ -0,0 +1,2086 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +spl_autoload_register(array('PHP_CodeSniffer', 'autoload')); + +if (class_exists('PHP_CodeSniffer_Exception', true) === false) { + throw new Exception('Class PHP_CodeSniffer_Exception not found'); +} + +if (class_exists('PHP_CodeSniffer_File', true) === false) { + throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_File not found'); +} + +if (class_exists('PHP_CodeSniffer_Tokens', true) === false) { + throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_Tokens not found'); +} + +if (class_exists('PHP_CodeSniffer_CLI', true) === false) { + throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_CLI not found'); +} + +if (interface_exists('PHP_CodeSniffer_Sniff', true) === false) { + throw new PHP_CodeSniffer_Exception('Interface PHP_CodeSniffer_Sniff not found'); +} + +if (interface_exists('PHP_CodeSniffer_MultiFileSniff', true) === false) { + throw new PHP_CodeSniffer_Exception('Interface PHP_CodeSniffer_MultiFileSniff not found'); +} + +/** + * PHP_CodeSniffer tokenises PHP code and detects violations of a + * defined set of coding standards. + * + * Standards are specified by classes that implement the PHP_CodeSniffer_Sniff + * interface. A sniff registers what token types it wishes to listen for, then + * PHP_CodeSniffer encounters that token, the sniff is invoked and passed + * information about where the token was found in the stack, and the token stack + * itself. + * + * Sniff files and their containing class must be prefixed with Sniff, and + * have an extension of .php. + * + * Multiple PHP_CodeSniffer operations can be performed by re-calling the + * process function with different parameters. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: @package_version@ + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PHP_CodeSniffer +{ + + /** + * The file or directory that is currently being processed. + * + * @var string + */ + protected $file = ''; + + /** + * A cache of different token types, resolved into arrays. + * + * @var array() + * @see standardiseToken() + */ + private static $_resolveTokenCache = array(); + + /** + * The directories that the processed rulesets are in. + * + * This is declared static because it is also used in the + * autoloader to look for sniffs outside the PHPCS install. + * This way, standards designed to be installed inside PHPCS can + * also be used from outside the PHPCS Standards directory. + * + * @var string + */ + protected static $rulesetDirs = array(); + + /** + * The CLI object controlling the run. + * + * @var PHP_CodeSniffer_CLI + */ + public $cli = null; + + /** + * The Reporting object controlling report generation. + * + * @var PHP_CodeSniffer_Reporting + */ + public $reporting = null; + + /** + * An array of sniff objects that are being used to check files. + * + * @var array(PHP_CodeSniffer_Sniff) + */ + protected $listeners = array(); + + /** + * An array of sniffs that are being used to check files. + * + * @var array(string) + */ + protected $sniffs = array(); + + /** + * The listeners array, indexed by token type. + * + * @var array + */ + private $_tokenListeners = array(); + + /** + * An array of rules from the ruleset.xml file. + * + * It may be empty, indicating that the ruleset does not override + * any of the default sniff settings. + * + * @var array + */ + protected $ruleset = array(); + + /** + * An array of patterns to use for skipping files. + * + * @var array + */ + protected $ignorePatterns = array(); + + /** + * An array of extensions for files we will check. + * + * @var array + */ + public $allowedFileExtensions = array( + 'php' => 'PHP', + 'inc' => 'PHP', + 'js' => 'JS', + 'css' => 'CSS', + ); + + /** + * An array of variable types for param/var we will check. + * + * @var array(string) + */ + public static $allowedTypes = array( + 'array', + 'boolean', + 'float', + 'integer', + 'mixed', + 'object', + 'string', + ); + + + /** + * Constructs a PHP_CodeSniffer object. + * + * @param int $verbosity The verbosity level. + * 1: Print progress information. + * 2: Print tokenizer debug information. + * 3: Print sniff debug information. + * @param int $tabWidth The number of spaces each tab represents. + * If greater than zero, tabs will be replaced + * by spaces before testing each file. + * @param string $encoding The charset of the sniffed files. + * This is important for some reports that output + * with utf-8 encoding as you don't want it double + * encoding messages. + * @param bool $interactive If TRUE, will stop after each file with errors + * and wait for user input. + * + * @see process() + */ + public function __construct( + $verbosity=0, + $tabWidth=0, + $encoding='iso-8859-1', + $interactive=false + ) { + if (defined('PHP_CODESNIFFER_VERBOSITY') === false) { + define('PHP_CODESNIFFER_VERBOSITY', $verbosity); + } + + if (defined('PHP_CODESNIFFER_TAB_WIDTH') === false) { + define('PHP_CODESNIFFER_TAB_WIDTH', $tabWidth); + } + + if (defined('PHP_CODESNIFFER_ENCODING') === false) { + define('PHP_CODESNIFFER_ENCODING', $encoding); + } + + if (defined('PHP_CODESNIFFER_INTERACTIVE') === false) { + define('PHP_CODESNIFFER_INTERACTIVE', $interactive); + } + + if (defined('PHPCS_DEFAULT_ERROR_SEV') === false) { + define('PHPCS_DEFAULT_ERROR_SEV', 5); + } + + if (defined('PHPCS_DEFAULT_WARN_SEV') === false) { + define('PHPCS_DEFAULT_WARN_SEV', 5); + } + + // Set default CLI object in case someone is running us + // without using the command line script. + $this->cli = new PHP_CodeSniffer_CLI(); + $this->cli->errorSeverity = PHPCS_DEFAULT_ERROR_SEV; + $this->cli->warningSeverity = PHPCS_DEFAULT_WARN_SEV; + $this->cli->dieOnUnknownArg = false; + + $this->reporting = new PHP_CodeSniffer_Reporting(); + + }//end __construct() + + + /** + * Autoload static method for loading classes and interfaces. + * + * @param string $className The name of the class or interface. + * + * @return void + */ + public static function autoload($className) + { + if (substr($className, 0, 4) === 'PHP_') { + $newClassName = substr($className, 4); + } else { + $newClassName = $className; + } + + $path = str_replace(array('_', '\\'), '/', $newClassName).'.php'; + + if (is_file(dirname(__FILE__).'/'.$path) === true) { + // Check standard file locations based on class name. + include dirname(__FILE__).'/'.$path; + } else if (is_file(dirname(__FILE__).'/CodeSniffer/Standards/'.$path) === true) { + // Check for included sniffs. + include dirname(__FILE__).'/CodeSniffer/Standards/'.$path; + } else { + // Check standard file locations based on the loaded rulesets. + foreach (self::$rulesetDirs as $rulesetDir) { + if (is_file(dirname($rulesetDir).'/'.$path) === true) { + include dirname($rulesetDir).'/'.$path; + return; + } + } + + // Everything else. + @include $path; + } + + }//end autoload() + + + /** + * Sets an array of file extensions that we will allow checking of. + * + * If the extension is one of the defaults, a specific tokenizer + * will be used. Otherwise, the PHP tokenizer will be used for + * all extensions passed. + * + * @param array $extensions An array of file extensions. + * + * @return void + */ + public function setAllowedFileExtensions(array $extensions) + { + $newExtensions = array(); + foreach ($extensions as $ext) { + if (isset($this->allowedFileExtensions[$ext]) === true) { + $newExtensions[$ext] = $this->allowedFileExtensions[$ext]; + } else { + $newExtensions[$ext] = 'PHP'; + } + } + + $this->allowedFileExtensions = $newExtensions; + + }//end setAllowedFileExtensions() + + + /** + * Sets an array of ignore patterns that we use to skip files and folders. + * + * Patterns are not case sensitive. + * + * @param array $patterns An array of ignore patterns. The pattern is the key + * and the value is either "absolute" or "relative", + * depending on how the pattern should be applied to a + * file path. + * + * @return void + */ + public function setIgnorePatterns(array $patterns) + { + $this->ignorePatterns = $patterns; + + }//end setIgnorePatterns() + + + /** + * Gets the array of ignore patterns. + * + * Optionally takes a listener to get ignore patterns specified + * for that sniff only. + * + * @param string $listener The listener to get patterns for. If NULL, all + * patterns are returned. + * + * @return array + */ + public function getIgnorePatterns($listener=null) + { + if ($listener === null) { + return $this->ignorePatterns; + } + + if (isset($this->ignorePatterns[$listener]) === true) { + return $this->ignorePatterns[$listener]; + } + + return array(); + + }//end getIgnorePatterns() + + + /** + * Sets the internal CLI object. + * + * @param object $cli The CLI object controlling the run. + * + * @return void + */ + public function setCli($cli) + { + $this->cli = $cli; + + }//end setCli() + + + /** + * Processes the files/directories that PHP_CodeSniffer was constructed with. + * + * @param string|array $files The files and directories to process. For + * directories, each sub directory will also + * be traversed for source files. + * @param string|array $standards The set of code sniffs we are testing + * against. + * @param array $restrictions The sniff names to restrict the allowed + * listeners to. + * @param boolean $local If true, don't recurse into directories. + * + * @return void + * @throws PHP_CodeSniffer_Exception If files or standard are invalid. + */ + public function process($files, $standards, array $restrictions=array(), $local=false) + { + if (is_array($files) === false) { + $files = array($files); + } + + if (is_array($standards) === false) { + $standards = array($standards); + } + + // Reset the members. + $this->listeners = array(); + $this->sniffs = array(); + $this->ruleset = array(); + $this->_tokenListeners = array(); + self::$rulesetDirs = array(); + + // Ensure this option is enabled or else line endings will not always + // be detected properly for files created on a Mac with the /r line ending. + ini_set('auto_detect_line_endings', true); + + $sniffs = array(); + foreach ($standards as $standard) { + $installed = $this->getInstalledStandardPath($standard); + if ($installed !== null) { + $standard = $installed; + } + + if (PHP_CODESNIFFER_VERBOSITY === 1) { + $ruleset = simplexml_load_file($standard); + if ($ruleset !== false) { + $standardName = (string) $ruleset['name']; + } + + echo "Registering sniffs in the $standardName standard... "; + if (count($standards) > 1 || PHP_CODESNIFFER_VERBOSITY > 2) { + echo PHP_EOL; + } + } + + $sniffs = array_merge($sniffs, $this->processRuleset($standard)); + }//end foreach + + $this->registerSniffs($sniffs, $restrictions); + $this->populateTokenListeners(); + + if (PHP_CODESNIFFER_VERBOSITY === 1) { + $numSniffs = count($this->sniffs); + echo "DONE ($numSniffs sniffs registered)".PHP_EOL; + } + + // The SVN pre-commit calls process() to init the sniffs + // and ruleset so there may not be any files to process. + // But this has to come after that initial setup. + if (empty($files) === true) { + return; + } + + $cliValues = $this->cli->getCommandLineValues(); + $showProgress = $cliValues['showProgress']; + + if (PHP_CODESNIFFER_VERBOSITY > 0) { + echo 'Creating file list... '; + } + + $todo = $this->getFilesToProcess($files, $local); + $numFiles = count($todo); + + if (PHP_CODESNIFFER_VERBOSITY > 0) { + echo "DONE ($numFiles files in queue)".PHP_EOL; + } + + $numProcessed = 0; + $dots = 0; + $maxLength = strlen($numFiles); + $lastDir = ''; + foreach ($todo as $file) { + $this->file = $file; + $currDir = dirname($file); + if ($lastDir !== $currDir) { + if (PHP_CODESNIFFER_VERBOSITY > 0) { + echo 'Changing into directory '.$currDir.PHP_EOL; + } + + $lastDir = $currDir; + } + + $phpcsFile = $this->processFile($file); + $numProcessed++; + + if (PHP_CODESNIFFER_VERBOSITY > 0 + || PHP_CODESNIFFER_INTERACTIVE === true + || $showProgress === false + ) { + continue; + } + + // Show progress information. + if ($phpcsFile === null) { + echo 'S'; + } else { + $errors = $phpcsFile->getErrorCount(); + $warnings = $phpcsFile->getWarningCount(); + if ($errors > 0) { + echo 'E'; + } else if ($warnings > 0) { + echo 'W'; + } else { + echo '.'; + } + } + + $dots++; + if ($dots === 60) { + $padding = ($maxLength - strlen($numProcessed)); + echo str_repeat(' ', $padding); + echo " $numProcessed / $numFiles".PHP_EOL; + $dots = 0; + } + }//end foreach + + if (PHP_CODESNIFFER_VERBOSITY === 0 + && PHP_CODESNIFFER_INTERACTIVE === false + && $showProgress === true + ) { + echo PHP_EOL.PHP_EOL; + } + + }//end process() + + + /** + * Processes a single ruleset and returns a list of the sniffs it represents. + * + * Rules founds within the ruleset are processed immediately, but sniff classes + * are not registered by this method. + * + * @param string $rulesetPath The path to a ruleset XML file. + * @param int $depth How many nested processing steps we are in. This + * is only used for debug output. + * + * @return array + * @throws PHP_CodeSniffer_Exception If the ruleset path is invalid. + */ + public function processRuleset($rulesetPath, $depth=0) + { + $rulesetPath = realpath($rulesetPath); + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo str_repeat("\t", $depth); + echo "Processing ruleset $rulesetPath".PHP_EOL; + } + + $ruleset = simplexml_load_file($rulesetPath); + if ($ruleset === false) { + throw new PHP_CodeSniffer_Exception("Ruleset $rulesetPath is not valid"); + } + + $ownSniffs = array(); + $includedSniffs = array(); + $excludedSniffs = array(); + + $rulesetDir = dirname($rulesetPath); + self::$rulesetDirs[] = $rulesetDir; + + if (is_dir($rulesetDir.'/Sniffs') === true) { + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo str_repeat("\t", $depth); + echo "\tAdding sniff files from \".../".basename($rulesetDir)."/Sniffs/\" directory".PHP_EOL; + } + + $ownSniffs = $this->_expandSniffDirectory($rulesetDir.'/Sniffs', $depth); + } + + foreach ($ruleset->rule as $rule) { + if (isset($rule['ref']) === false) { + continue; + } + + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo str_repeat("\t", $depth); + echo "\tProcessing rule \"".$rule['ref'].'"'.PHP_EOL; + } + + $includedSniffs = array_merge( + $includedSniffs, + $this->_expandRulesetReference($rule['ref'], $rulesetDir, $depth) + ); + + if (isset($rule->exclude) === true) { + foreach ($rule->exclude as $exclude) { + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo str_repeat("\t", $depth); + echo "\t\tExcluding rule \"".$exclude['name'].'"'.PHP_EOL; + } + + $excludedSniffs = array_merge( + $excludedSniffs, + $this->_expandRulesetReference($exclude['name'], $rulesetDir, ($depth + 1)) + ); + } + } + + $this->_processRule($rule, $depth); + }//end foreach + + // Process custom ignore pattern rules. + foreach ($ruleset->{'exclude-pattern'} as $pattern) { + if (isset($pattern['type']) === false) { + $pattern['type'] = 'absolute'; + } + + $this->ignorePatterns[(string) $pattern] = (string) $pattern['type']; + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo str_repeat("\t", $depth); + echo "\t=> added global ".(string) $pattern['type'].' ignore pattern: '.(string) $pattern.PHP_EOL; + } + } + + $includedSniffs = array_unique(array_merge($ownSniffs, $includedSniffs)); + $excludedSniffs = array_unique($excludedSniffs); + + if (PHP_CODESNIFFER_VERBOSITY > 1) { + $included = count($includedSniffs); + $excluded = count($excludedSniffs); + echo str_repeat("\t", $depth); + echo "=> Ruleset processing complete; included $included sniffs and excluded $excluded".PHP_EOL; + } + + // Merge our own sniff list with our externally included + // sniff list, but filter out any excluded sniffs. + $files = array(); + foreach ($includedSniffs as $sniff) { + if (in_array($sniff, $excludedSniffs) === true) { + continue; + } else { + $files[] = realpath($sniff); + } + } + + return $files; + + }//end processRuleset() + + + /** + * Expands a directory into a list of sniff files within. + * + * @param string $directory The path to a directory. + * @param int $depth How many nested processing steps we are in. This + * is only used for debug output. + * + * @return array + */ + private function _expandSniffDirectory($directory, $depth=0) + { + $sniffs = array(); + + $di = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)); + foreach ($di as $file) { + $fileName = $file->getFilename(); + + // Skip hidden files. + if (substr($fileName, 0, 1) === '.') { + continue; + } + + // We are only interested in PHP and sniff files. + $fileParts = explode('.', $fileName); + if (array_pop($fileParts) !== 'php') { + continue; + } + + $basename = basename($fileName, '.php'); + if (substr($basename, -5) !== 'Sniff') { + continue; + } + + $path = $file->getPathname(); + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo str_repeat("\t", $depth); + echo "\t\t=> $path".PHP_EOL; + } + + $sniffs[] = $path; + }//end foreach + + return $sniffs; + + }//end _expandSniffDirectory() + + + /** + * Expands a ruleset reference into a list of sniff files. + * + * @param string $ref The reference from the ruleset XML file. + * @param string $rulesetDir The directory of the ruleset XML file, used to + * evaluate relative paths. + * @param int $depth How many nested processing steps we are in. This + * is only used for debug output. + * + * @return array + * @throws PHP_CodeSniffer_Exception If the reference is invalid. + */ + private function _expandRulesetReference($ref, $rulesetDir, $depth=0) + { + // Ignore internal sniffs codes as they are used to only + // hide and change internal messages. + if (substr($ref, 0, 9) === 'Internal.') { + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo str_repeat("\t", $depth); + echo "\t\t* ignoring internal sniff code *".PHP_EOL; + } + + return array(); + } + + // As sniffs can't begin with a full stop, assume references in + // this format are relative paths and attempt to convert them + // to absolute paths. If this fails, let the reference run through + // the normal checks and have it fail as normal. + if (substr($ref, 0, 1) === '.') { + $realpath = realpath($rulesetDir.'/'.$ref); + if ($realpath !== false) { + $ref = $realpath; + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo str_repeat("\t", $depth); + echo "\t\t=> $ref".PHP_EOL; + } + } + } + + if (is_dir($ref) === false && is_file($ref) === false) { + // See if this is a whole standard being referenced. + $path = realpath(dirname(__FILE__).'/CodeSniffer/Standards/'.$ref); + if (is_dir($path) === true) { + $ref = $path; + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo str_repeat("\t", $depth); + echo "\t\t=> $ref".PHP_EOL; + } + } else { + // Work out the sniff path. + $parts = explode('.', $ref); + + if (count($parts) === 1) { + // A whole standard? + $path = ''; + } else if (count($parts) === 2) { + // A directory of sniffs? + $path = '/Sniffs/'.$parts[1]; + } else { + // A single sniff? + $path = '/Sniffs/'.$parts[1].'/'.$parts[2].'Sniff.php'; + } + + $newRef = realpath(dirname(__FILE__).'/CodeSniffer/Standards/'.$parts[0].$path); + if ($newRef === false) { + // The sniff is not locally installed, so check if it is being + // referenced as a remote sniff outside the install. We do this + // by looking through all directories where we have found ruleset + // files before, looking for ones for this particular standard, + // and seeing if it is in there. + foreach (self::$rulesetDirs as $dir) { + if (basename($dir) !== $parts[0]) { + continue; + } + + $newRef = realpath($dir.$path); + + if ($newRef !== false) { + $ref = $newRef; + } + } + } else { + $ref = $newRef; + } + + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo str_repeat("\t", $depth); + echo "\t\t=> $ref".PHP_EOL; + } + } + }//end if + + if (is_dir($ref) === true) { + if (is_file($ref.'/ruleset.xml') === true) { + // We are referencing an external coding standard. + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo str_repeat("\t", $depth); + echo "\t\t* rule is referencing a standard using directory name; processing *".PHP_EOL; + } + + return $this->processRuleset($ref.'/ruleset.xml', ($depth + 2)); + } else { + // We are referencing a whole directory of sniffs. + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo str_repeat("\t", $depth); + echo "\t\t* rule is referencing a directory of sniffs *".PHP_EOL; + echo str_repeat("\t", $depth); + echo "\t\tAdding sniff files from directory".PHP_EOL; + } + + return $this->_expandSniffDirectory($ref, ($depth + 1)); + } + } else { + if (is_file($ref) === false) { + $error = "Referenced sniff \"$ref\" does not exist"; + throw new PHP_CodeSniffer_Exception($error); + } + + if (substr($ref, -9) === 'Sniff.php') { + // A single sniff. + return array($ref); + } else { + // Assume an external ruleset.xml file. + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo str_repeat("\t", $depth); + echo "\t\t* rule is referencing a standard using ruleset path; processing *".PHP_EOL; + } + + return $this->processRuleset($ref, ($depth + 2)); + } + }//end if + + }//end _expandRulesetReference() + + + /** + * Processes a rule from a ruleset XML file, overriding built-in defaults. + * + * @param SimpleXMLElement $rule The rule object from a ruleset XML file. + * @param int $depth How many nested processing steps we are in. + * This is only used for debug output. + * + * @return void + */ + private function _processRule($rule, $depth=0) + { + $code = (string) $rule['ref']; + + // Custom severity. + if (isset($rule->severity) === true) { + if (isset($this->ruleset[$code]) === false) { + $this->ruleset[$code] = array(); + } + + $this->ruleset[$code]['severity'] = (int) $rule->severity; + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo str_repeat("\t", $depth); + echo "\t\t=> severity set to ".(int) $rule->severity.PHP_EOL; + } + } + + // Custom message type. + if (isset($rule->type) === true) { + if (isset($this->ruleset[$code]) === false) { + $this->ruleset[$code] = array(); + } + + $this->ruleset[$code]['type'] = (string) $rule->type; + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo str_repeat("\t", $depth); + echo "\t\t=> message type set to ".(string) $rule->type.PHP_EOL; + } + } + + // Custom message. + if (isset($rule->message) === true) { + if (isset($this->ruleset[$code]) === false) { + $this->ruleset[$code] = array(); + } + + $this->ruleset[$code]['message'] = (string) $rule->message; + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo str_repeat("\t", $depth); + echo "\t\t=> message set to ".(string) $rule->message.PHP_EOL; + } + } + + // Custom properties. + if (isset($rule->properties) === true) { + foreach ($rule->properties->property as $prop) { + if (isset($this->ruleset[$code]) === false) { + $this->ruleset[$code] = array( + 'properties' => array(), + ); + } else if (isset($this->ruleset[$code]['properties']) === false) { + $this->ruleset[$code]['properties'] = array(); + } + + $name = (string) $prop['name']; + if (isset($prop['type']) === true + && (string) $prop['type'] === 'array' + ) { + $value = (string) $prop['value']; + $this->ruleset[$code]['properties'][$name] = explode(',', $value); + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo str_repeat("\t", $depth); + echo "\t\t=> array property \"$name\" set to \"$value\"".PHP_EOL; + } + } else { + $this->ruleset[$code]['properties'][$name] = (string) $prop['value']; + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo str_repeat("\t", $depth); + echo "\t\t=> property \"$name\" set to \"".(string) $prop['value'].'"'.PHP_EOL; + } + } + }//end foreach + }//end if + + // Ignore patterns. + foreach ($rule->{'exclude-pattern'} as $pattern) { + if (isset($this->ignorePatterns[$code]) === false) { + $this->ignorePatterns[$code] = array(); + } + + if (isset($pattern['type']) === false) { + $pattern['type'] = 'absolute'; + } + + $this->ignorePatterns[$code][(string) $pattern] = (string) $pattern['type']; + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo str_repeat("\t", $depth); + echo "\t\t=> added sniff-specific ".(string) $pattern['type'].' ignore pattern: '.(string) $pattern.PHP_EOL; + } + } + + }//end _processRule() + + + /** + * Loads and stores sniffs objects used for sniffing files. + * + * @param array $files Paths to the sniff files to register. + * @param array $restrictions The sniff class names to restrict the allowed + * listeners to. + * + * @return void + */ + public function registerSniffs($files, $restrictions) + { + $listeners = array(); + + foreach ($files as $file) { + // Work out where the position of /StandardName/Sniffs/... is + // so we can determine what the class will be called. + $sniffPos = strrpos($file, DIRECTORY_SEPARATOR.'Sniffs'.DIRECTORY_SEPARATOR); + if ($sniffPos === false) { + continue; + } + + $slashPos = strrpos(substr($file, 0, $sniffPos), DIRECTORY_SEPARATOR); + if ($slashPos === false) { + continue; + } + + $className = substr($file, ($slashPos + 1)); + $className = substr($className, 0, -4); + $className = str_replace(DIRECTORY_SEPARATOR, '_', $className); + + include_once $file; + + // Support the use of PHP namespaces. If the class name we included + // contains namespace separators instead of underscores, use this as the + // class name from now on. + $classNameNS = str_replace('_', '\\', $className); + if (class_exists($classNameNS, false) === true) { + $className = $classNameNS; + } + + // If they have specified a list of sniffs to restrict to, check + // to see if this sniff is allowed. + if (empty($restrictions) === false + && in_array(strtolower($className), $restrictions) === false + ) { + continue; + } + + $listeners[$className] = $className; + + if (PHP_CODESNIFFER_VERBOSITY > 2) { + echo "Registered $className".PHP_EOL; + } + }//end foreach + + $this->sniffs = $listeners; + + }//end registerSniffs() + + + /** + * Populates the array of PHP_CodeSniffer_Sniff's for this file. + * + * @return void + * @throws PHP_CodeSniffer_Exception If sniff registration fails. + */ + public function populateTokenListeners() + { + // Construct a list of listeners indexed by token being listened for. + $this->_tokenListeners = array(); + + foreach ($this->sniffs as $listenerClass) { + // Work out the internal code for this sniff. Detect usage of namespace + // separators instead of underscores to support PHP namespaces. + if (strstr($listenerClass, '\\') === false) { + $parts = explode('_', $listenerClass); + } else { + $parts = explode('\\', $listenerClass); + } + + $code = $parts[0].'.'.$parts[2].'.'.$parts[3]; + $code = substr($code, 0, -5); + + $this->listeners[$listenerClass] = new $listenerClass(); + + // Set custom properties. + if (isset($this->ruleset[$code]['properties']) === true) { + foreach ($this->ruleset[$code]['properties'] as $name => $value) { + $this->setSniffProperty($listenerClass, $name, $value); + } + } + + $tokenizers = array('PHP'); + $vars = get_class_vars($listenerClass); + if (isset($vars['supportedTokenizers']) === true) { + $tokenizers = $vars['supportedTokenizers']; + } + + $tokens = $this->listeners[$listenerClass]->register(); + if (is_array($tokens) === false) { + $msg = "Sniff $listenerClass register() method must return an array"; + throw new PHP_CodeSniffer_Exception($msg); + } + + foreach ($tokens as $token) { + if (isset($this->_tokenListeners[$token]) === false) { + $this->_tokenListeners[$token] = array(); + } + + if (in_array($this->listeners[$listenerClass], $this->_tokenListeners[$token], true) === false) { + $this->_tokenListeners[$token][] = array( + 'listener' => $this->listeners[$listenerClass], + 'class' => $listenerClass, + 'tokenizers' => $tokenizers, + ); + } + } + }//end foreach + + }//end populateTokenListeners() + + + /** + * Set a single property for a sniff. + * + * @param string $listenerClass The class name of the sniff. + * @param string $name The name of the property to change. + * @param string $value The new value of the property. + * + * @return void + */ + public function setSniffProperty($listenerClass, $name, $value) + { + // Setting a property for a sniff we are not using. + if (isset($this->listeners[$listenerClass]) === false) { + return; + } + + $name = trim($name); + if (is_string($value) === true) { + $value = trim($value); + } + + // Special case for booleans. + if ($value === 'true') { + $value = true; + } else if ($value === 'false') { + $value = false; + } + + $this->listeners[$listenerClass]->$name = $value; + + }//end setSniffProperty() + + + /** + * Get a list of files that will be processed. + * + * If passed directories, this method will find all files within them. + * The method will also perform file extension and ignore pattern filtering. + * + * @param string $paths A list of file or directory paths to process. + * @param boolean $local If true, only process 1 level of files in directories + * + * @return array + * @throws Exception If there was an error opening a directory. + * @see shouldProcessFile() + */ + public function getFilesToProcess($paths, $local=false) + { + $files = array(); + + foreach ($paths as $path) { + if (is_dir($path) === true) { + if ($local === true) { + $di = new DirectoryIterator($path); + } else { + $di = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)); + } + + foreach ($di as $file) { + // Check if the file exists after all symlinks are resolved. + $filePath = realpath($file->getPathname()); + if ($filePath === false) { + continue; + } + + if (is_dir($filePath) === true) { + continue; + } + + if ($this->shouldProcessFile($file->getPathname(), $path) === false) { + continue; + } + + $files[] = $file->getPathname(); + }//end foreach + } else { + if ($this->shouldIgnoreFile($path, dirname($path)) === true) { + continue; + } + + $files[] = $path; + }//end if + }//end foreach + + return $files; + + }//end getFilesToProcess() + + + /** + * Checks filtering rules to see if a file should be checked. + * + * Checks both file extension filters and path ignore filters. + * + * @param string $path The path to the file being checked. + * @param string $basedir The directory to use for relative path checks. + * + * @return bool + */ + public function shouldProcessFile($path, $basedir) + { + // Check that the file's extension is one we are checking. + // We are strict about checking the extension and we don't + // let files through with no extension or that start with a dot. + $fileName = basename($path); + $fileParts = explode('.', $fileName); + if ($fileParts[0] === $fileName || $fileParts[0] === '') { + return false; + } + + // Checking multi-part file extensions, so need to create a + // complete extension list and make sure one is allowed. + $extensions = array(); + array_shift($fileParts); + foreach ($fileParts as $part) { + $extensions[implode('.', $fileParts)] = 1; + array_shift($fileParts); + } + + $matches = array_intersect_key($extensions, $this->allowedFileExtensions); + if (empty($matches) === true) { + return false; + } + + // If the file's path matches one of our ignore patterns, skip it. + if ($this->shouldIgnoreFile($path, $basedir) === true) { + return false; + } + + return true; + + }//end shouldProcessFile() + + + /** + * Checks filtering rules to see if a file should be ignored. + * + * @param string $path The path to the file being checked. + * @param string $basedir The directory to use for relative path checks. + * + * @return bool + */ + public function shouldIgnoreFile($path, $basedir) + { + $relativePath = $path; + if (strpos($path, $basedir) === 0) { + // The +1 cuts off the directory separator as well. + $relativePath = substr($path, (strlen($basedir) + 1)); + } + + foreach ($this->ignorePatterns as $pattern => $type) { + if (is_array($pattern) === true) { + // A sniff specific ignore pattern. + continue; + } + + // Maintains backwards compatibility in case the ignore pattern does + // not have a relative/absolute value. + if (is_int($pattern) === true) { + $pattern = $type; + $type = 'absolute'; + } + + $replacements = array( + '\\,' => ',', + '*' => '.*', + ); + + // We assume a / directory separator, as do the exclude rules + // most developers write, so we need a special case for any system + // that is different. + if (DIRECTORY_SEPARATOR === '\\') { + $replacements['/'] = '\\\\'; + } + + $pattern = strtr($pattern, $replacements); + + if ($type === 'relative') { + $testPath = $relativePath; + } else { + $testPath = $path; + } + + if (preg_match("|{$pattern}|i", $testPath) === 1) { + return true; + } + }//end foreach + + return false; + + }//end shouldIgnoreFile() + + + /** + * Run the code sniffs over a single given file. + * + * Processes the file and runs the PHP_CodeSniffer sniffs to verify that it + * conforms with the standard. Returns the processed file object, or NULL + * if no file was processed due to error. + * + * @param string $file The file to process. + * @param string $contents The contents to parse. If NULL, the content + * is taken from the file system. + * + * @return PHP_CodeSniffer_File + * @throws PHP_CodeSniffer_Exception If the file could not be processed. + * @see _processFile() + */ + public function processFile($file, $contents=null) + { + if ($contents === null && file_exists($file) === false) { + throw new PHP_CodeSniffer_Exception("Source file $file does not exist"); + } + + $filePath = realpath($file); + if ($filePath === false) { + $filePath = $file; + } + + // Before we go and spend time tokenizing this file, just check + // to see if there is a tag up top to indicate that the whole + // file should be ignored. It must be on one of the first two lines. + $firstContent = $contents; + if ($contents === null && is_readable($filePath) === true) { + $handle = fopen($filePath, 'r'); + if ($handle !== false) { + $firstContent = fgets($handle); + $firstContent .= fgets($handle); + fclose($handle); + } + } + + if (strpos($firstContent, '@codingStandardsIgnoreFile') !== false) { + // We are ignoring the whole file. + if (PHP_CODESNIFFER_VERBOSITY > 0) { + echo 'Ignoring '.basename($filePath).PHP_EOL; + } + + return null; + } + + try { + $phpcsFile = $this->_processFile($file, $contents); + } catch (Exception $e) { + $trace = $e->getTrace(); + + $filename = $trace[0]['args'][0]; + if (is_object($filename) === true + && get_class($filename) === 'PHP_CodeSniffer_File' + ) { + $filename = $filename->getFilename(); + } else if (is_numeric($filename) === true) { + // See if we can find the PHP_CodeSniffer_File object. + foreach ($trace as $data) { + if (isset($data['args'][0]) === true + && ($data['args'][0] instanceof PHP_CodeSniffer_File) === true + ) { + $filename = $data['args'][0]->getFilename(); + } + } + } else if (is_string($filename) === false) { + $filename = (string) $filename; + } + + $error = 'An error occurred during processing; checking has been aborted. The error message was: '.$e->getMessage(); + + $phpcsFile = new PHP_CodeSniffer_File( + $filename, + $this->_tokenListeners, + $this->allowedFileExtensions, + $this->ruleset, + $this + ); + + $phpcsFile->addError($error, null); + }//end try + + $cliValues = $this->cli->getCommandLineValues(); + + if (PHP_CODESNIFFER_INTERACTIVE === false) { + // Cache the report data for this file so we can unset it to save memory. + $this->reporting->cacheFileReport($phpcsFile, $cliValues); + return $phpcsFile; + } + + /* + Running interactively. + Print the error report for the current file and then wait for user input. + */ + + // Get current violations and then clear the list to make sure + // we only print violations for a single file each time. + $numErrors = null; + while ($numErrors !== 0) { + $numErrors = ($phpcsFile->getErrorCount() + $phpcsFile->getWarningCount()); + if ($numErrors === 0) { + continue; + } + + $reportClass = $this->reporting->factory('full'); + $reportData = $this->reporting->prepareFileReport($phpcsFile); + $reportClass->generateFileReport($reportData, $cliValues['showSources'], $cliValues['reportWidth']); + + echo ' to recheck, [s] to skip or [q] to quit : '; + $input = fgets(STDIN); + $input = trim($input); + + switch ($input) { + case 's': + break(2); + case 'q': + exit(0); + break; + default: + // Repopulate the sniffs because some of them save their state + // and only clear it when the file changes, but we are rechecking + // the same file. + $this->populateTokenListeners(); + $phpcsFile = $this->_processFile($file, $contents); + break; + } + }//end while + + return $phpcsFile; + + }//end processFile() + + + /** + * Process the sniffs for a single file. + * + * Does raw processing only. No interactive support or error checking. + * + * @param string $file The file to process. + * @param string $contents The contents to parse. If NULL, the content + * is taken from the file system. + * + * @return PHP_CodeSniffer_File + * @see processFile() + */ + private function _processFile($file, $contents) + { + if (PHP_CODESNIFFER_VERBOSITY > 0) { + $startTime = time(); + echo 'Processing '.basename($file).' '; + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo PHP_EOL; + } + } + + $phpcsFile = new PHP_CodeSniffer_File( + $file, + $this->_tokenListeners, + $this->allowedFileExtensions, + $this->ruleset, + $this + ); + + $phpcsFile->start($contents); + $phpcsFile->cleanUp(); + + if (PHP_CODESNIFFER_VERBOSITY > 0) { + $timeTaken = (time() - $startTime); + if ($timeTaken === 0) { + echo 'DONE in < 1 second'; + } else if ($timeTaken === 1) { + echo 'DONE in 1 second'; + } else { + echo "DONE in $timeTaken seconds"; + } + + $errors = $phpcsFile->getErrorCount(); + $warnings = $phpcsFile->getWarningCount(); + echo " ($errors errors, $warnings warnings)".PHP_EOL; + } + + return $phpcsFile; + + }//end _processFile() + + + /** + * Generates documentation for a coding standard. + * + * @param string $standard The standard to generate docs for + * @param array $sniffs A list of sniffs to limit the docs to. + * @param string $generator The name of the generator class to use. + * + * @return void + */ + public function generateDocs($standard, array $sniffs=array(), $generator='Text') + { + if (class_exists('PHP_CodeSniffer_DocGenerators_'.$generator, true) === false) { + throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_DocGenerators_'.$generator.' not found'); + } + + $class = "PHP_CodeSniffer_DocGenerators_$generator"; + $generator = new $class($standard, $sniffs); + + $generator->generate(); + + }//end generateDocs() + + + /** + * Gets the array of PHP_CodeSniffer_Sniff's. + * + * @return array(PHP_CodeSniffer_Sniff) + */ + public function getSniffs() + { + return $this->listeners; + + }//end getSniffs() + + + /** + * Gets the array of PHP_CodeSniffer_Sniff's indexed by token type. + * + * @return array() + */ + public function getTokenSniffs() + { + return $this->_tokenListeners; + + }//end getTokenSniffs() + + + /** + * Takes a token produced from token_get_all() and produces a + * more uniform token. + * + * Note that this method also resolves T_STRING tokens into more discrete + * types, therefore there is no need to call resolveTstringToken() + * + * @param string|array $token The token to convert. + * + * @return array The new token. + */ + public static function standardiseToken($token) + { + if (is_array($token) === false) { + if (isset(self::$_resolveTokenCache[$token]) === true) { + $newToken = self::$_resolveTokenCache[$token]; + } else { + $newToken = self::resolveSimpleToken($token); + } + } else { + switch ($token[0]) { + case T_STRING: + // Some T_STRING tokens can be more specific. + $tokenType = strtolower($token[1]); + if (isset(self::$_resolveTokenCache[$tokenType]) === true) { + $newToken = self::$_resolveTokenCache[$tokenType]; + } else { + $newToken = self::resolveTstringToken($tokenType); + } + + break; + case T_CURLY_OPEN: + $newToken = array( + 'code' => T_OPEN_CURLY_BRACKET, + 'type' => 'T_OPEN_CURLY_BRACKET', + ); + break; + default: + $newToken = array( + 'code' => $token[0], + 'type' => token_name($token[0]), + ); + break; + }//end switch + + $newToken['content'] = $token[1]; + }//end if + + return $newToken; + + }//end standardiseToken() + + + /** + * Converts T_STRING tokens into more usable token names. + * + * The token should be produced using the token_get_all() function. + * Currently, not all T_STRING tokens are converted. + * + * @param string $token The T_STRING token to convert as constructed + * by token_get_all(). + * + * @return array The new token. + */ + public static function resolveTstringToken($token) + { + $newToken = array(); + switch ($token) { + case 'false': + $newToken['type'] = 'T_FALSE'; + break; + case 'true': + $newToken['type'] = 'T_TRUE'; + break; + case 'null': + $newToken['type'] = 'T_NULL'; + break; + case 'self': + $newToken['type'] = 'T_SELF'; + break; + case 'parent': + $newToken['type'] = 'T_PARENT'; + break; + default: + $newToken['type'] = 'T_STRING'; + break; + } + + $newToken['code'] = constant($newToken['type']); + + self::$_resolveTokenCache[$token] = $newToken; + return $newToken; + + }//end resolveTstringToken() + + + /** + * Converts simple tokens into a format that conforms to complex tokens + * produced by token_get_all(). + * + * Simple tokens are tokens that are not in array form when produced from + * token_get_all(). + * + * @param string $token The simple token to convert. + * + * @return array The new token in array format. + */ + public static function resolveSimpleToken($token) + { + $newToken = array(); + + switch ($token) { + case '{': + $newToken['type'] = 'T_OPEN_CURLY_BRACKET'; + break; + case '}': + $newToken['type'] = 'T_CLOSE_CURLY_BRACKET'; + break; + case '[': + $newToken['type'] = 'T_OPEN_SQUARE_BRACKET'; + break; + case ']': + $newToken['type'] = 'T_CLOSE_SQUARE_BRACKET'; + break; + case '(': + $newToken['type'] = 'T_OPEN_PARENTHESIS'; + break; + case ')': + $newToken['type'] = 'T_CLOSE_PARENTHESIS'; + break; + case ':': + $newToken['type'] = 'T_COLON'; + break; + case '.': + $newToken['type'] = 'T_STRING_CONCAT'; + break; + case '?': + $newToken['type'] = 'T_INLINE_THEN'; + break; + case ';': + $newToken['type'] = 'T_SEMICOLON'; + break; + case '=': + $newToken['type'] = 'T_EQUAL'; + break; + case '*': + $newToken['type'] = 'T_MULTIPLY'; + break; + case '/': + $newToken['type'] = 'T_DIVIDE'; + break; + case '+': + $newToken['type'] = 'T_PLUS'; + break; + case '-': + $newToken['type'] = 'T_MINUS'; + break; + case '%': + $newToken['type'] = 'T_MODULUS'; + break; + case '^': + $newToken['type'] = 'T_POWER'; + break; + case '&': + $newToken['type'] = 'T_BITWISE_AND'; + break; + case '|': + $newToken['type'] = 'T_BITWISE_OR'; + break; + case '<': + $newToken['type'] = 'T_LESS_THAN'; + break; + case '>': + $newToken['type'] = 'T_GREATER_THAN'; + break; + case '!': + $newToken['type'] = 'T_BOOLEAN_NOT'; + break; + case ',': + $newToken['type'] = 'T_COMMA'; + break; + case '@': + $newToken['type'] = 'T_ASPERAND'; + break; + case '$': + $newToken['type'] = 'T_DOLLAR'; + break; + case '`': + $newToken['type'] = 'T_BACKTICK'; + break; + default: + $newToken['type'] = 'T_NONE'; + break; + }//end switch + + $newToken['code'] = constant($newToken['type']); + $newToken['content'] = $token; + + self::$_resolveTokenCache[$token] = $newToken; + return $newToken; + + }//end resolveSimpleToken() + + + /** + * Returns true if the specified string is in the camel caps format. + * + * @param string $string The string the verify. + * @param boolean $classFormat If true, check to see if the string is in the + * class format. Class format strings must start + * with a capital letter and contain no + * underscores. + * @param boolean $public If true, the first character in the string + * must be an a-z character. If false, the + * character must be an underscore. This + * argument is only applicable if $classFormat + * is false. + * @param boolean $strict If true, the string must not have two capital + * letters next to each other. If false, a + * relaxed camel caps policy is used to allow + * for acronyms. + * + * @return boolean + */ + public static function isCamelCaps( + $string, + $classFormat=false, + $public=true, + $strict=true + ) { + // Check the first character first. + if ($classFormat === false) { + if ($public === false) { + $legalFirstChar = '[_][a-z]'; + } else { + $legalFirstChar = '[a-z]'; + } + } else { + $legalFirstChar = '[A-Z]'; + } + + if (preg_match("|^$legalFirstChar|", $string) === 0) { + return false; + } + + // Check that the name only contains legal characters. + $legalChars = 'a-zA-Z0-9'; + if (preg_match("|[^$legalChars]|", substr($string, 1)) > 0) { + return false; + } + + if ($strict === true) { + // Check that there are not two capital letters next to each other. + $length = strlen($string); + $lastCharWasCaps = $classFormat; + + for ($i = 1; $i < $length; $i++) { + $ascii = ord($string{$i}); + if ($ascii >= 48 && $ascii <= 57) { + // The character is a number, so it cant be a capital. + $isCaps = false; + } else { + if (strtoupper($string{$i}) === $string{$i}) { + $isCaps = true; + } else { + $isCaps = false; + } + } + + if ($isCaps === true && $lastCharWasCaps === true) { + return false; + } + + $lastCharWasCaps = $isCaps; + } + }//end if + + return true; + + }//end isCamelCaps() + + + /** + * Returns true if the specified string is in the underscore caps format. + * + * @param string $string The string to verify. + * + * @return boolean + */ + public static function isUnderscoreName($string) + { + // If there are space in the name, it can't be valid. + if (strpos($string, ' ') !== false) { + return false; + } + + $validName = true; + $nameBits = explode('_', $string); + + if (preg_match('|^[A-Z]|', $string) === 0) { + // Name does not begin with a capital letter. + $validName = false; + } else { + foreach ($nameBits as $bit) { + if ($bit === '') { + continue; + } + + if ($bit{0} !== strtoupper($bit{0})) { + $validName = false; + break; + } + } + } + + return $validName; + + }//end isUnderscoreName() + + + /** + * Returns a valid variable type for param/var tag. + * + * If type is not one of the standard type, it must be a custom type. + * Returns the correct type name suggestion if type name is invalid. + * + * @param string $varType The variable type to process. + * + * @return string + */ + public static function suggestType($varType) + { + if ($varType === '') { + return ''; + } + + if (in_array($varType, self::$allowedTypes) === true) { + return $varType; + } else { + $lowerVarType = strtolower($varType); + switch ($lowerVarType) { + case 'bool': + return 'boolean'; + case 'double': + case 'real': + return 'float'; + case 'int': + return 'integer'; + case 'array()': + return 'array'; + }//end switch + + if (strpos($lowerVarType, 'array(') !== false) { + // Valid array declaration: + // array, array(type), array(type1 => type2). + $matches = array(); + $pattern = '/^array\(\s*([^\s^=^>]*)(\s*=>\s*(.*))?\s*\)/i'; + if (preg_match($pattern, $varType, $matches) !== 0) { + $type1 = ''; + if (isset($matches[1]) === true) { + $type1 = $matches[1]; + } + + $type2 = ''; + if (isset($matches[3]) === true) { + $type2 = $matches[3]; + } + + $type1 = self::suggestType($type1); + $type2 = self::suggestType($type2); + if ($type2 !== '') { + $type2 = ' => '.$type2; + } + + return "array($type1$type2)"; + } else { + return 'array'; + }//end if + } else if (in_array($lowerVarType, self::$allowedTypes) === true) { + // A valid type, but not lower cased. + return $lowerVarType; + } else { + // Must be a custom type name. + return $varType; + }//end if + }//end if + + }//end suggestType() + + + /** + * Get a list of all coding standards installed. + * + * Coding standards are directories located in the + * CodeSniffer/Standards directory. Valid coding standards + * include a Sniffs subdirectory. + * + * @param boolean $includeGeneric If true, the special "Generic" + * coding standard will be included + * if installed. + * @param string $standardsDir A specific directory to look for standards + * in. If not specified, PHP_CodeSniffer will + * look in its default location. + * + * @return array + * @see isInstalledStandard() + */ + public static function getInstalledStandards( + $includeGeneric=false, + $standardsDir='' + ) { + $installedStandards = array(); + + if ($standardsDir === '') { + $standardsDir = dirname(__FILE__).'/CodeSniffer/Standards'; + } + + $di = new DirectoryIterator($standardsDir); + foreach ($di as $file) { + if ($file->isDir() === true && $file->isDot() === false) { + $filename = $file->getFilename(); + + // Ignore the special "Generic" standard. + if ($includeGeneric === false && $filename === 'Generic') { + continue; + } + + // Valid coding standard dirs include a standard class. + $csFile = $file->getPathname().'/ruleset.xml'; + if (is_file($csFile) === true) { + // We found a coding standard directory. + $installedStandards[] = $filename; + } + } + } + + return $installedStandards; + + }//end getInstalledStandards() + + + /** + * Determine if a standard is installed. + * + * Coding standards are directories located in the + * CodeSniffer/Standards directory. Valid coding standards + * include a Sniffs subdirectory. + * + * @param string $standard The name of the coding standard. + * + * @return boolean + * @see getInstalledStandards() + */ + public static function isInstalledStandard($standard) + { + $path = self::getInstalledStandardPath($standard); + if ($path !== null) { + return true; + } else { + // This could be a custom standard, installed outside our + // standards directory. + $ruleset = rtrim($standard, ' /\\').DIRECTORY_SEPARATOR.'ruleset.xml'; + if (is_file($ruleset) === true) { + return true; + } + + // Might also be an actual ruleset file itself. + // If it has an XML extension, let's at least try it. + if (is_file($standard) === true + && substr(strtolower($standard), -4) === '.xml' + ) { + return true; + } + } + + return false; + + }//end isInstalledStandard() + + + /** + * Return the path of an installed coding standard. + * + * Coding standards are directories located in the + * CodeSniffer/Standards directory. Valid coding standards + * include a Sniffs subdirectory. + * + * @param string $standard The name of the coding standard. + * + * @return string|null + */ + public static function getInstalledStandardPath($standard) + { + $path = realpath(dirname(__FILE__).'/CodeSniffer/Standards/'.$standard.'/ruleset.xml'); + if (is_file($path) === true) { + return $path; + } + + return null; + + }//end getInstalledStandardPath() + + + /** + * Get a single config value. + * + * Config data is stored in the data dir, in a file called + * CodeSniffer.conf. It is a simple PHP array. + * + * @param string $key The name of the config value. + * + * @return string + * @see setConfigData() + * @see getAllConfigData() + */ + public static function getConfigData($key) + { + $phpCodeSnifferConfig = self::getAllConfigData(); + + if ($phpCodeSnifferConfig === null) { + return null; + } + + if (isset($phpCodeSnifferConfig[$key]) === false) { + return null; + } + + return $phpCodeSnifferConfig[$key]; + + }//end getConfigData() + + + /** + * Set a single config value. + * + * Config data is stored in the data dir, in a file called + * CodeSniffer.conf. It is a simple PHP array. + * + * @param string $key The name of the config value. + * @param string|null $value The value to set. If null, the config + * entry is deleted, reverting it to the + * default value. + * @param boolean $temp Set this config data temporarily for this + * script run. This will not write the config + * data to the config file. + * + * @return boolean + * @see getConfigData() + * @throws PHP_CodeSniffer_Exception If the config file can not be written. + */ + public static function setConfigData($key, $value, $temp=false) + { + if ($temp === false) { + $configFile = dirname(__FILE__).'/CodeSniffer.conf'; + if (is_file($configFile) === false + && strpos('@data_dir@', '@data_dir') === false + ) { + // If data_dir was replaced, this is a PEAR install and we can + // use the PEAR data dir to store the conf file. + $configFile = '@data_dir@/PHP_CodeSniffer/CodeSniffer.conf'; + } + + if (is_file($configFile) === true + && is_writable($configFile) === false + ) { + $error = "Config file $configFile is not writable"; + throw new PHP_CodeSniffer_Exception($error); + } + } + + $phpCodeSnifferConfig = self::getAllConfigData(); + + if ($value === null) { + if (isset($phpCodeSnifferConfig[$key]) === true) { + unset($phpCodeSnifferConfig[$key]); + } + } else { + $phpCodeSnifferConfig[$key] = $value; + } + + if ($temp === false) { + $output = '<'.'?php'."\n".' $phpCodeSnifferConfig = '; + $output .= var_export($phpCodeSnifferConfig, true); + $output .= "\n?".'>'; + + if (file_put_contents($configFile, $output) === false) { + return false; + } + } + + $GLOBALS['PHP_CODESNIFFER_CONFIG_DATA'] = $phpCodeSnifferConfig; + + return true; + + }//end setConfigData() + + + /** + * Get all config data in an array. + * + * @return string + * @see getConfigData() + */ + public static function getAllConfigData() + { + if (isset($GLOBALS['PHP_CODESNIFFER_CONFIG_DATA']) === true) { + return $GLOBALS['PHP_CODESNIFFER_CONFIG_DATA']; + } + + $configFile = dirname(__FILE__).'/CodeSniffer.conf'; + if (is_file($configFile) === false) { + $configFile = '@data_dir@/PHP_CodeSniffer/CodeSniffer.conf'; + } + + if (is_file($configFile) === false) { + return null; + } + + include $configFile; + $GLOBALS['PHP_CODESNIFFER_CONFIG_DATA'] = $phpCodeSnifferConfig; + return $GLOBALS['PHP_CODESNIFFER_CONFIG_DATA']; + + }//end getAllConfigData() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/scripts/phpcs php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/scripts/phpcs --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/scripts/phpcs 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/scripts/phpcs 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,44 @@ +#!/usr/bin/env php + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +error_reporting(E_ALL | E_STRICT); + +// Optionally use PHP_Timer to print time/memory stats for the run. +// Note that the reports are the ones who actually print the data +// as they decide if it is ok to print this data to screen. +@include_once 'PHP/Timer.php'; +if (class_exists('PHP_Timer', false) === true) { + PHP_Timer::start(); +} + +if (is_file(dirname(__FILE__).'/../CodeSniffer/CLI.php') === true) { + include_once dirname(__FILE__).'/../CodeSniffer/CLI.php'; +} else { + include_once 'PHP/CodeSniffer/CLI.php'; +} + +$phpcs = new PHP_CodeSniffer_CLI(); +$phpcs->checkRequirements(); + +$numErrors = $phpcs->process(); +if ($numErrors === 0) { + exit(0); +} else { + exit(1); +} + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/scripts/phpcs-svn-pre-commit php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/scripts/phpcs-svn-pre-commit --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/scripts/phpcs-svn-pre-commit 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/scripts/phpcs-svn-pre-commit 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,223 @@ +#!@php_bin@ + + * @author Greg Sherwood + * @copyright 2006-2012 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 + */ + +if (is_file(dirname(__FILE__).'/../CodeSniffer/CLI.php') === true) { + include_once dirname(__FILE__).'/../CodeSniffer/CLI.php'; +} else { + include_once 'PHP/CodeSniffer/CLI.php'; +} + +define('PHP_CODESNIFFER_SVNLOOK', '/usr/bin/svnlook'); + + +/** + * A class to process command line options. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Jack Bates + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: @package_version@ + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PHP_CodeSniffer_SVN_Hook extends PHP_CodeSniffer_CLI +{ + + + /** + * Get a list of default values for all possible command line arguments. + * + * @return array + */ + public function getDefaults() + { + $defaults = parent::getDefaults(); + + $defaults['svnArgs'] = array(); + return $defaults; + + }//end getDefaults() + + + /** + * Processes an unknown command line argument. + * + * All unknown args are sent to SVN commands. + * + * @param string $arg The command line argument. + * @param int $pos The position of the argument on the command line. + * @param array $values An array of values determined from CLI args. + * + * @return array The updated CLI values. + * @see getCommandLineValues() + */ + public function processUnknownArgument($arg, $pos, $values) + { + $values['svnArgs'][] = escapeshellarg($arg); + return $values; + + }//end processUnknownArgument() + + + /** + * Runs PHP_CodeSniffer over files are directories. + * + * @param array $values An array of values determined from CLI args. + * + * @return int The number of error and warning messages shown. + * @see getCommandLineValues() + */ + public function process($values=array()) + { + if (empty($values) === true) { + $values = parent::getCommandLineValues(); + } + + // Get list of files in this transaction. + $command = PHP_CODESNIFFER_SVNLOOK.' changed '.implode(' ', $values['svnArgs']); + $handle = popen($command, 'r'); + if ($handle === false) { + echo 'ERROR: Could not execute "'.$command.'"'.PHP_EOL.PHP_EOL; + exit(2); + } + + $contents = stream_get_contents($handle); + fclose($handle); + + // Do not check deleted paths. + $contents = preg_replace('/^D.*/m', null, $contents); + + // Drop the four characters representing the action which precede the path on + // each line. + $contents = preg_replace('/^.{4}/m', null, $contents); + + $values['standard'] = $this->validateStandard($values['standard']); + foreach ($values['standard'] as $standard) { + if (PHP_CodeSniffer::isInstalledStandard($standard) === false) { + // They didn't select a valid coding standard, so help them + // out by letting them know which standards are installed. + echo 'ERROR: the "'.$standard.'" coding standard is not installed. '; + $this->printInstalledStandards(); + exit(2); + } + } + + $phpcs = new PHP_CodeSniffer( + $values['verbosity'], + $values['tabWidth'], + $values['encoding'] + ); + + // Set file extensions if they were specified. Otherwise, + // let PHP_CodeSniffer decide on the defaults. + if (empty($values['extensions']) === false) { + $phpcs->setAllowedFileExtensions($values['extensions']); + } + + // Set ignore patterns if they were specified. + if (empty($values['ignored']) === false) { + $phpcs->setIgnorePatterns($values['ignored']); + } + + // Set some convenience member vars. + if ($values['errorSeverity'] === null) { + $this->errorSeverity = PHPCS_DEFAULT_ERROR_SEV; + } else { + $this->errorSeverity = $values['errorSeverity']; + } + + if ($values['warningSeverity'] === null) { + $this->warningSeverity = PHPCS_DEFAULT_WARN_SEV; + } else { + $this->warningSeverity = $values['warningSeverity']; + } + + // Initialize PHP_CodeSniffer listeners but don't process any files. + $phpcs->setCli($this); + $phpcs->process(array(), $values['standard'], $values['sniffs']); + + // Need double quotes around the following regex beause the vertical whitespace + // char is not always treated correctly for whatever reason. + foreach (preg_split("/\v|\n/", $contents, -1, PREG_SPLIT_NO_EMPTY) as $path) { + // No need to process folders as each changed file is checked. + if (substr($path, -1) === '/') { + continue; + } + + // We need to check ignore rules ourself because they are + // not checked when processing a single file. + if ($phpcs->shouldProcessFile($path, dirname($path)) === false) { + continue; + } + + // Get the contents of each file, as it would be after this transaction. + $command = PHP_CODESNIFFER_SVNLOOK.' cat '.implode(' ', $values['svnArgs']).' '.escapeshellarg($path); + $handle = popen($command, 'r'); + if ($handle === false) { + echo 'ERROR: Could not execute "'.$command.'"'.PHP_EOL.PHP_EOL; + exit(2); + } + + $contents = stream_get_contents($handle); + fclose($handle); + + $phpcs->processFile($path, $contents); + }//end foreach + + return $this->printErrorReport( + $phpcs, + $values['reports'], + $values['showSources'], + $values['reportFile'], + $values['reportWidth'] + ); + + }//end process() + + + /** + * Prints out the usage information for this script. + * + * @return void + */ + public function printUsage() + { + parent::printUsage(); + + echo PHP_EOL; + echo ' Each additional argument is passed to the `svnlook changed ...`'.PHP_EOL; + echo ' and `svnlook cat ...` commands. The report is printed on standard output,'.PHP_EOL; + echo ' however Subversion displays only standard error to the user, so in a'.PHP_EOL; + echo ' pre-commit hook, this script should be invoked as follows:'.PHP_EOL; + echo PHP_EOL; + echo ' '.basename($_SERVER['argv'][0]).' ... "$REPOS" -t "$TXN" >&2 || exit 1'.PHP_EOL; + + }//end printUsage() + + +}//end class + +$phpcs = new PHP_CodeSniffer_SVN_Hook(); +$phpcs->checkRequirements(); + +$numErrors = $phpcs->process(); +if ($numErrors !== 0) { + exit(1); +} + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/scripts/phpcs.bat php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/scripts/phpcs.bat --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/scripts/phpcs.bat 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/scripts/phpcs.bat 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,16 @@ +@echo off +REM PHP_CodeSniffer tokenises PHP code and detects violations of a +REM defined set of coding standards. +REM +REM PHP version 5 +REM +REM @category PHP +REM @package PHP_CodeSniffer +REM @author Greg Sherwood +REM @author Marc McIntyre +REM @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) +REM @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence +REM @version CVS: $Id: phpcs.bat,v 1.3 2007-11-04 22:02:16 squiz Exp $ +REM @link http://pear.php.net/package/PHP_CodeSniffer + +"@php_bin@" -d auto_append_file="" -d auto_prepend_file="" -d include_path="'@php_dir@'" -f "@bin_dir@\phpcs" -- %* diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/tests/AllTests.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/tests/AllTests.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/tests/AllTests.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/tests/AllTests.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,90 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +if (defined('PHP_CODESNIFFER_IN_TESTS') === false) { + define('PHP_CODESNIFFER_IN_TESTS', true); +} + +require_once 'TestSuite.php'; +require_once 'PHPUnit/TextUI/TestRunner.php'; + +if (is_file(dirname(__FILE__).'/../CodeSniffer.php') === true) { + // We are not installed. + include_once 'Core/AllTests.php'; + include_once 'Standards/AllSniffs.php'; + include_once dirname(__FILE__).'/../CodeSniffer.php'; +} else { + include_once 'CodeSniffer/Core/AllTests.php'; + include_once 'CodeSniffer/Standards/AllSniffs.php'; + include_once 'PHP/CodeSniffer.php'; +} + +/** + * A test class for running all PHP_CodeSniffer unit tests. + * + * Usage: phpunit AllTests.php + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PHP_CodeSniffer_AllTests +{ + + + /** + * Prepare the test runner. + * + * @return void + */ + public static function main() + { + PHPUnit_TextUI_TestRunner::run(self::suite()); + + }//end main() + + + /** + * Add all PHP_CodeSniffer test suites into a single test suite. + * + * @return PHPUnit_Framework_TestSuite + */ + public static function suite() + { + // Use a special PHP_CodeSniffer test suite so that we can + // unset our autoload function after the run. + $suite = new PHP_CodeSniffer_TestSuite('PHP CodeSniffer'); + + $suite->addTest(PHP_CodeSniffer_Core_AllTests::suite()); + $suite->addTest(PHP_CodeSniffer_Standards_AllSniffs::suite()); + + // Unregister this here because the PEAR tester loads + // all package suites before running then, so our autoloader + // will cause problems for the packages included after us. + spl_autoload_unregister(array('PHP_CodeSniffer', 'autoload')); + + return $suite; + + }//end suite() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/tests/Core/AllTests.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/tests/Core/AllTests.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/tests/Core/AllTests.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/tests/Core/AllTests.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,76 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +require_once 'IsCamelCapsTest.php'; +require_once 'ErrorSuppressionTest.php'; +require_once 'File/GetMethodParametersTest.php'; + +if (is_file(dirname(__FILE__).'/../../CodeSniffer.php') === true) { + // We are not installed. + include_once dirname(__FILE__).'/../../CodeSniffer.php'; +} else { + include_once 'PHP/CodeSniffer.php'; +} + +/** + * A test class for testing the core. + * + * Do not run this file directly. Run the AllSniffs.php file in the root + * testing directory of PHP_CodeSniffer. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PHP_CodeSniffer_Core_AllTests +{ + + + /** + * Prepare the test runner. + * + * @return void + */ + public static function main() + { + PHPUnit2_TextUI_TestRunner::run(self::suite()); + + }//end main() + + + /** + * Add all core unit tests into a test suite. + * + * @return PHPUnit_Framework_TestSuite + */ + public static function suite() + { + $suite = new PHPUnit_Framework_TestSuite('PHP CodeSniffer Core'); + $suite->addTestSuite('Core_IsCamelCapsTest'); + $suite->addTestSuite('Core_ErrorSuppressionTest'); + $suite->addTestSuite('Core_File_GetMethodParametersTest'); + return $suite; + + }//end suite() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/tests/Core/ErrorSuppressionTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/tests/Core/ErrorSuppressionTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/tests/Core/ErrorSuppressionTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/tests/Core/ErrorSuppressionTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,156 @@ + + * @copyright 2006-2012 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 + */ + +require_once 'PHPUnit/Framework/TestCase.php'; + +/** + * Tests for PHP_CodeSniffer error suppression tags. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Core_ErrorSuppressionTest extends PHPUnit_Framework_TestCase +{ + + + /** + * Test suppressing a single error. + * + * @return void + */ + public function testSuppressError() + { + $phpcs = new PHP_CodeSniffer(); + $phpcs->process(array(), 'PEAR', array('generic_sniffs_php_lowercaseconstantsniff')); + + // Process without suppression. + $content = 'processFile('noSuppressionTest.php', $content); + + $errors = $file->getErrors(); + $numErrors = $file->getErrorCount(); + $this->assertEquals(1, $numErrors); + $this->assertEquals(1, count($errors)); + + // Process with suppression. + $content = 'processFile('suppressionTest.php', $content); + + $errors = $file->getErrors(); + $numErrors = $file->getErrorCount(); + $this->assertEquals(0, $numErrors); + $this->assertEquals(0, count($errors)); + + }//end testSuppressError() + + + /** + * Test suppressing 1 out of 2 errors. + * + * @return void + */ + public function testSuppressSomeErrors() + { + $phpcs = new PHP_CodeSniffer(); + $phpcs->process(array(), 'Generic', array('generic_sniffs_php_lowercaseconstantsniff')); + + // Process without suppression. + $content = 'processFile('noSuppressionTest.php', $content); + + $errors = $file->getErrors(); + $numErrors = $file->getErrorCount(); + $this->assertEquals(2, $numErrors); + $this->assertEquals(2, count($errors)); + + // Process with suppression. + $content = 'processFile('suppressionTest.php', $content); + + $errors = $file->getErrors(); + $numErrors = $file->getErrorCount(); + $this->assertEquals(1, $numErrors); + $this->assertEquals(1, count($errors)); + + }//end testSuppressSomeErrors() + + + /** + * Test suppressing a single warning. + * + * @return void + */ + public function testSuppressWarning() + { + $phpcs = new PHP_CodeSniffer(); + $phpcs->process(array(), 'Generic', array('generic_sniffs_commenting_todosniff')); + + // Process without suppression. + $content = 'processFile('noSuppressionTest.php', $content); + + $warnings = $file->getWarnings(); + $numWarnings = $file->getWarningCount(); + $this->assertEquals(1, $numWarnings); + $this->assertEquals(1, count($warnings)); + + // Process with suppression. + $content = 'processFile('suppressionTest.php', $content); + + $warnings = $file->getWarnings(); + $numWarnings = $file->getWarningCount(); + $this->assertEquals(0, $numWarnings); + $this->assertEquals(0, count($warnings)); + + }//end testSuppressWarning() + + + /** + * Test suppressing a whole file. + * + * @return void + */ + public function testSuppressFile() + { + $phpcs = new PHP_CodeSniffer(); + $phpcs->process(array(), 'Squiz', array('squiz_sniffs_commenting_filecommentsniff')); + + // Process without suppression. + $content = 'processFile('noSuppressionTest.php', $content); + + $errors = $file->getErrors(); + $numErrors = $file->getErrorCount(); + $this->assertEquals(1, $numErrors); + $this->assertEquals(1, count($errors)); + + // Process with suppression. + $content = 'processFile('suppressionTest.php', $content); + + // PHP_CodeSniffer should not have even attempted to process the file. + $this->assertEquals(null, $file); + + }//end testSuppressFile() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/tests/Core/File/GetMethodParametersTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/tests/Core/File/GetMethodParametersTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/tests/Core/File/GetMethodParametersTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/tests/Core/File/GetMethodParametersTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,280 @@ + + * @author Greg Sherwood + * @copyright 2009 SQLI + * @copyright 2006-2012 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 + */ + +require_once 'PHPUnit/Framework/TestCase.php'; + +/** + * Tests for the PHP_CodeSniffer_File:getMethodParameters method. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Anti Veeranna + * @author Greg Sherwood + * @copyright 2009 SQLI + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Core_File_GetMethodParametersTest extends PHPUnit_Framework_TestCase +{ + + /** + * The PHP_CodeSniffer_File object containing parsed contents of this file. + * + * @var PHP_CodeSniffer_File + */ + private $_phpcsFile; + + + /** + * Initialize & tokenize PHP_CodeSniffer_File with code from this file. + * + * Methods used for these tests can be found at the bottom of + * this file. + * + * @return void + */ + public function setUp() + { + $phpcs = new PHP_CodeSniffer(); + $this->_phpcsFile = new PHP_CodeSniffer_File( + __FILE__, + array(), + array(), + array(), + $phpcs + ); + + $contents = file_get_contents(__FILE__); + $this->_phpcsFile->start($contents); + + }//end setUp() + + + /** + * Clean up after finished test. + * + * @return void + */ + public function tearDown() + { + unset($this->_phpcsFile); + + }//end tearDown() + + + /** + * Verify pass-by-reference parsing. + * + * @return void + */ + public function testPassByReference() + { + $expected = array(); + $expected[0] = array( + 'name' => '$var', + 'pass_by_reference' => true, + 'type_hint' => '', + ); + + $start = ($this->_phpcsFile->numTokens - 1); + $function = $this->_phpcsFile->findPrevious( + T_COMMENT, + $start, + null, + false, + '/* testPassByReference */' + ); + + $found = $this->_phpcsFile->getMethodParameters(($function + 2)); + $this->assertSame($expected, $found); + + }//end testPassByReference() + + + /** + * Verify array hint parsing. + * + * @return void + */ + public function testArrayHint() + { + $expected = array(); + $expected[0] = array( + 'name' => '$var', + 'pass_by_reference' => false, + 'type_hint' => 'array', + ); + + $start = ($this->_phpcsFile->numTokens - 1); + $function = $this->_phpcsFile->findPrevious( + T_COMMENT, + $start, + null, + false, + '/* testArrayHint */' + ); + + $found = $this->_phpcsFile->getMethodParameters(($function + 2)); + $this->assertSame($expected, $found); + + }//end testArrayHint() + + + /** + * Verify type hint parsing. + * + * @return void + */ + public function testTypeHint() + { + $expected = array(); + $expected[0] = array( + 'name' => '$var1', + 'pass_by_reference' => false, + 'type_hint' => 'foo', + ); + + $expected[1] = array( + 'name' => '$var2', + 'pass_by_reference' => false, + 'type_hint' => 'bar', + ); + + $start = ($this->_phpcsFile->numTokens - 1); + $function = $this->_phpcsFile->findPrevious( + T_COMMENT, + $start, + null, + false, + '/* testTypeHint */' + ); + + $found = $this->_phpcsFile->getMethodParameters(($function + 2)); + $this->assertSame($expected, $found); + + }//end testTypeHint() + + + /** + * Verify variable. + * + * @return void + */ + public function testVariable() + { + $expected = array(); + $expected[0] = array( + 'name' => '$var', + 'pass_by_reference' => false, + 'type_hint' => '', + ); + + $start = ($this->_phpcsFile->numTokens - 1); + $function = $this->_phpcsFile->findPrevious( + T_COMMENT, + $start, + null, + false, + '/* testVariable */' + ); + + $found = $this->_phpcsFile->getMethodParameters(($function + 2)); + $this->assertSame($expected, $found); + + }//end testVariable() + + + /** + * Verify default value parsing with a single function param. + * + * @return void + */ + public function testSingleDefaultValue() + { + $expected = array(); + $expected[0] = array( + 'name' => '$var1', + 'default' => 'self::CONSTANT', + 'pass_by_reference' => false, + 'type_hint' => '', + ); + + $start = ($this->_phpcsFile->numTokens - 1); + $function = $this->_phpcsFile->findPrevious( + T_COMMENT, + $start, + null, + false, + '/* testSingleDefaultValue */' + ); + + $found = $this->_phpcsFile->getMethodParameters(($function + 2)); + $this->assertSame($expected, $found); + + }//end testSingleDefaultValue() + + + /** + * Verify default value parsing. + * + * @return void + */ + public function testDefaultValues() + { + $expected = array(); + $expected[0] = array( + 'name' => '$var1', + 'default' => '1', + 'pass_by_reference' => false, + 'type_hint' => '', + ); + $expected[1] = array( + 'name' => '$var2', + 'default' => "'value'", + 'pass_by_reference' => false, + 'type_hint' => '', + ); + + $start = ($this->_phpcsFile->numTokens - 1); + $function = $this->_phpcsFile->findPrevious( + T_COMMENT, + $start, + null, + false, + '/* testDefaultValues */' + ); + + $found = $this->_phpcsFile->getMethodParameters(($function + 2)); + $this->assertSame($expected, $found); + + }//end testDefaultValues() + + +}//end class + +// @codingStandardsIgnoreStart +/* testPassByReference */ function passByReference(&$var) {} +/* testArrayHint */ function arrayHint(array $var) {} +/* testVariable */ function variable($var) {} +/* testSingleDefaultValue */ function defaultValue($var1=self::CONSTANT) {} +/* testDefaultValues */ function defaultValues($var1=1, $var2='value') {} +/* testTypeHint */ function typeHint(foo $var1, bar $var2) {} +// @codingStandardsIgnoreEnd + +?> + diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/tests/Core/IsCamelCapsTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/tests/Core/IsCamelCapsTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/tests/Core/IsCamelCapsTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/tests/Core/IsCamelCapsTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,152 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +require_once 'PHPUnit/Framework/TestCase.php'; + +/** + * Tests for the PHP_CodeSniffer:isCamelCaps method. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class Core_IsCamelCapsTest extends PHPUnit_Framework_TestCase +{ + + + /** + * Test valid public function/method names. + * + * @return void + */ + public function testValidNotClassFormatPublic() + { + $this->assertTrue(PHP_CodeSniffer::isCamelCaps('thisIsCamelCaps', false, true, true)); + $this->assertTrue(PHP_CodeSniffer::isCamelCaps('thisISCamelCaps', false, true, false)); + + }//end testValidNotClassFormatPublic() + + + /** + * Test invalid public function/method names. + * + * @return void + */ + public function testInvalidNotClassFormatPublic() + { + $this->assertFalse(PHP_CodeSniffer::isCamelCaps('_thisIsCamelCaps', false, true, true)); + $this->assertFalse(PHP_CodeSniffer::isCamelCaps('thisISCamelCaps', false, true, true)); + $this->assertFalse(PHP_CodeSniffer::isCamelCaps('ThisIsCamelCaps', false, true, true)); + + $this->assertFalse(PHP_CodeSniffer::isCamelCaps('3thisIsCamelCaps', false, true, true)); + $this->assertFalse(PHP_CodeSniffer::isCamelCaps('*thisIsCamelCaps', false, true, true)); + $this->assertFalse(PHP_CodeSniffer::isCamelCaps('-thisIsCamelCaps', false, true, true)); + + $this->assertFalse(PHP_CodeSniffer::isCamelCaps('this*IsCamelCaps', false, true, true)); + $this->assertFalse(PHP_CodeSniffer::isCamelCaps('this-IsCamelCaps', false, true, true)); + $this->assertFalse(PHP_CodeSniffer::isCamelCaps('this_IsCamelCaps', false, true, true)); + $this->assertFalse(PHP_CodeSniffer::isCamelCaps('this_is_camel_caps', false, true, true)); + + }//end testInvalidNotClassFormatPublic() + + + /** + * Test valid private method names. + * + * @return void + */ + public function testValidNotClassFormatPrivate() + { + $this->assertTrue(PHP_CodeSniffer::isCamelCaps('_thisIsCamelCaps', false, false, true)); + $this->assertTrue(PHP_CodeSniffer::isCamelCaps('_thisISCamelCaps', false, false, false)); + $this->assertTrue(PHP_CodeSniffer::isCamelCaps('_i18N', false, false, true)); + $this->assertTrue(PHP_CodeSniffer::isCamelCaps('_i18n', false, false, true)); + + }//end testValidNotClassFormatPrivate() + + + /** + * Test invalid private method names. + * + * @return void + */ + public function testInvalidNotClassFormatPrivate() + { + $this->assertFalse(PHP_CodeSniffer::isCamelCaps('thisIsCamelCaps', false, false, true)); + $this->assertFalse(PHP_CodeSniffer::isCamelCaps('_thisISCamelCaps', false, false, true)); + $this->assertFalse(PHP_CodeSniffer::isCamelCaps('_ThisIsCamelCaps', false, false, true)); + $this->assertFalse(PHP_CodeSniffer::isCamelCaps('__thisIsCamelCaps', false, false, true)); + $this->assertFalse(PHP_CodeSniffer::isCamelCaps('__thisISCamelCaps', false, false, false)); + + $this->assertFalse(PHP_CodeSniffer::isCamelCaps('3thisIsCamelCaps', false, false, true)); + $this->assertFalse(PHP_CodeSniffer::isCamelCaps('*thisIsCamelCaps', false, false, true)); + $this->assertFalse(PHP_CodeSniffer::isCamelCaps('-thisIsCamelCaps', false, false, true)); + $this->assertFalse(PHP_CodeSniffer::isCamelCaps('_this_is_camel_caps', false, false, true)); + + }//end testInvalidNotClassFormatPrivate() + + + /** + * Test valid class names. + * + * @return void + */ + public function testValidClassFormatPublic() + { + $this->assertTrue(PHP_CodeSniffer::isCamelCaps('ThisIsCamelCaps', true, true, true)); + $this->assertTrue(PHP_CodeSniffer::isCamelCaps('ThisISCamelCaps', true, true, false)); + $this->assertTrue(PHP_CodeSniffer::isCamelCaps('This3IsCamelCaps', true, true, false)); + + }//end testValidClassFormatPublic() + + + /** + * Test invalid class names. + * + * @return void + */ + public function testInvalidClassFormat() + { + $this->assertFalse(PHP_CodeSniffer::isCamelCaps('thisIsCamelCaps', true)); + $this->assertFalse(PHP_CodeSniffer::isCamelCaps('This-IsCamelCaps', true)); + $this->assertFalse(PHP_CodeSniffer::isCamelCaps('This_Is_Camel_Caps', true)); + + }//end testInvalidClassFormat() + + + /** + * Test invalid class names with the private flag set. + * + * Note that the private flag is ignored if the class format + * flag is set, so these names are all invalid. + * + * @return void + */ + public function testInvalidClassFormatPrivate() + { + $this->assertFalse(PHP_CodeSniffer::isCamelCaps('_ThisIsCamelCaps', true, true)); + $this->assertFalse(PHP_CodeSniffer::isCamelCaps('_ThisIsCamelCaps', true, false)); + + }//end testInvalidClassFormatPrivate() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/tests/Standards/AbstractSniffUnitTest.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/tests/Standards/AbstractSniffUnitTest.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/tests/Standards/AbstractSniffUnitTest.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/tests/Standards/AbstractSniffUnitTest.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,357 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +require_once 'PHPUnit/Framework/TestCase.php'; + +/** + * An abstract class that all sniff unit tests must extend. + * + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings that are not found, or + * warnings and errors that are not expected, are considered test failures. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +abstract class AbstractSniffUnitTest extends PHPUnit_Framework_TestCase +{ + + /** + * The PHP_CodeSniffer object used for testing. + * + * @var PHP_CodeSniffer + */ + protected static $phpcs = null; + + + /** + * Sets up this unit test. + * + * @return void + */ + protected function setUp() + { + if (self::$phpcs === null) { + self::$phpcs = new PHP_CodeSniffer(); + } + + }//end setUp() + + + /** + * Should this test be skipped for some reason. + * + * @return void + */ + protected function shouldSkipTest() + { + return false; + + }//end shouldSkipTest() + + + /** + * Tests the extending classes Sniff class. + * + * @return void + * @throws PHPUnit_Framework_Error + */ + protected final function runTest() + { + // Skip this test if we can't run in this environment. + if ($this->shouldSkipTest() === true) { + $this->markTestSkipped(); + } + + // The basis for determining file locations. + $basename = substr(get_class($this), 0, -8); + + // The name of the coding standard we are testing. + $standardName = substr($basename, 0, strpos($basename, '_')); + + // The class name of the sniff we are testing. + $sniffClass = str_replace('_Tests_', '_Sniffs_', $basename).'Sniff'; + + if (is_file(dirname(__FILE__).'/../../CodeSniffer.php') === true) { + // We have not been installed. + $standardsDir = realpath(dirname(__FILE__).'/../../CodeSniffer/Standards'); + $testFileBase = $standardsDir.DIRECTORY_SEPARATOR.str_replace('_', DIRECTORY_SEPARATOR, $basename).'UnitTest.'; + } else { + // The name of the dummy file we are testing. + $testFileBase = dirname(__FILE__).DIRECTORY_SEPARATOR.str_replace('_', DIRECTORY_SEPARATOR, $basename).'UnitTest.'; + } + + // Get a list of all test files to check. These will have the same base + // name but different extensions. We ignore the .php file as it is the class. + $testFiles = array(); + + $dir = substr($testFileBase, 0, strrpos($testFileBase, DIRECTORY_SEPARATOR)); + $di = new DirectoryIterator($dir); + + foreach ($di as $file) { + $path = $file->getPathname(); + if (substr($path, 0, strlen($testFileBase)) === $testFileBase) { + if ($path !== $testFileBase.'php') { + $testFiles[] = $path; + } + } + } + + // Get them in order. + sort($testFiles); + + self::$phpcs->process(array(), $standardName, array(strtolower($sniffClass))); + self::$phpcs->setIgnorePatterns(array()); + + $failureMessages = array(); + foreach ($testFiles as $testFile) { + try { + $phpcsFile = self::$phpcs->processFile($testFile); + } catch (Exception $e) { + $this->fail('An unexpected exception has been caught: '.$e->getMessage()); + } + + $failures = $this->generateFailureMessages($phpcsFile); + $failureMessages = array_merge($failureMessages, $failures); + }//end foreach + + if (empty($failureMessages) === false) { + $this->fail(implode(PHP_EOL, $failureMessages)); + } + + }//end testSniff() + + + /** + * Generate a list of test failures for a given sniffed file. + * + * @param PHP_CodeSniffer_File $file The file being tested. + * + * @return array + * @throws PHP_CodeSniffer_Exception + */ + public function generateFailureMessages(PHP_CodeSniffer_File $file) + { + $testFile = $file->getFilename(); + + $foundErrors = $file->getErrors(); + $foundWarnings = $file->getWarnings(); + $expectedErrors = $this->getErrorList(basename($testFile)); + $expectedWarnings = $this->getWarningList(basename($testFile)); + + if (is_array($expectedErrors) === false) { + throw new PHP_CodeSniffer_Exception('getErrorList() must return an array'); + } + + if (is_array($expectedWarnings) === false) { + throw new PHP_CodeSniffer_Exception('getWarningList() must return an array'); + } + + /* + We merge errors and warnings together to make it easier + to iterate over them and produce the errors string. In this way, + we can report on errors and warnings in the same line even though + it's not really structured to allow that. + */ + + $allProblems = array(); + $failureMessages = array(); + + foreach ($foundErrors as $line => $lineErrors) { + foreach ($lineErrors as $column => $errors) { + if (isset($allProblems[$line]) === false) { + $allProblems[$line] = array( + 'expected_errors' => 0, + 'expected_warnings' => 0, + 'found_errors' => array(), + 'found_warnings' => array(), + ); + } + + $foundErrorsTemp = array(); + foreach ($allProblems[$line]['found_errors'] as $foundError) { + $foundErrorsTemp[] = $foundError; + } + + $errorsTemp = array(); + foreach ($errors as $foundError) { + $errorsTemp[] = $foundError['message']; + } + + $allProblems[$line]['found_errors'] = array_merge($foundErrorsTemp, $errorsTemp); + } + + if (isset($expectedErrors[$line]) === true) { + $allProblems[$line]['expected_errors'] = $expectedErrors[$line]; + } else { + $allProblems[$line]['expected_errors'] = 0; + } + + unset($expectedErrors[$line]); + }//end foreach + + foreach ($expectedErrors as $line => $numErrors) { + if (isset($allProblems[$line]) === false) { + $allProblems[$line] = array( + 'expected_errors' => 0, + 'expected_warnings' => 0, + 'found_errors' => array(), + 'found_warnings' => array(), + ); + } + + $allProblems[$line]['expected_errors'] = $numErrors; + } + + foreach ($foundWarnings as $line => $lineWarnings) { + foreach ($lineWarnings as $column => $warnings) { + if (isset($allProblems[$line]) === false) { + $allProblems[$line] = array( + 'expected_errors' => 0, + 'expected_warnings' => 0, + 'found_errors' => array(), + 'found_warnings' => array(), + ); + } + + $foundWarningsTemp = array(); + foreach ($allProblems[$line]['found_warnings'] as $foundWarning) { + $foundWarningsTemp[] = $foundWarning; + } + + $warningsTemp = array(); + foreach ($warnings as $warning) { + $warningsTemp[] = $warning['message']; + } + + $allProblems[$line]['found_warnings'] = array_merge($foundWarningsTemp, $warningsTemp); + } + + if (isset($expectedWarnings[$line]) === true) { + $allProblems[$line]['expected_warnings'] = $expectedWarnings[$line]; + } else { + $allProblems[$line]['expected_warnings'] = 0; + } + + unset($expectedWarnings[$line]); + }//end foreach + + foreach ($expectedWarnings as $line => $numWarnings) { + if (isset($allProblems[$line]) === false) { + $allProblems[$line] = array( + 'expected_errors' => 0, + 'expected_warnings' => 0, + 'found_errors' => array(), + 'found_warnings' => array(), + ); + } + + $allProblems[$line]['expected_warnings'] = $numWarnings; + } + + // Order the messages by line number. + ksort($allProblems); + + foreach ($allProblems as $line => $problems) { + $numErrors = count($problems['found_errors']); + $numWarnings = count($problems['found_warnings']); + $expectedErrors = $problems['expected_errors']; + $expectedWarnings = $problems['expected_warnings']; + + $errors = ''; + $foundString = ''; + + if ($expectedErrors !== $numErrors || $expectedWarnings !== $numWarnings) { + $lineMessage = "[LINE $line]"; + $expectedMessage = 'Expected '; + $foundMessage = 'in '.basename($testFile).' but found '; + + if ($expectedErrors !== $numErrors) { + $expectedMessage .= "$expectedErrors error(s)"; + $foundMessage .= "$numErrors error(s)"; + if ($numErrors !== 0) { + $foundString .= 'error(s)'; + $errors .= implode(PHP_EOL.' -> ', $problems['found_errors']); + } + + if ($expectedWarnings !== $numWarnings) { + $expectedMessage .= ' and '; + $foundMessage .= ' and '; + if ($numWarnings !== 0) { + if ($foundString !== '') { + $foundString .= ' and '; + } + } + } + } + + if ($expectedWarnings !== $numWarnings) { + $expectedMessage .= "$expectedWarnings warning(s)"; + $foundMessage .= "$numWarnings warning(s)"; + if ($numWarnings !== 0) { + $foundString .= 'warning(s)'; + if (empty($errors) === false) { + $errors .= PHP_EOL.' -> '; + } + + $errors .= implode(PHP_EOL.' -> ', $problems['found_warnings']); + } + } + + $fullMessage = "$lineMessage $expectedMessage $foundMessage."; + if ($errors !== '') { + $fullMessage .= " The $foundString found were:".PHP_EOL." -> $errors"; + } + + $failureMessages[] = $fullMessage; + }//end if + }//end foreach + + return $failureMessages; + + }//end generateFailureMessages() + + + /** + * 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) + */ + protected abstract function 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) + */ + protected abstract function getWarningList(); + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/tests/Standards/AllSniffs.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/tests/Standards/AllSniffs.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/tests/Standards/AllSniffs.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/tests/Standards/AllSniffs.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,125 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +// Require this here so that the unit tests don't have to try and find the +// abstract class once it is installed into the PEAR tests directory. +require_once dirname(__FILE__).'/AbstractSniffUnitTest.php'; + +/** + * A test class for testing all sniffs for installed standards. + * + * Usage: phpunit AllSniffs.php + * + * This test class loads all unit tests for all installed standards into a + * single test suite and runs them. Errors are reported on the command line. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PHP_CodeSniffer_Standards_AllSniffs +{ + + + /** + * Prepare the test runner. + * + * @return void + */ + public static function main() + { + PHPUnit_TextUI_TestRunner::run(self::suite()); + + }//end main() + + + /** + * Add all sniff unit tests into a test suite. + * + * Sniff unit tests are found by recursing through the 'Tests' directory + * of each installed coding standard. + * + * @return PHPUnit_Framework_TestSuite + */ + public static function suite() + { + $suite = new PHPUnit_Framework_TestSuite('PHP CodeSniffer Standards'); + + $isInstalled = !is_file(dirname(__FILE__).'/../../CodeSniffer.php'); + + if ($isInstalled === false) { + // We have not been installed. + $standardsDir = realpath(dirname(__FILE__).'/../../CodeSniffer/Standards'); + } else { + $standardsDir = ''; + } + + $standards = PHP_CodeSniffer::getInstalledStandards(true, $standardsDir); + + foreach ($standards as $standard) { + if ($isInstalled === false) { + $standardDir = $standardsDir.DIRECTORY_SEPARATOR.$standard.DIRECTORY_SEPARATOR.'Tests'.DIRECTORY_SEPARATOR; + } else { + $standardDir = dirname(__FILE__).DIRECTORY_SEPARATOR.$standard.DIRECTORY_SEPARATOR.'Tests'.DIRECTORY_SEPARATOR; + } + + if (is_dir($standardDir) === false) { + // No tests for this standard. + continue; + } + + // Locate the actual directory that contains the standard's tests. + // This is individual to each standard as they could be symlinked in. + $baseDir = dirname(dirname($standardDir)); + + $di = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($standardDir)); + + foreach ($di as $file) { + // Skip hidden files. + if (substr($file->getFilename(), 0, 1) === '.') { + continue; + } + + // Tests must have the extension 'php'. + $parts = explode('.', $file); + $ext = array_pop($parts); + if ($ext !== 'php') { + continue; + } + + $filePath = $file->getPathname(); + $className = str_replace($baseDir.DIRECTORY_SEPARATOR, '', $filePath); + $className = substr($className, 0, -4); + $className = str_replace(DIRECTORY_SEPARATOR, '_', $className); + + include_once $filePath; + $class = new $className('getErrorList'); + $suite->addTest($class); + }//end foreach + }//end foreach + + return $suite; + + }//end suite() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/tests/TestSuite.php php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/tests/TestSuite.php --- php-codesniffer-1.3.4/PHP_CodeSniffer-1.5.0RC2/tests/TestSuite.php 1970-01-01 00:00:00.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/tests/TestSuite.php 2013-04-03 23:21:40.000000000 +0000 @@ -0,0 +1,56 @@ + + * @author Marc McIntyre + * @copyright 2006-2012 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 + */ + +require_once 'PHPUnit/Framework/TestSuite.php'; + +/** + * A PHP_CodeSniffer specific test suite for PHPUnit. + * + * Unregisters the PHP_CodeSniffer autoload function after the run. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: 1.5.0RC2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PHP_CodeSniffer_TestSuite extends PHPUnit_Framework_TestSuite +{ + + + /** + * Runs the tests and collects their result in a TestResult. + * + * @param PHPUnit_Framework_TestResult $result A test result. + * @param mixed $filter The filter passed to each test. + * + * @return PHPUnit_Framework_TestResult + */ + public function run(PHPUnit_Framework_TestResult $result=null, $filter=false) + { + spl_autoload_register(array('PHP_CodeSniffer', 'autoload')); + $result = parent::run($result, $filter); + spl_autoload_unregister(array('PHP_CodeSniffer', 'autoload')); + return $result; + + }//end run() + + +}//end class + +?> diff -Nru php-codesniffer-1.3.4/debian/changelog php-codesniffer-1.5.0~rc2/debian/changelog --- php-codesniffer-1.3.4/debian/changelog 2012-07-20 07:43:45.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/debian/changelog 2013-07-12 15:28:14.000000000 +0000 @@ -1,3 +1,12 @@ +php-codesniffer (1.5.0~rc2-1) unstable; urgency=low + + * New upstream release. + * Refreshed patch. + * Standards-Version is now 3.9.4. + * Canonical VCS URLs. + + -- Thomas Goirand Fri, 12 Jul 2013 15:16:25 +0000 + php-codesniffer (1.3.4-1) unstable; urgency=low * Adopting the package (Closes: #679251). diff -Nru php-codesniffer-1.3.4/debian/control php-codesniffer-1.5.0~rc2/debian/control --- php-codesniffer-1.3.4/debian/control 2012-07-20 07:43:45.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/debian/control 2013-07-12 15:28:14.000000000 +0000 @@ -5,9 +5,9 @@ Uploaders: Thomas Goirand Build-Depends: debhelper (>= 8), pkg-php-tools, phpunit (>= 3.6), php-timer Build-Depends-Indep: php-pear -Standards-Version: 3.9.3 -Vcs-Browser: http://git.debian.org/?p=pkg-php/php-codesniffer.git -Vcs-Git: http://git.debian.org/git/pkg-php/php-codesniffer.git +Standards-Version: 3.9.4 +Vcs-Browser: http://anonscm.debian.org/gitweb/?p=pkg-php/php-codesniffer.git +Vcs-Git: http://anonscm.debian.org/git/pkg-php/php-codesniffer.git Homepage: http://pear.php.net/package/PHP_CodeSniffer Package: php-codesniffer diff -Nru php-codesniffer-1.3.4/debian/copyright php-codesniffer-1.5.0~rc2/debian/copyright --- php-codesniffer-1.3.4/debian/copyright 2012-07-20 07:43:45.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/debian/copyright 2013-07-12 15:28:14.000000000 +0000 @@ -1,6 +1,6 @@ Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ -Upstream-Contact: Adam Ashley , Adam Harvey -Source: http://pear.php.net/package/Config/download +Upstream-Contact: Greg Sherwood +Source: http://pear.php.net/package/PHP_CodeSniffer/download Files: debian/* Copyright: (c) 2008, Jack Bates @@ -32,7 +32,7 @@ (c) Andy Brockhurst (c) Leif Wickland (c) Johann-Peter Hartmann -License: BSD-2-clauses +License: BSD-3-clause License: LGPL-2.1 This library is free software; you can redistribute it and/or modify it under @@ -52,24 +52,26 @@ On Debian systems, the complete text of the GNU Lesser General Public License (LGPL) may be found in /usr/share/common-licenses/LGPL-2.1 -License: BSD-2-clauses +License: BSD-3-clause 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. - . - 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 THE COPYRIGHT HOLDER OR CONTRIBUTORS 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. + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. 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. + 3. The name of the Squiz Pty Ltd nor the names of its contributors may + not be used to endorse or promote products derived from this software + without specific prior written permission. + . + THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 THE AUTHOR 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. diff -Nru php-codesniffer-1.3.4/debian/patches/0010-path-to-codesniffer.conf.patch php-codesniffer-1.5.0~rc2/debian/patches/0010-path-to-codesniffer.conf.patch --- php-codesniffer-1.3.4/debian/patches/0010-path-to-codesniffer.conf.patch 2012-07-20 07:43:45.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/debian/patches/0010-path-to-codesniffer.conf.patch 2013-07-12 15:28:14.000000000 +0000 @@ -2,19 +2,20 @@ Author: Thomas Goirand Bug-Debian: http://bugs.debian.org/470294 Forwarded: not-needed +Last-Update: 2013-07-12 ---- php-codesniffer-1.3.4.orig/PHP_CodeSniffer-1.3.4/CodeSniffer.php -+++ php-codesniffer-1.3.4/PHP_CodeSniffer-1.3.4/CodeSniffer.php -@@ -1951,7 +1951,7 @@ class PHP_CodeSniffer +--- php-codesniffer-1.5.0~rc2.orig/PHP_CodeSniffer-1.5.0RC2/CodeSniffer.php ++++ php-codesniffer-1.5.0~rc2/PHP_CodeSniffer-1.5.0RC2/CodeSniffer.php +@@ -2009,7 +2009,7 @@ class PHP_CodeSniffer public static function setConfigData($key, $value, $temp=false) { if ($temp === false) { - $configFile = dirname(__FILE__).'/CodeSniffer.conf'; + $configFile = '/etc/php-codesniffer/CodeSniffer.conf'; - if (is_file($configFile) === false) { - $configFile = '@data_dir@/PHP_CodeSniffer/CodeSniffer.conf'; - } -@@ -2003,7 +2003,7 @@ class PHP_CodeSniffer + if (is_file($configFile) === false + && strpos('@data_dir@', '@data_dir') === false + ) { +@@ -2065,7 +2065,7 @@ class PHP_CodeSniffer return $GLOBALS['PHP_CODESNIFFER_CONFIG_DATA']; } diff -Nru php-codesniffer-1.3.4/debian/watch php-codesniffer-1.5.0~rc2/debian/watch --- php-codesniffer-1.3.4/debian/watch 2012-07-20 07:43:45.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/debian/watch 2013-07-12 15:28:14.000000000 +0000 @@ -1,2 +1,4 @@ version=3 -http://pear.php.net/package/Config/download http://download.pear.php.net/package/Config-(.*).tgz +opts=uversionmangle=s/(\d)[\.\-]?((?:rc|RC|pre)\.?\d+(?:-\d+)?)$/$1~$2/,dversionmangle=s/(\d)[\.\-]?((?:rc|RC|pre)\.?\d+(?:-\d+)?)$/$1~$2/ \ +http://pear.php.net/package/PHP_CodeSniffer/download \ +(?:.*/|.*=|)PHP_CodeSniffer[\-\._](\d\S*)\.(?:tar\.xz|txz|tar\.bz2|tbz2|tar\.gz|tgz)(?:/\S*)? diff -Nru php-codesniffer-1.3.4/package.xml php-codesniffer-1.5.0~rc2/package.xml --- php-codesniffer-1.3.4/package.xml 2012-05-17 03:49:07.000000000 +0000 +++ php-codesniffer-1.5.0~rc2/package.xml 2013-04-03 23:21:41.000000000 +0000 @@ -10,1522 +10,1667 @@ gsherwood@squiz.net yes - 2012-05-17 - + 2013-04-03 + - 1.3.4 - 1.3.4 + 1.5.0RC2 + 1.5.0RC2 - stable - stable + beta + beta - BSD License + BSD 3-Clause License -- Added missing package.xml entries for new Generic FixmeSniff - -- Thanks to Jaroslav HanslĂ­k for the patch -- Expected indents for PEAR ScopeClosingBraceSniff and FunctionCallSignatureSniff can now be set in ruleset files - -- Both sniffs use a variable called "indent" - -- Thanks to Thomas Despoix for the patch -- Standards designed to be installed in the PHPCS Standards dir will now work outside this dir as well - -- In particular, allows the Drupal CS to work without needing to symlink it into the PHPCS install - -- Thanks to Peter Philipp for the patch -- Rule references for standards, directories and specific sniffs can now be relative in ruleset.xml files - -- For example: ref="../MyStandard/Sniffs/Commenting/DisallowHashCommentsSniff.php" -- Symlinked standards now work correctly, allowing aliasing of installed standards (request #19417) - -- Thanks to Tom Klingenberg for the patch -- Squiz ObjectInstantiationSniff now allows objects to be returned without assinging them to a variable -- Added Squiz.Commenting.FileComment.MissingShort error message for file comments that only contains tags - -- Also stops undefined index errors being generated for these comments -- Debug option -vv now shows tokenizer status for CSS files -- Added support for new gjslint error formats - -- Thanks to Meck for the patch -- Generic ScopeIndentSniff now allows comment indents to not be exact even if the exact flag is set - -- The start of the comment is still checked for exact indentation as normal -- Fixed an issue in AbstractPatternSniff where comments were not being ignored in some cases -- Fixed an issue in Zend ClosingTagSniff where the closing tag was not always being detected correctly - -- Thanks to Jonathan Robson for the patch -- Fixed an issue in Generic FunctionCallArgumentSpacingSniff where closures could cause incorrect errors -- Fixed an issue in Generic UpperCaseConstantNameSniff where errors were incorrectly reported on goto statements - -- Thanks to Tom Klingenberg for the patch -- PEAR FileCommentSniff and ClassCommentSniff now support author emails with a single character in the local part - -- E.g., a@me.com - -- Thanks to Denis Shapkin for the patch -- Fixed bug #19290 : Generic indent sniffer fails for anonymous functions -- Fixed bug #19324 : Setting show_warnings configuration option does not work -- Fixed bug #19354 : Not recognizing references passed to method -- Fixed bug #19361 : CSS tokenzier generates errors when PHP embedded in CSS file -- Fixed bug #19374 : HEREDOC/NOWDOC Indentation problems -- Fixed bug #19381 : traits and indetations in traits are not handled properly -- Fixed bug #19394 : Notice in NonExecutableCodeSniff -- Fixed bug #19402 : Syntax error when executing phpcs on Windows with parens in PHP path - -- Thanks to Tom Klingenberg for the patch -- Fixed bug #19411 : magic method error on __construct() - -- The fix required a rewrite of AbstractScopeSniff, so please test any sniffs that extend this class -- Fixed bug #19412 : Incorrect error about assigning objects to variables when inside inline IF -- Fixed bug #19413 : php_cs thinks I haven't used a parameter when I have -- Fixed bug #19414 : php_cs seems to not track variables correctly in heredocs +- Ruleset processing has been rewritten to be more predictable + -- Provides much better support for relative paths inside ruleset files + -- May mean that sniffs that were previously ignored are now being included when importing external rulesets + -- Ruleset processing output can be seen by using the -vv command line argument + -- Internal sniff registering functions have all changed, so please review custom scripts +- You can now pass multiple coding standards on the command line, comma separated (request #19144) + -- Works with built-in or custom standards and rulesets, or a mix of both +- You can now exclude directories or whole standards in a ruleset XML file (request #19731) + -- e.g., exclude "Generic.Commenting" or just "Generic" + -- You can also pass in a path to a directory instead, if you know it +- Added Generic LowerCaseKeywordSniff to ensure all PHP keywords are defined in lowercase + -- The PSR2 and Squiz standards now use this sniff +- Added Generic SAPIUsageSniff to ensure the PHP_SAPI constant is used instead of php_sapi_name() (request #19863) +- Squiz FunctionSpacingSniff now has a setting to specify how many lines there should between functions (request #19843) + -- Default remains at 2 + -- Override the "spacing" setting in a ruleset.xml file to change +- Squiz LowercasePHPFunctionSniff no longer throws errors for the limited set of PHP keywords it was checking + -- Add a rule for Generic.PHP.LowerCaseKeyword to your ruleset to replicate this functionality +- Added support for the PHP 5.4 T_CALLABLE token so it can be used in lower PHP versions +- Generic EndFileNoNewlineSniff now supports checking of CSS and JS files +- PSR2 SwitchDeclarationSniff now has a setting to specify how many spaces code should be indented + -- Default remains at 4; override the indent setting in a ruleset.xml file to change + -- Thanks to Asher Snyder for the patch +- Generic ScopeIndentSniff now has a setting to specify a list of tokens that should be ignored + -- The first token on the line is checked and the whole line is ignored if the token is in the array + -- Thanks to Eloy Lafuente for the patch +- Squiz LowercaseClassKeywordsSniff now checks for the TRAIT keyword + -- Thanks to Anthon Pang for the patch +- If you create your own PHP_CodeSniffer object, PHPCS will no longer exit when an unknown argument is found + -- This allows you to create wrapper scripts for PHPCS more easily +- PSR2 MethodDeclarationSniff no longer generates a notice for methods named "_" + -- Thanks to Bart S for the patch +- Squiz BlockCommentSniff no longer reports that a blank line between a scope closer and block comment is invalid +- Generic DuplicateClassNameSniff no longer reports an invalid error if multiple PHP open tags exist in a file +- Generic DuplicateClassNameSniff no longer reports duplicate errors if multiple PHP open tags exist in a file +- Fixed bug #19819 : Freeze with syntax error in use statement +- Fixed bug #19820 : Wrong message level in Generic_Sniffs_CodeAnalysis_EmptyStatementSniff +- Fixed bug #19859 : CodeSniffer::setIgnorePatterns API changed +- Fixed bug #19871 : findExtendedClassName doesn't return FQCN on namespaced classes +- Fixed bug #19879 : bitwise and operator interpreted as reference by value - - + + - + - + - - - - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - - - - - - - - - - - + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - - - - - - - - - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + - + - + - + - + - + - + - - + + - + - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + + + + + + + + + - + - + - + - + - - + + - + - + - + - + - + - - + + - - + + + + + + + + + + + + + + - + - + - + - + + + + + - + - - + + + + + + - + + + + + + + - + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + - + - + - + - + - + - + - + - + - + - + - - + + - + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - + - + - + - + - - + + - + - + - - + + - - + + - + - + - - + + - - + + - + - - + + - + - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + + + + - + - - + + - + - + - - + + - - + + - + - + - - + + - - + + - + - + - + - + - + - - + + - - - + + + - + - + - - + + - + - + - + - + - - - + + + - + - + - - - + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - + + + - - + + - + - + - + - + - - + + - + - + - - + + - - + + - + - + - + - + - + - + - + - + + - - + + - + - + - + - + - + - + - + - + - + - + - - + + - - + + - + - + - + - + - + - + - + - + - + - + - - + + - + - + - + - + - - - + + + - + - + - - + + - + - - - - + + + + + + + + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -1558,24 +1703,7 @@ - - - - - - - - - - - - - - - - - @@ -1588,24 +1716,7 @@ - - - - - - - - - - - - - - - - - @@ -1614,6 +1725,407 @@ + 1.5.0RC2 + 1.5.0RC2 + + + beta + beta + + 2013-04-04 + BSD License + +- Ruleset processing has been rewritten to be more predictable + -- Provides much better support for relative paths inside ruleset files + -- May mean that sniffs that were previously ignored are now being included when importing external rulesets + -- Ruleset processing output can be seen by using the -vv command line argument + -- Internal sniff registering functions have all changed, so please review custom scripts +- You can now pass multiple coding standards on the command line, comma separated (request #19144) + -- Works with built-in or custom standards and rulesets, or a mix of both +- You can now exclude directories or whole standards in a ruleset XML file (request #19731) + -- e.g., exclude "Generic.Commenting" or just "Generic" + -- You can also pass in a path to a directory instead, if you know it +- Added Generic LowerCaseKeywordSniff to ensure all PHP keywords are defined in lowercase + -- The PSR2 and Squiz standards now use this sniff +- Added Generic SAPIUsageSniff to ensure the PHP_SAPI constant is used instead of php_sapi_name() (request #19863) +- Squiz FunctionSpacingSniff now has a setting to specify how many lines there should between functions (request #19843) + -- Default remains at 2 + -- Override the "spacing" setting in a ruleset.xml file to change +- Squiz LowercasePHPFunctionSniff no longer throws errors for the limited set of PHP keywords it was checking + -- Add a rule for Generic.PHP.LowerCaseKeyword to your ruleset to replicate this functionality +- Added support for the PHP 5.4 T_CALLABLE token so it can be used in lower PHP versions +- Generic EndFileNoNewlineSniff now supports checking of CSS and JS files +- PSR2 SwitchDeclarationSniff now has a setting to specify how many spaces code should be indented + -- Default remains at 4; override the indent setting in a ruleset.xml file to change + -- Thanks to Asher Snyder for the patch +- Generic ScopeIndentSniff now has a setting to specify a list of tokens that should be ignored + -- The first token on the line is checked and the whole line is ignored if the token is in the array + -- Thanks to Eloy Lafuente for the patch +- Squiz LowercaseClassKeywordsSniff now checks for the TRAIT keyword + -- Thanks to Anthon Pang for the patch +- If you create your own PHP_CodeSniffer object, PHPCS will no longer exit when an unknown argument is found + -- This allows you to create wrapper scripts for PHPCS more easily +- PSR2 MethodDeclarationSniff no longer generates a notice for methods named "_" + -- Thanks to Bart S for the patch +- Squiz BlockCommentSniff no longer reports that a blank line between a scope closer and block comment is invalid +- Generic DuplicateClassNameSniff no longer reports an invalid error if multiple PHP open tags exist in a file +- Generic DuplicateClassNameSniff no longer reports duplicate errors if multiple PHP open tags exist in a file +- Fixed bug #19819 : Freeze with syntax error in use statement +- Fixed bug #19820 : Wrong message level in Generic_Sniffs_CodeAnalysis_EmptyStatementSniff +- Fixed bug #19859 : CodeSniffer::setIgnorePatterns API changed +- Fixed bug #19871 : findExtendedClassName doesn't return FQCN on namespaced classes +- Fixed bug #19879 : bitwise and operator interpreted as reference by value + + + + + 1.5.0RC1 + 1.5.0RC1 + + + beta + beta + + 2013-02-08 + BSD License + +- Reports have been completely rewritten to consume far less memory + -- Each report is incrementally written to the file system during a run and then printed out when the run ends + -- There is no longer a need to keep the list of errors and warnings in memory during a run +- Multi-file sniff support has been removed because they are too memory intensive + -- If you have a custom multi-file sniff, you can convert it into a standard sniff quite easily + -- See CodeSniffer/Standards/Generic/Sniffs/Classes/DuplicateClassNameSniff.php for an example + + + + + 1.4.5 + 1.4.5 + + + stable + stable + + 2013-04-04 + BSD License + +- Added Generic LowerCaseKeywordSniff to ensure all PHP keywords are defined in lowercase + -- The PSR2 and Squiz standards now use this sniff +- Added Generic SAPIUsageSniff to ensure the PHP_SAPI constant is used instead of php_sapi_name() (request #19863) +- Squiz FunctionSpacingSniff now has a setting to specify how many lines there should between functions (request #19843) + -- Default remains at 2 + -- Override the "spacing" setting in a ruleset.xml file to change +- Squiz LowercasePHPFunctionSniff no longer throws errors for the limited set of PHP keywords it was checking + -- Add a rule for Generic.PHP.LowerCaseKeyword to your ruleset to replicate this functionality +- Added support for the PHP 5.4 T_CALLABLE token so it can be used in lower PHP versions +- Generic EndFileNoNewlineSniff now supports checking of CSS and JS files +- PSR2 SwitchDeclarationSniff now has a setting to specify how many spaces code should be indented + -- Default remains at 4; override the indent setting in a ruleset.xml file to change + -- Thanks to Asher Snyder for the patch +- Generic ScopeIndentSniff now has a setting to specify a list of tokens that should be ignored + -- The first token on the line is checked and the whole line is ignored if the token is in the array + -- Thanks to Eloy Lafuente for the patch +- Squiz LowercaseClassKeywordsSniff now checks for the TRAIT keyword + -- Thanks to Anthon Pang for the patch +- If you create your own PHP_CodeSniffer object, PHPCS will no longer exit when an unknown argument is found + -- This allows you to create wrapper scripts for PHPCS more easily +- PSR2 MethodDeclarationSniff no longer generates a notice for methods named "_" + -- Thanks to Bart S for the patch +- Squiz BlockCommentSniff no longer reports that a blank line between a scope closer and block comment is invalid +- Generic DuplicateClassNameSniff no longer reports an invalid error if multiple PHP open tags exist in a file +- Generic DuplicateClassNameSniff no longer reports duplicate errors if multiple PHP open tags exist in a file +- Fixed bug #19819 : Freeze with syntax error in use statement +- Fixed bug #19820 : Wrong message level in Generic_Sniffs_CodeAnalysis_EmptyStatementSniff +- Fixed bug #19859 : CodeSniffer::setIgnorePatterns API changed +- Fixed bug #19871 : findExtendedClassName doesn't return FQCN on namespaced classes +- Fixed bug #19879 : bitwise and operator interpreted as reference by value + + + + + 1.4.4 + 1.4.4 + + + stable + stable + + 2013-02-07 + BSD License + +- Ignored lines no longer cause the summary report to show incorrect error and warning counts + -- Thanks to Bert Van Hauwaert for the patch +- Added Generic CSSLintSniff to run CSSLint over a CSS file and report warnings + -- Set full command to run CSSLint using phpcs --config-set csslint_path /path/to/csslint + -- Thanks to Roman Levishchenko for the contribution +- Added PSR2 ControlStructureSpacingSniff to ensure there are no spaces before and after parenthesis in control structures + -- Fixes bug #19732 : PSR2: some control structures errors not reported +- Squiz commenting sniffs now support non-English characters when checking for capital letters + -- Thanks to Roman Levishchenko for the patch +- Generic EndFileNewlineSniff now supports JS and CSS files + -- Thanks to Denis Ryabkov for the patch +- PSR1 SideEffectsSniff no longer reports constant declarations as side effects +- Notifysend report now supports notify-send versions before 0.7.3 + -- Thanks to Ken Guest for the patch +- PEAR and Squiz FunctionCommentSniffs no longer report errors for misaligned argument comments when they are blank + -- Thanks to Thomas Peterson for the patch +- Squiz FunctionDeclarationArgumentSpacingSniff now works correctly for equalsSpacing values greater than 0 + -- Thanks to Klaus Purer for the patch +- Squiz SuperfluousWhitespaceSniff no longer throws errors for CSS files with no newline at the end +- Squiz SuperfluousWhitespaceSniff now allows a single newline at the end of JS and CSS files +- Fixed bug #19755 : Token of T_CLASS type has no scope_opener and scope_closer keys +- Fixed bug #19759 : Squiz.PHP.NonExecutableCode fails for return function()... +- Fixed bug #19763 : Use statements for traits not recognised correctly for PSR2 code style +- Fixed bug #19764 : Instead of for traits throws uppercase constant name errors +- Fixed bug #19772 : PSR2_Sniffs_Namespaces_UseDeclarationSniff does not properly recognize last use +- Fixed bug #19775 : False positive in NonExecutableCode sniff when not using curly braces +- Fixed bug #19782 : Invalid found size functions in loop when using object operator +- Fixed bug #19799 : config folder is not created automatically +- Fixed bug #19804 : JS Tokenizer wrong /**/ parsing + + + + + 1.4.3 + 1.4.3 + + + stable + stable + + 2012-12-04 + BSD License + +- Added support for the PHP 5.5 T_FINALLY token to detect try/catch/finally statements +- Added empty CodeSniffer.conf to enable config settings for Composer installs +- Added Generic EndFileNoNewlineSniff to ensure there is no newline at the end of a file +- Autoloader can now load PSR-0 compliant classes + -- Thanks to Maik Penz for the patch +- Squiz NonExecutableCodeSniff no longer throws error for multi-line RETURNs inside CASE statements + -- Thanks to Marc Ypes for the patch +- Squiz OperatorSpacingSniff no longer reports errors for negative numbers inside inline THEN statements + -- Thanks to Klaus Purer for the patch +- Squiz OperatorSpacingSniff no longer reports errors for the assignment of operations involving negative numbers +- Squiz SelfMemberReferenceSniff can no longer get into an infinite loop when checking a static call with a namespace + -- Thanks to Andy Grunwald for the patch +- Fixed bug #19699 : Generic.Files.LineLength giving false positives when tab-width is used +- Fixed bug #19726 : Wrong number of spaces expected after instanceof static + - Fixed bug #19727 : PSR2: no error reported when using } elseif { + + + + + 1.4.2 + 1.4.2 + + + stable + stable + + 2012-11-09 + BSD License + +- PHP_CodeSniffer can now be installed using Composer + -- Require squizlabs/php_codesniffer in your composer.json file + -- Thanks to Rob Bast, Stephen Rees-Carter, Stefano Kowalke and Ivan Habunek for help with this +- Squiz BlockCommentSniff and InlineCommentSniff no longer report errors for trait block comments +- Squiz SelfMemberReferenceSniff now supports namespaces + -- Thanks to Andy Grunwald for the patch +- Squiz FileCommentSniff now uses tag names inside the error codes for many messages + -- This allows you to exclude specific missing, out of order etc., tags +- Squiz SuperfluousWhitespaceSniff now has an option to ignore blank lines + -- This will stop errors being reported for lines that contain only whitespace + -- Set the ignoreBlankLines property to TRUE in your ruleset.xml file to enable this +- PSR2 no longer reports errors for whitespace at the end of blank lines +- Fixed gitblame report not working on Windows + -- Thanks to Rogerio Prado de Jesus +- Fixed an incorrect error in Squiz OperatorSpacingSniff for default values inside a closure definition +- Fixed bug #19691 : SubversionPropertiesSniff fails to find missing properties + -- Thanks to Kevin Winahradsky for the patch +- Fixed bug #19692 : DisallowMultipleAssignments is triggered by a closure +- Fixed bug #19693 : exclude-patterns no longer work on specific messages +- Fixed bug #19694 : Squiz.PHP.LowercasePHPFunctions incorrectly matches return by ref functions + + + + + 1.4.1 + 1.4.1 + + + stable + stable + + 2012-11-02 + BSD License + +- All ignore patterns have been reverted to being checked against the absolute path of a file + -- Patterns can be specified to be relative in a rulset.xml file, but nowhere else + -- e.g., [exclude-pattern type="relative"]^tests/*[/exclude-pattern] (with angle brackets, not square brackets) +- Added support for PHP tokenizing of T_INLINE_ELSE colons, so this token type is now available + -- Custom sniffs that rely on looking for T_COLON tokens inside inline if statements must be changed to use the new token + -- Fixes bug #19666 : PSR1.Files.SideEffects throws a notice Undefined index: scope_closer +- Messages can now be changed from errors to warnings (and vice versa) inside ruleset.xml files + -- As you would with "message" and "severity", specify a "type" tag under a "rule" tag and set the value to "error" or "warning" +- PHP_CodeSniffer will now generate a warning on files that it detects have mixed line endings + -- This warning has the code Internal.LineEndings.Mixed and can be overriden in a ruleset.xml file + -- Thanks to Vit Brunner for help with this +- Sniffs inside PHP 5.3 namespaces are now supported, along with the existing underscore-style emulated namespaces + -- For example: namespace MyStandard\Sniffs\Arrays; class ArrayDeclarationSniff implements \PHP_CodeSniffer_Sniff { ... + -- Thanks to Till Klampaeckel for the patch +- Generic DuplicateClassNameSniff is no longer a multi-file sniff, so it won't max out your memory + -- Multi-file sniff support should be considered deprecated as standard sniffs can now do the same thing +- Added Generic DisallowSpaceIndent to check that files are indented using tabs +- Added Generic OneClassPerFileSniff to check that only one class is defined in each file + -- Thanks to Andy Grunwald for the contribution +- Added Generic OneInterfacePerFileSniff to check that only one interface is defined in each file + -- Thanks to Andy Grunwald for the contribution +- Added Generic LowercasedFilenameSniff to check that filenames are lowercase + -- Thanks to Andy Grunwald for the contribution +- Added Generic ClosingPHPTagSniff to check that each open PHP tag has a corresponding close tag + -- Thanks to Andy Grunwald for the contribution +- Added Generic CharacterBeforePHPOpeningTagSniff to check that the open PHP tag is the first content in a file + -- Thanks to Andy Grunwald for the contribution +- Fixed incorrect errors in Squiz OperatorBracketSniff and OperatorSpacingSniff for negative numbers in CASE statements + -- Thanks to Arnout Boks for the patch +- Generic CamelCapsFunctionNameSniff no longer enforces exact case matching for PHP magic methods +- Generic CamelCapsFunctionNameSniff no longer throws errors for overridden SOAPClient methods prefixed with double underscores + -- Thanks to Dorian Villet for the patch +- PEAR ValidFunctionNameSniff now supports traits +- PSR1 ClassDeclarationSniff no longer throws an error for non-namespaced code if PHP version is less than 5.3.0 +- Fixed bug #19616 : Nested switches cause false error in PSR2 +- Fixed bug #19629 : PSR2 error for inline comments on multi-line argument lists +- Fixed bug #19644 : Alternative syntax, e.g. if/endif triggers Inline Control Structure error +- Fixed bug #19655 : Closures reporting as multi-line when they are not +- Fixed bug #19675 : Improper indent of nested anonymous function bodies in a call +- Fixed bug #19685 : PSR2 catch-22 with empty third statement in for loop +- Fixed bug #19687 : Anonymous functions inside arrays marked as indented incorrectly in PSR2 + + + + + 1.4.0 + 1.4.0 + + + stable + stable + + 2012-09-26 + BSD License + +- Added PSR1 and PSR2 coding standards that can be used to check your code against these guidelines +- PHP 5.4 short array syntax is now detected and tokens are assigned to the open and close characters + -- New tokens are T_OPEN_SHORT_ARRAY and T_CLOSE_SHORT_ARRAY as PHP does not define its own +- Added the ability to explain a coding standard by listing the sniffs that it includes + -- The sniff list includes all imported and native sniffs + -- Explain a standard by using the -e and --standard=[standard] command line arguments + -- E.g., phpcs -e --standard=Squiz + -- Thanks to Ben Selby for the idea +- Added report to show results using notify-send + -- Use --report=notifysend to generate the report + -- Thanks to Christian Weiske for the contribution +- The JS tokenizer now recognises RETURN as a valid closer for CASE and DEFAULT inside switch statements +- AbstractPatternSniff now sets the ignoreComments option using a public var rather than through the constructor + -- This allows the setting to be overwritten in ruleset.xml files + -- Old method remains for backwards compatibility +- Generic LowerCaseConstantSniff and UpperCaseConstantSniff no longer report errors on classes named True, False or Null +- PEAR ValidFunctionNameSniff no longer enforces exact case matching for PHP magic methods +- Squiz SwitchDeclarationSniff now allows RETURN statements to close a CASE or DEFAULT statement +- Squiz BlockCommentSniff now correctly reports an error for blank lines before blocks at the start of a control structure +- Fixed a PHP notice generated when loading custom array settings from a rulset.xml file +- Fixed bug #17908 : CodeSniffer does not recognise optional @params + -- Thanks to Pete Walker for the patch +- Fixed bug #19538 : Function indentation code sniffer checks inside short arrays +- Fixed bug #19565 : Non-Executable Code Sniff Broken for Case Statements with both return and break +- Fixed bug #19612 : Invalid @package suggestion + + + + + 1.3.6 + 1.3.6 + + + stable + stable + + 2012-08-08 + BSD License + +- Memory usage has been dramatically reduced when using the summary report + -- Reduced memory is only available when displaying a single summary report to the screen + -- PHP_CodeSniffer will not generate any messages in this case, storing only error counts instead + -- Impact is most notable with very high error and warning counts +- Significantly improved the performance of Squiz NonExecutableCodeSniff +- Ignore patterns now check the relative path of a file based on the dir being checked + -- Allows ignore patterns to become more generic as the path to the code is no longer included when checking + -- Thanks to Kristof Coomans for the patch +- Sniff settings can now be changed by specifying a special comment format inside a file + -- e.g., // @codingStandardsChangeSetting PEAR.Functions.FunctionCallSignature allowMultipleArguments false + -- If you change a setting, don't forget to change it back +- Added Generic EndFileNewlineSniff to ensure PHP files end with a newline character +- PEAR FunctionCallSignatureSniff now includes a setting to force one argument per line in multi-line calls + -- Set allowMultipleArguments to false +- Squiz standard now enforces one argument per line in multi-line function calls +- Squiz FunctionDeclarationArgumentSpacingSniff now supports closures +- Squiz OperatorSpacingSniff no longer throws an error for negative values inside an inline THEN statement + -- Thanks to Klaus Purer for the patch +- Squiz FunctionCommentSniff now throws an error for not closing a comment with */ + -- Thanks to Klaus Purer for the patch +- Summary report no longer shows two lines of PHP_Timer output when showing sources +- Fixed undefined variable error in PEAR FunctionCallSignatureSniff for lines with no indent +- Fixed bug #19502 : Generic.Files.LineEndingsSniff fails if no new-lines in file +- Fixed bug #19508 : switch+return: Closing brace indented incorrectly +- Fixed bug #19532 : The PSR-2 standard don't recognize Null in class names +- Fixed bug #19546 : Error thrown for __call() method in traits + + + + + 1.3.5 + 1.3.5 + + + stable + stable + + 2012-07-12 + BSD License + +- Added Generic CamelCapsFunctionNameSniff to just check if function and method names use camel caps + -- Does not allow underscore prefixes for private/protected methods + -- Defaults to strict checking, where two uppercase characters can not be next to each other + -- Strict checking can be disabled in a ruleset.xml file +- Squiz FunctionDeclarationArgumentSpacing now has a setting to specify how many spaces should surround equals signs + -- Default remains at 0 + -- Override the equalsSpacing setting in a ruleset.xml file to change +- Squiz ClassDeclarationSniff now throws errors for > 1 space before extends/implements class name with ns seperator +- Squiz standard now warns about deprecated functions using Generic DeprecatedFunctionsSniff +- PEAR FunctionDeclarationSniff now reports an error for multiple spaces after the FUNCTION keyword and around USE +- PEAR FunctionDeclarationSniff now supports closures +- Squiz MultiLineFunctionDeclarationSniff now supports closures +- Exclude rules written for Unix systems will now work correctly on Windows + -- Thanks to Walter Tamboer for the patch +- The PHP tokenizer now recognises T_RETURN as a valid closer for T_CASE and T_DEFAULT inside switch statements +- Fixed duplicate message codes in Generic OpeningFunctionBraceKernighanRitchieSniff +- Fixed bug #18651 : PHPunit Test cases for custom standards are not working on Windows +- Fixed bug #19416 : Shorthand arrays cause bracket spacing errors +- Fixed bug #19421 : phpcs doesn't recognize ${x} as equivalent to $x +- Fixed bug #19428 : PHPCS Report "hgblame" doesn't support windows paths + -- Thanks to Justin Rovang for the patch +- Fixed bug #19448 : Problem with detecting remote standards +- Fixed bug #19463 : Anonymous functions incorrectly being flagged by NonExecutableCodeSniff +- Fixed bug #19469 : PHP_CodeSniffer_File::getMemberProperties() sets wrong scope +- Fixed bug #19471 : phpcs on Windows, when using Zend standard, doesn't catch problems + -- Thanks to Ivan Habunek for the patch +- Fixed bug #19478 : Incorrect indent detection in PEAR standard + -- Thanks to Shane Auckland for the patch +- Fixed bug #19483 : Blame Reports fail with space in directory name + + + + 1.3.4 1.3.4 @@ -1622,7 +2134,7 @@ stable 2012-05-17 - BSD License + BSD License - Added missing package.xml entries for new Generic FixmeSniff -- Thanks to Jaroslav HanslĂ­k for the patch @@ -1679,7 +2191,7 @@ stable 2012-02-17 - BSD License + BSD License - Added new Generic FixmeSniff that shows error messages for all FIXME comments left in your code -- Thanks to Sam Graham for the contribution @@ -1717,7 +2229,7 @@ stable 2011-12-01 - BSD License + BSD License - Added Generic JSHintSniff to run jshint.js over a JS file and report warnings -- Set jshint path using phpcs --config-set jshint_path /path/to/jshint-rhino.js @@ -1751,7 +2263,7 @@ stable 2011-11-03 - BSD License + BSD License - All report file command line arguments now work with relative paths (request #17240) - The extensions command line argument now supports multi-part file extensions (request #17227) @@ -1827,7 +2339,7 @@ stable 2011-03-17 - BSD License + BSD License - Add a new token T_CLOSURE that replaces T_FUNCTION if the function keyword is anonymous - Many Squiz sniffs no longer report errors when checking closures; they are now ignored @@ -1856,7 +2368,7 @@ beta 2011-01-14 - BSD License + BSD License - You can now print multiple reports for each run and print each to the screen or a file (request #12434) -- Format is --report-[report][=file] (e.g., --report-xml=out.xml) @@ -1933,7 +2445,7 @@ beta 2010-09-03 - BSD License + BSD License - Added exclude pattern support to ruleset.xml file so you can specify ignore patterns in a standard (request #17683) -- Use new exclude-pattern tags to include the ignore rules into your ruleset.xml file @@ -1974,7 +2486,7 @@ alpha 2010-07-15 - BSD License + BSD License - All CodingStandard.php files have been replaced by ruleset.xml files -- Custom standards will need to be converted over to this new format to continue working @@ -2028,7 +2540,7 @@ stable 2010-01-27 - BSD License + BSD License - The core PHP_CodeSniffer_File methods now understand the concept of closures (feature request #16866) -- Thanks to Christian Kaps for the sample code @@ -2105,7 +2617,7 @@ stable 2009-11-17 - BSD License + BSD License - Added a new report type --report=svnblame to show how many errors and warnings were committed by each author -- Also shows the percentage of their code that are errors and warnings @@ -2169,7 +2681,7 @@ stable 2009-08-17 - BSD License + BSD License - Installed standards are now favoured over custom standards when using the cmd line arg with relative paths - Unit tests now use a lot less memory while running @@ -2192,7 +2704,7 @@ beta 2009-07-07 - BSD License + BSD License - You can now use @codingStandardsIgnoreStart and @...End comments to suppress messages (feature request #14002) - A warning is now included for files without any code when short_open_tag is set to Off (feature request #12952) @@ -2212,7 +2724,7 @@ beta 2009-05-25 - BSD License + BSD License - Test suite can now be run using the full path to AllTests.php (feature request #16179) - Fixed bug #15980 : PHP_CodeSniffer change php current directory @@ -2234,7 +2746,7 @@ beta 2009-03-09 - BSD License + BSD License - Reports that are output to a file now include a trailing newline at the end of the file - Fixed sniff names not shown in -vvv token processing output @@ -2268,7 +2780,7 @@ alpha 2008-12-18 - BSD License + BSD License - PHP_CodeSniffer now has a CSS tokenizer for checking CSS files - Added support for a new multi-file sniff that sniffs all processed files at once @@ -2387,7 +2899,7 @@ stable 2008-07-14 - BSD License + BSD License - PEAR FileCommentSniff now allows tag orders to be overridden in child classes -- Thanks to Jeff Hodsdon for the patch @@ -2412,7 +2924,7 @@ beta 2008-07-03 - BSD License + BSD License - PEAR FileCommentSniff now allows tag orders to be overridden in child classes -- Thanks to Jeff Hodsdon for the patch @@ -2437,7 +2949,7 @@ beta 2008-06-13 - BSD License + BSD License - Permission denied errors now stop script execution but still display current errors (feature request #14076) - Added Squiz ValidArrayIndexNameSniff to ensure array indexes do not use camel case @@ -2460,7 +2972,7 @@ beta 2008-05-13 - BSD License + BSD License - Added support for multiple tokenizers so PHP_CodeSniffer can check more than just PHP files -- PHP_CodeSniffer now has a JS tokenizer for checking JavaScript files @@ -2533,7 +3045,7 @@ alpha 2008-04-21 - BSD License + BSD License - Fixed error in PEAR ValidClassNameSniff when checking class names with double underscores - Moved Squiz InlineControlStructureSniff into Generic standard @@ -2559,7 +3071,7 @@ stable 2008-02-04 - BSD License + BSD License - Squiz ArrayDeclarationSniff now throws error if the array keyword is followed by a space - Squiz ArrayDeclarationSniff now throws error for empty multi-line arrays @@ -2597,7 +3109,7 @@ stable 2007-12-21 - BSD License + BSD License - You can now specify the full path to a coding standard on the command line (feature request #11886) -- This allows you to use standards that are stored outside of PHP_CodeSniffer's own Standard dir @@ -2636,7 +3148,7 @@ beta 2007-11-30 - BSD License + BSD License - Added new command line argument --tab-width that will convert tabs to spaces before testing -- This allows you to use the existing sniffs that check for spaces even when you use tabs @@ -2673,7 +3185,7 @@ beta 2007-11-14 - BSD License + BSD License - Added a new Checkstyle report format -- Like the current XML format but modified to look like Checkstyle output @@ -2713,7 +3225,7 @@ beta 2007-11-01 - BSD License + BSD License - Main phpcs script can now be run from a CVS checkout without installing the package - Added a new CSV report format @@ -2771,7 +3283,7 @@ beta 2007-09-24 - BSD License + BSD License - Added a config system for setting config data across phpcs runs - You can now change the default coding standard from PEAR to something else @@ -2793,7 +3305,7 @@ beta 2007-08-08 - BSD License + BSD License - Added new XML report format; --report=xml (feature request #11535) -- Thanks to Brett Bieber for the patch @@ -2827,7 +3339,7 @@ beta 2007-07-02 - BSD License + BSD License - BC BREAK: EOL character is now auto-detected and used instead of hard-coded \n -- Pattern sniffs must now specify "EOL" instead of "\n" or "\r\n" to use auto-detection @@ -2883,7 +3395,7 @@ beta 2007-05-15 - BSD License + BSD License - The number of errors and warnings found is now shown for each file while checking the file if verbosity is enabled - Now using PHP_EOL instead of hard-coded \n so output looks good on Windows (feature request #10761) @@ -2909,7 +3421,7 @@ beta 2007-04-17 - BSD License + BSD License - BC BREAK: Coding standards now require a class to be added so PHP_CodeSniffer can get information from them - Please read the end user docs for info about the new class required for all coding standards @@ -2949,7 +3461,7 @@ beta 2007-02-19 - BSD License + BSD License - Standard name specified with --standard command line argument is no longer case sensitive - Long error and warning messages are now wrapped to 80 characters in the full error report (thanks Endre Czirbesz) @@ -2975,7 +3487,7 @@ beta 2007-01-11 - BSD License + BSD License - Updated package.xml to version 2 - Specifying coding standard on command line is now optional, even if you have multiple standards installed @@ -3009,7 +3521,7 @@ alpha 2006-11-09 - BSD License + BSD License - Fixed bug #9274 : nested_parenthesis element not set for open and close parenthesis tokens @@ -3024,7 +3536,7 @@ alpha 2006-10-13 - BSD License + BSD License - Added a generic standards package that will contain generic sniffs to be used in specific coding standards - thanks to Frederic Poeydomenge for the idea @@ -3058,7 +3570,7 @@ alpha 2006-09-25 - BSD License + BSD License - Added unit tests for all PEAR sniffs - Exception class now extends from PEAR_Exception @@ -3075,7 +3587,7 @@ alpha 2006-09-19 - BSD License + BSD License - Reorganised package contents to conform to PEAR standards - Changed version numbering to conform to PEAR standards @@ -3092,7 +3604,7 @@ alpha 2006-09-18 - BSD License + BSD License - Fixed .bat file for situation where php.ini cannot be found so include_path is not set @@ -3107,7 +3619,7 @@ alpha 2006-08-28 - BSD License + BSD License - Added .bat file for easier running of PHP_CodeSniffer on Windows - Sniff that checks method names now works for PHP4 style code where there is no scope keyword @@ -3136,7 +3648,7 @@ alpha 2006-08-22 - BSD License + BSD License - Added sniff to check for invalid class and interface names - Added sniff to check for invalid function and method names @@ -3156,7 +3668,7 @@ alpha 2006-07-25 - BSD License + BSD License - Removed the including of checked files to stop errors caused by parsing them - Removed the use of reflection so checked files do not have to be included @@ -3184,7 +3696,7 @@ alpha 2006-07-19 - BSD License + BSD License Initial preview release.