Skip to content

Commit

Permalink
cleanup RecastingRemovalRector test
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed Jul 13, 2023
1 parent 23e4b66 commit f0121f2
Show file tree
Hide file tree
Showing 15 changed files with 76 additions and 101 deletions.
1 change: 0 additions & 1 deletion packages/NodeTypeResolver/NodeTypeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ public function getType(Node $node): Type

if ($type instanceof Type) {
$type = $this->accessoryNonEmptyStringTypeCorrector->correct($type);

$type = $this->genericClassStringTypeCorrector->correct($type);

if ($type instanceof ObjectType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,6 @@ public function __construct(
) {
}

private function processInsideArrayDimFetch(ArrayDimFetch $arrayDimFetch): void
{
if ($arrayDimFetch->var instanceof PropertyFetch || $arrayDimFetch->var instanceof StaticPropertyFetch) {
$arrayDimFetch->var->setAttribute(AttributeKey::INSIDE_ARRAY_DIM_FETCH, true);
}
}

public function enterNode(Node $node): ?Node
{
if ($node instanceof For_ || $node instanceof Foreach_ || $node instanceof While_ || $node instanceof Do_) {
Expand Down Expand Up @@ -95,6 +88,13 @@ public function enterNode(Node $node): ?Node
return null;
}

private function processInsideArrayDimFetch(ArrayDimFetch $arrayDimFetch): void
{
if ($arrayDimFetch->var instanceof PropertyFetch || $arrayDimFetch->var instanceof StaticPropertyFetch) {
$arrayDimFetch->var->setAttribute(AttributeKey::INSIDE_ARRAY_DIM_FETCH, true);
}
}

private function processContextInClass(Node $node): void
{
if ($node instanceof Class_) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Rector\Tests\DeadCode\Rector\Cast\RecastingRemovalRector\Rector;
namespace Rector\Tests\DeadCode\Rector\Cast\RecastingRemovalRector\Fixture;

class MethodCallReturnStrictType
{
Expand All @@ -19,7 +19,7 @@ class MethodCallReturnStrictType
-----
<?php

namespace Rector\Tests\DeadCode\Rector\Cast\RecastingRemovalRector\Rector;
namespace Rector\Tests\DeadCode\Rector\Cast\RecastingRemovalRector\Fixture;

class MethodCallReturnStrictType
{
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Rector\Tests\DeadCode\Rector\Cast\RecastingRemovalRector\Rector;
namespace Rector\Tests\DeadCode\Rector\Cast\RecastingRemovalRector\Fixture;

class SkipMethodCallReturnDocblockString
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Rector\Tests\DeadCode\Rector\Cast\RecastingRemovalRector\Rector;
namespace Rector\Tests\DeadCode\Rector\Cast\RecastingRemovalRector\Fixture;

class SkipNonTypedParam
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Rector\Tests\DeadCode\Rector\Cast\RecastingRemovalRector\Rector;
namespace Rector\Tests\DeadCode\Rector\Cast\RecastingRemovalRector\Fixture;

class SkipNonTypedParamNumericCheck
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace Rector\Tests\DeadCode\Rector\Cast\RecastingRemovalRector\Rector;
namespace Rector\Tests\DeadCode\Rector\Cast\RecastingRemovalRector\Fixture;

class SkipNonTypedProperty
final class SkipNonTypedProperty
{
/** @var int */
public $property = 1;
Expand All @@ -12,5 +12,3 @@ class SkipNonTypedProperty
$value = (int) $this->property;
}
}

?>
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
<?php

namespace Rector\Tests\DeadCode\Rector\Cast\RecastingRemovalRector\Rector;
namespace Rector\Tests\DeadCode\Rector\Cast\RecastingRemovalRector\Fixture;

class Config
{
/** @var int */
public $property = 1;
}
use Rector\Tests\DeadCode\Rector\Cast\RecastingRemovalRector\Source\ExternalNonStrictTypedProperty;

class SkipNonTypedProperty2
final class SkipNonTypedProperty2
{
public function run(Config $config)
public function run(ExternalNonStrictTypedProperty $externalNonStrictTypedProperty)
{
$value = (int) $config->property;
$value = (int) $externalNonStrictTypedProperty->property;
}
}

?>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Rector\Tests\DeadCode\Rector\Cast\RecastingRemovalRector\Rector;
namespace Rector\Tests\DeadCode\Rector\Cast\RecastingRemovalRector\Fixture;

class AConfig
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace Rector\Tests\DeadCode\Rector\Cast\RecastingRemovalRector\Fixture;

use Rector\Tests\DeadCode\Rector\Cast\RecastingRemovalRector\Source\ExternalStrictTypedProperty;

final class SomeTypedProperty
{
public function run(ExternalStrictTypedProperty $externalStrictTypedProperty)
{
$value = (int) $externalStrictTypedProperty->property;
}
}

?>
-----
<?php

namespace Rector\Tests\DeadCode\Rector\Cast\RecastingRemovalRector\Fixture;

use Rector\Tests\DeadCode\Rector\Cast\RecastingRemovalRector\Source\ExternalStrictTypedProperty;

final class SomeTypedProperty
{
public function run(ExternalStrictTypedProperty $externalStrictTypedProperty)
{
$value = $externalStrictTypedProperty->property;
}
}

?>
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace Rector\Tests\DeadCode\Rector\Cast\RecastingRemovalRector\Rector;
namespace Rector\Tests\DeadCode\Rector\Cast\RecastingRemovalRector\Fixture;

class TypedParam
final class TypedParam
{
public function run(bool $isStrict = true)
{
Expand All @@ -14,9 +14,9 @@ class TypedParam
-----
<?php

namespace Rector\Tests\DeadCode\Rector\Cast\RecastingRemovalRector\Rector;
namespace Rector\Tests\DeadCode\Rector\Cast\RecastingRemovalRector\Fixture;

class TypedParam
final class TypedParam
{
public function run(bool $isStrict = true)
{
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

declare(strict_types=1);

namespace Rector\Tests\DeadCode\Rector\Cast\RecastingRemovalRector\Source;

final class ExternalNonStrictTypedProperty
{
/** @var int */
public $property = 1;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

declare(strict_types=1);

namespace Rector\Tests\DeadCode\Rector\Cast\RecastingRemovalRector\Source;

final class ExternalStrictTypedProperty
{
public int $property = 1;
}

0 comments on commit f0121f2

Please sign in to comment.