Skip to content

Commit f4b3afa

Browse files
committed
Modernize: Generic/SubversionProperties: use class constant for constant array
1 parent 72be213 commit f4b3afa

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

src/Standards/Generic/Sniffs/VersionControl/SubversionPropertiesSniff.php

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,22 @@ class SubversionPropertiesSniff implements Sniff
2323
* exact value the property should have or NULL if the
2424
* property should just be set but the value is not fixed.
2525
*
26-
* @var array
26+
* @var array<string, string>
2727
*/
28-
protected $properties = [
28+
protected const REQUIRED_PROPERTIES = [
2929
'svn:keywords' => 'Author Id Revision',
3030
'svn:eol-style' => 'native',
3131
];
3232

33+
/**
34+
* The Subversion properties that should be set.
35+
*
36+
* @var array<string, string>
37+
*
38+
* @deprecated 4.0.0 Use the SubversionPropertiesSniff::REQUIRED_PROPERTIES constant instead.
39+
*/
40+
protected $properties = self::REQUIRED_PROPERTIES;
41+
3342

3443
/**
3544
* Returns an array of tokens this test wants to listen for.
@@ -61,10 +70,10 @@ public function process(File $phpcsFile, $stackPtr)
6170
return $phpcsFile->numTokens;
6271
}
6372

64-
$allProperties = ($properties + $this->properties);
73+
$allProperties = ($properties + static::REQUIRED_PROPERTIES);
6574
foreach ($allProperties as $key => $value) {
6675
if (isset($properties[$key]) === true
67-
&& isset($this->properties[$key]) === false
76+
&& isset(static::REQUIRED_PROPERTIES[$key]) === false
6877
) {
6978
$error = 'Unexpected Subversion property "%s" = "%s"';
7079
$data = [
@@ -76,25 +85,25 @@ public function process(File $phpcsFile, $stackPtr)
7685
}
7786

7887
if (isset($properties[$key]) === false
79-
&& isset($this->properties[$key]) === true
88+
&& isset(static::REQUIRED_PROPERTIES[$key]) === true
8089
) {
8190
$error = 'Missing Subversion property "%s" = "%s"';
8291
$data = [
8392
$key,
84-
$this->properties[$key],
93+
static::REQUIRED_PROPERTIES[$key],
8594
];
8695
$phpcsFile->addError($error, $stackPtr, 'Missing', $data);
8796
continue;
8897
}
8998

9099
if ($properties[$key] !== null
91-
&& $properties[$key] !== $this->properties[$key]
100+
&& $properties[$key] !== static::REQUIRED_PROPERTIES[$key]
92101
) {
93102
$error = 'Subversion property "%s" = "%s" does not match "%s"';
94103
$data = [
95104
$key,
96105
$properties[$key],
97-
$this->properties[$key],
106+
static::REQUIRED_PROPERTIES[$key],
98107
];
99108
$phpcsFile->addError($error, $stackPtr, 'NoMatch', $data);
100109
}

0 commit comments

Comments
 (0)