]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-19247 Added detection of closing php tag, improved CLI tool and started clean...
authornicolasconnault <nicolasconnault>
Wed, 20 May 2009 10:49:59 +0000 (10:49 +0000)
committernicolasconnault <nicolasconnault>
Wed, 20 May 2009 10:49:59 +0000 (10:49 +0000)
42 files changed:
lib/pear/PHP/CodeSniffer/MoodleCLI.php
lib/pear/PHP/CodeSniffer/Standards/Moodle/MoodleCodingStandard.php
lib/pear/PHP/CodeSniffer/Standards/Moodle/Sniffs/Classes/ClassDeclarationSniff.php
lib/pear/PHP/CodeSniffer/Standards/Moodle/Sniffs/CodeAnalysis/EmptyStatementSniff.php
lib/pear/PHP/CodeSniffer/Standards/Moodle/Sniffs/CodeAnalysis/ForLoopShouldBeWhileLoopSniff.php
lib/pear/PHP/CodeSniffer/Standards/Moodle/Sniffs/CodeAnalysis/ForLoopWithTestFunctionCallSniff.php
lib/pear/PHP/CodeSniffer/Standards/Moodle/Sniffs/CodeAnalysis/JumbledIncrementerSniff.php
lib/pear/PHP/CodeSniffer/Standards/Moodle/Sniffs/CodeAnalysis/UnconditionalIfStatementSniff.php
lib/pear/PHP/CodeSniffer/Standards/Moodle/Sniffs/CodeAnalysis/UnnecessaryFinalModifierSniff.php
lib/pear/PHP/CodeSniffer/Standards/Moodle/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php
lib/pear/PHP/CodeSniffer/Standards/Moodle/Sniffs/CodeAnalysis/UselessOverridingMethodSniff.php
lib/pear/PHP/CodeSniffer/Standards/Moodle/Sniffs/Commenting/ClassCommentSniff.php
lib/pear/PHP/CodeSniffer/Standards/Moodle/Sniffs/Commenting/FileCommentSniff.php
lib/pear/PHP/CodeSniffer/Standards/Moodle/Sniffs/Commenting/FunctionCommentSniff.php
lib/pear/PHP/CodeSniffer/Standards/Moodle/Sniffs/Commenting/InlineCommentSniff.php
lib/pear/PHP/CodeSniffer/Standards/Moodle/Sniffs/ControlStructures/ControlSignatureSniff.php
lib/pear/PHP/CodeSniffer/Standards/Moodle/Sniffs/ControlStructures/ElseIfDeclarationSniff.php
lib/pear/PHP/CodeSniffer/Standards/Moodle/Sniffs/ControlStructures/InlineControlStructureSniff.php
lib/pear/PHP/CodeSniffer/Standards/Moodle/Sniffs/Files/ClosingPHPTagSniff.php [new file with mode: 0644]
lib/pear/PHP/CodeSniffer/Standards/Moodle/Sniffs/Files/IncludingFileSniff.php
lib/pear/PHP/CodeSniffer/Standards/Moodle/Sniffs/Files/LineEndingsSniff.php
lib/pear/PHP/CodeSniffer/Standards/Moodle/Sniffs/Files/LineLengthSniff.php
lib/pear/PHP/CodeSniffer/Standards/Moodle/Sniffs/Formatting/SpaceAfterCastSniff.php
lib/pear/PHP/CodeSniffer/Standards/Moodle/Sniffs/Functions/FunctionCallArgumentSpacingSniff.php
lib/pear/PHP/CodeSniffer/Standards/Moodle/Sniffs/Functions/FunctionCallSignatureSniff.php
lib/pear/PHP/CodeSniffer/Standards/Moodle/Sniffs/Functions/FunctionDeclarationSniff.php
lib/pear/PHP/CodeSniffer/Standards/Moodle/Sniffs/Functions/LowercaseFunctionKeywordsSniff.php
lib/pear/PHP/CodeSniffer/Standards/Moodle/Sniffs/Functions/ValidDefaultValueSniff.php
lib/pear/PHP/CodeSniffer/Standards/Moodle/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php
lib/pear/PHP/CodeSniffer/Standards/Moodle/Sniffs/NamingConventions/ValidClassNameSniff.php
lib/pear/PHP/CodeSniffer/Standards/Moodle/Sniffs/NamingConventions/ValidFunctionNameSniff.php
lib/pear/PHP/CodeSniffer/Standards/Moodle/Sniffs/NamingConventions/ValidVariableNameSniff.php
lib/pear/PHP/CodeSniffer/Standards/Moodle/Sniffs/PHP/DisallowShortOpenTagSniff.php
lib/pear/PHP/CodeSniffer/Standards/Moodle/Sniffs/PHP/LowerCaseConstantSniff.php
lib/pear/PHP/CodeSniffer/Standards/Moodle/Sniffs/PHP/LowercasePHPFunctionsSniff.php
lib/pear/PHP/CodeSniffer/Standards/Moodle/Sniffs/Strings/DoubleQuoteUsageSniff.php
lib/pear/PHP/CodeSniffer/Standards/Moodle/Sniffs/Strings/EchoedStringsSniff.php
lib/pear/PHP/CodeSniffer/Standards/Moodle/Sniffs/WhiteSpace/DisallowTabIndentSniff.php
lib/pear/PHP/CodeSniffer/Standards/Moodle/Sniffs/WhiteSpace/MemberVarSpacingSniff.php
lib/pear/PHP/CodeSniffer/Standards/Moodle/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php
lib/pear/PHP/CodeSniffer/Standards/Moodle/Sniffs/WhiteSpace/ScopeIndentSniff.php
lib/pear/PHP/runsniffer

