From 6cafd52715c8b3c118ab984afb9e79d1f2fa0760 Mon Sep 17 00:00:00 2001 From: Jim Seconde Date: Tue, 24 Sep 2024 15:24:54 +0100 Subject: [PATCH] Application API type hints --- src/Application/Application.php | 27 ++++++--------------------- src/Application/MessagesConfig.php | 5 +---- src/Application/RtcConfig.php | 5 +---- src/Application/VbcConfig.php | 5 +---- src/Application/VoiceConfig.php | 5 +---- src/Client/Callback/Callback.php | 15 +++------------ src/Network/Number/Callback.php | 2 +- 7 files changed, 14 insertions(+), 50 deletions(-) diff --git a/src/Application/Application.php b/src/Application/Application.php index 6326fca4..3f3eed30 100644 --- a/src/Application/Application.php +++ b/src/Application/Application.php @@ -22,32 +22,17 @@ class Application implements EntityInterface, JsonSerializable, ArrayHydrateInte use Psr7Trait; use JsonResponseTrait; - /** - * @var VoiceConfig - */ - protected $voiceConfig; + protected VoiceConfig $voiceConfig; - /** - * @var MessagesConfig - */ - protected $messagesConfig; + protected MessagesConfig $messagesConfig; - /** - * @var RtcConfig - */ - protected $rtcConfig; + protected RtcConfig $rtcConfig; - /** - * @var VbcConfig - */ - protected $vbcConfig; + protected VbcConfig $vbcConfig; - protected $name; + protected ?string $name = null; - /** - * @var array - */ - protected $keys = []; + protected array $keys = []; public function __construct(protected ?string $id = null) { diff --git a/src/Application/MessagesConfig.php b/src/Application/MessagesConfig.php index b462e1d2..59b5cfe2 100644 --- a/src/Application/MessagesConfig.php +++ b/src/Application/MessagesConfig.php @@ -11,10 +11,7 @@ class MessagesConfig public const INBOUND = 'inbound_url'; public const STATUS = 'status_url'; - /** - * @var array - */ - protected $webhooks = []; + protected array $webhooks = []; public function setWebhook($type, $url, $method = null): self { diff --git a/src/Application/RtcConfig.php b/src/Application/RtcConfig.php index dd49226a..7c832074 100644 --- a/src/Application/RtcConfig.php +++ b/src/Application/RtcConfig.php @@ -10,10 +10,7 @@ class RtcConfig { public const EVENT = 'event_url'; - /** - * @var array - */ - protected $webhooks = []; + protected array $webhooks = []; public function setWebhook($type, $url, $method = null): self { diff --git a/src/Application/VbcConfig.php b/src/Application/VbcConfig.php index da0c9ac7..b3e12a6c 100644 --- a/src/Application/VbcConfig.php +++ b/src/Application/VbcConfig.php @@ -6,10 +6,7 @@ class VbcConfig { - /** - * @var bool - */ - protected $enabled = false; + protected bool $enabled = false; public function enable(): void { diff --git a/src/Application/VoiceConfig.php b/src/Application/VoiceConfig.php index 2ef39389..b957b317 100644 --- a/src/Application/VoiceConfig.php +++ b/src/Application/VoiceConfig.php @@ -23,10 +23,7 @@ class VoiceConfig 'apac-australia' ]; - /** - * @var array - */ - protected $webhooks = []; + protected array $webhooks = []; public function setWebhook($type, $url, $method = null): self { diff --git a/src/Client/Callback/Callback.php b/src/Client/Callback/Callback.php index 081357db..5ff2e9ea 100644 --- a/src/Client/Callback/Callback.php +++ b/src/Client/Callback/Callback.php @@ -19,15 +19,9 @@ class Callback implements CallbackInterface public const ENV_POST = 'post'; public const ENV_GET = 'get'; - /** - * @var array - */ - protected $expected = []; + protected array $expected = []; - /** - * @var array - */ - protected $data; + protected array $data; public function __construct(array $data) { @@ -46,10 +40,7 @@ public function getData(): array return $this->data; } - /** - * @return Callback|callable - */ - public static function fromEnv(string $source = self::ENV_ALL) + public static function fromEnv(string $source = self::ENV_ALL): callable|Callback { $data = match (strtolower($source)) { 'post' => $_POST, diff --git a/src/Network/Number/Callback.php b/src/Network/Number/Callback.php index 64e7c1e8..de14520e 100644 --- a/src/Network/Number/Callback.php +++ b/src/Network/Number/Callback.php @@ -31,7 +31,7 @@ */ class Callback extends BaseCallback { - protected $expected = ['request_id', 'callback_part', 'callback_total_parts', 'number', 'status']; + protected array $expected = ['request_id', 'callback_part', 'callback_total_parts', 'number', 'status']; protected $optional = [ 'Type' => 'number_type', 'Network' => 'carrier_network_code',