John Davidson

PHP Rector - Look at "Rector\NodeTypeResolver\NodeTypeResolver::isObjectType()" on line 129

0 comments
Message:


I'm trying to run PHP Rector on a very old codebase to convert mysql_* calls into mysqli_* calls however it keeps failing with the following error:


In NodeTypeResolver.php line 129:

Look at "Rector\NodeTypeResolver\NodeTypeResolver::isObjectType()" on line 129

When I look at the NodeTypeResolver.php line 129 file it's throwing an exception:


        if ($node instanceof \PhpParser\Node\Expr\ClassConstFetch) {
throw new \Rector\Core\Exception\ShouldNotHappenException();
}

Looking at the ShouldNotHappenException.php file it gives me no information at to what the possible problem could be. The name of the error message itself seems very cryptic.


My config is pretty basic as I'm only testing this at the moment to see if its viable:


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

// Define what rule sets will be applied
$containerConfigurator->import(SetList::MYSQL_TO_MYSQLI);

// get services (needed for register a single rule)
//$services = $containerConfigurator->services();

// register a single rule
//$services->set(TypedPropertyRector::class);
};

Does anyone have an idea of what's going on?




EDIT:


I should probably mention I tried a few different configs to run different things like $containerConfigurator->import(SetList::DEAD_CODE); and $containerConfigurator->import(SetList::CODE_QUALITY); and they run fine so it seems to a specific issue with SetList::MYSQL_TO_MYSQLI



My Answer:
PHP Rector is a tool that helps automate the process of upgrading and modernizing PHP code. It can automatically refactor your codebase to adhere to the latest PHP standards and best practices, making it easier to maintain and improve your code.

Some of the features of PHP Rector include:

1. Automated code refactoring: PHP Rector can automatically refactor your codebase to update deprecated functions, change coding standards, and improve code quality.

2. Easy configuration: PHP Rector allows you to configure which rules and refactorings you want to apply to your codebase, making it easy to customize the tool to fit your specific needs.

3. Continuous integration support: PHP Rector can be integrated into your continuous integration pipeline, allowing you to automatically refactor your codebase with each new commit.

Overall, PHP Rector is a powerful tool that can help streamline the process of upgrading and modernizing your PHP codebase. It can save you time and effort by automating the tedious task of refactoring code, allowing you to focus on more important aspects of your development work.

Rate this post

3 of 5 based on 2068 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us