fix php cs fixer concat operator to use space

This commit is contained in:
osaajani 2020-01-17 18:47:08 +01:00
parent 9de6697752
commit 08bf5a878a
26 changed files with 113 additions and 109 deletions

View File

@ -198,7 +198,7 @@ namespace adapters;
}
$command_parts = [
PWD.'/bin/gammu_get_unread_sms.py',
PWD . '/bin/gammu_get_unread_sms.py',
escapeshellarg($this->datas['config_file']),
];

View File

@ -168,7 +168,7 @@ namespace adapters;
{
$success = true;
$endpoint = '/sms/'.$this->datas['service_name'].'/virtualNumbers/'.$this->formatted_number.'/jobs';
$endpoint = '/sms/' . $this->datas['service_name'] . '/virtualNumbers/' . $this->formatted_number . '/jobs';
$params = [
'message' => $text,
'receivers' => [$destination],
@ -203,7 +203,7 @@ namespace adapters;
{
$success = true;
$endpoint = '/sms/'.$this->datas['service_name'].'/virtualNumbers/'.$this->formatted_number.'/incoming';
$endpoint = '/sms/' . $this->datas['service_name'] . '/virtualNumbers/' . $this->formatted_number . '/incoming';
$uids = $this->api->get($endpoint);
if (!\is_array($uids) || !$uids)
@ -214,7 +214,7 @@ namespace adapters;
$received_smss = [];
foreach ($uids as $uid)
{
$endpoint = '/sms/'.$this->datas['service_name'].'/virtualNumbers/'.$this->formatted_number.'/incoming/'.$uid;
$endpoint = '/sms/' . $this->datas['service_name'] . '/virtualNumbers/' . $this->formatted_number . '/incoming/' . $uid;
$sms_details = $this->api->get($endpoint);
if (!isset($sms_details['creationDatetime'], $sms_details['message'], $sms_details['sender']))
@ -230,7 +230,7 @@ namespace adapters;
];
//Remove the sms to prevent double reading as ovh do not offer a filter for unread messages only
$endpoint = '/sms/'.$this->datas['service_name'].'/virtualNumbers/'.$this->formatted_number.'/incoming/'.$uid;
$endpoint = '/sms/' . $this->datas['service_name'] . '/virtualNumbers/' . $this->formatted_number . '/incoming/' . $uid;
$this->api->delete($endpoint);
}
@ -255,12 +255,12 @@ namespace adapters;
$success = true;
//Check service name
$endpoint = '/sms/'.$this->datas['service_name'];
$endpoint = '/sms/' . $this->datas['service_name'];
$response = $this->api->get($endpoint);
$success = $success && (bool) $response;
//Check virtualnumber
$endpoint = '/sms/virtualNumbers/'.$this->formatted_number;
$endpoint = '/sms/virtualNumbers/' . $this->formatted_number;
$response = $this->api->get($endpoint);
return $success && (bool) $response;

View File

@ -33,12 +33,12 @@ namespace adapters;
/**
* Path for the file to read sms as a json from.
*/
private $test_file_read = PWD_DATAS.'/test_read_sms.json';
private $test_file_read = PWD_DATAS . '/test_read_sms.json';
/**
* Path for the file to write sms as a json in.
*/
private $test_file_write = PWD_DATAS.'/test_write_sms.json';
private $test_file_write = PWD_DATAS . '/test_write_sms.json';
/**
* Adapter constructor, called when instanciated by RaspiSMS.
@ -126,7 +126,7 @@ namespace adapters;
$uid = uniqid();
$at = (new \DateTime())->format('Y-m-d H:i:s');
file_put_contents($this->test_file_write, json_encode(['uid' => $uid, 'at' => $at, 'destination' => $destination, 'text' => $text, 'flash' => $flash])."\n", FILE_APPEND);
file_put_contents($this->test_file_write, json_encode(['uid' => $uid, 'at' => $at, 'destination' => $destination, 'text' => $text, 'flash' => $flash]) . "\n", FILE_APPEND);
return uniqid();
}

View File

@ -72,7 +72,7 @@ namespace controllers\internals;
continue;
}
$adapters_files[] = PWD_ADAPTERS.'/'.$filename;
$adapters_files[] = PWD_ADAPTERS . '/' . $filename;
}
return $adapters_files;
@ -95,7 +95,7 @@ namespace controllers\internals;
}
$adapter_classname = pathinfo($adapter_file, PATHINFO_FILENAME);
$reflection_class = new \ReflectionClass('\adapters\\'.$adapter_classname);
$reflection_class = new \ReflectionClass('\adapters\\' . $adapter_classname);
if (!$reflection_class)
{
return false;

View File

@ -41,7 +41,7 @@ namespace controllers\internals;
}
$internal_event = new Event($this->bdd);
$internal_event->create($id_user, 'COMMAND_ADD', 'Ajout commande : '.$name.' => '.$script);
$internal_event->create($id_user, 'COMMAND_ADD', 'Ajout commande : ' . $name . ' => ' . $script);
return $result;
}
@ -127,9 +127,9 @@ namespace controllers\internals;
$decode_message['password'] = '******';
$updated_text = json_encode($decode_message);
$generated_command = PWD_SCRIPTS.'/'.$find_command['script'];
$generated_command = PWD_SCRIPTS . '/' . $find_command['script'];
$args = $decode_message['args'] ?? '';
$generated_command .= ' '.escapeshellcmd($args);
$generated_command .= ' ' . escapeshellcmd($args);
return [
'updated_text' => $updated_text,

View File

@ -46,7 +46,7 @@ namespace controllers\internals;
}
$internal_event = new Event($this->bdd);
$internal_event->create($id_user, 'CONDITIONAL_GROUP_ADD', 'Ajout du groupe conditionnel : '.$name);
$internal_event->create($id_user, 'CONDITIONAL_GROUP_ADD', 'Ajout du groupe conditionnel : ' . $name);
return $id_group;
}

View File

@ -79,7 +79,7 @@ namespace controllers\internals;
}
$internal_event = new Event($this->bdd);
$internal_event->create($id_user, 'CONTACT_ADD', 'Ajout contact : '.$name.' ('.\controllers\internals\Tool::phone_format($number).')');
$internal_event->create($id_user, 'CONTACT_ADD', 'Ajout contact : ' . $name . ' (' . \controllers\internals\Tool::phone_format($number) . ')');
return $result;
}
@ -288,7 +288,7 @@ namespace controllers\internals;
//Php only support csv formatting to file. To get it in string we need to create a tmp in memory file, write in it, and then read the file into a var
// output up to 5MB is kept in memory, if it becomes bigger it will automatically be written to a temporary file
$csv_tmp_file = fopen('php://temp/maxmemory:'.(5 * 1024 * 1024), 'r+');
$csv_tmp_file = fopen('php://temp/maxmemory:' . (5 * 1024 * 1024), 'r+');
fputcsv($csv_tmp_file, $columns);
foreach ($lines as $line)
{
@ -302,7 +302,7 @@ namespace controllers\internals;
'headers' => [
'Content-Disposition: attachment; filename=contacts.csv',
'Content-Type: text/csv',
'Content-Length: '.\mb_strlen($csv_string),
'Content-Length: ' . mb_strlen($csv_string),
],
'content' => $csv_string,
];
@ -331,7 +331,7 @@ namespace controllers\internals;
'headers' => [
'Content-Disposition: attachment; filename=contacts.json',
'Content-Type: application/json',
'Content-Length: '.\mb_strlen($content),
'Content-Length: ' . mb_strlen($content),
],
'content' => $content,
];

View File

@ -53,7 +53,7 @@ namespace controllers\internals;
}
$internal_event = new Event($this->bdd);
$internal_event->create($id_user, 'GROUP_ADD', 'Ajout group : '.$name);
$internal_event->create($id_user, 'GROUP_ADD', 'Ajout group : ' . $name);
return $id_group;
}

View File

@ -56,7 +56,7 @@ namespace controllers\internals;
{
$date = date('Y-m-d H:i:s');
$internal_event = new Event($this->bdd);
$internal_event->create($id_user, 'SCHEDULED_ADD', 'Ajout d\'un Sms pour le '.$date.'.');
$internal_event->create($id_user, 'SCHEDULED_ADD', 'Ajout d\'un Sms pour le ' . $date . '.');
return false;
}

View File

@ -80,7 +80,7 @@ namespace controllers\internals;
$number_format = self::phone_format($number);
$url = \descartes\Router::url('Discussion', 'show', ['number' => $number]);
return '<a href="'.self::s($url, false, true, false).'">'.self::s($number_format, false, true, false).'</a>';
return '<a href="' . self::s($url, false, true, false) . '">' . self::s($number_format, false, true, false) . '</a>';
}
/**
@ -228,7 +228,7 @@ namespace controllers\internals;
switch ($file['error'])
{
case UPLOAD_ERR_INI_SIZE:
$result['content'] = 'Impossible de télécharger le fichier car il dépasse les '.ini_get('upload_max_filesize') / (1000 * 1000).' Mégaoctets.';
$result['content'] = 'Impossible de télécharger le fichier car il dépasse les ' . ini_get('upload_max_filesize') / (1000 * 1000) . ' Mégaoctets.';
break;
case UPLOAD_ERR_FORM_SIZE:
@ -295,7 +295,7 @@ namespace controllers\internals;
switch ($file['error'])
{
case UPLOAD_ERR_INI_SIZE:
$result['content'] = 'Impossible de télécharger le fichier car il dépasse les '.ini_get('upload_max_filesize') / (1000 * 1000).' Mégaoctets.';
$result['content'] = 'Impossible de télécharger le fichier car il dépasse les ' . ini_get('upload_max_filesize') / (1000 * 1000) . ' Mégaoctets.';
break;
case UPLOAD_ERR_FORM_SIZE:
@ -339,7 +339,7 @@ namespace controllers\internals;
return $result;
}
$new_file_path = PWD_DATAS.'/'.$md5_filename;
$new_file_path = PWD_DATAS . '/' . $md5_filename;
if (file_exists($new_file_path))
{

View File

@ -104,14 +104,14 @@ namespace controllers\publics;
{
$return = self::DEFAULT_RETURN;
$return['error'] = self::ERROR_CODES['INVALID_PARAMETER'];
$return['message'] = self::ERROR_MESSAGES['INVALID_PARAMETER'].'entry_type must be one of : '.implode(', ', $entry_types).'.';
$return['message'] = self::ERROR_MESSAGES['INVALID_PARAMETER'] . 'entry_type must be one of : ' . implode(', ', $entry_types) . '.';
$this->auto_http_code(false);
$this->json($return);
return false;
}
$controller_str = 'internal_'.$entry_type;
$controller_str = 'internal_' . $entry_type;
$controller = $this->{$controller_str};
$page = (int) $page;
@ -184,7 +184,7 @@ namespace controllers\publics;
{
$return = self::DEFAULT_RETURN;
$return['error'] = self::ERROR_CODES['MISSING_PARAMETER'];
$return['message'] = self::ERROR_MESSAGES['MISSING_PARAMETER'].($at ? '' : 'at ').($text ? '' : 'text');
$return['message'] = self::ERROR_MESSAGES['MISSING_PARAMETER'] . ($at ? '' : 'at ') . ($text ? '' : 'text');
$this->auto_http_code(false);
$this->json($return);
@ -195,7 +195,7 @@ namespace controllers\publics;
{
$return = self::DEFAULT_RETURN;
$return['error'] = self::ERROR_CODES['INVALID_PARAMETER'];
$return['message'] = self::ERROR_MESSAGES['INVALID_PARAMETER'].'at must be a date of format "Y-m-d H:i:s".';
$return['message'] = self::ERROR_MESSAGES['INVALID_PARAMETER'] . 'at must be a date of format "Y-m-d H:i:s".';
$this->auto_http_code(false);
$this->json($return);
@ -220,7 +220,7 @@ namespace controllers\publics;
{
$return = self::DEFAULT_RETURN;
$return['error'] = self::ERROR_CODES['MISSING_PARAMETER'];
$return['message'] = self::ERROR_MESSAGES['MISSING_PARAMETER'].'You must specify at least one valid number, contact, group or conditional_group.';
$return['message'] = self::ERROR_MESSAGES['MISSING_PARAMETER'] . 'You must specify at least one valid number, contact, group or conditional_group.';
$this->auto_http_code(false);
$this->json($return);
@ -231,7 +231,7 @@ namespace controllers\publics;
{
$return = self::DEFAULT_RETURN;
$return['error'] = self::ERROR_CODES['INVALID_PARAMETER'];
$return['message'] = self::ERROR_MESSAGES['INVALID_PARAMETER'].'origin : You must specify an origin number among thoses of user phones.';
$return['message'] = self::ERROR_MESSAGES['INVALID_PARAMETER'] . 'origin : You must specify an origin number among thoses of user phones.';
$this->auto_http_code(false);
$this->json($return);
@ -260,6 +260,7 @@ namespace controllers\publics;
* Delete a scheduled message.
*
* @param int $id : Id of scheduled message to delete
*
* @return bool : void
*/
public function delete_scheduled(int $id)
@ -274,6 +275,7 @@ namespace controllers\publics;
}
$this->auto_http_code(true);
return true;
}
}