index 781edb85cd1bdb8965694b7225bba95e96adcedb..a2064b859b4550c05416133b8cee563567670108 100644 (file)
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
-if (is_file(dirname(__FILE__).'/../MoodleCodeSniffer.php') === true) {
-    include_once(dirname(__FILE__).'/../MoodleCodeSniffer.php');
-} else {
-    include_once('PHP/MoodleCodeSniffer.php');
-}
-
+include_once('PHP/MoodleCodeSniffer.php');
 require_once('PHP/CodeSniffer/CLI.php');
 
 /**
- * A class to process command line phpcs scripts. Modified for use within Moodle
+ * A class to process command line runsniffer scripts. Modified for use within Moodle
  *
  * @category  lib-pear-php-codesniffer
  * @copyright 2009 Nicolas Connault
@@ -59,7 +54,7 @@ class moodle_codesniffer_cli extends php_codesniffer_cli {
      * @return void
      */
     public function printusage() {
-        echo 'Usage: phpcs [-nwlvi] [--report=<report>]'.PHP_EOL;
+        echo 'Usage: runsniffer [-nwlvi] [--report=<report>]'.PHP_EOL;
         echo '    [--config-set key value] [--config-delete key] [--config-show]'.PHP_EOL;
         echo '    [--generator=<generator>] [--extensions=<extensions>]'.PHP_EOL;
         echo '    [--ignore=<patterns>] [--tab-width=<width>] <file> ...'.PHP_EOL;
@@ -82,6 +77,39 @@ class moodle_codesniffer_cli extends php_codesniffer_cli {
         echo '                     "csv" or "summary" report'.PHP_EOL;
         echo '                     (the "full" report is printed by default)'.PHP_EOL;
 
-    }//end printUsage()
+    }
+
+    /**
+     * Processes an unknown command line argument.
+     *
+     * Overriding CLI method to allow for dynamic loading of path to requested file/directory
+     *
+     * @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) {
+        global $args, $argv, $argc;
+
+        // 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 = $_SERVER['PWD'] . '/' . $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;
+    }
 }
index 51f135cf55135e4a2dd64b5ff493f53e8abc3d79..bf264eb7616af9f4247ec3629f56f45df95eec1d 100644 (file)
@@ -1,15 +1,27 @@
 <?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 /**
- * Moodle Coding Standard.
+ * Subclass of lib/pear/PHP/CodeSniffer/CLI.php
  *
- * PHP version 5
+ * Simple modifications to the CLI class to only use the Moodle Standard
  *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Nicolas Connault <nicolasconnault@gmail.com>
+ * @package   lib-pear-php-codesniffer
+ * @copyright 2008 Nicolas Connault
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @version   CVS: $Id$
- * @link      http://pear.php.net/package/PHP_CodeSniffer
  */
 
 if (class_exists('PHP_CodeSniffer_Standards_CodingStandard', true) === false) {
@@ -26,13 +38,22 @@ if (class_exists('PHP_CodeSniffer_Standards_CodingStandard', true) === false) {
  * @version   Release: @package_version@
  * @link      http://pear.php.net/package/PHP_CodeSniffer
  */
-class PHP_CodeSniffer_Standards_Moodle_MoodleCodingStandard extends PHP_CodeSniffer_Standards_CodingStandard {
-    public function getIncludedSniffs() {
+class php_codesniffer_standards_moodle_moodlecodingstandard extends php_codesniffer_standards_codingstandard {
+    /**
+     * To include additional sniffs in this standard, add their paths to this method's return array
+     *
+     * @return array
+     */
+    public function getincludedsniffs() {
         return array();
     }
 
-    public function getExcludedSniffs() {
+    /**
+     * To exclude included sniffs from this standard, add their paths to this method's return array
+     *
+     * @return array
+     */
+    public function getexcludedsniffs() {
         return array('Moodle/Sniffs/CodeAnalysis');
     }
-}//end class
-?>
+}
index 8ddc123fd3432bbc5efe5d427322592b45518c0c..cca131a436e4817990679f2df0a05626e595db88 100644 (file)
@@ -1,17 +1,25 @@
 <?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 /**
- * Class Declaration Test.
- *
- * PHP version 5
+ * File containing the Class Declaration Test.
  *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Nicolas Connault <nicolasconnault@gmail.com>
- *
- * @copyright 2009 Nicolas Connault
+ * @package   lib-pear-php-codesniffer-standards-moodle-sniffs-classes
+ * @copyright 2008 Nicolas Connault
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @version   CVS: $Id$
- * @link      http://pear.php.net/package/PHP_CodeSniffer
  */
 
 /**
  *
  * Checks the declaration of the class is correct.
  *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Nicolas Connault <nicolasconnault@gmail.com>
- *
  * @copyright 2009 Nicolas Connault
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @version   Release: 1.1.0
- * @link      http://pear.php.net/package/PHP_CodeSniffer
  */
-class Moodle_Sniffs_Classes_ClassDeclarationSniff implements PHP_CodeSniffer_Sniff
+class moodle_sniffs_classes_classdeclarationsniff implements php_codesniffer_sniff
 {
 
 
@@ -44,57 +46,57 @@ class Moodle_Sniffs_Classes_ClassDeclarationSniff implements PHP_CodeSniffer_Sni
                 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
+     * @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)
+    public function process(PHP_CodeSniffer_File $phpcsfile, $stackptr)
     {
-        $tokens = $phpcsFile->getTokens();
+        $tokens = $phpcsfile->gettokens();
 
-        if (isset($tokens[$stackPtr]['scope_opener']) === false) {
+        if (isset($tokens[$stackptr]['scope_opener']) === false) {
             $error  = 'Possible parse error: ';
-            $error .= $tokens[$stackPtr]['content'];
+            $error .= $tokens[$stackptr]['content'];
             $error .= ' missing opening or closing brace';
-            $phpcsFile->addWarning($error, $stackPtr);
+            $phpcsfile->addwarning($error, $stackptr);
             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) {
+        $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 ';
-            $error .= $tokens[$stackPtr]['content'];
+            $error .= $tokens[$stackptr]['content'];
             $error .= ' must be on the same line as the definition';
-            $phpcsFile->addError($error, $curlyBrace);
+            $phpcsfile->adderror($error, $curlyBrace);
             return;
         }
 
         if ($tokens[($curlyBrace - 1)]['code'] === T_WHITESPACE) {
-            $prevContent = $tokens[($curlyBrace - 1)]['content'];
-            if ($prevContent !== $phpcsFile->eolChar) {
-                $blankSpace = substr($prevContent, strpos($prevContent, $phpcsFile->eolChar));
+            $prevcontent = $tokens[($curlyBrace - 1)]['content'];
+            if ($prevcontent !== $phpcsfile->eolChar) {
+                $blankSpace = substr($prevcontent, strpos($prevcontent, $phpcsfile->eolChar));
                 $spaces     = strlen($blankSpace);
                 if ($spaces !== 1) {
                     $error = "Expected 1 space before opening brace; $spaces found";
-                    $phpcsFile->addError($error, $curlyBrace);
+                    $phpcsfile->adderror($error, $curlyBrace);
                 }
             }
         }
 
-    }//end process()
+    }
 
 
-}//end class
+}
 
 ?>
index ad2ada4c536ab59101c2a895668957dee2428254..42b43ddd2b17d91f43c9f5addf1829631e37b78f 100644 (file)
@@ -1,17 +1,25 @@
 <?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 /**
- * This file is part of the CodeAnalysis addon for PHP_CodeSniffer.
- *
- * PHP version 5
+ * File containing the moodle_sniffs_codeanalysis_emptystatementsniff Class
  *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Nicolas Connault <nicolasconnault@gmail.com>
- * @author    Manuel Pichler <mapi@manuel-pichler.de>
- * @copyright 2007-2008 Manuel Pichler. All rights reserved.
- * @license   http://www.opensource.org/licenses/bsd-license.php  BSD License
- * @version   CVS: $Id$
- * @link      http://pear.php.net/package/PHP_CodeSniffer
+ * @package   lib-pear-php-codesniffer-standards-moodle-sniffs-codeanalysis
+ * @copyright 2008 Nicolas Connault
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
 /**
  * <b>elsif</b>, <b>for</b>, <b>foreach<b>, <b>if</b>, <b>switch</b>, <b>try</b>
  * and <b>while</b>.
  *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Manuel Pichler <mapi@manuel-pichler.de>
- * @copyright 2007-2008 Manuel Pichler. All rights reserved.
- * @license   http://www.opensource.org/licenses/bsd-license.php  BSD License
- * @version   Release: 1.1.0
- * @link      http://pear.php.net/package/PHP_CodeSniffer
+ * @copyright 2008 Nicolas Connault
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
-class Moodle_Sniffs_CodeAnalysis_EmptyStatementSniff implements PHP_CodeSniffer_Sniff
+class moodle_sniffs_codeanalysis_emptystatementsniff implements php_codesniffer_sniff
 {
 
     /**
@@ -77,22 +80,22 @@ class Moodle_Sniffs_CodeAnalysis_EmptyStatementSniff implements PHP_CodeSniffer_
     {
         return array_keys($this->_tokens);
 
-    }//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
+     * @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)
+    public function process(PHP_CodeSniffer_File $phpcsfile, $stackptr)
     {
-        $tokens = $phpcsFile->getTokens();
-        $token  = $tokens[$stackPtr];
+        $tokens = $phpcsfile->gettokens();
+        $token  = $tokens[$stackptr];
 
         // Skip for-statements without body.
         if (isset($token['scope_opener']) === false) {
@@ -104,7 +107,7 @@ class Moodle_Sniffs_CodeAnalysis_EmptyStatementSniff implements PHP_CodeSniffer_
 
         $emptyBody = true;
         for (; $next <= $end; ++$next) {
-            if (in_array($tokens[$next]['code'], PHP_CodeSniffer_Tokens::$emptyTokens) === false) {
+            if (in_array($tokens[$next]['code'], PHP_CodeSniffer_tokens::$emptyTokens) === false) {
                 $emptyBody = false;
                 break;
             }
@@ -112,18 +115,18 @@ class Moodle_Sniffs_CodeAnalysis_EmptyStatementSniff implements PHP_CodeSniffer_
 
         if ($emptyBody === true) {
             // Get token identifier.
-            $name  = $phpcsFile->getTokensAsString($stackPtr, 1);
+            $name  = $phpcsfile->gettokensAsString($stackptr, 1);
             $error = sprintf('Empty %s statement detected', strtoupper($name));
             if ($this->_tokens[$token['code']] === true) {
-                $phpcsFile->addError($error, $stackPtr);
+                $phpcsfile->adderror($error, $stackptr);
             } else {
-                $phpcsFile->addWarning($error, $stackPtr);
+                $phpcsfile->addwarning($error, $stackptr);
             }
         }
 
-    }//end process()
+    }
 
 
-}//end class
+}
 
 ?>
index 159e7b3b160ac78eabe5c77e5e99a2303e9ffd54..89966fbd1a3a57a0f1f5b1c77a982f83d7ab8e1e 100644 (file)
@@ -1,17 +1,25 @@
 <?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 /**
  * This file is part of the CodeAnalysis addon for PHP_CodeSniffer.
  *
- * PHP version 5
- *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Nicolas Connault <nicolasconnault@gmail.com>
- * @author    Manuel Pichler <mapi@manuel-pichler.de>
- * @copyright 2007-2008 Manuel Pichler. All rights reserved.
- * @license   http://www.opensource.org/licenses/bsd-license.php  BSD License
- * @version   CVS: $Id$
- * @link      http://pear.php.net/package/PHP_CodeSniffer
+ * @package   lib-pear-php-codesniffer-standards-moodle-sniffs-codeanalysis
+ * @copyright 2008 Nicolas Connault
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
 /**
  * }
  * </code>
  *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Manuel Pichler <mapi@manuel-pichler.de>
- * @copyright 2007-2008 Manuel Pichler. All rights reserved.
- * @license   http://www.opensource.org/licenses/bsd-license.php  BSD License
- * @version   Release: 1.1.0
- * @link      http://pear.php.net/package/PHP_CodeSniffer
+ * @copyright 2008 Nicolas Connault
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
-class Moodle_Sniffs_CodeAnalysis_ForLoopShouldBeWhileLoopSniff implements PHP_CodeSniffer_Sniff
+class moodle_sniffs_codeanalysis_forloopshouldbewhileloopsniff implements php_codesniffer_sniff
 {
 
 
@@ -51,22 +54,22 @@ class Moodle_Sniffs_CodeAnalysis_ForLoopShouldBeWhileLoopSniff implements PHP_Co
     {
         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
+     * @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)
+    public function process(PHP_CodeSniffer_File $phpcsfile, $stackptr)
     {
-        $tokens = $phpcsFile->getTokens();
-        $token  = $tokens[$stackPtr];
+        $tokens = $phpcsfile->gettokens();
+        $token  = $tokens[$stackptr];
 
         // Skip invalid statement.
         if (isset($token['parenthesis_opener']) === false) {
@@ -83,19 +86,19 @@ class Moodle_Sniffs_CodeAnalysis_ForLoopShouldBeWhileLoopSniff implements PHP_Co
             $code = $tokens[$next]['code'];
             if ($code === T_SEMICOLON) {
                 ++$index;
-            } else if (in_array($code, PHP_CodeSniffer_Tokens::$emptyTokens) === false) {
+            } 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);
+            $phpcsfile->addwarning($error, $stackptr);
         }
 
-    }//end process()
+    }
 
 
-}//end class
+}
 
 ?>
index 7977f55897ce2ced684427710f044c1125aec5a9..5a77f699395ed932b665ca76ace34276796e4aec 100644 (file)
@@ -1,17 +1,25 @@
 <?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 /**
  * This file is part of the CodeAnalysis addon for PHP_CodeSniffer.
  *
- * PHP version 5
- *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Nicolas Connault <nicolasconnault@gmail.com>
- * @author    Manuel Pichler <mapi@manuel-pichler.de>
- * @copyright 2007-2008 Manuel Pichler. All rights reserved.
- * @license   http://www.opensource.org/licenses/bsd-license.php  BSD License
- * @version   CVS: $Id$
- * @link      http://pear.php.net/package/PHP_CodeSniffer
+ * @package   lib-pear-php-codesniffer-standards-moodle-sniffs-codeanalysis
+ * @copyright 2008 Nicolas Connault
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
 /**
  * }
  * </code>
  *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Manuel Pichler <mapi@manuel-pichler.de>
- * @copyright 2007-2008 Manuel Pichler. All rights reserved.
- * @license   http://www.opensource.org/licenses/bsd-license.php BSD License
- * @version   Release: 1.1.0
- * @link      http://pear.php.net/package/PHP_CodeSniffer
+ * @copyright 2008 Nicolas Connault
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
-class Moodle_Sniffs_CodeAnalysis_ForLoopWithTestFunctionCallSniff implements PHP_CodeSniffer_Sniff
+class moodle_sniffs_codeanalysis_forloopwithtestfunctioncallsniff implements php_codesniffer_sniff
 {
 
 
@@ -54,22 +57,22 @@ class Moodle_Sniffs_CodeAnalysis_ForLoopWithTestFunctionCallSniff implements PHP
     {
         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
+     * @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)
+    public function process(PHP_CodeSniffer_File $phpcsfile, $stackptr)
     {
-        $tokens = $phpcsFile->getTokens();
-        $token  = $tokens[$stackPtr];
+        $tokens = $phpcsfile->gettokens();
+        $token  = $tokens[$stackptr];
 
         // Skip invalid statement.
         if (isset($token['parenthesis_opener']) === false) {
@@ -97,18 +100,18 @@ class Moodle_Sniffs_CodeAnalysis_ForLoopWithTestFunctionCallSniff implements PHP
 
             // 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);
+            $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);
+                $phpcsfile->addwarning($error, $stackptr);
                 break;
             }
-        }//end for
+        }
 
-    }//end process()
+    }
 
 
-}//end class
+}
 
 ?>
index d1c08a5e47b4336f6acfc8b7d88921745a022115..0a17fe2a10bb5d29e8854d85224c0db280dca107 100644 (file)
@@ -1,17 +1,25 @@
 <?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 /**
  * This file is part of the CodeAnalysis addon for PHP_CodeSniffer.
  *
- * PHP version 5
- *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Nicolas Connault <nicolasconnault@gmail.com>
- * @author    Manuel Pichler <mapi@manuel-pichler.de>
- * @copyright 2007-2008 Manuel Pichler. All rights reserved.
- * @license   http://www.opensource.org/licenses/bsd-license.php BSD License
- * @version   CVS: $Id$
- * @link      http://pear.php.net/package/PHP_CodeSniffer
+ * @package   lib-pear-php-codesniffer-standards-moodle-sniffs-codeanalysis
+ * @copyright 2008 Nicolas Connault
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
 /**
  * }
  * </code>
  *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Manuel Pichler <mapi@manuel-pichler.de>
- * @copyright 2007-2008 Manuel Pichler. All rights reserved.
- * @license   http://www.opensource.org/licenses/bsd-license.php BSD License
- * @version   Release: 1.1.0
- * @link      http://pear.php.net/package/PHP_CodeSniffer
+ * @copyright 2008 Nicolas Connault
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
-class Moodle_Sniffs_CodeAnalysis_JumbledIncrementerSniff implements PHP_CodeSniffer_Sniff
+class moodle_sniffs_codeanalysis_jumbledincrementersniff implements php_codesniffer_sniff
 {
 
 
@@ -58,22 +61,22 @@ class Moodle_Sniffs_CodeAnalysis_JumbledIncrementerSniff implements PHP_CodeSnif
     {
         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
+     * @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)
+    public function process(PHP_CodeSniffer_File $phpcsfile, $stackptr)
     {
-        $tokens = $phpcsFile->getTokens();
-        $token  = $tokens[$stackPtr];
+        $tokens = $phpcsfile->gettokens();
+        $token  = $tokens[$stackptr];
 
         // Skip for-loop without body.
         if (isset($token['scope_opener']) === false) {
@@ -102,11 +105,11 @@ class Moodle_Sniffs_CodeAnalysis_JumbledIncrementerSniff implements PHP_CodeSnif
 
             if (count($diff) !== 0) {
                 $error = sprintf('Loop incrementor (%s) jumbling with inner loop', join(', ', $diff));
-                $phpcsFile->addWarning($error, $stackPtr);
+                $phpcsfile->addwarning($error, $stackptr);
             }
         }
 
-    }//end process()
+    }
 
 
     /**
@@ -140,9 +143,9 @@ class Moodle_Sniffs_CodeAnalysis_JumbledIncrementerSniff implements PHP_CodeSnif
 
         return $incrementers;
 
-    }//end findIncrementers()
+    }
 
 
-}//end class
+}
 
 ?>
index 8f0b4639b3ec80ab49abfb226ae4e123b11ea147..bd3f019dfea5c59509c0f077c628802738737e1d 100644 (file)
@@ -1,17 +1,25 @@
 <?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 /**
  * This file is part of the CodeAnalysis addon for PHP_CodeSniffer.
  *
- * PHP version 5
- *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Nicolas Connault <nicolasconnault@gmail.com>
- * @author    Manuel Pichler <mapi@manuel-pichler.de>
- * @copyright 2007-2008 Manuel Pichler. All rights reserved.
- * @license   http://www.opensource.org/licenses/bsd-license.php BSD License
- * @version   CVS: $Id$
- * @link      http://pear.php.net/package/PHP_CodeSniffer
+ * @package   lib-pear-php-codesniffer-standards-moodle-sniffs-codeanalysis
+ * @copyright 2008 Nicolas Connault
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
 /**
  * }
  * </code>
  *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Manuel Pichler <mapi@manuel-pichler.de>
- * @copyright 2007-2008 Manuel Pichler. All rights reserved.
- * @license   http://www.opensource.org/licenses/bsd-license.php BSD License
- * @version   Release: 1.1.0
- * @link      http://pear.php.net/package/PHP_CodeSniffer
+ * @copyright 2008 Nicolas Connault
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
-class Moodle_Sniffs_CodeAnalysis_UnconditionalIfStatementSniff implements PHP_CodeSniffer_Sniff
+class moodle_sniffs_codeanalysis_unconditionalifstatementsniff implements php_codesniffer_sniff
 {
 
 
@@ -58,22 +61,22 @@ class Moodle_Sniffs_CodeAnalysis_UnconditionalIfStatementSniff implements PHP_Co
                 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
+     * @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)
+    public function process(PHP_CodeSniffer_File $phpcsfile, $stackptr)
     {
-        $tokens = $phpcsFile->getTokens();
-        $token  = $tokens[$stackPtr];
+        $tokens = $phpcsfile->gettokens();
+        $token  = $tokens[$stackptr];
 
         // Skip for-loop without body.
         if (isset($token['parenthesis_opener']) === false) {
@@ -87,7 +90,7 @@ class Moodle_Sniffs_CodeAnalysis_UnconditionalIfStatementSniff implements PHP_Co
         for (; $next <= $end; ++$next) {
             $code = $tokens[$next]['code'];
 
-            if (in_array($code, PHP_CodeSniffer_Tokens::$emptyTokens) === true) {
+            if (in_array($code, PHP_CodeSniffer_tokens::$emptyTokens) === true) {
                 continue;
             } else if ($code !== T_TRUE && $code !== T_FALSE) {
                 $goodCondition = true;
@@ -96,12 +99,12 @@ class Moodle_Sniffs_CodeAnalysis_UnconditionalIfStatementSniff implements PHP_Co
 
         if ($goodCondition === false) {
             $error = 'Avoid IF statements that are always true or false';
-            $phpcsFile->addWarning($error, $stackPtr);
+            $phpcsfile->addwarning($error, $stackptr);
         }
 
-    }//end process()
+    }
 
 
-}//end class
+}
 
 ?>
index 9ad3fbc1835a7b1390f1b6f96fc865a964b83d0d..b10400349c6ae60674b20bf90278a5825bb2dfea 100644 (file)
@@ -1,17 +1,25 @@
 <?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 /**
  * This file is part of the CodeAnalysis addon for PHP_CodeSniffer.
  *
- * PHP version 5
- *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Nicolas Connault <nicolasconnault@gmail.com>
- * @author    Manuel Pichler <mapi@manuel-pichler.de>
- * @copyright 2007-2008 Manuel Pichler. All rights reserved.
- * @license   http://www.opensource.org/licenses/bsd-license.php BSD License
- * @version   CVS: $Id$
- * @link      http://pear.php.net/package/PHP_CodeSniffer
+ * @package   lib-pear-php-codesniffer-standards-moodle-sniffs-codeanalysis
+ * @copyright 2008 Nicolas Connault
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
 /**
  * }
  * </code>
  *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Manuel Pichler <mapi@manuel-pichler.de>
- * @copyright 2007-2008 Manuel Pichler. All rights reserved.
- * @license   http://www.opensource.org/licenses/bsd-license.php BSD License
- * @version   Release: 1.1.0
- * @link      http://pear.php.net/package/PHP_CodeSniffer
+ * @copyright 2008 Nicolas Connault
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
-class Moodle_Sniffs_CodeAnalysis_UnnecessaryFinalModifierSniff implements PHP_CodeSniffer_Sniff
+class moodle_sniffs_codeanalysis_unnecessaryfinalmodifiersniff implements php_codesniffer_sniff
 {
 
 
@@ -51,22 +54,22 @@ class Moodle_Sniffs_CodeAnalysis_UnnecessaryFinalModifierSniff implements PHP_Co
     {
         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
+     * @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)
+    public function process(PHP_CodeSniffer_File $phpcsfile, $stackptr)
     {
-        $tokens = $phpcsFile->getTokens();
-        $token  = $tokens[$stackPtr];
+        $tokens = $phpcsfile->gettokens();
+        $token  = $tokens[$stackptr];
 
         // Skip for-statements without body.
         if (isset($token['scope_opener']) === false) {
@@ -74,7 +77,7 @@ class Moodle_Sniffs_CodeAnalysis_UnnecessaryFinalModifierSniff implements PHP_Co
         }
 
         // Fetch previous token.
-        $prev = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true);
+        $prev = $phpcsfile->findPrevious(PHP_CodeSniffer_tokens::$emptyTokens, ($stackptr - 1), null, true);
 
         // Skip for non final class.
         if ($prev === false || $tokens[$prev]['code'] !== T_FINAL) {
@@ -87,13 +90,13 @@ class Moodle_Sniffs_CodeAnalysis_UnnecessaryFinalModifierSniff implements PHP_Co
         for (; $next <= $end; ++$next) {
             if ($tokens[$next]['code'] === T_FINAL) {
                 $error = 'Unnecessary FINAL modifier in FINAL class';
-                $phpcsFile->addWarning($error, $next);
+                $phpcsfile->addwarning($error, $next);
             }
         }
 
-    }//end process()
+    }
 
 
-}//end class
+}
 
 ?>
index 244aa09cef33a9e3cbb7de88e527f7eacf88234c..caf2bc03776144ec39d77f47f8abaecb81c3ac44 100644 (file)
@@ -1,17 +1,25 @@
 <?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 /**
  * This file is part of the CodeAnalysis addon for PHP_CodeSniffer.
  *
- * PHP version 5
- *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Nicolas Connault <nicolasconnault@gmail.com>
- * @author    Manuel Pichler <mapi@manuel-pichler.de>
- * @copyright 2009 Nicolas Connault
- * @license   http://www.opensource.org/licenses/bsd-license.php BSD License
- * @version   CVS: $Id$
- * @link      http://pear.php.net/package/PHP_CodeSniffer
+ * @package   lib-pear-php-codesniffer-standards-moodle-sniffs-codeanalysis
+ * @copyright 2008 Nicolas Connault
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
 /**
  * interface that defines multiple methods but the implementation only needs some
  * of them.
  *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Manuel Pichler <mapi@manuel-pichler.de>
- * @copyright 2007-2008 Manuel Pichler. All rights reserved.
- * @license   http://www.opensource.org/licenses/bsd-license.php BSD License
- * @version   Release: 1.1.0
- * @link      http://pear.php.net/package/PHP_CodeSniffer
+ * @copyright 2008 Nicolas Connault
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
-class Moodle_Sniffs_CodeAnalysis_UnusedFunctionParameterSniff implements PHP_CodeSniffer_Sniff
+class moodle_sniffs_codeanalysis_unusedfunctionparametersniff implements php_codesniffer_sniff
 {
 
 
@@ -44,22 +47,22 @@ class Moodle_Sniffs_CodeAnalysis_UnusedFunctionParameterSniff implements PHP_Cod
     {
         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
+     * @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)
+    public function process(PHP_CodeSniffer_File $phpcsfile, $stackptr)
     {
-        $tokens = $phpcsFile->getTokens();
-        $token  = $tokens[$stackPtr];
+        $tokens = $phpcsfile->gettokens();
+        $token  = $tokens[$stackptr];
 
         // Skip broken function declarations.
         if (isset($token['scope_opener']) === false || isset($token['parenthesis_opener']) === false) {
@@ -67,8 +70,8 @@ class Moodle_Sniffs_CodeAnalysis_UnusedFunctionParameterSniff implements PHP_Cod
         }
 
         $params = array();
-        foreach ($phpcsFile->getMethodParameters($stackPtr) as $param) {
-            $params[$param['name']] = $stackPtr;
+        foreach ($phpcsfile->getMethodParameters($stackptr) as $param) {
+            $params[$param['name']] = $stackptr;
         }
 
         $next = ++$token['scope_opener'];
@@ -81,14 +84,14 @@ class Moodle_Sniffs_CodeAnalysis_UnusedFunctionParameterSniff implements PHP_Cod
             $code  = $token['code'];
 
             // Ingorable tokens.
-            if (in_array($code, PHP_CodeSniffer_Tokens::$emptyTokens) === true) {
+            if (in_array($code, PHP_CodeSniffer_tokens::$emptyTokens) === true) {
                 continue;
             } else if ($code === T_THROW && $emptyBody === true) {
                 // Throw statement and an empty body indicate an interface method.
                 return;
             } else if ($code === T_RETURN && $emptyBody === true) {
                 // Return statement and an empty body indicate an interface method.
-                $tmp = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($next + 1), null, true);
+                $tmp = $phpcsfile->findNext(PHP_CodeSniffer_tokens::$emptyTokens, ($next + 1), null, true);
                 if ($tmp === false) {
                     return;
                 }
@@ -98,23 +101,23 @@ class Moodle_Sniffs_CodeAnalysis_UnusedFunctionParameterSniff implements PHP_Cod
                     return;
                 }
 
-                $tmp = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($tmp + 1), null, true);
+                $tmp = $phpcsfile->findNext(PHP_CodeSniffer_tokens::$emptyTokens, ($tmp + 1), null, true);
 
                 // There is a return <token>.
                 if ($tmp !== false && $tokens[$tmp] === T_SEMICOLON) {
                      return;
                 }
-            }//end if
+            }
 
             $emptyBody = false;
 
             if ($code === T_VARIABLE && isset($params[$token['content']]) === true) {
                 unset($params[$token['content']]);
             } else if ($code === T_DOUBLE_QUOTED_STRING) {
-                // Tokenize double quote string.
-                $strTokens = token_get_all(sprintf('<?php %s;?>', $token['content']));
+                // tokenize double quote string.
+                $strtokens = token_get_all(sprintf('<?php %s;?>', $token['content']));
 
-                foreach ($strTokens as $tok) {
+                foreach ($strtokens as $tok) {
                     if (is_array($tok) === false || $tok[0] !== T_VARIABLE ) {
                         continue;
                     }
@@ -123,19 +126,19 @@ class Moodle_Sniffs_CodeAnalysis_UnusedFunctionParameterSniff implements PHP_Cod
                         unset($params[$tok[1]]);
                     }
                 }
-            }//end if
-        }//end for
+            }
+        }
 
         if ($emptyBody === false && count($params) > 0) {
             foreach ($params as $paramName => $position) {
                 $error = 'The method parameter '.$paramName.' is never used';
-                $phpcsFile->addWarning($error, $position);
+                $phpcsfile->addwarning($error, $position);
             }
         }
 
-    }//end process()
+    }
 
 
-}//end class
+}
 
 ?>
index 9dd1a551f1fdc1a11b3942d3fccd09c9ad987c32..cc5ded9cfe977f6a5f9f412db2e41c7d32a3435d 100644 (file)
@@ -1,17 +1,25 @@
 <?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 /**
  * This file is part of the CodeAnalysis addon for PHP_CodeSniffer.
  *
- * PHP version 5
- *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Nicolas Connault <nicolasconnault@gmail.com>
- * @author    Manuel Pichler <mapi@manuel-pichler.de>
- * @copyright 2007-2008 Manuel Pichler. All rights reserved.
- * @license   http://www.opensource.org/licenses/bsd-license.php BSD License
- * @version   CVS: $Id$
- * @link      http://pear.php.net/package/PHP_CodeSniffer
+ * @package   lib-pear-php-codesniffer-standards-moodle-sniffs-codeanalysis
+ * @copyright 2008 Nicolas Connault
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
 /**
  * }
  * </code>
  *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Manuel Pichler <mapi@manuel-pichler.de>
- * @copyright 2007-2008 Manuel Pichler. All rights reserved.
- * @license   http://www.opensource.org/licenses/bsd-license.php BSD License
- * @version   Release: 1.1.0
- * @link      http://pear.php.net/package/PHP_CodeSniffer
+ * @copyright 2008 Nicolas Connault
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
-class Moodle_Sniffs_CodeAnalysis_UselessOverridingMethodSniff implements PHP_CodeSniffer_Sniff
+class moodle_sniffs_codeanalysis_uselessoverridingmethodsniff implements php_codesniffer_sniff
 {
 
 
@@ -51,22 +54,22 @@ class Moodle_Sniffs_CodeAnalysis_UselessOverridingMethodSniff implements PHP_Cod
     {
         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
+     * @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)
+    public function process(PHP_CodeSniffer_File $phpcsfile, $stackptr)
     {
-        $tokens = $phpcsFile->getTokens();
-        $token  = $tokens[$stackPtr];
+        $tokens = $phpcsfile->gettokens();
+        $token  = $tokens[$stackptr];
 
         // Skip function without body.
         if (isset($token['scope_opener']) === false) {
@@ -74,11 +77,11 @@ class Moodle_Sniffs_CodeAnalysis_UselessOverridingMethodSniff implements PHP_Cod
         }
 
         // Get function name.
-        $methodName = $phpcsFile->getDeclarationName($stackPtr);
+        $methodName = $phpcsfile->getDeclarationName($stackptr);
 
         // Get all parameters from method signature.
         $signature = array();
-        foreach ($phpcsFile->getMethodParameters($stackPtr) as $param) {
+        foreach ($phpcsfile->getMethodParameters($stackptr) as $param) {
             $signature[] = $param['name'];
         }
 
@@ -88,7 +91,7 @@ class Moodle_Sniffs_CodeAnalysis_UselessOverridingMethodSniff implements PHP_Cod
         for (; $next <= $end; ++$next) {
             $code = $tokens[$next]['code'];
 
-            if (in_array($code, PHP_CodeSniffer_Tokens::$emptyTokens) === true) {
+            if (in_array($code, PHP_CodeSniffer_tokens::$emptyTokens) === true) {
                 continue;
             } else if ($code === T_RETURN) {
                 continue;
@@ -103,7 +106,7 @@ class Moodle_Sniffs_CodeAnalysis_UselessOverridingMethodSniff implements PHP_Cod
         }
 
         // Find next non empty token index, should be double colon.
-        $next = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($next + 1), null, true);
+        $next = $phpcsfile->findNext(PHP_CodeSniffer_tokens::$emptyTokens, ($next + 1), null, true);
 
         // Skip for invalid code.
         if ($next === false || $tokens[$next]['code'] !== T_DOUBLE_COLON) {
@@ -111,7 +114,7 @@ class Moodle_Sniffs_CodeAnalysis_UselessOverridingMethodSniff implements PHP_Cod
         }
 
         // Find next non empty token index, should be the function name.
-        $next = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($next + 1), null, true);
+        $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) {
@@ -119,7 +122,7 @@ class Moodle_Sniffs_CodeAnalysis_UselessOverridingMethodSniff implements PHP_Cod
         }
 
         // Find next non empty token index, should be the open parenthesis.
-        $next = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($next + 1), null, true);
+        $next = $phpcsfile->findNext(PHP_CodeSniffer_tokens::$emptyTokens, ($next + 1), null, true);
 
         // Skip for invalid code.
         if ($next === false || $tokens[$next]['code'] !== T_OPEN_PARENTHESIS) {
@@ -144,16 +147,16 @@ class Moodle_Sniffs_CodeAnalysis_UselessOverridingMethodSniff implements PHP_Cod
                 --$parenthesisCount;
             } else if ($parenthesisCount === 1 && $code === T_COMMA) {
                 $parameters[] = '';
-            } else if (in_array($code, PHP_CodeSniffer_Tokens::$emptyTokens) === false) {
+            } 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);
+        $next = $phpcsfile->findNext(PHP_CodeSniffer_tokens::$emptyTokens, ($next + 1), null, true);
         if ($next === false || $tokens[$next]['code'] !== T_SEMICOLON) {
             return;
         }
@@ -162,7 +165,7 @@ class Moodle_Sniffs_CodeAnalysis_UselessOverridingMethodSniff implements PHP_Cod
         for (++$next; $next <= $end; ++$next) {
             $code = $tokens[$next]['code'];
             // Skip for any other content.
-            if (in_array($code, PHP_CodeSniffer_Tokens::$emptyTokens) === false) {
+            if (in_array($code, PHP_CodeSniffer_tokens::$emptyTokens) === false) {
                 return;
             }
         }
@@ -171,12 +174,12 @@ class Moodle_Sniffs_CodeAnalysis_UselessOverridingMethodSniff implements PHP_Cod
         $parameters = array_filter($parameters);
 
         if (count($parameters) === count($signature) && $parameters === $signature) {
-            $phpcsFile->addWarning('Useless method overriding detected', $stackPtr);
+            $phpcsfile->addwarning('Useless method overriding detected', $stackptr);
         }
 
-    }//end process()
+    }
 
 
-}//end class
+}
 
 ?>
index 732d31b92cfc2d514ba289a6b0b6d55372404188..73e0773bb3bb76b44d03e342088c5131ba761b57 100644 (file)
@@ -1,17 +1,25 @@
 <?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 /**
  * Parses and verifies the doc comments for classes.
  *
- * PHP version 5
- *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Nicolas Connault <nicolasconnault@gmail.com>
- *
- * @copyright 2009 Nicolas Connault
+ * @package   lib-pear-php-codesniffer-standards-moodle-sniffs-commenting
+ * @copyright 2008 Nicolas Connault
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @version   CVS: $Id$
- * @link      http://pear.php.net/package/PHP_CodeSniffer
  */
 
 if (class_exists('PHP_CodeSniffer_CommentParser_ClassCommentParser', true) === false) {
@@ -19,8 +27,8 @@ if (class_exists('PHP_CodeSniffer_CommentParser_ClassCommentParser', true) === f
     throw new PHP_CodeSniffer_Exception($error);
 }
 
-if (class_exists('Moodle_Sniffs_Commenting_FileCommentSniff', true) === false) {
-    $error = 'Class Moodle_Sniffs_Commenting_FileCommentSniff not found';
+if (class_exists('moodle_sniffs_commenting_filecommentsniff', true) === false) {
+    $error = 'Class moodle_sniffs_commenting_filecommentsniff not found';
     throw new PHP_CodeSniffer_Exception($error);
 }
 
@@ -38,54 +46,40 @@ if (class_exists('Moodle_Sniffs_Commenting_FileCommentSniff', true) === false) {
  *  <li>Check required and optional tags and the format of their content.</li>
  * </ul>
  *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Nicolas Connault <nicolasconnault@gmail.com>
- *
- * @copyright 2009 Nicolas Connault
+ * @copyright 2008 Nicolas Connault
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @version   Release: 1.1.0
- * @link      http://pear.php.net/package/PHP_CodeSniffer
  */
-class Moodle_Sniffs_Commenting_ClassCommentSniff extends Moodle_Sniffs_Commenting_FileCommentSniff
-{
-
+class moodle_sniffs_commenting_classcommentsniff extends moodle_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()
+    public function register() {
+        return array(T_CLASS, T_INTERFACE);
+    }
 
 
     /**
      * 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
+     * @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)
-    {
+    public function process(PHP_CodeSniffer_File $phpcsfile, $stackptr) {
         // Modify array of required tags
         $this->tags['package']['required'] = false;
         $this->tags['copyright']['required'] = false;
         $this->tags['author']['required'] = false;
 
-        $this->currentFile = $phpcsFile;
+        $this->currentFile = $phpcsfile;
 
-        $tokens = $phpcsFile->getTokens();
-        $type   = strtolower($tokens[$stackPtr]['content']);
+        $tokens = $phpcsfile->gettokens();
+        $type   = strtolower($tokens[$stackptr]['content']);
         $find   = array(
                    T_ABSTRACT,
                    T_WHITESPACE,
@@ -93,81 +87,81 @@ class Moodle_Sniffs_Commenting_ClassCommentSniff extends Moodle_Sniffs_Commentin
                   );
 
         // Extract the class comment docblock.
-        $commentEnd = $phpcsFile->findPrevious($find, ($stackPtr - 1), null, true);
+        $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 $type comment", $stackPtr);
+            $phpcsfile->adderror("You must use \"/**\" style comments for a $type comment", $stackptr);
             return;
         } else if ($commentEnd === false || $tokens[$commentEnd]['code'] !== T_DOC_COMMENT) {
-            $phpcsFile->addError("Missing $type doc comment", $stackPtr);
+            $phpcsfile->adderror("Missing $type doc comment", $stackptr);
             return;
         }
 
-        $commentStart = ($phpcsFile->findPrevious(T_DOC_COMMENT, ($commentEnd - 1), null, true) + 1);
-        $commentNext  = $phpcsFile->findPrevious(T_WHITESPACE, ($commentEnd + 1), $stackPtr, false, $phpcsFile->eolChar);
+        $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) {
+        $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);
+            $prevNonComment = $phpcsfile->findPrevious(T_DOC_COMMENT, ($commentStart - 1), null, true);
             if ($prevNonComment !== false) {
-                $prevComment = $phpcsFile->findPrevious(T_DOC_COMMENT, ($prevNonComment - 1));
+                $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) {
+                    $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 $type doc comment", ($stackPtr + 1));
+                            $phpcsfile->adderror("Missing $type doc comment", ($stackptr + 1));
                             return;
                         }
-                    }//end if
-                }//end if
-            }//end if
-        }//end if
+                    }
+                }
+            }
+        }
 
-        $comment = $phpcsFile->getTokensAsString($commentStart, ($commentEnd - $commentStart + 1));
+        $comment = $phpcsfile->gettokensAsString($commentStart, ($commentEnd - $commentStart + 1));
 
         // Parse the class comment.docblock.
         try {
-            $this->commentParser = new PHP_CodeSniffer_CommentParser_ClassCommentParser($comment, $phpcsFile);
+            $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);
+            $line = ($e->getlinewithinComment() + $commentStart);
+            $phpcsfile->adderror($e->getMessage(), $line);
             return;
         }
 
         $comment = $this->commentParser->getComment();
         if (is_null($comment) === true) {
             $error = ucfirst($type).' doc comment is empty';
-            $phpcsFile->addError($error, $commentStart);
+            $phpcsfile->adderror($error, $commentStart);
             return;
         }
 
         // No extra newline before short description.
         $short        = $comment->getShortComment();
         $newlineCount = 0;
-        $newlineSpan  = strspn($short, $phpcsFile->eolChar);
+        $newlineSpan  = strspn($short, $phpcsfile->eolChar);
         if ($short !== '' && $newlineSpan > 0) {
             $line  = ($newlineSpan > 1) ? 'newlines' : 'newline';
             $error = "Extra $line found before $type comment short description";
-            $phpcsFile->addError($error, ($commentStart + 1));
+            $phpcsfile->adderror($error, ($commentStart + 1));
         }
 
-        $newlineCount = (substr_count($short, $phpcsFile->eolChar) + 1);
+        $newlineCount = (substr_count($short, $phpcsfile->eolChar) + 1);
 
         // Exactly one blank line between short and long description.
-        $long = $comment->getLongComment();
+        $long = $comment->getlongcomment();
         if (empty($long) === false) {
             $between        = $comment->getWhiteSpaceBetween();
-            $newlineBetween = substr_count($between, $phpcsFile->eolChar);
+            $newlineBetween = substr_count($between, $phpcsfile->eolChar);
             if ($newlineBetween !== 2) {
                 $error = "There must be exactly one blank line between descriptions in $type comments";
-                $phpcsFile->addError($error, ($commentStart + $newlineCount + 1));
+                $phpcsfile->adderror($error, ($commentStart + $newlineCount + 1));
             }
 
             $newlineCount += $newlineBetween;
@@ -180,18 +174,18 @@ class Moodle_Sniffs_Commenting_ClassCommentSniff extends Moodle_Sniffs_Commentin
             if ($newlineSpan !== 2) {
                 $error = "There must be exactly one blank line before the tags in $type comments";
                 if ($long !== '') {
-                    $newlineCount += (substr_count($long, $phpcsFile->eolChar) - $newlineSpan + 1);
+                    $newlineCount += (substr_count($long, $phpcsfile->eolChar) - $newlineSpan + 1);
                 }
 
-                $phpcsFile->addWarning($error, ($commentStart + $newlineCount));
-                $short = rtrim($short, $phpcsFile->eolChar.' ');
+                $phpcsfile->addwarning($error, ($commentStart + $newlineCount));
+                $short = rtrim($short, $phpcsfile->eolChar.' ');
             }
         }
 
         // Check each tag.
         $this->processTags($commentStart, $commentEnd);
 
-    }//end process()
+    }
 
 
     /**
@@ -205,20 +199,18 @@ class Moodle_Sniffs_Commenting_ClassCommentSniff extends Moodle_Sniffs_Commentin
     {
         $version = $this->commentParser->getVersion();
         if ($version !== null) {
-            $content = $version->getContent();
+            $content = $version->getcontent();
             $matches = array();
             if (empty($content) === true) {
-                $error = 'Content missing for @version tag in doc comment';
-                $this->currentFile->addError($error, $errorPos);
+                $error = 'content missing for @version tag in doc comment';
+                $this->currentFile->adderror($error, $errorPos);
             } else if ((strstr($content, 'Release:') === false)) {
                 $error = "Invalid version \"$content\" in doc comment; consider \"Release: <package_version>\" instead";
-                $this->currentFile->addWarning($error, $errorPos);
+                $this->currentFile->addwarning($error, $errorPos);
             }
         }
 
-    }//end processVersion()
-
-
-}//end class
+    }
+}
 
 ?>
index e5afe5c08e733b81a022dd1f34abcf2003a9a4c1..18063e8a1e3f23aea8260db551a9fe40a27fd230 100644 (file)
@@ -1,16 +1,25 @@
 <?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 /**
  * Parses and verifies the doc comments for files.
  *
- * PHP version 5
- *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Nicolas Connault <nicolasconnault@gmail.com>
- * @copyright 2009 Nicolas Connault
+ * @package   lib-pear-php-codesniffer-standards-moodle-sniffs-commenting
+ * @copyright 2008 Nicolas Connault
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @version   CVS: $Id$
- * @link      http://pear.php.net/package/PHP_CodeSniffer
  */
 
 if (class_exists('PHP_CodeSniffer_CommentParser_ClassCommentParser', true) === false) {
@@ -32,16 +41,11 @@ if (class_exists('PHP_CodeSniffer_CommentParser_ClassCommentParser', true) === f
  *  <li>Check required and optional tags and the format of their content.</li>
  * </ul>
  *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Nicolas Connault <nicolasconnault@gmail.com>
- * @copyright 2009 Nicolas Connault
+ * @copyright 2008 Nicolas Connault
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @version   Release: 1.1.0
- * @link      http://pear.php.net/package/PHP_CodeSniffer
  */
 
-class Moodle_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
+class moodle_sniffs_commenting_filecommentsniff implements php_codesniffer_sniff
 {
 
     /**
@@ -131,40 +135,40 @@ class Moodle_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
     {
         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
+     * @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)
+    public function process(PHP_CodeSniffer_File $phpcsfile, $stackptr)
     {
-        $this->currentFile = $phpcsFile;
+        $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) {
+        if ($stackptr !== 0) {
+            if ($phpcsfile->findPrevious(T_OPEN_TAG, ($stackptr - 1)) !== false) {
                 return;
             }
         }
 
-        $tokens = $phpcsFile->getTokens();
+        $tokens = $phpcsfile->gettokens();
 
         // Find the next non whitespace token.
-        $commentStart = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true);
+        $commentStart = $phpcsfile->findNext(T_WHITESPACE, ($stackptr + 1), null, true);
 
         // Look for $Id$ and boilerplate
         if ($tokens[$commentStart]['code'] != T_COMMENT) {
-            $phpcsFile->addError('File must begin with License boilerplate', ($stackPtr + 1));
+            $phpcsfile->adderror('File must begin with License boilerplate', ($stackptr + 1));
             return;
         } else if (preg_match('|\$Id\$|i', $tokens[$commentStart]['content'])) {
-            $phpcsFile->addWarning('$Id$ tag is no longer required, please remove.', ($stackPtr + 1));
+            $phpcsfile->addwarning('$Id$ tag is no longer required, please remove.', ($stackptr + 1));
             return;
         }
 
@@ -184,104 +188,104 @@ class Moodle_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
 // You should have received a copy of the GNU General Public License
 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.';
 
-        $nextToken = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true);
+        $nexttoken = $phpcsfile->findNext(T_WHITESPACE, ($stackptr + 1), null, true);
         $boilerplate_lines = preg_split('/[\n\r]+/', $boilerplate);
 
-        if (rtrim($tokens[$nextToken]['content']) != $boilerplate_lines[0]) {
-            $phpcsFile->addError('You must include the Moodle boilerplate at the top of the file', ($nextToken));
+        if (rtrim($tokens[$nexttoken]['content']) != $boilerplate_lines[0]) {
+            $phpcsfile->adderror('You must include the Moodle boilerplate at the top of the file', ($nexttoken));
             return;
         }
 
         $boilerplate_index = 0;
 
         foreach ($boilerplate_lines as $line) {
-            $nextToken = $phpcsFile->findNext(T_COMMENT, ($nextToken));
+            $nexttoken = $phpcsfile->findNext(T_COMMENT, ($nexttoken));
 
-            if (rtrim($tokens[$nextToken]['content']) != $boilerplate_lines[$boilerplate_index]) {
-                $phpcsFile->addError('Badly formatted boilerplate. Please copy-paste exactly', ($nextToken));
+            if (rtrim($tokens[$nexttoken]['content']) != $boilerplate_lines[$boilerplate_index]) {
+                $phpcsfile->adderror('Badly formatted boilerplate. Please copy-paste exactly', ($nexttoken));
                 return;
             }
-            $nextToken++;
+            $nexttoken++;
             $boilerplate_index++;
         }
 
-        $filedocToken = $phpcsFile->findNext(T_WHITESPACE, ($nextToken + 1), null, true);
+        $filedoctoken = $phpcsfile->findNext(T_WHITESPACE, ($nexttoken + 1), null, true);
 
-        if ($tokens[$filedocToken]['code'] === T_CLOSE_TAG) {
+        if ($tokens[$filedoctoken]['code'] === T_CLOSE_TAG) {
             // We are only interested if this is the first open tag.
             return;
-        } else if ($tokens[$filedocToken]['code'] === T_COMMENT) {
-            $phpcsFile->addError('You must use "/**" style comments for a file comment', ($filedocToken + 1));
+        } else if ($tokens[$filedoctoken]['code'] === T_COMMENT) {
+            $phpcsfile->adderror('You must use "/**" style comments for a file comment', ($filedoctoken + 1));
             return;
-        } else if ($filedocToken === false || $tokens[$filedocToken]['code'] !== T_DOC_COMMENT) {
-            $phpcsFile->addError('Missing file doc comment', ($filedocToken + 1));
+        } else if ($filedoctoken === false || $tokens[$filedoctoken]['code'] !== T_DOC_COMMENT) {
+            $phpcsfile->adderror('Missing file doc comment', ($filedoctoken + 1));
             return;
         } else {
 
             // Extract the header comment docblock.
-            $commentEnd = ($phpcsFile->findNext(T_DOC_COMMENT, ($filedocToken + 1), null, true) - 1);
+            $commentEnd = ($phpcsfile->findNext(T_DOC_COMMENT, ($filedoctoken + 1), null, true) - 1);
 
             // Check if there is only 1 doc comment between the open tag and class token.
-            $nextToken   = array(
+            $nexttoken   = array(
                             T_ABSTRACT,
                             T_CLASS,
                             T_FUNCTION,
                             T_DOC_COMMENT,
                            );
-            $commentNext = $phpcsFile->findNext($nextToken, ($commentEnd + 1));
+            $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) {
+                $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', ($stackPtr + 1));
+                        $phpcsfile->adderror('Missing file doc comment', ($stackptr + 1));
                         return;
                     }
                 }
             }
 
-            $comment = $phpcsFile->getTokensAsString($filedocToken, ($commentEnd - $filedocToken + 1));
+            $comment = $phpcsfile->gettokensAsString($filedoctoken, ($commentEnd - $filedoctoken + 1));
 
             // Parse the header comment docblock.
             try {
-                $this->commentParser = new PHP_CodeSniffer_CommentParser_ClassCommentParser($comment, $phpcsFile);
+                $this->commentParser = new PHP_CodeSniffer_CommentParser_ClassCommentParser($comment, $phpcsfile);
                 $this->commentParser->parse();
             } catch (PHP_CodeSniffer_CommentParser_ParserException $e) {
-                $line = ($e->getLineWithinComment() + $filedocToken);
-                $phpcsFile->addError($e->getMessage(), $line);
+                $line = ($e->getlinewithinComment() + $filedoctoken);
+                $phpcsfile->adderror($e->getMessage(), $line);
                 return;
             }
 
             $comment = $this->commentParser->getComment();
             if (is_null($comment) === true) {
                 $error = 'File doc comment is empty';
-                $phpcsFile->addError($error, $filedocToken);
+                $phpcsfile->adderror($error, $filedoctoken);
                 return;
             }
 
             // No extra newline before short description.
             $short        = $comment->getShortComment();
             $newlineCount = 0;
-            $newlineSpan  = strspn($short, $phpcsFile->eolChar);
+            $newlineSpan  = strspn($short, $phpcsfile->eolChar);
             if ($short !== '' && $newlineSpan > 0) {
                 $line  = ($newlineSpan > 1) ? 'newlines' : 'newline';
                 $error = "Extra $line found before file comment short description";
-                $phpcsFile->addError($error, ($filedocToken + 1));
+                $phpcsfile->adderror($error, ($filedoctoken + 1));
             }
 
-            $newlineCount = (substr_count($short, $phpcsFile->eolChar) + 1);
+            $newlineCount = (substr_count($short, $phpcsfile->eolChar) + 1);
 
             // Exactly one blank line between short and long description.
-            $long = $comment->getLongComment();
+            $long = $comment->getlongcomment();
             if (empty($long) === false) {
                 $between        = $comment->getWhiteSpaceBetween();
-                $newlineBetween = substr_count($between, $phpcsFile->eolChar);
+                $newlineBetween = substr_count($between, $phpcsfile->eolChar);
                 if ($newlineBetween !== 2) {
                     $error = 'There should be exactly one blank line between descriptions in file comment';
-                    $phpcsFile->addWarning($error, ($filedocToken + $newlineCount + 1));
+                    $phpcsfile->addwarning($error, ($filedoctoken + $newlineCount + 1));
                 }
 
                 $newlineCount += $newlineBetween;
@@ -294,11 +298,11 @@ class Moodle_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
                 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);
+                        $newlineCount += (substr_count($long, $phpcsfile->eolChar) - $newlineSpan + 1);
                     }
 
-                    $phpcsFile->addWarning($error, ($filedocToken + $newlineCount));
-                    $short = rtrim($short, $phpcsFile->eolChar.' ');
+                    $phpcsfile->addwarning($error, ($filedoctoken + $newlineCount));
+                    $short = rtrim($short, $phpcsfile->eolChar.' ');
                 }
             }
 
@@ -306,15 +310,15 @@ class Moodle_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
             /*
             if (strstr(strtolower($long), 'php version') === false) {
                 $error = 'PHP version not specified';
-                $phpcsFile->addWarning($error, $commentEnd);
+                $phpcsfile->addwarning($error, $commentEnd);
             }
             */
 
             // Check each tag.
-            $this->processTags($filedocToken, $commentEnd);
-        }//end if
+            $this->processTags($filedoctoken, $commentEnd);
+        }
 
-    }//end process()
+    }
 
 
     /**
@@ -327,7 +331,7 @@ class Moodle_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
      */
     protected function processTags($commentStart, $commentEnd)
     {
-        $docBlock    = (get_class($this) === 'Moodle_Sniffs_Commenting_FileCommentSniff') ? 'file' : 'class';
+        $docBlock    = (get_class($this) === 'moodle_sniffs_commenting_filecommentsniff') ? 'file' : 'class';
         $foundTags   = $this->commentParser->getTagOrders();
         $orderIndex  = 0;
         $indentation = array();
@@ -339,7 +343,7 @@ class Moodle_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
             // Required tag missing.
             if ($info['required'] === true && in_array($tag, $foundTags) === false) {
                 $error = "Missing @$tag tag in $docBlock comment";
-                $this->currentFile->addError($error, $commentEnd);
+                $this->currentFile->adderror($error, $commentEnd);
                 continue;
             }
 
@@ -357,7 +361,7 @@ class Moodle_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
 
             $errorPos = $commentStart;
             if (is_array($tagElement) === false) {
-                $errorPos = ($commentStart + $tagElement->getLine());
+                $errorPos = ($commentStart + $tagElement->getline());
             }
 
             // Get the tag order.
@@ -367,35 +371,35 @@ class Moodle_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
                 // Multiple occurance not allowed.
                 if ($info['allow_multiple'] === false) {
                     $error = "Only 1 @$tag tag is allowed in a $docBlock comment";
-                    $this->currentFile->addError($error, $errorPos);
+                    $this->currentFile->adderror($error, $errorPos);
                 } 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());
+                            $errorPosIndex = ($errorPos + $tagElement[$i]->getline());
                             $error         = "@$tag tags must be grouped together";
-                            $this->currentFile->addError($error, $errorPosIndex);
+                            $this->currentFile->adderror($error, $errorPosIndex);
                         }
 
                         $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();
+                    $errorPos += $tagElement[0]->getline();
                 }
 
                 $orderText = $info['order_text'];
                 $error     = "The @$tag tag is in the wrong order; the tag $orderText";
-                $this->currentFile->addError($error, $errorPos);
+                $this->currentFile->adderror($error, $errorPos);
             }
 
             // Store the indentation for checking.
@@ -409,7 +413,7 @@ class Moodle_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
                     $indentation[] = array(
                                       'tag'   => $tag,
                                       'space' => $this->getIndentation($tag, $element),
-                                      'line'  => $element->getLine(),
+                                      'line'  => $element->getline(),
                                      );
                 }
             } else {
@@ -432,7 +436,7 @@ class Moodle_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
                      $tagElement->process($this->currentFile, $commentStart, $docBlock);
                 }
             }
