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: use dynamic class name instead of reference #2871

Merged
Merged
Changes from all commits
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
15 changes: 9 additions & 6 deletions src/ClientSideMonitoring/AbstractMonitoringMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,18 +224,21 @@ protected function populateResultEventData(
return $event;
}


/**
* Checks if the socket is created.
* Checks if the socket is created. If PHP version is greater or equals to 8 then,
* it will check if the var is instance of \Socket otherwise it will check if is
* a resource.
*
* @return bool Returns true if the socket is created, false otherwise.
*/
private function isSocketCreated()
private function isSocketCreated(): bool
{
// Before version 8, sockets are resources
// After version 8, sockets are instances of Socket
if (PHP_MAJOR_VERSION >= 8) {
return (self::$socket instanceof \Socket);
$socketClass = '\Socket';
return self::$socket instanceof $socketClass;
} else {
return is_resource(self::$socket);
}
Expand All @@ -252,7 +255,7 @@ private function isSocketCreated()
*/
private function prepareSocket($forceNewConnection = false)
{
if (!$this->isSocketCreated()
if (!$this->isSocketCreated()
|| $forceNewConnection
|| socket_last_error(self::$socket)
) {
Expand Down Expand Up @@ -303,4 +306,4 @@ private function unwrappedOptions()
}
return $this->options;
}
}
}