Skip to content

Commit b84c94e

Browse files
authored
Merge pull request #30 from alexandre-daubois/explicit-nullable-type
Add explicit nullable type where required
2 parents 42c2d70 + 1d7011e commit b84c94e

File tree

10 files changed

+19
-19
lines changed

10 files changed

+19
-19
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"license": "MIT",
55
"keywords": ["dns"],
66
"require": {
7-
"php": ">=7.0",
7+
"php": ">=7.1",
88
"ext-ctype": "*"
99
},
1010
"autoload": {

src/Decoder/DecoderFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class DecoderFactory
4343
* @param bool $allowTrailingData
4444
* @return Decoder
4545
*/
46-
public function create(TypeDefinitionManager $typeDefinitionManager = null, bool $allowTrailingData = true): Decoder
46+
public function create(?TypeDefinitionManager $typeDefinitionManager = null, bool $allowTrailingData = true): Decoder
4747
{
4848
$typeBuilder = new TypeBuilder(new TypeFactory);
4949

src/Encoder/EncodingContext.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public function useCompression(): bool
9595
* @param bool $truncate
9696
* @return bool
9797
*/
98-
public function isTruncated(bool $truncate = null): bool
98+
public function isTruncated(?bool $truncate = null): bool
9999
{
100100
$result = $this->truncate;
101101

src/Messages/Message.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class Message
9393
* @param int $type Value of the message type field
9494
* @throws \RangeException When the supplied message type is outside the valid range 0 - 1
9595
*/
96-
public function __construct(RecordCollectionFactory $recordCollectionFactory, int $type = null)
96+
public function __construct(RecordCollectionFactory $recordCollectionFactory, ?int $type = null)
9797
{
9898
$this->questionRecords = $recordCollectionFactory->create(RecordTypes::QUESTION);
9999
$this->answerRecords = $recordCollectionFactory->create(RecordTypes::RESOURCE);
@@ -186,7 +186,7 @@ public function setOpCode(int $opCode)
186186
* @param bool $newValue The new value
187187
* @return bool The old value
188188
*/
189-
public function isAuthoritative(bool $newValue = null): bool
189+
public function isAuthoritative(?bool $newValue = null): bool
190190
{
191191
$result = $this->authoritative;
192192

@@ -203,7 +203,7 @@ public function isAuthoritative(bool $newValue = null): bool
203203
* @param bool $newValue The new value
204204
* @return bool The old value
205205
*/
206-
public function isTruncated(bool $newValue = null): bool
206+
public function isTruncated(?bool $newValue = null): bool
207207
{
208208
$result = $this->truncated;
209209

@@ -220,7 +220,7 @@ public function isTruncated(bool $newValue = null): bool
220220
* @param bool $newValue The new value
221221
* @return bool The old value
222222
*/
223-
public function isRecursionDesired(bool $newValue = null): bool
223+
public function isRecursionDesired(?bool $newValue = null): bool
224224
{
225225
$result = $this->recursionDesired;
226226

@@ -237,7 +237,7 @@ public function isRecursionDesired(bool $newValue = null): bool
237237
* @param bool $newValue The new value
238238
* @return bool The old value
239239
*/
240-
public function isRecursionAvailable(bool $newValue = null): bool
240+
public function isRecursionAvailable(?bool $newValue = null): bool
241241
{
242242
$result = $this->recursionAvailable;
243243

src/Messages/MessageFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class MessageFactory
3030
* @param int $type Value of the message type field
3131
* @return \LibDNS\Messages\Message
3232
*/
33-
public function create(int $type = null): Message
33+
public function create(?int $type = null): Message
3434
{
3535
return new Message(new RecordCollectionFactory, $type);
3636
}

src/Packets/Packet.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function __construct(string $data = '')
5555
* @return string
5656
* @throws \OutOfBoundsException When the pointer position is invalid or the supplied length is negative
5757
*/
58-
public function read(int $length = null): string
58+
public function read(?int $length = null): string
5959
{
6060
if ($this->pointer > $this->length) {
6161
throw new \OutOfBoundsException('Pointer position invalid');

src/Records/ResourceBuilderFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class ResourceBuilderFactory
3434
* @param \LibDNS\Records\TypeDefinitions\TypeDefinitionManager $typeDefinitionManager
3535
* @return \LibDNS\Records\ResourceBuilder
3636
*/
37-
public function create(TypeDefinitionManager $typeDefinitionManager = null): ResourceBuilder
37+
public function create(?TypeDefinitionManager $typeDefinitionManager = null): ResourceBuilder
3838
{
3939
return new ResourceBuilder(
4040
new ResourceFactory,

src/Records/Types/BitMap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function setValue($value)
4444
* @param bool $newValue The new value
4545
* @return bool The old value
4646
*/
47-
public function isBitSet(int $index, bool $newValue = null): bool
47+
public function isBitSet(int $index, ?bool $newValue = null): bool
4848
{
4949
$charIndex = (int)($index / 8);
5050
$bitMask = 0b10000000 >> ($index % 8);

src/Records/Types/Type.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ abstract class Type
3333
* @param string $value Internal value
3434
* @throws \RuntimeException When the supplied value is invalid
3535
*/
36-
public function __construct(string $value = null)
36+
public function __construct(?string $value = null)
3737
{
3838
if (isset($value)) {
3939
$this->setValue($value);

src/Records/Types/TypeFactory.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class TypeFactory
2828
* @param string $value
2929
* @return \LibDNS\Records\Types\Anything
3030
*/
31-
public function createAnything(string $value = null)
31+
public function createAnything(?string $value = null)
3232
{
3333
return new Anything($value);
3434
}
@@ -39,7 +39,7 @@ public function createAnything(string $value = null)
3939
* @param string $value
4040
* @return \LibDNS\Records\Types\BitMap
4141
*/
42-
public function createBitMap(string $value = null)
42+
public function createBitMap(?string $value = null)
4343
{
4444
return new BitMap($value);
4545
}
@@ -50,7 +50,7 @@ public function createBitMap(string $value = null)
5050
* @param int $value
5151
* @return \LibDNS\Records\Types\Char
5252
*/
53-
public function createChar(int $value = null)
53+
public function createChar(?int $value = null)
5454
{
5555
return new Char((string)$value);
5656
}
@@ -61,7 +61,7 @@ public function createChar(int $value = null)
6161
* @param string $value
6262
* @return \LibDNS\Records\Types\CharacterString
6363
*/
64-
public function createCharacterString(string $value = null)
64+
public function createCharacterString(?string $value = null)
6565
{
6666
return new CharacterString($value);
6767
}
@@ -105,7 +105,7 @@ public function createIPv6Address($value = null)
105105
* @param int $value
106106
* @return \LibDNS\Records\Types\Long
107107
*/
108-
public function createLong(int $value = null)
108+
public function createLong(?int $value = null)
109109
{
110110
return new Long((string)$value);
111111
}
@@ -116,7 +116,7 @@ public function createLong(int $value = null)
116116
* @param int $value
117117
* @return \LibDNS\Records\Types\Short
118118
*/
119-
public function createShort(int $value = null)
119+
public function createShort(?int $value = null)
120120
{
121121
return new Short((string)$value);
122122
}

0 commit comments

Comments
 (0)