Skip to content

Commit

Permalink
Fix #115 – return original string if preg_replace fails
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianHenryIE committed Oct 10, 2024
1 parent d046e3f commit 6ba3d09
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Licenser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

0 comments on commit 6ba3d09

Please sign in to comment.