Skip to content

Commit

Permalink
clean (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba authored Aug 7, 2022
1 parent b1138ab commit 6de2c65
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 95 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
"autoload": {
"psr-4": {
"Rector\\Nette\\": ["src", "packages"]
"Rector\\Nette\\": "src"
}
},
"autoload-dev": {
Expand Down
94 changes: 1 addition & 93 deletions docs/rector_rules_overview.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 25 Rules Overview
# 22 Rules Overview

## BuilderExpandToHelperExpandRector

Expand All @@ -21,41 +21,6 @@ Change `containerBuilder->expand()` to static call with parameters

<br>

## ChangeNetteEventNamesInGetSubscribedEventsRector

Change EventSubscriber from Kdyby to Contributte

- class: [`Rector\Nette\Kdyby\Rector\ClassMethod\ChangeNetteEventNamesInGetSubscribedEventsRector`](../src/Kdyby/Rector/ClassMethod/ChangeNetteEventNamesInGetSubscribedEventsRector.php)

```diff
+use Contributte\Events\Extra\Event\Application\ShutdownEvent;
use Kdyby\Events\Subscriber;
use Nette\Application\Application;
-use Nette\Application\UI\Presenter;

class GetApplesSubscriber implements Subscriber
{
- public function getSubscribedEvents()
+ public static function getSubscribedEvents()
{
return [
- Application::class . '::onShutdown',
+ ShutdownEvent::class => 'onShutdown',
];
}

- public function onShutdown(Presenter $presenter)
+ public function onShutdown(ShutdownEvent $shutdownEvent)
{
+ $presenter = $shutdownEvent->getPresenter();
$presenterName = $presenter->getName();
// ...
}
}
```

<br>

## ContextGetByTypeToConstructorInjectionRector

Move dependency get via `$context->getByType()` to constructor injection
Expand Down Expand Up @@ -413,38 +378,6 @@ Renames method calls in LATTE templates

<br>

## ReplaceEventManagerWithEventSubscriberRector

Change Kdyby EventManager to EventDispatcher

- class: [`Rector\Nette\Kdyby\Rector\MethodCall\ReplaceEventManagerWithEventSubscriberRector`](../src/Kdyby/Rector/MethodCall/ReplaceEventManagerWithEventSubscriberRector.php)

```diff
use Kdyby\Events\EventManager;

final class SomeClass
{
/**
* @var EventManager
*/
private $eventManager;

public function __construct(EventManager $eventManager)
{
$this->eventManager = eventManager;
}

public function run()
{
$key = '2000';
- $this->eventManager->dispatchEvent(static::class . '::onCopy', new EventArgsList([$this, $key]));
+ $this->eventManager->dispatch(new SomeClassCopyEvent($this, $key));
}
}
```

<br>

## ReplaceTimeNumberWithDateTimeConstantRector

Replace time numbers with `Nette\Utils\DateTime` constants
Expand Down Expand Up @@ -626,28 +559,3 @@ Change `translate()` method call 2nd arg to variadic
```

<br>

## WrapTransParameterNameRector

Adds %% to placeholder name of `trans()` method if missing

- class: [`Rector\Nette\Kdyby\Rector\MethodCall\WrapTransParameterNameRector`](../src/Kdyby/Rector/MethodCall/WrapTransParameterNameRector.php)

```diff
use Symfony\Component\Translation\Translator;

final class SomeController
{
public function run()
{
$translator = new Translator('');
$translated = $translator->trans(
'Hello %name%',
- ['name' => $name]
+ ['%name%' => $name]
);
}
}
```

<br>
2 changes: 1 addition & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
>
Expand Down

0 comments on commit 6de2c65

Please sign in to comment.