Skip to content

Commit 78797a8

Browse files
committed
note
1 parent 42a14de commit 78797a8

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/Analyzer/DuplicatedScenarioTitlesAnalyzer.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Rector\Behastan\Analyzer;
66

7+
use Behat\Gherkin\Node\FeatureNode;
78
use Entropy\Attributes\RelatedTest;
89
use Rector\Behastan\Gherkin\GherkinParser;
910
use Rector\Behastan\Tests\Analyzer\DuplicatedScenarioNamesAnalyzer\DuplicatedScenarioTitlesAnalyzerTest;
@@ -28,6 +29,11 @@ public function analyze(array $featureFiles): array
2829
foreach ($featureFiles as $featureFile) {
2930
$featureGherkin = $this->gherkinParser->parseFile($featureFile->getRealPath());
3031

32+
// @todo test and improve here
33+
if (! $featureGherkin instanceof FeatureNode) {
34+
continue;
35+
}
36+
3137
foreach ($featureGherkin->getScenarios() as $scenario) {
3238
$scenarioNamesToFiles[$scenario->getTitle()][] = $featureFile->getRealPath();
3339
}

src/Gherkin/GherkinParser.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,10 @@ public function __construct()
3535
$this->parser = new Parser(new Lexer($arrayKeywords));
3636
}
3737

38-
public function parseFile(string $filePath): FeatureNode
38+
public function parseFile(string $filePath): ?FeatureNode
3939
{
4040
$fileContents = FileSystem::read($filePath);
4141

42-
$featureNode = $this->parser->parse($fileContents);
43-
Assert::isInstanceOf($featureNode, FeatureNode::class);
44-
45-
return $featureNode;
42+
return $this->parser->parse($fileContents);
4643
}
4744
}

0 commit comments

Comments
 (0)