View File

@ -227,7 +227,7 @@ namespace controllers\publics;
$contacts_name[] = $contact['name'];
}
$return['result'] = 'Contacts du groupe : '.implode(', ', $contacts_name);
$return['result'] = 'Contacts du groupe : ' . implode(', ', $contacts_name);
$return['success'] = true;
echo json_encode($return);

View File

@ -306,10 +306,10 @@ namespace controllers\publics;
return $this->redirect(\descartes\Router::url('Contact', 'list'));
}
$msg = $result.' nouveau contact a été inséré.';
$msg = $result . ' nouveau contact a été inséré.';
if ($result > 1)
{
$msg = $result.' nouveaux contacts ont été insérés.';
$msg = $result . ' nouveaux contacts ont été insérés.';
}
\FlashMessage\FlashMessage::push('success', $msg);

View File

@ -122,7 +122,7 @@ namespace controllers\publics;
'date' => htmlspecialchars($received['at']),
'text' => htmlspecialchars($received['text']),
'type' => 'received',
'md5' => md5($received['at'].$received['text']),
'md5' => md5($received['at'] . $received['text']),
];
}

View File

@ -59,7 +59,7 @@ namespace controllers\publics;
continue;
}
$receiveds[$key]['origin'] = $contact['name'].' ('.$received['origin'].')';
$receiveds[$key]['origin'] = $contact['name'] . ' (' . $received['origin'] . ')';
}
$this->render('received/list', ['receiveds' => $receiveds, 'page' => $page, 'limit' => $limit, 'nb_results' => \count($receiveds)]);
@ -85,7 +85,7 @@ namespace controllers\publics;
continue;
}
$receiveds[$key]['origin'] = $contact['name'].' ('.$received['origin'].')';
$receiveds[$key]['origin'] = $contact['name'] . ' (' . $received['origin'] . ')';
}
$this->render('received/list_unread', ['receiveds' => $receiveds, 'page' => $page, 'limit' => $limit, 'nb_results' => \count($receiveds)]);
@ -134,7 +134,7 @@ namespace controllers\publics;
continue;
}
$receiveds[$key]['origin'] = $this->s($contact['name'], false, true, false).' ('.\controllers\internals\Tool::phone_link($received['origin']).')';
$receiveds[$key]['origin'] = $this->s($contact['name'], false, true, false) . ' (' . \controllers\internals\Tool::phone_link($received['origin']) . ')';
}
$nb_received = \count($receiveds);

