Skip to content

Commit

Permalink
chore: update Psalm, fix issues
Browse files Browse the repository at this point in the history
  • Loading branch information
dkarlovi committed Mar 4, 2024
1 parent ccc28c8 commit 41b58d1
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 17 deletions.
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -37,7 +37,7 @@
"symfony/var-dumper": "^6.0",
"symfony/process": "^6.0",
"phpunit/phpunit": "^10.5",
"vimeo/psalm": "^5.0@beta",
"vimeo/psalm": "^5.22",
"friendsofphp/php-cs-fixer": "^3.8"
},
"scripts": {
Expand Down
3 changes: 2 additions & 1 deletion src/Model/RuleDocumentationBuilder.php
Expand Up @@ -33,6 +33,7 @@ public function generate(): string

/**
* @param list<string> $out
* @param-out list<string> $out
*/
private function ruleDocumentation(RuleDescription $description, array &$out): void
{
Expand All @@ -50,7 +51,7 @@ private function ruleDocumentation(RuleDescription $description, array &$out): v
[
$description->name => $example->config,
],
JSON_PRETTY_PRINT
JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR
);
$out[] = '```json';
$out[] = $configString;
Expand Down
10 changes: 0 additions & 10 deletions src/Rule/FileNameRule.php
Expand Up @@ -11,7 +11,6 @@
use DTL\GherkinLint\Model\RuleDescription;
use DTL\GherkinLint\Model\RuleExample;
use Generator;
use RuntimeException;
use Symfony\Component\Filesystem\Path;
use Symfony\Component\String\UnicodeString;

Expand All @@ -33,10 +32,6 @@ public function analyse(ParsedFeature $feature, RuleConfig $config): Generator
FileNameConfig::CAMEL_CASE => $path->camel()->__toString(),
FileNameConfig::SNAKE_CASE => $path->snake()->__toString(),
FileNameConfig::KEBAB_CASE => $path->snake()->replace('_', '-')->__toString(),
default => throw new RuntimeException(sprintf(
'Invalid filename style "%s"',
$config->style
)),
};

if ($converted === $path->__toString()) {
Expand Down Expand Up @@ -108,9 +103,4 @@ public function describe(): RuleDescription
]
);
}

private function match(string $pattern, string $filename): bool
{
return (bool)preg_match($pattern, $filename);
}
}
2 changes: 1 addition & 1 deletion src/Rule/IndentationRule.php
Expand Up @@ -100,7 +100,7 @@ private function check(Location $location, string $name, IndentationConfig $conf

$column = $location->column;

if (!$column) {
if ($column === null) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Rule/NoBackgroundWithSingleScenarioRule.php
Expand Up @@ -37,7 +37,7 @@ public function analyse(ParsedFeature $feature, RuleConfig $config): Generator
yield new FeatureDiagnostic(
Range::fromLocationAndName($background->location, $background->name),
FeatureDiagnosticSeverity::WARNING,
sprintf('Background is only permitted if there is more than one scenario')
'Background is only permitted if there is more than one scenario'
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Rule/NoConsecutiveEmptyLinesRule.php
Expand Up @@ -57,7 +57,7 @@ public function analyse(ParsedFeature $feature, RuleConfig $config): Generator
$prev = $lineNo;
}

if ($start && $lineNo && $prev) {
if ($start && $prev) {
yield new FeatureDiagnostic(
Range::fromInts($start, 1, $prev, 1),
FeatureDiagnosticSeverity::WARNING,
Expand Down
2 changes: 1 addition & 1 deletion src/Rule/NoDisallowedPatternsConfig.php
Expand Up @@ -7,7 +7,7 @@
class NoDisallowedPatternsConfig implements RuleConfig
{
public function __construct(
/** @var string[] */
/** @var list<non-empty-string> */
public readonly array $patterns = []
) {
}
Expand Down
2 changes: 1 addition & 1 deletion src/Rule/NoDisallowedPatternsRule.php
Expand Up @@ -18,7 +18,7 @@ public function analyse(ParsedFeature $feature, RuleConfig $config): Generator
{
assert($config instanceof NoDisallowedPatternsConfig);
foreach ($config->patterns as $pattern) {
if (!preg_match_all($pattern, $feature->source(), $matches, PREG_OFFSET_CAPTURE)) {
if (preg_match_all($pattern, $feature->source(), $matches, PREG_OFFSET_CAPTURE) === false) {
continue;
}

Expand Down

0 comments on commit 41b58d1

Please sign in to comment.