Merge pull request #639 from bendavies/tests-for-various-problems

AnnotatedPropertyInjectToConstructorInjectionRector issues
This commit is contained in:
Tomáš Votruba 2018-09-27 22:16:31 +08:00 committed by GitHub
commit e1ef0f1c6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 180 additions and 9 deletions

View File

@ -21,6 +21,11 @@ final class AnnotatedPropertyInjectToConstructorInjectionRectorTest extends Abst
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/wrong5.php.inc', __DIR__ . '/Correct/correct5.php.inc'];
yield [__DIR__ . '/Wrong/wrong6.php.inc', __DIR__ . '/Correct/correct6.php.inc'];
}
protected function provideConfig(): string

View File

@ -1,19 +1,19 @@
<?php declare (strict_types=1);
class ClassWithInjects
class ClassWithInjects2
{
/**
* @var stdClass
* @autowired
*/
private $property;
public $property;
/**
* @var DateTimeInterface
* @inject
*/
public $otherProperty;
public function __construct(\stdClass $property)
private $otherProperty;
public function __construct(\DateTimeInterface $otherProperty)
{
$this->property = $property;
$this->otherProperty = $otherProperty;
}
}

View File

@ -0,0 +1,16 @@
<?php declare(strict_types=1);
use Rector\Tests\Rector\Architecture\DependencyInjection\AnnotatedPropertyInjectToConstructorInjectionRector\Source\SomeProduct;
class ClassWithInjects3
{
/**
* @var SomeProduct
*/
private $property;
public function __construct(SomeProduct $property)
{
$this->property = $property;
}
}

View File

@ -0,0 +1,16 @@
<?php declare(strict_types=1);
use Rector\Tests\Rector\Architecture\DependencyInjection\AnnotatedPropertyInjectToConstructorInjectionRector\Source\SomeProductWithInterface;
class ClassWithInjects4
{
/**
* @var SomeProductWithInterface
*/
private $property;
public function __construct(SomeProductWithInterface $property)
{
$this->property = $property;
}
}

View File

@ -0,0 +1,16 @@
<?php declare(strict_types=1);
use Rector\Tests\Rector\Architecture\DependencyInjection\AnnotatedPropertyInjectToConstructorInjectionRector\Source\SomeProductWithTrait;
class ClassWithInjects5
{
/**
* @var SomeProductWithTrait
*/
private $property;
public function __construct(SomeProductWithTrait $property)
{
$this->property = $property;
}
}

View File

@ -0,0 +1,16 @@
<?php declare(strict_types=1);
use Rector\Tests\Rector\Architecture\DependencyInjection\AnnotatedPropertyInjectToConstructorInjectionRector\Source\SomeProductWithParent;
class ClassWithInjects6
{
/**
* @var SomeProductWithParent
*/
private $property;
public function __construct(SomeProductWithParent $property)
{
$this->property = $property;
}
}

View File

@ -0,0 +1,7 @@
<?php declare(strict_types=1);
namespace Rector\Tests\Rector\Architecture\DependencyInjection\AnnotatedPropertyInjectToConstructorInjectionRector\Source;
interface SomeInterface
{
}

View File

@ -0,0 +1,8 @@
<?php declare(strict_types=1);
namespace Rector\Tests\Rector\Architecture\DependencyInjection\AnnotatedPropertyInjectToConstructorInjectionRector\Source;
class SomeParent
{
}

View File

@ -0,0 +1,8 @@
<?php declare(strict_types=1);
namespace Rector\Tests\Rector\Architecture\DependencyInjection\AnnotatedPropertyInjectToConstructorInjectionRector\Source;
final class SomeProduct
{
}

View File

@ -0,0 +1,8 @@
<?php declare(strict_types=1);
namespace Rector\Tests\Rector\Architecture\DependencyInjection\AnnotatedPropertyInjectToConstructorInjectionRector\Source;
final class SomeProductWithInterface implements SomeInterface
{
}

View File

@ -0,0 +1,8 @@
<?php declare(strict_types=1);
namespace Rector\Tests\Rector\Architecture\DependencyInjection\AnnotatedPropertyInjectToConstructorInjectionRector\Source;
final class SomeProductWithParent extends SomeParent
{
}

View File

@ -0,0 +1,8 @@
<?php declare(strict_types=1);
namespace Rector\Tests\Rector\Architecture\DependencyInjection\AnnotatedPropertyInjectToConstructorInjectionRector\Source;
final class SomeProductWithTrait
{
use SomeTrait;
}

View File

@ -0,0 +1,7 @@
<?php declare(strict_types=1);
namespace Rector\Tests\Rector\Architecture\DependencyInjection\AnnotatedPropertyInjectToConstructorInjectionRector\Source;
trait SomeTrait
{
}

View File

@ -1,16 +1,16 @@
<?php declare (strict_types=1);
class ClassWithInjects
class ClassWithInjects2
{
/**
* @var stdClass
* @autowired
*/
protected $property;
public $property;
/**
* @var DateTimeInterface
* @inject
*/
public $otherProperty;
protected $otherProperty;
}

View File

@ -0,0 +1,12 @@
<?php declare(strict_types=1);
use Rector\Tests\Rector\Architecture\DependencyInjection\AnnotatedPropertyInjectToConstructorInjectionRector\Source\SomeProduct;
class ClassWithInjects3
{
/**
* @var SomeProduct
* @inject
*/
protected $property;
}

View File

@ -0,0 +1,12 @@
<?php declare(strict_types=1);
use Rector\Tests\Rector\Architecture\DependencyInjection\AnnotatedPropertyInjectToConstructorInjectionRector\Source\SomeProductWithInterface;
class ClassWithInjects4
{
/**
* @var SomeProductWithInterface
* @inject
*/
protected $property;
}

View File

@ -0,0 +1,12 @@
<?php declare(strict_types=1);
use Rector\Tests\Rector\Architecture\DependencyInjection\AnnotatedPropertyInjectToConstructorInjectionRector\Source\SomeProductWithTrait;
class ClassWithInjects5
{
/**
* @var SomeProductWithTrait
* @inject
*/
protected $property;
}

View File

@ -0,0 +1,12 @@
<?php declare(strict_types=1);
use Rector\Tests\Rector\Architecture\DependencyInjection\AnnotatedPropertyInjectToConstructorInjectionRector\Source\SomeProductWithParent;
class ClassWithInjects6
{
/**
* @var SomeProductWithParent
* @inject
*/
protected $property;
}