Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PHP 8.1 support #242

Merged
merged 1 commit into from
Sep 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [7.2, 7.3, 7.4, 8.0]
php: [7.2, 7.3, 7.4, 8.0, 8.1]
composer-flags: [ "" ]
symfony-version: [ "" ]
include:
Expand Down
8 changes: 8 additions & 0 deletions src/Behat/Gherkin/Filter/NameFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ public function __construct($filterString)
*/
public function isFeatureMatch(FeatureNode $feature)
{
if (null === $feature->getTitle()) {
return false;
}

if ('/' === $this->filterString[0]) {
return 1 === preg_match($this->filterString, $feature->getTitle());
}
Expand All @@ -57,6 +61,10 @@ public function isFeatureMatch(FeatureNode $feature)
*/
public function isScenarioMatch(ScenarioInterface $scenario)
{
if (null === $scenario->getTitle()) {
return false;
}

if ('/' === $this->filterString[0] && 1 === preg_match($this->filterString, $scenario->getTitle())) {
return true;
} elseif (false !== mb_strpos($scenario->getTitle(), $this->filterString, 0, 'utf8')) {
Expand Down
2 changes: 1 addition & 1 deletion src/Behat/Gherkin/Filter/NarrativeFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function __construct($regex)
*/
public function isFeatureMatch(FeatureNode $feature)
{
return 1 === preg_match($this->regex, $feature->getDescription());
return 1 === preg_match($this->regex, $feature->getDescription() ?? '');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Behat/Gherkin/Filter/RoleFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function __construct($role)
*/
public function isFeatureMatch(FeatureNode $feature)
{
return 1 === preg_match($this->pattern, $feature->getDescription());
return 1 === preg_match($this->pattern, $feature->getDescription() ?? '');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Behat/Gherkin/Lexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ protected function scanPyStringContent()

$token = $this->scanText();
// swallow trailing spaces
$token['value'] = preg_replace('/^\s{0,' . $this->pyStringSwallow . '}/u', '', $token['value']);
$token['value'] = preg_replace('/^\s{0,' . $this->pyStringSwallow . '}/u', '', $token['value'] ?? '');

return $token;
}
Expand Down
2 changes: 2 additions & 0 deletions src/Behat/Gherkin/Node/TableNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Behat\Gherkin\Exception\NodeException;
use Iterator;
use IteratorAggregate;
use ReturnTypeWillChange;

/**
* Represents Gherkin Table argument.
Expand Down Expand Up @@ -333,6 +334,7 @@ public function __toString()
*
* @return Iterator
*/
#[ReturnTypeWillChange]
public function getIterator()
{
return new ArrayIterator($this->getHash());
Expand Down
10 changes: 5 additions & 5 deletions src/Behat/Gherkin/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ protected function parseFeature()
{
$token = $this->expectTokenType('Feature');

$title = trim($token['value']) ?: null;
$title = trim($token['value'] ?? '');
$description = null;
$tags = $this->popTags();
$background = null;
Expand Down Expand Up @@ -288,7 +288,7 @@ protected function parseFeature()

return new FeatureNode(
rtrim($title) ?: null,
rtrim($description) ?: null,
rtrim($description ?? '') ?: null,
$tags,
$background,
$scenarios,
Expand All @@ -310,7 +310,7 @@ protected function parseBackground()
{
$token = $this->expectTokenType('Background');

$title = trim($token['value']);
$title = trim($token['value'] ?? '');
$keyword = $token['keyword'];
$line = $token['line'];

Expand Down Expand Up @@ -375,7 +375,7 @@ protected function parseScenario()
{
$token = $this->expectTokenType('Scenario');

$title = trim($token['value']);
$title = trim($token['value'] ?? '');
$tags = $this->popTags();
$keyword = $token['keyword'];
$line = $token['line'];
Expand Down Expand Up @@ -436,7 +436,7 @@ protected function parseOutline()
{
$token = $this->expectTokenType('Outline');

$title = trim($token['value']);
$title = trim($token['value'] ?? '');
$tags = $this->popTags();
$keyword = $token['keyword'];

Expand Down