imanghafoori1 / laravel-microscope

Fearless refactoring, it does a lot of smart checks to find certain errors.
MIT License
1.48k stars 96 forks source link

stringy_classes Error #66

Closed lsfiege closed 4 years ago

lsfiege commented 4 years ago

Hi! Thank you for this amazing component!

I have an error when I run the php artisan check:stringy_classes command: It throws the following error output:

Checking strings...
PHP Fatal error:  Cannot declare class App\Task, because the name is already in use in /home/luckas/Code/mol/interno/app/Task.php on line 9

   Symfony\Component\ErrorHandler\Error\FatalError 

  Cannot declare class App\Task, because the name is already in use

  at app/Task.php:9
     5| use Illuminate\Database\Eloquent\Model;
     6| use Illuminate\Database\Eloquent\SoftDeletes;
     7| use Illuminate\Support\Carbon;
     8| 
  >  9| class Task extends Model
    10| {
    11|     use SoftDeletes;
    12| 
    13|     protected $dates = [

   Whoops\Exception\ErrorException 

  Cannot declare class App\Task, because the name is already in use

  at app/Task.php:9
     5| use Illuminate\Database\Eloquent\Model;
     6| use Illuminate\Database\Eloquent\SoftDeletes;
     7| use Illuminate\Support\Carbon;
     8| 
  >  9| class Task extends Model
    10| {
    11|     use SoftDeletes;
    12| 
    13|     protected $dates = [

      +1 vendor frames 
  2   [internal]:0
      Whoops\Run::handleShutdown()

I have only one App\Task class model, Is this a false positive or is it another error?

imanghafoori1 commented 4 years ago

Hhhhmmm, check that trait are correctly referrenced. Run Check:import Check:psr4

First to see what happens.

imanghafoori1 commented 4 years ago

I think there is some problem with SoftDeletes; trait.

lsfiege commented 4 years ago

The psr4 and import checks are ok

imanghafoori1 commented 4 years ago

I investigate the issue, thanks for report.

imanghafoori1 commented 4 years ago

If you are ok, please send the content of the Task.php file. in the telegram or put it in github gist and mention the link

imanghafoori1 commented 4 years ago

Also composer dump may help you.

lsfiege commented 4 years ago

I've ran the command with an empty Task class and it still failing, maybe this is a problem from the legacy codebase I'm working on. So I'm going to close this issue. Thank you for your support!

imanghafoori1 commented 4 years ago

Let this be open until we find the root cause of this confusion.

pierrepavlov commented 3 years ago

Did you ever find out what was causing this issue? I'm just trying the package and I get this exact error. It's a legacy code base which has been upgraded to Laravel 8, so unsure if there's something missing/wrong further back.