Skip to content

Commit d40e960

Browse files
💄 Minor clean
1 parent 2628a8b commit d40e960

File tree

5 files changed

+9
-56
lines changed

5 files changed

+9
-56
lines changed

TwigCS/Environment/StubbedEnvironment.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@ class StubbedEnvironment extends Environment
2222
/**
2323
* @var TwigFilter[]
2424
*/
25-
private $stubFilters;
25+
protected $stubFilters = [];
2626

2727
/**
2828
* @var TwigFunction[]
2929
*/
30-
private $stubFunctions;
30+
protected $stubFunctions = [];
3131

3232
/**
3333
* @var TwigTest[]
3434
*/
35-
private $stubTests;
35+
protected $stubTests = [];
3636

3737
public function __construct()
3838
{
@@ -44,10 +44,6 @@ public function __construct()
4444
$this->addTokenParser(new TransChoiceTokenParser());
4545
$this->addTokenParser(new TransDefaultDomainTokenParser());
4646
$this->addTokenParser(new TransTokenParser());
47-
48-
$this->stubFilters = [];
49-
$this->stubFunctions = [];
50-
$this->stubTests = [];
5147
}
5248

5349
/**

TwigCS/Ruleset/Ruleset.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,7 @@ class Ruleset
1515
/**
1616
* @var SniffInterface[]
1717
*/
18-
protected $sniffs;
19-
20-
public function __construct()
21-
{
22-
$this->sniffs = [];
23-
}
18+
protected $sniffs = [];
2419

2520
/**
2621
* @return SniffInterface[]

TwigCS/Runner/Fixer.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -241,18 +241,6 @@ public function generateDiff($filePath)
241241
return $diff;
242242
}
243243

244-
/**
245-
* Get a count of fixes that have been performed on the file.
246-
*
247-
* This value is reset every time a new file is started, or an existing file is restarted.
248-
*
249-
* @return int
250-
*/
251-
public function getFixCount()
252-
{
253-
return $this->numFixes;
254-
}
255-
256244
/**
257245
* Get the current content of the file, as a string.
258246
*

TwigCS/Sniff/AbstractSniff.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,37 +27,24 @@ abstract class AbstractSniff implements SniffInterface
2727

2828
/**
2929
* @param Report $report
30-
*
31-
* @return self
3230
*/
3331
public function enableReport(Report $report)
3432
{
3533
$this->report = $report;
36-
37-
return $this;
3834
}
3935

4036
/**
4137
* @param Fixer $fixer
42-
*
43-
* @return self
4438
*/
4539
public function enableFixer(Fixer $fixer)
4640
{
4741
$this->fixer = $fixer;
48-
49-
return $this;
5042
}
5143

52-
/**
53-
* @return self
54-
*/
5544
public function disable()
5645
{
5746
$this->report = null;
5847
$this->fixer = null;
59-
60-
return $this;
6148
}
6249

6350
/**

TwigCS/Tests/AbstractSniffTest.php

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,6 @@
1818
*/
1919
abstract class AbstractSniffTest extends TestCase
2020
{
21-
/**
22-
* @var StubbedEnvironment
23-
*/
24-
private $env;
25-
26-
/**
27-
* @var Linter
28-
*/
29-
private $lint;
30-
31-
public function setUp()
32-
{
33-
$this->env = new StubbedEnvironment();
34-
$this->lint = new Linter($this->env, new Tokenizer($this->env));
35-
}
36-
3721
/**
3822
* Should call $this->checkGenericSniff(new Sniff(), [...]);
3923
*/
@@ -45,16 +29,18 @@ abstract public function testSniff();
4529
*/
4630
protected function checkGenericSniff(SniffInterface $sniff, array $expects)
4731
{
32+
$env = new StubbedEnvironment();
33+
$tokenizer = new Tokenizer($env);
34+
$linter = new Linter($env, $tokenizer);
4835
$ruleset = new Ruleset();
49-
$fixer = new Fixer($ruleset, new Tokenizer($this->env));
5036

5137
try {
5238
$class = new ReflectionClass(get_called_class());
5339
$className = $class->getShortName();
5440
$file = __DIR__.'/Fixtures/'.$className.'.twig';
5541

5642
$ruleset->addSniff($sniff);
57-
$report = $this->lint->run([$file], $ruleset);
43+
$report = $linter->run([$file], $ruleset);
5844
} catch (Exception $e) {
5945
$this->fail($e->getMessage());
6046

@@ -75,6 +61,7 @@ protected function checkGenericSniff(SniffInterface $sniff, array $expects)
7561

7662
$fixedFile = __DIR__.'/Fixtures/'.$className.'.fixed.twig';
7763
if (file_exists($fixedFile)) {
64+
$fixer = new Fixer($ruleset, $tokenizer);
7865
$sniff->enableFixer($fixer);
7966
$fixer->fixFile($file);
8067

0 commit comments

Comments
 (0)