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

Upgrade to Nette 3.1 #5195

Merged
merged 17 commits into from
Jan 20, 2021
Merged

Upgrade to Nette 3.1 #5195

merged 17 commits into from
Jan 20, 2021

Conversation

lulco
Copy link
Contributor

@lulco lulco commented Jan 15, 2021

Resolves #5142

config/set/nette-31.php Outdated Show resolved Hide resolved
@lulco
Copy link
Contributor Author

lulco commented Jan 16, 2021

@TomasVotruba Hi, I just finished with renaming things. I didn't see any other issues except those I marked as TODOs. Are there any rector rules to cover those or we have to write new rules?

@TomasVotruba
Copy link
Member

Good job with use of generic rules 👍 lot of case are covered now

@lulco
Copy link
Contributor Author

lulco commented Jan 17, 2021

@TomasVotruba I think it is ready for review. Code Analysis PHP 8.0 / PHPStan is failing but I believe it is not connected to this PR

@lulco lulco changed the title WIP: Upgrade to Nette 3.1 Upgrade to Nette 3.1 Jan 17, 2021
Copy link
Member

@TomasVotruba TomasVotruba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice work with the array dim fetch rule 👍

Comment on lines 92 to 101
if (! $this->isObjectType($assign->expr, 'Nette\Application\Routers\Route')) {
return false;
}

$arrayDimFetch = $assign->var;
if (! $arrayDimFetch->var instanceof Variable) {
return false;
}

return $this->isObjectType($arrayDimFetch->var, 'Nette\Application\Routers\RouteList');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The class and method should be passed via configure() method, so this rule can be used as generic one.

$services->set(ArrayAccessAddRouteToAddRouteMethodCallRector::class)
    ->call('configure', [[
        ArrayAccessAddRouteToAddRouteMethodCallRector::TYPE_TO_METHOD_CALL => [
           'Nette\Application\Routers\Route' => 'addRoute'
        ]
    ]]);

Is the second class 'Nette\Application\Routers\RouteList' really neccessary or can we remove it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure now. I have to go deeper :) there are at least two classes with method addRoute() but I don't know if both can be used in createRouter method...

But let assume that you have router which just adds Routes to some array and then iterates over this array and adds it to RouteList

Something like this:

public function createRouter()
{
    $routeArray = [];
    $routeList = new RouteList();

    $routeArray[] = new Route('<module>/<presenter>/<action>[/<id>]', 'Homepage:default');

    foreach ($routeArray as $route) {
        $routeList[] = $route;
    }
    return $routeList;
}

With ignoring RouteList, our code will call ->addRoute on $routeArray

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Thanks for the code.
The right part must be checked for New_ node instance.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check added

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be resolved. Rule must be configurable

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only time will tell. This abstraction is obvious (class and method name), so better do it now when we have focus, then in 6 month create duplicated rule. Yes that happens :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK I will try something. If I have 3+ config strings (listClass, itemClass, listMethod) I will need some ValueObject right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you 👍

I will need some ValueObject right?

Yes, that would be way to go for 3+ values to check

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you 👍

I will need some ValueObject right?

Yes, that would be way to go for 3+ values to check

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generic rule is created, but probably some renamings should be done...

@TomasVotruba
Copy link
Member

The PHPStan CI fail is unrelated, I'll look into it

@lulco
Copy link
Contributor Author

lulco commented Jan 17, 2021

Very nice work with the array dim fetch rule 👍

As I wrote, it is inspired by existing rule ArrayAccessSetControlToAddComponentMethodCallRector

@lulco
Copy link
Contributor Author

lulco commented Jan 18, 2021

So, are we done? :)

@TomasVotruba
Copy link
Member

@lulco
Copy link
Contributor Author

lulco commented Jan 18, 2021

Code Analysis PHP 8.0 / PHPStan failed again

@lulco
Copy link
Contributor Author

lulco commented Jan 20, 2021

@TomasVotruba I merged master into branch and build is green again. Generic rule is done. Is there anything you want to add / change in this PR?

@TomasVotruba
Copy link
Member

Looks very good, thanks for your detailed work 👍

@TomasVotruba TomasVotruba enabled auto-merge (squash) January 20, 2021 11:09
@TomasVotruba TomasVotruba merged commit f386ccd into rectorphp:master Jan 20, 2021
@lulco lulco deleted the nette-31 branch January 20, 2021 11:38
TomasVotruba added a commit that referenced this pull request Oct 24, 2023
rectorphp/rector-src@f2c8967 [DeadCode] Mirror comment on assign method call on RemoveUnusedVariableAssignRector (#5195)
TomasVotruba added a commit that referenced this pull request Oct 24, 2023
rectorphp/rector-src@f2c8967 [DeadCode] Mirror comment on assign method call on RemoveUnusedVariableAssignRector (#5195)
TomasVotruba added a commit that referenced this pull request Oct 24, 2023
rectorphp/rector-src@f2c8967 [DeadCode] Mirror comment on assign method call on RemoveUnusedVariableAssignRector (#5195)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Nette 3.1] Add upgrade set
2 participants