Skip to content
This repository was archived by the owner on May 6, 2025. It is now read-only.

Commit c118453

Browse files
committed
Quickfix
1 parent 2a878df commit c118453

File tree

5 files changed

+55
-11
lines changed

5 files changed

+55
-11
lines changed

src/DetectorFactory.php

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,10 @@ public function create(Configuration $configuration, OutputInterface $output)
100100
'Deprecation detection'
101101
);
102102
$deprecationUsageParser = $this->getUsageParser($configuration);
103-
$deprecationUsageFinder = new ParsedPhpFileFinder(
103+
$deprecationUsageFinder = ParsedPhpFileFinder::usageFinder(
104104
$deprecationUsageParser,
105105
$deprecationProgressOutput
106106
);
107-
$deprecationUsageFinder
108-
->exclude('vendor')
109-
->exclude('Tests')
110-
->exclude('Test');
111107

112108
$this->ancestorResolver = new AncestorResolver($deprecationUsageParser);
113109

@@ -117,15 +113,10 @@ public function create(Configuration $configuration, OutputInterface $output)
117113
'RuleSet generation'
118114
);
119115
$ruleSetDeprecationParser = $this->getDeprecationParser();
120-
$ruleSetDeprecationFinder = new ParsedPhpFileFinder(
116+
$ruleSetDeprecationFinder = ParsedPhpFileFinder::deprecationFinder(
121117
$ruleSetDeprecationParser,
122118
$ruleSetProgressOutput
123119
);
124-
$ruleSetDeprecationFinder
125-
->contains('@deprecated')
126-
->exclude('vendor')
127-
->exclude('Tests')
128-
->exclude('Test');
129120
$deprecationDirectoryTraverser = new DirectoryTraverser($ruleSetDeprecationFinder);
130121

131122
$violationDetector = $this->getViolationDetector($configuration);

src/Finder/ParsedPhpFileFinder.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,47 @@ public function getParserErrors()
8585
{
8686
return $this->parserErrors;
8787
}
88+
89+
/**
90+
* @param ParserInterface $parser
91+
* @param VerboseProgressOutput $progressOutput
92+
* @return ParsedPhpFileFinder
93+
*/
94+
public static function deprecationFinder(ParserInterface $parser, VerboseProgressOutput $progressOutput)
95+
{
96+
return (new ParsedPhpFileFinder($parser, $progressOutput))
97+
->contains('@deprecated')
98+
->exclude('vendor')
99+
->exclude('Tests')
100+
->exclude('Test');
101+
}
102+
103+
/**
104+
* @param ParserInterface $parser
105+
* @param VerboseProgressOutput $progressOutput
106+
* @return ParsedPhpFileFinder
107+
*/
108+
public static function usageFinder(ParserInterface $parser, VerboseProgressOutput $progressOutput)
109+
{
110+
return (new ParsedPhpFileFinder($parser, $progressOutput))
111+
->exclude('vendor')
112+
->exclude('Tests')
113+
->exclude('Test');
114+
}
115+
116+
/**
117+
* @return ParserInterface
118+
*/
119+
public function getParser()
120+
{
121+
return $this->parser;
122+
}
123+
124+
/**
125+
* @return VerboseProgressOutput
126+
*/
127+
public function getOutput()
128+
{
129+
return $this->progressOutput;
130+
}
88131
}

src/RuleSet/DirectoryTraverser.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,12 @@ public function traverse($path, RuleSet $ruleSet = null)
4848

4949
return $ruleSet;
5050
}
51+
52+
public function reset()
53+
{
54+
$this->finder = ParsedPhpFileFinder::deprecationFinder(
55+
$this->finder->getParser(),
56+
$this->finder->getOutput()
57+
);
58+
}
5159
}

src/RuleSet/Loader/Composer/ComposerLoader.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ private function loadPackageRuleSet(Package $package)
7373
if ($this->cache->has($key)) {
7474
$ruleSet = $this->cache->getCachedRuleSet($key);
7575
} elseif (is_dir($path = $package->getPackagePath(self::PACKAGE_PATH))) {
76+
$this->traverser->reset();
7677
$ruleSet = $this->traverser->traverse($path);
7778
$this->cache->cacheRuleSet($key, $ruleSet);
7879
} else {

tests/RuleSet/Loader/Composer/ComposerLoaderTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ public function testLoadRuleSet()
8585

8686
$traverser = $this->prophesize('SensioLabs\DeprecationDetector\RuleSet\DirectoryTraverser');
8787
$traverser->traverse(vfsStream::url('root/vendor/avendor/anotherlib'))->willReturn($aVendorAnotherLibRuleSet);
88+
$traverser->reset()->shouldBeCalled();
8889
$cache->cacheRuleSet('vendor_anotherlib_1.0.0', $aVendorAnotherLibRuleSet)->shouldBeCalled();
8990

9091
$factory = $this->prophesize('SensioLabs\DeprecationDetector\RuleSet\Loader\Composer\ComposerFactory');

0 commit comments

Comments
 (0)