Skip to content

Commit

Permalink
Merge pull request #30 from alexandre-daubois/explicit-nullable-type
Browse files Browse the repository at this point in the history
Add explicit nullable type where required
  • Loading branch information
kelunik authored Apr 12, 2024
2 parents 42c2d70 + 1d7011e commit b84c94e
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"license": "MIT",
"keywords": ["dns"],
"require": {
"php": ">=7.0",
"php": ">=7.1",
"ext-ctype": "*"
},
"autoload": {
Expand Down
2 changes: 1 addition & 1 deletion src/Decoder/DecoderFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class DecoderFactory
* @param bool $allowTrailingData
* @return Decoder
*/
public function create(TypeDefinitionManager $typeDefinitionManager = null, bool $allowTrailingData = true): Decoder
public function create(?TypeDefinitionManager $typeDefinitionManager = null, bool $allowTrailingData = true): Decoder
{
$typeBuilder = new TypeBuilder(new TypeFactory);

Expand Down
2 changes: 1 addition & 1 deletion src/Encoder/EncodingContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function useCompression(): bool
* @param bool $truncate
* @return bool
*/
public function isTruncated(bool $truncate = null): bool
public function isTruncated(?bool $truncate = null): bool
{
$result = $this->truncate;

Expand Down
10 changes: 5 additions & 5 deletions src/Messages/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class Message
* @param int $type Value of the message type field
* @throws \RangeException When the supplied message type is outside the valid range 0 - 1
*/
public function __construct(RecordCollectionFactory $recordCollectionFactory, int $type = null)
public function __construct(RecordCollectionFactory $recordCollectionFactory, ?int $type = null)
{
$this->questionRecords = $recordCollectionFactory->create(RecordTypes::QUESTION);
$this->answerRecords = $recordCollectionFactory->create(RecordTypes::RESOURCE);
Expand Down Expand Up @@ -186,7 +186,7 @@ public function setOpCode(int $opCode)
* @param bool $newValue The new value
* @return bool The old value
*/
public function isAuthoritative(bool $newValue = null): bool
public function isAuthoritative(?bool $newValue = null): bool
{
$result = $this->authoritative;

Expand All @@ -203,7 +203,7 @@ public function isAuthoritative(bool $newValue = null): bool
* @param bool $newValue The new value
* @return bool The old value
*/
public function isTruncated(bool $newValue = null): bool
public function isTruncated(?bool $newValue = null): bool
{
$result = $this->truncated;

Expand All @@ -220,7 +220,7 @@ public function isTruncated(bool $newValue = null): bool
* @param bool $newValue The new value
* @return bool The old value
*/
public function isRecursionDesired(bool $newValue = null): bool
public function isRecursionDesired(?bool $newValue = null): bool
{
$result = $this->recursionDesired;

Expand All @@ -237,7 +237,7 @@ public function isRecursionDesired(bool $newValue = null): bool
* @param bool $newValue The new value
* @return bool The old value
*/
public function isRecursionAvailable(bool $newValue = null): bool
public function isRecursionAvailable(?bool $newValue = null): bool
{
$result = $this->recursionAvailable;

Expand Down
2 changes: 1 addition & 1 deletion src/Messages/MessageFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class MessageFactory
* @param int $type Value of the message type field
* @return \LibDNS\Messages\Message
*/
public function create(int $type = null): Message
public function create(?int $type = null): Message
{
return new Message(new RecordCollectionFactory, $type);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Packets/Packet.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function __construct(string $data = '')
* @return string
* @throws \OutOfBoundsException When the pointer position is invalid or the supplied length is negative
*/
public function read(int $length = null): string
public function read(?int $length = null): string
{
if ($this->pointer > $this->length) {
throw new \OutOfBoundsException('Pointer position invalid');
Expand Down
2 changes: 1 addition & 1 deletion src/Records/ResourceBuilderFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class ResourceBuilderFactory
* @param \LibDNS\Records\TypeDefinitions\TypeDefinitionManager $typeDefinitionManager
* @return \LibDNS\Records\ResourceBuilder
*/
public function create(TypeDefinitionManager $typeDefinitionManager = null): ResourceBuilder
public function create(?TypeDefinitionManager $typeDefinitionManager = null): ResourceBuilder
{
return new ResourceBuilder(
new ResourceFactory,
Expand Down
2 changes: 1 addition & 1 deletion src/Records/Types/BitMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function setValue($value)
* @param bool $newValue The new value
* @return bool The old value
*/
public function isBitSet(int $index, bool $newValue = null): bool
public function isBitSet(int $index, ?bool $newValue = null): bool
{
$charIndex = (int)($index / 8);
$bitMask = 0b10000000 >> ($index % 8);
Expand Down
2 changes: 1 addition & 1 deletion src/Records/Types/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ abstract class Type
* @param string $value Internal value
* @throws \RuntimeException When the supplied value is invalid
*/
public function __construct(string $value = null)
public function __construct(?string $value = null)
{
if (isset($value)) {
$this->setValue($value);
Expand Down
12 changes: 6 additions & 6 deletions src/Records/Types/TypeFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class TypeFactory
* @param string $value
* @return \LibDNS\Records\Types\Anything
*/
public function createAnything(string $value = null)
public function createAnything(?string $value = null)
{
return new Anything($value);
}
Expand All @@ -39,7 +39,7 @@ public function createAnything(string $value = null)
* @param string $value
* @return \LibDNS\Records\Types\BitMap
*/
public function createBitMap(string $value = null)
public function createBitMap(?string $value = null)
{
return new BitMap($value);
}
Expand All @@ -50,7 +50,7 @@ public function createBitMap(string $value = null)
* @param int $value
* @return \LibDNS\Records\Types\Char
*/
public function createChar(int $value = null)
public function createChar(?int $value = null)
{
return new Char((string)$value);
}
Expand All @@ -61,7 +61,7 @@ public function createChar(int $value = null)
* @param string $value
* @return \LibDNS\Records\Types\CharacterString
*/
public function createCharacterString(string $value = null)
public function createCharacterString(?string $value = null)
{
return new CharacterString($value);
}
Expand Down Expand Up @@ -105,7 +105,7 @@ public function createIPv6Address($value = null)
* @param int $value
* @return \LibDNS\Records\Types\Long
*/
public function createLong(int $value = null)
public function createLong(?int $value = null)
{
return new Long((string)$value);
}
Expand All @@ -116,7 +116,7 @@ public function createLong(int $value = null)
* @param int $value
* @return \LibDNS\Records\Types\Short
*/
public function createShort(int $value = null)
public function createShort(?int $value = null)
{
return new Short((string)$value);
}
Expand Down

0 comments on commit b84c94e

Please sign in to comment.