Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Parallel]: Could not process <file> System error Class <class> was not found #6911

Closed
gander opened this issue Jan 4, 2022 · 3 comments
Closed
Labels

Comments

@gander
Copy link

gander commented Jan 4, 2022

Bug Report

Subject Details
Rector version 0.12.10 fee8a47d1a627b01bfba2d85293c84692715506a
Rector version dev-main 74b90d35752d75433bc5fe5e6933bed8a1cb4dee
 [ERROR] Could not process "database/migrations/2014_10_12_000000_create_users_table.php" file, due to:                 
         "System error: "Class CreateUsersTable was not found while trying to analyse it - discovering symbols is       
         probably not configured properly."                                                                             
         Run Rector with "--debug" option and post the report here: https://github.com/rectorphp/rector/issues/new". On 
         line: 45                                                                                                       

It's similar to #6903 but adding NormalizeNamespaceByPSR4ComposerAutoloadRector not helps.

Minimal PHP Code Causing Issue

Cannot reproduce the issue using https://getrector.org/demo/

<?php declare(strict_types=1);

use Rector\Core\Configuration\Option;
use Rector\Transform\Rector\StaticCall\StaticCallToMethodCallRector;
use Rector\Transform\ValueObject\StaticCallToMethodCall;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return static function (ContainerConfigurator $containerConfigurator): void {
    $services = $containerConfigurator->services();
    $services->set(StaticCallToMethodCallRector::class)
        ->configure([
            new StaticCallToMethodCall(
                'Illuminate\\Support\\Facades\\Schema', '*',
                'Illuminate\\Database\\Schema\\Builder', '*'
            ),
        ]);

    $parameters = $containerConfigurator->parameters();
    $parameters->set(Option::PARALLEL, true);
    $parameters->set(Option::PATHS, [
        __DIR__ . '/database/migrations/2014_10_12_000000_create_users_table.php',
    ]);
};
composer create-project laravel/laravel
composer req --dev rector/rector
vendor/bin/rector init
# put rector.php contents
vendor/bin/rector process -n

Expected Behaviour

1 file with changes
===================

1) database/migrations/2014_10_12_000000_create_users_table.php:6

    ---------- begin diff ----------
@@ @@
 class CreateUsersTable extends Migration
 {
     /**
+     * @var \Illuminate\Database\Schema\Builder
+     */
+    private $builder;
+    public function __construct(\Illuminate\Database\Schema\Builder $builder)
+    {
+        $this->builder = $builder;
+    }
+    /**
      * Run the migrations.
      *
      * @return void
@@ @@
      */
     public function up()
     {
-        Schema::create('users', function (Blueprint $table) {
+        $this->builder->create('users', function (Blueprint $table) {
             $table->id();
             $table->string('name');
             $table->string('email')->unique();
@@ @@
      */
     public function down()
     {
-        Schema::dropIfExists('users');
+        $this->builder->dropIfExists('users');
     }
 }
    ----------- end diff -----------

Applied rules:
 * PropertyAddingPostRector
 * StaticCallToMethodCallRector


                                                                                                                        
 [OK] 1 file would have changed (dry-run) by Rector                                                                     
                                                                                                                        

@gander gander added the bug label Jan 4, 2022
@samsonasik
Copy link
Member

@gander could you verify if latest "rector/rector": "dev-main" solve it? Thank you.

@gander
Copy link
Author

gander commented Jan 4, 2022

I confirm that in the 0e1150596d9e0661d82f57a916be69fda63ff20c version the error no longer appears.

@samsonasik
Copy link
Member

Thank you for verify 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants