(\d+)/", $doc, $matches); $prevLayer = (int) $matches[1]; if ($prevLayer === $layer) { return; } \preg_match_all("/const V = (\d+)/", $doc, $matches); $prevVersion = $matches[1][1]; $version = $prevVersion + 1; $doc = \str_replace( [ "'layer' => $prevLayer", "TL_telegram_$prevLayer", "const V = $prevVersion" ], [ "'layer' => $layer", "TL_telegram_$layer", "const V = $version" ], $doc ); \file_put_contents('src/danog/MadelineProto/MTProto.php', $doc); }