[phpcs] Add missing rules

- Do not add spaces after opening or before closing parenthesis

  // Wrong
  if( !is_null($var) ) {
    ...
  }

  // Right
  if(!is_null($var)) {
    ...
  }

- Add space after closing parenthesis

  // Wrong
  if(true){
    ...
  }

  // Right
  if(true) {
    ...
  }

- Add body into new line
- Close body in new line

  // Wrong
  if(true) { ... }

  // Right
  if(true) {
    ...
  }

Notice: Spaces after keywords are not detected:

  // Wrong (not detected)
  // -> space after 'if' and missing space after 'else'
  if (true) {
    ...
  } else{
    ...
  }

  // Right
  if(true) {
    ...
  } else {
    ...
  }
This commit is contained in:
logmanoriginal 2017-07-29 19:28:00 +02:00
parent 38b56bf23a
commit a4b9611e66
128 changed files with 692 additions and 694 deletions

View file

@ -13,8 +13,7 @@ class ABCTabsBridge extends BridgeAbstract {
$table = $html->find('table#myTable', 0)->children(1); $table = $html->find('table#myTable', 0)->children(1);
foreach ($table->find('tr') as $tab) foreach ($table->find('tr') as $tab) {
{
$item = array(); $item = array();
$item['author'] = $tab->find('td', 1)->plaintext $item['author'] = $tab->find('td', 1)->plaintext
. ' - ' . ' - '

View file

@ -71,8 +71,7 @@ class AllocineFRBridge extends BridgeAbstract {
$content = trim($element->innertext); $content = trim($element->innertext);
$figCaption = strpos($content, $category); $figCaption = strpos($content, $category);
if($figCaption !== false) if($figCaption !== false) {
{
$content = str_replace('src="/', 'src="' . static::URI, $content); $content = str_replace('src="/', 'src="' . static::URI, $content);
$content = str_replace('href="/', 'href="' . static::URI, $content); $content = str_replace('href="/', 'href="' . static::URI, $content);
$content = str_replace('src=\'/', 'src=\'' . static::URI, $content); $content = str_replace('src=\'/', 'src=\'' . static::URI, $content);

View file

@ -89,12 +89,10 @@ class FacebookBridge extends BridgeAbstract {
$html = null; $html = null;
//Handle captcha response sent by the viewer //Handle captcha response sent by the viewer
if (isset($_POST['captcha_response'])) if (isset($_POST['captcha_response'])) {
{
if (session_status() == PHP_SESSION_NONE) if (session_status() == PHP_SESSION_NONE)
session_start(); session_start();
if (isset($_SESSION['captcha_fields'], $_SESSION['captcha_action'])) if (isset($_SESSION['captcha_fields'], $_SESSION['captcha_action'])) {
{
$captcha_action = $_SESSION['captcha_action']; $captcha_action = $_SESSION['captcha_action'];
$captcha_fields = $_SESSION['captcha_fields']; $captcha_fields = $_SESSION['captcha_fields'];
$captcha_fields['captcha_response'] = preg_replace("/[^a-zA-Z0-9]+/", "", $_POST['captcha_response']); $captcha_fields['captcha_response'] = preg_replace("/[^a-zA-Z0-9]+/", "", $_POST['captcha_response']);
@ -145,8 +143,7 @@ class FacebookBridge extends BridgeAbstract {
//Handle captcha form? //Handle captcha form?
$captcha = $html->find('div.captcha_interstitial', 0); $captcha = $html->find('div.captcha_interstitial', 0);
if (!is_null($captcha)) if (!is_null($captcha)) {
{
//Save form for submitting after getting captcha response //Save form for submitting after getting captcha response
if (session_status() == PHP_SESSION_NONE) if (session_status() == PHP_SESSION_NONE)
session_start(); session_start();

View file

@ -36,8 +36,7 @@ class GithubSearchBridge extends BridgeAbstract {
if (count($element->find('p')) == 2) { if (count($element->find('p')) == 2) {
$content = $element->find('p', 0)->innertext; $content = $element->find('p', 0)->innertext;
} } else{
else{
$content = ''; $content = '';
} }
$item['content'] = $content; $item['content'] = $content;

View file

@ -64,8 +64,7 @@ class KATBridge extends BridgeAbstract {
'torrents-search.php?search=' . 'torrents-search.php?search=' .
rawurlencode($keywords) rawurlencode($keywords)
) or returnServerError('Could not request KAT.'); ) or returnServerError('Could not request KAT.');
} } else {
else {
$html = getSimpleHTMLDOM( $html = getSimpleHTMLDOM(
self::URI . self::URI .
'torrents-search.php?search=' . 'torrents-search.php?search=' .

View file

@ -185,15 +185,11 @@ try {
die; die;
} }
} } catch(HttpException $e) {
catch(HttpException $e){
header('HTTP/1.1 ' . $e->getCode() . ' ' . Http::getMessageForCode($e->getCode())); header('HTTP/1.1 ' . $e->getCode() . ' ' . Http::getMessageForCode($e->getCode()));
header('Content-Type: text/plain'); header('Content-Type: text/plain');
die($e->getMessage()); die($e->getMessage());
} } catch(\Exception $e) {
catch(\Exception $e){
die($e->getMessage()); die($e->getMessage());
} }

View file

@ -42,8 +42,17 @@
<rule ref="PEAR.NamingConventions.ValidClassName"/> <rule ref="PEAR.NamingConventions.ValidClassName"/>
<!-- Use 'elseif' instead of 'else if' --> <!-- Use 'elseif' instead of 'else if' -->
<rule ref="PSR2.ControlStructures.ElseIfDeclaration"/> <rule ref="PSR2.ControlStructures.ElseIfDeclaration"/>
<!-- Do not add spaces after opening or before closing bracket -->
<rule ref="PSR2.ControlStructures.ControlStructureSpacing"/>
<!-- Add a new line at the end of a file --> <!-- Add a new line at the end of a file -->
<rule ref="PSR2.Files.EndFileNewline"/> <rule ref="PSR2.Files.EndFileNewline"/>
<!-- Add space after closing parenthesis -->
<!-- Add body into new line -->
<!-- Close body in new line -->
<rule ref="Squiz.ControlStructures.ControlSignature">
<!-- No space after keyword (before opening parenthesis) -->
<exclude name="Squiz.ControlStructures.ControlSignature.SpaceAfterKeyword"/>
</rule>
<!-- When declaring a function: --> <!-- When declaring a function: -->
<!-- Do not add a space before a comma --> <!-- Do not add a space before a comma -->
<!-- Add a space after a comma --> <!-- Add a space after a comma -->