View File

@ -297,7 +297,7 @@ namespace controllers\publics;
$media = $_FILES['media'] ?? false;
if (!($_SESSION['user']['settings']['mms'] ?? false) || !$media)
{
\FlashMessage\FlashMessage::push('success', 'Le Sms a bien été créé pour le '.$at.'.');
\FlashMessage\FlashMessage::push('success', 'Le Sms a bien été créé pour le ' . $at . '.');
return $this->redirect(\descartes\Router::url('Scheduled', 'list'));
}
@ -310,7 +310,7 @@ namespace controllers\publics;
return $this->redirect(\descartes\Router::url('Scheduled', 'list'));
}
\FlashMessage\FlashMessage::push('success', 'Le Sms a bien été créé pour le '.$at.'.');
\FlashMessage\FlashMessage::push('success', 'Le Sms a bien été créé pour le ' . $at . '.');
return $this->redirect(\descartes\Router::url('Scheduled', 'list'));
}

View File

@ -96,9 +96,9 @@ abstract class AbstractDaemon
protected function start()
{
//If process must be uniq and a process with the same pid file is already running
if (file_exists($this->pid_dir.'/'.$this->name.'.pid') && $this->uniq)
if (file_exists($this->pid_dir . '/' . $this->name . '.pid') && $this->uniq)
{
$this->logger->info('Another process named '.$this->name.' is already running.');
$this->logger->info('Another process named ' . $this->name . ' is already running.');
return false;
}
@ -119,7 +119,7 @@ abstract class AbstractDaemon
return true;
}
$this->logger->info("Process {$this->name} started as a child with pid ".getmypid().'.');
$this->logger->info("Process {$this->name} started as a child with pid " . getmypid() . '.');
//Child script
$sid = posix_setsid(); //Try to make the child process a main process
@ -129,7 +129,7 @@ abstract class AbstractDaemon
exit(1);
}
$this->logger->info('The child process with pid '.getmypid().' is now independent.');
$this->logger->info('The child process with pid ' . getmypid() . ' is now independent.');
}
//Create pid dir if not exists
@ -138,7 +138,7 @@ abstract class AbstractDaemon
$success = mkdir($this->pid_dir, 0777, true);
if (!$success)
{
$this->logger->critical('Cannot create PID directory : '.$this->pid_dir);
$this->logger->critical('Cannot create PID directory : ' . $this->pid_dir);
exit(2);
}
}
@ -147,7 +147,7 @@ abstract class AbstractDaemon
cli_set_process_title($this->name);
//Write the pid of the process into a file
file_put_contents($this->pid_dir.'/'.$this->name.'.pid', getmypid());
file_put_contents($this->pid_dir . '/' . $this->name . '.pid', getmypid());
//Really start the daemon
$this->on_start();
@ -162,16 +162,16 @@ abstract class AbstractDaemon
}
catch (\Exception $e)
{
$this->logger->critical('Exception : '.$e->getMessage().' in '.$e->getFile().' line '.$e->getLine());
$this->logger->critical('Exception : ' . $e->getMessage() . ' in ' . $e->getFile() . ' line ' . $e->getLine());
}
//Stop the daemon
$this->on_stop();
//Delete pid file
if (file_exists($this->pid_dir.'/'.$this->name.'.pid'))
if (file_exists($this->pid_dir . '/' . $this->name . '.pid'))
{
unlink($this->pid_dir.'/'.$this->name.'.pid');
unlink($this->pid_dir . '/' . $this->name . '.pid');
}
}