-        }//end foreach
+        }
 
         foreach ($indentation as $indentInfo) {
             if ($indentInfo['space'] !== 0 && $indentInfo['space'] !== ($longestTag + 1)) {
@@ -445,14 +449,14 @@ class Moodle_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
                     $line = $indentInfo['line'];
                 } else {
                     $tagElem = $this->commentParser->$getTagMethod();
-                    $line    = $tagElem->getLine();
+                    $line    = $tagElem->getline();
                 }
 
-                $this->currentFile->addWarning($error, ($commentStart + $line));
+                $this->currentFile->addwarning($error, ($commentStart + $line));
             }
         }
 
-    }//end processTags()
+    }
 
 
     /**
@@ -466,8 +470,8 @@ class Moodle_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
     protected function getIndentation($tagName, $tagElement)
     {
         if ($tagElement instanceof PHP_CodeSniffer_CommentParser_SingleElement) {
-            if ($tagElement->getContent() !== '') {
-                return (strlen($tagName) + substr_count($tagElement->getWhitespaceBeforeContent(), ' '));
+            if ($tagElement->getcontent() !== '') {
+                return (strlen($tagName) + substr_count($tagElement->getWhitespaceBeforecontent(), ' '));
             }
         } else if ($tagElement instanceof PHP_CodeSniffer_CommentParser_PairElement) {
             if ($tagElement->getValue() !== '') {
@@ -477,7 +481,7 @@ class Moodle_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
 
         return 0;
 
-    }//end getIndentation()
+    }
 
 
     /**
@@ -491,11 +495,11 @@ class Moodle_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
     {
         $category = $this->commentParser->getCategory();
         if ($category !== null) {
-            $content = $category->getContent();
+            $content = $category->getcontent();
             if ($content !== '') {
                 if (PHP_CodeSniffer::isUnderscoreName($content) !== true) {
-                    $newContent = str_replace(' ', '_', $content);
-                    $nameBits   = explode('_', $newContent);
+                    $newcontent = str_replace(' ', '_', $content);
+                    $nameBits   = explode('_', $newcontent);
                     $firstBit   = array_shift($nameBits);
                     $newName    = ucfirst($firstBit).'_';
                     foreach ($nameBits as $bit) {
@@ -504,15 +508,15 @@ class Moodle_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
 
                     $validName = trim($newName, '_');
                     $error     = "Category name \"$content\" is not valid; consider \"$validName\" instead";
-                    $this->currentFile->addError($error, $errorPos);
+                    $this->currentFile->adderror($error, $errorPos);
                 }
             } else {
                 $error = '@category tag must contain a name';
-                $this->currentFile->addError($error, $errorPos);
+                $this->currentFile->adderror($error, $errorPos);
             }
         }
 
-    }//end processCategory()
+    }
 
 
     /**
@@ -526,20 +530,20 @@ class Moodle_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
     {
         $package = $this->commentParser->getPackage();
         if ($package !== null) {
-            $content = $package->getContent();
+            $content = $package->getcontent();
 
             if ($content !== '') {
                 if (!preg_match('/^[a-z\-]*$/', $content)) {
                     $error     = "Package name \"$content\" is not valid; must be lower-case with optional hyphens.";
-                    $this->currentFile->addError($error, $errorPos);
+                    $this->currentFile->adderror($error, $errorPos);
                 }
             } else {
                 $error = '@package tag must contain a name';
-                $this->currentFile->addError($error, $errorPos);
+                $this->currentFile->adderror($error, $errorPos);
             }
         }
 
-    }//end processPackage()
+    }
 
 
     /**
@@ -553,11 +557,11 @@ class Moodle_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
     {
         $package = $this->commentParser->getSubpackage();
         if ($package !== null) {
-            $content = $package->getContent();
+            $content = $package->getcontent();
             if ($content !== '') {
                 if (PHP_CodeSniffer::isUnderscoreName($content) !== true) {
-                    $newContent = str_replace(' ', '_', $content);
-                    $nameBits   = explode('_', $newContent);
+                    $newcontent = str_replace(' ', '_', $content);
+                    $nameBits   = explode('_', $newcontent);
                     $firstBit   = array_shift($nameBits);
                     $newName    = strtoupper($firstBit{0}).substr($firstBit, 1).'_';
                     foreach ($nameBits as $bit) {
@@ -566,15 +570,15 @@ class Moodle_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
 
                     $validName = trim($newName, '_');
                     $error     = "Subpackage name \"$content\" is not valid; consider \"$validName\" instead";
-                    $this->currentFile->addError($error, $errorPos);
+                    $this->currentFile->adderror($error, $errorPos);
                 }
             } else {
                 $error = '@subpackage tag must contain a name';
-                $this->currentFile->addError($error, $errorPos);
+                $this->currentFile->adderror($error, $errorPos);
             }
         }
 
-    }//end processSubpackage()
+    }
 
 
     /**
@@ -595,25 +599,25 @@ class Moodle_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
         // Report missing return.
         if (empty($authors) === false) {
             foreach ($authors as $author) {
-                $errorPos = ($commentStart + $author->getLine());
-                $content  = $author->getContent();
+                $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 <username@example.com>"';
-                        $this->currentFile->addError($error, $errorPos);
+                        $error = 'content of the @author tag must be in the form "Display Name <username@example.com>"';
+                        $this->currentFile->adderror($error, $errorPos);
                     }
                 } else {
-                    $docBlock = (get_class($this) === 'Moodle_Sniffs_Commenting_FileCommentSniff') ? 'file' : 'class';
-                    $error    = "Content missing for @author tag in $docBlock comment";
-                    $this->currentFile->addError($error, $errorPos);
+                    $docBlock = (get_class($this) === 'moodle_sniffs_commenting_filecommentsniff') ? 'file' : 'class';
+                    $error    = "content missing for @author tag in $docBlock comment";
+                    $this->currentFile->adderror($error, $errorPos);
                 }
             }
         }
 
-    }//end processAuthors()
+    }
 
 
     /**
@@ -628,8 +632,8 @@ class Moodle_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
     {
         $copyrights = $this->commentParser->getCopyrights();
         foreach ($copyrights as $copyright) {
-            $errorPos = ($commentStart + $copyright->getLine());
-            $content  = $copyright->getContent();
+            $errorPos = ($commentStart + $copyright->getline());
+            $content  = $copyright->getcontent();
             if ($content !== '') {
                 $matches = array();
                 if (preg_match('/^([0-9]{4})((.{1})([0-9]{4}))? (.+)$/', $content, $matches) !== 0) {
@@ -637,25 +641,25 @@ class Moodle_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
                     if ($matches[3] !== '') {
                         if ($matches[3] !== '-') {
                             $error = 'A hyphen must be used between the earliest and latest year';
-                            $this->currentFile->addError($error, $errorPos);
+                            $this->currentFile->adderror($error, $errorPos);
                         }
 
                         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);
+                            $this->currentFile->addwarning($error, $errorPos);
                         }
                     }
                 } else {
                     $error = '@copyright tag must contain a year and the name of the copyright holder';
-                    $this->currentFile->addError($error, $errorPos);
+                    $this->currentFile->adderror($error, $errorPos);
                 }
             } else {
                 $error = '@copyright tag must contain a year and the name of the copyright holder';
-                $this->currentFile->addError($error, $errorPos);
-            }//end if
-        }//end if
+                $this->currentFile->adderror($error, $errorPos);
+            }
+        }
 
-    }//end processCopyrights()
+    }
 
 
     /**
@@ -673,17 +677,17 @@ class Moodle_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
             $comment = $license->getComment();
             if ($value === '' || $comment === '') {
                 $error = '@license tag must contain a URL and a license name';
-                $this->currentFile->addError($error, $errorPos);
+                $this->currentFile->adderror($error, $errorPos);
             }
             if ($comment != 'GNU GPL v3 or later') {
-                $this->currentFile->addError('License must be "GNU GPL v3 or later", found "'.$comment.'"', $errorPos);
+                $this->currentFile->adderror('License must be "GNU GPL v3 or later", found "'.$comment.'"', $errorPos);
             }
             if ($value != 'http://www.gnu.org/copyleft/gpl.html') {
-                $this->currentFile->addError('License must be "GNU GPL v3 or later"', $errorPos);
+                $this->currentFile->adderror('License must be "GNU GPL v3 or later"', $errorPos);
             }
         }
 
-    }//end processLicense()
+    }
 
 
     /**
@@ -697,20 +701,20 @@ class Moodle_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
     {
         $version = $this->commentParser->getVersion();
         if ($version !== null) {
-            $content = $version->getContent();
+            $content = $version->getcontent();
             $matches = array();
             if (empty($content) === true) {
-                $error = 'Content missing for @version tag in file comment';
-                $this->currentFile->addError($error, $errorPos);
+                $error = 'content missing for @version tag in file comment';
+                $this->currentFile->adderror($error, $errorPos);
             } else if (strstr($content, 'CVS:') === false && strstr($content, 'SVN:') === false) {
                 $error = "Invalid version \"$content\" in file comment; consider \"CVS: <cvs_id>\" or \"SVN: <svn_id>\" instead";
-                $this->currentFile->addWarning($error, $errorPos);
+                $this->currentFile->addwarning($error, $errorPos);
             }
         }
 
-    }//end processVersion()
+    }
 
 
-}//end class
+}
 
 ?>
index 74678958120b8b4eccf1fb752aa6912b278297ef..ff7febec59715c5614e77c0bba887bd2f9de3b3f 100644 (file)
@@ -1,17 +1,25 @@
 <?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 /**
  * Parses and verifies the doc comments for functions.
  *
- * PHP version 5
- *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Nicolas Connault <nicolasconnault@gmail.com>
- *
- * @copyright 2009 Nicolas Connault
+ * @package   lib-pear-php-codesniffer-standards-moodle-sniffs-commenting
+ * @copyright 2008 Nicolas Connault
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @version   CVS: $Id$
- * @link      http://pear.php.net/package/PHP_CodeSniffer
  */
 
 if (class_exists('PHP_CodeSniffer_CommentParser_FunctionCommentParser', true) === false) {
@@ -36,16 +44,10 @@ if (class_exists('PHP_CodeSniffer_CommentParser_FunctionCommentParser', true) ==
  *  <li>Any throw tag must have an exception class.</li>
  * </ul>
  *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Nicolas Connault <nicolasconnault@gmail.com>
- *
- * @copyright 2009 Nicolas Connault
+ * @copyright 2008 Nicolas Connault
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @version   Release: 1.1.0
- * @link      http://pear.php.net/package/PHP_CodeSniffer
  */
-class Moodle_Sniffs_Commenting_FunctionCommentSniff implements PHP_CodeSniffer_Sniff
+class moodle_sniffs_commenting_functioncommentsniff implements php_codesniffer_sniff
 {
 
     /**
@@ -60,14 +62,14 @@ class Moodle_Sniffs_Commenting_FunctionCommentSniff implements PHP_CodeSniffer_S
      *
      * @var int
      */
-    private $_functionToken = null;
+    private $_functiontoken = null;
 
     /**
      * The position in the stack where the class token was found.
      *
      * @var int
      */
-    private $_classToken = null;
+    private $_classtoken = null;
 
     /**
      * The function comment parser for the current method.
@@ -93,19 +95,19 @@ class Moodle_Sniffs_Commenting_FunctionCommentSniff implements PHP_CodeSniffer_S
     {
         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
+     * @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)
+    public function process(PHP_CodeSniffer_File $phpcsfile, $stackptr)
     {
         $find = array(
                  T_COMMENT,
@@ -115,14 +117,14 @@ class Moodle_Sniffs_Commenting_FunctionCommentSniff implements PHP_CodeSniffer_S
                  T_OPEN_TAG,
                 );
 
-        $commentEnd = $phpcsFile->findPrevious($find, ($stackPtr - 1));
+        $commentEnd = $phpcsfile->findPrevious($find, ($stackptr - 1));
 
         if ($commentEnd === false) {
             return;
         }
 
-        $this->currentFile = $phpcsFile;
-        $tokens            = $phpcsFile->getTokens();
+        $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.
@@ -130,63 +132,63 @@ class Moodle_Sniffs_Commenting_FunctionCommentSniff implements PHP_CodeSniffer_S
 
         if ($code === T_COMMENT) {
             $error = 'You must use "/**" style comments for a function comment';
-            $phpcsFile->addError($error, $stackPtr);
+            $phpcsfile->adderror($error, $stackptr);
             return;
         } else if ($code !== T_DOC_COMMENT) {
-            $phpcsFile->addError('Missing function doc comment', $stackPtr);
+            $phpcsfile->adderror('Missing function doc comment', $stackptr);
             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    = 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);
+        $prevtoken = $phpcsfile->findPrevious($ignore, ($stackptr - 1), null, true);
+        if ($prevtoken !== $commentEnd) {
+            $phpcsfile->adderror('Missing function doc comment', $stackptr);
             return;
         }
 
-        $this->_functionToken = $stackPtr;
+        $this->_functiontoken = $stackptr;
 
-        foreach ($tokens[$stackPtr]['conditions'] as $condPtr => $condition) {
+        foreach ($tokens[$stackptr]['conditions'] as $condPtr => $condition) {
             if ($condition === T_CLASS || $condition === T_INTERFACE) {
-                $this->_classToken = $condPtr;
+                $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) {
+        $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);
+            if ($stackptr === 0 || $phpcsfile->findPrevious(T_OPEN_TAG, ($prevtoken - 1)) === false) {
+                $phpcsfile->adderror('Missing function doc comment', $stackptr);
                 return;
             }
         }
 
-        $comment           = $phpcsFile->getTokensAsString($commentStart, ($commentEnd - $commentStart + 1));
-        $this->_methodName = $phpcsFile->getDeclarationName($stackPtr);
+        $comment           = $phpcsfile->gettokensAsString($commentStart, ($commentEnd - $commentStart + 1));
+        $this->_methodName = $phpcsfile->getDeclarationName($stackptr);
 
         try {
-            $this->commentParser = new PHP_CodeSniffer_CommentParser_FunctionCommentParser($comment, $phpcsFile);
+            $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);
+            $line = ($e->getlinewithinComment() + $commentStart);
+            $phpcsfile->adderror($e->getMessage(), $line);
             return;
         }
 
         $comment = $this->commentParser->getComment();
         if (is_null($comment) === true) {
             $error = 'Function doc comment is empty';
-            $phpcsFile->addError($error, $commentStart);
+            $phpcsfile->adderror($error, $commentStart);
             return;
         }
 
@@ -197,23 +199,23 @@ class Moodle_Sniffs_Commenting_FunctionCommentSniff implements PHP_CodeSniffer_S
         // No extra newline before short description.
         $short        = $comment->getShortComment();
         $newlineCount = 0;
-        $newlineSpan  = strspn($short, $phpcsFile->eolChar);
+        $newlineSpan  = strspn($short, $phpcsfile->eolChar);
         if ($short !== '' && $newlineSpan > 0) {
             $line  = ($newlineSpan > 1) ? 'newlines' : 'newline';
             $error = "Extra $line found before function comment short description";
-            $phpcsFile->addError($error, ($commentStart + 1));
+            $phpcsfile->adderror($error, ($commentStart + 1));
         }
 
-        $newlineCount = (substr_count($short, $phpcsFile->eolChar) + 1);
+        $newlineCount = (substr_count($short, $phpcsfile->eolChar) + 1);
 
         // Exactly one blank line between short and long description.
-        $long = $comment->getLongComment();
+        $long = $comment->getlongcomment();
         if (empty($long) === false) {
             $between        = $comment->getWhiteSpaceBetween();
-            $newlineBetween = substr_count($between, $phpcsFile->eolChar);
+            $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));
+                $phpcsfile->adderror($error, ($commentStart + $newlineCount + 1));
             }
 
             $newlineCount += $newlineBetween;
@@ -226,15 +228,15 @@ class Moodle_Sniffs_Commenting_FunctionCommentSniff implements PHP_CodeSniffer_S
             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);
+                    $newlineCount += (substr_count($long, $phpcsfile->eolChar) - $newlineSpan + 1);
                 }
 
-                $phpcsFile->addWarning($error, ($commentStart + $newlineCount));
-                $short = rtrim($short, $phpcsFile->eolChar.' ');
+                $phpcsfile->addwarning($error, ($commentStart + $newlineCount));
+                $short = rtrim($short, $phpcsfile->eolChar.' ');
             }
         }
 
-    }//end process()
+    }
 
 
     /**
@@ -254,15 +256,15 @@ class Moodle_Sniffs_Commenting_FunctionCommentSniff implements PHP_CodeSniffer_S
         foreach ($this->commentParser->getThrows() as $throw) {
 
             $exception = $throw->getValue();
-            $errorPos  = ($commentStart + $throw->getLine());
+            $errorPos  = ($commentStart + $throw->getline());
 
             if ($exception === '') {
                 $error = '@throws tag must contain the exception class name';
-                $this->currentFile->addError($error, $errorPos);
+                $this->currentFile->adderror($error, $errorPos);
             }
         }
 
-    }//end processThrows()
+    }
 
 
     /**
@@ -277,8 +279,8 @@ class Moodle_Sniffs_Commenting_FunctionCommentSniff implements PHP_CodeSniffer_S
     {
         // Skip constructor and destructor.
         $className = '';
-        if ($this->_classToken !== null) {
-            $className = $this->currentFile->getDeclarationName($this->_classToken);
+        if ($this->_classtoken !== null) {
+            $className = $this->currentFile->getDeclarationName($this->_classtoken);
             $className = strtolower(ltrim($className, '_'));
         }
 
@@ -289,15 +291,15 @@ class Moodle_Sniffs_Commenting_FunctionCommentSniff implements PHP_CodeSniffer_S
             // Report missing return tag.
             if ($this->commentParser->getReturn() === null) {
                 $error = 'Missing @return tag in function comment';
-                $this->currentFile->addError($error, $commentEnd);
-            } else if (trim($this->commentParser->getReturn()->getRawContent()) === '') {
+                $this->currentFile->adderror($error, $commentEnd);
+            } 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);
+                $errorPos = ($commentStart + $this->commentParser->getReturn()->getline());
+                $this->currentFile->adderror($error, $errorPos);
             }
         }
 
-    }//end processReturn()
+    }
 
 
     /**
@@ -310,7 +312,7 @@ class Moodle_Sniffs_Commenting_FunctionCommentSniff implements PHP_CodeSniffer_S
      */
     protected function processParams($commentStart)
     {
-        $realParams = $this->currentFile->getMethodParameters($this->_functionToken);
+        $realParams = $this->currentFile->getMethodParameters($this->_functiontoken);
 
         $params      = $this->commentParser->getParams();
         $foundParams = array();
@@ -320,15 +322,15 @@ class Moodle_Sniffs_Commenting_FunctionCommentSniff implements PHP_CodeSniffer_S
             $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->addWarning($error, $errorPos);
+                $errorPos = ($params[$lastParm]->getline() + $commentStart);
+                $this->currentFile->addwarning($error, $errorPos);
             }
 
             // 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);
+                $errorPos = ($params[0]->getline() + $commentStart);
+                $this->currentFile->adderror($error, $errorPos);
             }
 
             $previousParam      = null;
@@ -340,12 +342,12 @@ class Moodle_Sniffs_Commenting_FunctionCommentSniff implements PHP_CodeSniffer_S
             foreach ($params as $param) {
 
                 $paramComment = trim($param->getComment());
-                $errorPos     = ($param->getLine() + $commentStart);
+                $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->addWarning($error, $errorPos);
+                    $this->currentFile->addwarning($error, $errorPos);
                 }
 
                 $spaceCount = substr_count($param->getWhitespaceBeforeVarName(), ' ');
@@ -373,14 +375,14 @@ class Moodle_Sniffs_Commenting_FunctionCommentSniff implements PHP_CodeSniffer_S
                     // Check to see if the parameters align properly.
                     if ($param->alignsVariableWith($previousParam) === false) {
                         $error = 'The variable names for parameters '.$previousName.' ('.($pos - 1).') and '.$paramName.' ('.$pos.') do not align';
-                        $this->currentFile->addWarning($error, $errorPos);
+                        $this->currentFile->addwarning($error, $errorPos);
                     }
 
                     if ($param->alignsCommentWith($previousParam) === false) {
                         $error = 'The comments for parameters '.$previousName.' ('.($pos - 1).') and '.$paramName.' ('.$pos.') do not align';
-                        $this->currentFile->addWarning($error, $errorPos);
+                        $this->currentFile->addwarning($error, $errorPos);
                     }
-                }//end if
+                }
 
                 // Make sure the names of the parameter comment matches the
                 // actual parameter.
