1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-05-07 16:15:22 +02:00

Merge pull request from Nicofuma/ticket/12721

[ticket/12721] Improve the code sniffer: simple rules

* Nicofuma/ticket/12721:
  [ticket/12721] Update rules descriptions
  [ticket/12721] Add Generic.NamingConventions.ConstructorName in strict
  [ticket/12721] Add Squiz.Functions.LowercaseFunctionKeywords in legacy
  [ticket/12721] Add Squiz.ControlStructures.ForLoopDeclaration in legacy
  [ticket/12721] Add Squiz.ControlStructures.ForEachLoopDeclaration
  [ticket/12721] Add Squiz.ControlStructures.ElseIfDeclaration in legacy
  [ticket/12721] Add Generic.Functions.OpeningFunctionBraceBsdAllman
  [ticket/12721] Add Squiz.Arrays.ArrayBracketSpacing in the legacy ruleset
  [ticket/12721] Add Generic.Files.LowercasedFilename in the legacy ruleset
This commit is contained in:
Andreas Fischer 2014-06-17 00:42:39 +02:00
commit 89af115071
15 changed files with 45 additions and 17 deletions

@ -20,6 +20,13 @@
<!-- Call-time pass-by-reference MUST not be used. -->
<rule ref="Generic.Functions.CallTimePassByReference.NotAllowed" />
<!-- Filenames MUST be lowercase. -->
<rule ref="Generic.Files.LowercasedFilename" />
<!-- The function brace MUST be on the line following the function declaration
and MUST be indented to the same column as the start of the function declaration. -->
<rule ref="Generic.Functions.OpeningFunctionBraceBsdAllman" />
<!-- There MUST be exactly one space after a cast. -->
<rule ref="Generic.Formatting.SpaceAfterCast" />
@ -35,6 +42,20 @@
<!-- Each file MUST end with exactly one newline character -->
<rule ref="PSR2.Files.EndFileNewline" />
<!-- When referencing arrays there MUST NOT be any whitespace around the opening bracket
or before the closing bracket. -->
<rule ref="Squiz.Arrays.ArrayBracketSpacing" />
<!-- The "else if" statement MUST be written with a space between the words else and if. -->
<rule ref="Squiz.ControlStructures.ElseIfDeclaration" />
<!-- There MUST be a space between each element of a foreach loop. -->
<rule ref="Squiz.ControlStructures.ForEachLoopDeclaration" />
<!-- In a for loop declaration, there MUST be no space inside the brackets
and there MUST be 0 spaces before and 1 space after semicolons. -->
<rule ref="Squiz.ControlStructures.ForLoopDeclaration" />
<!-- In the argument list, there MUST NOT be a space before each comma,
and there MUST be one space after each comma. -->
<rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing">
@ -44,6 +65,9 @@
</rule>
<rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing.SpacingAfterHint" />
<!-- All built-in PHP functions MUST be called lowercased. -->
<rule ref="Squiz.Functions.LowercaseFunctionKeywords" />
<!-- The eval() function MUST NOT be used. -->
<rule ref="Squiz.PHP.Eval" />

@ -22,6 +22,9 @@
<!-- PHP keywords MUST be in lower case. -->
<rule ref="Generic.PHP.LowerCaseKeyword" />
<!-- Constructors MUST be called __construct() instead of after the class. -->
<rule ref="Generic.NamingConventions.ConstructorName" />
<!-- Classes etc. MUST be namespaced -->
<rule ref="PSR1.Classes.ClassDeclaration.MissingNamespace" />

@ -527,7 +527,7 @@ class acp_extensions
$version_helper = new \phpbb\version_helper($this->cache, $this->config, $this->user);
$version_helper->set_current_version($meta['version']);
$version_helper->set_file_location($version_check ['host'], $version_check ['directory'], $version_check ['filename']);
$version_helper->set_file_location($version_check['host'], $version_check['directory'], $version_check['filename']);
$version_helper->force_stability($this->config['extension_force_unstable'] ? 'unstable' : null);
return $updates = $version_helper->get_suggested_updates($force_update, $force_cache);

