Skip to content

Commit b82de7f

Browse files
Add php type hints and update phpdoc
1 parent 054a6a1 commit b82de7f

29 files changed

+95
-322
lines changed

DelayedEnvelope.php

+2-22
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,16 @@
2727
*/
2828
class DelayedEnvelope extends Envelope
2929
{
30-
/**
31-
* @var bool
32-
*/
33-
private $senderSet = false;
30+
private bool $senderSet = false;
3431

35-
/**
36-
* @var bool
37-
*/
38-
private $recipientsSet = false;
32+
private bool $recipientsSet = false;
3933

4034
/**
4135
* @var Message
4236
*/
4337
private $message;
4438

4539
/**
46-
* Constructor.
47-
*
4840
* @param Message|RawMessage $message The message
4941
*/
5042
public function __construct(RawMessage $message)
@@ -62,19 +54,13 @@ public function __construct(RawMessage $message)
6254
$this->message = $message;
6355
}
6456

65-
/**
66-
* {@inheritdoc}
67-
*/
6857
public function setFrom(Phone $from): void
6958
{
7059
parent::setFrom($from);
7160

7261
$this->senderSet = true;
7362
}
7463

75-
/**
76-
* {@inheritdoc}
77-
*/
7864
public function getFrom(): Phone
7965
{
8066
if ($this->senderSet) {
@@ -88,19 +74,13 @@ public function getFrom(): Phone
8874
throw new LogicException('Unable to determine the sender of the message.');
8975
}
9076

91-
/**
92-
* {@inheritdoc}
93-
*/
9477
public function setRecipients(array $recipients): void
9578
{
9679
parent::setRecipients($recipients);
9780

9881
$this->recipientsSet = \count(parent::getRecipients()) > 0;
9982
}
10083

101-
/**
102-
* {@inheritdoc}
103-
*/
10484
public function getRecipients(): array
10585
{
10686
if ($this->recipientsSet) {

Envelope.php

+2-7
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,14 @@
2121
*/
2222
class Envelope
2323
{
24-
/**
25-
* @var Phone
26-
*/
27-
private $from;
24+
private Phone $from;
2825

2926
/**
3027
* @var Phone[]
3128
*/
32-
private $recipients = [];
29+
private array $recipients = [];
3330

3431
/**
35-
* Constructor.
36-
*
3732
* @param Phone $from The from phone
3833
* @param Phone[] $recipients The recipient phones
3934
*/

Event/AbstractMessageEvent.php

+2-10
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,11 @@
2020
*/
2121
abstract class AbstractMessageEvent extends Event
2222
{
23-
/**
24-
* @var RawMessage
25-
*/
26-
private $message;
23+
private RawMessage $message;
2724

28-
/**
29-
* @var Envelope
30-
*/
31-
private $envelope;
25+
private Envelope $envelope;
3226

3327
/**
34-
* Constructor.
35-
*
3628
* @param RawMessage $message The message
3729
* @param Envelope $envelope The envelope
3830
*/

Event/MessageResultEvent.php

+1-6
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,9 @@
2020
*/
2121
class MessageResultEvent extends AbstractMessageEvent
2222
{
23-
/**
24-
* @var Result
25-
*/
26-
private $result;
23+
private Result $result;
2724

2825
/**
29-
* Constructor.
30-
*
3126
* @param RawMessage $message The message
3227
* @param Envelope $envelope The envelope
3328
* @param Result $result The result

EventListener/MessageListener.php

+2-13
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,11 @@
2222
*/
2323
class MessageListener implements EventSubscriberInterface
2424
{
25-
/**
26-
* @var null|Headers
27-
*/
28-
private $headers;
25+
private ?Headers $headers;
2926

30-
/**
31-
* @var null|BodyRendererInterface
32-
*/
33-
private $renderer;
27+
private ?BodyRendererInterface $renderer;
3428

3529
/**
36-
* Constructor.
37-
*
3830
* @param null|Headers $headers The headers
3931
* @param null|BodyRendererInterface $renderer The body renderer
4032
*/
@@ -44,9 +36,6 @@ public function __construct(?Headers $headers = null, ?BodyRendererInterface $re
4436
$this->renderer = $renderer;
4537
}
4638

47-
/**
48-
* {@inheritdoc}
49-
*/
5039
public static function getSubscribedEvents(): array
5140
{
5241
return [

Exception/TransportResultException.php

+2-7
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,13 @@
2020
*/
2121
class TransportResultException extends RuntimeException implements TransportExceptionInterface
2222
{
23-
/**
24-
* @var Result
25-
*/
26-
private $result;
23+
private Result $result;
2724

2825
/**
29-
* Constructor.
30-
*
3126
* @param Result $result The result
3227
* @param int $code The exception code
3328
*/
34-
public function __construct(Result $result, $code = 0)
29+
public function __construct(Result $result, int $code = 0)
3530
{
3631
parent::__construct($this->buildMessage($result), $code);
3732

Exception/UnsupportedHostException.php

-5
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,6 @@ class UnsupportedHostException extends LogicException
3333
],
3434
];
3535

36-
/**
37-
* Constructor.
38-
*
39-
* @param Dsn $dsn The dsn instance
40-
*/
4136
public function __construct(Dsn $dsn)
4237
{
4338
parent::__construct(static::buildMessage($dsn->getHost(), self::HOST_TO_PACKAGE_MAP));

Exception/UnsupportedSchemeException.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,10 @@
2121
class UnsupportedSchemeException extends LogicException
2222
{
2323
/**
24-
* Constructor.
25-
*
2624
* @param Dsn $dsn The dsn instance
2725
* @param null|string[] $supported The supported schemes
2826
*/
29-
public function __construct(Dsn $dsn, array $supported = null)
27+
public function __construct(Dsn $dsn, ?array $supported = null)
3028
{
3129
$message = sprintf('The "%s" scheme is not supported for SMS Sender "%s".', $dsn->getScheme(), $dsn->getHost());
3230

Messenger/MessageHandler.php

+1-6
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,9 @@
1818
*/
1919
class MessageHandler
2020
{
21-
/**
22-
* @var TransportInterface
23-
*/
24-
private $transport;
21+
private TransportInterface $transport;
2522

2623
/**
27-
* Constructor.
28-
*
2924
* @param TransportInterface $transport The SMS transport
3025
*/
3126
public function __construct(TransportInterface $transport)

Messenger/SendSmsMessage.php

+3-11
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,15 @@
2121
*/
2222
class SendSmsMessage
2323
{
24-
/**
25-
* @var RawMessage
26-
*/
27-
private $message;
24+
private RawMessage $message;
2825

29-
/**
30-
* @var null|Envelope
31-
*/
32-
private $envelope;
26+
private ?Envelope $envelope;
3327

3428
/**
35-
* Constructor.
36-
*
3729
* @param RawMessage $message The message
3830
* @param null|Envelope $envelope The envelope
3931
*/
40-
public function __construct(RawMessage $message, Envelope $envelope = null)
32+
public function __construct(RawMessage $message, ?Envelope $envelope = null)
4133
{
4234
$this->message = $message;
4335
$this->envelope = $envelope;

Mime/Phone.php

+4-18
Original file line numberDiff line numberDiff line change
@@ -27,29 +27,15 @@
2727
*/
2828
final class Phone
2929
{
30-
/**
31-
* @var string
32-
*/
33-
public static $encoderClass = PhoneNumberUtil::class;
30+
public static string $encoderClass = PhoneNumberUtil::class;
3431

35-
/**
36-
* @var PhoneNumberUtil
37-
*/
38-
private static $phoneEncoder;
32+
private static ?PhoneNumberUtil $phoneEncoder = null;
3933

40-
/**
41-
* @var null|IdnAddressEncoder
42-
*/
43-
private static $addressEncoder;
34+
private static ?IdnAddressEncoder $addressEncoder = null;
4435

45-
/**
46-
* @var string
47-
*/
48-
private $phone;
36+
private string $phone;
4937

5038
/**
51-
* Constructor.
52-
*
5339
* @param string $phone The phone
5440
*/
5541
public function __construct(string $phone)

SentMessage.php

+4-18
Original file line numberDiff line numberDiff line change
@@ -22,29 +22,15 @@
2222
*/
2323
class SentMessage
2424
{
25-
/**
26-
* @var RawMessage
27-
*/
28-
private $original;
25+
private RawMessage $original;
2926

30-
/**
31-
* @var RawMessage
32-
*/
33-
private $raw;
27+
private RawMessage $raw;
3428

35-
/**
36-
* @var Envelope
37-
*/
38-
private $envelope;
29+
private Envelope $envelope;
3930

40-
/**
41-
* @var Result
42-
*/
43-
private $result;
31+
private Result $result;
4432

4533
/**
46-
* Constructor.
47-
*
4834
* @param RawMessage $message The message
4935
* @param Envelope $envelope The envelope
5036
* @param Result $result The result wrapper for transport

SmsSender.php

+4-18
Original file line numberDiff line numberDiff line change
@@ -25,32 +25,21 @@
2525
*/
2626
class SmsSender implements SmsSenderInterface
2727
{
28-
/**
29-
* @var TransportInterface
30-
*/
31-
private $transport;
28+
private TransportInterface $transport;
3229

33-
/**
34-
* @var null|MessageBusInterface
35-
*/
36-
private $bus;
30+
private ?MessageBusInterface $bus;
3731

3832
/**
39-
* Constructor.
40-
*
4133
* @param TransportInterface $transport The transport
4234
* @param null|MessageBusInterface $bus The message bus
4335
*/
44-
public function __construct(TransportInterface $transport, MessageBusInterface $bus = null)
36+
public function __construct(TransportInterface $transport, ?MessageBusInterface $bus = null)
4537
{
4638
$this->transport = $transport;
4739
$this->bus = $bus;
4840
}
4941

50-
/**
51-
* {@inheritdoc}
52-
*/
53-
public function send(RawMessage $message, Envelope $envelope = null): void
42+
public function send(RawMessage $message, ?Envelope $envelope = null): void
5443
{
5544
if ($message instanceof Message && $this->hasRequiredFrom() && !$message->getHeaders()->has('From')) {
5645
throw new TransportException('The transport required the "From" information');
@@ -65,9 +54,6 @@ public function send(RawMessage $message, Envelope $envelope = null): void
6554
$this->bus->dispatch(new SendSmsMessage($message, $envelope));
6655
}
6756

68-
/**
69-
* {@inheritdoc}
70-
*/
7157
public function hasRequiredFrom(): bool
7258
{
7359
return $this->transport->hasRequiredFrom();

SmsSenderInterface.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ interface SmsSenderInterface
2929
*
3030
* @throws TransportExceptionInterface
3131
*/
32-
public function send(RawMessage $message, Envelope $envelope = null): void;
32+
public function send(RawMessage $message, ?Envelope $envelope = null): void;
3333

3434
/**
3535
* Check if the transport has a required from phone.

Tests/Transport/ErrorResultTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@ public function testGettersAndSetters(): void
3838
static::assertSame($message, $result->getMessage());
3939
static::assertSame($code, $result->getCode());
4040
static::assertSame($data, $result->getData());
41-
static::assertSame($exception, $result->getException());
41+
static::assertSame($exception, $result->getThrowable());
4242
}
4343
}

0 commit comments

Comments
 (0)