Skip to content

Encountering various Rector processing errors that do not occur in the app #3902

@MrMage

Description

@MrMage

Still trying to get Rector to run on my Laravel app. Running vendor/bin/rector process (version 0.7.61) triggers the following errors. Note that the web app runs fine locally and all tests pass; these issues only occur when running Rector.

Also, some comments on the individual error messages:

  • Call to undefined method Illuminate\Container\Container::databasePath(): Seems like databasePath() is only declared in Laravel framework methods. In particular, it is not called at all by my application code.
  • config: Not sure what that means, my config does not exclude the files in question from being processed.
  • "Rector\TypeDeclaration\Rector\Property\CompleteVarDocTypePropertyRector", due to: "Call to a member function changeVarType() on null".: No idea what this is about, but maybe it helps identify the two other issues?

Please note that I am not implying any problems in Rector; I assume it's just something specific to my configuration or app setup.

Full error log:

 [ERROR] Could not process "app/Models/Auth/User.php" file, due to:                                                     
         "Call to undefined method Illuminate\Container\Container::databasePath()".                                     
 [ERROR] Could not process "app/Models/Project/CombinedProjectsHolder.php" file, due to:                                
         "Call to undefined method Illuminate\Container\Container::databasePath()".                                     
 [ERROR] Could not process "app/Models/Project/ProjectsHolderException.php" file, due to:                               
         "Call to undefined method Illuminate\Container\Container::databasePath()".                                     
 [ERROR] Could not process "app/Models/TaskActivity/TaskActivity.php" file, due to:                                     
         "config".                                                                                                      
 [ERROR] Could not process "app/Models/Team.php" file, due to:                                                          
         "Call to undefined method Illuminate\Container\Container::databasePath()".                                     
 [ERROR] Could not process "app/Models/TeamMembership.php" file, due to:                                                
         "Call to undefined method Illuminate\Container\Container::databasePath()".                                                                  
 [ERROR] Could not process "app/Models/Auth/User.php" file by                                                           
         "Rector\TypeDeclaration\Rector\Property\CompleteVarDocTypePropertyRector", due to:                             
         "Call to a member function changeVarType() on null".                                                           
 [ERROR] Could not process "app/Models/TaskActivity/TaskActivity.php" file by                                           
         "Rector\TypeDeclaration\Rector\Property\CompleteVarDocTypePropertyRector", due to:                             
         "Call to a member function changeVarType() on null".                                                           
 [ERROR] Could not process "app/Models/Team.php" file by                                                                
         "Rector\TypeDeclaration\Rector\Property\CompleteVarDocTypePropertyRector", due to:                             
         "Call to a member function changeVarType() on null".                                                                                                                                                                             
 [ERROR] Could not process "app/Models/TeamMembership.php" file by                                                      
         "Rector\TypeDeclaration\Rector\Property\CompleteVarDocTypePropertyRector", due to:                             
         "Call to a member function changeVarType() on null".                                                           

rector.php

<?php

declare(strict_types=1);

use Rector\CodeQuality\Rector\FuncCall\CompactToVariablesRector;
use Rector\Core\Configuration\Option;
use Rector\TypeDeclaration\Rector\FunctionLike\ParamTypeDeclarationRector;
use Rector\TypeDeclaration\Rector\FunctionLike\ReturnTypeDeclarationRector;
use Rector\TypeDeclaration\Rector\Property\CompleteVarDocTypePropertyRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return static function (ContainerConfigurator $containerConfigurator): void {
    $parameters = $containerConfigurator->parameters();

    $parameters->set('php_version_features', '7.4');

    $parameters->set('auto_import_names', true);

    $parameters->set('import_short_classes', false);

    $parameters->set('sets', ['code-quality']);

    $parameters->set('paths', [__DIR__ . '/app/Models']);

    $parameters->set('exclude_paths', ['bootstrap/cache/*', 'storage/*', 'vendor/*', 'storage/*', '*/Protos/*', '*.blade.php']);

    $parameters->set(Option::EXCLUDE_RECTORS, [
        CompactToVariablesRector::class,
    ]);

    $services = $containerConfigurator->services();

    $services->set(ParamTypeDeclarationRector::class);
    $services->set(ReturnTypeDeclarationRector::class);
    $services->set(CompleteVarDocTypePropertyRector::class);
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions