Skip to content

Commit

Permalink
php: Try to follow Psalm tips (#238)
Browse files Browse the repository at this point in the history
  • Loading branch information
olleolleolle authored Mar 17, 2024
1 parent c22cfaa commit 46f33b6
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
4 changes: 2 additions & 2 deletions php/psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<psalm
errorLevel="1"
resolveFromConfigFile="true"
findUnusedBaselineEntry="false"
findUnusedCode="false"
findUnusedBaselineEntry="true"
findUnusedCode="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
Expand Down
1 change: 1 addition & 0 deletions php/src/AstNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public function add(RuleType $ruleType, object|array|string $entry): void
*/
public function getItems(string $expectedType, RuleType $ruleType): array
{
$expectedType == 0; // Avoid error: Param #1 is never referenced in this method (see https://psalm.dev/135)
$items = $this->subItems[$ruleType->name] ?? [];

/**
Expand Down
6 changes: 4 additions & 2 deletions php/src/GherkinParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

/**
* Parses a Gherkin document (or list of Source envelopes) and emits Cucumber Messages envelopes
*
* @psalm-api
*/
final class GherkinParser
{
Expand All @@ -28,13 +30,13 @@ final class GherkinParser
* @param bool $predictableIds Ignored if IdGenerator is provided
*/
public function __construct(
private readonly bool $predictableIds = false,
bool $predictableIds = false,
private readonly bool $includeSource = true,
private readonly bool $includeGherkinDocument = true,
private readonly bool $includePickles = true,
?IdGenerator $idGenerator = null,
) {
$this->idGenerator = $idGenerator ?? ($this->predictableIds ? new IncrementingIdGenerator() : new UuidIdGenerator());
$this->idGenerator = $idGenerator ?? ($predictableIds ? new IncrementingIdGenerator() : new UuidIdGenerator());
$this->pickleCompiler = new PickleCompiler($this->idGenerator);
}

Expand Down
3 changes: 3 additions & 0 deletions php/src/Location.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

namespace Cucumber\Gherkin;

/**
* @psalm-api
*/
final class Location
{
public function __construct(
Expand Down
6 changes: 2 additions & 4 deletions php/src/Parser/ParserTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,10 @@ private function addError(ParserContext $context, ParserException $error): void
/**
* @template U
* @param callable() : U $action
*
* @return U
*/
private function handleAstError(ParserContext $context, callable $action): mixed
private function handleAstError(ParserContext $context, callable $action): void
{
return $this->handleExternalError($context, $action, null);
$this->handleExternalError($context, $action, null);
}

/**
Expand Down

0 comments on commit 46f33b6

Please sign in to comment.