Skip to content

Commit c6a579e

Browse files
authored
Merge pull request #884 from PHPCSStandards/feature/messagecollector-follow-up
Remove some redundant code
2 parents 18578da + 27fd29a commit c6a579e

File tree

3 files changed

+1
-26
lines changed

3 files changed

+1
-26
lines changed

src/Files/File.php

+1-17
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,6 @@ public function process()
346346
$listenerIgnoreTo = [];
347347
$inTests = defined('PHP_CODESNIFFER_IN_TESTS');
348348
$checkAnnotations = $this->config->annotations;
349-
$annotationErrors = [];
350349

351350
// Foreach of the listeners that have registered to listen for this
352351
// token, get them to process it.
@@ -415,15 +414,7 @@ public function process()
415414
'scope' => 'sniff',
416415
];
417416
$listenerClass = $this->ruleset->sniffCodes[$listenerCode];
418-
try {
419-
$this->ruleset->setSniffProperty($listenerClass, $propertyCode, $settings);
420-
} catch (RuntimeException $e) {
421-
// Non-existant property being set via an inline annotation.
422-
// This is typically a PHPCS test case file, but we can't throw an error on the annotation
423-
// line as it would get ignored. We also don't want this error to block
424-
// the scan of the current file, so collect these and throw later.
425-
$annotationErrors[] = 'Line '.$token['line'].': '.str_replace('Ruleset invalid. ', '', $e->getMessage());
426-
}
417+
$this->ruleset->setSniffProperty($listenerClass, $propertyCode, $settings);
427418
}
428419
}
429420
}//end if
@@ -553,13 +544,6 @@ public function process()
553544
}
554545
}
555546

556-
if ($annotationErrors !== []) {
557-
$error = 'Encountered invalid inline phpcs:set annotations. Found:'.PHP_EOL;
558-
$error .= implode(PHP_EOL, $annotationErrors);
559-
560-
$this->addWarning($error, null, 'Internal.PropertyDoesNotExist');
561-
}
562-
563547
if (PHP_CODESNIFFER_VERBOSITY > 2) {
564548
echo "\t*** END TOKEN PROCESSING ***".PHP_EOL;
565549
echo "\t*** START SNIFF PROCESSING REPORT ***".PHP_EOL;
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,2 @@
11
<?php
22
$output = `ls -al`;
3-
4-
// Testing an invalid phpcs:set annotations.
5-
// This test is unrelated to this sniff, but the issue needs a sniff to be tested.
6-
// phpcs:set Generic.PHP.BacktickOperator unknown 10
7-
8-
// Make sure errors after an incorrect annotation are still being thrown.
9-
$output = `ls -al`;

src/Standards/Generic/Tests/PHP/BacktickOperatorUnitTest.php

-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ public function getErrorList()
3232
{
3333
return [
3434
2 => 2,
35-
9 => 2,
3635
];
3736

3837
}//end getErrorList()
@@ -48,7 +47,6 @@ public function getErrorList()
4847
*/
4948
public function getWarningList()
5049
{
51-
// Warning about incorrect annotation will be shown on line 1 once PR #3915 would be merged.
5250
return [];
5351

5452
}//end getWarningList()

0 commit comments

Comments
 (0)