Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup RecastingRemovalRector tests #4498

Merged
merged 1 commit into from
Jul 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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;
}