diff --git a/src/AbstractMessage.php b/src/AbstractMessage.php index d87bd32..3e40e32 100644 --- a/src/AbstractMessage.php +++ b/src/AbstractMessage.php @@ -17,7 +17,7 @@ abstract class AbstractMessage implements Message * @param \Protobuf\Stream|resource|string $stream * @param \Protobuf\Configuration $configuration */ - public function __construct($stream = null, \Protobuf\Configuration $configuration = null) + public function __construct(?$stream = null, ?\Protobuf\Configuration $configuration = null) { if ($stream === null) { return; diff --git a/src/Binary/StreamWriter.php b/src/Binary/StreamWriter.php index 235af8d..6d67119 100644 --- a/src/Binary/StreamWriter.php +++ b/src/Binary/StreamWriter.php @@ -50,7 +50,7 @@ public function __construct(Configuration $config) * @param string $bytes * @param int $length */ - public function writeBytes(Stream $stream, $bytes, $length = null) + public function writeBytes(Stream $stream, $bytes, ?$length = null) { if ($length === null) { $length = mb_strlen($bytes, '8bit'); @@ -290,7 +290,7 @@ public function writeByteStream(Stream $stream, Stream $value) * @param \Protobuf\Stream $value * @param int $length */ - public function writeStream(Stream $stream, Stream $value, $length = null) + public function writeStream(Stream $stream, Stream $value, ?$length = null) { if ($length === null) { $length = $value->getSize(); diff --git a/src/Extension/ExtensionField.php b/src/Extension/ExtensionField.php index 082c9bc..0823b28 100644 --- a/src/Extension/ExtensionField.php +++ b/src/Extension/ExtensionField.php @@ -57,7 +57,7 @@ class ExtensionField * @param callback $sizeCalculator * @param string $method */ - public function __construct($extendee, $name, $tag, $reader, $writer, $sizeCalculator, $method = null) + public function __construct($extendee, $name, $tag, $reader, $writer, $sizeCalculator, ?$method = null) { $this->tag = $tag; $this->name = $name; diff --git a/src/Extension/ExtensionFieldMap.php b/src/Extension/ExtensionFieldMap.php index e5b32c3..ecced29 100644 --- a/src/Extension/ExtensionFieldMap.php +++ b/src/Extension/ExtensionFieldMap.php @@ -26,7 +26,7 @@ class ExtensionFieldMap extends SplObjectStorage implements Collection /** * @param string $extendee */ - public function __construct($extendee = null) + public function __construct(?$extendee = null) { $this->extendee = trim($extendee, '\\'); } diff --git a/src/Message.php b/src/Message.php index a319f7f..2540d78 100644 --- a/src/Message.php +++ b/src/Message.php @@ -22,7 +22,7 @@ interface Message * * @return \Protobuf\Message */ - public static function fromStream($stream, Configuration $configuration = null); + public static function fromStream($stream, Configuration ?$configuration = null); /** * Serializes the message and returns a stream containing its bytes. @@ -31,7 +31,7 @@ public static function fromStream($stream, Configuration $configuration = null); * * @return \Protobuf\Stream */ - public function toStream(Configuration $configuration = null); + public function toStream(Configuration ?$configuration = null); /** * Compute the number of bytes that would be needed to encode the message diff --git a/src/MessageSerializer.php b/src/MessageSerializer.php index 23df67f..58c17fb 100644 --- a/src/MessageSerializer.php +++ b/src/MessageSerializer.php @@ -17,7 +17,7 @@ class MessageSerializer implements Serializer /** * @param \Protobuf\Configuration $config */ - public function __construct(Configuration $config = null) + public function __construct(Configuration ?$config = null) { $this->config = $config ?: Configuration::getInstance(); } diff --git a/src/ReadContext.php b/src/ReadContext.php index 5099f63..d8eaa99 100644 --- a/src/ReadContext.php +++ b/src/ReadContext.php @@ -38,7 +38,7 @@ class ReadContext * @param \Protobuf\Binary\StreamReader $reader * @param \Protobuf\Extension\ExtensionRegistry $extensionRegistry */ - public function __construct($stream, StreamReader $reader, ExtensionRegistry $extensionRegistry = null) + public function __construct($stream, StreamReader $reader, ExtensionRegistry ?$extensionRegistry = null) { if ( ! $stream instanceof \Protobuf\Stream) { $stream = Stream::wrap($stream); diff --git a/src/Stream.php b/src/Stream.php index 4c7b5b1..454e8d2 100644 --- a/src/Stream.php +++ b/src/Stream.php @@ -28,7 +28,7 @@ class Stream * * @throws \InvalidArgumentException if the stream is not a stream resource */ - public function __construct($stream, $size = null) + public function __construct($stream, ?$size = null) { if ( ! is_resource($stream)) { throw new InvalidArgumentException('Stream must be a resource'); @@ -253,7 +253,7 @@ public function writeStream(Stream $stream, $length) * * @throws \InvalidArgumentException if the $resource arg is not valid. */ - public static function wrap($resource = '', $size = null) + public static function wrap($resource = '', ?$size = null) { if ($resource instanceof Stream) { return $resource; @@ -290,7 +290,7 @@ public static function create() * * @return \Protobuf\Stream */ - public static function fromString($resource = '', $size = null) + public static function fromString($resource = '', ?$size = null) { $stream = fopen('php://temp', 'r+'); diff --git a/src/Unknown.php b/src/Unknown.php index ccfa28e..2b78ab6 100644 --- a/src/Unknown.php +++ b/src/Unknown.php @@ -30,7 +30,7 @@ class Unknown * @param integer $type * @param mixed $value */ - public function __construct($tag = 0, $type = null, $value = null) + public function __construct($tag = 0, $type = null, ?$value = null) { $this->tag = $tag; $this->type = $type;