mirror of
https://github.com/phpbb/phpbb.git
synced 2025-03-13 20:28:44 +01:00
Merge branch '3.1.x'
* 3.1.x: [ticket/13790] Update phpcs Conflicts: phpBB/composer.json phpBB/composer.lock
This commit is contained in:
commit
f958d05aed
@ -75,14 +75,14 @@
|
||||
|
||||
<target name="sniff">
|
||||
<exec command="phpBB/vendor/bin/phpcs
|
||||
-s
|
||||
-s -p
|
||||
--extensions=php
|
||||
--standard=build/code_sniffer/ruleset-php-strict-core.xml
|
||||
--ignore=${project.basedir}/phpBB/phpbb/db/migration/data/v30x/*
|
||||
phpBB/phpbb"
|
||||
dir="." returnProperty="retval-php-strict" passthru="true" />
|
||||
<exec command="phpBB/vendor/bin/phpcs
|
||||
-s
|
||||
-s -p
|
||||
--extensions=php
|
||||
--standard=build/code_sniffer/ruleset-php-legacy-core.xml
|
||||
--ignore=${project.basedir}/phpBB/cache/*
|
||||
@ -98,7 +98,7 @@
|
||||
phpBB"
|
||||
dir="." returnProperty="retval-php-legacy" passthru="true" />
|
||||
<exec command="phpBB/vendor/bin/phpcs
|
||||
-s
|
||||
-s -p
|
||||
--extensions=php
|
||||
--standard=build/code_sniffer/ruleset-php-extensions.xml
|
||||
--ignore=${project.basedir}/phpBB/ext/*/tests/*
|
||||
|
@ -60,14 +60,14 @@ class phpbb_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
|
||||
return;
|
||||
}
|
||||
// Mark as error if this is not a doc comment
|
||||
else if ($start === false || $tokens[$start]['code'] !== T_DOC_COMMENT)
|
||||
else if ($start === false || $tokens[$start]['code'] !== T_DOC_COMMENT_OPEN_TAG)
|
||||
{
|
||||
$phpcsFile->addError('Missing required file doc comment.', $stackPtr);
|
||||
return;
|
||||
}
|
||||
|
||||
// Find comment end token
|
||||
$end = $phpcsFile->findNext(T_DOC_COMMENT, $start + 1, null, true) - 1;
|
||||
$end = $tokens[$start]['comment_closer'];
|
||||
|
||||
// If there is no end, skip processing here
|
||||
if ($end === false)
|
||||
@ -75,38 +75,30 @@ class phpbb_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
|
||||
return;
|
||||
}
|
||||
|
||||
// List of found comment tags
|
||||
$tags = array();
|
||||
|
||||
// check comment lines without the first(/**) an last(*/) line
|
||||
for ($i = $start + 1, $c = $end - 1; $i <= $c; ++$i)
|
||||
for ($token = $start + 1, $c = $end - 2; $token <= $c; ++$token)
|
||||
{
|
||||
$line = $tokens[$i]['content'];
|
||||
|
||||
// Check that each line starts with a '*'
|
||||
if (substr($line, 0, 1) !== '*' && substr($line, 0, 2) !== ' *')
|
||||
if ($tokens[$token]['column'] === 1 && (($tokens[$token]['content'] !== '*' && $tokens[$token]['content'] !== ' ') || ($tokens[$token]['content'] === ' ' && $tokens[$token + 1]['content'] !== '*')))
|
||||
{
|
||||
$message = 'The file doc comment should not be indented.';
|
||||
$phpcsFile->addWarning($message, $i);
|
||||
}
|
||||
else if (preg_match('/^[ ]?\*\s+@([\w]+)\s+(.*)$/', $line, $match) !== 0)
|
||||
{
|
||||
if (!isset($tags[$match[1]]))
|
||||
{
|
||||
$tags[$match[1]] = array();
|
||||
}
|
||||
|
||||
$tags[$match[1]][] = array($match[2], $i);
|
||||
$phpcsFile->addWarning($message, $token);
|
||||
}
|
||||
}
|
||||
|
||||
// Check that the first and last line is empty
|
||||
if (trim($tokens[$start + 1]['content']) !== '*')
|
||||
// /**T_WHITESPACE
|
||||
// (T_WHITESPACE)*T_WHITESPACE
|
||||
// (T_WHITESPACE)* ...
|
||||
// (T_WHITESPACE)*T_WHITESPACE
|
||||
// T_WHITESPACE*/
|
||||
if (!(($tokens[$start + 2]['content'] !== '*' && $tokens[$start + 4]['content'] !== '*') || ($tokens[$start + 3]['content'] !== '*' && $tokens[$start + 6]['content'] !== '*')))
|
||||
{
|
||||
$message = 'The first file comment line should be empty.';
|
||||
$phpcsFile->addWarning($message, ($start + 1));
|
||||
}
|
||||
if (trim($tokens[$end - 1]['content']) !== '*')
|
||||
|
||||
if ($tokens[$end - 3]['content'] !== '*' && $tokens[$end - 6]['content'] !== '*')
|
||||
{
|
||||
$message = 'The last file comment line should be empty.';
|
||||
$phpcsFile->addWarning($message, $end - 1);
|
||||
@ -114,8 +106,8 @@ class phpbb_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
|
||||
|
||||
//$this->processPackage($phpcsFile, $start, $tags);
|
||||
//$this->processVersion($phpcsFile, $start, $tags);
|
||||
$this->processCopyright($phpcsFile, $start, $tags);
|
||||
$this->processLicense($phpcsFile, $start, $tags);
|
||||
$this->processCopyright($phpcsFile, $start, $tokens[$start]['comment_tags']);
|
||||
$this->processLicense($phpcsFile, $start, $tokens[$start]['comment_tags']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -176,17 +168,24 @@ class phpbb_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
|
||||
protected function processCopyright(PHP_CodeSniffer_File $phpcsFile, $ptr, $tags)
|
||||
{
|
||||
$copyright = '(c) phpBB Limited <https://www.phpbb.com>';
|
||||
$tokens = $phpcsFile->getTokens();
|
||||
|
||||
if (!isset($tags['copyright']))
|
||||
foreach ($tags as $tag)
|
||||
{
|
||||
$message = 'Missing require @copyright tag in file doc comment.';
|
||||
$phpcsFile->addError($message, $ptr);
|
||||
}
|
||||
else if ($tags['copyright'][0][0] !== $copyright)
|
||||
{
|
||||
$message = 'Invalid content found for the first @copyright tag, use "' . $copyright . '".';
|
||||
$phpcsFile->addError($message, $tags['copyright'][0][1]);
|
||||
if ($tokens[$tag]['content'] === '@copyright')
|
||||
{
|
||||
if ($tokens[$tag + 2]['content'] !== $copyright)
|
||||
{
|
||||
$message = 'Invalid content found for the first @copyright tag, use "' . $copyright . '".';
|
||||
$phpcsFile->addError($message, $tags['copyright'][0][1]);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$message = 'Missing require @copyright tag in file doc comment.';
|
||||
$phpcsFile->addError($message, $ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -201,22 +200,33 @@ class phpbb_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
|
||||
protected function processLicense(PHP_CodeSniffer_File $phpcsFile, $ptr, $tags)
|
||||
{
|
||||
$license = 'GNU General Public License, version 2 (GPL-2.0)';
|
||||
$tokens = $phpcsFile->getTokens();
|
||||
|
||||
if (!isset($tags['license']))
|
||||
$found = false;
|
||||
foreach ($tags as $tag)
|
||||
{
|
||||
if ($tokens[$tag]['content'] === '@license')
|
||||
{
|
||||
if ($found)
|
||||
{
|
||||
$message = 'It must be only one @license tag in file doc comment.';
|
||||
$phpcsFile->addError($message, $ptr);
|
||||
}
|
||||
|
||||
$found = true;
|
||||
|
||||
if ($tokens[$tag + 2]['content'] !== $license)
|
||||
{
|
||||
$message = 'Invalid content found for @license tag, use "' . $license . '".';
|
||||
$phpcsFile->addError($message, $tags['license'][0][1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$found)
|
||||
{
|
||||
$message = 'Missing require @license tag in file doc comment.';
|
||||
$phpcsFile->addError($message, $ptr);
|
||||
}
|
||||
else if (sizeof($tags['license']) !== 1)
|
||||
{
|
||||
$message = 'It must be only one @license tag in file doc comment.';
|
||||
$phpcsFile->addError($message, $ptr);
|
||||
}
|
||||
else if (trim($tags['license'][0][0]) !== $license)
|
||||
{
|
||||
$message = 'Invalid content found for @license tag, use '
|
||||
. '"' . $license . '".';
|
||||
$phpcsFile->addError($message, $tags['license'][0][1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -138,6 +138,7 @@ class phpbb_Sniffs_Namespaces_UnusedUseSniff implements PHP_CodeSniffer_Sniff
|
||||
// Check docblocks
|
||||
$find = array(
|
||||
T_COMMENT,
|
||||
T_DOC_COMMENT_CLOSE_TAG,
|
||||
T_DOC_COMMENT,
|
||||
T_CLASS,
|
||||
T_FUNCTION,
|
||||
@ -147,43 +148,31 @@ class phpbb_Sniffs_Namespaces_UnusedUseSniff implements PHP_CodeSniffer_Sniff
|
||||
$comment_end = $phpcsFile->findPrevious($find, ($function_declaration - 1));
|
||||
if ($comment_end !== false)
|
||||
{
|
||||
if (!$tokens[$comment_end]['code'] !== T_DOC_COMMENT)
|
||||
if ($tokens[$comment_end]['code'] === T_DOC_COMMENT_CLOSE_TAG)
|
||||
{
|
||||
$comment_start = ($phpcsFile->findPrevious(T_DOC_COMMENT, ($comment_end - 1), null, true) + 1);
|
||||
$comment = $phpcsFile->getTokensAsString($comment_start, ($comment_end - $comment_start + 1));
|
||||
|
||||
try
|
||||
{
|
||||
$comment_parser = new PHP_CodeSniffer_CommentParser_FunctionCommentParser($comment, $phpcsFile);
|
||||
$comment_parser->parse();
|
||||
|
||||
// Check @param
|
||||
foreach ($comment_parser->getParams() as $param) {
|
||||
$type = $param->getType();
|
||||
$types = explode('|', str_replace('[]', '', $type));
|
||||
foreach ($types as $type)
|
||||
{
|
||||
$ok = $this->check($phpcsFile, $type, $class_name_full, $class_name_short, $param->getLine() + $comment_start) ? true : $ok;
|
||||
}
|
||||
$comment_start = $tokens[$comment_end]['comment_opener'];
|
||||
foreach ($tokens[$comment_start]['comment_tags'] as $tag) {
|
||||
if ($tokens[$tag]['content'] !== '@param' && $tokens[$tag]['content'] !== '@return' && $tokens[$tag]['content'] !== '@throws') {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check @return
|
||||
$return = $comment_parser->getReturn();
|
||||
if ($return !== null)
|
||||
$classes = $tokens[($tag + 2)]['content'];
|
||||
$space = strpos($classes, ' ');
|
||||
if ($space !== false) {
|
||||
$classes = substr($classes, 0, $space);
|
||||
}
|
||||
|
||||
$tab = strpos($classes, "\t");
|
||||
if ($tab !== false) {
|
||||
$classes = substr($classes, 0, $tab);
|
||||
}
|
||||
|
||||
$classes = explode('|', str_replace('[]', '', $classes));
|
||||
foreach ($classes as $class)
|
||||
{
|
||||
$type = $return->getValue();
|
||||
$types = explode('|', str_replace('[]', '', $type));
|
||||
foreach ($types as $type)
|
||||
{
|
||||
$ok = $this->check($phpcsFile, $type, $class_name_full, $class_name_short, $return->getLine() + $comment_start) ? true : $ok;
|
||||
}
|
||||
$ok = $this->check($phpcsFile, $class, $class_name_full, $class_name_short, $tokens[$tag + 2]['line']) ? true : $ok;
|
||||
}
|
||||
}
|
||||
catch (PHP_CodeSniffer_CommentParser_ParserException $e)
|
||||
{
|
||||
$line = ($e->getLineWithinComment() + $comment_start);
|
||||
$phpcsFile->addError($e->getMessage(), $line, 'FailedParse');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@
|
||||
"phpunit/dbunit": "1.3.*",
|
||||
"phpunit/phpunit": "4.1.*",
|
||||
"sami/sami": "1.*",
|
||||
"squizlabs/php_codesniffer": "1.*",
|
||||
"squizlabs/php_codesniffer": "2.*",
|
||||
"symfony/browser-kit": "2.8.*@dev",
|
||||
"symfony/css-selector": "2.8.*@dev",
|
||||
"symfony/debug": "2.8.*@dev",
|
||||
|
418
phpBB/composer.lock
generated
418
phpBB/composer.lock
generated
File diff suppressed because it is too large
Load Diff
@ -978,7 +978,7 @@ class p_master
|
||||
*
|
||||
* @param string $class module class (acp/mcp/ucp)
|
||||
* @param string $name module name (class name of the module, or its basename
|
||||
* phpbb_ext_foo_acp_bar_module, ucp_zebra or zebra)
|
||||
* phpbb_ext_foo_acp_bar_module, ucp_zebra or zebra)
|
||||
* @param string $mode mode, as passed through to the module
|
||||
*
|
||||
*/
|
||||
|
@ -13,7 +13,6 @@
|
||||
|
||||
namespace phpbb\auth\provider\oauth;
|
||||
|
||||
|
||||
use OAuth\OAuth1\Token\StdOAuth1Token;
|
||||
use OAuth\Common\Token\TokenInterface;
|
||||
use OAuth\Common\Storage\TokenStorageInterface;
|
||||
|
@ -107,7 +107,7 @@ class sql_insert_buffer
|
||||
* first building a huge rowset. Or at least sizeof($rows) should be kept
|
||||
* small.
|
||||
*
|
||||
* @param array $rows
|
||||
* @param array $rows
|
||||
*
|
||||
* @return bool True when some data was flushed to the database.
|
||||
* False otherwise.
|
||||
|
@ -60,7 +60,7 @@ abstract class base implements \phpbb\notification\method\method_interface
|
||||
|
||||
/**
|
||||
* Notification Method Base Constructor
|
||||
*
|
||||
*
|
||||
* @param \phpbb\user_loader $user_loader
|
||||
* @param \phpbb\db\driver\driver_interface $db
|
||||
* @param \phpbb\cache\driver\driver_interface $cache
|
||||
@ -85,7 +85,7 @@ abstract class base implements \phpbb\notification\method\method_interface
|
||||
|
||||
/**
|
||||
* Set notification manager (required)
|
||||
*
|
||||
*
|
||||
* @param \phpbb\notification\manager $notification_manager
|
||||
*/
|
||||
public function set_notification_manager(\phpbb\notification\manager $notification_manager)
|
||||
|
@ -14,7 +14,6 @@
|
||||
|
||||
namespace phpbb\template\twig\node;
|
||||
|
||||
|
||||
class definenode extends \Twig_Node
|
||||
{
|
||||
public function __construct($capture, \Twig_NodeInterface $name, \Twig_NodeInterface $value, $lineno, $tag = null)
|
||||
|
@ -13,7 +13,6 @@
|
||||
|
||||
namespace phpbb\template\twig\node;
|
||||
|
||||
|
||||
class event extends \Twig_Node
|
||||
{
|
||||
/**
|
||||
|
@ -13,7 +13,6 @@
|
||||
|
||||
namespace phpbb\template\twig\node\expression\binary;
|
||||
|
||||
|
||||
class equalequal extends \Twig_Node_Expression_Binary
|
||||
{
|
||||
public function operator(\Twig_Compiler $compiler)
|
||||
|
@ -13,7 +13,6 @@
|
||||
|
||||
namespace phpbb\template\twig\node\expression\binary;
|
||||
|
||||
|
||||
class notequalequal extends \Twig_Node_Expression_Binary
|
||||
{
|
||||
public function operator(\Twig_Compiler $compiler)
|
||||
|
@ -13,7 +13,6 @@
|
||||
|
||||
namespace phpbb\template\twig\node;
|
||||
|
||||
|
||||
class includenode extends \Twig_Node_Include
|
||||
{
|
||||
/**
|
||||
|
@ -14,7 +14,6 @@
|
||||
|
||||
namespace phpbb\template\twig\node;
|
||||
|
||||
|
||||
class includephp extends \Twig_Node
|
||||
{
|
||||
/** @var \Twig_Environment */
|
||||
|
@ -13,7 +13,6 @@
|
||||
|
||||
namespace phpbb\template\twig\node;
|
||||
|
||||
|
||||
class php extends \Twig_Node
|
||||
{
|
||||
/** @var \Twig_Environment */
|
||||
|
@ -14,7 +14,6 @@
|
||||
|
||||
namespace phpbb\template\twig\tokenparser;
|
||||
|
||||
|
||||
class defineparser extends \Twig_TokenParser
|
||||
{
|
||||
/**
|
||||
|
@ -13,7 +13,6 @@
|
||||
|
||||
namespace phpbb\template\twig\tokenparser;
|
||||
|
||||
|
||||
class event extends \Twig_TokenParser
|
||||
{
|
||||
/**
|
||||
|
@ -13,7 +13,6 @@
|
||||
|
||||
namespace phpbb\template\twig\tokenparser;
|
||||
|
||||
|
||||
class includejs extends \Twig_TokenParser
|
||||
{
|
||||
/**
|
||||
|
@ -14,7 +14,6 @@
|
||||
|
||||
namespace phpbb\template\twig\tokenparser;
|
||||
|
||||
|
||||
class includeparser extends \Twig_TokenParser_Include
|
||||
{
|
||||
/**
|
||||
|
@ -14,7 +14,6 @@
|
||||
|
||||
namespace phpbb\template\twig\tokenparser;
|
||||
|
||||
|
||||
class includephp extends \Twig_TokenParser
|
||||
{
|
||||
/**
|
||||
|
@ -13,7 +13,6 @@
|
||||
|
||||
namespace phpbb\template\twig\tokenparser;
|
||||
|
||||
|
||||
class php extends \Twig_TokenParser
|
||||
{
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user