From 1aec0d29fd573950d5fbfd224997aac546df9b05 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 15 Jun 2014 19:39:52 +0200 Subject: [PATCH 1/9] [ticket/12721] Add Generic.Files.LowercasedFilename in the legacy ruleset PHPBB3-12721 --- build/code_sniffer/ruleset-php-legacy.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build/code_sniffer/ruleset-php-legacy.xml b/build/code_sniffer/ruleset-php-legacy.xml index 272c4840b6..fe42d25431 100644 --- a/build/code_sniffer/ruleset-php-legacy.xml +++ b/build/code_sniffer/ruleset-php-legacy.xml @@ -20,6 +20,9 @@ + + + From 34a4ba36cd554ebd3cab1bdbb422d97a9429bd72 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 15 Jun 2014 20:52:51 +0200 Subject: [PATCH 2/9] [ticket/12721] Add Squiz.Arrays.ArrayBracketSpacing in the legacy ruleset PHPBB3-12721 --- build/code_sniffer/ruleset-php-legacy.xml | 3 +++ phpBB/includes/acp/acp_extensions.php | 2 +- phpBB/phpbb/db/driver/mssqlnative.php | 6 +++--- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/build/code_sniffer/ruleset-php-legacy.xml b/build/code_sniffer/ruleset-php-legacy.xml index fe42d25431..175a993f48 100644 --- a/build/code_sniffer/ruleset-php-legacy.xml +++ b/build/code_sniffer/ruleset-php-legacy.xml @@ -38,6 +38,9 @@ + + + diff --git a/phpBB/includes/acp/acp_extensions.php b/phpBB/includes/acp/acp_extensions.php index 3d3cfb7f16..b2a6820461 100644 --- a/phpBB/includes/acp/acp_extensions.php +++ b/phpBB/includes/acp/acp_extensions.php @@ -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); diff --git a/phpBB/phpbb/db/driver/mssqlnative.php b/phpBB/phpbb/db/driver/mssqlnative.php index 9639bfa988..a7f93c8feb 100644 --- a/phpBB/phpbb/db/driver/mssqlnative.php +++ b/phpBB/phpbb/db/driver/mssqlnative.php @@ -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; From 06bf864c41eeb8e0232f124f5a0539cb4f788439 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 15 Jun 2014 21:07:24 +0200 Subject: [PATCH 3/9] [ticket/12721] Add Generic.Functions.OpeningFunctionBraceBsdAllman PHPBB3-12721 --- build/code_sniffer/ruleset-php-legacy.xml | 4 ++++ phpBB/phpbb/event/recursive_event_filter_iterator.php | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/build/code_sniffer/ruleset-php-legacy.xml b/build/code_sniffer/ruleset-php-legacy.xml index 175a993f48..71741ce190 100644 --- a/build/code_sniffer/ruleset-php-legacy.xml +++ b/build/code_sniffer/ruleset-php-legacy.xml @@ -23,6 +23,10 @@ + + + diff --git a/phpBB/phpbb/event/recursive_event_filter_iterator.php b/phpBB/phpbb/event/recursive_event_filter_iterator.php index f65feff448..64e2e56f6a 100644 --- a/phpBB/phpbb/event/recursive_event_filter_iterator.php +++ b/phpBB/phpbb/event/recursive_event_filter_iterator.php @@ -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); } From 09fc008e62453352cb34f4391acda310ea8b41c7 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 15 Jun 2014 21:34:02 +0200 Subject: [PATCH 4/9] [ticket/12721] Add Squiz.ControlStructures.ElseIfDeclaration in legacy PHPBB3-12721 --- build/code_sniffer/ruleset-php-legacy.xml | 3 +++ phpBB/includes/mcp/mcp_main.php | 4 ++-- phpBB/includes/mcp/mcp_reports.php | 2 +- phpBB/includes/sphinxapi.php | 1 + phpBB/phpbb/auth/provider_collection.php | 2 +- phpBB/phpbb/avatar/driver/upload.php | 2 +- phpBB/phpbb/cache/driver/file.php | 2 +- phpBB/phpbb/console/command/config/get.php | 2 +- phpBB/phpbb/passwords/helper.php | 2 +- phpBB/phpbb/search/fulltext_postgres.php | 4 ++-- 10 files changed, 14 insertions(+), 10 deletions(-) diff --git a/build/code_sniffer/ruleset-php-legacy.xml b/build/code_sniffer/ruleset-php-legacy.xml index 71741ce190..0f95cee957 100644 --- a/build/code_sniffer/ruleset-php-legacy.xml +++ b/build/code_sniffer/ruleset-php-legacy.xml @@ -45,6 +45,9 @@ + + + diff --git a/phpBB/includes/mcp/mcp_main.php b/phpBB/includes/mcp/mcp_main.php index 9a2b4d2a4e..84097327bd 100644 --- a/phpBB/includes/mcp/mcp_main.php +++ b/phpBB/includes/mcp/mcp_main.php @@ -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++; } diff --git a/phpBB/includes/mcp/mcp_reports.php b/phpBB/includes/mcp/mcp_reports.php index f045fd018f..b0148356ce 100644 --- a/phpBB/includes/mcp/mcp_reports.php +++ b/phpBB/includes/mcp/mcp_reports.php @@ -489,7 +489,7 @@ function close_report($report_id_list, $mode, $action, $pm = false) { $redirect = request_var('redirect', build_url(array('mode', 'r', 'quickmod')) . '&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')) . '&mode=pm_reports'); } diff --git a/phpBB/includes/sphinxapi.php b/phpBB/includes/sphinxapi.php index 6c3b66710c..be68de6fc2 100644 --- a/phpBB/includes/sphinxapi.php +++ b/phpBB/includes/sphinxapi.php @@ -1,4 +1,5 @@ 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'); } diff --git a/phpBB/phpbb/avatar/driver/upload.php b/phpBB/phpbb/avatar/driver/upload.php index 7f77db5949..c43004f340 100644 --- a/phpBB/phpbb/avatar/driver/upload.php +++ b/phpBB/phpbb/avatar/driver/upload.php @@ -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)) { diff --git a/phpBB/phpbb/cache/driver/file.php b/phpBB/phpbb/cache/driver/file.php index 03b7b1ea82..b32af32d25 100644 --- a/phpBB/phpbb/cache/driver/file.php +++ b/phpBB/phpbb/cache/driver/file.php @@ -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) diff --git a/phpBB/phpbb/console/command/config/get.php b/phpBB/phpbb/console/command/config/get.php index 20164f0da1..ee8c65110e 100644 --- a/phpBB/phpbb/console/command/config/get.php +++ b/phpBB/phpbb/console/command/config/get.php @@ -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]); } diff --git a/phpBB/phpbb/passwords/helper.php b/phpBB/phpbb/passwords/helper.php index c6c5fb6d02..c2a49202cd 100644 --- a/phpBB/phpbb/passwords/helper.php +++ b/phpBB/phpbb/passwords/helper.php @@ -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; diff --git a/phpBB/phpbb/search/fulltext_postgres.php b/phpBB/phpbb/search/fulltext_postgres.php index 49d528c8ba..bdb5a86009 100644 --- a/phpBB/phpbb/search/fulltext_postgres.php +++ b/phpBB/phpbb/search/fulltext_postgres.php @@ -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) . ' '; From 99a2f2fdb4d3f617f09ca248bf526b7ec97ba7aa Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 15 Jun 2014 21:46:24 +0200 Subject: [PATCH 5/9] [ticket/12721] Add Squiz.ControlStructures.ForEachLoopDeclaration PHPBB3-12721 --- build/code_sniffer/ruleset-php-legacy.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build/code_sniffer/ruleset-php-legacy.xml b/build/code_sniffer/ruleset-php-legacy.xml index 0f95cee957..f060e8e14f 100644 --- a/build/code_sniffer/ruleset-php-legacy.xml +++ b/build/code_sniffer/ruleset-php-legacy.xml @@ -48,6 +48,9 @@ + + + From a94581e7cae2e7fac6f88b8718866f694e8b01f0 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 15 Jun 2014 21:52:25 +0200 Subject: [PATCH 6/9] [ticket/12721] Add Squiz.ControlStructures.ForLoopDeclaration in legacy PHPBB3-12721 --- build/code_sniffer/ruleset-php-legacy.xml | 3 +++ phpBB/includes/functions_convert.php | 2 +- phpBB/search.php | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/build/code_sniffer/ruleset-php-legacy.xml b/build/code_sniffer/ruleset-php-legacy.xml index f060e8e14f..3a1d849135 100644 --- a/build/code_sniffer/ruleset-php-legacy.xml +++ b/build/code_sniffer/ruleset-php-legacy.xml @@ -51,6 +51,9 @@ + + + diff --git a/phpBB/includes/functions_convert.php b/phpBB/includes/functions_convert.php index e8f8151d6f..9005c57c8a 100644 --- a/phpBB/includes/functions_convert.php +++ b/phpBB/includes/functions_convert.php @@ -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); diff --git a/phpBB/search.php b/phpBB/search.php index 91ea21909d..f1f02ac766 100644 --- a/phpBB/search.php +++ b/phpBB/search.php @@ -1256,7 +1256,7 @@ $s_characters .= ''; $s_characters .= ''; $s_characters .= ''; -for ($i = 100; $i <= 1000 ; $i += 100) +for ($i = 100; $i <= 1000; $i += 100) { $selected = ($i == 300) ? ' selected="selected"' : ''; $s_characters .= ''; From 13c03b6fcf47a1ce496521b70c2acf37fd9a51b9 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 15 Jun 2014 21:58:57 +0200 Subject: [PATCH 7/9] [ticket/12721] Add Squiz.Functions.LowercaseFunctionKeywords in legacy PHPBB3-12721 --- build/code_sniffer/ruleset-php-legacy.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build/code_sniffer/ruleset-php-legacy.xml b/build/code_sniffer/ruleset-php-legacy.xml index 3a1d849135..621942b38b 100644 --- a/build/code_sniffer/ruleset-php-legacy.xml +++ b/build/code_sniffer/ruleset-php-legacy.xml @@ -63,6 +63,9 @@ + + + From 6b52155a2aefc26036a0246fbefd9fe3dc3f2696 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 15 Jun 2014 23:25:41 +0200 Subject: [PATCH 8/9] [ticket/12721] Add Generic.NamingConventions.ConstructorName in strict PHPBB3-12721 --- build/code_sniffer/ruleset-php-strict.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build/code_sniffer/ruleset-php-strict.xml b/build/code_sniffer/ruleset-php-strict.xml index f2d5b86dd1..c722f7851c 100644 --- a/build/code_sniffer/ruleset-php-strict.xml +++ b/build/code_sniffer/ruleset-php-strict.xml @@ -22,6 +22,9 @@ + + + From afcca62784b51e34649f44905a27948bc3c8400c Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Mon, 16 Jun 2014 22:45:44 +0200 Subject: [PATCH 9/9] [ticket/12721] Update rules descriptions PHPBB3-12721 --- build/code_sniffer/ruleset-php-legacy.xml | 18 ++++++++++-------- phpBB/includes/sphinxapi.php | 1 - 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/build/code_sniffer/ruleset-php-legacy.xml b/build/code_sniffer/ruleset-php-legacy.xml index 621942b38b..b0110e8b12 100644 --- a/build/code_sniffer/ruleset-php-legacy.xml +++ b/build/code_sniffer/ruleset-php-legacy.xml @@ -20,11 +20,11 @@ - + - + @@ -42,16 +42,18 @@ - + - + - + - + + diff --git a/phpBB/includes/sphinxapi.php b/phpBB/includes/sphinxapi.php index be68de6fc2..6c3b66710c 100644 --- a/phpBB/includes/sphinxapi.php +++ b/phpBB/includes/sphinxapi.php @@ -1,5 +1,4 @@