diff --git a/.gitignore b/.gitignore index e0f2848..2b007f4 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ .credentials .credentials* vendor/ +scripts/ composer.lock env.* phinx.* diff --git a/VERSION b/VERSION index e711991..5e333f9 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v3.0.7 +v3.0.8 diff --git a/adapters/AdapterInterface.php b/adapters/AdapterInterface.php index eb3ec75..8760620 100644 --- a/adapters/AdapterInterface.php +++ b/adapters/AdapterInterface.php @@ -39,8 +39,8 @@ namespace adapters; public static function meta_uid(): string; /** - * Should this adapter be hidden in user interface for phone creation and - * available to creation through API only + * Should this adapter be hidden in user interface for phone creation and + * available to creation through API only. */ public static function meta_hidden(): bool; diff --git a/adapters/BenchmarkAdapter.php b/adapters/BenchmarkAdapter.php index 866d9bd..e874c8f 100644 --- a/adapters/BenchmarkAdapter.php +++ b/adapters/BenchmarkAdapter.php @@ -56,10 +56,10 @@ namespace adapters; { return 'benchmark_adapter'; } - + /** * Should this adapter be hidden in user interface for phone creation and - * available to creation through API only + * available to creation through API only. */ public static function meta_hidden(): bool { diff --git a/adapters/GammuAdapter.php b/adapters/GammuAdapter.php index e6a2e95..2554bf7 100644 --- a/adapters/GammuAdapter.php +++ b/adapters/GammuAdapter.php @@ -51,17 +51,16 @@ namespace adapters; { return 'gammu_adapter'; } - + /** * Should this adapter be hidden in user interface for phone creation and - * available to creation through API only + * available to creation through API only. */ public static function meta_hidden(): bool { return false; } - /** * Name of the adapter. * It should probably be the name of the service it adapt (e.g : Gammu SMSD, OVH SMS, SIM800L, etc.). diff --git a/adapters/OctopushShortcodeAdapter.php b/adapters/OctopushShortcodeAdapter.php index dacb914..667a872 100644 --- a/adapters/OctopushShortcodeAdapter.php +++ b/adapters/OctopushShortcodeAdapter.php @@ -50,7 +50,7 @@ class OctopushShortcodeAdapter implements AdapterInterface * Adapter constructor, called when instanciated by RaspiSMS. * * @param string $number : Phone number the adapter is used for - * @param json string $data : JSON string of the data to configure interaction with the implemented service + * @param json string $data : JSON string of the data to configure interaction with the implemented service */ public function __construct(string $data) { @@ -77,10 +77,10 @@ class OctopushShortcodeAdapter implements AdapterInterface { return 'octopush_shortcode_adapter'; } - + /** * Should this adapter be hidden in user interface for phone creation and - * available to creation through API only + * available to creation through API only. */ public static function meta_hidden(): bool { diff --git a/adapters/OctopushVirtualNumberAdapter.php b/adapters/OctopushVirtualNumberAdapter.php index 03151e9..1fc5305 100644 --- a/adapters/OctopushVirtualNumberAdapter.php +++ b/adapters/OctopushVirtualNumberAdapter.php @@ -55,7 +55,7 @@ class OctopushVirtualNumberAdapter implements AdapterInterface * Adapter constructor, called when instanciated by RaspiSMS. * * @param string $number : Phone number the adapter is used for - * @param json string $data : JSON string of the data to configure interaction with the implemented service + * @param json string $data : JSON string of the data to configure interaction with the implemented service */ public function __construct(string $data) { @@ -83,10 +83,10 @@ class OctopushVirtualNumberAdapter implements AdapterInterface { return 'octopush_virtual_number_adapter'; } - + /** * Should this adapter be hidden in user interface for phone creation and - * available to creation through API only + * available to creation through API only. */ public static function meta_hidden(): bool { diff --git a/adapters/OvhSmsShortcodeAdapter.php b/adapters/OvhSmsShortcodeAdapter.php index a2b179c..dd68aff 100644 --- a/adapters/OvhSmsShortcodeAdapter.php +++ b/adapters/OvhSmsShortcodeAdapter.php @@ -32,7 +32,7 @@ namespace adapters; * Adapter constructor, called when instanciated by RaspiSMS. * * @param string $number : Phone number the adapter is used for - * @param json string $data : JSON string of the data to configure interaction with the implemented service + * @param json string $data : JSON string of the data to configure interaction with the implemented service */ public function __construct(string $data) { @@ -62,10 +62,10 @@ namespace adapters; { return 'ovh_sms_shortcode_adapter'; } - + /** * Should this adapter be hidden in user interface for phone creation and - * available to creation through API only + * available to creation through API only. */ public static function meta_hidden(): bool { diff --git a/adapters/OvhSmsVirtualNumberAdapter.php b/adapters/OvhSmsVirtualNumberAdapter.php index 6563b2b..1217295 100644 --- a/adapters/OvhSmsVirtualNumberAdapter.php +++ b/adapters/OvhSmsVirtualNumberAdapter.php @@ -74,10 +74,10 @@ namespace adapters; { return 'ovh_sms_virtual_number_adapter'; } - + /** * Should this adapter be hidden in user interface for phone creation and - * available to creation through API only + * available to creation through API only. */ public static function meta_hidden(): bool { diff --git a/adapters/TestAdapter.php b/adapters/TestAdapter.php index 99759fb..2851fb6 100644 --- a/adapters/TestAdapter.php +++ b/adapters/TestAdapter.php @@ -61,10 +61,10 @@ namespace adapters; { return 'test_adapter'; } - + /** * Should this adapter be hidden in user interface for phone creation and - * available to creation through API only + * available to creation through API only. */ public static function meta_hidden(): bool { diff --git a/adapters/TwilioVirtualNumberAdapter.php b/adapters/TwilioVirtualNumberAdapter.php index 6ccc914..2835d84 100644 --- a/adapters/TwilioVirtualNumberAdapter.php +++ b/adapters/TwilioVirtualNumberAdapter.php @@ -42,7 +42,7 @@ class TwilioVirtualNumberAdapter implements AdapterInterface * Adapter constructor, called when instanciated by RaspiSMS. * * @param string $number : Phone number the adapter is used for - * @param json string $data : JSON string of the data to configure interaction with the implemented service + * @param json string $data : JSON string of the data to configure interaction with the implemented service */ public function __construct(string $data) { @@ -73,10 +73,10 @@ class TwilioVirtualNumberAdapter implements AdapterInterface { return 'twilio_virtual_number_adapter'; } - + /** * Should this adapter be hidden in user interface for phone creation and - * available to creation through API only + * available to creation through API only. */ public static function meta_hidden(): bool { diff --git a/controllers/internals/Command.php b/controllers/internals/Command.php index aee4757..10f10c5 100644 --- a/controllers/internals/Command.php +++ b/controllers/internals/Command.php @@ -99,7 +99,7 @@ namespace controllers\internals; //Check for user $internal_user = new \controllers\internals\User($this->bdd); $user = $internal_user->check_credentials($decode_message['login'], $decode_message['password']); - if (!$user || $user['id'] !== $id_user) + if (!$user || (int) $user['id'] !== $id_user) { return false; } diff --git a/controllers/internals/Console.php b/controllers/internals/Console.php index 0ce0ac1..ccb48b6 100644 --- a/controllers/internals/Console.php +++ b/controllers/internals/Console.php @@ -71,8 +71,6 @@ namespace controllers\internals; * Check if a user exists based on email. * * @param string $email : User email - * - * @return void : exit code 1 on false, 0 else */ public function user_exists(string $email) { diff --git a/controllers/internals/Contact.php b/controllers/internals/Contact.php index 7528465..502299e 100644 --- a/controllers/internals/Contact.php +++ b/controllers/internals/Contact.php @@ -59,7 +59,7 @@ namespace controllers\internals; * @param int $id_user : User id * @param string $number : Contact number * @param string $name : Contact name - * @param string $data : Contact data + * @param string $data : Contact data * * @return mixed bool|int : False if cannot create contact, id of the new contact else */ @@ -91,7 +91,7 @@ namespace controllers\internals; * @param int $id : Contact id * @param string $number : Contact number * @param string $name : Contact name - * @param ?string $data : Contact data + * @param ?string $data : Contact data * * @return int : number of modified rows */ @@ -135,7 +135,7 @@ namespace controllers\internals; //Padding line with '' entries to make sure its same length as head //this allow to mix users with data with users without data - $line = array_pad($line, count($head), ''); + $line = array_pad($line, \count($head), ''); $line = array_combine($head, $line); if (false === $line) @@ -282,15 +282,16 @@ namespace controllers\internals; $data = json_decode($contact['data'], true); $line = [$contact['name'], $contact['number']]; - foreach (array_slice($columns, 2) as $column) //ignore first two columns as it's alway name & number - { + foreach (\array_slice($columns, 2) as $column) + { //ignore first two columns as it's alway name & number //If their is no data for this column key, we set '' to ignore if (!isset($data[$column])) { $line[] = ''; + continue; } - + $line[] = $data[$column]; } $lines[] = $line; diff --git a/controllers/internals/ExpressionProvider.php b/controllers/internals/ExpressionProvider.php index fa40361..7ee1f9c 100644 --- a/controllers/internals/ExpressionProvider.php +++ b/controllers/internals/ExpressionProvider.php @@ -27,7 +27,7 @@ class ExpressionProvider implements ExpressionFunctionProviderInterface { return null; }); - + //Exists must be personnalized because it inverse is_null $exists = new ExpressionFunction('exists', function ($str) { diff --git a/controllers/internals/Mailer.php b/controllers/internals/Mailer.php index cb25aa2..2df5d3c 100755 --- a/controllers/internals/Mailer.php +++ b/controllers/internals/Mailer.php @@ -100,7 +100,7 @@ class Mailer extends \descartes\Controller * * @param string $destination : email address to send email to * @param array $settings : Email settings - * @param array $data : Data to inject into email template + * @param array $data : Data to inject into email template * * @return bool : true on success, false on error */ diff --git a/controllers/internals/Phone.php b/controllers/internals/Phone.php index fe976d1..63a0b96 100644 --- a/controllers/internals/Phone.php +++ b/controllers/internals/Phone.php @@ -55,9 +55,9 @@ namespace controllers\internals; /** * Create a phone. * - * @param int $id_user : User to insert phone for - * @param string $name : The name of the phone - * @param string $adapter : The adapter to use the phone + * @param int $id_user : User to insert phone for + * @param string $name : The name of the phone + * @param string $adapter : The adapter to use the phone * @param string json $adapter_data : A JSON string representing adapter's data (for example credentials for an api) * * @return bool|int : false on error, new id on success @@ -77,10 +77,10 @@ namespace controllers\internals; /** * Update a phone. * - * @param int $id_user : User to insert phone for - * @param int $id : Phone id - * @param string $name : The name of the phone - * @param string $adapter : The adapter to use the phone + * @param int $id_user : User to insert phone for + * @param int $id : Phone id + * @param string $name : The name of the phone + * @param string $adapter : The adapter to use the phone * @param array $adapter_data : An array of the data of the adapter (for example credentials for an api) * * @return bool : false on error, true on success diff --git a/controllers/internals/Ruler.php b/controllers/internals/Ruler.php index ed61dc1..1ec9a22 100644 --- a/controllers/internals/Ruler.php +++ b/controllers/internals/Ruler.php @@ -35,7 +35,7 @@ use Symfony\Component\ExpressionLanguage\ExpressionLanguage; * Verify if a condition is valid. i.e we can evaluate it without error. * * @param string $condition : The condition to evaluate - * @param array $data : The data to made available to condition + * @param array $data : The data to made available to condition * * @return bool : false if invalid, true else */ @@ -61,7 +61,7 @@ use Symfony\Component\ExpressionLanguage\ExpressionLanguage; * Evaluate a condition. * * @param string $condition : The condition to evaluate - * @param array $data : The data to made available to condition + * @param array $data : The data to made available to condition * * @return ?bool : false if invalid, true else, null only on error */ diff --git a/controllers/internals/Templating.php b/controllers/internals/Templating.php index 12cffe1..e10019f 100644 --- a/controllers/internals/Templating.php +++ b/controllers/internals/Templating.php @@ -57,7 +57,7 @@ namespace controllers\internals; * Render a string as a twig template. * * @param string $template : Template string - * @param array $data : Data to pass to the template + * @param array $data : Data to pass to the template * * @return array : keys, success, error, result */ diff --git a/controllers/internals/Webhook.php b/controllers/internals/Webhook.php index 6f2c59b..8d25108 100644 --- a/controllers/internals/Webhook.php +++ b/controllers/internals/Webhook.php @@ -126,10 +126,10 @@ class Webhook extends StandardController { $timestamp = time(); $webhook_random_id = $timestamp . '-' . bin2hex(openssl_random_pseudo_bytes(16)); - + //signature is hexa string representing hmac sha256 of webhook_random_id $webhook_signature = hash_hmac(self::HMAC_ALGO, $webhook_random_id, $user['api_key']); - + $message = [ 'url' => $webhook['url'], 'data' => [ diff --git a/controllers/publics/Api.php b/controllers/publics/Api.php index 4039aa6..02b09d7 100644 --- a/controllers/publics/Api.php +++ b/controllers/publics/Api.php @@ -309,8 +309,8 @@ namespace controllers\publics; /** * Create a new phone. * - * @param string $_POST['name'] : Phone name - * @param string $_POST['adapter'] : Phone adapter + * @param string $_POST['name'] : Phone name + * @param string $_POST['adapter'] : Phone adapter * @param array $_POST['adapter_data'] : Phone adapter data * * @return int : id phone the new phone on success diff --git a/controllers/publics/Phone.php b/controllers/publics/Phone.php index 4ecd873..329572a 100644 --- a/controllers/publics/Phone.php +++ b/controllers/publics/Phone.php @@ -157,8 +157,8 @@ class Phone extends \descartes\Controller * Create a new phone. * * @param $csrf : CSRF token - * @param string $_POST['name'] : Phone name - * @param string $_POST['adapter'] : Phone adapter + * @param string $_POST['name'] : Phone name + * @param string $_POST['adapter'] : Phone adapter * @param array $_POST['adapter_data'] : Phone adapter data */ public function create($csrf) diff --git a/controllers/publics/Scheduled.php b/controllers/publics/Scheduled.php index 4bff35c..8f270df 100644 --- a/controllers/publics/Scheduled.php +++ b/controllers/publics/Scheduled.php @@ -96,8 +96,8 @@ namespace controllers\publics; /** * Cette fonction retourne la page d'ajout d'un scheduled. * - * @param array? int $contacts_ids : Ids of contacts to prefilled - * @param array? int $groups_ids : Ids of groups to prefilled + * @param array? int $contacts_ids : Ids of contacts to prefilled + * @param array? int $groups_ids : Ids of groups to prefilled * @param array? int $conditional_groups_ids : Ids of conditional groups to prefilled * @param $prefilled : If we have prefilled some fields (possible values : 'contacts', 'groups', 'conditional_groups', false) */ @@ -112,9 +112,9 @@ namespace controllers\publics; $contacts = $this->internal_contact->gets_for_user($id_user); $phones = $this->internal_phone->gets_for_user($id_user); - $contact_ids = (isset($_GET['contact_ids']) && is_array($_GET['contact_ids'])) ? $_GET['contact_ids'] : []; - $group_ids = (isset($_GET['group_ids']) && is_array($_GET['group_ids'])) ? $_GET['group_ids'] : []; - $conditional_group_ids = (isset($_GET['conditional_group_ids']) && is_array($_GET['conditional_group_ids'])) ? $_GET['conditional_group_ids'] : []; + $contact_ids = (isset($_GET['contact_ids']) && \is_array($_GET['contact_ids'])) ? $_GET['contact_ids'] : []; + $group_ids = (isset($_GET['group_ids']) && \is_array($_GET['group_ids'])) ? $_GET['group_ids'] : []; + $conditional_group_ids = (isset($_GET['conditional_group_ids']) && \is_array($_GET['conditional_group_ids'])) ? $_GET['conditional_group_ids'] : []; $prefilled_contacts = []; $prefilled_groups = []; diff --git a/models/Media.php b/models/Media.php index dc92645..7b7cd83 100644 --- a/models/Media.php +++ b/models/Media.php @@ -188,7 +188,7 @@ namespace models; * * @param int $id_user : User id * @param int $id : Entry id - * @param array $data : data to update + * @param array $data : data to update * * @return int : number of modified rows */ diff --git a/models/StandardModel.php b/models/StandardModel.php index f6eea2a..32b9686 100644 --- a/models/StandardModel.php +++ b/models/StandardModel.php @@ -154,7 +154,7 @@ namespace models; * * @param int $id_user : User id * @param int $id : Entry id - * @param array $data : data to update + * @param array $data : data to update * * @return int : number of modified rows */ @@ -166,7 +166,7 @@ namespace models; /** * Update a entry by his id. * - * @param int $id : Entry id + * @param int $id : Entry id * @param array $data : data to update * * @return int : number of modified rows diff --git a/models/User.php b/models/User.php index f6c70f0..f48274f 100644 --- a/models/User.php +++ b/models/User.php @@ -95,7 +95,7 @@ namespace models; /** * Update a user using his is. * - * @param int $id : User id + * @param int $id : User id * @param array $data : Data to update * * @return int : number of modified rows diff --git a/tests/php-cs-fixer/php_cs.config b/tests/php-cs-fixer/php_cs.config index d364092..4b661e9 100644 --- a/tests/php-cs-fixer/php_cs.config +++ b/tests/php-cs-fixer/php_cs.config @@ -25,7 +25,7 @@ $config = PhpCsFixer\Config::create() '@PHP56Migration' => true, '@PHPUnit60Migration:risky' => true, '@PhpCsFixer' => true, - '@PhpCsFixer:risky' => true, + '@PhpCsFixer:risky' => false, 'header_comment' => ['header' => $header], 'list_syntax' => ['syntax' => 'long'], 'array_syntax' => ['syntax' => 'short'],