Vqmods offset value is for replacing a line and the following x lines, however the search is for one line only. Vqmod doesn't match multiple lines in search.
Example :
Input
public function index() {
$a = rand();
$b = rand();
if ($a == $b) {
echo 'oh noes';
return false;
}
}
Script
<?xml version="1.0" encoding="UTF-8"?>
<modification>
<id>Replace many lines with one</id>
<version>1.0</version>
<vqmver>2.X</vqmver>
<author>xxx</author>
<file name="path/to/testfile.php">
<operation info="Replace index function">
<search position="replace" offset="7"><![CDATA[
public function index() {
]]></search>
<add><![CDATA[
public function index($arr = array()) {
foreach ($arr as $a) {
echo $a;
}
}
]]></add>
</operation>
</file>
</modification>
Output
public function index($arr = array()) {
foreach ($arr as $a) {
echo $a;
}
}
Note : There are still 7 blank lines. The offset clears the extra 7 lines of code from the input, but the replaced code is added in place of the initial line. So there will be 7 extra spaces after the new code, but it will not affect the code functionality, only the look of the vqcache file which is of no importance.