original_string: private function optimizeListeners(string $eventName): array
      {
          krsort($this->listeners[$eventName]);
          $this->optimized[$eventName] = [];
  
          foreach ($this->listeners[$eventName] as &$listeners) {
              foreach ($listeners as &$listener) {
                  $closure = &$this->optimized[$eventName][];
                  if (\is_array($listener) && isset($listener[0]) && $listener[0] instanceof \Closure) {
                      $closure = static function (...$args) use (&$listener, &$closure) {
                          if ($listener[0] instanceof \Closure) {
                              $listener[0] = $listener[0]();
                          }
                          ($closure = \Closure::fromCallable($listener))(...$args);
                      };
                  } else {
                      $closure = $listener instanceof \Closure || $listener instanceof WrappedListener ? $listener : \Closure::fromCallable($listener);
                  }
              }
          }
  
          return $this->optimized[$eventName];
      }
code: private function optimizeListeners(string $eventName): array
      {
          krsort($this->listeners[$eventName]);
          $this->optimized[$eventName] = [];
  
          foreach ($this->listeners[$eventName] as &$listeners) {
              foreach ($listeners as &$listener) {
                  $closure = &$this->optimized[$eventName][];
                  if (\is_array($listener) && isset($listener[0]) && $listener[0] instanceof \Closure) {
                      $closure = static function (...$args) use (&$listener, &$closure) {
                          if ($listener[0] instanceof \Closure) {
                              $listener[0] = $listener[0]();
                          }
                          ($closure = \Closure::fromCallable($listener))(...$args);
                      };
                  } else {
                      $closure = $listener instanceof \Closure || $listener instanceof WrappedListener ? $listener : \Closure::fromCallable($listener);
                  }
              }
          }
  
          return $this->optimized[$eventName];
      }
code_tokens: private function optimizeListeners ( string $ eventName ) : array { krsort ( $ this -> listeners [ $ eventName ] ) ; $ this -> optimized [ $ eventName ] = [ ] ; foreach ( $ this -> listeners [ $ eventName ] as & $ listeners ) { foreach ( $ listeners as & $ listener ) { $ closure = & $ this -> optimized [ $ eventName ] [ ] ; if ( \ is_array ( $ listener ) && isset ( $ listener [ 0 ] ) && $ listener [ 0 ] instanceof \ Closure ) { $ closure = static function ( ... $ args ) use ( & $ listener , & $ closure ) { if ( $ listener [ 0 ] instanceof \ Closure ) { $ listener [ 0 ] = $ listener [ 0 ] ( ) ; } ( $ closure = \ Closure :: fromCallable ( $ listener ) ) ( ... $ args ) ; } ; } else { $ closure = $ listener instanceof \ Closure || $ listener instanceof WrappedListener ? $ listener : \ Closure :: fromCallable ( $ listener ) ; } } } return $ this -> optimized [ $ eventName ] ; }
docstring: Optimizes the internal list of listeners for the given event by priority.
docstring_tokens: Optimizes the internal list of listeners for the given event by priority .