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

@ -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);
}
}