diff --git a/include/person.class.php b/include/person.class.php index 58b718de0..cc83fa701 100644 --- a/include/person.class.php +++ b/include/person.class.php @@ -90,19 +90,19 @@ class person extends Person_model public function load($personId) { //person_id auf gueltigkeit pruefen - if(is_numeric($personId) && $personId != '') + if (is_numeric($personId) && $personId != '') { $result = $this->getPerson($personId); - if(!is_object($result)) + if (!is_object($result)) { $this->errormsg = "Fehler beim Lesen der Personendaten\n"; - return FALSE; + return false; } $row = $result->row(); - if(isset($row)) + if (isset($row)) { $this->person_id = $row->person_id; $this->sprache = $row->sprache; @@ -177,7 +177,7 @@ class person extends Person_model * auf Gueltigkeit. * @return true wenn ok, false im Fehlerfall **/ - protected function validate() + public function validate() { $this->nachname = trim($this->nachname); $this->vorname = trim($this->vorname); @@ -271,8 +271,10 @@ class person extends Person_model $gewichtung = array(3, 7, 9, 0, 5, 8, 4, 2, 1, 6); $erg = 0; //Quersumme bilden - for($i = 0; $i < 10; $i++) + for ($i = 0; $i < 10; $i++) + { $erg += $gewichtung[$i] * $this->svnr{$i}; + } if ($this->svnr{3} != ($erg % 11)) //Vergleichen der Pruefziffer mit Quersumme Modulo 11 { @@ -280,7 +282,7 @@ class person extends Person_model return false; } } - + if ($this->svnr != '') { //Pruefen ob bereits ein Eintrag mit dieser SVNR vorhanden ist @@ -501,7 +503,6 @@ class person extends Person_model } } return true; - } else { diff --git a/tests/codesniffer/FHComplete/Sniffs/ControlStructures/ControlSignatureSniff.php b/tests/codesniffer/FHComplete/Sniffs/ControlStructures/ControlSignatureSniff.php index b78202cec..6b2f483d0 100644 --- a/tests/codesniffer/FHComplete/Sniffs/ControlStructures/ControlSignatureSniff.php +++ b/tests/codesniffer/FHComplete/Sniffs/ControlStructures/ControlSignatureSniff.php @@ -40,16 +40,16 @@ class FHComplete_Sniffs_ControlStructures_ControlSignatureSniff extends PHP_Code protected function getPatterns() { return array( - 'try {EOL...}\s+catch (...)EOL...{EOL...EOL...}', - 'do+EOL...{EOL...EOL...} while (...);EOL', + 'tryEOL...{EOL...}EOL...catch (...)EOL...{EOL...}EOL', + 'doEOL...{EOL...EOL...}EOL...while (...);EOL', 'while (...)EOL...{EOL', - 'for (...) {EOL', + 'for (...)EOL...{EOL', 'if (...)EOL...{EOL', 'foreach (...)EOL...{EOL', '}EOL...\s+else if (...)EOL...{EOL', '}EOL...\s+elseif (...)EOL...{EOL', '}EOL...\s+else+EOL...{EOL', - 'do+EOL...{EOL', + 'doEOL...{EOL', ); }//end getPatterns() diff --git a/tests/codesniffer/FHComplete/Sniffs/NamingConventions/CamelCapsMethodNameSniff.php b/tests/codesniffer/FHComplete/Sniffs/NamingConventions/CamelCapsMethodNameSniff.php index b5ea68b47..e99f05e04 100644 --- a/tests/codesniffer/FHComplete/Sniffs/NamingConventions/CamelCapsMethodNameSniff.php +++ b/tests/codesniffer/FHComplete/Sniffs/NamingConventions/CamelCapsMethodNameSniff.php @@ -71,7 +71,7 @@ class FHComplete_Sniffs_NamingConventions_CamelCapsMethodNameSniff extends Gener $error = 'Method name "%s" is not in camel caps format'; $className = $phpcsFile->getDeclarationName($currScope); $errorData = array($className.'::'.$methodName); - $phpcsFile->addError($error, $stackPtr, 'NotCamelCaps', $errorData); + $phpcsFile->addWarning($error, $stackPtr, 'NotCamelCaps', $errorData); $phpcsFile->recordMetric($stackPtr, 'CamelCase method name', 'no'); } else { $phpcsFile->recordMetric($stackPtr, 'CamelCase method name', 'yes'); diff --git a/tests/codesniffer/FHComplete/Sniffs/NamingConventions/ValidVariableNameSniff.php b/tests/codesniffer/FHComplete/Sniffs/NamingConventions/ValidVariableNameSniff.php deleted file mode 100644 index bce627331..000000000 --- a/tests/codesniffer/FHComplete/Sniffs/NamingConventions/ValidVariableNameSniff.php +++ /dev/null @@ -1,171 +0,0 @@ -getTokens(); - $varName = ltrim($tokens[$stackPtr]['content'], '$'); - - $phpReservedVars = array( - '_SERVER', - '_GET', - '_POST', - '_REQUEST', - '_SESSION', - '_ENV', - '_COOKIE', - '_FILES', - 'GLOBALS', - ); - - // If it's a php reserved var, then its ok. - if (in_array($varName, $phpReservedVars) === true) { - return; - } - - // There is no way for us to know if the var is public or private, - // so we have to ignore a leading underscore if there is one and just - // check the main part of the variable name. - $originalVarName = $varName; - if (substr($varName, 0, 1) === '_') { - $objOperator = $phpcsFile->findPrevious(array(T_WHITESPACE), ($stackPtr - 1), null, true); - if ($tokens[$objOperator]['code'] === T_DOUBLE_COLON) { - // The variable lives within a class, and is referenced like - // this: MyClass::$_variable, so we don't know its scope. - $inClass = true; - } else { - $inClass = $phpcsFile->hasCondition($stackPtr, array(T_TRAIT, T_CLASS, T_INTERFACE)); - } - - if ($inClass === true) { - $varName = ltrim($varName, '_'); - } - } - - // $title_for_layout is allowed on controllers - $fileName = basename($phpcsFile->getFilename(), '.php'); - if ((substr($fileName, -10) === 'Controller') && ($varName == 'title_for_layout')) { - return; - } - - if ($this->_isValidVar($varName) === false) { - $error = 'Variable "%s" is not in valid camel caps format'; - $data = array($originalVarName); - $phpcsFile->addError($error, $stackPtr, 'NotCamelCaps', $data); - } - } - -/** - * Processes class member variables. - * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param integer $stackPtr The position of the current token in the - * stack passed in $tokens. - * @return void - */ - protected function processMemberVar(PHP_CodeSniffer_File $phpcsFile, $stackPtr) { - } - -/** - * Processes the variable found within a double quoted string. - * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param integer $stackPtr The position of the double quoted string. - * @return void - */ - protected function processVariableInString(PHP_CodeSniffer_File $phpcsFile, $stackPtr) { - $tokens = $phpcsFile->getTokens(); - - $phpReservedVars = array( - '_SERVER', - '_GET', - '_POST', - '_REQUEST', - '_SESSION', - '_ENV', - '_COOKIE', - '_FILES', - 'GLOBALS', - ); - - if (preg_match_all('|[^\\\]\$([a-zA-Z0-9_]+)|', $tokens[$stackPtr]['content'], $matches) !== 0) { - foreach ($matches[1] as $varName) { - // If it's a php reserved var, then its ok. - if (in_array($varName, $phpReservedVars) === true) { - continue; - } - - // There is no way for us to know if the var is public or private, - // so we have to ignore a leading underscore if there is one and just - // check the main part of the variable name. - $originalVarName = $varName; - if (substr($varName, 0, 1) === '_') { - if ($phpcsFile->hasCondition($stackPtr, array(T_CLASS, T_INTERFACE)) === true) { - $varName = substr($varName, 1); - } - } - - if ($this->_isValidVar($varName) === false) { - $error = 'Variable "%s" is not in valid camel caps format'; - $data = array($originalVarName); - $phpcsFile->addError($error, $stackPtr, 'StringVarNotCamelCaps', $data); - } - } - } - } - -/** - * Check that a variable is a valid shape. - * - * Variables in FHComplete can either be $fooBar, $FooBar, $_fooBar, or $_FooBar. - * - * @param string $string The variable to check. - * @param boolea $public Whether or not the variable is public. - * @return boolean - */ - protected function _isValidVar($string, $public = true) { - $firstChar = '[a-zA-Z]'; - if (!$public) { - $firstChar = '[_]{1,2}' . $firstChar; - } - if (preg_match("|^$firstChar|", $string) === 0) { - return false; - } - $firstStringCount = 1; - if (preg_match("|^__|", $string)) { - $firstStringCount = 2; - } - // Check that the name only contains legal characters. - $legalChars = 'a-zA-Z0-9'; - if (preg_match("|[^$legalChars]|", substr($string, $firstStringCount)) > 0) { - return false; - } - return true; - } - -} diff --git a/tests/codesniffer/FHComplete/ruleset.xml b/tests/codesniffer/FHComplete/ruleset.xml index 6673d18fe..25055a89a 100644 --- a/tests/codesniffer/FHComplete/ruleset.xml +++ b/tests/codesniffer/FHComplete/ruleset.xml @@ -12,6 +12,7 @@ + @@ -22,7 +23,13 @@ + + +