@@ -397,44 +399,44 @@ class Moodle_Sniffs_Commenting_FunctionCommentSniff implements PHP_CodeSniffer_S
                         $error .= '" does not match actual variable name "'.$realName;
                         $error .= '" at position '.$pos;
 
-                        $this->currentFile->addError($error, $errorPos);
+                        $this->currentFile->adderror($error, $errorPos);
                     }
                 } else {
                     // We must have an extra parameter comment.
                     $error = 'Superfluous doc comment at position '.$pos;
-                    $this->currentFile->addError($error, $errorPos);
+                    $this->currentFile->adderror($error, $errorPos);
                 }
 
                 if ($param->getVarName() === '') {
                     $error = 'Missing parameter name at position '.$pos;
-                     $this->currentFile->addError($error, $errorPos);
+                     $this->currentFile->adderror($error, $errorPos);
                 }
 
                 if ($param->getType() === '') {
                     $error = 'Missing type at position '.$pos;
-                    $this->currentFile->addError($error, $errorPos);
+                    $this->currentFile->adderror($error, $errorPos);
                 }
 
                 if ($paramComment === '') {
                     $error = 'Missing comment for param "'.$paramName.'" at position '.$pos;
-                    $this->currentFile->addError($error, $errorPos);
+                    $this->currentFile->adderror($error, $errorPos);
                 }
 
                 $previousParam = $param;
 
-            }//end foreach
+            }
 
             if ($spaceBeforeVar !== 1 && $spaceBeforeVar !== 10000 && $spaceBeforeComment !== 10000) {
                 $error = 'Expected 1 space after the longest type';
-                $this->currentFile->addError($error, $longestType);
+                $this->currentFile->adderror($error, $longestType);
             }
 
             if ($spaceBeforeComment !== 1 && $spaceBeforeComment !== 10000) {
                 $error = 'Expected 1 space after the longest variable name';
-                $this->currentFile->addError($error, $longestVar);
+                $this->currentFile->adderror($error, $longestVar);
             }
 
-        }//end if
+        }
 
         $realNames = array();
         foreach ($realParams as $realParam) {
@@ -445,18 +447,18 @@ class Moodle_Sniffs_Commenting_FunctionCommentSniff implements PHP_CodeSniffer_S
         $diff = array_diff($realNames, $foundParams);
         foreach ($diff as $neededParam) {
             if (count($params) !== 0) {
-                $errorPos = ($params[(count($params) - 1)]->getLine() + $commentStart);
+                $errorPos = ($params[(count($params) - 1)]->getline() + $commentStart);
             } else {
                 $errorPos = $commentStart;
             }
 
             $error = 'Doc comment for "'.$neededParam.'" missing';
-            $this->currentFile->addError($error, $errorPos);
+            $this->currentFile->adderror($error, $errorPos);
         }
 
-    }//end processParams()
+    }
 
 
-}//end class
+}
 
 ?>
index 695a2b05e80a6a9962ea3e878eba042958f9ac0f..f2b8abfc6b42b976adbd58ed1fe7a16fe8a469a4 100644 (file)
@@ -1,34 +1,36 @@
 <?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 /**
- * PHP_CodeSniffer_Sniffs_Moodle_Commenting_InlineCommentSniff.
- *
- * PHP version 5
+ * php_codesniffer_sniffs_moodle_commenting_inlinecommentsniff.
  *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Nicolas Connault <nicolasconnault@gmail.com>
- *
- * @copyright 2009 Nicolas Connault
+ * @package   lib-pear-php-codesniffer-standards-moodle-sniffs-commenting
+ * @copyright 2008 Nicolas Connault
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @version   CVS: $Id$
- * @link      http://pear.php.net/package/PHP_CodeSniffer
  */
 
 /**
- * PHP_CodeSniffer_Sniffs_Moodle_Commenting_InlineCommentSniff.
+ * php_codesniffer_sniffs_moodle_commenting_inlinecommentsniff.
  *
  * Checks that no perl-style comments are used.
  *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Nicolas Connault <nicolasconnault@gmail.com>
- *
- * @copyright 2009 Nicolas Connault
+ * @copyright 2008 Nicolas Connault
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @version   Release: 1.1.0
- * @link      http://pear.php.net/package/PHP_CodeSniffer
  */
-class Moodle_Sniffs_Commenting_InlineCommentSniff implements PHP_CodeSniffer_Sniff
+class moodle_sniffs_commenting_inlinecommentsniff implements php_codesniffer_sniff
 {
 
 
@@ -41,31 +43,31 @@ class Moodle_Sniffs_Commenting_InlineCommentSniff implements PHP_CodeSniffer_Sni
     {
         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
+     * @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)
+    public function process(PHP_CodeSniffer_File $phpcsfile, $stackptr)
     {
-        $tokens = $phpcsFile->getTokens();
+        $tokens = $phpcsfile->gettokens();
 
-        if ($tokens[$stackPtr]['content']{0} === '#') {
+        if ($tokens[$stackptr]['content']{0} === '#') {
             $error  = 'Perl-style comments are not allowed. Use "// Comment."';
             $error .= ' or "/* comment */" instead.';
-            $phpcsFile->addError($error, $stackPtr);
+            $phpcsfile->adderror($error, $stackptr);
         }
 
-    }//end process()
+    }
 
 
-}//end class
+}
 
 ?>
