mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 22:28:51 +00:00
Merge pull request #3694 from marc1706/ticket/13930
[ticket/13930] Check for correct spacing between keyword & parenthesis * marc1706/ticket/13930: [ticket/13930] Add missing spaces to code [ticket/13930] Use OpeningParenthesisSniff in legacy ruleset [ticket/13930] Remove not needed return statements [ticket/13930] Add missing spaces to code [ticket/13930] Check for correct spacing between keyword & parenthesis
This commit is contained in:
commit
c952622fa0
12 changed files with 82 additions and 19 deletions
|
@ -0,0 +1,60 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* This file is part of the phpBB Forum Software package.
|
||||||
|
*
|
||||||
|
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||||
|
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||||
|
*
|
||||||
|
* For full copyright and license information, please see
|
||||||
|
* the docs/CREDITS.txt file.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks that there is exactly one space between the keyword and the opening
|
||||||
|
* parenthesis of a control structures.
|
||||||
|
*/
|
||||||
|
class phpbb_Sniffs_ControlStructures_OpeningParenthesisSniff implements PHP_CodeSniffer_Sniff
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Registers the tokens that this sniff wants to listen for.
|
||||||
|
*/
|
||||||
|
public function register()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
T_IF,
|
||||||
|
T_FOREACH,
|
||||||
|
T_WHILE,
|
||||||
|
T_FOR,
|
||||||
|
T_SWITCH,
|
||||||
|
T_ELSEIF,
|
||||||
|
T_CATCH,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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();
|
||||||
|
|
||||||
|
if ($tokens[$stackPtr + 1]['content'] === '(')
|
||||||
|
{
|
||||||
|
$error = 'There should be exactly one space between the keyword and opening parenthesis';
|
||||||
|
$phpcsFile->addError($error, $stackPtr, 'NoSpaceBeforeOpeningParenthesis');
|
||||||
|
}
|
||||||
|
else if ($tokens[$stackPtr + 1]['content'] !== ' ')
|
||||||
|
{
|
||||||
|
$error = 'There should be exactly one space between the keyword and opening parenthesis';
|
||||||
|
$phpcsFile->addError($error, $stackPtr, 'IncorrectSpaceBeforeOpeningParenthesis');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -86,4 +86,7 @@
|
||||||
<!-- The ?> closing tag MUST be omitted from files containing only PHP. -->
|
<!-- The ?> closing tag MUST be omitted from files containing only PHP. -->
|
||||||
<rule ref="Zend.Files.ClosingTag" />
|
<rule ref="Zend.Files.ClosingTag" />
|
||||||
|
|
||||||
|
<!-- There MUST be one space between control structure and opening parenthesis -->
|
||||||
|
<rule ref="./phpbb/Sniffs/ControlStructures/OpeningParenthesisSniff.php" />
|
||||||
|
|
||||||
</ruleset>
|
</ruleset>
|
||||||
|
|
|
@ -1558,7 +1558,7 @@ class mssql_extractor extends base_extractor
|
||||||
{
|
{
|
||||||
$this->write_data_mssql($table_name);
|
$this->write_data_mssql($table_name);
|
||||||
}
|
}
|
||||||
else if($db->get_sql_layer() === 'mssqlnative')
|
else if ($db->get_sql_layer() === 'mssqlnative')
|
||||||
{
|
{
|
||||||
$this->write_data_mssqlnative($table_name);
|
$this->write_data_mssqlnative($table_name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@ class acp_extensions
|
||||||
{
|
{
|
||||||
$md_manager->get_metadata('all');
|
$md_manager->get_metadata('all');
|
||||||
}
|
}
|
||||||
catch(\phpbb\extension\exception $e)
|
catch (\phpbb\extension\exception $e)
|
||||||
{
|
{
|
||||||
trigger_error($e, E_USER_WARNING);
|
trigger_error($e, E_USER_WARNING);
|
||||||
}
|
}
|
||||||
|
@ -352,7 +352,7 @@ class acp_extensions
|
||||||
$enabled_extension_meta_data[$name]['S_VERSIONCHECK'] = true;
|
$enabled_extension_meta_data[$name]['S_VERSIONCHECK'] = true;
|
||||||
$enabled_extension_meta_data[$name]['U_VERSIONCHECK_FORCE'] = $this->u_action . '&action=details&versioncheck_force=1&ext_name=' . urlencode($md_manager->get_metadata('name'));
|
$enabled_extension_meta_data[$name]['U_VERSIONCHECK_FORCE'] = $this->u_action . '&action=details&versioncheck_force=1&ext_name=' . urlencode($md_manager->get_metadata('name'));
|
||||||
}
|
}
|
||||||
catch(\phpbb\extension\exception $e)
|
catch (\phpbb\extension\exception $e)
|
||||||
{
|
{
|
||||||
$this->template->assign_block_vars('disabled', array(
|
$this->template->assign_block_vars('disabled', array(
|
||||||
'META_DISPLAY_NAME' => $this->user->lang('EXTENSION_INVALID_LIST', $name, $e),
|
'META_DISPLAY_NAME' => $this->user->lang('EXTENSION_INVALID_LIST', $name, $e),
|
||||||
|
@ -408,7 +408,7 @@ class acp_extensions
|
||||||
$disabled_extension_meta_data[$name]['S_VERSIONCHECK'] = true;
|
$disabled_extension_meta_data[$name]['S_VERSIONCHECK'] = true;
|
||||||
$disabled_extension_meta_data[$name]['U_VERSIONCHECK_FORCE'] = $this->u_action . '&action=details&versioncheck_force=1&ext_name=' . urlencode($md_manager->get_metadata('name'));
|
$disabled_extension_meta_data[$name]['U_VERSIONCHECK_FORCE'] = $this->u_action . '&action=details&versioncheck_force=1&ext_name=' . urlencode($md_manager->get_metadata('name'));
|
||||||
}
|
}
|
||||||
catch(\phpbb\extension\exception $e)
|
catch (\phpbb\extension\exception $e)
|
||||||
{
|
{
|
||||||
$this->template->assign_block_vars('disabled', array(
|
$this->template->assign_block_vars('disabled', array(
|
||||||
'META_DISPLAY_NAME' => $this->user->lang('EXTENSION_INVALID_LIST', $name, $e),
|
'META_DISPLAY_NAME' => $this->user->lang('EXTENSION_INVALID_LIST', $name, $e),
|
||||||
|
@ -467,7 +467,7 @@ class acp_extensions
|
||||||
$available_extension_meta_data[$name]['S_VERSIONCHECK'] = true;
|
$available_extension_meta_data[$name]['S_VERSIONCHECK'] = true;
|
||||||
$available_extension_meta_data[$name]['U_VERSIONCHECK_FORCE'] = $this->u_action . '&action=details&versioncheck_force=1&ext_name=' . urlencode($md_manager->get_metadata('name'));
|
$available_extension_meta_data[$name]['U_VERSIONCHECK_FORCE'] = $this->u_action . '&action=details&versioncheck_force=1&ext_name=' . urlencode($md_manager->get_metadata('name'));
|
||||||
}
|
}
|
||||||
catch(\phpbb\extension\exception $e)
|
catch (\phpbb\extension\exception $e)
|
||||||
{
|
{
|
||||||
$this->template->assign_block_vars('disabled', array(
|
$this->template->assign_block_vars('disabled', array(
|
||||||
'META_DISPLAY_NAME' => $this->user->lang('EXTENSION_INVALID_LIST', $name, $e),
|
'META_DISPLAY_NAME' => $this->user->lang('EXTENSION_INVALID_LIST', $name, $e),
|
||||||
|
|
|
@ -995,7 +995,7 @@ class acp_styles
|
||||||
|
|
||||||
// Assign template variables
|
// Assign template variables
|
||||||
$this->template->assign_block_vars('styles_list', $row);
|
$this->template->assign_block_vars('styles_list', $row);
|
||||||
foreach($actions as $action)
|
foreach ($actions as $action)
|
||||||
{
|
{
|
||||||
$this->template->assign_block_vars('styles_list.actions', $action);
|
$this->template->assign_block_vars('styles_list.actions', $action);
|
||||||
}
|
}
|
||||||
|
|
|
@ -966,7 +966,7 @@ function get_remote_avatar_dim($src, $axis)
|
||||||
$protocol = (isset($url_info['scheme'])) ? $url_info['scheme'] : 'http';
|
$protocol = (isset($url_info['scheme'])) ? $url_info['scheme'] : 'http';
|
||||||
if (empty($port))
|
if (empty($port))
|
||||||
{
|
{
|
||||||
switch(strtolower($protocol))
|
switch (strtolower($protocol))
|
||||||
{
|
{
|
||||||
case 'ftp':
|
case 'ftp':
|
||||||
$port = 21;
|
$port = 21;
|
||||||
|
|
|
@ -52,11 +52,11 @@ class ucp_notifications
|
||||||
|
|
||||||
$notification_methods = $phpbb_notifications->get_subscription_methods();
|
$notification_methods = $phpbb_notifications->get_subscription_methods();
|
||||||
|
|
||||||
foreach($phpbb_notifications->get_subscription_types() as $group => $subscription_types)
|
foreach ($phpbb_notifications->get_subscription_types() as $group => $subscription_types)
|
||||||
{
|
{
|
||||||
foreach($subscription_types as $type => $data)
|
foreach ($subscription_types as $type => $data)
|
||||||
{
|
{
|
||||||
foreach($notification_methods as $method => $method_data)
|
foreach ($notification_methods as $method => $method_data)
|
||||||
{
|
{
|
||||||
if ($request->is_set_post(str_replace('.', '_', $type . '_' . $method_data['id'])) && (!isset($subscriptions[$type]) || !in_array($method_data['id'], $subscriptions[$type])))
|
if ($request->is_set_post(str_replace('.', '_', $type . '_' . $method_data['id'])) && (!isset($subscriptions[$type]) || !in_array($method_data['id'], $subscriptions[$type])))
|
||||||
{
|
{
|
||||||
|
@ -180,13 +180,13 @@ class ucp_notifications
|
||||||
{
|
{
|
||||||
$notification_methods = $phpbb_notifications->get_subscription_methods();
|
$notification_methods = $phpbb_notifications->get_subscription_methods();
|
||||||
|
|
||||||
foreach($phpbb_notifications->get_subscription_types() as $group => $subscription_types)
|
foreach ($phpbb_notifications->get_subscription_types() as $group => $subscription_types)
|
||||||
{
|
{
|
||||||
$template->assign_block_vars($block, array(
|
$template->assign_block_vars($block, array(
|
||||||
'GROUP_NAME' => $user->lang($group),
|
'GROUP_NAME' => $user->lang($group),
|
||||||
));
|
));
|
||||||
|
|
||||||
foreach($subscription_types as $type => $data)
|
foreach ($subscription_types as $type => $data)
|
||||||
{
|
{
|
||||||
$template->assign_block_vars($block, array(
|
$template->assign_block_vars($block, array(
|
||||||
'TYPE' => $type,
|
'TYPE' => $type,
|
||||||
|
@ -197,7 +197,7 @@ class ucp_notifications
|
||||||
'SUBSCRIBED' => (isset($subscriptions[$type])) ? true : false,
|
'SUBSCRIBED' => (isset($subscriptions[$type])) ? true : false,
|
||||||
));
|
));
|
||||||
|
|
||||||
foreach($notification_methods as $method => $method_data)
|
foreach ($notification_methods as $method => $method_data)
|
||||||
{
|
{
|
||||||
$template->assign_block_vars($block . '.notification_methods', array(
|
$template->assign_block_vars($block . '.notification_methods', array(
|
||||||
'METHOD' => $method_data['id'],
|
'METHOD' => $method_data['id'],
|
||||||
|
@ -227,7 +227,7 @@ class ucp_notifications
|
||||||
{
|
{
|
||||||
$notification_methods = $phpbb_notifications->get_subscription_methods();
|
$notification_methods = $phpbb_notifications->get_subscription_methods();
|
||||||
|
|
||||||
foreach($notification_methods as $method => $method_data)
|
foreach ($notification_methods as $method => $method_data)
|
||||||
{
|
{
|
||||||
$template->assign_block_vars($block, array(
|
$template->assign_block_vars($block, array(
|
||||||
'METHOD' => $method_data['id'],
|
'METHOD' => $method_data['id'],
|
||||||
|
|
2
phpBB/phpbb/cache/driver/memcache.php
vendored
2
phpBB/phpbb/cache/driver/memcache.php
vendored
|
@ -50,7 +50,7 @@ class memcache extends \phpbb\cache\driver\memory
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
|
||||||
$this->memcache = new \Memcache;
|
$this->memcache = new \Memcache;
|
||||||
foreach(explode(',', PHPBB_ACM_MEMCACHE) as $u)
|
foreach (explode(',', PHPBB_ACM_MEMCACHE) as $u)
|
||||||
{
|
{
|
||||||
$parts = explode('/', $u);
|
$parts = explode('/', $u);
|
||||||
$this->memcache->addServer(trim($parts[0]), trim($parts[1]));
|
$this->memcache->addServer(trim($parts[0]), trim($parts[1]));
|
||||||
|
|
|
@ -350,7 +350,7 @@ class qa
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach($schemas as $table => $schema)
|
foreach ($schemas as $table => $schema)
|
||||||
{
|
{
|
||||||
if (!$db_tool->sql_table_exists($table))
|
if (!$db_tool->sql_table_exists($table))
|
||||||
{
|
{
|
||||||
|
|
|
@ -535,7 +535,7 @@ class log implements \phpbb\log\log_interface
|
||||||
'ORDER_BY' => $sort_by,
|
'ORDER_BY' => $sort_by,
|
||||||
);
|
);
|
||||||
|
|
||||||
if($log_time)
|
if ($log_time)
|
||||||
{
|
{
|
||||||
$get_logs_sql_ary['WHERE'] = 'l.log_time >= ' . (int) $log_time . '
|
$get_logs_sql_ary['WHERE'] = 'l.log_time >= ' . (int) $log_time . '
|
||||||
AND ' . $get_logs_sql_ary['WHERE'];
|
AND ' . $get_logs_sql_ary['WHERE'];
|
||||||
|
|
|
@ -146,7 +146,7 @@ class fulltext_sphinx
|
||||||
// Initialize \phpbb\db\tools object
|
// Initialize \phpbb\db\tools object
|
||||||
$this->db_tools = new \phpbb\db\tools($this->db);
|
$this->db_tools = new \phpbb\db\tools($this->db);
|
||||||
|
|
||||||
if(!$this->config['fulltext_sphinx_id'])
|
if (!$this->config['fulltext_sphinx_id'])
|
||||||
{
|
{
|
||||||
set_config('fulltext_sphinx_id', unique_id());
|
set_config('fulltext_sphinx_id', unique_id());
|
||||||
}
|
}
|
||||||
|
|
|
@ -588,7 +588,7 @@ $quickmod_array = array(
|
||||||
'topic_logs' => array('VIEW_TOPIC_LOGS', $auth->acl_get('m_', $forum_id)),
|
'topic_logs' => array('VIEW_TOPIC_LOGS', $auth->acl_get('m_', $forum_id)),
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach($quickmod_array as $option => $qm_ary)
|
foreach ($quickmod_array as $option => $qm_ary)
|
||||||
{
|
{
|
||||||
if (!empty($qm_ary[1]))
|
if (!empty($qm_ary[1]))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue