mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-17 13:28:18 +01:00
README: add magic disclosure rectors [closes #142]
This commit is contained in:
parent
6f07ef7115
commit
a477dc1772
57
README.md
57
README.md
@ -192,6 +192,63 @@ You can:
|
||||
- '!PHPUnit_Framework_MockObject_MockObject'
|
||||
```
|
||||
|
||||
### Turn Magic to Methods
|
||||
|
||||
- **replace get/set magic methods with real ones**
|
||||
|
||||
```yml
|
||||
rectors:
|
||||
Rector\Rector\MagicDisclosure\GetAndSetToMethodCallRector:
|
||||
# class
|
||||
'Nette\DI\Container':
|
||||
# magic method (prepared keys): new real method
|
||||
'get': 'getService'
|
||||
'set': 'addService'
|
||||
```
|
||||
|
||||
This will change:
|
||||
|
||||
```php
|
||||
$result = $container['key'];
|
||||
|
||||
$container['key'] = $value;
|
||||
```
|
||||
|
||||
Into
|
||||
|
||||
```php
|
||||
$result = $container->getService('key');
|
||||
|
||||
$container->addService('key', $value);
|
||||
```
|
||||
|
||||
- or **replaces isset/unset magic methods with real ones**
|
||||
|
||||
```yml
|
||||
rectors:
|
||||
Rector\Rector\MagicDisclosure\UnsetAndIssetToMethodCallRector:
|
||||
# class
|
||||
'Nette\DI\Container':
|
||||
# magic method (prepared keys): new real method
|
||||
'isset': 'hasService'
|
||||
'unset': 'removeService'
|
||||
```
|
||||
|
||||
This will change:
|
||||
|
||||
```php
|
||||
isset($container['key']);
|
||||
|
||||
unset($container['key']);
|
||||
```
|
||||
|
||||
Into
|
||||
|
||||
```php
|
||||
$container->hasService('key');
|
||||
|
||||
$container->removeService('key');
|
||||
```
|
||||
|
||||
### 6 Steps to Add New Rector
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user