diff --git a/build/code_sniffer/phpbb/Sniffs/ControlStructures/OpeningParenthesisSniff.php b/build/code_sniffer/phpbb/Sniffs/ControlStructures/OpeningParenthesisSniff.php
new file mode 100644
index 0000000000..349bccbb02
--- /dev/null
+++ b/build/code_sniffer/phpbb/Sniffs/ControlStructures/OpeningParenthesisSniff.php
@@ -0,0 +1,60 @@
+
+ * @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');
+ }
+ }
+}
diff --git a/build/code_sniffer/ruleset-php-legacy.xml b/build/code_sniffer/ruleset-php-legacy.xml
index b0110e8b12..c740c6080f 100644
--- a/build/code_sniffer/ruleset-php-legacy.xml
+++ b/build/code_sniffer/ruleset-php-legacy.xml
@@ -86,4 +86,7 @@
+
+
+
diff --git a/phpBB/includes/acp/acp_styles.php b/phpBB/includes/acp/acp_styles.php
index b652fd6587..de3ca5f787 100644
--- a/phpBB/includes/acp/acp_styles.php
+++ b/phpBB/includes/acp/acp_styles.php
@@ -1013,7 +1013,7 @@ class acp_styles
// Assign template variables
$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);
}
diff --git a/phpBB/includes/functions_convert.php b/phpBB/includes/functions_convert.php
index ad693f4019..0a25ae8c36 100644
--- a/phpBB/includes/functions_convert.php
+++ b/phpBB/includes/functions_convert.php
@@ -966,7 +966,7 @@ function get_remote_avatar_dim($src, $axis)
$protocol = (isset($url_info['scheme'])) ? $url_info['scheme'] : 'http';
if (empty($port))
{
- switch(strtolower($protocol))
+ switch (strtolower($protocol))
{
case 'ftp':
$port = 21;
diff --git a/phpBB/includes/ucp/ucp_notifications.php b/phpBB/includes/ucp/ucp_notifications.php
index b778ffdf12..6d0d4f06a6 100644
--- a/phpBB/includes/ucp/ucp_notifications.php
+++ b/phpBB/includes/ucp/ucp_notifications.php
@@ -55,11 +55,11 @@ class ucp_notifications
$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])))
{
@@ -183,13 +183,13 @@ class ucp_notifications
{
$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(
'GROUP_NAME' => $user->lang($group),
));
- foreach($subscription_types as $type => $data)
+ foreach ($subscription_types as $type => $data)
{
$template->assign_block_vars($block, array(
'TYPE' => $type,
@@ -200,7 +200,7 @@ class ucp_notifications
'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(
'METHOD' => $method_data['id'],
@@ -230,7 +230,7 @@ class ucp_notifications
{
$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(
'METHOD' => $method_data['id'],
diff --git a/phpBB/phpbb/cache/driver/memcache.php b/phpBB/phpbb/cache/driver/memcache.php
index 406ab11ddd..caa82fb0b1 100644
--- a/phpBB/phpbb/cache/driver/memcache.php
+++ b/phpBB/phpbb/cache/driver/memcache.php
@@ -50,7 +50,7 @@ class memcache extends \phpbb\cache\driver\memory
parent::__construct();
$this->memcache = new \Memcache;
- foreach(explode(',', PHPBB_ACM_MEMCACHE) as $u)
+ foreach (explode(',', PHPBB_ACM_MEMCACHE) as $u)
{
$parts = explode('/', $u);
$this->memcache->addServer(trim($parts[0]), trim($parts[1]));
diff --git a/phpBB/phpbb/db/extractor/mssql_extractor.php b/phpBB/phpbb/db/extractor/mssql_extractor.php
index d0aa78f1f5..fc30f4789d 100644
--- a/phpBB/phpbb/db/extractor/mssql_extractor.php
+++ b/phpBB/phpbb/db/extractor/mssql_extractor.php
@@ -184,7 +184,7 @@ class mssql_extractor extends base_extractor
{
$this->write_data_mssql($table_name);
}
- else if($this->db->get_sql_layer() === 'mssqlnative')
+ else if ($this->db->get_sql_layer() === 'mssqlnative')
{
$this->write_data_mssqlnative($table_name);
}
diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php
index a1bf0f8e88..1b02d98b82 100644
--- a/phpBB/phpbb/log/log.php
+++ b/phpBB/phpbb/log/log.php
@@ -535,7 +535,7 @@ class log implements \phpbb\log\log_interface
'ORDER_BY' => $sort_by,
);
- if($log_time)
+ if ($log_time)
{
$get_logs_sql_ary['WHERE'] = 'l.log_time >= ' . (int) $log_time . '
AND ' . $get_logs_sql_ary['WHERE'];
diff --git a/phpBB/phpbb/search/fulltext_sphinx.php b/phpBB/phpbb/search/fulltext_sphinx.php
index 082dddeb1a..937292fd38 100644
--- a/phpBB/phpbb/search/fulltext_sphinx.php
+++ b/phpBB/phpbb/search/fulltext_sphinx.php
@@ -147,7 +147,7 @@ class fulltext_sphinx
global $phpbb_container; // TODO inject into object
$this->db_tools = $phpbb_container->get('dbal.tools');
- if(!$this->config['fulltext_sphinx_id'])
+ if (!$this->config['fulltext_sphinx_id'])
{
$this->config->set('fulltext_sphinx_id', unique_id());
}
diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php
index faf5768edf..4a42d78b2b 100644
--- a/phpBB/viewtopic.php
+++ b/phpBB/viewtopic.php
@@ -590,7 +590,7 @@ $quickmod_array = array(
'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]))
{