These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | use Behat\Gherkin\Node\OutlineNode; |
||
4 | use Behat\Gherkin\Node\ScenarioNode; |
||
5 | use Behat\Gherkin\Node\TableNode; |
||
6 | |||
7 | require 'vendor/autoload.php'; |
||
8 | |||
9 | $feature = <<<FEATURE |
||
10 | Feature: All quantities and units |
||
11 | Test all metadata and conversions between all units in all quantities |
||
12 | |||
13 | Scenario Outline: Available units per quantity |
||
14 | Then I should have "<Number>" "<Quantity>" units |
||
15 | |||
16 | Examples: |
||
17 | | Quantity | Number |oele| |
||
18 | | Temperature | 3 | boele | |
||
19 | | Volume | 13 | tra | |
||
20 | | Mileage | 400 |lalala | |
||
21 | |||
22 | Scenario: Users |
||
23 | Given I create these users: |
||
24 | | name | age | |
||
25 | | jeff | 101 | |
||
26 | | jaap | 16 | |
||
27 | | john | 3 | |
||
28 | FEATURE; |
||
29 | |||
30 | header('Content-type: text/plain'); |
||
31 | |||
32 | $keywords = new Behat\Gherkin\Keywords\ArrayKeywords(array( |
||
33 | 'en' => array( |
||
34 | 'feature' => 'Feature', |
||
35 | 'background' => 'Background', |
||
36 | 'scenario' => 'Scenario', |
||
37 | 'scenario_outline' => 'Scenario Outline', |
||
38 | 'examples' => 'Examples', |
||
39 | 'given' => 'Given', |
||
40 | 'when' => 'When', |
||
41 | 'then' => 'Then', |
||
42 | 'and' => 'And', |
||
43 | 'but' => 'But' |
||
44 | ), |
||
45 | )); |
||
46 | $lexer = new Behat\Gherkin\Lexer($keywords); |
||
47 | $parser = new Behat\Gherkin\Parser($lexer); |
||
48 | |||
49 | try { |
||
50 | $feature = $parser->parse($feature); |
||
51 | } |
||
52 | catch (Exception $ex) { |
||
53 | echo $ex->getMessage() . "\n"; |
||
54 | exit; |
||
55 | } |
||
56 | |||
57 | foreach ($feature->getScenarios() as $scenario) { |
||
58 | if ($scenario instanceof OutlineNode) { |
||
59 | echo $scenario->getExampleTable() . "\n\n"; |
||
60 | } |
||
61 | elseif ($scenario instanceof ScenarioNode) { |
||
62 | foreach ($scenario->getSteps() as $step) { |
||
63 | foreach ($step->getArguments() as $argument) { |
||
64 | if ($argument instanceof TableNode) { |
||
65 | echo $argument . "\n\n"; |
||
66 | } |
||
67 | } |
||
68 | // print_r($step); |
||
1 ignored issue
–
show
|
|||
69 | } |
||
70 | } |
||
71 | } |
||
72 | |||
73 | print_r($feature); |
||
74 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.