1
0
mirror of https://github.com/RSS-Bridge/rss-bridge.git synced 2025-08-10 18:44:04 +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

@@ -32,7 +32,7 @@ class FacebookBridge extends BridgeAbstract {
//Extract a string using start and end delimiters
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;
@@ -43,7 +43,7 @@ class FacebookBridge extends BridgeAbstract {
//Utility function for cleaning a Facebook link
$unescape_fb_link = function($matches){
if(is_array($matches) && count($matches) > 1){
if(is_array($matches) && count($matches) > 1) {
$link = $matches[1];
if(strpos($link, '/') === 0)
$link = self::URI . $link . '"';
@@ -89,12 +89,10 @@ class FacebookBridge extends BridgeAbstract {
$html = null;
//Handle captcha response sent by the viewer
if (isset($_POST['captcha_response']))
{
if (isset($_POST['captcha_response'])) {
if (session_status() == PHP_SESSION_NONE)
session_start();
if (isset($_SESSION['captcha_fields'], $_SESSION['captcha_action']))
{
if (isset($_SESSION['captcha_fields'], $_SESSION['captcha_action'])) {
$captcha_action = $_SESSION['captcha_action'];
$captcha_fields = $_SESSION['captcha_fields'];
$captcha_fields['captcha_response'] = preg_replace("/[^a-zA-Z0-9]+/", "", $_POST['captcha_response']);
@@ -110,7 +108,7 @@ class FacebookBridge extends BridgeAbstract {
$context = stream_context_create($http_options);
$html = getContents($captcha_action, false, $context);
if($html === false){
if($html === false) {
returnServerError('Failed to submit captcha response back to Facebook');
}
unset($_SESSION['captcha_fields']);
@@ -121,7 +119,7 @@ class FacebookBridge extends BridgeAbstract {
}
//Retrieve page contents
if(is_null($html)){
if(is_null($html)) {
$http_options = array(
'http' => array(
'method' => 'GET',
@@ -130,7 +128,7 @@ class FacebookBridge extends BridgeAbstract {
)
);
$context = stream_context_create($http_options);
if(!strpos($this->getInput('u'), "/")){
if(!strpos($this->getInput('u'), "/")) {
$html = getSimpleHTMLDOM(self::URI . urlencode($this->getInput('u')) . '?_fb_noscript=1',
false,
$context)
@@ -145,8 +143,7 @@ class FacebookBridge extends BridgeAbstract {
//Handle captcha form?
$captcha = $html->find('div.captcha_interstitial', 0);
if (!is_null($captcha))
{
if (!is_null($captcha)) {
//Save form for submitting after getting captcha response
if (session_status() == PHP_SESSION_NONE)
session_start();
@@ -182,7 +179,7 @@ EOD;
->next_sibling()
->children(0);
if(isset($element)){
if(isset($element)) {
$author = str_replace(' | Facebook', '', $html->find('title#pageTitle', 0)->innertext);
$profilePic = 'https://graph.facebook.com/'
@@ -191,17 +188,17 @@ EOD;
$this->authorName = $author;
foreach($element->children() as $cell){
foreach($element->children() as $cell) {
// Manage summary posts
if(strpos($cell->class, '_3xaf') !== false){
if(strpos($cell->class, '_3xaf') !== false) {
$posts = $cell->children();
} else {
$posts = array($cell);
}
foreach($posts as $post){
foreach($posts as $post) {
// Check media type
switch($this->getInput('media_type')){
switch($this->getInput('media_type')) {
case 'all': break;
case 'video':
if(empty($post->find('[aria-label=Video]'))) continue 2;
@@ -214,7 +211,7 @@ EOD;
$item = array();
if(count($post->find('abbr')) > 0){
if(count($post->find('abbr')) > 0) {
//Retrieve post contents
$content = preg_replace(
@@ -270,7 +267,7 @@ EOD;
//Retrieve date of the post
$date = $post->find("abbr")[0];
if(isset($date) && $date->hasAttribute('data-utime')){
if(isset($date) && $date->hasAttribute('data-utime')) {
$date = $date->getAttribute('data-utime');
} else {
$date = 0;
@@ -298,7 +295,7 @@ EOD;
}
public function getName(){
if(!empty($this->authorName)){
if(!empty($this->authorName)) {
return isset($this->extraInfos['name']) ? $this->extraInfos['name'] : $this->authorName
. ' - Facebook Bridge';
}