index c9bb0a38a112f79cb833f1d2190616995379dd61..66376674490c2e19bbe3d45b3bf6528a5d2884c7 100644 (file)
@@ -1,17 +1,25 @@
 <?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 /**
  * Verifies that control statements conform to their coding standards.
  *
- * PHP version 5
- *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Nicolas Connault <nicolasconnault@gmail.com>
- *
- * @copyright 2009 Nicolas Connault
+ * @package   lib-pear-php-codesniffer-standards-moodle-sniffs-controlstructures
+ * @copyright 2008 Nicolas Connault
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @version   CVS: $Id$
- * @link      http://pear.php.net/package/PHP_CodeSniffer
  */
 
 if (class_exists('PHP_CodeSniffer_Standards_AbstractPatternSniff', true) === false) {
@@ -21,27 +29,21 @@ if (class_exists('PHP_CodeSniffer_Standards_AbstractPatternSniff', true) === fal
 /**
  * Verifies that control statements conform to their coding standards.
  *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Nicolas Connault <nicolasconnault@gmail.com>
- *
- * @copyright 2009 Nicolas Connault
+ * @copyright 2008 Nicolas Connault
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @version   Release: 1.1.0
- * @link      http://pear.php.net/package/PHP_CodeSniffer
  */
-class Moodle_Sniffs_ControlStructures_ControlSignatureSniff extends PHP_CodeSniffer_Standards_AbstractPatternSniff
+class moodle_sniffs_controlstructures_controlsignaturesniff extends php_codesniffer_standards_abstractpatternsniff
 {
 
 
     /**
-     * Constructs a Moodle_Sniffs_ControlStructures_ControlSignatureSniff.
+     * Constructs a moodle_sniffs_controlstructures_controlsignaturesniff.
      */
     public function __construct()
     {
         parent::__construct(true);
 
-    }//end __construct()
+    }
 
 
     /**
@@ -62,9 +64,9 @@ class Moodle_Sniffs_ControlStructures_ControlSignatureSniff extends PHP_CodeSnif
                 'do {EOL',
                );
 
-    }//end getPatterns()
+    }
 
 
-}//end class
+}
 
 ?>
index a30ceb0a95569f0d7cb6788476847ef83284ceed..d95da4f3d2aae285607a27a3402dbb6104bb4147 100644 (file)
@@ -1,35 +1,37 @@
 <?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 /**
- * Moodle_Sniffs_ControlStructures_ElseIfDeclarationSniff.
- *
- * PHP version 5
+ * moodle_sniffs_controlstructures_elseifdeclarationsniff.
  *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Greg Sherwood <gsherwood@squiz.net>
- * @author    Marc McIntyre <mmcintyre@squiz.net>
- * @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600)
- * @license   http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence
- * @version   CVS: $Id$
- * @link      http://pear.php.net/package/PHP_CodeSniffer
+ * @package   lib-pear-php-codesniffer-standards-moodle-sniffs-controlstructures
+ * @copyright 2008 Nicolas Connault
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
 /**
- * Moodle_Sniffs_ControlStructures_ElseIfDeclarationSniff.
+ * moodle_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 <gsherwood@squiz.net>
- * @author    Marc McIntyre <mmcintyre@squiz.net>
- * @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600)
- * @license   http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence
- * @version   Release: 1.1.0
- * @link      http://pear.php.net/package/PHP_CodeSniffer
+ * @copyright 2008 Nicolas Connault
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
-class Moodle_Sniffs_ControlStructures_ElseIfDeclarationSniff implements PHP_CodeSniffer_Sniff
+class moodle_sniffs_controlstructures_elseifdeclarationsniff implements php_codesniffer_sniff
 {
 
 
@@ -42,27 +44,27 @@ class Moodle_Sniffs_ControlStructures_ElseIfDeclarationSniff implements PHP_Code
     {
         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
+     * @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)
+    public function process(PHP_CodeSniffer_File $phpcsfile, $stackptr)
     {
         $error = 'Usage of ELSEIF not allowed. Use ELSE IF instead.';
-        $phpcsFile->addError($error, $stackPtr);
+        $phpcsfile->adderror($error, $stackptr);
 
-    }//end process()
+    }
 
 
-}//end class
+}
 
 
 ?>
index 63803d9f0133ca35711048f71572dff548a9d880..20d8030b3e642499bc152951fea2f1ba0263bd60 100644 (file)
@@ -1,34 +1,36 @@
 <?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 /**
- * Moodle_Sniffs_ControlStructures_InlineControlStructureSniff.
- *
- * PHP version 5
+ * moodle_sniffs_controlstructures_inlinecontrolstructuresniff.
  *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Greg Sherwood <gsherwood@squiz.net>
- * @author    Marc McIntyre <mmcintyre@squiz.net>
- * @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600)
- * @license   http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence
- * @version   CVS: $Id$
- * @link      http://pear.php.net/package/PHP_CodeSniffer
+ * @package   lib-pear-php-codesniffer-standards-moodle-sniffs-controlstructures
+ * @copyright 2008 Nicolas Connault
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
 /**
- * Moodle_Sniffs_ControlStructures_InlineControlStructureSniff.
+ * moodle_sniffs_controlstructures_inlinecontrolstructuresniff.
  *
  * Verifies that inline control statements are not present.
  *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Greg Sherwood <gsherwood@squiz.net>
- * @author    Marc McIntyre <mmcintyre@squiz.net>
- * @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600)
- * @license   http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence
- * @version   Release: 1.1.0
- * @link      http://pear.php.net/package/PHP_CodeSniffer
+ * @copyright 2008 Nicolas Connault
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
-class Moodle_Sniffs_ControlStructures_InlineControlStructureSniff implements PHP_CodeSniffer_Sniff
+class moodle_sniffs_controlstructures_inlinecontrolstructuresniff implements php_codesniffer_sniff
 {
 
     /**
@@ -36,7 +38,7 @@ class Moodle_Sniffs_ControlStructures_InlineControlStructureSniff implements PHP
      *
      * @var array
      */
-    public $supportedTokenizers = array(
+    public $supportedtokenizers = array(
                                    'PHP',
                                    'JS',
                                   );
@@ -65,33 +67,33 @@ class Moodle_Sniffs_ControlStructures_InlineControlStructureSniff implements PHP
                 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
+     * @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)
+    public function process(PHP_CodeSniffer_File $phpcsfile, $stackptr)
     {
-        $tokens = $phpcsFile->getTokens();
+        $tokens = $phpcsfile->gettokens();
 
-        if (isset($tokens[$stackPtr]['scope_opener']) === false) {
+        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)) {
+            if (($tokens[$stackptr]['code'] === T_ELSE) && ($tokens[($stackptr + 2)]['code'] === T_IF)) {
                 return;
             }
 
-            if ($tokens[$stackPtr]['code'] === T_WHILE) {
+            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];
+                $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) {
@@ -104,17 +106,17 @@ class Moodle_Sniffs_ControlStructures_InlineControlStructureSniff implements PHP
             // 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);
+                $phpcsfile->adderror('Inline control structures are not allowed', $stackptr);
             } else {
-                $phpcsFile->addWarning('Inline control structures are discouraged', $stackPtr);
+                $phpcsfile->addwarning('Inline control structures are discouraged', $stackptr);
             }
 
             return;
-        }//end if
+        }
 
-    }//end process()
+    }
 
 
-}//end class
+}
 
 ?>
diff --git a/lib/pear/PHP/CodeSniffer/Standards/Moodle/Sniffs/Files/ClosingPHPTagSniff.php b/lib/pear/PHP/CodeSniffer/Standards/Moodle/Sniffs/Files/ClosingPHPTagSniff.php
new file mode 100644 (file)
index 0000000..d2cfeb6
--- /dev/null
@@ -0,0 +1,61 @@
+<?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+/**
+ * File including class for sniffing out the closing PHP tag
+ *
+ * @package   lib-pear-php-codesniffer-standards-moodle-sniffs-files
+ * @copyright 2008 Nicolas Connault
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+/**
+ * Class for sniffing out the closing PHP tag
+ *
+ * @copyright 2008 Nicolas Connault
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class moodle_sniffs_files_closingphptagsniff 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);
+    }
+
+    /**
+     * 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();
+
+        $last_token = end($tokens);
+        if ($last_token['code'] === T_CLOSE_TAG) {
+            $error  = 'Closing PHP tag is not required at the end of the file. Please remove.';
+            $phpcsfile->addwarning($error, $stackptr);
+        }
+    }
+}
index 6a5bb2461181c629baf92b862fbc0d84606adfdd..832a26150dd7e3c40dcedec7cef9e91bde438980 100644 (file)
@@ -1,34 +1,38 @@
 <?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 /**
- * Moodle_Sniffs_Files_IncludingFileSniff.
- *
- * PHP version 5
+ * moodle_sniffs_files_includingfilesniff.
  *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Nicolas Connault <nicolasconnault@gmail.com>
- * @copyright 2009 Nicolas Connault
+ * @package   lib-pear-php-codesniffer-standards-moodle-sniffs-files
+ * @copyright 2008 Nicolas Connault
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @version   CVS: $Id$
- * @link      http://pear.php.net/package/PHP_CodeSniffer
  */
 
 /**
- * Moodle_Sniffs_Files_IncludingFileSniff.
+ * moodle_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    Nicolas Connault <nicolasconnault@gmail.com>
- * @copyright 2009 Nicolas Connault
+ * @copyright 2008 Nicolas Connault
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @version   Release: 1.1.0
- * @link      http://pear.php.net/package/PHP_CodeSniffer
  */
-class Moodle_Sniffs_Files_IncludingFileSniff implements PHP_CodeSniffer_Sniff
+class moodle_sniffs_files_includingfilesniff implements php_codesniffer_sniff
 {
 
     /**
@@ -58,37 +62,37 @@ class Moodle_Sniffs_Files_IncludingFileSniff implements PHP_CodeSniffer_Sniff
                 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
+     * @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)
+    public function process(PHP_CodeSniffer_File $phpcsfile, $stackptr)
     {
-        $tokens = $phpcsFile->getTokens();
+        $tokens = $phpcsfile->gettokens();
 
-        //$nextToken = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr + 1), null, true);
-        //if ($tokens[$nextToken]['code'] === T_OPEN_PARENTHESIS) {
-        //    $error  = '"'.$tokens[$stackPtr]['content'].'"';
+        //$nexttoken = $phpcsfile->findNext(PHP_CodeSniffer_tokens::$emptyTokens, ($stackptr + 1), null, true);
+        //if ($tokens[$nexttoken]['code'] === T_OPEN_PARENTHESIS) {
+        //    $error  = '"'.$tokens[$stackptr]['content'].'"';
         //    $error .= ' is a statement, not a function; ';
         //    $error .= 'no parentheses are required';
-        //    $phpcsFile->addError($error, $stackPtr);
+        //    $phpcsfile->adderror($error, $stackptr);
         //}
 
-        $inCondition = (count($tokens[$stackPtr]['conditions']) !== 0) ? true : false;
+        $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[$stackptr]['nested_parenthesis']) === true) {
+            foreach ($tokens[$stackptr]['nested_parenthesis'] as $left => $right) {
                 if (isset($tokens[$left]['parenthesis_owner']) === true) {
                     $inCondition = true;
                 }
@@ -97,40 +101,40 @@ class Moodle_Sniffs_Files_IncludingFileSniff implements PHP_CodeSniffer_Sniff
 
         // Check to see if they are assigning the return value of this including call.
         // If they are then they are probably checking it, so its conditional.
-        $previous = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true);
-        if (in_array($tokens[$previous]['code'], PHP_CodeSniffer_Tokens::$assignmentTokens) === true) {
+        $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'];
+        $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);
+                $phpcsfile->adderror($error, $stackptr);
             } else if ($tokenCode === T_REQUIRE) {
                 $error  = 'File is being conditionally included; ';
                 $error .= 'use "include" instead';
-                $phpcsFile->addError($error, $stackPtr);
+                $phpcsfile->adderror($error, $stackptr);
             }
         } 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);
+                $phpcsfile->adderror($error, $stackptr);
             } else if ($tokenCode === T_INCLUDE) {
                 $error  = 'File is being unconditionally included; ';
                 $error .= 'use "require" instead';
-                $phpcsFile->addError($error, $stackPtr);
+                $phpcsfile->adderror($error, $stackptr);
             }
-        }//end if
+        }
 
-    }//end process()
+    }
 
 
-}//end class
+}
 
 ?>
index 8ab212f69d1cdbd6f65960b373f0586d52806f02..56132466e6da18b34693e50fe439e1fe3c49339e 100644 (file)
@@ -1,34 +1,36 @@
 <?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 /**
- * Moodle_Sniffs_Files_LineEndingsSniff.
- *
- * PHP version 5
+ * moodle_sniffs_files_lineendingssniff.
  *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Greg Sherwood <gsherwood@squiz.net>
- * @author    Marc McIntyre <mmcintyre@squiz.net>
- * @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600)
- * @license   http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence
- * @version   CVS: $Id$
- * @link      http://pear.php.net/package/PHP_CodeSniffer
+ * @package   lib-pear-php-codesniffer-standards-moodle-sniffs-files
+ * @copyright 2008 Nicolas Connault
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
 /**
- * Moodle_Sniffs_Files_LineEndingsSniff.
+ * moodle_sniffs_files_lineendingssniff.
  *
  * Checks that end of line characters are correct.
  *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Greg Sherwood <gsherwood@squiz.net>
- * @author    Marc McIntyre <mmcintyre@squiz.net>
- * @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600)
- * @license   http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence
- * @version   Release: 1.1.0
- * @link      http://pear.php.net/package/PHP_CodeSniffer
+ * @copyright 2008 Nicolas Connault
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
-class Moodle_Sniffs_Files_LineEndingsSniff implements PHP_CodeSniffer_Sniff
+class moodle_sniffs_files_lineendingssniff implements php_codesniffer_sniff
 {
 
     /**
@@ -48,41 +50,41 @@ class Moodle_Sniffs_Files_LineEndingsSniff implements PHP_CodeSniffer_Sniff
     {
         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
+     * @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)
+    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) {
+        if ($stackptr !== 0) {
+            if ($phpcsfile->findPrevious(T_OPEN_TAG, ($stackptr - 1)) !== false) {
                 return;
             }
         }
 
-        if ($phpcsFile->eolChar !== $this->eolChar) {
+        if ($phpcsfile->eolChar !== $this->eolChar) {
             $expected = $this->eolChar;
             $expected = str_replace("\n", '\n', $expected);
             $expected = str_replace("\r", '\r', $expected);
-            $found    = $phpcsFile->eolChar;
+            $found    = $phpcsfile->eolChar;
             $found    = str_replace("\n", '\n', $found);
             $found    = str_replace("\r", '\r', $found);
             $error    = "End of line character is invalid; expected \"$expected\" but found \"$found\"";
-            $phpcsFile->addError($error, $stackPtr);
+            $phpcsfile->adderror($error, $stackptr);
         }
 
-    }//end process()
+    }
 
 
-}//end class
+}
 
 ?>
index 00a14cfd5d97dd667d0094b48aa4ca1b9acf30f0..303fe48f0e214108fda944fdabc6798fe24c2bbf 100644 (file)
@@ -1,36 +1,38 @@
 <?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 /**
- * Moodle_Sniffs_Files_LineLengthSniff.
- *
- * PHP version 5
+ * moodle_sniffs_files_linelengthsniff.
  *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Greg Sherwood <gsherwood@squiz.net>
- * @author    Marc McIntyre <mmcintyre@squiz.net>
- * @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600)
- * @license   http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence
- * @version   CVS: $Id$
- * @link      http://pear.php.net/package/PHP_CodeSniffer
+ * @package   lib-pear-php-codesniffer-standards-moodle-sniffs-files
+ * @copyright 2008 Nicolas Connault
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
 /**
- * Moodle_Sniffs_Files_LineLengthSniff.
+ * moodle_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 <gsherwood@squiz.net>
- * @author    Marc McIntyre <mmcintyre@squiz.net>
- * @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600)
- * @license   http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence
- * @version   Release: 1.1.0
- * @link      http://pear.php.net/package/PHP_CodeSniffer
+ * @copyright 2008 Nicolas Connault
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
-class Moodle_Sniffs_Files_LineLengthSniff implements PHP_CodeSniffer_Sniff
+class moodle_sniffs_files_linelengthsniff implements php_codesniffer_sniff
 {
 
     /**
@@ -47,7 +49,7 @@ class Moodle_Sniffs_Files_LineLengthSniff implements PHP_CodeSniffer_Sniff
      *
      * @var int
      */
-    protected $absoluteLineLimit = 200;
+    protected $absolutelineLimit = 200;
 
 
     /**
@@ -59,76 +61,76 @@ class Moodle_Sniffs_Files_LineLengthSniff implements PHP_CodeSniffer_Sniff
     {
         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
+     * @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)
+    public function process(PHP_CodeSniffer_File $phpcsfile, $stackptr)
     {
-        $tokens = $phpcsFile->getTokens();
+        $tokens = $phpcsfile->gettokens();
 
         // Make sure this is the first open tag.
-        $previousOpenTag = $phpcsFile->findPrevious(array(T_OPEN_TAG), ($stackPtr - 1));
+        $previousOpenTag = $phpcsfile->findPrevious(array(T_OPEN_TAG), ($stackptr - 1));
         if ($previousOpenTag !== false) {
             return;
         }
 
         $tokenCount         = 0;
-        $currentLineContent = '';
-        $currentLine        = 1;
+        $currentlinecontent = '';
+        $currentline        = 1;
 
-        for (; $tokenCount < $phpcsFile->numTokens; $tokenCount++) {
-            if ($tokens[$tokenCount]['line'] === $currentLine) {
-                $currentLineContent .= $tokens[$tokenCount]['content'];
+        for (; $tokenCount < $phpcsfile->numTokens; $tokenCount++) {
+            if ($tokens[$tokenCount]['line'] === $currentline) {
+                $currentlinecontent .= $tokens[$tokenCount]['content'];
             } else {
-                $currentLineContent = trim($currentLineContent, $phpcsFile->eolChar);
-                $this->checkLineLength($phpcsFile, ($tokenCount - 1), $currentLineContent);
-                $currentLineContent = $tokens[$tokenCount]['content'];
-                $currentLine++;
+                $currentlinecontent = trim($currentlinecontent, $phpcsfile->eolChar);
+                $this->checklineLength($phpcsfile, ($tokenCount - 1), $currentlinecontent);
+                $currentlinecontent = $tokens[$tokenCount]['content'];
+                $currentline++;
             }
         }
 
-        $this->checkLineLength($phpcsFile, ($tokenCount - 1), $currentLineContent);
+        $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.
+     * @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)
+    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 && preg_match('|@license|', $lineContent) === 0) {
-            $lineLength = strlen($lineContent);
-            if ($this->absoluteLineLimit > 0 && $lineLength > $this->absoluteLineLimit) {
-                $error = 'Line exceeds maximum limit of '.$this->absoluteLineLimit." characters; contains $lineLength characters";
-                $phpcsFile->addError($error, $stackPtr);
+        if (preg_match('|@version[^\$]+\$Id|', $linecontent) === 0 && preg_match('|@license|', $linecontent) === 0) {
+            $lineLength = strlen($linecontent);
+            if ($this->absolutelineLimit > 0 && $lineLength > $this->absolutelineLimit) {
+                $error = 'line exceeds maximum limit of '.$this->absolutelineLimit." characters; contains $lineLength characters";
+                $phpcsfile->adderror($error, $stackptr);
             } else if ($lineLength > $this->lineLimit) {
-                $warning = 'Line exceeds '.$this->lineLimit." characters; contains $lineLength characters";
-                $phpcsFile->addWarning($warning, $stackPtr);
+                $warning = 'line exceeds '.$this->lineLimit." characters; contains $lineLength characters";
+                $phpcsfile->addwarning($warning, $stackptr);
             }
         }
 
-    }//end checkLineLength()
+    }
 
 
-}//end class
+}
 
 ?>
index 4dee2b7b955e09aa8731178dd9d9ef4ffdf17373..4927f712d4b570cd2c3dbb7d872218e3b291ee10 100644 (file)
@@ -1,34 +1,36 @@
 <?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 /**
- * Moodle_Sniffs_Formatting_SpaceAfterCastSniff.
- *
- * PHP version 5
+ * moodle_sniffs_formatting_spaceaftercastsniff.
  *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Nicolas Connault <nicolasconnault@gmail.com>
- *
- * @copyright 2009 Nicolas Connault
+ * @package   lib-pear-php-codesniffer-standards-moodle-sniffs-formatting
+ * @copyright 2008 Nicolas Connault
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @version   CVS: $Id$
- * @link      http://pear.php.net/package/PHP_CodeSniffer
  */
 
 /**
- * Moodle_Sniffs_Formatting_SpaceAfterCastSniff.
+ * moodle_sniffs_formatting_spaceaftercastsniff.
  *
  * Ensures there is a single space after cast tokens.
  *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Nicolas Connault <nicolasconnault@gmail.com>
- *
- * @copyright 2009 Nicolas Connault
+ * @copyright 2008 Nicolas Connault
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @version   Release: 1.1.0
- * @link      http://pear.php.net/package/PHP_CodeSniffer
  */
-class Moodle_Sniffs_Formatting_SpaceAfterCastSniff implements PHP_CodeSniffer_Sniff
+class moodle_sniffs_formatting_spaceaftercastsniff implements php_codesniffer_sniff
 {
 
 
@@ -39,38 +41,38 @@ class Moodle_Sniffs_Formatting_SpaceAfterCastSniff implements PHP_CodeSniffer_Sn
      */
     public function register()
     {
-        return PHP_CodeSniffer_Tokens::$castTokens;
+        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
+     * @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)
+    public function process(PHP_CodeSniffer_File $phpcsfile, $stackptr)
     {
-        $tokens = $phpcsFile->getTokens();
+        $tokens = $phpcsfile->gettokens();
 
-        if ($tokens[($stackPtr + 1)]['code'] !== T_WHITESPACE) {
+        if ($tokens[($stackptr + 1)]['code'] !== T_WHITESPACE) {
             $error = 'A cast statement must be followed by a single space';
-            $phpcsFile->addError($error, $stackPtr);
+            $phpcsfile->adderror($error, $stackptr);
             return;
         }
 
-        if ($tokens[($stackPtr + 1)]['content'] !== ' ') {
+        if ($tokens[($stackptr + 1)]['content'] !== ' ') {
             $error = 'A cast statement must be followed by a single space';
-            $phpcsFile->addError($error, $stackPtr);
+            $phpcsfile->adderror($error, $stackptr);
         }
 
-    }//end process()
+    }
 
 
-}//end class
+}
 
 ?>
index d559a7a778154c726aa01401ca7a68a89efae7c8..ae4ef7894a5a99b1d4f5dd277bfa76f93025e975 100644 (file)
@@ -1,34 +1,36 @@
 <?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 /**
- * Moodle_Sniffs_Functions_FunctionCallArgumentSpacingSniff.
- *
- * PHP version 5
- *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Nicolas Connault <nicolasconnault@gmail.com>
+ * moodle_sniffs_functions_functioncallargumentspacingsniff.
  *
- * @copyright 2009 Nicolas Connault
+ * @package   lib-pear-php-codesniffer-standards-moodle-sniffs-functions
+ * @copyright 2008 Nicolas Connault
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @version   CVS: $Id$
- * @link      http://pear.php.net/package/PHP_CodeSniffer
  */
 
 /**
- * Moodle_Sniffs_Functions_FunctionCallArgumentSpacingSniff.
+ * moodle_sniffs_functions_functioncallargumentspacingsniff.
  *
  * Checks that calls to methods and functions are spaced correctly.
  *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Nicolas Connault <nicolasconnault@gmail.com>
- *
- * @copyright 2009 Nicolas Connault
+ * @copyright 2008 Nicolas Connault
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @version   Release: 1.1.0
- * @link      http://pear.php.net/package/PHP_CodeSniffer
  */
-class Moodle_Sniffs_Functions_FunctionCallArgumentSpacingSniff implements PHP_CodeSniffer_Sniff
+class moodle_sniffs_functions_functioncallargumentspacingsniff implements php_codesniffer_sniff
 {
 
 
@@ -41,36 +43,36 @@ class Moodle_Sniffs_Functions_FunctionCallArgumentSpacingSniff implements PHP_Co
     {
         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
+     * @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)
+    public function process(PHP_CodeSniffer_File $phpcsfile, $stackptr)
     {
-        $tokens = $phpcsFile->getTokens();
+        $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;
-        $functionKeyword = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true);
+        $functionName    = $stackptr;
+        $functionKeyword = $phpcsfile->findPrevious(PHP_CodeSniffer_tokens::$emptyTokens, ($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);
+        $openBracket = $phpcsfile->findNext(PHP_CodeSniffer_tokens::$emptyTokens, ($functionName + 1), null, true);
         if ($tokens[$openBracket]['code'] !== T_OPEN_PARENTHESIS) {
             return;
         }
@@ -78,7 +80,7 @@ class Moodle_Sniffs_Functions_FunctionCallArgumentSpacingSniff implements PHP_Co
         $closeBracket = $tokens[$openBracket]['parenthesis_closer'];
 
         $nextSeperator = $openBracket;
-        while (($nextSeperator = $phpcsFile->findNext(array(T_COMMA, T_VARIABLE), ($nextSeperator + 1), $closeBracket)) !== false) {
+        while (($nextSeperator = $phpcsfile->findNext(array(T_COMMA, T_VARIABLE), ($nextSeperator + 1), $closeBracket)) !== false) {
             // 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'];
@@ -90,46 +92,46 @@ class Moodle_Sniffs_Functions_FunctionCallArgumentSpacingSniff implements PHP_Co
             if ($tokens[$nextSeperator]['code'] === T_COMMA) {
                 if ($tokens[($nextSeperator - 1)]['code'] === T_WHITESPACE) {
                     $error = 'Space found before comma in function call';
-                    $phpcsFile->addWarning($error, $stackPtr);
+                    $phpcsfile->addwarning($error, $stackptr);
                 }
 
                 if ($tokens[($nextSeperator + 1)]['code'] !== T_WHITESPACE) {
                     $error = 'No space found after comma in function call';
-                    $phpcsFile->addWarning($error, $stackPtr);
+                    $phpcsfile->addwarning($error, $stackptr);
                 } 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) {
+                    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; ';
                             $error .= $space.' found';
-                            $phpcsFile->addWarning($error, $stackPtr);
+                            $phpcsfile->addwarning($error, $stackptr);
                         }
                     }
                 }
             } 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) {
+                // 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->addWarning($error, $stackPtr);
+                            $phpcsfile->addwarning($error, $stackptr);
                         }
 
-                        if ($tokens[($nextToken + 1)]['code'] !== T_WHITESPACE) {
+                        if ($tokens[($nexttoken + 1)]['code'] !== T_WHITESPACE) {
                             $error = 'Expected 1 space after = sign of default value';
-                            $phpcsFile->addWarning($error, $stackPtr);
+                            $phpcsfile->addwarning($error, $stackptr);
                         }
                     }
                 }
