Skip to content

Commit

Permalink
fix: deprecation message in PsrLogger on PHP 8.1 (#5006)
Browse files Browse the repository at this point in the history
  • Loading branch information
vntw committed Feb 10, 2022
1 parent f4da571 commit 58ff66a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
30 changes: 20 additions & 10 deletions Logging/src/PsrLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,22 @@ public function getMetadataProvider()
* @access private
*/
public function serialize()
{
return serialize($this->__serialize());
}

/**
* Unserializes data.
*
* @param string
* @access private
*/
public function unserialize($data)
{
$this->__unserialize(unserialize($data));
}

public function __serialize()
{
$debugOutputResource = null;
if (is_resource($this->debugOutputResource)) {
Expand All @@ -440,7 +456,7 @@ public function serialize()
];
}

return serialize([
return [
$this->messageKey,
$this->batchEnabled,
$this->metadataProvider,
Expand All @@ -449,16 +465,10 @@ public function serialize()
$this->batchMethod,
$this->logName,
$debugOutputResource
]);
];
}

/**
* Unserializes data.
*
* @param string
* @access private
*/
public function unserialize($data)
public function __unserialize(array $data)
{
list(
$this->messageKey,
Expand All @@ -469,7 +479,7 @@ public function unserialize($data)
$this->batchMethod,
$this->logName,
$debugOutputResource
) = unserialize($data);
) = $data;

if (is_array($debugOutputResource)) {
$this->debugOutputResource = fopen(
Expand Down
2 changes: 1 addition & 1 deletion Logging/tests/Unit/PsrLoggerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ public function testSerializesCorrectly()
);
$this->assertEquals(
PHPUnit_Framework_Assert::readAttribute($psrLogger, 'logName'),
$this->logName
$options['logName']
);
}

Expand Down

0 comments on commit 58ff66a

Please sign in to comment.