Skip to content

Commit

Permalink
Enable ternary_to_null_coalescing
Browse files Browse the repository at this point in the history
  • Loading branch information
uuf6429 committed Dec 17, 2024
1 parent d31bbc1 commit 08ea544
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@
'heredoc_to_nowdoc' => true,
'heredoc_indentation' => ['indentation' => 'same_as_start'],
'single_line_throw' => false,
'ternary_to_null_coalescing' => true,
])
->setFinder($finder);
4 changes: 2 additions & 2 deletions src/Behat/Gherkin/Loader/ArrayLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ protected function loadTableHash(array $hash)
*/
protected function loadPyStringHash(array $hash, $line = 0)
{
$line = isset($hash['line']) ? $hash['line'] : $line;
$line = $hash['line'] ?? $line;

$strings = [];
foreach (explode("\n", $hash['text']) as $string) {
Expand Down Expand Up @@ -300,7 +300,7 @@ private function processExamplesArray($exHash, $examplesKeyword, $examples)
for ($i = 0; $i < count($exHash); ++$i) {
if (isset($exHash[$i]['table'])) {
// we have examples as objects, hence there could be tags
$exHashTags = isset($exHash[$i]['tags']) ? $exHash[$i]['tags'] : [];
$exHashTags = $exHash[$i]['tags'] ?? [];
$examples[] = new ExampleTableNode($exHash[$i]['table'], $examplesKeyword, $exHashTags);
} else {
// we have examples as arrays
Expand Down
16 changes: 8 additions & 8 deletions src/Behat/Gherkin/Loader/CucumberNDJsonAstLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private static function getFeature(array $json, $filePath)
$featureJson = $json['gherkinDocument']['feature'];

$feature = new FeatureNode(
isset($featureJson['name']) ? $featureJson['name'] : null,
$featureJson['name'] ?? null,
$featureJson['description'] ? trim($featureJson['description']) : null,
self::getTags($featureJson),
self::getBackground($featureJson),
Expand All @@ -71,7 +71,7 @@ private static function getTags(array $json)
{
return array_map(
static function (array $tag) { return preg_replace('/^@/', '', $tag['name']); },
isset($json['tags']) ? $json['tags'] : []
$json['tags'] ?? []
);
}

Expand All @@ -85,9 +85,9 @@ private static function getScenarios(array $json)
static function ($child) {
if ($child['scenario']['examples']) {
return new OutlineNode(
isset($child['scenario']['name']) ? $child['scenario']['name'] : null,
$child['scenario']['name'] ?? null,
self::getTags($child['scenario']),
self::getSteps(isset($child['scenario']['steps']) ? $child['scenario']['steps'] : []),
self::getSteps($child['scenario']['steps'] ?? []),
self::getTables($child['scenario']['examples']),
$child['scenario']['keyword'],
$child['scenario']['location']['line']
Expand All @@ -96,14 +96,14 @@ static function ($child) {
return new ScenarioNode(
$child['scenario']['name'],
self::getTags($child['scenario']),
self::getSteps(isset($child['scenario']['steps']) ? $child['scenario']['steps'] : []),
self::getSteps($child['scenario']['steps'] ?? []),
$child['scenario']['keyword'],
$child['scenario']['location']['line']
);
}
},
array_filter(
isset($json['children']) ? $json['children'] : [],
$json['children'] ?? [],
static function ($child) {
return isset($child['scenario']);
}
Expand All @@ -122,13 +122,13 @@ private static function getBackground(array $json)
static function ($child) {
return new BackgroundNode(
$child['background']['name'],
self::getSteps(isset($child['background']['steps']) ? $child['background']['steps'] : []),
self::getSteps($child['background']['steps'] ?? []),
$child['background']['keyword'],
$child['background']['location']['line']
);
},
array_filter(
isset($json['children']) ? $json['children'] : [],
$json['children'] ?? [],
static function ($child) {
return isset($child['background']);
}
Expand Down

0 comments on commit 08ea544

Please sign in to comment.