-            }//end if
-        }//end while
+            }
+        }
 
-    }//end process()
+    }
 
 
-}//end class
+}
 
 ?>
index a7780969753449d276f0f17e372366dd24900e1e..2da9a624ff955af7dffb84c5ea3d1452023a6390 100644 (file)
@@ -1,32 +1,34 @@
 <?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 /**
- * Moodle_Sniffs_Functions_FunctionCallSignatureSniff.
- *
- * PHP version 5
+ * moodle_sniffs_functions_functioncallsignaturesniff.
  *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Nicolas Connault <nicolasconnault@gmail.com>
- *
- * @copyright 2009 Nicolas Connault
+ * @package   lib-pear-php-codesniffer-standards-moodle-sniffs-functions
+ * @copyright 2008 Nicolas Connault
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @version   CVS: $Id$
- * @link      http://pear.php.net/package/PHP_CodeSniffer
  */
 
 /**
- * Moodle_Sniffs_Functions_FunctionCallSignatureSniff.
- *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Nicolas Connault <nicolasconnault@gmail.com>
+ * moodle_sniffs_functions_functioncallsignaturesniff.
  *
- * @copyright 2009 Nicolas Connault
+ * @copyright 2008 Nicolas Connault
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @version   Release: 1.1.0
- * @link      http://pear.php.net/package/PHP_CodeSniffer
  */
-class Moodle_Sniffs_Functions_FunctionCallSignatureSniff implements PHP_CodeSniffer_Sniff
+class moodle_sniffs_functions_functioncallsignaturesniff implements php_codesniffer_sniff
 {
 
 
@@ -39,24 +41,24 @@ class Moodle_Sniffs_Functions_FunctionCallSignatureSniff implements PHP_CodeSnif
     {
         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
+     * @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)
+    public function process(PHP_CodeSniffer_File $phpcsfile, $stackptr)
     {
-        $tokens = $phpcsFile->getTokens();
+        $tokens = $phpcsfile->gettokens();
 
         // Find the next non-empty token.
-        $next = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr + 1), null, true);
+        $next = $phpcsfile->findNext(PHP_CodeSniffer_tokens::$emptyTokens, ($stackptr + 1), null, true);
 
         if ($tokens[$next]['code'] !== T_OPEN_PARENTHESIS) {
             // Not a function call.
@@ -69,7 +71,7 @@ class Moodle_Sniffs_Functions_FunctionCallSignatureSniff implements PHP_CodeSnif
         }
 
         // Find the previous non-empty token.
-        $previous = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true);
+        $previous = $phpcsfile->findPrevious(PHP_CodeSniffer_tokens::$emptyTokens, ($stackptr - 1), null, true);
         if ($tokens[$previous]['code'] === T_FUNCTION) {
             // It's a function definition, not a function call.
             return;
@@ -80,23 +82,23 @@ class Moodle_Sniffs_Functions_FunctionCallSignatureSniff implements PHP_CodeSnif
             return;
         }
 
-        if (($stackPtr + 1) !== $next) {
+        if (($stackptr + 1) !== $next) {
             // Checking this: $value = my_function[*](...).
             $error = 'Space before opening parenthesis of function call prohibited';
-            $phpcsFile->addError($error, $stackPtr);
+            $phpcsfile->adderror($error, $stackptr);
         }
 
         if ($tokens[($next + 1)]['code'] === T_WHITESPACE) {
             // Checking this: $value = my_function([*]...).
             $error = 'Space after opening parenthesis of function call prohibited';
-            $phpcsFile->addError($error, $stackPtr);
+            $phpcsfile->adderror($error, $stackptr);
         }
 
         $closer = $tokens[$next]['parenthesis_closer'];
 
         if ($tokens[($closer - 1)]['code'] === T_WHITESPACE) {
             // Checking this: $value = my_function(...[*]).
-            $between = $phpcsFile->findNext(T_WHITESPACE, ($next + 1), null, true);
+            $between = $phpcsfile->findNext(T_WHITESPACE, ($next + 1), null, true);
 
             // Only throw an error if there is some content between the parenthesis.
             // IE. Checking for this: $value = my_function().
@@ -105,21 +107,21 @@ class Moodle_Sniffs_Functions_FunctionCallSignatureSniff implements PHP_CodeSnif
             // $value = my_function( ).
             if ($between !== $closer) {
                 $error = 'Space before closing parenthesis of function call prohibited';
-                $phpcsFile->addError($error, $closer);
+                $phpcsfile->adderror($error, $closer);
             }
         }
 
-        $next = $phpcsFile->findNext(T_WHITESPACE, ($closer + 1), null, true);
+        $next = $phpcsfile->findNext(T_WHITESPACE, ($closer + 1), null, true);
 
         if ($tokens[$next]['code'] === T_SEMICOLON) {
-            if (in_array($tokens[($closer + 1)]['code'], PHP_CodeSniffer_Tokens::$emptyTokens) === true) {
+            if (in_array($tokens[($closer + 1)]['code'], PHP_CodeSniffer_tokens::$emptyTokens) === true) {
                 $error = 'Space after closing parenthesis of function call prohibited';
-                $phpcsFile->addError($error, $closer);
+                $phpcsfile->adderror($error, $closer);
             }
         }
 
-    }//end process()
+    }
 
 
-}//end class
+}
 ?>
index 76e03a5d0c562ab13ec8afa84b3303a2156fd467..1dcf2d1e9c4d9bccf1b7c2f9c46551b71deb5c73 100644 (file)
@@ -1,16 +1,25 @@
 <?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 /**
- * Moodle_Sniffs_Functions_FunctionDeclarationSniff.
- *
- * PHP version 5
+ * moodle_sniffs_functions_functiondeclarationsniff.
  *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Nicolas Connault <nicolasconnault@gmail.com>
- * @copyright 2006 Moodle Pty Ltd (ABN 77 084 670 600)
- * @license   http://www.gnu.org/copyleft/gpl.html GPL 
- * @version   CVS: $Id:
- * @link      http://pear.php.net/package/PHP_CodeSniffer
+ * @package   lib-pear-php-codesniffer-standards-moodle-sniffs-functions
+ * @copyright 2008 Nicolas Connault
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
 if (class_exists('PHP_CodeSniffer_Standards_AbstractPatternSniff', true) === false) {
@@ -18,19 +27,14 @@ if (class_exists('PHP_CodeSniffer_Standards_AbstractPatternSniff', true) === fal
 }
 
 /**
- * Moodle_Sniffs_Functions_FunctionDeclarationSniff.
+ * moodle_sniffs_functions_functiondeclarationsniff.
  *
  * Checks the function declaration is correct.
  *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Nicolas Connault <nicolasconnault@gmail.com>
- * @copyright 2006 Moodle Pty Ltd (ABN 77 084 670 600)
- * @license http://www.gnu.org/copyleft/gpl.html GPL 
- * @version   CVS: $Id:
- * @link      http://pear.php.net/package/PHP_CodeSniffer
+ * @copyright 2008 Nicolas Connault
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
-class Moodle_Sniffs_Functions_FunctionDeclarationSniff extends PHP_CodeSniffer_Standards_AbstractPatternSniff
+class moodle_sniffs_functions_functiondeclarationsniff extends php_codesniffer_standards_abstractpatternsniff
 {
 
 
@@ -46,9 +50,9 @@ class Moodle_Sniffs_Functions_FunctionDeclarationSniff extends PHP_CodeSniffer_S
                 'abstract function abc(...);'
                );
 
-    }//end getPatterns()
+    }
 
 
-}//end class
+}
 
 ?>
index afbe5065f2e5bb022889b02b479f439eab8b619b..776a3ffd86ac29aed8a1b0730e3bf9f02ac031d2 100644 (file)
@@ -1,32 +1,36 @@
 <?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 /**
- * Moodle_Sniffs_Functions_LowercaseFunctionKeywordsSniff.
- *
- * PHP version 5
+ * moodle_sniffs_functions_lowercasefunctionkeywordssniff.
  *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Nicolas Connault <nicolasconnault@gmail.com>
- * @copyright 2006 Moodle Pty Ltd (ABN 77 084 670 600)
- * @license   http://www.gnu.org/copyleft/gpl.html GPL 
- * @version   CVS: $Id:
- * @link      http://pear.php.net/package/PHP_CodeSniffer
+ * @package   lib-pear-php-codesniffer-standards-moodle-sniffs-functions
+ * @copyright 2008 Nicolas Connault
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
 /**
- * Moodle_Sniffs_Functions_LowercaseFunctionKeywordsSniff.
+ * moodle_sniffs_functions_lowercasefunctionkeywordssniff.
  *
  * Ensures all class keywords are lowercase.
  *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Nicolas Connault <nicolasconnault@gmail.com>
- * @copyright 2006 Moodle Pty Ltd (ABN 77 084 670 600)
- * @license   http://www.gnu.org/copyleft/gpl.html GPL 
- * @version   CVS: $Id:
- * @link      http://pear.php.net/package/PHP_CodeSniffer
+ * @copyright 2008 Nicolas Connault
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
-class Moodle_Sniffs_Functions_LowercaseFunctionKeywordsSniff implements PHP_CodeSniffer_Sniff
+class moodle_sniffs_functions_lowercasefunctionkeywordssniff implements php_codesniffer_sniff
 {
 
 
@@ -45,33 +49,33 @@ class Moodle_Sniffs_Functions_LowercaseFunctionKeywordsSniff implements PHP_Code
                 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
+     * @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)
+    public function process(PHP_CodeSniffer_File $phpcsfile, $stackptr)
     {
-        $tokens = $phpcsFile->getTokens();
+        $tokens = $phpcsfile->gettokens();
 
-        $content = $tokens[$stackPtr]['content'];
+        $content = $tokens[$stackptr]['content'];
         if ($content !== strtolower($content)) {
             $type     = strtoupper($content);
             $expected = strtolower($content);
             $error    = "$type keyword must be lowercase; expected \"$expected\" but found \"$content\"";
-            $phpcsFile->addError($error, $stackPtr);
+            $phpcsfile->adderror($error, $stackptr);
         }
 
-    }//end process()
+    }
 
 
-}//end class
+}
 
 ?>
index f906472cf8515cfb4c20accc6f1a571f2e921104..02b83ecbd0a50e90239f62a33c054fe80ef8b68c 100644 (file)
@@ -1,35 +1,37 @@
 <?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 /**
- * Moodle_Sniffs_Functions_ValidDefaultValueSniff.
- *
- * PHP version 5
+ * moodle_sniffs_functions_validdefaultvaluesniff.
  *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Nicolas Connault <nicolasconnault@gmail.com>
- *
- * @copyright 2009 Nicolas Connault
+ * @package   lib-pear-php-codesniffer-standards-moodle-sniffs-functions
+ * @copyright 2008 Nicolas Connault
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @version   CVS: $Id$
- * @link      http://pear.php.net/package/PHP_CodeSniffer
  */
 
 /**
- * Moodle_Sniffs_Functions_ValidDefaultValueSniff.
+ * moodle_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    Nicolas Connault <nicolasconnault@gmail.com>
- *
- * @copyright 2009 Nicolas Connault
+ * @copyright 2008 Nicolas Connault
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @version   Release: 1.1.0
- * @link      http://pear.php.net/package/PHP_CodeSniffer
  */
-class Moodle_Sniffs_Functions_ValidDefaultValueSniff implements PHP_CodeSniffer_Sniff
+class moodle_sniffs_functions_validdefaultvaluesniff implements php_codesniffer_sniff
 {
 
 
@@ -42,36 +44,36 @@ class Moodle_Sniffs_Functions_ValidDefaultValueSniff implements PHP_CodeSniffer_
     {
         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
+     * @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)
+    public function process(PHP_CodeSniffer_File $phpcsfile, $stackptr)
     {
-        $tokens = $phpcsFile->getTokens();
+        $tokens = $phpcsfile->gettokens();
 
-        $argStart = $tokens[$stackPtr]['parenthesis_opener'];
-        $argEnd   = $tokens[$stackPtr]['parenthesis_closer'];
+        $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);
+        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';
                 $error .= ' of the argument list';
-                $phpcsFile->addError($error, $nextArg);
+                $phpcsfile->adderror($error, $nextArg);
                 return;
             }
 
@@ -80,31 +82,31 @@ class Moodle_Sniffs_Functions_ValidDefaultValueSniff implements PHP_CodeSniffer_
             }
         }
 
-    }//end process()
+    }
 
 
     /**
      * Returns true if the passed argument has a default value.
      *
-     * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
+     * @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)
+    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) {
+        $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
+}
 
 ?>
index 533ed85f273c8d8dc8e66ea9703829b0296052c0..4f88456ab5faf389d6ddd6dffd3e1f7a9a8bff87 100644 (file)
@@ -1,34 +1,36 @@
 <?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 /**
- * Moodle_Sniffs_NamingConventions_UpperCaseConstantNameSniff.
- *
- * PHP version 5
- *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Nicolas Connault <nicolasconnault@gmail.com>
+ * moodle_sniffs_namingconventions_uppercaseconstantnamesniff.
  *
- * @copyright 2009 Nicolas Connault
+ * @package   lib-pear-php-codesniffer-standards-moodle-sniffs-namingconventions
+ * @copyright 2008 Nicolas Connault
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @version   CVS: $Id$
- * @link      http://pear.php.net/package/PHP_CodeSniffer
  */
 
 /**
- * Moodle_Sniffs_NamingConventions_UpperCaseConstantNameSniff.
+ * moodle_sniffs_namingconventions_uppercaseconstantnamesniff.
  *
  * Ensures that constant names are all uppercase.
  *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Nicolas Connault <nicolasconnault@gmail.com>
- *
- * @copyright 2009 Nicolas Connault
+ * @copyright 2008 Nicolas Connault
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @version   Release: 1.1.0
- * @link      http://pear.php.net/package/PHP_CodeSniffer
  */
-class Moodle_Sniffs_NamingConventions_UpperCaseConstantNameSniff implements PHP_CodeSniffer_Sniff
+class moodle_sniffs_namingconventions_uppercaseconstantnamesniff implements php_codesniffer_sniff
 {
 
 
@@ -41,33 +43,33 @@ class Moodle_Sniffs_NamingConventions_UpperCaseConstantNameSniff implements PHP_
     {
         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
+     * @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)
+    public function process(PHP_CodeSniffer_File $phpcsfile, $stackptr)
     {
-        $tokens    = $phpcsFile->getTokens();
-        $constName = $tokens[$stackPtr]['content'];
+        $tokens    = $phpcsfile->gettokens();
+        $constName = $tokens[$stackptr]['content'];
 
         // If this token is in a heredoc, ignore it.
-        if ($phpcsFile->hasCondition($stackPtr, T_START_HEREDOC) === true) {
+        if ($phpcsfile->hasCondition($stackptr, T_START_HEREDOC) === true) {
             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(array(T_WHITESPACE), ($stackPtr + 1), null, true);
+        $openBracket = $phpcsfile->findNext(array(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), ($stackPtr - 1), null, true);
+            $functionKeyword = $phpcsfile->findPrevious(array(T_WHITESPACE, T_COMMA, T_COMMENT, T_STRING), ($stackptr - 1), null, true);
 
             $declarations = array(
                              T_FUNCTION,
@@ -87,14 +89,14 @@ class Moodle_Sniffs_NamingConventions_UpperCaseConstantNameSniff implements PHP_
                 // This is a class constant.
                 if (strtoupper($constName) !== $constName) {
                     $error = 'Class constants must be uppercase; expected '.strtoupper($constName)." but found $constName";
-                    $phpcsFile->addError($error, $stackPtr);
+                    $phpcsfile->adderror($error, $stackptr);
                 }
 
                 return;
             }
 
             // Is this a class name?
-            $nextPtr = $phpcsFile->findNext(array(T_WHITESPACE), ($stackPtr + 1), null, true);
+            $nextPtr = $phpcsfile->findNext(array(T_WHITESPACE), ($stackptr + 1), null, true);
             if ($tokens[$nextPtr]['code'] === T_DOUBLE_COLON) {
                 return;
             }
@@ -102,18 +104,18 @@ class Moodle_Sniffs_NamingConventions_UpperCaseConstantNameSniff implements PHP_
             // Is this a type hint?
             if ($tokens[$nextPtr]['code'] === T_VARIABLE) {
                 return;
-            } else if ($phpcsFile->isReference($nextPtr) === true) {
+            } else if ($phpcsfile->isReference($nextPtr) === true) {
                 return;
             }
 
             // Is this a member var name?
-            $prevPtr = $phpcsFile->findPrevious(array(T_WHITESPACE), ($stackPtr - 1), null, true);
+            $prevPtr = $phpcsfile->findPrevious(array(T_WHITESPACE), ($stackptr - 1), null, true);
             if ($tokens[$prevPtr]['code'] === T_OBJECT_OPERATOR) {
                 return;
             }
 
             // Is this an instance of declare()
-            $prevPtr = $phpcsFile->findPrevious(array(T_WHITESPACE, T_OPEN_PARENTHESIS), ($stackPtr - 1), null, true);
+            $prevPtr = $phpcsfile->findPrevious(array(T_WHITESPACE, T_OPEN_PARENTHESIS), ($stackptr - 1), null, true);
             if ($tokens[$prevPtr]['code'] === T_DECLARE) {
                 return;
             }
@@ -121,7 +123,7 @@ class Moodle_Sniffs_NamingConventions_UpperCaseConstantNameSniff implements PHP_
             // This is a real constant.
             if (strtoupper($constName) !== $constName) {
                 $error = 'Constants must be uppercase; expected '.strtoupper($constName)." but found $constName";
-                $phpcsFile->addError($error, $stackPtr);
+                $phpcsfile->adderror($error, $stackptr);
             }
 
         } else if (strtolower($constName) === 'define' || strtolower($constName) === 'constant') {
@@ -131,7 +133,7 @@ class Moodle_Sniffs_NamingConventions_UpperCaseConstantNameSniff implements PHP_
             */
 
             // The next non-whitespace token must be the constant name.
-            $constPtr = $phpcsFile->findNext(array(T_WHITESPACE), ($openBracket + 1), null, true);
+            $constPtr = $phpcsfile->findNext(array(T_WHITESPACE), ($openBracket + 1), null, true);
             if ($tokens[$constPtr]['code'] !== T_CONSTANT_ENCAPSED_STRING) {
                 return;
             }
@@ -139,13 +141,13 @@ class Moodle_Sniffs_NamingConventions_UpperCaseConstantNameSniff implements PHP_
             $constName = $tokens[$constPtr]['content'];
             if (strtoupper($constName) !== $constName) {
                 $error = 'Constants must be uppercase; expected '.strtoupper($constName)." but found $constName";
-                $phpcsFile->addError($error, $stackPtr);
+                $phpcsfile->adderror($error, $stackptr);
             }
-        }//end if
+        }
 
-    }//end process()
+    }
 
 
-}//end class
+}
 
 ?>
index accc3508f0f5821310006a0508e57526c6122508..2be9459fc0e0ac3f52e2e6ecb9e8ae93dbad3cd4 100644 (file)
@@ -1,35 +1,37 @@
 <?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 /**
- * Moodle_Sniffs_NamingConventions_ValidClassNameSniff.
- *
- * PHP version 5
+ * moodle_sniffs_namingconventions_validclassnamesniff.
  *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Nicolas Connault <nicolasconnault@gmail.com>
- *
- * @copyright 2009 Nicolas Connault
+ * @package   lib-pear-php-codesniffer-standards-moodle-sniffs-namingconventions
+ * @copyright 2008 Nicolas Connault
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @version   CVS: $Id$
- * @link      http://pear.php.net/package/PHP_CodeSniffer
  */
 
 /**
- * Moodle_Sniffs_NamingConventions_ValidClassNameSniff.
+ * moodle_sniffs_namingconventions_validclassnamesniff.
  *
  * Ensures class and interface names start with a capital letter
  * and use _ separators.
  *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Nicolas Connault <nicolasconnault@gmail.com>
- *
- * @copyright 2009 Nicolas Connault
+ * @copyright 2008 Nicolas Connault
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @version   Release: 1.1.0
- * @link      http://pear.php.net/package/PHP_CodeSniffer
  */
-class Moodle_Sniffs_NamingConventions_ValidClassNameSniff implements PHP_CodeSniffer_Sniff
+class moodle_sniffs_namingconventions_validclassnamesniff implements php_codesniffer_sniff
 {
 
 
@@ -45,36 +47,36 @@ class Moodle_Sniffs_NamingConventions_ValidClassNameSniff implements PHP_CodeSni
                 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
+     * @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)
+    public function process(PHP_CodeSniffer_File $phpcsfile, $stackptr)
     {
-        $tokens = $phpcsFile->getTokens();
+        $tokens = $phpcsfile->gettokens();
 
-        $className = $phpcsFile->findNext(T_STRING, $stackPtr);
+        $className = $phpcsfile->findNext(T_STRING, $stackptr);
         $name      = trim($tokens[$className]['content']);
 
         // Make sure that the word is all lowercase
 
         if (!preg_match('/[a-z]?/', $name)) {
-            $error = ucfirst($tokens[$stackPtr]['content']).' name is not valid, must be all lower-case';
-            $phpcsFile->addError($error, $stackPtr);
-        }//end if
+            $error = ucfirst($tokens[$stackptr]['content']).' name is not valid, must be all lower-case';
+            $phpcsfile->adderror($error, $stackptr);
+        }
 
