mirror of
https://github.com/rectorphp/rector.git
synced 2024-05-28 23:10:51 +00:00
Clean up documentation
This commit is contained in:
parent
7f66efa095
commit
76028f66f6
|
@ -1,6 +1,5 @@
|
|||
## PHPUnit Rectors
|
||||
|
||||
|
||||
All methods are changes by default. But **you can specify methods** you like:
|
||||
|
||||
````yaml
|
||||
|
|
|
@ -11,12 +11,10 @@ rectors:
|
|||
|
||||
requires `Rector\Contract\Bridge\ServiceTypeForNameProviderInterface` service that provides **service type for certain service name**.
|
||||
|
||||
|
||||
**Why Should You Implement the Interface?**
|
||||
|
||||
This operation could be automated on some level, but Kernel and Container API vary too much over frameworks and their versions. The implementation is left up to you and your specific case. **This allows any framework and container to use these rectors and gives you freedom to provide own desired types if needed**.
|
||||
|
||||
|
||||
## How to Add it?
|
||||
|
||||
1. Implement `Rector\Contract\Bridge\ServiceTypeForNameProviderInterface`
|
||||
|
@ -31,13 +29,13 @@ This operation could be automated on some level, but Kernel and Container API va
|
|||
|
||||
final class StaticProvidero implements ServiceTypeForNameProviderInterface
|
||||
{
|
||||
/**
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
private $nameToTypeMap = [
|
||||
'eventDispatcher' => 'Symfony\Component\EventDispatcher\EventDispatcherInterface',
|
||||
];
|
||||
|
||||
|
||||
public function provideTypeForName(string $name): ?string
|
||||
{
|
||||
return $this->nameToTypeMap[$name] ?? null;
|
||||
|
@ -58,13 +56,10 @@ This operation could be automated on some level, but Kernel and Container API va
|
|||
|
||||
That's it!
|
||||
|
||||
|
||||
|
||||
## Symfony Kernel Version
|
||||
|
||||
Of couse we have some prepared examples for Kernel, don't you worry.
|
||||
|
||||
|
||||
```php
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Rector\Contract\Bridge\ServiceTypeForNameProviderInterface;
|
||||
|
@ -82,7 +77,7 @@ final class AppKernelProvider implements ServiceTypeForNameProviderInterface
|
|||
if (! $this->container->has($name)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
return $this->container->get($name);
|
||||
}
|
||||
|
||||
|
@ -101,8 +96,6 @@ final class AppKernelProvider implements ServiceTypeForNameProviderInterface
|
|||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
## Nette Environment
|
||||
|
||||
@tba
|
Loading…
Reference in New Issue
Block a user