code: public function detach(string $eventName, $handler): void
      {
          if (is_object($handler) == false && is_callable($handler) == false) {
              throw new InvalidArgumentException(
                  sprintf('Event handler must be either an object or a callable %s given.', gettype($handler))
              );
          }
  
          if (isset($this->events[$eventName]) == false) {
              return;
          }
  
          $priorityQueue = $this->events[$eventName];
          $priorityQueue->setExtractFlags(SplPriorityQueue::EXTR_BOTH);
          $priorityQueue->top();
  
          $newPriorityQueue = $this->createQueue();
  
          while ($priorityQueue->valid()) {
              $data = $priorityQueue->current();
              $priorityQueue->next();
  
              if ($data['data'] !== $handler) {
                  $newPriorityQueue->insert($data['data'], $data['priority']);
              }
          }
  
          $this->events[$eventName] = $newPriorityQueue;
      }
docs: Detach the listener from the events manager.
  
  @param  string          $eventName
  @param  object|callable $handler
  @return void
  
  @throws InvalidArgumentException