Skip to content

Commit

Permalink
Remove redundant assertions in ClassesInDirectories.php
Browse files Browse the repository at this point in the history
Eliminated unnecessary assert statements that checked for array type, which are verified earlier in the code. This improves code clarity and reduces redundant operations.
  • Loading branch information
koriym committed Nov 2, 2024
1 parent 427290a commit 356983f
Showing 1 changed file with 0 additions and 2 deletions.
2 changes: 0 additions & 2 deletions src/ClassesInDirectories.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ private static function extractNamespace(array $tokens): string|null
}

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) {

Check failure on line 101 in src/ClassesInDirectories.php

View workflow job for this annotation

GitHub Actions / sa / PHPStan

Cannot access offset 0 on mixed.

Check failure on line 101 in src/ClassesInDirectories.php

View workflow job for this annotation

GitHub Actions / sa / Psalm

MixedArrayAccess: Cannot access array value on mixed variable $tokens[$j]

Check failure on line 101 in src/ClassesInDirectories.php

View workflow job for this annotation

GitHub Actions / sa / PHPStan

Cannot access offset 0 on mixed.

Check failure on line 101 in src/ClassesInDirectories.php

View workflow job for this annotation

GitHub Actions / sa / Psalm

MixedArrayAccess: Cannot access array value on mixed variable $tokens[$j]
$string = $tokens[$j][1];

Check failure on line 102 in src/ClassesInDirectories.php

View workflow job for this annotation

GitHub Actions / sa / PHPStan

Cannot access offset 1 on mixed.

Check failure on line 102 in src/ClassesInDirectories.php

View workflow job for this annotation

GitHub Actions / sa / Psalm

MixedArrayAccess: Cannot access array value on mixed variable $tokens[$j]

Check failure on line 102 in src/ClassesInDirectories.php

View workflow job for this annotation

GitHub Actions / sa / PHPStan

Cannot access offset 1 on mixed.

Check failure on line 102 in src/ClassesInDirectories.php

View workflow job for this annotation

GitHub Actions / sa / Psalm

MixedArrayAccess: Cannot access array value on mixed variable $tokens[$j]
assert(is_string($string));
Expand All @@ -115,7 +114,6 @@ private static function extractNamespace(array $tokens): string|null
private static function extractClassName(array $tokens): string|null
{
foreach ($tokens as $index => $token) {

Check failure on line 116 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 116 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
assert(is_array($token));
if ($token[0] !== T_CLASS && $token[0] !== T_INTERFACE) {

Check failure on line 117 in src/ClassesInDirectories.php

View workflow job for this annotation

GitHub Actions / sa / PHPStan

Cannot access offset 0 on mixed.

Check failure on line 117 in src/ClassesInDirectories.php

View workflow job for this annotation

GitHub Actions / sa / Psalm

MixedArrayAccess: Cannot access array value on mixed variable $token

Check failure on line 117 in src/ClassesInDirectories.php

View workflow job for this annotation

GitHub Actions / sa / PHPStan

Cannot access offset 0 on mixed.

Check failure on line 117 in src/ClassesInDirectories.php

View workflow job for this annotation

GitHub Actions / sa / Psalm

MixedArrayAccess: Cannot access array value on mixed variable $token
continue;
}
Expand Down

0 comments on commit 356983f

Please sign in to comment.