Skip to content

Commit

Permalink
Fix Psalm
Browse files Browse the repository at this point in the history
  • Loading branch information
gmazzap committed Oct 17, 2020
1 parent 91ff869 commit 38546e6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions Inpsyde/PhpcsHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public static function findOopContext(File $file, int $position): int
in_array($condCode, Tokens::$ooScopeTokens, true)
&& ($condLevel === $targetLevel)
) {
return $condPosition;
return (int)$condPosition;
}
}

Expand Down Expand Up @@ -422,7 +422,7 @@ public static function functionDocBlockTag(string $tag, File $file, int $positio
/**
* @param File $file
* @param int $functionPosition
* @return array<string>
* @return array<string, array<string>>
*/
public static function functionDocBlockParamTypes(File $file, int $functionPosition): array
{
Expand Down Expand Up @@ -688,6 +688,7 @@ public static function isUntypedPsrMethod(File $file, int $position): bool
return false;
}

/** @var array<string> $psrInterfaces */
static $psrInterfaces;
$psrInterfaces or $psrInterfaces = [
'LoggerInterface',
Expand All @@ -712,6 +713,7 @@ public static function isUntypedPsrMethod(File $file, int $position): bool
'StreamFactoryInterface',
];

/** @var string $name */
foreach ($names as $name) {
$lastName = array_slice(explode('\\', $name), -1, 1)[0];
if (in_array($lastName, $psrInterfaces, true)) {
Expand Down
4 changes: 2 additions & 2 deletions Inpsyde/Sniffs/CodeQuality/ArgumentTypeDeclarationSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function process(File $file, $position)

foreach ($variables as $varPosition => $varToken) {
// Not triggering error for variable explicitly declared as mixed (or mixed|null)
if ($this->isMixed($varToken['content'] ?? '', $docBlockTypes)) {
if ($this->isMixed((string)($varToken['content'] ?? ''), $docBlockTypes)) {
continue;
}

Expand All @@ -102,7 +102,7 @@ public function process(File $file, $position)

/**
* @param string $paramName
* @param array $docBlockTypes
* @param array<string, array<string>> $docBlockTypes
* @return bool
*/
private function isMixed(string $paramName, array $docBlockTypes): bool
Expand Down

0 comments on commit 38546e6

Please sign in to comment.