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
21 changes: 21 additions & 0 deletions resources/docs/swiss-knife.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
In 2024 we shipped an in-house tool that we originally used only internally to help with upgrades.

It can help you with various everyday tasks that are outside Rector's scope, but are connected with upgrades and code quality.

### Install

```bash
composer require rector/swiss-knife --dev
```

It helps with:

* fixing PSR-4 namespace to match `composer.json` autoload
* finalizing all classes excepts parents, entities marked with docblock, attributes or YAML-defined
* detecting commented code or git conflicts

<br>

See [Swiss knife Github repository](https://github.com/rectorphp/swiss-knife) for full documentation.


12 changes: 0 additions & 12 deletions resources/docs/team-tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,6 @@ There 2 more tools that help out with specific sets:
* [tomasvotruba/type-coverage](https://github.com/TomasVotruba/type-coverage) - works best with `withTypeCoverageLevel()`
* [tomasvotruba/class-leak](https://github.com/TomasVotruba/class-leak) - works best with `withDeadCodeLevel()`

## 3. Multi Tools

Last but not least, in 2024 we shipped a home made tool that can help you with various tasks. We use it every project and it's a great help:

* [rector/swiss-knife](https://github.com/rectorphp/swiss-knife)

It helps with:

* fixing PSR-4 namespace to match `composer.json` autoload
* finalizing all classes excepts parents, entities marked with docblock, attributes or YAML-defined
* detecting commented code or git conflicts

<br>

There is also [symplify/config-transformer](https://github.com/symplify/config-transformer) that helps with transforming YAML Symfony configs to PHP. There you can follow up with [Symfony rules for Rector](/rule-detail/string-extension-to-config-builder-rector) to reach config builders.
12 changes: 1 addition & 11 deletions resources/views/docs/section.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@

<ul class="mt-3">
<li>
<a
href="{{ action(\App\Controller\DocumentationController::class) }}"
>Introduction</a>
<a href="{{ action(\App\Controller\DocumentationController::class) }}">Introduction</a>
</li>
</ul>

Expand Down Expand Up @@ -44,14 +42,6 @@ class="{{ $documentation_menu_item->isNew() ? 'text-bold' : '' }}"
@endforeach
</ul>
@endforeach

<ul>
<li>
<a href="https://leanpub.com/rector-the-power-of-automated-refactoring">
Learn Rector in Depth from Book
</a>
</li>
</ul>
</div>

<div class="col-12 col-sm-9" id="documentation">
Expand Down
7 changes: 7 additions & 0 deletions src/Documentation/DocumentationMenuFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ public function create(): array
$this->documentationMenuItemFactory->createSection('rules-overview', 'Rules Overview'),
$this->documentationMenuItemFactory->createSection('creating-a-node-visitor', 'Creating Node Visitor'),
$this->documentationMenuItemFactory->createSection('how-to-run-on-php-53', 'Run on PHP 5.3'),
$this->documentationMenuItemFactory->createSection(
'https://leanpub.com/rector-the-power-of-automated-refactoring',
'Learn Rector in Depth from Book'
),
],
'Rector Family Tools' => [
$this->documentationMenuItemFactory->createSection('swiss-knife', 'Swiss Knife', true),
],
];
}
Expand Down
19 changes: 10 additions & 9 deletions src/Documentation/DocumentationMenuItemFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,17 @@ public function __construct(
) {
}

public function createSection(string $slug, string $name, bool $isNew = false): DocumentationMenuItem
public function createSection(string $slugOrUrl, string $name, bool $isNew = false): DocumentationMenuItem
{
return new DocumentationMenuItem(
$this->urlGenerator->action(DocumentationController::class, [
'section' => $slug,
]),
$name,
$isNew
);

if (str_starts_with($slugOrUrl, 'https://')) {
$url = $slugOrUrl;
} else {
$url = $this->urlGenerator->action(DocumentationController::class, [
'section' => $slugOrUrl,
]);
}

return new DocumentationMenuItem($url, $name, $isNew);
}

/**
Expand Down