diff options
author | Andreas Gohr <andi@splitbrain.org> | 2012-04-15 13:45:45 +0200 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2012-04-15 13:45:45 +0200 |
commit | ae7c596cf4e6a0a09ebcf01fe8ae98789360c5be (patch) | |
tree | f156252e404e9893922cb5d984fdc646644b6c17 /_cs | |
parent | f41c79d730286e8e8c95deb88a4c876e08e278a2 (diff) | |
parent | 026b314868ee80aca644bf4107f78d8e8052b43e (diff) | |
download | rpg-ae7c596cf4e6a0a09ebcf01fe8ae98789360c5be.tar.gz rpg-ae7c596cf4e6a0a09ebcf01fe8ae98789360c5be.tar.bz2 |
Merge branch 'master' into htmlmail
* master: (382 commits)
Romanian language update
Marathi language update
Arabic Language Update
when there's not enough space for images, make sure they stay proportional (might be FS#2480)
added minimal RTL print styles (part of FS#2185)
moved plugins' rtl.css to their style.css counterpart (part of FS#2185)
removed all browser-specific gradients as the recently (in 42ff6730) introduced svg makes them unnecessary
removed comments from accidentally commented lines in tpl_includeFile()
removed obsolete template file
added tpl_includeFile() to core
Make getTitle method in remote interface public
Changed an error code in XML-RPC interface. This error hasn't anything to do with the rest of the -32600 errors.
BG: language update
Korean language update
fixed performance issues with gradient in Firefox (which also added gradient support for IE9) (FS#2447)
deleted very old (and unused) images
added accidentally removed '<?php' back in (was in 57fc5edd)
wrapped X-UA-Compatible meta tag with conditional comments
added explanation to todo in _forms.css
removed problematic 'overflow: hidden' from lists again ('unfixes' FS#1950)
...
Conflicts:
inc/auth.php
inc/load.php
Diffstat (limited to '_cs')
-rw-r--r-- | _cs/DokuWiki/DokuWikiCodingStandard.php | 78 | ||||
-rw-r--r-- | _cs/DokuWiki/Sniffs/NamingConventions/ConstructorNameSniff.php | 85 | ||||
-rw-r--r-- | _cs/DokuWiki/Sniffs/PHP/DeprecatedFunctionsSniff.php | 61 | ||||
-rw-r--r-- | _cs/DokuWiki/Sniffs/PHP/DiscouragedFunctionsSniff.php | 4 | ||||
-rw-r--r-- | _cs/DokuWiki/ruleset.xml | 64 |
5 files changed, 211 insertions, 81 deletions
diff --git a/_cs/DokuWiki/DokuWikiCodingStandard.php b/_cs/DokuWiki/DokuWikiCodingStandard.php deleted file mode 100644 index 36133fc46..000000000 --- a/_cs/DokuWiki/DokuWikiCodingStandard.php +++ /dev/null @@ -1,78 +0,0 @@ -<?php -/** - * DokuWiki Coding Standard. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Andreas Gohr <andi@splitbrain.org> - */ - -if (class_exists('PHP_CodeSniffer_Standards_CodingStandard', true) === false) { - throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_Standards_CodingStandard not found'); -} - -/** - * DokuWiki Coding Standard. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Andreas Gohr <andi@splitbrain.org> - */ -class PHP_CodeSniffer_Standards_DokuWiki_DokuWikiCodingStandard extends PHP_CodeSniffer_Standards_CodingStandard { - - - /** - * Return a list of external sniffs to include with this standard. - * - * @return array - */ - public function getIncludedSniffs() { - return array( - 'Generic/Sniffs/Classes/DuplicateClassNameSniff.php', - 'Generic/Sniffs/CodeAnalysis/JumbledIncrementerSniff.php', - 'Generic/Sniffs/CodeAnalysis/UnnecessaryFinalModifierSniff.php', - 'Generic/Sniffs/CodeAnalysis/UnconditionalIfStatementSniff.php', - 'Generic/Sniffs/CodeAnalysis/ForLoopShouldBeWhileLoopSniff.php', - 'Generic/Sniffs/CodeAnalysis/ForLoopWithTestFunctionCallSniff.php', - 'Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php', - 'Generic/Sniffs/CodeAnalysis/EmptyStatementSniff.php', - 'Generic/Sniffs/CodeAnalysis/UselessOverridingMethodSniff.php', - 'Generic/Sniffs/Commenting/TodoSniff.php', - 'Generic/Sniffs/Files/LineEndingsSniff.php', - 'Generic/Sniffs/Formatting/DisallowMultipleStatementsSniff.php', - 'Generic/Sniffs/Metrics/NestingLevelSniff.php', -// 'Generic/Sniffs/Metrics/CyclomaticComplexitySniff.php', //FIXME we might need to tune this first - 'Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php', - 'Generic/Sniffs/PHP/LowerCaseConstantSniff.php', - 'Generic/Sniffs/PHP/DisallowShortOpenTagSniff.php', - 'Generic/Sniffs/PHP/ForbiddenFunctionsSniff.php', - 'Generic/Sniffs/WhiteSpace/DisallowTabIndentSniff.php', - 'DokuWiki/Sniffs/WhiteSpace/ScopeIndentSniff.php', - 'Zend/Sniffs/Files/ClosingTagSniff.php', - 'PEAR/Sniffs/Functions/ValidDefaultValueSniff.php', - 'Squiz/Sniffs/PHP/EvalSniff.php', - 'Squiz/Sniffs/PHP/NonExecutableCodeSniff.php', -// 'Squiz/Sniffs/PHP/CommentedOutCodeSniff.php', //FIXME should ignore oneliners - 'Squiz/Sniffs/WhiteSpace/SuperfluousWhitespaceSniff.php', - 'Squiz/Sniffs/PHP/NonExecutableCodeSniff.php', - 'Squiz/Sniffs/CSS/LowercaseStyleDefinitionSniff.php', - 'Squiz/Sniffs/CSS/MissingColonSniff.php', - 'Squiz/Sniffs/CSS/DisallowMultipleStyleDefinitionsSniff.php', - 'Squiz/Sniffs/CSS/ColonSpacingSniff.php', - 'Squiz/Sniffs/CSS/ClassDefinitionClosingBraceSpaceSniff.php', - 'Squiz/Sniffs/CSS/SemicolonSpacingSniff.php', - 'Squiz/Sniffs/CSS/IndentationSniff.php', - 'Squiz/Sniffs/CSS/EmptyClassDefinitionSniff.php', - 'Squiz/Sniffs/CSS/ClassDefinitionNameSpacingSniff.php', - 'Squiz/Sniffs/CSS/EmptyStyleDefinitionSniff.php', - 'Squiz/Sniffs/CSS/OpacitySniff.php', - 'Squiz/Sniffs/CSS/ColourDefinitionSniff.php', - 'Squiz/Sniffs/CSS/DuplicateClassDefinitionSniff.php', - 'Squiz/Sniffs/CSS/ClassDefinitionOpeningBraceSpaceSniff.php', - - 'Squiz/Sniffs/Commenting/DocCommentAlignmentSniff.php', - - ); - } - -}//end class diff --git a/_cs/DokuWiki/Sniffs/NamingConventions/ConstructorNameSniff.php b/_cs/DokuWiki/Sniffs/NamingConventions/ConstructorNameSniff.php new file mode 100644 index 000000000..7dd6d9366 --- /dev/null +++ b/_cs/DokuWiki/Sniffs/NamingConventions/ConstructorNameSniff.php @@ -0,0 +1,85 @@ +<?php +/** + * Generic_Sniffs_NamingConventions_ConstructorNameSniff. + * + * PHP version 5 + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood <gsherwood@squiz.net> + * @author Leif Wickland <lwickland@rightnow.com> + * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600) + * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence + * @link http://pear.php.net/package/PHP_CodeSniffer + */ + +if (class_exists('PHP_CodeSniffer_Standards_AbstractScopeSniff', true) === false) { + $error = 'Class PHP_CodeSniffer_Standards_AbstractScopeSniff not found'; + throw new PHP_CodeSniffer_Exception($error); +} + +/** + * Generic_Sniffs_NamingConventions_ConstructorNameSniff. + * + * Favor PHP 5 constructor syntax, which uses "function __construct()". + * Avoid PHP 4 constructor syntax, which uses "function ClassName()". + * + * @category PHP + * @package PHP_CodeSniffer + * @author Leif Wickland <lwickland@rightnow.com> + * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence + * @version Release: 1.3.3 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class DokuWiki_Sniffs_NamingConventions_ConstructorNameSniff extends Generic_Sniffs_NamingConventions_ConstructorNameSniff +{ + /** + * Processes this test when one of its tokens is encountered. + * + * @param PHP_CodeSniffer_File $phpcsFile The current file being scanned. + * @param int $stackPtr The position of the current token + * in the stack passed in $tokens. + * @param int $currScope A pointer to the start of the scope. + * + * @return void + */ + protected function processTokenWithinScope( + PHP_CodeSniffer_File $phpcsFile, + $stackPtr, + $currScope + ) { + $className = $phpcsFile->getDeclarationName($currScope); + $methodName = $phpcsFile->getDeclarationName($stackPtr); + + if (strcasecmp($methodName, $className) === 0) { + $error = 'PHP4 style constructors are discouraged; use "__construct()" instead'; + $phpcsFile->addWarning($error, $stackPtr, 'OldStyle'); + } else if (strcasecmp($methodName, '__construct') !== 0) { + // Not a constructor. + return; + } + + $tokens = $phpcsFile->getTokens(); + + $parentClassName = $phpcsFile->findExtendedClassName($currScope); + if ($parentClassName === false) { + return; + } + + $endFunctionIndex = $tokens[$stackPtr]['scope_closer']; + $startIndex = $stackPtr; + while ($doubleColonIndex = $phpcsFile->findNext(array(T_DOUBLE_COLON), $startIndex, $endFunctionIndex)) { + if ($tokens[($doubleColonIndex + 1)]['code'] === T_STRING + && $tokens[($doubleColonIndex + 1)]['content'] === $parentClassName + ) { + $error = 'PHP4 style calls to parent constructors are discouraged; use "parent::__construct()" instead'; + $phpcsFile->addWarning($error, ($doubleColonIndex + 1), 'OldStyleCall'); + } + + $startIndex = ($doubleColonIndex + 1); + } + + }//end processTokenWithinScope() + + +}//end class diff --git a/_cs/DokuWiki/Sniffs/PHP/DeprecatedFunctionsSniff.php b/_cs/DokuWiki/Sniffs/PHP/DeprecatedFunctionsSniff.php new file mode 100644 index 000000000..ecd4093b8 --- /dev/null +++ b/_cs/DokuWiki/Sniffs/PHP/DeprecatedFunctionsSniff.php @@ -0,0 +1,61 @@ +<?php +/** + * DokuWiki_Sniffs_PHP_DiscouragedFunctionsSniff. + * + * PHP version 5 + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood <gsherwood@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: DiscouragedFunctionsSniff.php 265110 2008-08-19 06:36:11Z squiz $ + * @link http://pear.php.net/package/PHP_CodeSniffer + */ + +if (class_exists('Generic_Sniffs_PHP_ForbiddenFunctionsSniff', true) === false) { + throw new PHP_CodeSniffer_Exception('Class Generic_Sniffs_PHP_ForbiddenFunctionsSniff not found'); +} + +/** + * DokuWiki_Sniffs_PHP_DiscouragedFunctionsSniff. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood <gsherwood@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.2.2 + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class DokuWiki_Sniffs_PHP_DeprecatedFunctionsSniff extends Generic_Sniffs_PHP_ForbiddenFunctionsSniff +{ + + /** + * A list of forbidden functions with their alternatives. + * + * The value is NULL if no alternative exists. IE, the + * function should just not be used. + * + * @var array(string => string|null) + */ + protected $forbiddenFunctions = array( + 'setCorrectLocale' => null, + 'html_attbuild' => 'buildAttributes', + 'io_runcmd' => null, + 'p_wiki_xhtml_summary' => 'p_cached_output', + 'search_callback' => 'call_user_func_array', + 'search_backlinks' => 'ft_backlinks', + 'search_fulltext' => 'Fulltext Indexer', + 'search_regex' => 'Fulltext Indexer', + 'tpl_getFavicon' => 'tpl_getMediaFile', + ); + + /** + * If true, an error will be thrown; otherwise a warning. + * + * @var bool + */ + public $error = true; + +}//end class diff --git a/_cs/DokuWiki/Sniffs/PHP/DiscouragedFunctionsSniff.php b/_cs/DokuWiki/Sniffs/PHP/DiscouragedFunctionsSniff.php index c95e0fd33..9cd9a7d36 100644 --- a/_cs/DokuWiki/Sniffs/PHP/DiscouragedFunctionsSniff.php +++ b/_cs/DokuWiki/Sniffs/PHP/DiscouragedFunctionsSniff.php @@ -49,8 +49,6 @@ class DokuWiki_Sniffs_PHP_DiscouragedFunctionsSniff extends Generic_Sniffs_PHP_F * * @var bool */ - protected $error = false; + public $error = false; }//end class - -?> diff --git a/_cs/DokuWiki/ruleset.xml b/_cs/DokuWiki/ruleset.xml new file mode 100644 index 000000000..bfbef87fe --- /dev/null +++ b/_cs/DokuWiki/ruleset.xml @@ -0,0 +1,64 @@ +<?xml version="1.0"?> +<ruleset name="DokuWiki"> + <description>DokuWiki Coding Standard</description> + + <!-- ignore 3rd party libraries (that we haven't adopted) --> + <exclude-pattern>*/adLDAP.php</exclude-pattern> + <exclude-pattern>*/EmailAddressValidator.php</exclude-pattern> + <exclude-pattern>*/feedcreator.class.php</exclude-pattern> + <exclude-pattern>*/SimplePie.php</exclude-pattern> + <exclude-pattern>*/geshi.php</exclude-pattern> + <exclude-pattern>*/geshi/*</exclude-pattern> + <exclude-pattern>*/JSON.php</exclude-pattern> + + <!-- ignore devel only parts --> + <exclude-pattern>*/_test/*</exclude-pattern> + <exclude-pattern>*/_cs/*</exclude-pattern> + + <rule ref="Generic.Classes.DuplicateClassName" /> + <rule ref="Generic.CodeAnalysis.JumbledIncrementer" /> + <rule ref="Generic.CodeAnalysis.UnnecessaryFinalModifier" /> + <rule ref="Generic.CodeAnalysis.UnconditionalIfStatement" /> + <rule ref="Generic.CodeAnalysis.ForLoopShouldBeWhileLoop" /> + <rule ref="Generic.CodeAnalysis.ForLoopWithTestFunctionCall" /> + <rule ref="Generic.CodeAnalysis.UnusedFunctionParameter" /> + <rule ref="Generic.CodeAnalysis.EmptyStatement" /> + <rule ref="Generic.CodeAnalysis.UselessOverridingMethod" /> + <rule ref="Generic.Commenting.Todo" /> + <ruke ref="Generic.Files.ByteOrderMark" /> + <rule ref="Generic.Files.LineEndings" /> + <rule ref="Generic.Formatting.DisallowMultipleStatements" /> + <rule ref="Generic.Metrics.NestingLevel"> + <properties> + <property name="nestingLevel" value="6" /> + </properties> + </rule> + <rule ref="Generic.NamingConventions.UpperCaseConstantName" /> + <rule ref="Generic.PHP.LowerCaseConstant" /> + <rule ref="Generic.PHP.DeprecatedFunctions.php" /> + <rule ref="Generic.PHP.DisallowShortOpenTag" /> + <rule ref="Generic.PHP.ForbiddenFunctions" /> + <rule ref="Generic.WhiteSpace.DisallowTabIndent" /> + <rule ref="Generic.Classes.DuplicateClassName" /> + <rule ref="Generic.Functions.CallTimePassByReference" /> + <rule ref="Zend.Files.ClosingTag" /> + <rule ref="PEAR.Functions.ValidDefaultValue" /> + <rule ref="Squiz.PHP.Eval" /> + <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace" /> + <rule ref="Squiz.CSS.LowercaseStyleDefinition" /> + <rule ref="Squiz.CSS.MissingColon" /> + <rule ref="Squiz.CSS.DisallowMultipleStyleDefinitions" /> + <rule ref="Squiz.CSS.ColonSpacing" /> + <rule ref="Squiz.CSS.ClassDefinitionClosingBraceSpace" /> + <rule ref="Squiz.CSS.SemicolonSpacing" /> + <rule ref="Squiz.CSS.Indentation" /> + <rule ref="Squiz.CSS.EmptyClassDefinition" /> + <rule ref="Squiz.CSS.ClassDefinitionNameSpacing" /> + <rule ref="Squiz.CSS.EmptyStyleDefinition" /> + <rule ref="Squiz.CSS.Opacity" /> + <rule ref="Squiz.CSS.ColourDefinition" /> + <rule ref="Squiz.CSS.DuplicateClassDefinition" /> + <rule ref="Squiz.CSS.ClassDefinitionOpeningBraceSpace" /> + <rule ref="Squiz.Commenting.DocCommentAlignment" /> + +</ruleset> |