@@ -153,28 +153,62 @@ class File
153
153
protected $ warningCount = 0 ;
154
154
155
155
/**
156
- * The total number of errors that can be fixed.
156
+ * The original total number of errors that can be fixed (first run on a file).
157
+ *
158
+ * @readonly This should be regarded as an immutable property.
159
+ *
160
+ * @var integer
161
+ */
162
+ private $ fixableErrorCountFirstRun ;
163
+
164
+ /**
165
+ * The original total number of warnings that can be fixed (first run on a file).
166
+ *
167
+ * @readonly This should be regarded as an immutable property.
168
+ *
169
+ * @var integer
170
+ */
171
+ private $ fixableWarningCountFirstRun ;
172
+
173
+ /**
174
+ * The current total number of errors that can be fixed.
157
175
*
158
176
* @var integer
159
177
*/
160
178
protected $ fixableErrorCount = 0 ;
161
179
162
180
/**
163
- * The total number of warnings that can be fixed.
181
+ * The current total number of warnings that can be fixed.
164
182
*
165
183
* @var integer
166
184
*/
167
185
protected $ fixableWarningCount = 0 ;
168
186
169
187
/**
170
- * The total number of errors that were fixed.
188
+ * The actual number of errors and warnings that were fixed.
189
+ *
190
+ * I.e. how many fixes were applied. This may be higher than the originally found
191
+ * issues if the fixer from one sniff causes other sniffs to come into play in follow-up loops.
192
+ * Example: if a brace is moved to a new line, the `ScopeIndent` sniff may need to ensure
193
+ * the brace is indented correctly in the next loop.
194
+ *
195
+ * @var integer
196
+ */
197
+ protected $ fixedCount = 0 ;
198
+
199
+ /**
200
+ * The effective number of errors that were fixed.
201
+ *
202
+ * I.e. how many of the originally found errors were fixed.
171
203
*
172
204
* @var integer
173
205
*/
174
206
protected $ fixedErrorCount = 0 ;
175
207
176
208
/**
177
- * The total number of warnings that were fixed.
209
+ * The effective number of warnings that were fixed.
210
+ *
211
+ * I.e. how many of the originally found warnings were fixed.
178
212
*
179
213
* @var integer
180
214
*/
@@ -521,9 +555,18 @@ public function process()
521
555
StatusWriter::write ('*** END SNIFF PROCESSING REPORT *** ' , 1 );
522
556
}
523
557
524
- //$this->fixedCount += $this->fixer->getFixCount();
525
- $ this ->fixedErrorCount += $ this ->fixer ->getFixedErrorCount ();
526
- $ this ->fixedWarningCount += $ this ->fixer ->getFixedWarningCount ();
558
+ if (isset ($ this ->fixableErrorCountFirstRun , $ this ->fixableWarningCountFirstRun ) === false ) {
559
+ $ this ->fixableErrorCountFirstRun = $ this ->fixableErrorCount ;
560
+ $ this ->fixableWarningCountFirstRun = $ this ->fixableWarningCount ;
561
+ }
562
+
563
+ // This is still needed for the progress reporting ?
564
+ // Only if the error/warning counts don't work, as otherwise, it can be calculated in the getter method.
565
+ // Then again, maybe we should still leave it in as-is and not have the calculation to have actual vs effective fixes in File too.
566
+ $ this ->fixedCount += $ this ->fixer ->getFixCount ();
567
+ // THIS IS WHAT I NEED TO LOOK AT/FIX
568
+ $ this ->fixedErrorCount = ($ this ->fixableErrorCountFirstRun - $ this ->fixableErrorCount );
569
+ $ this ->fixedWarningCount = ($ this ->fixableWarningCountFirstRun - $ this ->fixableWarningCount );
527
570
528
571
}//end process()
529
572
@@ -1166,37 +1209,52 @@ public function getFixableWarningCount()
1166
1209
1167
1210
1168
1211
/**
1169
- * Returns the number of fixed errors/warnings.
1212
+ * Returns the actual number of fixed errors/warnings.
1170
1213
*
1171
1214
* @return int
1172
1215
*/
1173
1216
public function getFixedCount ()
1174
1217
{
1175
- return ($ this ->fixedErrorCount + $ this ->fixedWarningCount );
1218
+ return $ this ->fixedCount ;
1219
+ //return ($this->fixedErrorCount + $this->fixedWarningCount);
1176
1220
1177
1221
}//end getFixedCount()
1178
1222
1179
1223
1180
1224
/**
1181
- * Returns the number of fixed errors.
1225
+ * Returns the effective number of fixed errors.
1182
1226
*
1183
1227
* @return int
1184
1228
*/
1185
1229
public function getFixedErrorCount ()
1186
1230
{
1187
- return $ this ->fixedErrorCount ;
1231
+ /*
1232
+ if ($this->fixedErrorCount === 0 && PHP_CODESNIFFER_CBF === true) {
1233
+ return $this->fixer->getFixedErrorCount();
1234
+ } else {
1235
+ */
1236
+ // Using value retrieved from cache/child process.
1237
+ return $ this ->fixedErrorCount ;
1238
+ // }
1188
1239
1189
1240
}//end getFixedErrorCount()
1190
1241
1191
1242
1192
1243
/**
1193
- * Returns the number of fixed warnings.
1244
+ * Returns the effective number of fixed warnings.
1194
1245
*
1195
1246
* @return int
1196
1247
*/
1197
1248
public function getFixedWarningCount ()
1198
1249
{
1199
- return $ this ->fixedWarningCount ;
1250
+ /*
1251
+ if ($this->fixedWarningCount === 0 && PHP_CODESNIFFER_CBF === true) {
1252
+ return $this->fixer->getFixedWarningCount();
1253
+ } else {
1254
+ */
1255
+ // Using value retrieved from cache/child process.
1256
+ return $ this ->fixedWarningCount ;
1257
+ // }
1200
1258
1201
1259
}//end getFixedWarningCount()
1202
1260
0 commit comments