File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -106,8 +106,35 @@ private function cleanup(array $data)
106
106
if (isset($data[$file][0])) {
107
107
unset($data[$file][0]);
108
108
}
109
+
110
+ if (file_exists($file)) {
111
+ $numLines = $this->getNumberOfLinesInFile($file);
112
+
113
+ foreach (array_keys($data[$file]) as $line) {
114
+ if (isset($data[$file][$line]) && $line > $numLines) {
115
+ unset($data[$file][$line]);
116
+ }
117
+ }
118
+ }
109
119
}
110
120
111
121
return $data;
112
122
}
123
+
124
+ /**
125
+ * @param string $file
126
+ * @return integer
127
+ * @since Method available since Release 2.0.0
128
+ */
129
+ private function getNumberOfLinesInFile($file)
130
+ {
131
+ $buffer = file_get_contents($file);
132
+ $lines = substr_count($buffer, "\n");
133
+
134
+ if (substr($buffer, -1) !== "\n") {
135
+ $lines++;
136
+ }
137
+
138
+ return $lines;
139
+ }
113
140
}
You can’t perform that action at this time.
0 commit comments