Skip to content

Commit

Permalink
remove ClearReturnNewByReferenceRector, PHPStan cannot handle it
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed Oct 27, 2021
1 parent 292cee4 commit 051c751
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 129 deletions.
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"nette/utils": "^3.2",
"nikic/php-parser": "4.13.0",
"phpstan/phpdoc-parser": "^1.2",
"phpstan/phpstan": "1.0.x-dev as 0.12.99",
"phpstan/phpstan": "^1.0",
"phpstan/phpstan-phpunit": "^0.12.22",
"rector/extension-installer": "^0.11.1",
"rector/rector-cakephp": "^0.11.5",
Expand Down Expand Up @@ -56,7 +56,7 @@
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan-nette": "^0.12.21",
"phpunit/phpunit": "^9.5",
"rector/phpstan-rules": "^0.4.6",
"rector/phpstan-rules": "^0.4.7",
"rector/rector-generator": "^0.4.1",
"spatie/enum": "^3.9",
"symplify/coding-standard": "^9.5",
Expand Down Expand Up @@ -107,6 +107,7 @@
"rules-tests/Renaming/Rector/Name/RenameClassRector/Source"
],
"files": [
"rules-tests/CodeQuality/Rector/Name/FixClassCaseSensitivityNameRector/Source/MissCaseTypedClass.php",
"stubs/Doctrine/Persistence/ObjectManager.php",
"stubs/Doctrine/Common/Persistence/ObjectManager.php",
"rules-tests/Transform/Rector/FuncCall/FuncCallToMethodCallRector/Source/some_view_function.php",
Expand Down
6 changes: 1 addition & 5 deletions config/set/php53.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,15 @@

declare(strict_types=1);

use Rector\Php53\Rector\AssignRef\ClearReturnNewByReferenceRector;
use Rector\Php53\Rector\FuncCall\DirNameFileConstantToDirConstantRector;
use Rector\Php53\Rector\Ternary\TernaryToElvisRector;
use Rector\Php53\Rector\Variable\ReplaceHttpServerVarsByServerRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(TernaryToElvisRector::class);

$services->set(TernaryToElvisRector::class);
$services->set(DirNameFileConstantToDirConstantRector::class);

$services->set(ClearReturnNewByReferenceRector::class);

$services->set(ReplaceHttpServerVarsByServerRector::class);
};
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ final class FixClassCaseSensitivityNameRectorTest extends AbstractRectorTestCase
public function test(SmartFileInfo $fileInfo): void
{
// for PHPStan class reflection
require_once __DIR__ . '/Source/MissCaseTypedClass.php';
//require_once __DIR__ . '/Source/MissCaseTypedClass.php';

$this->doTestFileInfo($fileInfo);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,24 @@ abstract class KeepStaticMethod
return Token::create($parts[0] ?? '', $parts[1] ?? '');
}
}

?>
-----
<?php

declare(strict_types=1);

namespace Rector\Tests\CodingStyle\Rector\Namespace_\ImportFullyQualifiedNamesRector\Fixture;

use Rector\Tests\CodingStyle\Rector\Namespace_\ImportFullyQualifiedNamesRector\Fixture\Contract\Token;
abstract class KeepStaticMethod
{
public static function decode(string $token): Token
{
$parts = explode('|', (string) base64_decode($token, true));

return Token::create($parts[0] ?? '', $parts[1] ?? '');
}
}

?>
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,18 @@ class SkipAliasedNames
}
}
?>
-----
<?php
namespace Rector\Tests\CodingStyle\Rector\Namespace_\ImportFullyQualifiedNamesRector\Fixture;

use Symfony\Component\Validator\Constraints\Blank;
use Symfony\Component\Validator\Constraints as Assert;

class SkipAliasedNames
{
public function __construct()
{
$constraint = Blank::class;
}
}
?>
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,18 @@ class SkipSameNamespacedUsedClass
{
}
}
-----
<?php

namespace Rector\Tests\CodingStyle\Rector\Namespace_\ImportFullyQualifiedNamesRector\Fixture;

use Rector\Tests\CodingStyle\Rector\Namespace_\ImportFullyQualifiedNamesRector\Source\SharedShortName;
class SkipSameNamespacedUsedClass
{
/**
* @return SharedShortName
*/
public function run(): SharedShortName
{
}
}

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public function getNodeTypes(): array
public function refactor(Node $node): ?Node
{
$fullyQualifiedName = $this->resolveFullyQualifiedName($node);

if (! $this->reflectionProvider->hasClass($fullyQualifiedName)) {
return null;
}
Expand All @@ -91,6 +92,9 @@ public function refactor(Node $node): ?Node
return null;
}

dump($fullyQualifiedName);
die;

$realClassName = $classReflection->getName();
if (strtolower($realClassName) !== strtolower($fullyQualifiedName)) {
// skip class alias
Expand Down
65 changes: 0 additions & 65 deletions rules/Php53/Rector/AssignRef/ClearReturnNewByReferenceRector.php

This file was deleted.

0 comments on commit 051c751

Please sign in to comment.