Skip to content

Commit 1388512

Browse files
committed
Modernize: various tests: use class constants for constant arrays
1 parent 7dc700b commit 1388512

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

tests/Core/Tokenizers/PHP/NullsafeObjectOperatorTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ final class NullsafeObjectOperatorTest extends AbstractTokenizerTestCase
2020
*
2121
* @var array<int|string>
2222
*/
23-
protected $find = [
23+
private const TARGET_TOKENS = [
2424
T_NULLSAFE_OBJECT_OPERATOR,
2525
T_OBJECT_OPERATOR,
2626
T_INLINE_THEN,
@@ -38,7 +38,7 @@ public function testObjectOperator()
3838
{
3939
$tokens = $this->phpcsFile->getTokens();
4040

41-
$operator = $this->getTargetToken('/* testObjectOperator */', $this->find);
41+
$operator = $this->getTargetToken('/* testObjectOperator */', self::TARGET_TOKENS);
4242
$this->assertSame(T_OBJECT_OPERATOR, $tokens[$operator]['code'], 'Failed asserting code is object operator');
4343
$this->assertSame('T_OBJECT_OPERATOR', $tokens[$operator]['type'], 'Failed asserting type is object operator');
4444

@@ -59,7 +59,7 @@ public function testNullsafeObjectOperator($testMarker)
5959
{
6060
$tokens = $this->phpcsFile->getTokens();
6161

62-
$operator = $this->getTargetToken($testMarker, $this->find);
62+
$operator = $this->getTargetToken($testMarker, self::TARGET_TOKENS);
6363
$this->assertSame(T_NULLSAFE_OBJECT_OPERATOR, $tokens[$operator]['code'], 'Failed asserting code is nullsafe object operator');
6464
$this->assertSame('T_NULLSAFE_OBJECT_OPERATOR', $tokens[$operator]['type'], 'Failed asserting type is nullsafe object operator');
6565

@@ -99,7 +99,7 @@ public function testTernaryThen($testMarker, $testObjectOperator=false)
9999
{
100100
$tokens = $this->phpcsFile->getTokens();
101101

102-
$operator = $this->getTargetToken($testMarker, $this->find);
102+
$operator = $this->getTargetToken($testMarker, self::TARGET_TOKENS);
103103
$this->assertSame(T_INLINE_THEN, $tokens[$operator]['code'], 'Failed asserting code is inline then');
104104
$this->assertSame('T_INLINE_THEN', $tokens[$operator]['type'], 'Failed asserting type is inline then');
105105

tests/Core/Tokenizers/Tokenizer/RecurseScopeMapDefaultKeywordConditionsTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ final class RecurseScopeMapDefaultKeywordConditionsTest extends AbstractTokenize
2020
*
2121
* @var array<int>
2222
*/
23-
protected $conditionStopTokens = [
23+
private const CONDITION_STOP_TOKENS = [
2424
T_BREAK,
2525
T_CONTINUE,
2626
T_EXIT,
@@ -272,7 +272,7 @@ public function testSwitchDefault($testMarker, $openerMarker, $closerMarker, $co
272272
if (($opener + 1) !== $closer) {
273273
$end = $closer;
274274
if (isset($conditionStopMarker) === true) {
275-
$end = ( $this->getTargetToken($conditionStopMarker, $this->conditionStopTokens) + 1);
275+
$end = ( $this->getTargetToken($conditionStopMarker, self::CONDITION_STOP_TOKENS) + 1);
276276
}
277277

278278
for ($i = ($opener + 1); $i < $end; $i++) {

0 commit comments

Comments
 (0)