Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(logging): Fix deprecation message in PsrLogger with PHP 8.1 #5006

Merged
merged 3 commits into from
Feb 10, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(): array
bshaffer marked this conversation as resolved.
Show resolved Hide resolved
{
$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): void
bshaffer marked this conversation as resolved.
Show resolved Hide resolved
{
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