Skip to content

Commit

Permalink
Fix strtr calls 🤦🏻‍♂️
Browse files Browse the repository at this point in the history
  • Loading branch information
Seldaek committed May 31, 2024
1 parent fa7edd2 commit 5bb7f1e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/ClassMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function sort(): void
*/
public function addClass(string $className, string $path): void
{
unset($this->psrViolations[strtr('\\', '/', $path)]);
unset($this->psrViolations[strtr($path, '\\', '/')]);

$this->map[$className] = $path;
}
Expand Down Expand Up @@ -116,14 +116,14 @@ public function hasClass(string $className): bool

public function addPsrViolation(string $warning, string $className, string $path): void
{
$path = rtrim(strtr('\\', '/', $path), '/');
$path = rtrim(strtr($path, '\\', '/'), '/');

$this->psrViolations[$path][] = ['warning' => $warning, 'className' => $className];
}

public function clearPsrViolationsByPath(string $pathPrefix): void
{
$pathPrefix = rtrim(strtr('\\', '/', $pathPrefix), '/');
$pathPrefix = rtrim(strtr($pathPrefix, '\\', '/'), '/');

foreach ($this->psrViolations as $path => $violations) {
if ($path === $pathPrefix || 0 === \strpos($path, $pathPrefix.'/')) {
Expand Down

1 comment on commit 5bb7f1e

@staabm
Copy link

@staabm staabm commented on 5bb7f1e Jun 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we will be able to catch such errors in PHPStan: phpstan/phpstan#11118

Please sign in to comment.