1
0
mirror of https://github.com/RSS-Bridge/rss-bridge.git synced 2025-08-12 11:34:09 +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

@@ -168,7 +168,7 @@ class ZDNetBridge extends BridgeAbstract {
}
function extractFromDelimiters($string, $start, $end){
if(strpos($string, $start) !== false){
if(strpos($string, $start) !== false) {
$section_retrieved = substr($string, strpos($string, $start) + strlen($start));
$section_retrieved = substr($section_retrieved, 0, strpos($section_retrieved, $end));
return $section_retrieved;
@@ -178,7 +178,7 @@ class ZDNetBridge extends BridgeAbstract {
}
function stripWithDelimiters($string, $start, $end){
while(strpos($string, $start) !== false){
while(strpos($string, $start) !== false) {
$section_to_remove = substr($string, strpos($string, $start));
$section_to_remove = substr($section_to_remove, 0, strpos($section_to_remove, $end) + strlen($end));
$string = str_replace($section_to_remove, '', $string);
@@ -191,8 +191,8 @@ class ZDNetBridge extends BridgeAbstract {
$open_tag = '<' . $tag_name;
$close_tag = '</' . $tag_name . '>';
$close_tag_length = strlen($close_tag);
if(strpos($tag_start, $open_tag) === 0){
while(strpos($string, $tag_start) !== false){
if(strpos($tag_start, $open_tag) === 0) {
while(strpos($string, $tag_start) !== false) {
$max_recursion = 100;
$section_to_remove = null;
$section_start = strpos($string, $tag_start);
@@ -218,7 +218,7 @@ class ZDNetBridge extends BridgeAbstract {
$baseUri = self::URI;
$feed = $this->getInput('feed');
if(strpos($feed, 'downloads!') !== false){
if(strpos($feed, 'downloads!') !== false) {
$feed = str_replace('downloads!', '', $feed);
$baseUri = str_replace('www.', 'downloads.', $baseUri);
}
@@ -227,8 +227,8 @@ class ZDNetBridge extends BridgeAbstract {
or returnServerError('Could not request ZDNet: ' . $url);
$limit = 0;
foreach($html->find('item') as $element){
if($limit < 10){
foreach($html->find('item') as $element) {
if($limit < 10) {
$article_url = preg_replace(
'/([^#]+)#ftag=.*/',
'$1',
@@ -242,11 +242,11 @@ class ZDNetBridge extends BridgeAbstract {
$article = getSimpleHTMLDOM($article_url)
or returnServerError('Could not request ZDNet: ' . $article_url);
if(!empty($article_author)){
if(!empty($article_author)) {
$author = $article_author;
} else {
$author = $article->find('meta[name=author]', 0);
if(is_object($author)){
if(is_object($author)) {
$author = $author->content;
} else {
$author = 'ZDNet';
@@ -254,7 +254,7 @@ class ZDNetBridge extends BridgeAbstract {
}
$thumbnail = $article->find('meta[itemprop=image]', 0);
if(is_object($thumbnail)){
if(is_object($thumbnail)) {
$thumbnail = $thumbnail->content;
} else {
$thumbnail = '';
@@ -269,14 +269,14 @@ class ZDNetBridge extends BridgeAbstract {
'<div data-shortcode',
'<div id="sharethrough',
'<div id="inpage-video'
) as $div_start){
) as $div_start) {
$contents = stripRecursiveHtmlSection($contents, 'div', $div_start);
}
$contents = stripWithDelimiters($contents, '<script', '</script>');
$contents = stripWithDelimiters($contents, '<meta itemprop="image"', '>');
$contents = trim(stripWithDelimiters($contents, '<section class="sharethrough-top', '</section>'));
$content_img = strpos($contents, '<img'); //Look for first image
if (($content_img !== false && $content_img < 512) || $thumbnail == ''){
if (($content_img !== false && $content_img < 512) || $thumbnail == '') {
$content_img = ''; //Image already present on article beginning or no thumbnail
} else {
$content_img = '<p><img src="'.$thumbnail.'" /></p>'; //Include thumbnail