Add CodeSniffing
authorTim Düsterhus <duesterhus@woltlab.com>
Wed, 19 Dec 2012 21:56:22 +0000 (22:56 +0100)
committerTim Düsterhus <duesterhus@woltlab.com>
Thu, 20 Dec 2012 14:44:59 +0000 (15:44 +0100)
35 files changed:
CodeSniff/WCF/Sniffs/Classes/ClassFileNameSniff.php [new file with mode: 0644]
CodeSniff/WCF/Sniffs/ControlStructures/ControlSignatureSniff.php [new file with mode: 0644]
CodeSniff/WCF/Sniffs/WhiteSpace/SuperfluousWhitespaceSniff.php [new file with mode: 0644]
CodeSniff/WCF/ruleset.xml [new file with mode: 0644]
wcfsetup/install/files/acp/dereferrer.php
wcfsetup/install/files/icon/flag/index.php
wcfsetup/install/files/icon/index.php
wcfsetup/install/files/lib/acp/form/PackageStartInstallForm.class.php
wcfsetup/install/files/lib/acp/form/UsersMassProcessingForm.class.php
wcfsetup/install/files/lib/acp/page/IndexPage.class.php
wcfsetup/install/files/lib/action/APIAction.class.php
wcfsetup/install/files/lib/data/DatabaseObjectList.class.php
wcfsetup/install/files/lib/data/ICategorizedObject.class.php
wcfsetup/install/files/lib/data/ILinkableDatabaseObject.class.php
wcfsetup/install/files/lib/data/ILoadableCollapsibleContainerAction.class.php
wcfsetup/install/files/lib/data/ISearchAction.class.php
wcfsetup/install/files/lib/data/ITitledDatabaseObject.class.php
wcfsetup/install/files/lib/data/language/LanguageEditor.class.php
wcfsetup/install/files/lib/system/exception/SystemException.class.php
wcfsetup/install/files/lib/system/io/TarWriter.class.php
wcfsetup/install/files/lib/system/io/ZipWriter.class.php
wcfsetup/install/files/lib/system/language/I18nHandler.class.php
wcfsetup/install/files/lib/system/log/modification/ModificationLogHandler.class.php
wcfsetup/install/files/lib/system/option/user/IUserOptionOutput.class.php
wcfsetup/install/files/lib/system/option/user/group/UserGroupOptionHandler.class.php
wcfsetup/install/files/lib/system/package/ACPTemplatesFileHandler.class.php
wcfsetup/install/files/lib/system/package/plugin/AbstractXMLPackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/sitemap/ISitemapProvider.class.php
wcfsetup/install/files/lib/system/sitemap/SitemapHandler.class.php
wcfsetup/install/files/lib/system/style/lessc.inc.php
wcfsetup/install/files/lib/system/template/TemplateEngine.class.php
wcfsetup/install/files/lib/system/template/TemplateScriptingCompiler.class.php
wcfsetup/install/files/lib/system/template/plugin/StaticlangTemplatePluginCompiler.class.php
wcfsetup/install/files/lib/util/HTTPRequest.class.php
wcfsetup/install/files/lib/util/JSON.class.php

