Skip to content

Commit

Permalink
bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
Leonid74 committed Jan 4, 2024
1 parent f920a54 commit 503e122
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/StringHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ public static function printVar($mixVar, string $sTitle = ''): void
* Возвращает массив, где первый элемент (result) - true, если замена выполнена или замена не требуется,
* false если произошла ошибка, а второй элемент (description) - подробности.
*/
public static function replaceStringInFile(?string $filename, ?string $searchString, ?string $replaceString = '', $enc = static::$encoding): array
public static function replaceStringInFile(?string $filename, ?string $searchString, ?string $replaceString = '', $enc = ''): array
{
try {
// Checking an empty file name
Expand All @@ -520,6 +520,11 @@ public static function replaceStringInFile(?string $filename, ?string $searchStr
throw new \RuntimeException("Передана пустая строка поиска");
}

// Checking an empty enc
if (empty($enc)) {
$enc = static::$encoding;
}

// Checking if the file exists and if it is available for reading/writing
if (!\is_readable($filename) || !\is_writable($filename)) {
throw new \RuntimeException("Файл не доступен для чтения/записи: {$filename}");
Expand Down

0 comments on commit 503e122

Please sign in to comment.