Skip to content

Commit d7f2850

Browse files
committed
Fixing PHP 8.4 Implicitly nullable parameter declarations deprecated
Signed-off-by: Yevhenii Miniailenko <[email protected]>
1 parent 8a6f679 commit d7f2850

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/FluentLogger.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,16 +99,16 @@ class FluentLogger implements LoggerInterface
9999
* create fluent logger object.
100100
*
101101
*
102-
* @param string $host
103-
* @param int $port
104-
* @param array $options
105-
* @param PackerInterface $packer
102+
* @param string $host
103+
* @param int $port
104+
* @param array $options
105+
* @param PackerInterface|null $packer
106106
* @return FluentLogger
107107
*/
108108
public function __construct($host = FluentLogger::DEFAULT_ADDRESS,
109109
$port = FluentLogger::DEFAULT_LISTEN_PORT,
110110
array $options = array(),
111-
PackerInterface $packer = null)
111+
$packer = null)
112112
{
113113
/* keep original host and port */
114114
$this->host = $host;
@@ -120,6 +120,8 @@ public function __construct($host = FluentLogger::DEFAULT_ADDRESS,
120120
if (is_null($packer)) {
121121
/* for backward compatibility */
122122
$packer = new JsonPacker();
123+
} elseif (!$packer instanceof PackerInterface) {
124+
throw new \InvalidArgumentException(sprintf('The $packer parameter must implement %s. %s given.', PackerInterface::class, get_class($packer)));
123125
}
124126

125127
$this->packer = $packer;

0 commit comments

Comments
 (0)