Skip to content

Commit

Permalink
add support for PHP 8
Browse files Browse the repository at this point in the history
  • Loading branch information
Brendon committed Sep 27, 2022
1 parent 3952416 commit 98b650e
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/Lifo/Daemon/IPC/SysV.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ public function purge()
$this->setupIPC();
}

private function check($var)
{
if(PHP_MAJOR_VERSION >= 8) {
return is_object($var);
}
return is_resource($var);
}

private function purgeSEM()
{
if ($this->sem) {
Expand All @@ -62,7 +70,7 @@ private function purgeSEM()

private function purgeSHM()
{
if (!is_resource($this->shm)) {
if (!$this->check($this->shm)) {
$this->setupIPC();
}

Expand All @@ -75,7 +83,7 @@ private function purgeSHM()

private function purgeQueue()
{
if (!is_resource($this->queue)) {
if (!$this->check($this->queue)) {
$this->setupIPC();
}

Expand All @@ -93,12 +101,12 @@ private function setupIPC()
{
$this->sem = sem_get($this->mediator->getGuid());
$this->shm = shm_attach($this->mediator->getGuid(), $this->size, 0666);
if (!is_resource($this->shm)) {
if (!$this->check($this->shm)) {
throw new \Exception(sprintf("Could not attach to Shared Memory Block 0x%08x", $this->mediator->getGuid()));
}

$this->queue = msg_get_queue($this->mediator->getGuid(), 0666);
if (!is_resource($this->queue)) {
if (!$this->check($this->queue)) {
throw new \Exception(sprintf("Could not attach to message queue 0x%08x", $this->mediator->getGuid()));
}
}
Expand Down Expand Up @@ -381,7 +389,7 @@ public function setMediator(Mediator $mediator)
*/
private function testIpc()
{
if (!is_resource($this->shm)) {
if (!$this->check($this->shm)) {
return false;
}

Expand Down

0 comments on commit 98b650e

Please sign in to comment.