add READMEs for subpackages, so people know

This commit is contained in:
TomasVotruba 2017-09-06 19:48:46 +02:00
parent 4bb5f41b67
commit 7a217267b9
2 changed files with 77 additions and 0 deletions

View File

@ -0,0 +1,52 @@
# Node Type Resolver
This package detects `class`, type `class_node` and `$variable` or `$this->property` types and adds them to all relevant nodes.
Class type is added to all nodes inside it, so you always now where you are.
Anonymous classes are skipped.
## How it works?
1. Traverse all nodes
2. Detect variable assigns, property use, method arguments
3. Resolve types
4. Add them via `$node->setAttribute('type', $type);` to ever node
## How it helps you?
You can get `class`
```php
$class = (string) $node->getAttribute('class');
if (Strings::endsWith($class, 'Command')) {
// we are in Command class
}
// to be sure it's console command
/** @var PhpParser\Node\Name\FullyQualified $fqnName */
$classNode = $node->getAttribute('class_node');
$fqnName = $classNode->extends->getAttribute('resolvedName');
if ($fqnName->toString() === 'Symfony\Component\Console\Command') {
// we are sure it's child of Symfony\Console Command class
}
```
or `type` attribute:
```php
/** @var string $type */
$type = $node->var->getAttribute('type');
if ($type === 'Nette\Application\UI\Form') {
// this is Nette\Application\UI\Form variable
}
```
...in any Rector you create.

View File

@ -0,0 +1,25 @@
# Trigger Extractor
This package extracts `trigger_error(*, E_USER_DEPRECATED)` from the code.
It helps to generated automate rectors.
## How it works?
1. Just read the message
2. Detect what code should be change into what code
3. Create rectors that will do the work
## How it helps you?
Instead of using your eyes and brain to read `CHANGELOG.md` or `UPGRADE-x.md`, just run it over directory of framework you use:
```bash
vendor/bin/rector extract-deprecations vendor/nette
```
It will show you what changed and how.
Moreover, it will change the code for you.