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

chore: update Psalm, fix issues #32

Merged
merged 1 commit into from Mar 4, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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