mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-18 05:48:21 +01:00
split ValueObjectRemoverDocBlockRector
This commit is contained in:
parent
f53e9c2127
commit
d8b430ff72
@ -11,7 +11,6 @@ use PhpParser\Node\Name\FullyQualified;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PhpParser\Node\Stmt\Expression;
|
||||
use PhpParser\Node\Stmt\Return_;
|
||||
use Rector\Node\Attribute;
|
||||
use Rector\NodeTypeResolver\PhpDoc\NodeAnalyzer\DocBlockAnalyzer;
|
||||
use Rector\Rector\AbstractPHPUnitRector;
|
||||
use Rector\RectorDefinition\CodeSample;
|
||||
|
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\Tests\Rector\DomainDrivenDesign\ValueObjectRemoverDocBlockRector;
|
||||
|
||||
use Rector\Tests\Rector\DomainDrivenDesign\ValueObjectRemoverDocBlockRector\Source\SomeChildOfValueObject;
|
||||
|
||||
class ActionClass
|
||||
{
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $someChildValueObject;
|
||||
|
||||
public function someFunction()
|
||||
{
|
||||
$this->someChildValueObject = new SomeChildOfValueObject('value');
|
||||
|
||||
$someChildValueObject = new SomeChildOfValueObject();
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace SomeNamespace;
|
||||
|
||||
use Rector\Tests\Rector\DomainDrivenDesign\ValueObjectRemoverDocBlockRector\Source\SomeValueObject;
|
||||
|
||||
class FourthActionClass
|
||||
{
|
||||
public function someFunction(?SomeValueObject $name): ?SomeValueObject
|
||||
{
|
||||
/** @var string|null $someValueObject */
|
||||
$someValueObject = new SomeValueObject('value');
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace SomeNamespace;
|
||||
|
||||
use Rector\Tests\Rector\DomainDrivenDesign\ValueObjectRemoverDocBlockRector\Source\SomeValueObject;
|
||||
|
||||
class ThirdActionClass
|
||||
{
|
||||
/**
|
||||
* @param null|string $name
|
||||
*/
|
||||
public function someFunction(?SomeValueObject $name): ?SomeValueObject
|
||||
{
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\Rector\DomainDrivenDesign\ValueObjectRemoverDocBlockRector\Source;
|
||||
|
||||
class SomeChildOfValueObject extends SomeValueObject
|
||||
{
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\Rector\DomainDrivenDesign\ValueObjectRemoverDocBlockRector\Source;
|
||||
|
||||
class SomeValueObject
|
||||
{
|
||||
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\Rector\DomainDrivenDesign\ValueObjectRemoverDocBlockRector;
|
||||
|
||||
use Iterator;
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
|
||||
/**
|
||||
* @covers \Rector\Rector\DomainDrivenDesign\ValueObjectRemover\ValueObjectRemoverDocBlockRector
|
||||
*/
|
||||
final class ValueObjectRemoverDocBlockRectorTest extends AbstractRectorTestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideWrongToFixedFiles()
|
||||
*/
|
||||
public function test(string $wrong, string $fixed): void
|
||||
{
|
||||
$this->doTestFileMatchesExpectedContent($wrong, $fixed);
|
||||
}
|
||||
|
||||
public function provideWrongToFixedFiles(): Iterator
|
||||
{
|
||||
yield [__DIR__ . '/Wrong/wrong.php.inc', __DIR__ . '/Correct/correct.php.inc'];
|
||||
yield [__DIR__ . '/Wrong/wrong2.php.inc', __DIR__ . '/Correct/correct2.php.inc'];
|
||||
yield [__DIR__ . '/Wrong/wrong3.php.inc', __DIR__ . '/Correct/correct3.php.inc'];
|
||||
}
|
||||
|
||||
protected function provideConfig(): string
|
||||
{
|
||||
return __DIR__ . '/config.yml';
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\Tests\Rector\DomainDrivenDesign\ValueObjectRemoverDocBlockRector;
|
||||
|
||||
use Rector\Tests\Rector\DomainDrivenDesign\ValueObjectRemoverDocBlockRector\Source\SomeChildOfValueObject;
|
||||
|
||||
class ActionClass
|
||||
{
|
||||
/**
|
||||
* @var SomeChildOfValueObject|null
|
||||
*/
|
||||
private $someChildValueObject;
|
||||
|
||||
public function someFunction()
|
||||
{
|
||||
$this->someChildValueObject = new SomeChildOfValueObject('value');
|
||||
|
||||
$someChildValueObject = new SomeChildOfValueObject();
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace SomeNamespace;
|
||||
|
||||
use Rector\Tests\Rector\DomainDrivenDesign\ValueObjectRemoverDocBlockRector\Source\SomeValueObject;
|
||||
|
||||
class FourthActionClass
|
||||
{
|
||||
public function someFunction(?SomeValueObject $name): ?SomeValueObject
|
||||
{
|
||||
/** @var SomeValueObject|null $someValueObject */
|
||||
$someValueObject = new SomeValueObject('value');
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace SomeNamespace;
|
||||
|
||||
use Rector\Tests\Rector\DomainDrivenDesign\ValueObjectRemoverDocBlockRector\Source\SomeValueObject;
|
||||
|
||||
class ThirdActionClass
|
||||
{
|
||||
/**
|
||||
* @param null|SomeValueObject $name
|
||||
*/
|
||||
public function someFunction(?SomeValueObject $name): ?SomeValueObject
|
||||
{
|
||||
}
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
services:
|
||||
Rector\Rector\DomainDrivenDesign\ValueObjectRemover\ValueObjectRemoverDocBlockRector:
|
||||
$valueObjectsToSimpleTypes:
|
||||
'Rector\Tests\Rector\DomainDrivenDesign\ValueObjectRemoverDocBlockRector\Source\SomeValueObject': 'string'
|
@ -7,7 +7,7 @@ use Rector\Tests\Rector\DomainDrivenDesign\ValueObjectRemoverRector\Source\SomeC
|
||||
class ActionClass
|
||||
{
|
||||
/**
|
||||
* @var string|null
|
||||
* @var SomeChildOfValueObject|null
|
||||
*/
|
||||
private $someChildValueObject;
|
||||
|
||||
|
@ -7,7 +7,7 @@ use Rector\Tests\Rector\DomainDrivenDesign\ValueObjectRemoverRector\Source\SomeV
|
||||
class ThirdActionClass
|
||||
{
|
||||
/**
|
||||
* @param null|string $name
|
||||
* @param null|SomeValueObject $name
|
||||
*/
|
||||
public function someFunction(?string $name): ?string
|
||||
{
|
||||
|
@ -8,7 +8,7 @@ class FourthActionClass
|
||||
{
|
||||
public function someFunction(?string $name): ?string
|
||||
{
|
||||
/** @var string|null $someValueObject */
|
||||
/** @var SomeValueObject|null $someValueObject */
|
||||
$someValueObject = 'value';
|
||||
}
|
||||
}
|
||||
|
@ -22,9 +22,9 @@ final class ValueObjectRemoverRectorTest extends AbstractRectorTestCase
|
||||
public function provideWrongToFixedFiles(): Iterator
|
||||
{
|
||||
yield [__DIR__ . '/Wrong/wrong.php.inc', __DIR__ . '/Correct/correct.php.inc'];
|
||||
// yield [__DIR__ . '/Wrong/wrong2.php.inc', __DIR__ . '/Correct/correct2.php.inc'];
|
||||
// yield [__DIR__ . '/Wrong/wrong3.php.inc', __DIR__ . '/Correct/correct3.php.inc'];
|
||||
// yield [__DIR__ . '/Wrong/wrong4.php.inc', __DIR__ . '/Correct/correct4.php.inc'];
|
||||
yield [__DIR__ . '/Wrong/wrong2.php.inc', __DIR__ . '/Correct/correct2.php.inc'];
|
||||
yield [__DIR__ . '/Wrong/wrong3.php.inc', __DIR__ . '/Correct/correct3.php.inc'];
|
||||
yield [__DIR__ . '/Wrong/wrong4.php.inc', __DIR__ . '/Correct/correct4.php.inc'];
|
||||
}
|
||||
|
||||
protected function provideConfig(): string
|
||||
|
@ -1,9 +1,4 @@
|
||||
services:
|
||||
# todo: combine configuration in some way
|
||||
Rector\Rector\DomainDrivenDesign\ValueObjectRemover\ValueObjectRemoverDocBlockRector:
|
||||
$valueObjectsToSimpleTypes:
|
||||
'Rector\Tests\Rector\DomainDrivenDesign\ValueObjectRemoverRector\Source\SomeValueObject': 'string'
|
||||
|
||||
Rector\Rector\DomainDrivenDesign\ValueObjectRemover\ValueObjectRemoverRector:
|
||||
$valueObjectsToSimpleTypes:
|
||||
'Rector\Tests\Rector\DomainDrivenDesign\ValueObjectRemoverRector\Source\SomeValueObject': 'string'
|
||||
|
Loading…
x
Reference in New Issue
Block a user