View File

@ -29,7 +29,7 @@ class Launcher extends AbstractDaemon
$name = 'RaspiSMS Daemon Launcher';
$logger = new Logger($name);
$logger->pushHandler(new StreamHandler(PWD_LOGS.'/raspisms.log', Logger::DEBUG));
$logger->pushHandler(new StreamHandler(PWD_LOGS . '/raspisms.log', Logger::DEBUG));
$pid_dir = PWD_PID;
$no_parent = true; //Launcher should be rattach to PID 1
$additional_signals = [];
@ -63,7 +63,7 @@ class Launcher extends AbstractDaemon
public function start_sender_daemon()
{
$name = 'RaspiSMS Daemon Sender';
$pid_file = PWD_PID.'/'.$name.'.pid';
$pid_file = PWD_PID . '/' . $name . '.pid';
if (file_exists($pid_file))
{
@ -72,7 +72,7 @@ class Launcher extends AbstractDaemon
//Create a new daemon for sender
$pid = null;
exec('php '.PWD.'/console.php controllers/internals/Console.php sender > /dev/null 2>&1 &');
exec('php ' . PWD . '/console.php controllers/internals/Console.php sender > /dev/null 2>&1 &');
}
/**
@ -81,7 +81,7 @@ class Launcher extends AbstractDaemon
public function start_webhook_daemon()
{
$name = 'RaspiSMS Daemon Webhook';
$pid_file = PWD_PID.'/'.$name.'.pid';
$pid_file = PWD_PID . '/' . $name . '.pid';
if (file_exists($pid_file))
{
@ -89,7 +89,7 @@ class Launcher extends AbstractDaemon
}
//Create a new daemon for webhook
exec('php '.PWD.'/console.php controllers/internals/Console.php webhook > /dev/null 2>&1 &');
exec('php ' . PWD . '/console.php controllers/internals/Console.php webhook > /dev/null 2>&1 &');
}
/**
@ -101,8 +101,8 @@ class Launcher extends AbstractDaemon
{
foreach ($phones as $phone)
{
$phone_name = 'RaspiSMS Daemon Phone '.$phone['number'];
$pid_file = PWD_PID.'/'.$phone_name.'.pid';
$phone_name = 'RaspiSMS Daemon Phone ' . $phone['number'];
$pid_file = PWD_PID . '/' . $phone_name . '.pid';
if (file_exists($pid_file))
{
@ -110,22 +110,22 @@ class Launcher extends AbstractDaemon
}
//Create a new daemon for the phone
exec('php '.PWD.'/console.php controllers/internals/Console.php phone --id_phone=\''.$phone['id'].'\' > /dev/null 2>&1 &');
exec('php ' . PWD . '/console.php controllers/internals/Console.php phone --id_phone=\'' . $phone['id'] . '\' > /dev/null 2>&1 &');
}
}
public function on_start()
{
$this->logger->info('Starting Launcher with pid '.getmypid());
$this->logger->info('Starting Launcher with pid ' . getmypid());
}
public function on_stop()
{
$this->logger->info('Stopping Launcher with pid '.getmypid());
$this->logger->info('Stopping Launcher with pid ' . getmypid());
}
public function handle_other_signals($signal)
{
$this->logger->info('Signal not handled by '.$this->name.' Daemon : '.$signal);
$this->logger->info('Signal not handled by ' . $this->name . ' Daemon : ' . $signal);
}
}

View File

@ -37,9 +37,9 @@ class Phone extends AbstractDaemon
$this->phone = $phone;
$this->msg_queue_id = (int) mb_substr($this->phone['number'], 1);
$name = 'RaspiSMS Daemon Phone '.$this->phone['number'];
$name = 'RaspiSMS Daemon Phone ' . $this->phone['number'];
$logger = new Logger($name);
$logger->pushHandler(new StreamHandler(PWD_LOGS.'/raspisms.log', Logger::DEBUG));
$logger->pushHandler(new StreamHandler(PWD_LOGS . '/raspisms.log', Logger::DEBUG));
$pid_dir = PWD_PID;
$no_parent = false; //Phone should be rattach to manager, so manager can stop him easily
$additional_signals = [];
@ -83,21 +83,21 @@ class Phone extends AbstractDaemon
$adapter_class = $this->phone['adapter'];
$this->adapter = new $adapter_class($this->phone['number'], $this->phone['adapter_datas']);
$this->logger->info('Starting Phone daemon with pid '.getmypid());
$this->logger->info('Starting Phone daemon with pid ' . getmypid());
}
public function on_stop()
{
//Delete queue on daemon close
$this->logger->info('Closing queue : '.$this->msg_queue_id);
$this->logger->info('Closing queue : ' . $this->msg_queue_id);
msg_remove_queue($this->msg_queue);
$this->logger->info('Stopping Phone daemon with pid '.getmypid());
$this->logger->info('Stopping Phone daemon with pid ' . getmypid());
}
public function handle_other_signals($signal)
{
$this->logger->info('Signal not handled by '.$this->name.' Daemon : '.$signal);
$this->logger->info('Signal not handled by ' . $this->name . ' Daemon : ' . $signal);
}
/**
@ -118,7 +118,7 @@ class Phone extends AbstractDaemon
if (!$success && MSG_ENOMSG !== $error_code)
{
$this->logger->critical('Error reading MSG SEND Queue, error code : '.$error_code);
$this->logger->critical('Error reading MSG SEND Queue, error code : ' . $error_code);
return false;
}
@ -140,12 +140,12 @@ class Phone extends AbstractDaemon
$message['at'] = $at;
$this->logger->info('Try send message : '.json_encode($message));
$this->logger->info('Try send message : ' . json_encode($message));
$sended_sms_uid = $this->adapter->send($message['destination'], $message['text'], $message['flash']);
if (!$sended_sms_uid)
{
$this->logger->error('Failed send message : '.json_encode($message));
$this->logger->error('Failed send message : ' . json_encode($message));
$internal_sended->create($at, $message['text'], $message['origin'], $message['destination'], $sended_sms_uid, $this->phone['adapter'], $message['flash'], 'failed');
continue;
@ -156,7 +156,7 @@ class Phone extends AbstractDaemon
$user_settings = $internal_setting->gets_for_user($this->phone['id_user']);
$this->process_for_webhook($message, 'send_sms', $user_settings);
$this->logger->info('Successfully send message : '.json_encode($message));
$this->logger->info('Successfully send message : ' . json_encode($message));
$internal_sended->create($at, $message['text'], $message['origin'], $message['destination'], $sended_sms_uid, $this->phone['adapter'], $message['flash']);
}
@ -182,7 +182,7 @@ class Phone extends AbstractDaemon
//Process smss
foreach ($smss as $sms)
{
$this->logger->info('Receive message : '.json_encode($sms));
$this->logger->info('Receive message : ' . json_encode($sms));
$command_result = $this->process_for_command($sms);
$this->logger->info('after command');
@ -254,7 +254,7 @@ class Phone extends AbstractDaemon
$success = msg_send($this->webhook_queue, QUEUE_TYPE_WEBHOOK, $message, true, true, $error_code);
if (!$success)
{
$this->logger->critical('Failed send webhook message in queue, error code : '.$error_code);
$this->logger->critical('Failed send webhook message in queue, error code : ' . $error_code);
}
}
}
@ -280,7 +280,7 @@ class Phone extends AbstractDaemon
return false;
}
$this->logger->info('Transfer sms to '.$user['email'].' : '.json_encode($sms));
$this->logger->info('Transfer sms to ' . $user['email'] . ' : ' . json_encode($sms));
\controllers\internals\Tool::send_email($user['email'], EMAIL_TRANSFER_SMS, ['sms' => $sms]);
}

View File

@ -29,7 +29,7 @@ class Sender extends AbstractDaemon
{
$name = 'RaspiSMS Daemon Sender';
$logger = new Logger($name);
$logger->pushHandler(new StreamHandler(PWD_LOGS.'/raspisms.log', Logger::DEBUG));
$logger->pushHandler(new StreamHandler(PWD_LOGS . '/raspisms.log', Logger::DEBUG));
$pid_dir = PWD_PID;
$no_parent = false; //Webhook should be rattach to manager, so manager can stop him easily
$additional_signals = [];
@ -86,24 +86,24 @@ class Sender extends AbstractDaemon
public function on_start()
{
$this->logger->info('Starting Sender with pid '.getmypid());
$this->logger->info('Starting Sender with pid ' . getmypid());
$this->bdd = \descartes\Model::_connect(DATABASE_HOST, DATABASE_NAME, DATABASE_USER, DATABASE_PASSWORD, 'UTF8');
}
public function on_stop()
{
$this->logger->info('Stopping Sender with pid '.getmypid());
$this->logger->info('Stopping Sender with pid ' . getmypid());
//Delete queues on daemon close
foreach ($this->queues as $queue_id => $queue)
{
$this->logger->info('Closing queue : '.$queue_id);
$this->logger->info('Closing queue : ' . $queue_id);
msg_remove_queue($queue);
}
}
public function handle_other_signals($signal)
{
$this->logger->info('Signal not handled by '.$this->name.' Daemon : '.$signal);
$this->logger->info('Signal not handled by ' . $this->name . ' Daemon : ' . $signal);
}
}

View File

@ -34,7 +34,7 @@ class Webhook extends AbstractDaemon
{
$name = 'RaspiSMS Daemon Webhook';
$logger = new Logger($name);
$logger->pushHandler(new StreamHandler(PWD_LOGS.'/raspisms.log', Logger::DEBUG));
$logger->pushHandler(new StreamHandler(PWD_LOGS . '/raspisms.log', Logger::DEBUG));
$pid_dir = PWD_PID;
$no_parent = false; //Sended should be rattach to manager, so manager can stop him easily
$additional_signals = [];
@ -60,7 +60,7 @@ class Webhook extends AbstractDaemon
$success = msg_receive($this->webhook_queue, QUEUE_TYPE_WEBHOOK, $msgtype, $maxsize, $message, true, 0, $error_code);
if (!$success)
{
$this->logger->critical('Error for webhook queue reading, error code : '.$error_code);
$this->logger->critical('Error for webhook queue reading, error code : ' . $error_code);
}
if (!$message)
@ -70,7 +70,7 @@ class Webhook extends AbstractDaemon
continue;
}
$this->logger->info('Trigger webhook : '.json_encode($message));
$this->logger->info('Trigger webhook : ' . json_encode($message));
//Do the webhook http query
$curl = curl_init();
@ -92,20 +92,20 @@ class Webhook extends AbstractDaemon
$this->webhook_queue = msg_get_queue(QUEUE_ID_WEBHOOK);
$this->logger->info('Starting Webhook daemon with pid '.getmypid());
$this->logger->info('Starting Webhook daemon with pid ' . getmypid());
}
public function on_stop()
{
//Delete queue on daemon close
$this->logger->info('Closing queue : '.QUEUE_ID_WEBHOOK);
$this->logger->info('Closing queue : ' . QUEUE_ID_WEBHOOK);
msg_remove_queue($this->webhook_queue);
$this->logger->info('Stopping Webhook daemon with pid '.getmypid());
$this->logger->info('Stopping Webhook daemon with pid ' . getmypid());
}
public function handle_other_signals($signal)
{
$this->logger->info('Signal not handled by '.$this->name.' Daemon : '.$signal);
$this->logger->info('Signal not handled by ' . $this->name . ' Daemon : ' . $signal);
}
}

View File

@ -27,7 +27,7 @@ namespace models;
public function get_for_user(int $id_user, int $id)
{
$query = '
SELECT * FROM `'.$this->get_table_name().'`
SELECT * FROM `' . $this->get_table_name() . '`
WHERE id_scheduled IN (SELECT id FROM scheduled WHERE id_user = :id_user)
AND id = :id
';
@ -52,7 +52,7 @@ namespace models;
public function gets_for_user(int $id_user)
{
$query = '
SELECT * FROM `'.$this->get_table_name().'`
SELECT * FROM `' . $this->get_table_name() . '`
WHERE id_scheduled IN (SELECT id FROM scheduled WHERE id_user = :id_user)
';
@ -74,7 +74,7 @@ namespace models;
public function get_for_scheduled_and_user(int $id_user, int $id_scheduled)
{
$query = '
SELECT * FROM `'.$this->get_table_name().'`
SELECT * FROM `' . $this->get_table_name() . '`
WHERE id_scheduled IN (SELECT id FROM scheduled WHERE id_user = :id_user)
AND id_scheduled = :id_scheduled
';
@ -108,7 +108,7 @@ namespace models;
$query = '
SELECT * FROM media
WHERE id_scheduled IN (SELECT id FROM scheduled WHERE id_user = :id_user)
LIMIT '.$limit.' OFFSET '.$offset;
LIMIT ' . $limit . ' OFFSET ' . $offset;
$params = [
'id_user' => $id_user,
@ -200,13 +200,13 @@ namespace models;
foreach ($datas as $label => $value)
{
$label = preg_replace('#[^a-zA-Z0-9_]#', '', $label);
$params['set_'.$label] = $value;
$sets[] = '`'.$label.'` = :set_'.$label.' ';
$params['set_' . $label] = $value;
$sets[] = '`' . $label . '` = :set_' . $label . ' ';
}
$query = '
UPDATE `media`
SET '.implode(', ', $sets).'
SET ' . implode(', ', $sets) . '
WHERE id = :id
AND id_scheduled IN (SELECT id FROM scheduled WHERE id_user = :id_user)
';

View File

@ -27,7 +27,7 @@ namespace models;
public function get_for_user(int $id_user, int $id)
{
$query = '
SELECT * FROM `'.$this->get_table_name().'`
SELECT * FROM `' . $this->get_table_name() . '`
WHERE destination IN (SELECT number FROM phone WHERE id_user = :id_user)
AND id = :id
';
@ -52,7 +52,7 @@ namespace models;
public function gets_for_user(int $id_user)
{
$query = '
SELECT * FROM `'.$this->get_table_name().'`
SELECT * FROM `' . $this->get_table_name() . '`
WHERE destination IN (SELECT number FROM phone WHERE id_user = :id_user)
';
@ -78,7 +78,7 @@ namespace models;
$query = '
SELECT * FROM received
WHERE destination IN (SELECT number FROM phone WHERE id_user = :id_user)
LIMIT '.$limit.' OFFSET '.$offset;
LIMIT ' . $limit . ' OFFSET ' . $offset;
$params = [
'id_user' => $id_user,
@ -103,7 +103,7 @@ namespace models;
SELECT * FROM received
WHERE destination IN (SELECT number FROM phone WHERE id_user = :id_user)
AND status = \'unread\'
LIMIT '.$limit.' OFFSET '.$offset;
LIMIT ' . $limit . ' OFFSET ' . $offset;
$params = [
'id_user' => $id_user,
@ -174,13 +174,13 @@ namespace models;
foreach ($datas as $label => $value)
{
$label = preg_replace('#[^a-zA-Z0-9_]#', '', $label);
$params['set_'.$label] = $value;
$sets[] = '`'.$label.'` = :set_'.$label.' ';
$params['set_' . $label] = $value;
$sets[] = '`' . $label . '` = :set_' . $label . ' ';
}
$query = '
UPDATE `received`
SET '.implode(', ', $sets).'
SET ' . implode(', ', $sets) . '
WHERE id = :id
AND destination IN (SELECT number FROM phone WHERE id_user = :id_user)
';
@ -259,7 +259,7 @@ namespace models;
FROM received
WHERE destination IN (SELECT number FROM phone WHERE id_user = :id_user)
ORDER BY at ASC
LIMIT '.$nb_entry;
LIMIT ' . $nb_entry;
$params = [
'id_user' => $id_user,

View File

@ -27,7 +27,7 @@ namespace models;
public function get_for_user(int $id_user, int $id)
{
$query = '
SELECT * FROM `'.$this->get_table_name().'`
SELECT * FROM `' . $this->get_table_name() . '`
WHERE origin IN (SELECT number FROM phone WHERE id_user = :id_user)
AND id = :id
';
@ -52,7 +52,7 @@ namespace models;
public function gets_for_user(int $id_user)
{
$query = '
SELECT * FROM `'.$this->get_table_name().'`
SELECT * FROM `' . $this->get_table_name() . '`
WHERE origin IN (SELECT number FROM phone WHERE id_user = :id_user)
';
@ -78,7 +78,7 @@ namespace models;
$query = '
SELECT * FROM sended
WHERE origin IN (SELECT number FROM phone WHERE id_user = :id_user)
LIMIT '.$limit.' OFFSET '.$offset;
LIMIT ' . $limit . ' OFFSET ' . $offset;
$params = [
'id_user' => $id_user,
@ -149,13 +149,13 @@ namespace models;
foreach ($datas as $label => $value)
{
$label = preg_replace('#[^a-zA-Z0-9_]#', '', $label);
$params['set_'.$label] = $value;
$sets[] = '`'.$label.'` = :set_'.$label.' ';
$params['set_' . $label] = $value;
$sets[] = '`' . $label . '` = :set_' . $label . ' ';
}
$query = '
UPDATE `sended`
SET '.implode(', ', $sets).'
SET ' . implode(', ', $sets) . '
WHERE id = :id
AND origin IN (SELECT number FROM phone WHERE id_user = :id_user)
';
@ -211,7 +211,7 @@ namespace models;
FROM sended
WHERE origin IN (SELECT number FROM phone WHERE id_user = :id_user)
ORDER BY at ASC
LIMIT '.$nb_entry;
LIMIT ' . $nb_entry;
$params = [
'id_user' => $id_user,

View File

@ -94,7 +94,7 @@ namespace models;
}
$query = '
SELECT * FROM `'.$this->get_table_name().'`
SELECT * FROM `' . $this->get_table_name() . '`
WHERE id_user = :id_user
AND id ';

View File

@ -24,8 +24,10 @@ $config = PhpCsFixer\Config::create()
'@PhpCsFixer:risky' => true,
'header_comment' => ['header' => $header],
'list_syntax' => ['syntax' => 'long'],
'array_syntax' => ['syntax' => 'short'],
'mb_str_functions' => true,
'method_separation' => true,
'concat_space' => ['spacing' => 'one'],
'braces' => [
'position_after_anonymous_constructs' => 'next',
'position_after_control_structures' => 'next',