Skip to content

Commit 515caec

Browse files
committed
Verbose diff report output has slightly changed to improve readability
1 parent c328457 commit 515caec

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

package.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ http://pear.php.net/dtd/package-2.0.xsd">
2626
</stability>
2727
<license uri="https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt">BSD 3-Clause License</license>
2828
<notes>
29+
- Verbose diff report output has slightly changed to improve readability
30+
-- Fully qualified class names are now replaced with sniff codes
31+
-- Tokens being changed now display the line number they are on
2932
- PSR12.Files.FileHeader no longer ignores comments preceding a use, namespace, or declare statement
3033
- PSR12.Files.FileHeader now allows a hashbang line at the top of the file
3134
- Fixed bug #2615 : Constant visibility false positive on non-class constants

src/Fixer.php

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,10 @@ public function beginChangeset()
355355
$sniff = $bt[1]['class'];
356356
$line = $bt[0]['line'];
357357

358+
$sniff = Util\Common::getSniffCode($sniff);
359+
358360
@ob_end_clean();
359-
echo "\t=> Changeset started by $sniff (line $line)".PHP_EOL;
361+
echo "\t=> Changeset started by $sniff:$line".PHP_EOL;
360362
ob_start();
361363
}
362364

@@ -434,10 +436,12 @@ public function rollbackChangeset()
434436
$line = $bt[0]['line'];
435437
}
436438

439+
$sniff = Util\Common::getSniffCode($sniff);
440+
437441
$numChanges = count($this->changeset);
438442

439443
@ob_end_clean();
440-
echo "\t\tR: $sniff (line $line) rolled back the changeset ($numChanges changes)".PHP_EOL;
444+
echo "\t\tR: $sniff:$line rolled back the changeset ($numChanges changes)".PHP_EOL;
441445
echo "\t=> Changeset rolled back".PHP_EOL;
442446
ob_start();
443447
}
@@ -489,8 +493,11 @@ public function replaceToken($stackPtr, $content)
489493
$line = $bt[0]['line'];
490494
}
491495

496+
$sniff = Util\Common::getSniffCode($sniff);
497+
492498
$tokens = $this->currentFile->getTokens();
493499
$type = $tokens[$stackPtr]['type'];
500+
$tokenLine = $tokens[$stackPtr]['line'];
494501
$oldContent = Common::prepareForOutput($this->tokens[$stackPtr]);
495502
$newContent = Common::prepareForOutput($content);
496503
if (trim($this->tokens[$stackPtr]) === '' && isset($this->tokens[($stackPtr + 1)]) === true) {
@@ -506,7 +513,7 @@ public function replaceToken($stackPtr, $content)
506513

507514
if (PHP_CODESNIFFER_VERBOSITY > 1) {
508515
@ob_end_clean();
509-
echo "\t\tQ: $sniff (line $line) replaced token $stackPtr ($type) \"$oldContent\" => \"$newContent\"".PHP_EOL;
516+
echo "\t\tQ: $sniff:$line replaced token $stackPtr ($type on line $tokenLine) \"$oldContent\" => \"$newContent\"".PHP_EOL;
510517
ob_start();
511518
}
512519

@@ -532,8 +539,8 @@ public function replaceToken($stackPtr, $content)
532539
$loop = $this->oldTokenValues[$stackPtr]['loop'];
533540

534541
@ob_end_clean();
535-
echo "$indent**** $sniff (line $line) has possible conflict with another sniff on loop $loop; caused by the following change ****".PHP_EOL;
536-
echo "$indent**** replaced token $stackPtr ($type) \"$oldContent\" => \"$newContent\" ****".PHP_EOL;
542+
echo "$indent**** $sniff:$line has possible conflict with another sniff on loop $loop; caused by the following change ****".PHP_EOL;
543+
echo "$indent**** replaced token $stackPtr ($type on line $tokenLine) \"$oldContent\" => \"$newContent\" ****".PHP_EOL;
537544
}
538545

539546
if ($this->oldTokenValues[$stackPtr]['loop'] >= ($this->loops - 1)) {
@@ -569,7 +576,7 @@ public function replaceToken($stackPtr, $content)
569576
ob_end_clean();
570577
}
571578

572-
echo "$indent$sniff (line $line) replaced token $stackPtr ($type) \"$oldContent\" => \"$newContent\"".PHP_EOL;
579+
echo "$indent$sniff:$line replaced token $stackPtr ($type on line $tokenLine) \"$oldContent\" => \"$newContent\"".PHP_EOL;
573580
ob_start();
574581
}
575582

@@ -601,8 +608,11 @@ public function revertToken($stackPtr)
601608
$line = $bt[0]['line'];
602609
}
603610

611+
$sniff = Util\Common::getSniffCode($sniff);
612+
604613
$tokens = $this->currentFile->getTokens();
605614
$type = $tokens[$stackPtr]['type'];
615+
$tokenLine = $tokens[$stackPtr]['line'];
606616
$oldContent = Common::prepareForOutput($this->tokens[$stackPtr]);
607617
$newContent = Common::prepareForOutput($this->fixedTokens[$stackPtr]);
608618
if (trim($this->tokens[$stackPtr]) === '' && isset($tokens[($stackPtr + 1)]) === true) {
@@ -624,7 +634,7 @@ public function revertToken($stackPtr)
624634
}
625635

626636
@ob_end_clean();
627-
echo "$indent$sniff (line $line) reverted token $stackPtr ($type) \"$oldContent\" => \"$newContent\"".PHP_EOL;
637+
echo "$indent$sniff:$line reverted token $stackPtr ($type on line $tokenLine) \"$oldContent\" => \"$newContent\"".PHP_EOL;
628638
ob_start();
629639
}
630640

0 commit comments

Comments
 (0)