[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

@ -7,7 +7,7 @@ abstract class FeedExpander extends BridgeAbstract {
private $feedType;
public function collectExpandableDatas($url, $maxItems = -1){
if(empty($url)){
if(empty($url)) {
returnServerError('There is no $url for this RSS expander');
}
@ -21,7 +21,7 @@ abstract class FeedExpander extends BridgeAbstract {
$rssContent = simplexml_load_string($content);
debugMessage('Detecting feed format/version');
switch(true){
switch(true) {
case isset($rssContent->item[0]):
debugMessage('Detected RSS 1.0 format');
$this->feedType = "RSS_1_0";
@ -46,7 +46,7 @@ abstract class FeedExpander extends BridgeAbstract {
protected function collect_RSS_1_0_data($rssContent, $maxItems){
$this->load_RSS_2_0_feed_data($rssContent->channel[0]);
foreach($rssContent->item as $item){
foreach($rssContent->item as $item) {
debugMessage('parsing item ' . var_export($item, true));
$tmp_item = $this->parseItem($item);
if (!empty($tmp_item)) {
@ -63,7 +63,7 @@ abstract class FeedExpander extends BridgeAbstract {
. '===========');
$this->load_RSS_2_0_feed_data($rssContent);
foreach($rssContent->item as $item){
foreach($rssContent->item as $item) {
debugMessage('parsing item ' . var_export($item, true));
$tmp_item = $this->parseItem($item);
if (!empty($tmp_item)) {
@ -75,7 +75,7 @@ abstract class FeedExpander extends BridgeAbstract {
protected function collect_ATOM_1_0_data($content, $maxItems){
$this->load_ATOM_feed_data($content);
foreach($content->entry as $item){
foreach($content->entry as $item) {
debugMessage('parsing item ' . var_export($item, true));
$tmp_item = $this->parseItem($item);
if (!empty($tmp_item)) {
@ -99,14 +99,14 @@ abstract class FeedExpander extends BridgeAbstract {
$this->name = (string)$content->title;
// Find best link (only one, or first of 'alternate')
if(!isset($content->link)){
if(!isset($content->link)) {
$this->uri = '';
} elseif (count($content->link) === 1){
} elseif (count($content->link) === 1) {
$this->uri = $content->link[0]['href'];
} else {
$this->uri = '';
foreach($content->link as $link){
if(strtolower($link['rel']) === 'alternate'){
foreach($content->link as $link) {
if(strtolower($link['rel']) === 'alternate') {
$this->uri = $link['href'];
break;
}
@ -139,7 +139,7 @@ abstract class FeedExpander extends BridgeAbstract {
$item = $this->parseRSS_0_9_1_Item($feedItem);
$namespaces = $feedItem->getNamespaces(true);
if(isset($namespaces['dc'])){
if(isset($namespaces['dc'])) {
$dc = $feedItem->children($namespaces['dc']);
if(isset($dc->date)) $item['timestamp'] = strtotime((string)$dc->date);
if(isset($dc->creator)) $item['author'] = (string)$dc->creator;
@ -155,24 +155,24 @@ abstract class FeedExpander extends BridgeAbstract {
$namespaces = $feedItem->getNamespaces(true);
if(isset($namespaces['dc'])) $dc = $feedItem->children($namespaces['dc']);
if(isset($feedItem->guid)){
foreach($feedItem->guid->attributes() as $attribute => $value){
if(isset($feedItem->guid)) {
foreach($feedItem->guid->attributes() as $attribute => $value) {
if($attribute === 'isPermaLink'
&& ($value === 'true' || filter_var($feedItem->guid, FILTER_VALIDATE_URL))){
&& ($value === 'true' || filter_var($feedItem->guid, FILTER_VALIDATE_URL))) {
$item['uri'] = (string)$feedItem->guid;
break;
}
}
}
if(isset($feedItem->pubDate)){
if(isset($feedItem->pubDate)) {
$item['timestamp'] = strtotime((string)$feedItem->pubDate);
} elseif(isset($dc->date)){
} elseif(isset($dc->date)) {
$item['timestamp'] = strtotime((string)$dc->date);
}
if(isset($feedItem->author)){
if(isset($feedItem->author)) {
$item['author'] = (string)$feedItem->author;
} elseif(isset($dc->creator)){
} elseif(isset($dc->creator)) {
$item['author'] = (string)$dc->creator;
}
return $item;
@ -184,7 +184,7 @@ abstract class FeedExpander extends BridgeAbstract {
* @return a RSS-Bridge Item, with (hopefully) the whole content)
*/
protected function parseItem($item){
switch($this->feedType){
switch($this->feedType) {
case 'RSS_1_0':
return $this->parseRSS_1_0_Item($item);
break;