From ebbfd3a02b3a54056e61374aca4993bfb5c3e808 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Sun, 2 Aug 2026 12:08:51 +0200 Subject: [PATCH] [Symfony44] Add try/catch fixtures with statements before the return ConsoleExecuteReturnIntRector appended a second, unreachable "return 0;" after a try/catch whose branches did work before returning. Fixed upstream in rector-src #8260; lock the behaviour in here. --- ...ch_return_with_stmts_before_return.php.inc | 21 +++++++++ ...ch_return_with_stmts_before_return.php.inc | 47 +++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 rules-tests/Symfony44/Rector/ClassMethod/ConsoleExecuteReturnIntRector/Fixture/skip_try_catch_return_with_stmts_before_return.php.inc create mode 100644 rules-tests/Symfony44/Rector/ClassMethod/ConsoleExecuteReturnIntRector/Fixture/try_catch_return_with_stmts_before_return.php.inc diff --git a/rules-tests/Symfony44/Rector/ClassMethod/ConsoleExecuteReturnIntRector/Fixture/skip_try_catch_return_with_stmts_before_return.php.inc b/rules-tests/Symfony44/Rector/ClassMethod/ConsoleExecuteReturnIntRector/Fixture/skip_try_catch_return_with_stmts_before_return.php.inc new file mode 100644 index 00000000..882a9faf --- /dev/null +++ b/rules-tests/Symfony44/Rector/ClassMethod/ConsoleExecuteReturnIntRector/Fixture/skip_try_catch_return_with_stmts_before_return.php.inc @@ -0,0 +1,21 @@ +writeln('working'); + return 0; + } catch (\Exception $exception) { + $output->writeln($exception->getMessage()); + return 1; + } + } +} diff --git a/rules-tests/Symfony44/Rector/ClassMethod/ConsoleExecuteReturnIntRector/Fixture/try_catch_return_with_stmts_before_return.php.inc b/rules-tests/Symfony44/Rector/ClassMethod/ConsoleExecuteReturnIntRector/Fixture/try_catch_return_with_stmts_before_return.php.inc new file mode 100644 index 00000000..2249a195 --- /dev/null +++ b/rules-tests/Symfony44/Rector/ClassMethod/ConsoleExecuteReturnIntRector/Fixture/try_catch_return_with_stmts_before_return.php.inc @@ -0,0 +1,47 @@ +writeln('working'); + return 0; + } catch (\Exception $exception) { + $output->writeln($exception->getMessage()); + return 1; + } + } +} + +?> +----- +writeln('working'); + return 0; + } catch (\Exception $exception) { + $output->writeln($exception->getMessage()); + return 1; + } + } +} + +?>