fix tests - remove .inc

This commit is contained in:
Tomas Votruba 2018-08-14 13:24:34 +02:00
parent d8b430ff72
commit 87a5cf6ed7
12 changed files with 39 additions and 12 deletions

View File

@ -37,6 +37,9 @@ services:
parameters:
exclude_files:
- '*tests/*Source/*.php'
# tests files
- '*tests/*/Wrong/*'
- '*tests/*/Correct/*'
skip:
Symplify\CodingStandard\Fixer\Php\ClassStringToClassConstantFixer:

View File

@ -4,6 +4,7 @@ namespace Rector\NodeTypeResolver\PerNodeTypeResolver;
use PhpParser\Node;
use PhpParser\Node\Expr\Variable;
use PHPStan\Analyser\Scope;
use PHPStan\TrinaryLogic;
use PHPStan\Type\ThisType;
use Rector\NodeTypeResolver\Contract\PerNodeTypeResolver\PerNodeTypeResolverInterface;
@ -13,11 +14,6 @@ use Rector\NodeTypeResolver\PHPStan\Type\TypeToStringResolver;
final class VariableTypeResolver implements PerNodeTypeResolverInterface
{
/**
* @var ClassReflectionTypesResolver
*/
private $classReflectionTypesResolver;
/**
* @var DocBlockAnalyzer
*/
@ -48,6 +44,7 @@ final class VariableTypeResolver implements PerNodeTypeResolverInterface
*/
public function resolve(Node $variableNode): array
{
/** @var Scope $nodeScope */
$nodeScope = $variableNode->getAttribute(Attribute::SCOPE);
$variableName = (string) $variableNode->name;
@ -57,7 +54,7 @@ final class VariableTypeResolver implements PerNodeTypeResolverInterface
// this
if ($type instanceof ThisType) {
return $this->classReflectionTypesResolver->resolve($nodeScope->getClassReflection());
return [$nodeScope->getClassReflection()->getName()];
}
return $this->typeToStringResolver->resolve($type);

View File

@ -7,6 +7,8 @@ use PhpParser\Node\Stmt\Property;
use Rector\NodeTypeResolver\Tests\PerNodeTypeResolver\AbstractNodeTypeResolverTest;
use Rector\NodeTypeResolver\Tests\PerNodeTypeResolver\PropertyTypeResolver\Source\ClassThatExtendsHtml;
use Rector\NodeTypeResolver\Tests\PerNodeTypeResolver\PropertyTypeResolver\Source\Html;
use Rector\Tests\Rector\DomainDrivenDesign\ValueObjectRemoverDocBlockRector\Source\SomeChildOfValueObject;
use Rector\Tests\Rector\DomainDrivenDesign\ValueObjectRemoverDocBlockRector\Source\SomeValueObject;
/**
* @covers \Rector\NodeTypeResolver\PerNodeTypeResolver\PropertyTypeResolver
@ -27,5 +29,8 @@ final class PropertyTypeResolverTest extends AbstractNodeTypeResolverTest
{
yield [__DIR__ . '/Source/ClassWithProperties.php', 0, [Html::class]];
yield [__DIR__ . '/Source/ClassWithProperties.php', 1, [ClassThatExtendsHtml::class, Html::class]];
// mimics failing test from DomainDrivenDesign set
yield [__DIR__ . '/Source/wrong.php', 0, [SomeChildOfValueObject::class, SomeValueObject::class]];
}
}

View File

@ -31,6 +31,7 @@ parameters:
- '#Call to function in_array\(\) with arguments string, array<array<string\|false>> and true will always evaluate to false#'
# known values
- '#Cannot call method getName\(\) on PHPStan\\Reflection\\ClassReflection\|null#' # 1
- '#Parameter \#1 \$classReflection of method Rector\\NodeTypeResolver\\Reflection\\ClassReflectionTypesResolver::resolve\(\) expects PHPStan\\Reflection\\ClassReflection, PHPStan\\Reflection\\ClassReflection|null given#'
- '#Cannot call method getAttribute\(\) on PhpParser\\Node\\Name\|null#'
- '#Cannot call method getName\(\) on Rector\\Builder\\Class_\\VariableInfo\|null#'
@ -70,9 +71,6 @@ parameters:
- '#Access to an undefined property PhpParser\\Node\\Expr::\$value#' # 2
- '#Access to an undefined property PhpParser\\Node\\Expr::\$(name|var)#' # 2
# tests or coding standars?
- '#Constructor of class [\s\S]+ has an unused parameter \$html#' # 2
# tests - known values
- '#Parameter \#1 \$code of method PhpParser\\Parser::parse\(\) expects string, string\|false given#' # 1
@ -84,3 +82,7 @@ parameters:
- '*tests/Rector/MethodCall/MethodNameReplacerRector/**/SomeClass.php'
- '*packages/BetterReflection/tests/Reflector/NotLoadedSource/SomeClass.php'
- 'packages/NodeTypeResolver/tests/PerNodeTypeResolver/VariableTypeResolver/Source/NewClass.php'
# tests files
- '*tests/**/Wrong/*'
- '*tests/**/Correct/*'
- '*tests/**/Source/*'

View File

@ -20,9 +20,9 @@ final class ValueObjectRemoverDocBlockRectorTest 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/wrong.php', __DIR__ . '/Correct/correct.php'];
yield [__DIR__ . '/Wrong/wrong2.php', __DIR__ . '/Correct/correct2.php'];
yield [__DIR__ . '/Wrong/wrong3.php', __DIR__ . '/Correct/correct3.php'];
}
protected function provideConfig(): string

View File

@ -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();
}
}