-    }//end process()
+    }
 
 
-}//end class
+}
 
 
 ?>
index 1eb1148f1e4e75903a20a69571e87240126a6026..3ca5e689ab09bb546748a1d923b061bb57385b61 100644 (file)
@@ -1,17 +1,25 @@
 <?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 /**
- * Moodle_Sniffs_NamingConventions_ValidFunctionNameSniff.
- *
- * PHP version 5
- *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Nicolas Connault <nicolasconnault@gmail.com>
+ * moodle_sniffs_namingconventions_validfunctionnamesniff.
  *
- * @copyright 2009 Nicolas Connault
+ * @package   lib-pear-php-codesniffer-standards-moodle-sniffs-namingconventions
+ * @copyright 2008 Nicolas Connault
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @version   CVS: $Id$
- * @link      http://pear.php.net/package/PHP_CodeSniffer
  */
 
 if (class_exists('PHP_CodeSniffer_Standards_AbstractScopeSniff', true) === false) {
@@ -19,21 +27,15 @@ if (class_exists('PHP_CodeSniffer_Standards_AbstractScopeSniff', true) === false
 }
 
 /**
- * Moodle_Sniffs_NamingConventions_ValidFunctionNameSniff.
+ * moodle_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    Nicolas Connault <nicolasconnault@gmail.com>
- *
- * @copyright 2009 Nicolas Connault
+ * @copyright 2008 Nicolas Connault
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @version   Release: 1.1.0
- * @link      http://pear.php.net/package/PHP_CodeSniffer
  */
-class Moodle_Sniffs_NamingConventions_ValidFunctionNameSniff extends PHP_CodeSniffer_Standards_AbstractScopeSniff
+class moodle_sniffs_namingconventions_validfunctionnamesniff extends php_codesniffer_standards_abstractscopesniff
 {
 
     /**
@@ -68,36 +70,36 @@ class Moodle_Sniffs_NamingConventions_ValidFunctionNameSniff extends PHP_CodeSni
 
 
     /**
-     * Constructs a Moodle_Sniffs_NamingConventions_ValidFunctionNameSniff.
+     * Constructs a moodle_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
+     * @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)
+    protected function processtokenwithinScope(PHP_CodeSniffer_File $phpcsfile, $stackptr, $currScope)
     {
-        $className  = $phpcsFile->getDeclarationName($currScope);
-        $methodName = $phpcsFile->getDeclarationName($stackPtr);
+        $className  = $phpcsfile->getDeclarationName($currScope);
+        $methodName = $phpcsfile->getDeclarationName($stackptr);
 
         // 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 \"$className::$methodName\" is invalid; only PHP magic methods should be prefixed with a double underscore";
-                 $phpcsFile->addError($error, $stackPtr);
+                 $phpcsfile->adderror($error, $stackptr);
             }
 
             return;
@@ -113,7 +115,7 @@ class Moodle_Sniffs_NamingConventions_ValidFunctionNameSniff extends PHP_CodeSni
             return;
         }
 
-        $methodProps    = $phpcsFile->getMethodProperties($stackPtr);
+        $methodProps    = $phpcsfile->getMethodProperties($stackptr);
         $isPublic       = ($methodProps['scope'] === 'private') ? false : true;
         $scope          = $methodProps['scope'];
         $scopeSpecified = $methodProps['scope_specified'];
@@ -126,7 +128,7 @@ class Moodle_Sniffs_NamingConventions_ValidFunctionNameSniff extends PHP_CodeSni
                 $error = "Method name \"$className::$methodName\" must be in lower-case letters only";
             }
 
-            $phpcsFile->addError($error, $stackPtr);
+            $phpcsfile->adderror($error, $stackptr);
             return;
         }
 
@@ -138,32 +140,32 @@ class Moodle_Sniffs_NamingConventions_ValidFunctionNameSniff extends PHP_CodeSni
                 $error = "Method name \"$className::$methodName\" must only contain letters";
             }
 
-            $phpcsFile->addError($error, $stackPtr);
+            $phpcsfile->adderror($error, $stackptr);
             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
+     * @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)
+    protected function processtokenOutsideScope(PHP_CodeSniffer_File $phpcsfile, $stackptr)
     {
-        $functionName = $phpcsFile->getDeclarationName($stackPtr);
+        $functionName = $phpcsfile->getDeclarationName($stackptr);
 
         // 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 \"$functionName\" is invalid; only PHP magic methods should be prefixed with a double underscore";
-                 $phpcsFile->addError($error, $stackPtr);
+                 $phpcsfile->adderror($error, $stackptr);
             }
 
             return;
@@ -173,7 +175,7 @@ class Moodle_Sniffs_NamingConventions_ValidFunctionNameSniff extends PHP_CodeSni
         if (preg_match('/[A-Z]+/', $functionName)) {
             $error = "function name \"$functionName\" must be lower-case letters only";
 
-            $phpcsFile->addError($error, $stackPtr);
+            $phpcsfile->adderror($error, $stackptr);
             return;
         }
 
@@ -181,13 +183,13 @@ class Moodle_Sniffs_NamingConventions_ValidFunctionNameSniff extends PHP_CodeSni
         if (preg_match('/[0-9]+/', $functionName)) {
             $error = "function name \"$functionName\" must only contain letters";
 
-            $phpcsFile->addError($error, $stackPtr);
+            $phpcsfile->adderror($error, $stackptr);
             return;
         }
 
-    }//end processTokenOutsideScope()
+    }
 
 
-}//end class
+}
 
 ?>
index 052f1469b7849033928f7dae57427cdd2ff7b6e2..ff8353ccdd8ae0fa48f79f387fbc46a3af14a46e 100644 (file)
@@ -1,16 +1,25 @@
 <?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 /**
- * Moodle_Sniffs_NamingConventions_ValidVariableNameSniff.
- *
- * PHP version 5
+ * moodle_sniffs_namingconventions_validvariablenamesniff.
  *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Nicolas Connault <nicolasconnault@gmail.com>
- * @copyright 2009 Nicolas Connault
+ * @package   lib-pear-php-codesniffer-standards-moodle-sniffs-namingconventions
+ * @copyright 2008 Nicolas Connault
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @version   CVS: $Id$
- * @link      http://pear.php.net/package/PHP_CodeSniffer
  */
 
 if (class_exists('PHP_CodeSniffer_Standards_AbstractVariableSniff', true) === false) {
@@ -19,19 +28,14 @@ if (class_exists('PHP_CodeSniffer_Standards_AbstractVariableSniff', true) === fa
 }
 
 /**
- * Moodle_Sniffs_NamingConventions_ValidVariableNameSniff.
+ * moodle_sniffs_namingconventions_validvariablenamesniff.
  *
  * Checks the naming of member variables.
  *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Nicolas Connault <nicolasconnault@gmail.com>
- * @copyright 2009 Nicolas Connault
+ * @copyright 2008 Nicolas Connault
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @version   Release: 1.1.0
- * @link      http://pear.php.net/package/PHP_CodeSniffer
  */
-class Moodle_Sniffs_NamingConventions_ValidVariableNameSniff extends PHP_CodeSniffer_Standards_AbstractVariableSniff
+class moodle_sniffs_namingconventions_validvariablenamesniff extends php_codesniffer_standards_abstractvariablesniff
 {
 
     private $allowed_global_vars = array('CFG', 'SESSION', 'USER', 'COURSE', 'SITE', 'PAGE', 'DB', 'THEME');
@@ -39,68 +43,68 @@ class Moodle_Sniffs_NamingConventions_ValidVariableNameSniff extends PHP_CodeSni
     /**
      * Processes class member variables.
      *
-     * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
-     * @param int                  $stackPtr  The position of the current token
+     * @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)
+    protected function processMemberVar(PHP_CodeSniffer_File $phpcsfile, $stackptr)
     {
-        $tokens = $phpcsFile->getTokens();
-        $memberName     = ltrim($tokens[$stackPtr]['content'], '$');
+        $tokens = $phpcsfile->gettokens();
+        $memberName     = ltrim($tokens[$stackptr]['content'], '$');
         if (preg_match('/[A-Z]+/', $memberName)) {
             $error = "Member variable \"$memberName\" must be all lower-case";
-            $phpcsFile->addError($error, $stackPtr);
+            $phpcsfile->adderror($error, $stackptr);
             return;
         }
 
         // Must not be preceded by 'var' keyword
-        $keyword = $phpcsFile->findPrevious(T_VAR, $stackPtr);
-        if ($tokens[$keyword]['line'] == $tokens[$stackPtr]['line']) {
+        $keyword = $phpcsfile->findPrevious(T_VAR, $stackptr);
+        if ($tokens[$keyword]['line'] == $tokens[$stackptr]['line']) {
             $error = "The 'var' keyword is not permitted. Visibility must be explicitly declared with public, private or protected";
-            $phpcsFile->addError($error, $stackPtr);
+            $phpcsfile->adderror($error, $stackptr);
             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.
+     * @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)
+    protected function processVariable(PHP_CodeSniffer_File $phpcsfile, $stackptr)
     {
-        $tokens = $phpcsFile->getTokens();
-        $memberName     = ltrim($tokens[$stackPtr]['content'], '$');
+        $tokens = $phpcsfile->gettokens();
+        $memberName     = ltrim($tokens[$stackptr]['content'], '$');
         if (preg_match('/[A-Z]+/', $memberName)) {
             if (!in_array($memberName, $this->allowed_global_vars)) {
                 $error = "Member variable \"$memberName\" must be all lower-case";
-                $phpcsFile->addError($error, $stackPtr);
+                $phpcsfile->adderror($error, $stackptr);
                 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.
+     * @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)
+    protected function processVariableInString(PHP_CodeSniffer_File $phpcsfile, $stackptr)
     {
-        $tokens = $phpcsFile->getTokens();
-        if (preg_match('/\$([A-Za-z0-9_]+)(\-\>([A-Za-z0-9_]+))?/i', $tokens[$stackPtr]['content'], $matches)) {
+        $tokens = $phpcsfile->gettokens();
+        if (preg_match('/\$([A-Za-z0-9_]+)(\-\>([A-Za-z0-9_]+))?/i', $tokens[$stackptr]['content'], $matches)) {
             $firstvar = $matches[1];
             $objectvar = (empty($matches[3])) ? null : $matches[3];
             $memberName = $firstvar . $objectvar;
@@ -108,23 +112,23 @@ class Moodle_Sniffs_NamingConventions_ValidVariableNameSniff extends PHP_CodeSni
             if (preg_match('/[A-Z]+/', $firstvar, $matches)) {
                 if (!in_array($firstvar, $this->allowed_global_vars)) {
                     $error = "Member variable \"$firstvar\" must be all lower-case";
-                    $phpcsFile->addError($error, $stackPtr);
+                    $phpcsfile->adderror($error, $stackptr);
                     return;
                 }
             }
 
             if (!empty($objectvar) && preg_match('/[A-Z]+/', $objectvar, $matches)) {
                 $error = "Member variable \"$objectvar\" must be all lower-case";
-                $phpcsFile->addError($error, $stackPtr);
+                $phpcsfile->adderror($error, $stackptr);
                 return;
             }
         }
 
         return;
 
-    }//end processVariableInString()
+    }
 
 
-}//end class
+}
 
 ?>
index f61266a2e8c891006840363f424c9d0548cb2f38..7933f67a621a2106ef5e805fef38458acbe4d7bb 100644 (file)
@@ -1,34 +1,36 @@
 <?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 /**
- * Moodle_Sniffs_PHP_DisallowShortOpenTagSniff.
- *
- * PHP version 5
+ * moodle_sniffs_php_disallowshortopentagsniff.
  *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Nicolas Connault <nicolasconnault@gmail.com>
- *
- * @copyright 2009 Nicolas Connault
+ * @package   lib-pear-php-codesniffer-standards-moodle-sniffs-php
+ * @copyright 2008 Nicolas Connault
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @version   CVS: $Id$
- * @link      http://pear.php.net/package/PHP_CodeSniffer
  */
 
 /**
- * Moodle_Sniffs_PHP_DisallowShortOpenTagSniff.
+ * moodle_sniffs_php_disallowshortopentagsniff.
  *
  * Makes sure that shorthand PHP open tags are not used.
  *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Nicolas Connault <nicolasconnault@gmail.com>
- *
- * @copyright 2009 Nicolas Connault
+ * @copyright 2008 Nicolas Connault
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @version   Release: 1.1.0
- * @link      http://pear.php.net/package/PHP_CodeSniffer
  */
-class Moodle_Sniffs_PHP_DisallowShortOpenTagSniff implements PHP_CodeSniffer_Sniff
+class moodle_sniffs_php_disallowshortopentagsniff implements php_codesniffer_sniff
 {
 
 
@@ -44,19 +46,19 @@ class Moodle_Sniffs_PHP_DisallowShortOpenTagSniff implements PHP_CodeSniffer_Sni
                 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
+     * @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)
+    public function process(PHP_CodeSniffer_File $phpcsfile, $stackptr)
     {
         // If short open tags are off, then any short open tags will be converted
         // to inline_html tags so we can just ignore them.
@@ -68,24 +70,24 @@ class Moodle_Sniffs_PHP_DisallowShortOpenTagSniff implements PHP_CodeSniffer_Sni
             return;
         }
 
-        $tokens  = $phpcsFile->getTokens();
-        $openTag = $tokens[$stackPtr];
+        $tokens  = $phpcsfile->gettokens();
+        $openTag = $tokens[$stackptr];
 
         if ($openTag['content'] === '<?') {
             $error = 'Short PHP opening tag used. Found "'.$openTag['content'].'" Expected "<?php".';
-            $phpcsFile->addError($error, $stackPtr);
+            $phpcsfile->adderror($error, $stackptr);
         }
 
         if ($openTag['code'] === T_OPEN_TAG_WITH_ECHO) {
-            $nextVar = $tokens[$phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr + 1), null, true)];
+            $nextVar = $tokens[$phpcsfile->findNext(PHP_CodeSniffer_tokens::$emptyTokens, ($stackptr + 1), null, true)];
             $error   = 'Short PHP opening tag used with echo. Found "';
             $error  .= $openTag['content'].' '.$nextVar['content'].' ..." but expected "<?php echo '.$nextVar['content'].' ...".';
-            $phpcsFile->addError($error, $stackPtr);
+            $phpcsfile->adderror($error, $stackptr);
         }
 
-    }//end process()
+    }
 
 
-}//end class
+}
 
 ?>
index 760ad028af6e1eb6efe7dfd92d114f2298710374..26ac008cfb914c20e278247f983b6f800664735c 100644 (file)
@@ -1,34 +1,36 @@
 <?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 /**
- * Moodle_Sniffs_PHP_LowerCaseConstantSniff.
- *
- * PHP version 5
+ * moodle_sniffs_php_lowercaseconstantsniff.
  *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Nicolas Connault <nicolasconnault@gmail.com>
- *
- * @copyright 2009 Nicolas Connault
+ * @package   lib-pear-php-codesniffer-standards-moodle-sniffs-php
+ * @copyright 2008 Nicolas Connault
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @version   CVS: $Id$
- * @link      http://pear.php.net/package/PHP_CodeSniffer
  */
 
 /**
- * Moodle_Sniffs_PHP_LowerCaseConstantSniff.
+ * moodle_sniffs_php_lowercaseconstantsniff.
  *
  * Checks that all uses of true, false and null are lowerrcase.
  *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Nicolas Connault <nicolasconnault@gmail.com>
- *
- * @copyright 2009 Nicolas Connault
+ * @copyright 2008 Nicolas Connault
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @version   Release: 1.1.0
- * @link      http://pear.php.net/package/PHP_CodeSniffer
  */
-class Moodle_Sniffs_PHP_LowerCaseConstantSniff implements PHP_CodeSniffer_Sniff
+class moodle_sniffs_php_lowercaseconstantsniff implements php_codesniffer_sniff
 {
 
     /**
@@ -36,7 +38,7 @@ class Moodle_Sniffs_PHP_LowerCaseConstantSniff implements PHP_CodeSniffer_Sniff
      *
      * @var array
      */
-    public $supportedTokenizers = array(
+    public $supportedtokenizers = array(
                                    'PHP',
                                    'JS',
                                   );
@@ -54,31 +56,31 @@ class Moodle_Sniffs_PHP_LowerCaseConstantSniff implements PHP_CodeSniffer_Sniff
                 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
+     * @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)
+    public function process(PHP_CodeSniffer_File $phpcsfile, $stackptr)
     {
-        $tokens = $phpcsFile->getTokens();
+        $tokens = $phpcsfile->gettokens();
 
-        $keyword = $tokens[$stackPtr]['content'];
+        $keyword = $tokens[$stackptr]['content'];
         if (strtolower($keyword) !== $keyword) {
             $error = 'TRUE, FALSE and NULL must be lowercase; expected "'.strtolower($keyword).'" but found "'.$keyword.'"';
-            $phpcsFile->addError($error, $stackPtr);
+            $phpcsfile->adderror($error, $stackptr);
         }
 
-    }//end process()
+    }
 
 
-}//end class
+}
 
 ?>
index b3d305c71733839a90fcbf6689cc627af756dc7c..57683c8537cfbda8cc43f775fb2c8a7a2a07500e 100644 (file)
@@ -1,34 +1,36 @@
 <?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 /**
- * Moodle_Sniffs_PHP_LowercasePHPFunctionsSniff.
- *
- * PHP version 5
+ * moodle_sniffs_php_lowercasephpfunctionssniff.
  *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Nicolas Connault <nicolasconnault@gmail.com>
- *
- * @copyright 2009 Nicolas Connault
+ * @package   lib-pear-php-codesniffer-standards-moodle-sniffs-php
+ * @copyright 2008 Nicolas Connault
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @version   CVS: $Id$
- * @link      http://pear.php.net/package/PHP_CodeSniffer
  */
 
 /**
- * Moodle_Sniffs_PHP_LowercasePHPFunctionsSniff.
+ * moodle_sniffs_php_lowercasephpfunctionssniff.
  *
  * Ensures all calls to inbuilt PHP functions are lowercase.
  *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Nicolas Connault <nicolasconnault@gmail.com>
- *
- * @copyright 2009 Nicolas Connault
+ * @copyright 2008 Nicolas Connault
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @version   Release: 1.1.0
- * @link      http://pear.php.net/package/PHP_CodeSniffer
  */
-class Moodle_Sniffs_PHP_LowercasePHPFunctionsSniff implements PHP_CodeSniffer_Sniff
+class moodle_sniffs_php_lowercasephpfunctionssniff implements php_codesniffer_sniff
 {
 
 
@@ -60,36 +62,36 @@ class Moodle_Sniffs_PHP_LowercasePHPFunctionsSniff implements PHP_CodeSniffer_Sn
                 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
+     * @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)
+    public function process(PHP_CodeSniffer_File $phpcsfile, $stackptr)
     {
-        $tokens = $phpcsFile->getTokens();
+        $tokens = $phpcsfile->gettokens();
 
-        if ($tokens[$stackPtr]['code'] !== T_STRING) {
-            $content = $tokens[$stackPtr]['content'];
+        if ($tokens[$stackptr]['code'] !== T_STRING) {
+            $content = $tokens[$stackptr]['content'];
             if ($content !== strtolower($content)) {
                 $type     = strtoupper($content);
                 $expected = strtolower($content);
                 $error    = "$type keyword must be lowercase; expected \"$expected\" but found \"$content\"";
-                $phpcsFile->addError($error, $stackPtr);
+                $phpcsfile->adderror($error, $stackptr);
             }
 
             return;
         }
 
         // Make sure this is a function call.
-        $next = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true);
+        $next = $phpcsfile->findNext(T_WHITESPACE, ($stackptr + 1), null, true);
         if ($next === false) {
             // Not a function call.
             return;
@@ -100,7 +102,7 @@ class Moodle_Sniffs_PHP_LowercasePHPFunctionsSniff implements PHP_CodeSniffer_Sn
             return;
         }
 
-        $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);
+        $prev = $phpcsfile->findPrevious(T_WHITESPACE, ($stackptr - 1), null, true);
         if ($tokens[$prev]['code'] === T_FUNCTION) {
             // Function declaration, not a function call.
             return;
@@ -120,7 +122,7 @@ class Moodle_Sniffs_PHP_LowercasePHPFunctionsSniff implements PHP_CodeSniffer_Sn
         // 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'];
+        $content = $tokens[$stackptr]['content'];
         if (function_exists($content) === false) {
             return;
         }
@@ -128,12 +130,12 @@ class Moodle_Sniffs_PHP_LowercasePHPFunctionsSniff implements PHP_CodeSniffer_Sn
         if ($content !== strtolower($content)) {
             $expected = strtolower($content);
             $error    = "Calls to inbuilt PHP functions must be lowercase; expected \"$expected\" but found \"$content\"";
-            $phpcsFile->addError($error, $stackPtr);
+            $phpcsfile->adderror($error, $stackptr);
         }
 
-    }//end process()
+    }
 
 
-}//end class
+}
 
 ?>
index bbdd781c46784b4bf2dbbaa71df17114e8f2e01f..bf20d210e976a56991cfd7b2a2e7231ba85240cb 100644 (file)
@@ -1,34 +1,36 @@
 <?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 /**
- * Moodle_Sniffs_Strings_DoubleQuoteUsageSniff.
- *
- * PHP version 5
+ * moodle_sniffs_strings_doublequoteusagesniff.
  *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Nicolas Connault <nicolasconnault@gmail.com>
- *
- * @copyright 2009 Nicolas Connault
+ * @package   lib-pear-php-codesniffer-standards-moodle-sniffs-strings
+ * @copyright 2008 Nicolas Connault
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @version   CVS: $Id$
- * @link      http://pear.php.net/package/PHP_CodeSniffer
  */
 
 /**
- * Moodle_Sniffs_Strings_DoubleQuoteUsageSniff.
+ * moodle_sniffs_strings_doublequoteusagesniff.
  *
  * Makes sure that any use of Double Quotes ("") are warranted.
  *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Nicolas Connault <nicolasconnault@gmail.com>
- *
- * @copyright 2009 Nicolas Connault
+ * @copyright 2008 Nicolas Connault
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @version   Release: 1.1.0
- * @link      http://pear.php.net/package/PHP_CodeSniffer
  */
