original_string: private function stopServer()
      {
          if ($this->resource !== null) {
              $this->write('Stopping PhantomJS Server.');
  
              // Wait till the server has been stopped.
              $max_checks = 10;
              for ($i = 0; $i < $max_checks; $i++) {
                  // If we're on the last loop, and it's still not shut down, just
                  // unset resource to allow the tests to finish.
                  if ($i === $max_checks - 1 && proc_get_status($this->resource)['running'] === true) {
                      $this->writeln('');
                      $this->writeln('Unable to properly shutdown PhantomJS server.');
                      unset($this->resource);
                      break;
                  }
  
                  // Check if the process has stopped yet.
                  if (proc_get_status($this->resource)['running'] === false) {
                      $this->writeln('');
                      $this->writeln('PhantomJS server stopped.');
                      unset($this->resource);
                      break;
                  }
  
                  foreach ($this->pipes as $pipe) {
                      if (is_resource($pipe)) {
                          fclose($pipe);
                      }
                  }
  
                  // Terminate the process.
                  // Note: Use of SIGINT adds dependency on PCTNL extension so we
                  // use the integer value instead.
                  proc_terminate($this->resource, 2);
  
                  $this->write('.');
  
                  // Wait before checking again.
                  sleep(1);
              }
          }
      }
code: private function stopServer()
      {
          if ($this->resource !== null) {
              $this->write('Stopping PhantomJS Server.');
  
              // Wait till the server has been stopped.
              $max_checks = 10;
              for ($i = 0; $i < $max_checks; $i++) {
                  // If we're on the last loop, and it's still not shut down, just
                  // unset resource to allow the tests to finish.
                  if ($i === $max_checks - 1 && proc_get_status($this->resource)['running'] === true) {
                      $this->writeln('');
                      $this->writeln('Unable to properly shutdown PhantomJS server.');
                      unset($this->resource);
                      break;
                  }
  
                  // Check if the process has stopped yet.
                  if (proc_get_status($this->resource)['running'] === false) {
                      $this->writeln('');
                      $this->writeln('PhantomJS server stopped.');
                      unset($this->resource);
                      break;
                  }
  
                  foreach ($this->pipes as $pipe) {
                      if (is_resource($pipe)) {
                          fclose($pipe);
                      }
                  }
  
                  // Terminate the process.
                  // Note: Use of SIGINT adds dependency on PCTNL extension so we
                  // use the integer value instead.
                  proc_terminate($this->resource, 2);
  
                  $this->write('.');
  
                  // Wait before checking again.
                  sleep(1);
              }
          }
      }
code_tokens: private function stopServer ( ) { if ( $ this -> resource !== null ) { $ this -> write ( 'Stopping PhantomJS Server.' ) ; // Wait till the server has been stopped. $ max_checks = 10 ; for ( $ i = 0 ; $ i < $ max_checks ; $ i ++ ) { // If we're on the last loop, and it's still not shut down, just // unset resource to allow the tests to finish. if ( $ i === $ max_checks - 1 && proc_get_status ( $ this -> resource ) [ 'running' ] === true ) { $ this -> writeln ( '' ) ; $ this -> writeln ( 'Unable to properly shutdown PhantomJS server.' ) ; unset ( $ this -> resource ) ; break ; } // Check if the process has stopped yet. if ( proc_get_status ( $ this -> resource ) [ 'running' ] === false ) { $ this -> writeln ( '' ) ; $ this -> writeln ( 'PhantomJS server stopped.' ) ; unset ( $ this -> resource ) ; break ; } foreach ( $ this -> pipes as $ pipe ) { if ( is_resource ( $ pipe ) ) { fclose ( $ pipe ) ; } } // Terminate the process. // Note: Use of SIGINT adds dependency on PCTNL extension so we // use the integer value instead. proc_terminate ( $ this -> resource , 2 ) ; $ this -> write ( '.' ) ; // Wait before checking again. sleep ( 1 ) ; } } }
docstring: Stop PhantomJS server.
docstring_tokens: Stop PhantomJS server .