rectorphp / swiss-knife

Swiss knife in pocket of every upgrade architect!
https://getrector.com
MIT License
72 stars 8 forks source link

Files in scan directory root gets additional postfix \ in their namespace #9

Open RafalSalwa opened 5 months ago

RafalSalwa commented 5 months ago

Hi, two things related to swiss-knife

  1. Namespace root files get additional backslash
  2. On second run, swiss-knife throws a syntax error

How to reproduce: command: vendor/bin/swiss-knife namespace-to-psr-4 src --namespace-root "App\\"

run in symfony project (6.3) on src directory with following structure

src
  Controller/
  Entity/
  Repository/
  Kernel.php

Fixer works flawlessly for every file inside directories :=) Unfortunately files in scan directory root are getting App\ namespace with additional backslash.

declare(strict_types=1);

namespace App\;

use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
use Symfony\Component\HttpKernel\Kernel as BaseKernel;

class Kernel extends BaseKernel
{
    use MicroKernelTrait;
}

after running swiss-knife and then paraller-lint linter for example, i got this error: image

Also in second run You will get error:

image

TomasVotruba commented 4 months ago

Hi, thanks for reporting. This package is in its early development, so testing like your is very important to us.

Could you send us a PR with fix?

RafalSalwa commented 4 months ago

yes, within this week i will sit and help with this one:)