-class Moodle_Sniffs_Strings_DoubleQuoteUsageSniff implements PHP_CodeSniffer_Sniff
+class moodle_sniffs_strings_doublequoteusagesniff implements php_codesniffer_sniff
 {
 
 
@@ -43,23 +45,23 @@ class Moodle_Sniffs_Strings_DoubleQuoteUsageSniff implements PHP_CodeSniffer_Sni
                 T_CONSTANT_ENCAPSED_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
+     * @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)
+    public function process(PHP_CodeSniffer_File $phpcsfile, $stackptr)
     {
-        $tokens = $phpcsFile->getTokens();
+        $tokens = $phpcsfile->gettokens();
 
-        $workingString = $tokens[$stackPtr]['content'];
+        $workingString = $tokens[$stackptr]['content'];
 
         // Check if it's a double quoted string.
         if (strpos($workingString, '"') === false) {
@@ -74,7 +76,7 @@ class Moodle_Sniffs_Strings_DoubleQuoteUsageSniff implements PHP_CodeSniffer_Sni
 
         // Work through the following tokens, in case this string is stretched
         // over multiple Lines.
-        for ($i = ($stackPtr + 1); $i < $phpcsFile->numTokens; $i++) {
+        for ($i = ($stackptr + 1); $i < $phpcsfile->numTokens; $i++) {
             if ($tokens[$i]['type'] !== 'T_CONSTANT_ENCAPSED_STRING') {
                 break;
             }
@@ -99,11 +101,11 @@ class Moodle_Sniffs_Strings_DoubleQuoteUsageSniff implements PHP_CodeSniffer_Sni
         }
 
         $error = "String $workingString does not require double quotes; use single quotes instead";
-        $phpcsFile->addWarning($error, $stackPtr);
+        $phpcsfile->addwarning($error, $stackptr);
 
-    }//end process()
+    }
 
 
-}//end class
+}
 
 ?>
index e60a05c921bb82528fb7f55f993b329cf0f9f8fa..d56794b1c13dc1c8e424f70682246517b4bcf36b 100644 (file)
@@ -1,35 +1,37 @@
 <?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 /**
- * Moodle_Sniffs_Strings_EchoedStringsSniff.
- *
- * PHP version 5
+ * moodle_sniffs_strings_echoedstringssniff.
  *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Nicolas Connault <nicolasconnault@gmail.com>
- *
- * @copyright 2009 Nicolas Connault
+ * @package   lib-pear-php-codesniffer-standards-moodle-sniffs-strings
+ * @copyright 2008 Nicolas Connault
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @version   CVS: $Id$
- * @link      http://pear.php.net/package/PHP_CodeSniffer
  */
 
 /**
- * Moodle_Sniffs_Strings_EchoedStringsSniff.
+ * moodle_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    Nicolas Connault <nicolasconnault@gmail.com>
- *
- * @copyright 2009 Nicolas Connault
+ * @copyright 2008 Nicolas Connault
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @version   Release: 1.1.0
- * @link      http://pear.php.net/package/PHP_CodeSniffer
  */
-class Moodle_Sniffs_Strings_EchoedStringsSniff implements PHP_CodeSniffer_Sniff
+class moodle_sniffs_strings_echoedstringssniff implements php_codesniffer_sniff
 {
 
 
@@ -42,44 +44,44 @@ class Moodle_Sniffs_Strings_EchoedStringsSniff implements PHP_CodeSniffer_Sniff
     {
         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
+     * @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)
+    public function process(PHP_CodeSniffer_File $phpcsfile, $stackptr)
     {
-        $tokens = $phpcsFile->getTokens();
+        $tokens = $phpcsfile->gettokens();
 
-        $firstContent = $phpcsFile->findNext(array(T_WHITESPACE), ($stackPtr + 1), null, true);
+        $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) {
+        if ($tokens[$firstcontent]['code'] !== T_OPEN_PARENTHESIS) {
             return;
         }
 
-        $endOfStatement = $phpcsFile->findNext(array(T_SEMICOLON), $stackPtr, null, false);
+        $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) {
+        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);
+            $phpcsfile->adderror($error, $stackptr);
         }
 
-    }//end process()
+    }
 
 
-}//end class
+}
 
 ?>
index 678e9219178b5c7f0721a5159d287d0e3162bee6..9c5fc2cefd65a22f98b8d182408245092b3737f4 100644 (file)
@@ -1,34 +1,36 @@
 <?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 /**
- * Moodle_Sniffs_WhiteSpace_DisallowTabIndentSniff.
- *
- * PHP version 5
+ * moodle_sniffs_whitespace_disallowtabindentsniff.
  *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Nicolas Connault <nicolasconnault@gmail.com>
- *
- * @copyright 2009 Nicolas Connault
+ * @package   lib-pear-php-codesniffer-standards-moodle-sniffs-whitespace
+ * @copyright 2008 Nicolas Connault
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @version   CVS: $Id$
- * @link      http://pear.php.net/package/PHP_CodeSniffer
  */
 
 /**
- * Moodle_Sniffs_WhiteSpace_DisallowTabIndentSniff.
+ * moodle_sniffs_whitespace_disallowtabindentsniff.
  *
  * Throws errors if tabs are used for indentation.
  *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Nicolas Connault <nicolasconnault@gmail.com>
- *
- * @copyright 2009 Nicolas Connault
+ * @copyright 2008 Nicolas Connault
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @version   Release: 1.1.0
- * @link      http://pear.php.net/package/PHP_CodeSniffer
  */
-class Moodle_Sniffs_WhiteSpace_DisallowTabIndentSniff implements PHP_CodeSniffer_Sniff
+class moodle_sniffs_whitespace_disallowtabindentsniff implements php_codesniffer_sniff
 {
 
     /**
@@ -36,7 +38,7 @@ class Moodle_Sniffs_WhiteSpace_DisallowTabIndentSniff implements PHP_CodeSniffer
      *
      * @var array
      */
-    public $supportedTokenizers = array(
+    public $supportedtokenizers = array(
                                    'PHP',
                                    'JS',
                                   );
@@ -51,36 +53,36 @@ class Moodle_Sniffs_WhiteSpace_DisallowTabIndentSniff implements PHP_CodeSniffer
     {
         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
+     * @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)
+    public function process(PHP_CodeSniffer_File $phpcsfile, $stackptr)
     {
-        $tokens = $phpcsFile->getTokens();
+        $tokens = $phpcsfile->gettokens();
 
         // Make sure this is whitespace used for indentation.
-        $line = $tokens[$stackPtr]['line'];
-        if ($stackPtr > 0 && $tokens[($stackPtr - 1)]['line'] === $line) {
+        $line = $tokens[$stackptr]['line'];
+        if ($stackptr > 0 && $tokens[($stackptr - 1)]['line'] === $line) {
             return;
         }
 
-        if (strpos($tokens[$stackPtr]['content'], "\t") !== false) {
+        if (strpos($tokens[$stackptr]['content'], "\t") !== false) {
             $error = 'Spaces must be used to indent lines; tabs are not allowed';
-            $phpcsFile->addError($error, $stackPtr);
+            $phpcsfile->adderror($error, $stackptr);
         }
 
-    }//end process()
+    }
 
 
-}//end class
+}
 
 ?>
index ba78a64004443b167a1509feaf3858e73ed60cd6..1b6ec79a1a8bbd57a515ec520f7fe8ae38f51541 100644 (file)
@@ -1,17 +1,25 @@
 <?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 /**
  * Verifies that class members are spaced correctly.
  *
- * PHP version 5
- *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Nicolas Connault <nicolasconnault@gmail.com>
- *
- * @copyright 2009 Nicolas Connault
+ * @package   lib-pear-php-codesniffer-standards-moodle-sniffs-whitespace
+ * @copyright 2008 Nicolas Connault
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @version   CVS: $Id$
- * @link      http://pear.php.net/package/PHP_CodeSniffer
  */
 
 if (class_exists('PHP_CodeSniffer_Standards_AbstractVariableSniff', true) === false) {
@@ -21,101 +29,95 @@ if (class_exists('PHP_CodeSniffer_Standards_AbstractVariableSniff', true) === fa
 /**
  * Verifies that class members are spaced correctly.
  *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Nicolas Connault <nicolasconnault@gmail.com>
- *
- * @copyright 2009 Nicolas Connault
+ * @copyright 2008 Nicolas Connault
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @version   Release: 1.1.0
- * @link      http://pear.php.net/package/PHP_CodeSniffer
  */
-class Moodle_Sniffs_WhiteSpace_MemberVarSpacingSniff extends PHP_CodeSniffer_Standards_AbstractVariableSniff
+class moodle_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.
+     * @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)
+    protected function processMemberVar(PHP_CodeSniffer_File $phpcsfile, $stackptr)
     {
-        $tokens = $phpcsFile->getTokens();
+        $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) {
+        $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) {
+            } 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) {
+                if ($tokens[$i]['code'] === T_WHITESPACE && in_array($tokens[($i - 1)]['code'], PHP_CodeSniffer_tokens::$commentTokens) === true) {
                     continue;
                 }
 
-                $prevLineToken = $i;
+                $prevlinetoken = $i;
                 break;
             }
         }
 
-        if (is_null($prevLineToken) === true) {
+        if (is_null($prevlinetoken) === true) {
             // Never found the previous line, which means
             // there are 0 blank lines before the member var.
-            $foundLines = 0;
+            $foundlines = 0;
         } else {
-            $prevContent = $phpcsFile->findPrevious(array(T_WHITESPACE, T_DOC_COMMENT), $prevLineToken, null, true);
-            $foundLines  = ($tokens[$prevLineToken]['line'] - $tokens[$prevContent]['line']);
-        }//end if
+            $prevcontent = $phpcsfile->findPrevious(array(T_WHITESPACE, T_DOC_COMMENT), $prevlinetoken, null, true);
+            $foundlines  = ($tokens[$prevlinetoken]['line'] - $tokens[$prevcontent]['line']);
+        }
 
-        if ($foundLines !== 1) {
-            // $phpcsFile->addError("Expected 1 blank line before member var; $foundLines found", $stackPtr);
+        if ($foundlines !== 1) {
+            // $phpcsfile->adderror("Expected 1 blank line before member var; $foundlines found", $stackptr);
         }
 
-    }//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.
+     * @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)
+    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.
+     * @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)
+    protected function processVariableInString(PHP_CodeSniffer_File $phpcsfile, $stackptr)
     {
         // We don't care about normal variables.
         return;
 
-    }//end processVariableInString()
+    }
 
 
-}//end class
+}
 
 ?>
index 689f8762ff193540be283c01856824d28beba24f..43070359b1c6779333339388c9d5db6c25ee7698 100644 (file)
@@ -1,34 +1,36 @@
 <?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 /**
- * Moodle_Sniffs_Whitespace_ScopeClosingBraceSniff.
- *
- * PHP version 5
+ * moodle_sniffs_whitespace_scopeclosingbracesniff.
  *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Nicolas Connault <nicolasconnault@gmail.com>
- *
- * @copyright 2009 Nicolas Connault
+ * @package   lib-pear-php-codesniffer-standards-moodle-sniffs-whitespace
+ * @copyright 2008 Nicolas Connault
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @version   CVS: $Id$
- * @link      http://pear.php.net/package/PHP_CodeSniffer
  */
 
 /**
- * Moodle_Sniffs_Whitespace_ScopeClosingBraceSniff.
+ * moodle_sniffs_whitespace_scopeclosingbracesniff.
  *
  * Checks that the closing braces of scopes are aligned correctly.
  *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Nicolas Connault <nicolasconnault@gmail.com>
- *
- * @copyright 2009 Nicolas Connault
+ * @copyright 2008 Nicolas Connault
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @version   Release: 1.1.0
- * @link      http://pear.php.net/package/PHP_CodeSniffer
  */
-class Moodle_Sniffs_WhiteSpace_ScopeClosingBraceSniff implements PHP_CodeSniffer_Sniff
+class moodle_sniffs_whitespace_scopeclosingbracesniff implements php_codesniffer_sniff
 {
 
 
@@ -39,27 +41,27 @@ class Moodle_Sniffs_WhiteSpace_ScopeClosingBraceSniff implements PHP_CodeSniffer
      */
     public function register()
     {
-        return PHP_CodeSniffer_Tokens::$scopeOpeners;
+        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
+     * @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)
+    public function process(PHP_CodeSniffer_File $phpcsfile, $stackptr)
     {
-        $tokens = $phpcsFile->getTokens();
+        $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) {
+        if (isset($tokens[$stackptr]['scope_closer']) === false) {
             return;
         }
 
@@ -67,53 +69,53 @@ class Moodle_Sniffs_WhiteSpace_ScopeClosingBraceSniff implements PHP_CodeSniffer
         // 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);
+        $lineStart = ($stackptr - 1);
         for ($lineStart; $lineStart > 0; $lineStart--) {
-            if (strpos($tokens[$lineStart]['content'], $phpcsFile->eolChar) !== 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 + 1), null, true);
+        $lineStart = $phpcsfile->findNext(array(T_WHITESPACE), ($lineStart + 1), null, true);
 
         $startColumn = $tokens[$lineStart]['column'];
-        $scopeStart  = $tokens[$stackPtr]['scope_opener'];
-        $scopeEnd    = $tokens[$stackPtr]['scope_closer'];
+        $scopeStart  = $tokens[$stackptr]['scope_opener'];
+        $scopeEnd    = $tokens[$stackptr]['scope_closer'];
 
         // Check that the closing brace is on its own line.
-        $lastContent = $phpcsFile->findPrevious(array(T_WHITESPACE), ($scopeEnd - 1), $scopeStart, true);
-        if ($tokens[$lastContent]['line'] === $tokens[$scopeEnd]['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);
+            $phpcsfile->adderror($error, $scopeEnd);
             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) {
+        if (in_array($tokens[$stackptr]['code'], array(T_CASE, T_DEFAULT)) === true && $isBreakCloser === true) {
             // BREAK statements should be indented 4 spaces from the
             // CASE or DEFAULT statement.
             if ($braceIndent !== ($startColumn + 4)) {
                 $error = 'Break statement indented incorrectly; expected '.($startColumn + 3).' spaces, found '.($braceIndent - 1);
-                $phpcsFile->addError($error, $scopeEnd);
+                $phpcsfile->adderror($error, $scopeEnd);
             }
         } else {
-            if (in_array($tokens[$stackPtr]['code'], array(T_CASE, T_DEFAULT))) {
+            if (in_array($tokens[$stackptr]['code'], array(T_CASE, T_DEFAULT))) {
                 $startColumn -= 4;
             }
 
             if ($braceIndent !== $startColumn) {
                 $error = 'Closing brace indented incorrectly; expected '.($startColumn - 1).' spaces, found '.($braceIndent - 1);
-                $phpcsFile->addError($error, $scopeEnd);
+                $phpcsfile->adderror($error, $scopeEnd);
             }
         }
 
-    }//end process()
+    }
 
 
-}//end class
+}
 
 ?>
index f1648983ea21dfaa0a7d68a1f9d5c1cf50846203..32ecb681e79cc7c608bb731a55302acf188e7c7d 100644 (file)
@@ -1,36 +1,38 @@
 <?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 /**
- * Moodle_Sniffs_Whitespace_ScopeIndentSniff.
- *
- * PHP version 5
+ * moodle_sniffs_whitespace_scopeindentsniff.
  *
- * @category  PHP
- * @package   PHP_CodeSniffer
- * @author    Greg Sherwood <gsherwood@squiz.net>
- * @author    Marc McIntyre <mmcintyre@squiz.net>
- * @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600)
- * @license   http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence
- * @version   CVS: $Id$
- * @link      http://pear.php.net/package/PHP_CodeSniffer
+ * @package   lib-pear-php-codesniffer-standards-moodle-sniffs-whitespace
+ * @copyright 2008 Nicolas Connault
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
 /**
- * Moodle_Sniffs_Whitespace_ScopeIndentSniff.
+ * moodle_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 <gsherwood@squiz.net>
- * @author    Marc McIntyre <mmcintyre@squiz.net>
- * @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600)
- * @license   http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence
- * @version   Release: 1.1.0
- * @link      http://pear.php.net/package/PHP_CodeSniffer
+ * @copyright 2008 Nicolas Connault
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
-class Moodle_Sniffs_WhiteSpace_ScopeIndentSniff implements PHP_CodeSniffer_Sniff
+class moodle_sniffs_whitespace_scopeindentsniff implements php_codesniffer_sniff
 {
 
     /**
@@ -65,32 +67,32 @@ class Moodle_Sniffs_WhiteSpace_ScopeIndentSniff implements PHP_CodeSniffer_Sniff
      */
     public function register()
     {
-        return PHP_CodeSniffer_Tokens::$scopeOpeners;
+        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
+     * @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)
+    public function process(PHP_CodeSniffer_File $phpcsfile, $stackptr)
     {
-        $tokens = $phpcsFile->getTokens();
+        $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) {
+        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);
+        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;
@@ -98,11 +100,11 @@ class Moodle_Sniffs_WhiteSpace_ScopeIndentSniff implements PHP_CodeSniffer_Sniff
         }
 
         // Find the first token on this line.
-        $firstToken = $stackPtr;
-        for ($i = $stackPtr; $i >= 0; $i--) {
+        $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;
+            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.
@@ -113,20 +115,20 @@ class Moodle_Sniffs_WhiteSpace_ScopeIndentSniff implements PHP_CodeSniffer_Sniff
 
         // Based on the conditions that surround this token, determine the
         // indent that we expect this current content to be.
-        $expectedIndent = $this->calculateExpectedIndent($tokens, $firstToken);
+        $expectedIndent = $this->calculateExpectedIndent($tokens, $firsttoken);
 
-        if ($tokens[$firstToken]['column'] !== $expectedIndent) {
-            $error  = 'Line indented incorrectly; expected ';
+        if ($tokens[$firsttoken]['column'] !== $expectedIndent) {
+            $error  = 'line indented incorrectly; expected ';
             $error .= ($expectedIndent - 1).' spaces, found ';
-            $error .= ($tokens[$firstToken]['column'] - 1);
-            $phpcsFile->addError($error, $stackPtr);
+            $error .= ($tokens[$firsttoken]['column'] - 1);
+            $phpcsfile->adderror($error, $stackptr);
         }
 
-        $scopeOpener = $tokens[$stackPtr]['scope_opener'];
-        $scopeCloser = $tokens[$stackPtr]['scope_closer'];
+        $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) {
+        if (in_array($tokens[$firsttoken]['code'], $this->nonIndentingScopes) === false) {
             $indent = ($expectedIndent + $this->indent);
         } else {
             $indent = $expectedIndent;
@@ -142,16 +144,16 @@ class Moodle_Sniffs_WhiteSpace_ScopeIndentSniff implements PHP_CodeSniffer_Sniff
 
             // 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 (in_array($tokens[$i]['code'], PHP_CodeSniffer_tokens::$scopeOpeners) === true) {
                 if (isset($tokens[$i]['scope_opener']) === true) {
                     $i = $tokens[$i]['scope_closer'];
                 } 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;
+                    $nexttoken = $phpcsfile->findNext(T_SEMICOLON, $i, $scopeCloser);
+                    if ($nexttoken !== false) {
+                        $i = $nexttoken;
                     }
                 }
 
@@ -181,26 +183,26 @@ class Moodle_Sniffs_WhiteSpace_ScopeIndentSniff implements PHP_CodeSniffer_Sniff
                 // whitespace, then this must be the first token on the line that
                 // must be indented.
                 $newline    = false;
-                $firstToken = $i;
+                $firsttoken = $i;
 
-                $column = $tokens[$firstToken]['column'];
+                $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) {
+                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);
+                    $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 (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.
@@ -210,9 +212,9 @@ class Moodle_Sniffs_WhiteSpace_ScopeIndentSniff implements PHP_CodeSniffer_Sniff
 
                 // 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'], array(T_COMMENT, T_DOC_COMMENT)) === true) {
+                if (in_array($tokens[$firsttoken]['code'], array(T_COMMENT, T_DOC_COMMENT)) === true) {
 
-                    $content = trim($tokens[$firstToken]['content']);
+                    $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
@@ -229,54 +231,54 @@ class Moodle_Sniffs_WhiteSpace_ScopeIndentSniff implements PHP_CodeSniffer_Sniff
                             continue;
                         }
 
-                        $contentLength        = strlen($tokens[$firstToken]['content']);
-                        $trimmedContentLength = strlen(ltrim($tokens[$firstToken]['content']));
-                        $column               = ($contentLength - $trimmedContentLength + 1);
+                        $contentLength        = strlen($tokens[$firsttoken]['content']);
+                        $trimmedcontentLength = strlen(ltrim($tokens[$firsttoken]['content']));
+                        $column               = ($contentLength - $trimmedcontentLength + 1);
                         if (preg_match('|\*/$|', $content) !== 0) {
                             $commentOpen = false;
                         }
-                    }//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) {
-                        $error  = 'Line indented incorrectly; expected ';
+                        $error  = 'line indented incorrectly; expected ';
                         if ($this->exact === false) {
                             $error .= 'at least ';
                         }
 
                         $error .= ($indent - 1).' spaces, found ';
                         $error .= ($column - 1);
-                        $phpcsFile->addError($error, $firstToken);
+                        $phpcsfile->adderror($error, $firsttoken);
                     }
                 }
-            }//end if
-        }//end for
+            }
+        }
 
-    }//end process()
+    }
 
 
     /**
      * Calculates the expected indent of a token.
      *
      * @param array $tokens   The stack of tokens for this file.
-     * @param int   $stackPtr The position of the token to get indent for.
+     * @param int   $stackptr The position of the token to get indent for.
      *
      * @return int
      */
-    protected function calculateExpectedIndent(array $tokens, $stackPtr)
+    protected function calculateExpectedIndent(array $tokens, $stackptr)
     {
         $conditionStack = array();
 
         // Empty conditions array (top level structure).
-        if (empty($tokens[$stackPtr]['conditions']) === true) {
+        if (empty($tokens[$stackptr]['conditions']) === true) {
             return 1;
         }
 
-        $tokenConditions = $tokens[$stackPtr]['conditions'];
+        $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, add it to our condition stack.
@@ -287,9 +289,9 @@ class Moodle_Sniffs_WhiteSpace_ScopeIndentSniff implements PHP_CodeSniffer_Sniff
 
         return ((count($conditionStack) * $this->indent) + 1);
 
-    }//end calculateExpectedIndent()
+    }
 
 
-}//end class
+}
 
 ?>
index d77aac8199613d30d93793ab2a7a8b7e6e771e0f..ebdf909e1c4166498ed0894ffd56ce029f53c6a4 100755 (executable)
  */
 
 error_reporting(E_ALL | E_STRICT);
-
-if (is_file(dirname(__FILE__).'/CodeSniffer/MoodleCLI.php') === true) {
-    include_once dirname(__FILE__).'/CodeSniffer/MoodleCLI.php';
-} else {
-    include_once 'lib/pear/PHP/CodeSniffer/MoodleCLI.php';
-}
+require_once(dirname(__FILE__).'/../../../config.php');
+include_once('PHP/CodeSniffer/MoodleCLI.php');
 
 $phpcs = new moodle_codesniffer_cli();
 $phpcs->checkRequirements();