@ -2297,7 +2297,7 @@ function convert_bbcode($message, $convert_size = true, $extended_bbcodes = fals
$message = preg_replace('#\[size=([0-9]+)\](.*?)\[/size\]#i', '[size=\1]\2[/size]', $message);
$message = preg_replace('#\[size=[0-9]{2,}\](.*?)\[/size\]#i', '[size=29]\1[/size]', $message);
for ($i = sizeof($size); $i; )
for ($i = sizeof($size); $i;)
{
$i--;
$message = str_replace('[size=' . $i . ']', '[size=' . $size[$i] . ']', $message);

@ -496,11 +496,11 @@ function mcp_move_topic($topic_ids)
{
$topics_moved++;
}
elseif ($topic_info['topic_visibility'] == ITEM_UNAPPROVED || $topic_info['topic_visibility'] == ITEM_REAPPROVE)
else if ($topic_info['topic_visibility'] == ITEM_UNAPPROVED || $topic_info['topic_visibility'] == ITEM_REAPPROVE)
{
$topics_moved_unapproved++;
}
elseif ($topic_info['topic_visibility'] == ITEM_DELETED)
else if ($topic_info['topic_visibility'] == ITEM_DELETED)
{
$topics_moved_softdeleted++;
}

@ -489,7 +489,7 @@ function close_report($report_id_list, $mode, $action, $pm = false)
{
$redirect = request_var('redirect', build_url(array('mode', 'r', 'quickmod')) . '&amp;mode=reports');
}
elseif ($action == 'delete' && strpos($user->data['session_page'], 'mode=pm_report_details') !== false)
else if ($action == 'delete' && strpos($user->data['session_page'], 'mode=pm_report_details') !== false)
{
$redirect = request_var('redirect', build_url(array('mode', 'r', 'quickmod')) . '&amp;mode=pm_reports');
}

@ -53,7 +53,7 @@ class provider_collection extends \phpbb\di\service_collection
return $this->offsetGet('auth.provider.' . basename(trim($this->config['auth_method'])));
}
// Revert to db auth provider if selected method does not exist
elseif ($this->offsetExists('auth.provider.db'))
else if ($this->offsetExists('auth.provider.db'))
{
return $this->offsetGet('auth.provider.db');
}

@ -72,7 +72,7 @@ class upload extends \phpbb\avatar\driver\driver
{
$file = $upload->form_upload('avatar_upload_file');
}
elseif (!empty($this->config['allow_avatar_remote_upload']) && !empty($url))
else if (!empty($this->config['allow_avatar_remote_upload']) && !empty($url))
{
if (!preg_match('#^(http|https|ftp)://#i', $url))
{

@ -224,7 +224,7 @@ class file extends \phpbb\cache\driver\base
{
$this->remove_dir($fileInfo->getPathname());
}
elseif (strpos($filename, 'container_') === 0 ||
else if (strpos($filename, 'container_') === 0 ||
strpos($filename, 'url_matcher') === 0 ||
strpos($filename, 'sql_') === 0 ||
strpos($filename, 'data_') === 0)

@ -60,7 +60,7 @@ class get extends command
{
$output->write($this->config[$key]);
}
elseif (isset($this->config[$key]))
else if (isset($this->config[$key]))
{
$output->writeln($this->config[$key]);
}

@ -319,10 +319,10 @@ class mssqlnative extends \phpbb\db\driver\mssql_base
{
foreach ($errors as $error)
{
$error_message .= "SQLSTATE: " . $error[ 'SQLSTATE'] . "\n";
$error_message .= "code: " . $error[ 'code'] . "\n";
$error_message .= "SQLSTATE: " . $error['SQLSTATE'] . "\n";
$error_message .= "code: " . $error['code'] . "\n";
$code = $error['code'];
$error_message .= "message: " . $error[ 'message'] . "\n";
$error_message .= "message: " . $error['message'] . "\n";
}
$this->last_error_result = $error_message;
$error = $this->last_error_result;

@ -39,7 +39,8 @@ class recursive_event_filter_iterator extends \RecursiveFilterIterator
*
* @return recursive_event_filter_iterator
*/
public function getChildren() {
public function getChildren()
{
return new self($this->getInnerIterator()->getChildren(), $this->root_path);
}

@ -60,7 +60,7 @@ class helper
$data[$type] .= ($data[$type] !== '$') ? '\\' : '';
$data[$type] .= str_replace('$', '', $value);
}
elseif ($type == 'settings')
else if ($type == 'settings')
{
$data[$type] .= ($data[$type] !== '$') ? '$' : '';
$data[$type] .= $value;

@ -263,12 +263,12 @@ class fulltext_postgres extends \phpbb\search\base
$this->search_query .= $word . ' ';
$this->tsearch_query .= '&' . substr($word, 1) . ' ';
}
elseif (strpos($word, '-') === 0)
else if (strpos($word, '-') === 0)
{
$this->search_query .= $word . ' ';
$this->tsearch_query .= '&!' . substr($word, 1) . ' ';
}
elseif (strpos($word, '|') === 0)
else if (strpos($word, '|') === 0)
{
$this->search_query .= $word . ' ';
$this->tsearch_query .= '|' . substr($word, 1) . ' ';

@ -1256,7 +1256,7 @@ $s_characters .= '<option value="0">0</option>';
$s_characters .= '<option value="25">25</option>';
$s_characters .= '<option value="50">50</option>';
for ($i = 100; $i <= 1000 ; $i += 100)
for ($i = 100; $i <= 1000; $i += 100)
{
$selected = ($i == 300) ? ' selected="selected"' : '';
$s_characters .= '<option value="' . $i . '"' . $selected . '>' . $i . '</option>';