original_string: protected function addFilter($when, $action, $callback)
      {
          if (!is_callable($callback) && !is_array($callback)) {
              $callback = [$this, $callback];
          }
  
          if (is_array($action)) {
              foreach ($action as $method) {
                  $this->addFilter($when, $method, $callback);
              }
          } else {
              EventDispatcher::addListener("{$when}." . get_called_class() . "::{$action}", $callback);
          }
      }
code: protected function addFilter($when, $action, $callback)
      {
          if (!is_callable($callback) && !is_array($callback)) {
              $callback = [$this, $callback];
          }
  
          if (is_array($action)) {
              foreach ($action as $method) {
                  $this->addFilter($when, $method, $callback);
              }
          } else {
              EventDispatcher::addListener("{$when}." . get_called_class() . "::{$action}", $callback);
          }
      }
code_tokens: protected function addFilter ( $ when , $ action , $ callback ) { if ( ! is_callable ( $ callback ) && ! is_array ( $ callback ) ) { $ callback = [ $ this , $ callback ] ; } if ( is_array ( $ action ) ) { foreach ( $ action as $ method ) { $ this -> addFilter ( $ when , $ method , $ callback ) ; } } else { EventDispatcher :: addListener ( "{$when}." . get_called_class ( ) . "::{$action}" , $ callback ) ; } }
docstring: Adds the filter to the event dispatcher.
  
  @param string $when     Either 'before' or 'after'
  @param string $action
  @param mixed  $callback
docstring_tokens: Adds the filter to the event dispatcher .