Skip to content

Commit 51c92e7

Browse files
committed
Type declarations
1 parent 05775bb commit 51c92e7

File tree

8 files changed

+40
-40
lines changed

8 files changed

+40
-40
lines changed

src/Group.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
class Group extends Model
1414
{
1515
/**
16-
* @var int
16+
* @var int|null
1717
*/
18-
public $id;
18+
public ?int $id = null;
1919

2020
/**
21-
* @var string
21+
* @var string|null
2222
*/
23-
public $name;
23+
public ?string $name = null;
2424

2525
/**
2626
* @inheritdoc

src/Plugin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class Plugin extends \craft\base\Plugin
9999
* @see request()
100100
* @since 2.3.0
101101
*/
102-
private $_pendingJobs = [];
102+
private array $_pendingJobs = [];
103103

104104
/**
105105
* @inheritdoc

src/SendRequestJob.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ class SendRequestJob extends BaseJob
1818
/**
1919
* @var int The request ID to send
2020
*/
21-
public $requestId;
21+
public int $requestId;
2222

2323
/**
2424
* @var int|null The webhook ID
2525
*/
26-
public $webhookId;
26+
public ?int $webhookId = null;
2727

2828
/**
2929
* @inheritdoc
@@ -79,7 +79,7 @@ private function _data(): array
7979
*
8080
* @return Webhook|null
8181
*/
82-
private function _webhook()
82+
private function _webhook(): ?Webhook
8383
{
8484
if (!$this->webhookId) {
8585
return null;

src/Settings.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,43 +11,43 @@ class Settings extends Model
1111
* @var bool Whether all webhooks should be disabled.
1212
* @since 2.4.1
1313
*/
14-
public $disableAllWebhooks = false;
14+
public bool $disableAllWebhooks = false;
1515

1616
/**
1717
* @var int The maximum depth that the plugin should go into objects/arrays when converting them to arrays for
1818
* event payloads.
1919
*/
20-
public $maxDepth = 5;
20+
public int $maxDepth = 5;
2121

2222
/**
2323
* @var int The maximum number of request attempts that should be made.
2424
*/
25-
public $maxAttempts = 1;
25+
public int $maxAttempts = 1;
2626

2727
/**
2828
* @var int|null The time delay in seconds that initial webhook request attempts should have.
2929
* @since 2.4.0
3030
*/
31-
public $initialDelay;
31+
public ?int $initialDelay = null;
3232

3333
/**
3434
* @var int The time delay in seconds between request retries.
3535
* @since 2.3.0
3636
*/
37-
public $retryDelay = 60;
37+
public int $retryDelay = 60;
3838

3939
/**
4040
* @var int|null The time (in seconds) that request history should be saved in the database before being
4141
* deletable via garbage collection.
4242
* @since 3.4.0
4343
*/
44-
public $purgeDuration = 604800;
44+
public ?int $purgeDuration = 604800;
4545

4646
/**
4747
* @var array Custom config options that should be applied when creating Guzzle clients.
4848
* @since 2.3.0
4949
*/
50-
public $guzzleConfig = [];
50+
public array $guzzleConfig = [];
5151

5252
/**
5353
* @inheritdoc

src/Webhook.php

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,84 +19,84 @@
1919
class Webhook extends Model
2020
{
2121
/**
22-
* @var int
22+
* @var int|null
2323
*/
24-
public $id;
24+
public ?int $id = null;
2525

2626
/**
2727
* @var int|null
2828
*/
29-
public $groupId;
29+
public ?int $groupId = null;
3030

3131
/**
3232
* @var bool
3333
*/
34-
public $enabled = true;
34+
public bool $enabled = true;
3535

3636
/**
37-
* @var string
37+
* @var string|null
3838
*/
39-
public $name;
39+
public ?string $name = null;
4040

4141
/**
42-
* @var string
42+
* @var string|null
4343
*/
44-
public $class;
44+
public ?string $class = null;
4545

4646
/**
47-
* @var string
47+
* @var string|null
4848
*/
49-
public $event;
49+
public ?string $event = null;
5050

5151
/**
5252
* @var array
5353
*/
54-
public $filters = [];
54+
public array $filters = [];
5555

5656
/**
5757
* @var string|null
5858
*/
59-
public $debounceKeyFormat;
59+
public ?string $debounceKeyFormat = null;
6060

6161
/**
6262
* @var string
6363
*/
64-
public $method = 'post';
64+
public string $method = 'post';
6565

6666
/**
67-
* @var string
67+
* @var string|null
6868
*/
69-
public $url;
69+
public ?string $url = null;
7070

7171
/**
7272
* @var array
7373
*/
74-
public $headers = [];
74+
public array $headers = [];
7575

7676
/**
7777
* @var string|null
7878
*/
79-
public $userAttributes;
79+
public ?string $userAttributes = null;
8080

8181
/**
8282
* @var string|null
8383
*/
84-
public $senderAttributes;
84+
public ?string $senderAttributes = null;
8585

8686
/**
8787
* @var string|null
8888
*/
89-
public $eventAttributes;
89+
public ?string $eventAttributes = null;
9090

9191
/**
9292
* @var string|null
9393
*/
94-
public $payloadTemplate;
94+
public ?string $payloadTemplate = null;
9595

9696
/**
9797
* @inheritdoc
9898
*/
99-
public function attributeLabels()
99+
public function attributeLabels(): array
100100
{
101101
return [
102102
'class' => Craft::t('webhooks', 'Sender Class'),
@@ -190,7 +190,7 @@ function() {
190190
* @param array|null $params
191191
* @param Validator $validator
192192
*/
193-
public function validateAttributeList(string $attribute, array $params = null, Validator $validator)
193+
public function validateAttributeList(string $attribute, ?array $params, Validator $validator)
194194
{
195195
$regex = $params['regex'] ?? '/^[a-z]\w*(?:\.[a-z]\w*)*$/i';
196196

src/WebhookHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ private static function _findClasses(): array
164164
* @param string $doc
165165
* @return string|null
166166
*/
167-
private static function _shortDesc(string $doc)
167+
private static function _shortDesc(string $doc): ?string
168168
{
169169
foreach (preg_split("/\r\n|\n|\r/", $doc) as $line) {
170170
$line = preg_replace('/^[\/\*\s]*(?:@event\s+[^\s]+\s+)?/', '', $line);

src/controllers/WebhooksController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public function actionEdit(int $id = null, int $groupId = null, Webhook $webhook
112112
* @return Response|null
113113
* @throws BadRequestHttpException
114114
*/
115-
public function actionSave()
115+
public function actionSave(): ?Response
116116
{
117117
$this->requirePostRequest();
118118

src/records/Webhook.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
*/
2727
class Webhook extends ActiveRecord
2828
{
29-
public static function tableName()
29+
public static function tableName(): string
3030
{
3131
return '{{%webhooks}}';
3232
}

0 commit comments

Comments
 (0)