diff --git a/composer.lock b/composer.lock index 368f3ca60..80fe8788b 100644 --- a/composer.lock +++ b/composer.lock @@ -3514,12 +3514,12 @@ "source": { "type": "git", "url": "https://github.com/rectorphp/rector.git", - "reference": "f38fd4a5ba583bd4300324e9ed14146c2e5f7b53" + "reference": "7257de091208898419bdaed6ebe95b3fc0b48015" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/rectorphp/rector/zipball/f38fd4a5ba583bd4300324e9ed14146c2e5f7b53", - "reference": "f38fd4a5ba583bd4300324e9ed14146c2e5f7b53", + "url": "https://api.github.com/repos/rectorphp/rector/zipball/7257de091208898419bdaed6ebe95b3fc0b48015", + "reference": "7257de091208898419bdaed6ebe95b3fc0b48015", "shasum": "" }, "require": { @@ -3567,7 +3567,7 @@ "type": "github" } ], - "time": "2026-02-20T17:47:25+00:00" + "time": "2026-02-20T21:34:48+00:00" }, { "name": "samsonasik/array-lookup", diff --git a/src/DemoRunner.php b/src/DemoRunner.php index cfd50a3be..c3da92ede 100644 --- a/src/DemoRunner.php +++ b/src/DemoRunner.php @@ -111,7 +111,7 @@ private function processFilesContents(string $fileContent, string $rectorConfig) } catch (JsonException $jsonException) { if ($jsonException->getMessage() === 'Syntax error') { $errorMessage = 'Invalid json syntax in "vendor/bin/rector" process output: ' . PHP_EOL . PHP_EOL . $output; - throw new ShouldNotHappenException($errorMessage); + throw new ShouldNotHappenException($errorMessage, $jsonException->getCode(), $jsonException); } throw $jsonException; diff --git a/src/FileSystem/RectorFinder.php b/src/FileSystem/RectorFinder.php index 4f937ebe4..e76a91bcd 100644 --- a/src/FileSystem/RectorFinder.php +++ b/src/FileSystem/RectorFinder.php @@ -170,14 +170,12 @@ private function findInDirectoriesAndCreateRuleMetadatas(array $directories, arr $ruleDefinition = $rector->getRuleDefinition(); } catch (Throwable $throwable) { - throw new InvalidRuleDescriptionException( - sprintf( - 'Rule "%s" has invalid code samples:%s"%s"', - $findRectorClass, - PHP_EOL . PHP_EOL, - $throwable->getMessage() - ) - ); + throw new InvalidRuleDescriptionException(sprintf( + 'Rule "%s" has invalid code samples:%s"%s"', + $findRectorClass, + PHP_EOL . PHP_EOL, + $throwable->getMessage() + ), $throwable->getCode(), $throwable); } $ruleDefinition->setRuleClass($findRectorClass); diff --git a/src/Validation/Rules/HasRectorRule.php b/src/Validation/Rules/HasRectorRule.php index 6f0691111..434dcf2f5 100644 --- a/src/Validation/Rules/HasRectorRule.php +++ b/src/Validation/Rules/HasRectorRule.php @@ -75,10 +75,10 @@ private function createFromConfigs(array $configFiles): RectorConfig } catch (Throwable $e) { $message = $e->getMessage(); if (str_starts_with($message, 'Call to undefined method')) { - throw new ShouldNotHappenException('PHP config should have valid method name, you may have typo'); + throw new ShouldNotHappenException('PHP config should have valid method name, you may have typo', $e->getCode(), $e); } - throw new ShouldNotHappenException('Expected config should return callable RectorConfig instance'); + throw new ShouldNotHappenException('Expected config should return callable RectorConfig instance', $e->getCode(), $e); } }