Skip to content

Commit

Permalink
Apply fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
uuf6429 committed Dec 11, 2024
1 parent 50fdacc commit 8ee3e6f
Show file tree
Hide file tree
Showing 82 changed files with 2,256 additions and 1,495 deletions.
8 changes: 4 additions & 4 deletions src/Behat/Gherkin/Cache/CacheInterface.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/*
* This file is part of the Behat Gherkin.
* This file is part of the Behat Gherkin Parser.
* (c) Konstantin Kudryashov <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
Expand All @@ -22,8 +22,8 @@ interface CacheInterface
/**
* Checks that cache for feature exists and is fresh.
*
* @param string $path Feature path
* @param integer $timestamp The last time feature was updated
* @param string $path Feature path
* @param int $timestamp The last time feature was updated
*
* @return bool
*/
Expand All @@ -41,7 +41,7 @@ public function read($path);
/**
* Caches feature node.
*
* @param string $path Feature path
* @param string $path Feature path
* @param FeatureNode $feature Feature instance
*/
public function write($path, FeatureNode $feature);
Expand Down
28 changes: 14 additions & 14 deletions src/Behat/Gherkin/Cache/FileCache.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<?php

/*
* This file is part of the Behat Gherkin.
* (c) Konstantin Kudryashov <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
* This file is part of the Behat Gherkin Parser.
* (c) Konstantin Kudryashov <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Behat\Gherkin\Cache;

use Behat\Gherkin\Exception\CacheException;
use Behat\Gherkin\Node\FeatureNode;
use Behat\Gherkin\Gherkin;
use Behat\Gherkin\Node\FeatureNode;

/**
* File cache.
Expand All @@ -27,13 +27,13 @@ class FileCache implements CacheInterface
/**
* Initializes file cache.
*
* @param string $path Path to the folder where to store caches.
* @param string $path path to the folder where to store caches
*
* @throws CacheException
*/
public function __construct($path)
{
$this->path = rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'v'.Gherkin::VERSION;
$this->path = rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . 'v' . Gherkin::VERSION;

if (!is_dir($this->path)) {
@mkdir($this->path, 0777, true);
Expand All @@ -47,8 +47,8 @@ public function __construct($path)
/**
* Checks that cache for feature exists and is fresh.
*
* @param string $path Feature path
* @param integer $timestamp The last time feature was updated
* @param string $path Feature path
* @param int $timestamp The last time feature was updated
*
* @return bool
*/
Expand Down Expand Up @@ -78,7 +78,7 @@ public function read($path)
$feature = unserialize(file_get_contents($cachePath));

if (!$feature instanceof FeatureNode) {
throw new CacheException(sprintf('Can not load cache for a feature "%s" from "%s".', $path, $cachePath ));
throw new CacheException(sprintf('Can not load cache for a feature "%s" from "%s".', $path, $cachePath));
}

return $feature;
Expand All @@ -87,7 +87,7 @@ public function read($path)
/**
* Caches feature node.
*
* @param string $path Feature path
* @param string $path Feature path
* @param FeatureNode $feature Feature instance
*/
public function write($path, FeatureNode $feature)
Expand All @@ -104,6 +104,6 @@ public function write($path, FeatureNode $feature)
*/
protected function getCachePathFor($path)
{
return $this->path.'/'.md5($path).'.feature.cache';
return $this->path . '/' . md5($path) . '.feature.cache';
}
}
24 changes: 12 additions & 12 deletions src/Behat/Gherkin/Cache/MemoryCache.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php

/*
* This file is part of the Behat Gherkin.
* (c) Konstantin Kudryashov <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
* This file is part of the Behat Gherkin Parser.
* (c) Konstantin Kudryashov <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Behat\Gherkin\Cache;

Expand All @@ -20,14 +20,14 @@
*/
class MemoryCache implements CacheInterface
{
private $features = array();
private $timestamps = array();
private $features = [];
private $timestamps = [];

/**
* Checks that cache for feature exists and is fresh.
*
* @param string $path Feature path
* @param integer $timestamp The last time feature was updated
* @param string $path Feature path
* @param int $timestamp The last time feature was updated
*
* @return bool
*/
Expand Down Expand Up @@ -55,12 +55,12 @@ public function read($path)
/**
* Caches feature node.
*
* @param string $path Feature path
* @param string $path Feature path
* @param FeatureNode $feature Feature instance
*/
public function write($path, FeatureNode $feature)
{
$this->features[$path] = $feature;
$this->features[$path] = $feature;
$this->timestamps[$path] = time();
}
}
6 changes: 2 additions & 4 deletions src/Behat/Gherkin/Exception/CacheException.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/*
* This file is part of the Behat Gherkin.
* This file is part of the Behat Gherkin Parser.
* (c) Konstantin Kudryashov <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
Expand All @@ -10,13 +10,11 @@

namespace Behat\Gherkin\Exception;

use RuntimeException;

/**
* Cache exception.
*
* @author Konstantin Kudryashov <[email protected]>
*/
class CacheException extends RuntimeException implements Exception
class CacheException extends \RuntimeException implements Exception
{
}
2 changes: 1 addition & 1 deletion src/Behat/Gherkin/Exception/Exception.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/*
* This file is part of the Behat Gherkin.
* This file is part of the Behat Gherkin Parser.
* (c) Konstantin Kudryashov <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
Expand Down
6 changes: 2 additions & 4 deletions src/Behat/Gherkin/Exception/LexerException.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/*
* This file is part of the Behat Gherkin.
* This file is part of the Behat Gherkin Parser.
* (c) Konstantin Kudryashov <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
Expand All @@ -10,8 +10,6 @@

namespace Behat\Gherkin\Exception;

use RuntimeException;

class LexerException extends RuntimeException implements Exception
class LexerException extends \RuntimeException implements Exception
{
}
6 changes: 2 additions & 4 deletions src/Behat/Gherkin/Exception/NodeException.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/*
* This file is part of the Behat Gherkin.
* This file is part of the Behat Gherkin Parser.
* (c) Konstantin Kudryashov <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
Expand All @@ -10,8 +10,6 @@

namespace Behat\Gherkin\Exception;

use RuntimeException;

class NodeException extends RuntimeException implements Exception
class NodeException extends \RuntimeException implements Exception
{
}
6 changes: 2 additions & 4 deletions src/Behat/Gherkin/Exception/ParserException.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/*
* This file is part of the Behat Gherkin.
* This file is part of the Behat Gherkin Parser.
* (c) Konstantin Kudryashov <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
Expand All @@ -10,8 +10,6 @@

namespace Behat\Gherkin\Exception;

use RuntimeException;

class ParserException extends RuntimeException implements Exception
class ParserException extends \RuntimeException implements Exception
{
}
6 changes: 2 additions & 4 deletions src/Behat/Gherkin/Filter/ComplexFilter.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/*
* This file is part of the Behat Gherkin.
* This file is part of the Behat Gherkin Parser.
* (c) Konstantin Kudryashov <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
Expand All @@ -22,13 +22,11 @@ abstract class ComplexFilter implements ComplexFilterInterface
/**
* Filters feature according to the filter.
*
* @param FeatureNode $feature
*
* @return FeatureNode
*/
public function filterFeature(FeatureNode $feature)
{
$scenarios = array();
$scenarios = [];
foreach ($feature->getScenarios() as $scenario) {
if (!$this->isScenarioMatch($feature, $scenario)) {
continue;
Expand Down
4 changes: 2 additions & 2 deletions src/Behat/Gherkin/Filter/ComplexFilterInterface.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/*
* This file is part of the Behat Gherkin.
* This file is part of the Behat Gherkin Parser.
* (c) Konstantin Kudryashov <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
Expand All @@ -23,7 +23,7 @@ interface ComplexFilterInterface extends FeatureFilterInterface
/**
* Checks if scenario or outline matches specified filter.
*
* @param FeatureNode $feature Feature node instance
* @param FeatureNode $feature Feature node instance
* @param ScenarioInterface $scenario Scenario or Outline node instance
*
* @return bool
Expand Down
4 changes: 1 addition & 3 deletions src/Behat/Gherkin/Filter/FeatureFilterInterface.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/*
* This file is part of the Behat Gherkin.
* This file is part of the Behat Gherkin Parser.
* (c) Konstantin Kudryashov <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
Expand Down Expand Up @@ -31,8 +31,6 @@ public function isFeatureMatch(FeatureNode $feature);
/**
* Filters feature according to the filter and returns new one.
*
* @param FeatureNode $feature
*
* @return FeatureNode
*/
public function filterFeature(FeatureNode $feature);
Expand Down
2 changes: 1 addition & 1 deletion src/Behat/Gherkin/Filter/FilterInterface.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/*
* This file is part of the Behat Gherkin.
* This file is part of the Behat Gherkin Parser.
* (c) Konstantin Kudryashov <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
Expand Down
10 changes: 4 additions & 6 deletions src/Behat/Gherkin/Filter/LineFilter.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/*
* This file is part of the Behat Gherkin.
* This file is part of the Behat Gherkin Parser.
* (c) Konstantin Kudryashov <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
Expand Down Expand Up @@ -70,13 +70,11 @@ public function isScenarioMatch(ScenarioInterface $scenario)
/**
* Filters feature according to the filter and returns new one.
*
* @param FeatureNode $feature
*
* @return FeatureNode
*/
public function filterFeature(FeatureNode $feature)
{
$scenarios = array();
$scenarios = [];
foreach ($feature->getScenarios() as $scenario) {
if (!$this->isScenarioMatch($scenario)) {
continue;
Expand All @@ -88,7 +86,7 @@ public function filterFeature(FeatureNode $feature)
$lines = array_keys($table);

if (in_array($this->filterLine, $lines)) {
$filteredTable = array($lines[0] => $table[$lines[0]]);
$filteredTable = [$lines[0] => $table[$lines[0]]];

if ($lines[0] !== $this->filterLine) {
$filteredTable[$this->filterLine] = $table[$this->filterLine];
Expand All @@ -98,7 +96,7 @@ public function filterFeature(FeatureNode $feature)
$scenario->getTitle(),
$scenario->getTags(),
$scenario->getSteps(),
array(new ExampleTableNode($filteredTable, $exampleTable->getKeyword(), $exampleTable->getTags())),
[new ExampleTableNode($filteredTable, $exampleTable->getKeyword(), $exampleTable->getTags())],
$scenario->getKeyword(),
$scenario->getLine()
);
Expand Down
Loading

0 comments on commit 8ee3e6f

Please sign in to comment.