Skip to content

Commit 0c50103

Browse files
authored
Add returntypes where possible (#48)
* In case the exact returntype is not yet possible, add it in docblock with a ReturnTypeWillChange-attribute. * Changed some instances of "static public function foo()" to "public static function foo()". * Added "public" to all constants which were public implicitly
1 parent 122fd5f commit 0c50103

24 files changed

+118
-95
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
},
1414
"require-dev": {
1515
"swiftmailer/swiftmailer": "^6.1",
16-
"phpunit/phpunit": "^8.3"
16+
"phpunit/phpunit": "^8.3",
17+
"pear/pear-core-minimal": "^1.10"
1718
},
1819
"suggest": {
1920
"swiftmailer/swiftmailer": "Conversion to MIME (eml file) message format"

src/MAPI/Item/Attachment.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function copyToStream($stream)
2525
fwrite($stream, $this->getData() ?? '');
2626
}
2727

28-
protected function storeEmbeddedOle($stream)
28+
protected function storeEmbeddedOle($stream): void
2929
{
3030
// this is very untested...
3131
//throw new \RuntimeException('Saving an OLE Compound Document is not supported');

src/MAPI/Message/Attachment.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public function getContentId(): ?string
9797
return $this->properties['attach_content_id'] ?? null;
9898
}
9999

100-
public function getEmbeddedOleData()
100+
public function getEmbeddedOleData(): ?string
101101
{
102102
$compobj = $this->properties["\01CompObj"];
103103
if (is_null($compobj)) {
@@ -106,7 +106,7 @@ public function getEmbeddedOleData()
106106
return substr($compobj, 32);
107107
}
108108

109-
public function isValid()
109+
public function isValid(): bool
110110
{
111111
return $this->properties !== null;
112112
}

src/MAPI/Message/Message.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,18 +88,18 @@ protected function buildRecipients()
8888
}
8989

9090
/** @return Attachment[] */
91-
public function getAttachments()
91+
public function getAttachments(): array
9292
{
9393
return $this->attachments;
9494
}
9595

9696
/** @return Recipient[] */
97-
public function getRecipients()
97+
public function getRecipients(): array
9898
{
9999
return $this->recipients;
100100
}
101101

102-
public function getRecipientsOfType($type)
102+
public function getRecipientsOfType($type): array
103103
{
104104
$response = [];
105105
foreach ($this->recipients as $r) {

src/MAPI/Mime/HeaderCollection.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ class HeaderCollection implements \IteratorAggregate
66
{
77
protected $rawHeaders = [];
88

9-
public function getIterator()
9+
public function getIterator(): \ArrayIterator
1010
{
1111
return new \ArrayIterator($this->rawHeaders);
1212
}
1313

14-
public function add($header, $value = null)
14+
public function add($header, $value = null): void
1515
{
1616
if (is_null($value)) {
1717
//echo $header . "\n";
@@ -40,7 +40,7 @@ public function add($header, $value = null)
4040
}
4141
}
4242

43-
public function set($header, $value)
43+
public function set($header, $value): void
4444
{
4545
$key = strtolower($header);
4646
$val = [
@@ -77,13 +77,13 @@ public function getValue($header)
7777

7878
}
7979

80-
public function has($header)
80+
public function has($header): bool
8181
{
8282
$key = strtolower($header);
8383
return isset($this->rawHeaders[$key]);
8484
}
8585

86-
public function unset($header)
86+
public function unset($header): void
8787
{
8888
$key = strtolower($header);
8989
unset($this->rawHeaders[$key]);

src/MAPI/Mime/Swiftmailer/Adapter/DependencySet.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
class DependencySet {
99

1010
// override the HeaderFactory registration in the DI container
11-
public static function register($force = false)
11+
public static function register($force = false): void
1212
{
1313
static $registered = false;
1414

src/MAPI/Mime/Swiftmailer/Adapter/HeaderFactory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function __construct(Swift_Mime_HeaderEncoder $encoder, Swift_Encoder $pa
2222
$this->charset = $charset;
2323
}
2424

25-
public function createTextHeader($name, $value = null)
25+
public function createTextHeader($name, $value = null): UnstructuredHeader
2626
{
2727
$header = new UnstructuredHeader($name, $this->encoder);
2828
if (isset($value)) {
@@ -33,7 +33,7 @@ public function createTextHeader($name, $value = null)
3333
return $header;
3434
}
3535

36-
protected function setHeaderCharset(Swift_Mime_Header $header)
36+
protected function setHeaderCharset(Swift_Mime_Header $header): void
3737
{
3838
if (isset($this->charset)) {
3939
$header->setCharset($this->charset);

src/MAPI/Mime/Swiftmailer/Adapter/UnstructuredHeader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class UnstructuredHeader extends Swift_Mime_Headers_UnstructuredHeader
1818
*
1919
* @return bool
2020
*/
21-
protected function tokenNeedsEncoding($token)
21+
protected function tokenNeedsEncoding($token): bool
2222
{
2323
static $prevToken = '';
2424

src/MAPI/Mime/Swiftmailer/Attachment.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public static function wrap(BaseAttachment $attachment)
1717
return new self($attachment->obj, $attachment->parent);
1818
}
1919

20-
public function toMime()
20+
public function toMime(): \Swift_Attachment
2121
{
2222
DependencySet::register();
2323

@@ -67,7 +67,7 @@ public function toMimeString(): string
6767
return (string)$this->toMime();
6868
}
6969

70-
public function copyMimeToStream($stream)
70+
public function copyMimeToStream($stream): void
7171
{
7272
fwrite($stream, $this->toMimeString());
7373
}

src/MAPI/Mime/Swiftmailer/Factory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ public function __construct(bool $muteConversionExceptions = false)
1616
$this->muteConversionExceptions = $muteConversionExceptions;
1717
}
1818

19-
public function parseMessage(Element $root)
19+
public function parseMessage(Element $root): Message
2020
{
21-
$message = new \Hfig\MAPI\Mime\Swiftmailer\Message($root);
21+
$message = new Message($root);
2222
$message->setMuteConversionExceptions($this->muteConversionExceptions);
2323

2424
return $message;

0 commit comments

Comments
 (0)