From 6ba3d09071d877ddad0f1487f580d4b5985b18f2 Mon Sep 17 00:00:00 2001 From: Brian Henry Date: Thu, 10 Oct 2024 13:41:51 -0700 Subject: [PATCH] =?UTF-8?q?Fix=20#115=20=E2=80=93=20return=20original=20st?= =?UTF-8?q?ring=20if=20preg=5Freplace=20fails?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Licenser.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Licenser.php b/src/Licenser.php index ca524637..06dd0f6e 100644 --- a/src/Licenser.php +++ b/src/Licenser.php @@ -286,6 +286,12 @@ public function addChangeDeclarationToPhpString( ); } - return $updatedPhpString; + /** + * In some cases `preg_replace_callback` returns `null` instead of the string. If that happens, return + * the original, unaltered string. + * + * @see https://github.com/BrianHenryIE/strauss/issues/115 + */ + return $updatedPhpString ?? $phpString; } }