Repository: symfony/symfony
File: src/Symfony/Component/HttpClient/Internal/AmpListener.php (PHP)

Code before:
        private array $pinSha256,
        private \Closure $onProgress,
        private &$handle,
        private float $maxConnectDuration,
        private ?DeferredCancellation $canceller,
    ) {
        $info += [
            'connect_time' => 0.0,
            'pretransfer_time' => 0.0,
            'starttransfer_time' => 0.0,
            'total_time' => 0.0,
            'namelookup_time' => 0.0,
            'primary_ip' => '',
            'primary_port' => 0,
        ];

        $this->info = &$info;
    }

    public function requestStart(Request $request): void
    {
        $this->info['start_time'] ??= microtime(true);

        if (0 < $this->maxConnectDuration) {
            $this->connectTimerId = EventLoop::delay($this->maxConnectDuration, function (): void {
                $this->canceller?->cancel(new TransportException(\sprintf('Max connect duration was reached for "%s".', $this->info['url'])));
            });
        }

        ($this->onProgress)();
    }

    public function connectionAcquired(Request $request, Connection $connection, int $streamCount): void
    {
        if (null !== $this->connectTimerId) {
            EventLoop::cancel($this->connectTimerId);
            $this->connectTimerId = null;
        }

        $this->info['namelookup_time'] = microtime(true) - $this->info['start_time']; // see https://github.com/amphp/socket/issues/114
        $this->info['connect_time'] = microtime(true) - $this->info['start_time'];
        ($this->onProgress)();
    }

    public function requestHeaderStart(Request $request, Stream $stream): void
    {
        $host = $stream->getRemoteAddress()->toString();
        if ($stream->getRemoteAddress() instanceof InternetAddress) {
            $host = $stream->getRemoteAddress()->getAddress();
            $this->info['primary_port'] = $stream->getRemoteAddress()->getPort();
        }

Review comment (suggestion):
```suggestion
                $this->canceller->cancel(new TransportException(\sprintf('Max connect duration was reached for "%s".', $this->info['url'])));
```

Code after:
        private array $pinSha256,
        private \Closure $onProgress,
        private &$handle,
        private float $maxConnectDuration,
        private DeferredCancellation $canceller,
    ) {
        $info += [
            'connect_time' => 0.0,
            'pretransfer_time' => 0.0,
            'starttransfer_time' => 0.0,
            'total_time' => 0.0,
            'namelookup_time' => 0.0,
            'primary_ip' => '',
            'primary_port' => 0,
        ];

        $this->info = &$info;
    }

    public function requestStart(Request $request): void
    {
        $this->info['start_time'] ??= microtime(true);

        if (0 < $this->maxConnectDuration) {
            $this->connectTimerId = EventLoop::delay($this->maxConnectDuration, function (): void {
                $this->canceller->cancel(new TransportException(\sprintf('Max connect duration was reached for "%s".', $this->info['url'])));
            });
        }

        ($this->onProgress)();
    }

    public function connectionAcquired(Request $request, Connection $connection, int $streamCount): void
    {
        if (null !== $this->connectTimerId) {
            EventLoop::cancel($this->connectTimerId);
            $this->connectTimerId = null;
        }

        $this->info['namelookup_time'] = microtime(true) - $this->info['start_time']; // see https://github.com/amphp/socket/issues/114
        $this->info['connect_time'] = microtime(true) - $this->info['start_time'];
        ($this->onProgress)();
    }

    public function requestHeaderStart(Request $request, Stream $stream): void
    {
        $host = $stream->getRemoteAddress()->toString();
        if ($stream->getRemoteAddress() instanceof InternetAddress) {
            $host = $stream->getRemoteAddress()->getAddress();
            $this->info['primary_port'] = $stream->getRemoteAddress()->getPort();
        }