diff --git a/CodeSniff/WCF/Sniffs/Classes/ClassFileNameSniff.php b/CodeSniff/WCF/Sniffs/Classes/ClassFileNameSniff.php
new file mode 100644 (file)
index 0000000..da3ca9d
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+/**
+ * This sniff is based on Squiz_Sniffs_Classes_ClassFileNameSniff. Originally written
+ * by Greg Sherwood <gsherwood@squiz.net> and Marc McIntyre <mmcintyre@squiz.net>
+ * and released under the terms of the BSD Licence.
+ * See: https://github.com/squizlabs/PHP_CodeSniffer/blob/master/CodeSniffer/Standards/Squiz/Sniffs/Classes/ClassFileNameSniff.php
+ * 
+ * @author     Tim Duesterhus
+ * @license    BSD Licence <https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt>
+ * @package    com.woltlab.wcf
+ * @category   Community Framework
+ */
+class WCF_Sniffs_Classes_ClassFileNameSniff implements PHP_CodeSniffer_Sniff {
+       /**
+        * Returns an array of tokens this test wants to listen for.
+        *
+        * @return array
+        */
+       public function register() {
+               return array(
+                       T_CLASS,
+                       T_INTERFACE,
+               );
+       }
+       
+       /**
+        * Processes this test, when one of its tokens is encountered.
+        *
+        * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
+        * @param int                  $stackPtr  The position of the current token in the
+        *                                        stack passed in $tokens.
+        *
+        * @return void
+        */
+       public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
+               $tokens   = $phpcsFile->getTokens();
+               $decName  = $phpcsFile->findNext(T_STRING, $stackPtr);
+               $fullPath = basename($phpcsFile->getFilename());
+               $fileName = substr($fullPath, 0, strpos($fullPath, '.'));
+               
+               if ($tokens[$decName]['content'] !== $fileName) {
+                       $error = '%s name doesn\'t match filename; expected "%s %s"';
+                       $data = array(
+                               ucfirst($tokens[$stackPtr]['content']),
+                               $tokens[$stackPtr]['content'],
+                               $fileName,
+                       );
+                       $phpcsFile->addError($error, $stackPtr, 'NoMatch', $data);
+               }
+       }
+}
diff --git a/CodeSniff/WCF/Sniffs/ControlStructures/ControlSignatureSniff.php b/CodeSniff/WCF/Sniffs/ControlStructures/ControlSignatureSniff.php
new file mode 100644 (file)
index 0000000..283c33e
--- /dev/null
@@ -0,0 +1,46 @@
+<?php
+if (class_exists('PHP_CodeSniffer_Standards_AbstractPatternSniff', true) === false) {
+       throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_Standards_AbstractPatternSniff not found');
+}
+
+/**
+ * This sniff is based on Squiz_Sniffs_ControlStructures_ControlSignatureSniff. Originally written
+ * by Greg Sherwood <gsherwood@squiz.net> and Marc McIntyre <mmcintyre@squiz.net>
+ * and released under the terms of the BSD Licence.
+ * See: https://github.com/squizlabs/PHP_CodeSniffer/blob/master/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/ControlSignatureSniff.php
+ * 
+ * @author     Tim Duesterhus
+ * @license    BSD Licence <https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt>
+ * @package    com.woltlab.wcf
+ * @category   Community Framework
+ */
+class WCF_Sniffs_ControlStructures_ControlSignatureSniff extends PHP_CodeSniffer_Standards_AbstractPatternSniff {
+       /**
+        * A list of tokenizers this sniff supports.
+        *
+        * @var array
+        */
+       public $supportedTokenizers = array(
+               'PHP',
+               'JS'
+       );
+       
+       /**
+        * Returns the patterns that this test wishes to verify.
+        *
+        * @return array(string)
+        */
+       protected function getPatterns() {
+               return array(
+                       'try {EOL...}EOL...catch (...) {',
+                       'do {EOL...}EOL...while (...);EOL',
+                       'while (...) {EOL',
+                       'for (...) {EOL',
+                       'if (...) {EOL',
+                       'foreach (...) {EOL',
+                       '}EOL...else if (...) {EOL',
+                       '}EOL...elseif (...) {EOL',
+                       '}EOL...else {EOL',
+               );
+       }
+}
diff --git a/CodeSniff/WCF/Sniffs/WhiteSpace/SuperfluousWhitespaceSniff.php b/CodeSniff/WCF/Sniffs/WhiteSpace/SuperfluousWhitespaceSniff.php
new file mode 100644 (file)
index 0000000..40d5f21
--- /dev/null
@@ -0,0 +1,177 @@
+<?php
+/**
+ * This sniff is based on Squiz_Sniffs_WhiteSpace_SuperfluousWhitespaceSniff. Originally written
+ * by Greg Sherwood <gsherwood@squiz.net> and Marc McIntyre <mmcintyre@squiz.net>
+ * and released under the terms of the BSD Licence.
+ * See: https://github.com/squizlabs/PHP_CodeSniffer/blob/master/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/SuperfluousWhitespaceSniff.php
+ * 
+ * @author     Tim Duesterhus
+ * @license    BSD Licence <https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt>
+ * @package    com.woltlab.wcf
+ * @category   Community Framework
+ */
+class WCF_Sniffs_WhiteSpace_SuperfluousWhitespaceSniff implements PHP_CodeSniffer_Sniff {
+       /**
+        * A list of tokenizers this sniff supports.
+        *
+        * @var array
+        */
+       public $supportedTokenizers = array(
+               'PHP',
+               'JS',
+               'CSS',
+       );
+       
+       /**
+        * If TRUE, whitespace rules are not checked for blank lines.
+        *
+        * Blank lines are those that contain only whitespace.
+        *
+        * @var boolean
+        */
+       public $ignoreBlankLines = false;
+       
+       /**
+        * Returns an array of tokens this test wants to listen for.
+        *
+        * @return array
+        */
+       public function register() {
+               return array(
+                       T_OPEN_TAG,
+                       T_CLOSE_TAG,
+                       T_WHITESPACE,
+                       T_COMMENT,
+               );
+       }
+       
+       /**
+        * Processes this sniff, when one of its tokens is encountered.
+        *
+        * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
+        * @param int                  $stackPtr  The position of the current token in the
+        *                                        stack passed in $tokens.
+        */
+       public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
+               $tokens = $phpcsFile->getTokens();
+               
+               if ($tokens[$stackPtr]['code'] === T_OPEN_TAG) {
+                       // Check for start of file whitespace.
+                       if ($phpcsFile->tokenizerType !== 'PHP') {
+                               // The first token is always the open tag inserted when tokenizsed
+                               // and the second token is always the first piece of content in
+                               // the file. If the second token is whitespace, there was
+                               // whitespace at the start of the file.
+                               if ($tokens[($stackPtr + 1)]['code'] !== T_WHITESPACE) {
+                                       return;
+                               }
+                       }
+                       else {
+                               // If its the first token, then there is no space.
+                               if ($stackPtr === 0) {
+                                       return;
+                               }
+                               
+                               for ($i = ($stackPtr - 1); $i >= 0; $i--) {
+                                       // If we find something that isn't inline html then there is something previous in the file.
+                                       if ($tokens[$i]['type'] !== 'T_INLINE_HTML') {
+                                               return;
+                                       }
+                                       
+                                       // If we have ended up with inline html make sure it isn't just whitespace.
+                                       $tokenContent = trim($tokens[$i]['content']);
+                                       if ($tokenContent !== '') {
+                                               return;
+                                       }
+                               }
+                       }
+               
+                       $phpcsFile->addError('Additional whitespace found at start of file', $stackPtr, 'StartFile');
+               }
+               else if ($tokens[$stackPtr]['code'] === T_CLOSE_TAG) {
+                       // Check for end of file whitespace.
+                       
+                       if ($phpcsFile->tokenizerType === 'JS') {
+                               // The last token is always the close tag inserted when tokenized
+                               // and the second last token is always the last piece of content in
+                               // the file. If the second last token is whitespace, there was
+                               // whitespace at the end of the file.
+                               if ($tokens[($stackPtr - 1)]['code'] !== T_WHITESPACE) {
+                                       return;
+                               }
+                       }
+                       else if ($phpcsFile->tokenizerType === 'CSS') {
+                               // The last two tokens are always the close tag and whitespace
+                               // inserted when tokenizsed and the third last token is always the
+                               // last piece of content in the file. If the third last token is
+                               // whitespace, there was whitespace at the end of the file.
+                               if ($tokens[($stackPtr - 3)]['code'] !== T_WHITESPACE) {
+                                       return;
+                               }
+                               
+                               // Adjust the pointer to give the correct line number for the error.
+                               $stackPtr -= 2;
+                       }
+                       else {
+                               if (isset($tokens[($stackPtr + 1)]) === false) {
+                                       // The close PHP token is the last in the file.
+                                       return;
+                               }
+                               
+                               for ($i = ($stackPtr + 1); $i < $phpcsFile->numTokens; $i++) {
+                                       // If we find something that isn't inline html then there
+                                       // is more to the file.
+                                       if ($tokens[$i]['type'] !== 'T_INLINE_HTML') {
+                                               return;
+                                       }
+                                       
+                                       // If we have ended up with inline html make sure it
+                                       // isn't just whitespace.
+                                       $tokenContent = trim($tokens[$i]['content']);
+                                       if (empty($tokenContent) === false) {
+                                               return;
+                                       }
+                               }
+                       }
+                       
+                       $phpcsFile->addError('Additional whitespace found at end of file', $stackPtr, 'EndFile');
+               }
+               else {
+                       // Check for end of line whitespace.
+                       
+                       // Ignore whitespace that is not at the end of a line.
+                       if (strpos($tokens[$stackPtr]['content'], $phpcsFile->eolChar) === false) {
+                               return;
+                       }
+                       
+                       // Ignore blank lines if required.
+                       if ($this->ignoreBlankLines === true && $tokens[($stackPtr - 1)]['line'] !== $tokens[$stackPtr]['line']) {
+                               return;
+                       }
+                       
+                       $tokenContent = rtrim($tokens[$stackPtr]['content'], $phpcsFile->eolChar);
+                       if (empty($tokenContent) === false) {
+                               if (preg_match("|^.*\n\\s+$|", $tokenContent) !== 0) {
+                                       $phpcsFile->addError('Whitespace found at end of line', $stackPtr, 'EndLine');
+                               }
+                       }
+               
+                       // Check for multiple blanks lines in a function.
+                       
+                       if ($phpcsFile->hasCondition($stackPtr, T_FUNCTION) === true) {
+                               if ($tokens[($stackPtr - 1)]['line'] < $tokens[$stackPtr]['line'] && $tokens[($stackPtr - 2)]['line'] === $tokens[($stackPtr - 1)]['line']) {
+                                       // This is an empty line and the line before this one is not
+                                       // empty, so this could be the start of a multiple empty
+                                       // line block.
+                                       $next  = $phpcsFile->findNext(T_WHITESPACE, $stackPtr, null, true);
+                                       $lines = $tokens[$next]['line'] - $tokens[$stackPtr]['line'];
+                                       if ($lines > 1) {
+                                               $error = 'Functions must not contain multiple empty lines in a row; found %s empty lines';
+                                               $data  = array($lines);
+                                               $phpcsFile->addError($error, $stackPtr, 'EmptyLines', $data);
+                                       }
+                               }
+                       }
+               }
+       }
+}
diff --git a/CodeSniff/WCF/ruleset.xml b/CodeSniff/WCF/ruleset.xml
new file mode 100644 (file)
index 0000000..c1297a3
--- /dev/null
@@ -0,0 +1,44 @@
+<?xml version="1.0"?>
+<ruleset name="WCF">
+       <description>WoltLab Community Framework Coding Standard</description>
+       <exclude-pattern>*/wcfsetup/test.php</exclude-pattern>
+       <exclude-pattern>*/wcfsetup/install.php</exclude-pattern>
+       <exclude-pattern>*/CodeSniff/*</exclude-pattern>
+       
+       <rule ref="Generic.Classes.DuplicateClassName" />
+       <rule ref="Generic.Files.ByteOrderMark" />
+       <rule ref="Generic.Files.EndFileNewline" />
+       <rule ref="Generic.Files.OneClassPerFile" />
+       <rule ref="Generic.Files.OneInterfacePerFile" />
+       <rule ref="Generic.Formatting.DisallowMultipleStatements" />
+       <rule ref="Generic.Functions.FunctionCallArgumentSpacing" />
+       <rule ref="Generic.Functions.OpeningFunctionBraceKernighanRitchie" />
+       <rule ref="Generic.NamingConventions.UpperCaseConstantName" />
+       <rule ref="Generic.PHP.CharacterBeforePHPOpeningTag" />
+       <rule ref="Generic.PHP.DisallowShortOpenTag" />
+       <rule ref="Generic.PHP.ForbiddenFunctions" />
+       <rule ref="Generic.PHP.LowerCaseConstant" />
+       <rule ref="Generic.WhiteSpace.DisallowSpaceIndent" />
+       <rule ref="Squiz.Arrays.ArrayBracketSpacing" />
+       <rule ref="Squiz.Classes.LowercaseClassKeywords" />
+       <!--rule ref="Squiz.Classes.SelfMemberReference" /--> <!-- TODO: Is this wanted? -->
+       <rule ref="Squiz.Classes.ValidClassName" />
+       <rule ref="Squiz.Commenting.DocCommentAlignment" />
+       <rule ref="Squiz.ControlStructures.ElseIfDeclaration" />
+       <rule ref="Squiz.ControlStructures.ForEachLoopDeclaration" />
+       <rule ref="Squiz.ControlStructures.ForLoopDeclaration" />
+       <rule ref="Squiz.ControlStructures.LowercaseDeclaration" />
+       <rule ref="Squiz.Operators.ValidLogicalOperators" />
+       <rule ref="WCF.Classes.ClassFileName" />
+       <rule ref="WCF.ControlStructures.ControlSignature" />
+       <rule ref="WCF.WhiteSpace.SuperfluousWhitespace" />
+       <rule ref="Zend.Files.ClosingTag" />
+       
+       
+       <!-- Use Unix newlines -->
+       <rule ref="Generic.Files.LineEndings">
+               <properties>
+                       <property name="eolChar" value="\n" />
+               </properties>
+       </rule>
+</ruleset>
index 98cd6d3eff5049af745597cd45d15d4a92fbf0c5..35569c02d0c2cafac47fc3b473d91d2fe7f2aaf4 100644 (file)
@@ -6,6 +6,7 @@
  * @package    com.woltlab.wcf
  * @category   Community Framework
  */
