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
19 changes: 19 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# How to Contribute

Just follow 3 rules:

- **1 feature per pull-request**
- **New features need tests**
- Tests, coding standards and PHPStan **checks must pass**:

```bash
composer complete-check
```

Do you need to fix coding standards? Run:

```bash
composer fix-cs
```

We would be happy to accept PRs that follow these guidelines.
58 changes: 23 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Rector - Upgrade Your Legacy App to a Modern Codebase

Rector is a **rec**onstruc**tor** tool - it does **instant upgrades** and **instant refactoring** of your code.
Why refactor manually if Rector can handle 80% for you?
Why refactor manually if Rector can handle 80% of the task for you?

[![Coverage Status](https://img.shields.io/coveralls/rectorphp/rector/master.svg?style=flat-square)](https://coveralls.io/github/rectorphp/rector?branch=master)
[![Downloads](https://img.shields.io/packagist/dt/rector/rector.svg?style=flat-square)](https://packagist.org/packages/rector/rector)
[![SonarCube](https://img.shields.io/badge/SonarCube_Debt-%3C25-brightgreen.svg?style=flat-square)](https://sonarcloud.io/dashboard?id=rectorphp_rector)

<br>

- **[All 450+ Rectors Overview](/docs/AllRectorsOverview.md)**
- **[Overview of all 450+ Rectors](/docs/AllRectorsOverview.md)**
- **[Do you Love&Hate Legacy? We're Hiring](https://getrector.org/join-rector-team)**

<br>
Expand All @@ -21,7 +21,7 @@ Why refactor manually if Rector can handle 80% for you?
## Sponsors

Rector grows faster with your help, the more you help the more work it saves you.
Check out [Rector's Patreon](https://www.patreon.com/rectorphp). One-time donation is welcomed [through PayPal](https://www.paypal.me/rectorphp).
Check out [Rector's Patreon](https://www.patreon.com/rectorphp). One-time donations are welcome [through PayPal](https://www.paypal.me/rectorphp).

Thank you:

Expand Down Expand Up @@ -75,21 +75,21 @@ Tip: If you have EasyCodingStandard, you can start your set with [`ecs-after-rec

## Try Rector Online

Too little time to download?
No time to try Rector locally?

We have **[online demo](https://getrector.org/demo) just for you!**
We have **[an online demo](https://getrector.org/demo) just for you!**

## Install

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

**Do you have conflicts during `composer require` or on run?**
**Having conflicts during `composer require` or on run?**

- Use the [Rector Prefixed](https://github.com/rectorphp/rector-prefixed)

**Do you need different PHP version than Rector supports?**
**Using a different PHP version than Rector supports?**

- Use the [Docker image](#run-rector-in-docker)

Expand Down Expand Up @@ -138,7 +138,7 @@ parameters:

### C. Custom Sets

1. Create a `rector.yaml` config file with your desired Rectors or provide another config file with `--config`:
1. Create a `rector.yaml` configuration file with your desired Rectors or provide another configuration file with `--config`:

```yaml
services:
Expand All @@ -159,13 +159,13 @@ parameters:

### Extra Autoloading

Rector relies on project and autoloading of its classes by using the composer autoloader as default. To specify your own autoload file, use `--autoload-file` option:
Rector relies on whatever autoload setup the project it is fixing is using by using the Composer autoloader as default. To specify your own autoload file, use `--autoload-file` option:

```bash
vendor/bin/rector process ../project --autoload-file ../project/vendor/autoload.php
```

Or use a `rector.yaml` config file:
Or use a `rector.yaml` configuration file:

```yaml
# rector.yaml
Expand Down Expand Up @@ -329,13 +329,14 @@ final class MyFirstRector extends AbstractRector
*/
public function getNodeTypes(): array
{
// what node types we look for?
// what node types are we looking for?
// pick any node from https://github.com/rectorphp/rector/blob/master/docs/NodesOverview.md
return [MethodCall::class];
}

/**
* @param MethodCall $node - we can add "MethodCall" type here, because only this node is in "getNodeTypes()"
* @param MethodCall $node - we can add "MethodCall" type here, because
* only this node is in "getNodeTypes()"
*/
public function refactor(Node $node): ?Node
{
Expand Down Expand Up @@ -373,7 +374,7 @@ final class MyFirstRector extends AbstractRector
}
```

This is how file structure should look like:
This is how the file structure should look like:

```bash
/src/YourCode.php
Expand All @@ -399,7 +400,7 @@ We also need to load Rector rules in `composer.json`:
}
```

After adding this to `composer.json`, be sure to reload composer class map:
After adding this to `composer.json`, be sure to reload Composer's class map:

```bash
composer dump-autoload
Expand All @@ -415,7 +416,7 @@ services:

### 3. Let Rector Refactor Your Code

The `rector.yaml` config is loaded by default, so we can skip it.
The `rector.yaml` configuration is loaded by default, so we can skip it.

```bash
# see the diff first
Expand All @@ -427,11 +428,11 @@ vendor/bin/rector process src

That's it!

### Generate Rector Rule
### Generating a Rector Rule

Do you want to save time with making rules and tests?

Use [`create` command](/docs/RectorRecipe.md).
Use [the `create` command](/docs/RectorRecipe.md).

## More Detailed Documentation

Expand All @@ -442,23 +443,7 @@ Use [`create` command](/docs/RectorRecipe.md).

## How to Contribute

Just follow 3 rules:

- **1 feature per pull-request**
- **New features need tests**
- Tests, coding standards and PHPStan **checks must pass**:

```bash
composer complete-check
```

Do you need to fix coding standards? Run:

```bash
composer fix-cs
```

We would be happy to accept PRs that follow these guidelines.
See [the contribution guide](/CONTRIBUTING.md).

## Run Rector in Docker
You can run Rector on your project using Docker:
Expand All @@ -472,7 +457,10 @@ docker run -v $(pwd):/project rector/rector:latest process /project/src --set sy
Using `rector.yaml`:

```bash
docker run -v $(pwd):/project rector/rector:latest process /project/app --config /project/rector.yaml --autoload-file /project/vendor/autoload.php --dry-run
docker run -v $(pwd):/project rector/rector:latest process /project/app \
--config /project/rector.yaml \
--autoload-file /project/vendor/autoload.php \
--dry-run
```

### Community Packages
Expand Down