Skip to content

Commit e89075f

Browse files
committed
Ruleset: use MsgCollector for "setting non-existent property" error
Includes minor adjustment to the error message (removal of "Ruleset invalid" and punctuation).
1 parent a28f133 commit e89075f

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/Ruleset.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1575,9 +1575,9 @@ public function setSniffProperty($sniffClass, $name, $settings)
15751575

15761576
if ($isSettable === false) {
15771577
if ($settings['scope'] === 'sniff') {
1578-
$notice = "ERROR: Ruleset invalid. Property \"$propertyName\" does not exist on sniff ";
1579-
$notice .= array_search($sniffClass, $this->sniffCodes, true);
1580-
throw new RuntimeException($notice);
1578+
$notice = "Property \"$propertyName\" does not exist on sniff ";
1579+
$notice .= array_search($sniffClass, $this->sniffCodes, true).'.';
1580+
$this->msgCache->add($notice, MsgCollector::ERROR);
15811581
}
15821582

15831583
return;

tests/Core/Ruleset/SetSniffPropertyTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public function testSetPropertyAppliesPropertyToMultipleSniffsInCategory()
135135
*/
136136
public function testSetPropertyThrowsErrorOnInvalidProperty()
137137
{
138-
$exceptionMsg = 'ERROR: Ruleset invalid. Property "indentation" does not exist on sniff Generic.Arrays.ArrayIndent';
138+
$exceptionMsg = 'ERROR: Property "indentation" does not exist on sniff Generic.Arrays.ArrayIndent.'.PHP_EOL.PHP_EOL;
139139
$this->expectRuntimeExceptionMessage($exceptionMsg);
140140

141141
// Set up the ruleset.
@@ -155,7 +155,7 @@ public function testSetPropertyThrowsErrorOnInvalidProperty()
155155
*/
156156
public function testSetPropertyThrowsErrorWhenPropertyOnlyAllowedViaAttribute()
157157
{
158-
$exceptionMsg = 'ERROR: Ruleset invalid. Property "arbitrarystring" does not exist on sniff TestStandard.SetProperty.NotAllowedViaAttribute';
158+
$exceptionMsg = 'ERROR: Property "arbitrarystring" does not exist on sniff TestStandard.SetProperty.NotAllowedViaAttribute.'.PHP_EOL.PHP_EOL;
159159
$this->expectRuntimeExceptionMessage($exceptionMsg);
160160

161161
// Set up the ruleset.

0 commit comments

Comments
 (0)