【发布时间】:2018-06-30 18:16:20
【问题描述】:
我有以下代码需要迁移到 Guzzle 6:
use GuzzleHttp\Stream\Stream;
use Drupal\Testing\PHPUnit\DrupalTestCase;
class OpsAbstractTest extends DrupalTestCase {
public function responseMock($value, $code = 200) {
$body = Stream::factory(json_encode($value));
return new Response($code, ['Content-type' => 'application/json'], $body);
}
}
升级到 Guzzle 6 后代码失败:
PHP 致命错误:找不到类“GuzzleHttp\Stream\Stream”
代码使用static factory method,在 Guzzle 6 中似乎是 non-existing。
在 Guzzle 6 中使用的等效静态工厂方法是什么?
【问题讨论】: