1
0
mirror of https://github.com/RSS-Bridge/rss-bridge.git synced 2025-08-06 08:37:30 +02:00

[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

@@ -24,7 +24,7 @@ class Bridge {
* @return Bridge object dedicated
*/
static public function create($nameBridge){
if(!preg_match('@^[A-Z][a-zA-Z0-9-]*$@', $nameBridge)){
if(!preg_match('@^[A-Z][a-zA-Z0-9-]*$@', $nameBridge)) {
$message = <<<EOD
'nameBridge' must start with one uppercase character followed or not by
alphanumeric or dash characters!
@@ -35,14 +35,14 @@ EOD;
$nameBridge = $nameBridge . 'Bridge';
$pathBridge = self::getDir() . $nameBridge . '.php';
if(!file_exists($pathBridge)){
if(!file_exists($pathBridge)) {
throw new \Exception('The bridge you looking for does not exist. It should be at path '
. $pathBridge);
}
require_once $pathBridge;
if(Bridge::isInstantiable($nameBridge)){
if(Bridge::isInstantiable($nameBridge)) {
return new $nameBridge();
} else {
return false;
@@ -50,11 +50,11 @@ EOD;
}
static public function setDir($dirBridge){
if(!is_string($dirBridge)){
if(!is_string($dirBridge)) {
throw new \InvalidArgumentException('Dir bridge must be a string.');
}
if(!file_exists($dirBridge)){
if(!file_exists($dirBridge)) {
throw new \Exception('Dir bridge does not exist.');
}
@@ -64,7 +64,7 @@ EOD;
static public function getDir(){
$dirBridge = self::$dirBridge;
if(is_null($dirBridge)){
if(is_null($dirBridge)) {
throw new \LogicException(__CLASS__ . ' class need to know bridge path !');
}
@@ -80,9 +80,9 @@ EOD;
$listBridge = array();
$dirFiles = scandir($pathDirBridge);
if($dirFiles !== false){
foreach($dirFiles as $fileName){
if(preg_match('@^([^.]+)Bridge\.php$@U', $fileName, $out)){
if($dirFiles !== false) {
foreach($dirFiles as $fileName) {
if(preg_match('@^([^.]+)Bridge\.php$@U', $fileName, $out)) {
$listBridge[] = $out[1];
}
}
@@ -96,7 +96,7 @@ EOD;
|| in_array($name . '.php', $whitelist)
|| in_array($name . 'Bridge', $whitelist) // DEPRECATED
|| in_array($name . 'Bridge.php', $whitelist) // DEPRECATED
|| (count($whitelist) === 1 && trim($whitelist[0]) === '*')){
|| (count($whitelist) === 1 && trim($whitelist[0]) === '*')) {
return true;
} else {
return false;