+// @codingStandardsIgnoreFile
 // get url
 $url = '';
 if (isset($_GET['url'])) $url = htmlspecialchars(str_replace(';', '%3B', trim($_GET['url'])));
index f7f786f8baad0a8301fb1a2247e19d0a8af0a04a..263bedda0850aa1f73d3106219e3404c45aded64 100644 (file)
@@ -1,5 +1,6 @@
 <div style="padding: 5em; background-color: lightgrey">
 <?php
+// @codingStandardsIgnoreFile
 $flags = glob('*.svg');
 foreach ($flags as $flag) {
        if ($flag == 'de-informal.svg') {
index 6a07be680c8bf44ea7ee1d5a6c9d65615669a5bd..76ddf6daa734dfa8b5835995f9ade2106bd6dcec 100644 (file)
@@ -1,4 +1,5 @@
 <?php
+// @codingStandardsIgnoreFile
 $icons = array();
 $files = glob('*.svg');
 if (is_array($files)) {
index 1d00d7a3c42863332445022809b97db1c5bea0a1..055b8508e7ceffb5261c084cd6ffe5c4eeee204f 100755 (executable)
@@ -193,7 +193,7 @@ class PackageStartInstallForm extends ACPForm {
                        if (!$this->archive->isValidInstall()) {
                                throw new UserInputException($type, 'noValidInstall');
                        }
-                       elseif ($this->archive->isAlreadyInstalled()) {
+                       else if ($this->archive->isAlreadyInstalled()) {
                                throw new UserInputException($type, 'uniqueAlreadyInstalled');
                        }
                }
index 708b8b34beca0f3bb47e3863e16f87aeb9ed4eb3..8e9cbb998eec750e85a1fadaf8a481a98f713fcc 100644 (file)
@@ -337,7 +337,6 @@ class UsersMassProcessingForm extends UserOptionListForm {
                        $groupIDs[$row['userID']][] = $row['groupID'];
                }
                
-               
                foreach ($users as $userID => $userData) {
                        if (!UserGroup::isAccessibleGroup($groupIDs[$userID])) {
                                throw new PermissionDeniedException();
index e34ef2a8e30ae462383d2012974547f6108714a6..9e65fae0d163778b42d01fae4c9d326de0fffce6 100755 (executable)
@@ -77,7 +77,7 @@ class IndexPage extends AbstractPage {
                                }
                        }
                        
-                       for($i = 0; $i < 7; $i++) {
+                       for ($i = 0; $i < 7; $i++) {
                                if (file_exists(WCF_DIR.'log/'.date('Y-m-d', TIME_NOW - 86400 * $i).'.txt')) {
                                        $this->healthDetails['error'][] = WCF::getLanguage()->getDynamicVariable('wcf.acp.index.health.exception', array(
                                                'date' => TIME_NOW - 86400 * $i
index 55d2cd51134469a4d8eaa1b789beb59278758525..b1d3053891d24a571d536de1c209e169633f88ee 100644 (file)
@@ -59,7 +59,7 @@ final class APIAction extends AbstractAjaxAction {
                
                $this->data = $this->prune($object);
                
-               if(empty($this->data)) {
+               if (empty($this->data)) {
                        throw new AJAXException("no results");
                }
                
@@ -81,7 +81,7 @@ final class APIAction extends AbstractAjaxAction {
        protected function prune(IRESTfulResponse $object) {
                $prunedArray = array();
                
-               foreach($object->getResponseFields() as $fieldName) {
+               foreach ($object->getResponseFields() as $fieldName) {
                        if ($object->$fieldName) {
                                $prunedArray[$fieldName] = $object->$fieldName;
                        }
index 71e760cf068ef206d10aee10dada9b7795dbb897..adb014e440c78052a6099364aedd194ee058be21 100644 (file)
@@ -181,7 +181,7 @@ abstract class DatabaseObjectList implements \Countable, ITraversableObject {
                
                // use table index as array index
                $objects = array();
-               foreach($this->objects as $object) {
+               foreach ($this->objects as $object) {
                        $objectID = $object->{$this->getDatabaseTableIndexName()};
                        $objects[$objectID] = $object;
                        
index ce7f3af21f41a54b8af4730cac3d0c93013b7a37..2ade1832089e5ebc22797d0e3222a9b4249534ab 100644 (file)
@@ -18,4 +18,4 @@ interface ICategorizedObject {
         * @return      wcf\data\category\Category
         */
        public function getCategory();
-}
\ No newline at end of file
+}
index 99eaea07d9a12af21cec8bc9cf143a8eb3a63641..597a9404a0c268bbd6d5befba899c4ec8f4a4b6d 100644 (file)
@@ -18,4 +18,4 @@ interface ILinkableDatabaseObject {
         * @return      string
         */
        public function getLink();
-}
\ No newline at end of file
+}
index 56c926dac179a150b962336fd21ddcb5ff1cf726..3db52ce323e86117e2afd9a87c1f85c746240dee 100644 (file)
@@ -23,4 +23,4 @@ interface ILoadableCollapsibleContainerAction {
         * Validates the "loadContainer" action.
         */
        public function validateLoadContainer();
-}
\ No newline at end of file
+}
index e0f4f1ae47b52053a3801ef46b16f22e71ae8956..94310257f353492b5bc76c85f990555efc002889 100644 (file)
@@ -24,4 +24,4 @@ interface ISearchAction {
         * Validates the "getSearchResultList" action.
         */
        public function validateGetSearchResultList();
-}
\ No newline at end of file
+}
index 18cea0f32c1235ec2061b5e81465534ed83352a9..fbaca8946aa0a5dbce5ff5d1ae0cfc8f2b575d48 100644 (file)
@@ -18,4 +18,4 @@ interface ITitledDatabaseObject {
         * @return      string
         */
        public function getTitle();
-}
\ No newline at end of file
+}
index adec04b551c97fca86a872b9e3d8c215dfd12148..3e816a24cfa5e50ef8f71fc3c7b99da96fb2c29e 100644 (file)
@@ -447,7 +447,7 @@ class LanguageEditor extends DatabaseObjectEditor implements IEditableCachedObje
                $languageItemList->sqlLimit = 0;
                $languageItemList->readObjects();
                
-               foreach($languageItemList->getObjects() as $languageItem) {
+               foreach ($languageItemList->getObjects() as $languageItem) {
                        $languageItemEditor = new LanguageItemEditor($languageItem);
                        $languageItemEditor->update(array(
                                'languageCustomItemValue' => $items[$languageItem->languageItem],
index 9168be41ad866d1f68391fe39e2de0a4f7bf84ae..12081c862e174d40d5596e4e24c43b15951f5b3d 100644 (file)
@@ -13,6 +13,7 @@ use wcf\util\StringUtil;
  * @subpackage system.exception
  * @category   Community Framework
  */
+// @codingStandardsIgnoreFile
 class SystemException extends LoggedException implements IPrintableException {
        /**
         * error description
index 6908fa9291770533d33c0e314c3bd9aad5cb893f..2be3e9f8a0c999d975c8fc9d220ffdd644d9e3e5 100644 (file)
@@ -232,9 +232,15 @@ class TarWriter extends Tar {
                
                // calculate the checksum
                $checksum = 0;
-               for ($i = 0; $i < 148; $i++) $checksum += ord(substr($binaryDataFirst, $i, 1));
-               for ($i = 148; $i < 156; $i++) $checksum += ord(' ');
-               for ($i = 156, $j = 0; $i < 512; $i++, $j++) $checksum += ord(substr($binaryDataLast, $j, 1));
+               for ($i = 0; $i < 148; $i++) {
+                       $checksum += ord(substr($binaryDataFirst, $i, 1));
+               }
+               for ($i = 148; $i < 156; $i++) {
+                       $checksum += ord(' ');
+               }
+               for ($i = 156, $j = 0; $i < 512; $i++, $j++) {
+                       $checksum += ord(substr($binaryDataLast, $j, 1));
+               }
                
                $this->file->write($binaryDataFirst, 148);
                $this->file->write(pack("a8", sprintf("%6s ", decOct($checksum))), 8); // write the checksum
@@ -257,9 +263,15 @@ class TarWriter extends Tar {
                
                // calculate the checksum
                $checksum = 0;
-               for ($i = 0; $i < 148; $i++) $checksum += ord(substr($binaryDataFirst, $i, 1));
-               for ($i = 148; $i < 156; $i++) $checksum += ord(' ');
-               for ($i = 156, $j = 0; $i < 512; $i++, $j++) $checksum += ord(substr($binaryDataLast, $j, 1));
+               for ($i = 0; $i < 148; $i++) {
+                       $checksum += ord(substr($binaryDataFirst, $i, 1));
+               }
+               for ($i = 148; $i < 156; $i++) {
+                       $checksum += ord(' ');
+               }
+               for ($i = 156, $j = 0; $i < 512; $i++, $j++) {
+                       $checksum += ord(substr($binaryDataLast, $j, 1));
+               }
                
                $this->file->write($binaryDataFirst, 148);
                $this->file->write(pack("a8", sprintf("%6s ", decOct($checksum))), 8); // write the checksum
index 738c84afdd650d6e5988c24c4188b92f833ecb2d..d56ac10a1e613aad7023d270059b51b1e5b446e3 100644 (file)
@@ -166,8 +166,8 @@ class ZipWriter {
                        $headers.
                        $data.
                        $this->endOfData.
-                       pack("v", sizeof($this->data)).
-                       pack("v", sizeof($this->data)).
+                       pack("v", count($this->data)).
+                       pack("v", count($this->data)).
                        pack("V", strlen($data)).
                        pack("V", strlen($headers)).
                        "\x00\x00";
index 624c854e27862efccd58317e84442c030fbb0a95..6daa54a0b4e1788f4d390564df67e5cc025b2dc6 100644 (file)
@@ -65,7 +65,7 @@ class I18nHandler extends SingletonFactory {
         * @see wcf\system\SingletonFactory::init()
         */
        protected function init() {
-                $this->availableLanguages = LanguageFactory::getInstance()->getLanguages();
+               $this->availableLanguages = LanguageFactory::getInstance()->getLanguages();
        }
        
        /**
index b7ba33ab19b62ea754f89c8d2d151609e03fdcd2..98e30c41b032e93de5333f802971eaccd8372da1 100644 (file)
@@ -97,4 +97,4 @@ class ModificationLogHandler extends SingletonFactory {
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute($conditions->getParameters());
        }
-}
\ No newline at end of file
+}
index a913ab6d1a0fc2ff40effbf963309381ec4db71b..fa1266dd1a8aa14164d558d4e9566008e7d497f1 100644 (file)
@@ -24,4 +24,3 @@ interface IUserOptionOutput {
         */
        public function getOutput(User $user, UserOption $option, $value);
 }
-?>
index 4c176020eb80b1d52e33d42bc0ad201b4d989bab..871ccfad298692cb4fadee3cf516ac24f981d8b0 100644 (file)
@@ -65,4 +65,4 @@ class UserGroupOptionHandler extends OptionHandler {
                        }
                }
        }
-}
\ No newline at end of file
+}
index defd2b4ff8e99581d8c23cc108b3767141c95801..c268901c8bf8ab83ec7cbecc91aa7218545f70a5 100644 (file)
@@ -76,7 +76,7 @@ class ACPTemplatesFileHandler extends PackageInstallationFileHandler {
                
                // remove file extension
                foreach ($files as &$file) {
-                       $file = preg_replace('~.tpl$~','', $file);
+                       $file = preg_replace('~.tpl$~', '', $file);
                }
                unset($file);
                
index e8118fc88eccb9d7759821e2523750e5aa7ebf05..6862f462b7c8c6f8ed47ed1c0e1aefc29d1c9cbf 100644 (file)
@@ -315,7 +315,7 @@ abstract class AbstractXMLPackageInstallationPlugin extends AbstractPackageInsta
         */
        protected function getShowOrder($showOrder, $parentName = null, $columnName = null, $tableNameExtension = '') {
                if ($showOrder === null) {
-                        // get greatest showOrder value
+                       // get greatest showOrder value
                        $conditions = new PreparedStatementConditionBuilder();
                        if ($columnName !== null) $conditions->add($columnName." = ?", array($parentName));
                        
index c398d282b95c787ff79de95a5ed92d05b2566870..daecaea19f08315caa6950ccc642b888625cbe96 100644 (file)
@@ -18,4 +18,4 @@ interface ISitemapProvider {
         * @return      string
         */
        public function getTemplate();
-}
\ No newline at end of file
+}
index eddce10745c5dcd3980edcf2289eecaf6f6b751c..92e54e14dd43f60991d5c8eee8c5355c47e80aa6 100644 (file)
@@ -107,4 +107,4 @@ class SitemapHandler extends SingletonFactory {
                        throw new SystemException("Sitemap name '".$sitemapName."' is unknown");
                }
        }
-}
\ No newline at end of file
+}
index c42147c58ad95201ec590f52b5a22ba08d4e942f..219d217514db7245c97a7a9de588360dfc8c7a08 100644 (file)
@@ -1,5 +1,5 @@
 <?php
-
+// @codingStandardsIgnoreFile
 /**
  * lessphp v0.3.8
  * http://leafo.net/lessphp
index 416fa721cde86ddd9e5c6f654be6843f8cce4d2a..851d18960816ea5ef589c58817727493ac8e136e 100755 (executable)
@@ -359,7 +359,6 @@ class TemplateEngine extends SingletonFactory {
                        return 1;
                }
                
-               
                throw new SystemException("Unable to find template '$templateName'");
        }
        
index d1dda3fc178e3137053962955f15172837e92520..cb5abc710a92350c60a275277bc092a6a5be8e84 100644 (file)
@@ -884,7 +884,7 @@ class TemplateScriptingCompiler {
         */
        public static function makeArgString($args) {
                $argString = '';
-               foreach ($args as $key => $val) {
+               foreach ($args as $key => $val) {
                        if ($argString != '') {
                                $argString .= ', ';
                        }
@@ -906,7 +906,7 @@ class TemplateScriptingCompiler {
                if ($file && $line) {
                        $errorMsg .= " in template '$file' on line $line";
                }
-               elseif ($file && !$line) {
+               else if ($file && !$line) {
                        $errorMsg .= " in template '$file'";
                }
                return $errorMsg;
index b716484b5fc50ecb7fac50bd9903b00fb4958cf9..ff4e3e37da434d1049a378779bfa651e28d7b0e6 100644 (file)
@@ -15,6 +15,7 @@ use wcf\system\template\TemplateScriptingCompiler;
  * @subpackage system.template.plugin
  * @category   Community Framework
  */
+// TODO: Is the classname or the filename correct?
 class StaticlangCompilerTemplatePlugin implements ICompilerTemplatePlugin {
        /**
         * @see wcf\system\template\ICompilerTemplatePlugin::executeStart()
index 97c5f1aacf0f2c7291494d8e5fc685a633a7098d..54ba7fa405f8016b5069fa330473213610446185 100644 (file)
@@ -317,4 +317,4 @@ final class HTTPRequest {
                $this->replyBody = '';
                $this->statusCode = 0;
        }
-}
\ No newline at end of file
+}
index 98ed96baad2007420869d748d1e9aa7c3e44371b..9ee70e1718bee48ed1877b9b91ca0efeb2587fad 100644 (file)
@@ -51,4 +51,4 @@ final class JSON {
        }
        
        private function __construct() { }
-}
\ No newline at end of file
+}