Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
"Rector\\AttributeAwarePhpDoc\\": "packages/attribute-aware-php-doc/src",
"Rector\\Autodiscovery\\": "rules/autodiscovery/src",
"Rector\\BetterPhpDocParser\\": "packages/better-php-doc-parser/src",
"Rector\\CakePHPToSymfony\\": "rules/cakephp-to-symfony/src",
"Rector\\CakePHP\\": "rules/cakephp/src",
"Rector\\Celebrity\\": "rules/celebrity/src",
"Rector\\ChangesReporting\\": "packages/changes-reporting/src",
Expand Down Expand Up @@ -143,7 +142,6 @@
"Rector\\Architecture\\Tests\\": "rules/architecture/tests",
"Rector\\Autodiscovery\\Tests\\": "rules/autodiscovery/tests",
"Rector\\BetterPhpDocParser\\Tests\\": "packages/better-php-doc-parser/tests",
"Rector\\CakePHPToSymfony\\Tests\\": "rules/cakephp-to-symfony/tests",
"Rector\\CakePHP\\Tests\\": "rules/cakephp/tests",
"Rector\\Celebrity\\Tests\\": "rules/celebrity/tests",
"Rector\\CodeQuality\\Tests\\": "rules/code-quality/tests",
Expand Down Expand Up @@ -220,8 +218,6 @@
"rules/autodiscovery/tests/Rector/FileSystem/MoveInterfacesToContractNamespaceDirectoryRector/Expected",
"rules/autodiscovery/tests/Rector/FileSystem/MoveServicesBySuffixToDirectoryRector/Expected",
"rules/cakephp/tests/Rector/StaticCall/AppUsesStaticCallToUseStatementRector/Source",
"rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPControllerComponentToSymfonyRector/Source",
"rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineEntityRector/Source",
"tests/Source",
"tests/Rector/Psr4/MultipleClassFileToPsr4ClassesRector/Source",
"tests/Rector/Namespace_/PseudoNamespaceToNamespaceRector/Source",
Expand Down
20 changes: 0 additions & 20 deletions config/set/cakephp-to-symfony/cakephp-24-to-symfony-51.yaml

This file was deleted.

323 changes: 1 addition & 322 deletions docs/rector_rules_overview.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# All 512 Rectors Overview
# All 499 Rectors Overview

