Skip to content

Commit

Permalink
Merge pull request #190 from martin-helmich/chore/typings
Browse files Browse the repository at this point in the history
Clean up old Psalm typings
  • Loading branch information
martin-helmich authored Dec 8, 2024
2 parents 1264e16 + 507db9d commit c8b45ae
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 28 deletions.
1 change: 1 addition & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
parameters:
level: 10
reportUnmatchedIgnoredErrors: false
treatPhpDocTypesAsCertain: false
paths:
- src
4 changes: 0 additions & 4 deletions src/Linter/Configuration/YamlConfigurationLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ public function __construct(FileLocatorInterface $locator, YamlParser $yamlParse
* @param string|null $type The resource type
*
* @return array<string, mixed>
*
* @psalm-suppress MethodSignatureMismatch
*/
public function load(mixed $resource, ?string $type = null): array
{
Expand All @@ -73,8 +71,6 @@ public function load(mixed $resource, ?string $type = null): array
* @param string|null $type The resource type
*
* @return bool true if this class supports the given resource, false otherwise
*
* @psalm-suppress MethodSignatureMismatch
*/
public function supports(mixed $resource, ?string $type = null): bool
{
Expand Down
4 changes: 2 additions & 2 deletions src/Linter/Linter.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function lintFile(
}

/**
* @psalm-param TokenInterface[] $tokens
* @param TokenInterface[] $tokens
*/
private function lintTokenStream(
array $tokens,
Expand All @@ -82,7 +82,7 @@ private function lintTokenStream(
}

/**
* @psalm-param Statement[] $statements
* @param Statement[] $statements
*/
private function lintSyntaxTree(
array $statements,
Expand Down
4 changes: 0 additions & 4 deletions src/Linter/Sniff/DeadCodeSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ public function __construct(array $parameters)

/**
* @param TokenInterface[] $tokens
* @param File $file
* @param LinterConfiguration $configuration
*
* @return void
*/
public function sniff(array $tokens, File $file, LinterConfiguration $configuration): void
{
Expand Down
17 changes: 8 additions & 9 deletions src/Linter/Sniff/IndentationSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@
use Helmich\TypoScriptParser\Tokenizer\LineGrouper;
use Helmich\TypoScriptParser\Tokenizer\TokenInterface;

/**
* @phpstan-type IndentationSniffParams array{
* useSpaces: ?bool,
* indentPerLevel: ?int,
* indentConditions: ?bool,
* }
*/
class IndentationSniff implements TokenStreamSniffInterface
{
use TokenInspections;
Expand All @@ -30,10 +37,8 @@ class IndentationSniff implements TokenStreamSniffInterface
private bool $insideCondition = false;

/**
* @param array $parameters
*
* @psalm-param array{useSpaces: ?bool, indentPerLevel: ?int, indentConditions: ?bool} $parameters
* @psalm-suppress MoreSpecificImplementedParamType
* @param IndentationSniffParams $parameters
*/
public function __construct(array $parameters)
{
Expand All @@ -50,10 +55,6 @@ public function __construct(array $parameters)

/**
* @param TokenInterface[] $tokens
* @param File $file
* @param LinterConfiguration $configuration
*
* @return void
*/
public function sniff(array $tokens, File $file, LinterConfiguration $configuration): void
{
Expand Down Expand Up @@ -103,8 +104,6 @@ public function sniff(array $tokens, File $file, LinterConfiguration $configurat
* Checks if a stream of tokens is an empty line.
*
* @param TokenInterface[] $tokensInLine
*
* @return bool
*/
private function isEmptyLine(array $tokensInLine): bool
{
Expand Down
10 changes: 9 additions & 1 deletion src/Linter/Sniff/NestingConsistencySniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,23 @@
use Helmich\TypoScriptLint\Linter\Sniff\Visitor\NestingConsistencyVisitor;
use Helmich\TypoScriptLint\Linter\Sniff\Visitor\SniffVisitor;

/**
* @phpstan-type NestingConsistencySniffParams array{
* commonPathPrefixThreshold: ?int
* }
*/
class NestingConsistencySniff extends AbstractSyntaxTreeSniff
{
private int $commonPathPrefixThreshold = 1;

/**
* @param NestingConsistencySniffParams $parameters
*/
public function __construct(array $parameters)
{
parent::__construct($parameters);

if (array_key_exists('commonPathPrefixThreshold', $parameters) && is_int($parameters['commonPathPrefixThreshold'])) {
if (isset($parameters['commonPathPrefixThreshold']) && is_int($parameters['commonPathPrefixThreshold'])) {
$this->commonPathPrefixThreshold = $parameters['commonPathPrefixThreshold'];
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Linter/Sniff/OperatorWhitespaceSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class OperatorWhitespaceSniff implements TokenStreamSniffInterface
use TokenInspections;

/**
* @param array<mixed, mixed> $parameters
* @param array{} $parameters
* @phpstan-ignore constructor.unusedParameter (defined in interface)
*/
public function __construct(array $parameters)
Expand Down
13 changes: 7 additions & 6 deletions src/Linter/Sniff/RepeatingRValueSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
use Helmich\TypoScriptLint\Linter\Report\Issue;
use Helmich\TypoScriptParser\Tokenizer\TokenInterface;

/**
* @phpstan-type RepeatingRValueSniffParams array{
* allowedRightValues: ?string[],
* valueLengthThreshold: ?int,
* }
*/
class RepeatingRValueSniff implements TokenStreamSniffInterface
{

Expand All @@ -21,8 +27,7 @@ class RepeatingRValueSniff implements TokenStreamSniffInterface
private int $valueLengthThreshold = 8;

/**
* @psalm-param array{allowedRightValues: ?string[], valueLengthThreshold: ?int} $parameters
* @psalm-suppress MoreSpecificImplementedParamType
* @param RepeatingRValueSniffParams $parameters
*/
public function __construct(array $parameters)
{
Expand All @@ -37,10 +42,6 @@ public function __construct(array $parameters)

/**
* @param TokenInterface[] $tokens
* @param File $file
* @param LinterConfiguration $configuration
*
* @return void
*/
public function sniff(array $tokens, File $file, LinterConfiguration $configuration): void
{
Expand Down
1 change: 0 additions & 1 deletion src/Linter/Sniff/Visitor/DuplicateAssignmentVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public function enterNode(Statement $statement): void

if ($statement instanceof Assignment && false === $this->inCondition) {
if (isset($this->assignments[$statement->object->absoluteName])) {
/** @var Statement $lastAssignment */
$lastAssignment = $this->assignments[$statement->object->absoluteName];
$this->issues[] = new Issue(
$lastAssignment->sourceLine,
Expand Down

0 comments on commit c8b45ae

Please sign in to comment.