1

私はちょうどこのような関数を書いた

  /**
   * Send an asynchronous GET request
   *
   * @param string $url
   * @param array  $options
   *
   * @return \React\Promise\ExtendedPromiseInterface
   */
  public function getAsync( $url, array $options = [] );

しかし、docblock を作成するときに、それ@return \React\Promise\ExtendedPromiseInterfaceは非常に一般的であり、拒否または履行の場合に期待される返品をクライアントが理解するのに実際には役立たないことに気付きました。

この関数の結果として期待される値または例外を文書化するための確立された規則はありますか?これにより、クライアントはインターフェイスのみを見てこの関数をチェーンできますか?

4

2 に答える 2

0

何も見つからず、私はこれを作りました

  /**
   * Send an asynchronous GET request
   * 
   * @param string $url
   * @param array  $options
   *
   * @return \React\Promise\ExtendedPromiseInterface
   *
   * @promise.resolve \MyApp\Interfaces\ResponseInterface
   * @promise.reject  \MyApp\Exceptions\RequestException
   */
  public function getAsync( $url, array $options = [] );
于 2016-06-23T14:09:33.247 に答える