- [Projects](#projects)
- [General](#general)
Expand All @@ -9,7 +9,6 @@
- [Architecture](#architecture)
- [Autodiscovery](#autodiscovery)
- [CakePHP](#cakephp)
- [CakePHPToSymfony](#cakephptosymfony)
- [Celebrity](#celebrity)
- [CodeQuality](#codequality)
- [CodingStyle](#codingstyle)
Expand Down Expand Up @@ -380,326 +379,6 @@ services:

<br>

## CakePHPToSymfony

### `CakePHPBeforeFilterToRequestEventSubscriberRector`

- class: [`Rector\CakePHPToSymfony\Rector\Class_\CakePHPBeforeFilterToRequestEventSubscriberRector`](/../master/rules/cakephp-to-symfony/src/Rector/Class_/CakePHPBeforeFilterToRequestEventSubscriberRector.php)

Migrate CakePHP beforeFilter() method from controller to Event Subscriber before request

```diff
class SuperadminController extends \AppController
{
- public function beforeFilter()
- {
- // something
- }
}
```

<br>

### `CakePHPControllerActionToSymfonyControllerActionRector`

- class: [`Rector\CakePHPToSymfony\Rector\ClassMethod\CakePHPControllerActionToSymfonyControllerActionRector`](/../master/rules/cakephp-to-symfony/src/Rector/ClassMethod/CakePHPControllerActionToSymfonyControllerActionRector.php)
- [test fixtures](/../master/rules/cakephp-to-symfony/tests/Rector/ClassMethod/CakePHPControllerActionToSymfonyControllerActionRector/Fixture)

Migrate CakePHP 2.4 Controller action to Symfony 5

```diff
+use Symfony\Component\HttpFoundation\Response;
+
class HomepageController extends \AppController
{
- public function index()
+ public function index(): Response
{
$value = 5;
}
}
```

<br>

### `CakePHPControllerComponentToSymfonyRector`

- class: [`Rector\CakePHPToSymfony\Rector\Class_\CakePHPControllerComponentToSymfonyRector`](/../master/rules/cakephp-to-symfony/src/Rector/Class_/CakePHPControllerComponentToSymfonyRector.php)
- [test fixtures](/../master/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPControllerComponentToSymfonyRector/Fixture)

Migrate CakePHP 2.4 Controller $components property to Symfony 5

```diff
class MessagesController extends \AppController
{
- public $components = ['Overview'];
+ private function __construct(OverviewComponent $overviewComponent)
+ {
+ $this->overviewComponent->filter();
+ }

public function someAction()
{
- $this->Overview->filter();
+ $this->overviewComponent->filter();
}
}

class OverviewComponent extends \Component
{
public function filter()
{
}
}
```

<br>

### `CakePHPControllerHelperToSymfonyRector`

- class: [`Rector\CakePHPToSymfony\Rector\Class_\CakePHPControllerHelperToSymfonyRector`](/../master/rules/cakephp-to-symfony/src/Rector/Class_/CakePHPControllerHelperToSymfonyRector.php)
- [test fixtures](/../master/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPControllerHelperToSymfonyRector/Fixture)

Migrate CakePHP 2.4 Controller $helpers and $components property to Symfony 5

```diff
class HomepageController extends AppController
{
- public $helpers = ['Flash'];
-
public function index()
{
- $this->Flash->success(__('Your post has been saved.'));
- $this->Flash->error(__('Unable to add your post.'));
+ $this->addFlash('success', __('Your post has been saved.'));
+ $this->addFlash('error', __('Unable to add your post.'));
}
}
```

<br>

### `CakePHPControllerRedirectToSymfonyRector`

- class: [`Rector\CakePHPToSymfony\Rector\ClassMethod\CakePHPControllerRedirectToSymfonyRector`](/../master/rules/cakephp-to-symfony/src/Rector/ClassMethod/CakePHPControllerRedirectToSymfonyRector.php)
- [test fixtures](/../master/rules/cakephp-to-symfony/tests/Rector/ClassMethod/CakePHPControllerRedirectToSymfonyRector/Fixture)

Migrate CakePHP 2.4 Controller redirect() to Symfony 5

```diff
class RedirectController extends \AppController
{
public function index()
{
- $this->redirect('boom');
+ return $this->redirect('boom');
}
}
```

<br>

### `CakePHPControllerRenderToSymfonyRector`

- class: [`Rector\CakePHPToSymfony\Rector\ClassMethod\CakePHPControllerRenderToSymfonyRector`](/../master/rules/cakephp-to-symfony/src/Rector/ClassMethod/CakePHPControllerRenderToSymfonyRector.php)
- [test fixtures](/../master/rules/cakephp-to-symfony/tests/Rector/ClassMethod/CakePHPControllerRenderToSymfonyRector/Fixture)

Migrate CakePHP 2.4 Controller render() to Symfony 5

```diff
class RedirectController extends \AppController
{
public function index()
{
- $this->render('custom_file');
+ return $this->render('redirect/custom_file.twig');
}
}
```

<br>

### `CakePHPControllerToSymfonyControllerRector`

- class: [`Rector\CakePHPToSymfony\Rector\Class_\CakePHPControllerToSymfonyControllerRector`](/../master/rules/cakephp-to-symfony/src/Rector/Class_/CakePHPControllerToSymfonyControllerRector.php)
- [test fixtures](/../master/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPControllerToSymfonyControllerRector/Fixture)

Migrate CakePHP 2.4 Controller to Symfony 5

```diff
-class HomepageController extends AppController
+use Symfony\Component\HttpFoundation\Response;
+use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
+
+class HomepageController extends AbstractController
{
- public function index()
+ public function index(): Response
{
}
}
```

<br>

### `CakePHPImplicitRouteToExplicitRouteAnnotationRector`

- class: [`Rector\CakePHPToSymfony\Rector\Class_\CakePHPImplicitRouteToExplicitRouteAnnotationRector`](/../master/rules/cakephp-to-symfony/src/Rector/Class_/CakePHPImplicitRouteToExplicitRouteAnnotationRector.php)
- [test fixtures](/../master/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPImplicitRouteToExplicitRouteAnnotationRector/Fixture)

Migrate CakePHP implicit routes to Symfony @route annotations

```diff
-class PaymentsController extends AppController
+use Symfony\Component\Routing\Annotation\Route;
+
+class AdminPaymentsController extends AppController
{
+ /**
+ * @Route(path="/payments/index", name="payments_index")
+ */
public function index()
{
}
}
```

<br>

### `CakePHPModelToDoctrineEntityRector`

- class: [`Rector\CakePHPToSymfony\Rector\Class_\CakePHPModelToDoctrineEntityRector`](/../master/rules/cakephp-to-symfony/src/Rector/Class_/CakePHPModelToDoctrineEntityRector.php)
- [test fixtures](/../master/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineEntityRector/Fixture)

Migrate CakePHP Model active record to Doctrine\ORM Entity and EntityRepository

```diff
-class Activity extends \AppModel
+use Doctrine\Mapping\Annotation as ORM;
+
+/**
+ * @ORM\Entity
+ */
+class Activity
{
- public $belongsTo = [
- 'ActivityType' => [
- 'className' => 'ActivityType',
- 'foreignKey' => 'activity_type_id',
- 'dependent' => false,
- ],
- ];
+ /**
+ * @ORM\ManyToOne(targetEntity="ActivityType")
+ * @ORM\JoinColumn(name="activity_type_id")
+ */
+ private $activityType;
}
```

<br>

### `CakePHPModelToDoctrineRepositoryRector`

- class: [`Rector\CakePHPToSymfony\Rector\Class_\CakePHPModelToDoctrineRepositoryRector`](/../master/rules/cakephp-to-symfony/src/Rector/Class_/CakePHPModelToDoctrineRepositoryRector.php)
- [test fixtures](/../master/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineRepositoryRector/Fixture)

Migrate CakePHP Model active record to Doctrine\ORM\Repository with repository/DQL method calls

```diff
-class Activity extends \AppModel
+use Doctrine\ORM\EntityManagerInterface;
+
+class Activity
{
+}
+
+class ActivityRepository
+{
+ /**
+ * @var EntityManagerInterface
+ */
+ private $repository;
+
+ public function __construct(EntityManagerInterface $entityManager)
+ {
+ $this->repository = $entityManager->getRepository(Activity::class);
+ }
+
public function getAll()
{
- $result = $this->find('all');
+ $result = $this->repository->findAll();

return $result;
}

public function getOne()
{
- $result = $this->find('first', [
- 'conditions' => [
- 'DocumentVersionsSave.revision_number' => $versionId,
- 'DocumentVersionsSave.document_id' => $documentId,
- ],
- 'order' => [
- 'created DESC',
- ],
- ]);
+ $result = $this->findOneBy([
+ 'revision_number' => $versionId,
+ 'document_id' => $documentId,
+ ], 'created DESC');

return $result;
}
}
```

<br>

### `CakePHPTemplateHToTwigRector`

- class: [`Rector\CakePHPToSymfony\Rector\Echo_\CakePHPTemplateHToTwigRector`](/../master/rules/cakephp-to-symfony/src/Rector/Echo_/CakePHPTemplateHToTwigRector.php)
- [test fixtures](/../master/rules/cakephp-to-symfony/tests/Rector/Echo_/CakePHPTemplateHToTwigRector/Fixture)

Migrate CakePHP 2.4 h() function calls to Twig

```diff
-<h3><?php echo h($value); ?></h3>
+<h3>{{ value|escape }}</h3>
```

<br>

### `CakePHPTemplateLinkToTwigRector`

- class: [`Rector\CakePHPToSymfony\Rector\Echo_\CakePHPTemplateLinkToTwigRector`](/../master/rules/cakephp-to-symfony/src/Rector/Echo_/CakePHPTemplateLinkToTwigRector.php)

Migrate CakePHP 2.4 template method calls to Twig

```diff
<li>
- <?php echo $this->Html->link('List Rights', ['action' => 'index']); ?>
+ <a href="{{ path('index') }}">List Rights</a>
</li>
```

<br>

### `CakePHPTemplateTranslateToTwigRector`

- class: [`Rector\CakePHPToSymfony\Rector\Echo_\CakePHPTemplateTranslateToTwigRector`](/../master/rules/cakephp-to-symfony/src/Rector/Echo_/CakePHPTemplateTranslateToTwigRector.php)
- [test fixtures](/../master/rules/cakephp-to-symfony/tests/Rector/Echo_/CakePHPTemplateTranslateToTwigRector/Fixture)

Migrate CakePHP 2.4 template method calls with translate to Twig

```diff
-<h3><?php echo __("Actions"); ?></h3>
+<h3>{{ "Actions"|trans }}</h3>
```

<br>

## Celebrity

### `CommonNotEqualRector`
Expand Down
9 changes: 0 additions & 9 deletions rules/cakephp-to-symfony/config/config.yaml

This file was deleted.

Loading