Replies: 3 comments 10 replies
-
Hi, I've moved it here to discussion, as it's the place you wanted at first. Congrats on a honorable challange! I think many project would benefit from such migration set.
There is lot of generic knowledge about framework migrations, that would save your some blind branches. The set can be found here: https://github.com/rectorphp/rector/blob/master/config/set/nette-to-symfony.php Personally, I'd just take it and modify custom rules from Symfony to Laravel. They're very alike (Laravel build on Symfony ideology), so that would only syntax tweaks. Whole work could be matter of 1 week. Depends what mess is the Nette project in :) If you want to speed-up learning process, I can offer you private consulting 👍 |
Beta Was this translation helpful? Give feedback.
-
I'm curious, how is it going? :) |
Beta Was this translation helpful? Give feedback.
-
I am currently struggling with the function params into Request $request Rector rule. /**
* @param ClassMethod $classMethod
*/
private function migrateToFunction(ClassMethod $classMethod): ?ClassMethod
{
$args = [];
/** @var Param $param */
foreach ($classMethod->getParams() as $param) {
// function actionTest(int $id, int $id2)
$args[] = $this->getName($param);
}
// first line of function
$first = $classMethod->getStmts()[0];
if (!$first) {
return null;
}
foreach($args as $var) {
// $request->input('id');
$methodCall = $this->createMethodCall(
'request', "input", [
$this->createArg($var)
]
);
$assign = new Assign(new Variable($var), $methodCall);
$this->addNodeBeforeNode($assign, $first);
}
$classMethod->params = [
new Param(new Variable("request"), null, new FullyQualified(\App\Requests\Request::class))
];
return $classMethod;
} Any idea why would this remove lines between other statements inside of that method? ---------- begin diff ----------
--- Original
+++ New
@@ -72,22 +72,22 @@
}
}
- function actionDefault($reservation_id): void
+ function actionDefault(\App\Requests\Request $request): void
{
+ $reservation_id = $request->input('reservation_id');
$this->redirect("hall", ["id" => 1]);
}
- function actionHall($id, $reservation_id): void
+ function actionHall(\App\Requests\Request $request): void
{
+ $id = $request->input('id');
+ $reservation_id = $request->input('reservation_id');
$this->template->hall = $hall = $this->getHall($id);
-
$reservations_q = $this->hall_reservations->where("hall_id", $id);
$reservations = [];
-
foreach ($reservations_q as $reservation) {
$reservations[$reservation->hour][$reservation->minute] = $reservation;
}
-
$this->template->reservations = $reservations;
$this->template->reservation_id = $reservation_id;
} |
Beta Was this translation helpful? Give feedback.
-
Hello. I tried to create a discussion thread but couldn't because it is not enabled (or whatever).
I am in process of refactoring a big Nette project using no Doctrine (only NetteDatabase) (51k lines of code) and preparing it to be migrated to Laravel.
Many things were done by using generators (such as DB Entities), but many of these things will probably need help from Rector. I know I probably have to create a new set for that, and would love your help.
Are there any sets I can use as a whole, or at least point me to some specific Rector Rules that comes into your mind?
I know I will specifically need RenameClassRector, RenameMethodRector.
I for sure know I will need rule to transfer all parameters from action*, render*
render(int $id, ?int $param1, ?string $param2, int $param3)
->render(Request $request)
[$id, $param1, $param2, $param3] = $request->getParameters(["id", "param1", "param2", "param3"]
If you had time to help me with this one, even in pseudocode/description, it would be really appreciated (and for sure donated if that saves me even 10 hours of my work)
Beta Was this translation helpful? Give feedback.
All reactions