{"record":{"id":"4a67ba523545b5f1","repo":"w7corp/easywechat","slug":"s-does-t-implements-s","errorCode":null,"errorMessage":"%s does't implements %s","messagePattern":"(.+?) does't implements (.+?)","errorType":"exception","errorClass":"BadMethodCallException","httpStatus":null,"severity":"warning","filePath":"src/Kernel/HttpClient/Response.php","lineNumber":133,"sourceCode":"\n    public function toJson(?bool $throw = null): string|false\n    {\n        return json_encode($this->toArray($throw), JSON_UNESCAPED_UNICODE);\n    }\n\n    /**\n     * {@inheritdoc}\n     *\n     * @throws BadMethodCallException\n     */\n    public function toStream(?bool $throw = null)\n    {\n        if ($this->response instanceof StreamableInterface) {\n            return $this->response->toStream($throw ?? $this->throw);\n        }\n\n        if ($throw) {\n            throw new BadMethodCallException(sprintf('%s does\\'t implements %s', \\get_class($this->response), StreamableInterface::class));\n        }\n\n        return StreamWrapper::createResource(new MockResponse);\n    }\n\n    /**\n     * @throws \\LogicException\n     */\n    public function toDataUrl(): string\n    {\n        return 'data:'.$this->getHeaderLine('content-type').';base64,'.base64_encode($this->getContent());\n    }\n\n    public function toPsrResponse(?ResponseFactoryInterface $responseFactory = null, ?StreamFactoryInterface $streamFactory = null): \\Psr\\Http\\Message\\ResponseInterface\n    {\n        $streamFactory ??= $responseFactory instanceof StreamFactoryInterface ? $responseFactory : null;\n\n        if ($responseFactory === null || $streamFactory === null) {","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/w7corp/easywechat/blob/f0cf0a8b8361417ed683b8246d0ecbaf0aafcaa8/src/Kernel/HttpClient/Response.php#L115-L151","documentation":"Response::toStream() can only stream when the wrapped Symfony response implements StreamableInterface; the fallback path (used for MockResponse and other non-streamable responses) returns a mock stream when $throw is falsy, but throws BadMethodCallException(\"<class> does't implements ...\") when $throw is true. The library is telling you the concrete response class cannot provide a PHP stream resource.","triggerScenarios":"Calling toStream(true) on a Response wrapping a Symfony HttpClient MockResponse (unit tests) or any response class lacking StreamableInterface.","commonSituations":"Test suites mocking HttpClient responses, custom response wrappers injected into the client, code paths that force throw=true unconditionally.","solutions":["Do not pass true: call $response->toStream() and let it fall back when streaming is unsupported","In tests, provide a response that implements StreamableInterface if you need a real stream","For large downloads prefer saveAs($path) or toDataUrl() over streaming"],"exampleFix":"// before\n$stream = $response->toStream(true); // throws for MockResponse\n\n// after\n$stream = $response->toStream(); // mock fallback, no exception","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    $stream = $response->toStream(true);\n} catch (\\BadMethodCallException $e) {\n    // underlying response (e.g. MockResponse in tests) cannot stream\n    $stream = $response->toStream(); // mock fallback\n}","preventionTips":["Do not force throw=true on toStream(); let the library fall back","In tests, exercise streaming with a real HTTP response or skip stream assertions for mocked clients","Prefer saveAs() for large payloads"],"tags":["php","easywechat","http-client","streaming","testing"],"backgroundTag":"stream-not-supported","analyzedSha":"f0cf0a8b8361417ed683b8246d0ecbaf0aafcaa8","analyzedAt":"2026-08-21T05:29:19.565Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}