From 6a6ec1b8f8a5c70d21f3772ce637b763e8ab21ea Mon Sep 17 00:00:00 2001 From: nsfisis Date: Mon, 31 Aug 2026 00:15:52 +0900 Subject: feat(plugin): carry Http\Response across as a materialized value MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A response is built for one request and the graph never retains it, so there is no entity for a handle to point at. The child holds a real instance instead, revived from the object record the wire carries, and collect() frees the copy each world holds — which is what that method is for. The value-object rule rejects the class only because collect() assigns to $this, so the category comes from an overrides.list entry. HttpDownloader::get() and copy() answer with one. Two gaps stay: decodeJson() reaches Composer\Json\JsonFile, which a guard shadows, and Composer answers a curl request with the CurlResponse subclass where this port flattens the value into a Response. Co-Authored-By: Claude Opus 5 (1M context) --- .../e2e-http-downloader/plugin/src/Plugin.php | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'crates/shirabe/tests/plugin/fixtures') diff --git a/crates/shirabe/tests/plugin/fixtures/e2e-http-downloader/plugin/src/Plugin.php b/crates/shirabe/tests/plugin/fixtures/e2e-http-downloader/plugin/src/Plugin.php index 504c2108..054a47ca 100644 --- a/crates/shirabe/tests/plugin/fixtures/e2e-http-downloader/plugin/src/Plugin.php +++ b/crates/shirabe/tests/plugin/fixtures/e2e-http-downloader/plugin/src/Plugin.php @@ -78,6 +78,32 @@ class Plugin implements PluginInterface, EventSubscriberInterface ); }); + // A file:// url keeps the probe offline and off the curl path, so the trace is the same + // on a machine with no network. Paths stay out of the trace: the two runs work in + // different temporary directories. + $payload = getcwd() . '/probe-payload.json'; + file_put_contents($payload, '{"probe":true,"n":42}'); + + $response = null; + $lines[] = 'get=' . $this->describe(static function () use ($downloader, $payload, &$response): void { + $response = $downloader->get('file://' . $payload); + }); + $lines[] = 'response class=' . json_encode($response === null ? null : \get_class($response)) + . ' body=' . json_encode($response === null ? null : $response->getBody()) + . ' headers=' . json_encode($response === null ? null : $response->getHeaders()); + $lines[] = 'getHeader=' . json_encode($response === null ? null : $response->getHeader('Content-Type')); + + $target = getcwd() . '/probe-copy.json'; + $lines[] = 'copy=' . $this->describe(static function () use ($downloader, $payload, $target): void { + $downloader->copy('file://' . $payload, $target); + }) . ' file=' . json_encode(@file_get_contents($target)); + + // collect() unsets the response's own properties, so the object is spent afterwards and + // nothing may read it again. + $lines[] = 'collect=' . $this->describe(static function () use ($response): void { + $response->collect(); + }); + file_put_contents('http-downloader-trace.txt', implode("\n", $lines) . "\n"); } -- cgit v1.3.1-4-g156e