original_string: public function attach(Task $task, $task_name = null)
      {
          if (is_null($task_name)) {
              $task_name = count($this->tasks);
          }
          $this->tasks[$task_name] = $task;
          curl_multi_add_handle($this->curl, $task->createCurl());
          $deferred = new Deferred();
          $this->deferred[$task_name] = $deferred;
  
          return $deferred->promise();
      }
code: public function attach(Task $task, $task_name = null)
      {
          if (is_null($task_name)) {
              $task_name = count($this->tasks);
          }
          $this->tasks[$task_name] = $task;
          curl_multi_add_handle($this->curl, $task->createCurl());
          $deferred = new Deferred();
          $this->deferred[$task_name] = $deferred;
  
          return $deferred->promise();
      }
code_tokens: public function attach ( Task $ task , $ task_name = null ) { if ( is_null ( $ task_name ) ) { $ task_name = count ( $ this -> tasks ) ; } $ this -> tasks [ $ task_name ] = $ task ; curl_multi_add_handle ( $ this -> curl , $ task -> createCurl ( ) ) ; $ deferred = new Deferred ( ) ; $ this -> deferred [ $ task_name ] = $ deferred ; return $ deferred -> promise ( ) ; }
docstring: add new task and return a promise
  
  @param Task $task
  @param null $task_name
  @return \React\Promise\PromiseInterface
docstring_tokens: add new task and return a promise