Skip to content

Commit

Permalink
Update src/ClassesInDirectories.php
Browse files Browse the repository at this point in the history
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
  • Loading branch information
koriym and coderabbitai[bot] authored Nov 2, 2024
1 parent 427290a commit aac63b5
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions src/ClassesInDirectories.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,23 +91,18 @@ private static function getClassFromFile(string $filePath): string|null
/** @param array<int, mixed> $tokens*/
private static function extractNamespace(array $tokens): string|null

Check failure on line 92 in src/ClassesInDirectories.php

View workflow job for this annotation

GitHub Actions / sa / Psalm

MixedInferredReturnType: Could not verify return type 'null|string' for Ray\MediaQuery\ClassesInDirectories::extractNamespace

Check failure on line 92 in src/ClassesInDirectories.php

View workflow job for this annotation

GitHub Actions / sa / Psalm

MixedInferredReturnType: Could not verify return type 'null|string' for Ray\MediaQuery\ClassesInDirectories::extractNamespace
{
/** @psalm-suppress MixedAssignment */
foreach ($tokens as $index => $token) {
if (is_array($token) && $token[0] !== T_NAMESPACE) {
continue;
}

for ($j = $index + 1, $count = count($tokens); $j < $count; $j++) {
assert(is_array($tokens[$j]) && isset($tokens[$j][0]));
if ($tokens[$j][0] === T_NAME_QUALIFIED) {
$string = $tokens[$j][1];
assert(is_string($string));

return $string;
}
$index = array_search(T_NAMESPACE, array_column($tokens, 0));

Check failure on line 94 in src/ClassesInDirectories.php

View workflow job for this annotation

GitHub Actions / cs / Coding Standards

Function array_search() should not be referenced via a fallback global name, but via a use statement.

Check failure on line 94 in src/ClassesInDirectories.php

View workflow job for this annotation

GitHub Actions / cs / Coding Standards

Function array_column() should not be referenced via a fallback global name, but via a use statement.

Check failure on line 94 in src/ClassesInDirectories.php

View workflow job for this annotation

GitHub Actions / cs / Coding Standards

Function array_search() should not be referenced via a fallback global name, but via a use statement.

Check failure on line 94 in src/ClassesInDirectories.php

View workflow job for this annotation

GitHub Actions / cs / Coding Standards

Function array_column() should not be referenced via a fallback global name, but via a use statement.
if ($index === false) {
return null;
}

Check failure on line 98 in src/ClassesInDirectories.php

View workflow job for this annotation

GitHub Actions / cs / Coding Standards

Whitespace found at end of line

Check failure on line 98 in src/ClassesInDirectories.php

View workflow job for this annotation

GitHub Actions / cs / Coding Standards

Whitespace found at end of line
$remaining = array_slice($tokens, $index + 1);

Check failure on line 99 in src/ClassesInDirectories.php

View workflow job for this annotation

GitHub Actions / cs / Coding Standards

Function array_slice() should not be referenced via a fallback global name, but via a use statement.

Check failure on line 99 in src/ClassesInDirectories.php

View workflow job for this annotation

GitHub Actions / cs / Coding Standards

Function array_slice() should not be referenced via a fallback global name, but via a use statement.
foreach ($remaining as $token) {

Check failure on line 100 in src/ClassesInDirectories.php

View workflow job for this annotation

GitHub Actions / sa / Psalm

MixedAssignment: Unable to determine the type that $token is being assigned to

Check failure on line 100 in src/ClassesInDirectories.php

View workflow job for this annotation

GitHub Actions / sa / Psalm

MixedAssignment: Unable to determine the type that $token is being assigned to
if (is_array($token) && $token[0] === T_NAME_QUALIFIED) {
return $token[1];

Check failure on line 102 in src/ClassesInDirectories.php

View workflow job for this annotation

GitHub Actions / sa / Psalm

MixedReturnStatement: Could not infer a return type

Check failure on line 102 in src/ClassesInDirectories.php

View workflow job for this annotation

GitHub Actions / sa / Psalm

MixedReturnStatement: Could not infer a return type
}
}

Check failure on line 105 in src/ClassesInDirectories.php

View workflow job for this annotation

GitHub Actions / cs / Coding Standards

Whitespace found at end of line

Check failure on line 105 in src/ClassesInDirectories.php

View workflow job for this annotation

GitHub Actions / cs / Coding Standards

Whitespace found at end of line
return null;
}

Expand Down

0 comments on commit aac63b5

Please sign in to comment.