Skip to content

Incorrect behavior of ThrowWithPreviousExceptionRector #9664

@dczech

Description

@dczech

Bug Report

Subject Details
Rector version 8.3.7
Installed as composer dependency

Minimal PHP Code Causing Issue

See https://getrector.com/demo/caff3294-f6c7-445e-8cbd-8be167bb5028

<?php

class HttpException extends \RuntimeException
{
    private int $statusCode;
    private array $headers;

    public function __construct(int $statusCode, string $message = '', ?\Throwable $previous = null, array $headers = [], int $code = 0)
    {
        $this->statusCode = $statusCode;
        $this->headers = $headers;

        parent::__construct($message, $code, $previous);
    }
}

class BadGatewayHttpException extends HttpException
{
    public function __construct(string $message = '', ?Throwable $previous = null, array $headers = [], int $code = 0)
    {
        parent::__construct(Response::HTTP_BAD_GATEWAY, $message, $previous, $headers, $code);
    }
}


try {
    // do sth
} catch (\Throwable $exception) {
	throw new BadGatewayHttpException('test exception', $exception);
}

Responsible rules

  • ThrowWithPreviousExceptionRector

Expected Behavior

This case is based on the custom implementation of Symfony\Component\HttpKernel\Exception\HttpException for 502 error
No change should be suggested.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions