rename issue 2863 to CommentPreserving

This commit is contained in:
TomasVotruba 2020-07-02 13:47:01 +02:00
parent 574de08dfa
commit 9a75aaa4b9
13 changed files with 113 additions and 178 deletions

View File

@ -1,12 +0,0 @@
<?php
namespace Rector\Core\Tests\Issues\Issue2863\Fixture;
class Fixture2863KeepComment
{
public function foo($foo)
{
//thiscommentshouldnotberemoved
return $foo;
}
}

View File

@ -1,13 +0,0 @@
<?php
namespace Rector\Core\Tests\Issues\Issue2863\Fixture;
class Fixture2863KeepSpace
{
public function bar($bar)
{
// @var string $bar['should_not_be_changed]
return $bar['should_not_be_changed'];
}
}

View File

@ -1,3 +0,0 @@
parameters:
sets:
- "dead-code"

View File

@ -1,47 +0,0 @@
<?php
namespace Rector\Core\Tests\Issues\Issue3222\Fixture;
/**
* This docblock is being deleted when there's an empty docblock after it.
*/
/**
*
*/
final class Fixture3222
{
private $eventDispatcher;
public function __construct(EventDispatcher $eventDispatcher)
{
$this->eventDispatcher = $eventDispatcher;
}
}
?>
-----
<?php
namespace Rector\Core\Tests\Issues\Issue3222\Fixture;
/**
* This docblock is being deleted when there's an empty docblock after it.
*/
/**
*
*/
final class Fixture3222
{
private \Rector\Core\Tests\Issues\Issue3222\Fixture\EventDispatcher $eventDispatcher;
public function __construct(EventDispatcher $eventDispatcher)
{
$this->eventDispatcher = $eventDispatcher;
}
}
?>

View File

@ -1,63 +0,0 @@
<?php
namespace Rector\Core\Tests\Issues\Issue3222\Fixture;
/**
* The empty line after this docblock is being deleted.
*/
/**
* Another dockblock.
*
*
* first_function()
*
*
* second_function()
* third_function()
* fourth_function()
*/
final class Fixture3222WithManyComments
{
private $eventDispatcher;
public function __construct(EventDispatcher $eventDispatcher)
{
$this->eventDispatcher = $eventDispatcher;
}
}
?>
-----
<?php
namespace Rector\Core\Tests\Issues\Issue3222\Fixture;
/**
* The empty line after this docblock is being deleted.
*/
/**
* Another dockblock.
*
*
* first_function()
*
*
* second_function()
* third_function()
* fourth_function()
*/
final class Fixture3222WithManyComments
{
private \Rector\Core\Tests\Issues\Issue3222\Fixture\EventDispatcher $eventDispatcher;
public function __construct(EventDispatcher $eventDispatcher)
{
$this->eventDispatcher = $eventDispatcher;
}
}
?>

View File

@ -1,30 +0,0 @@
<?php
declare(strict_types=1);
namespace Rector\Core\Tests\Issues\Issue3222;
use Iterator;
use Rector\Core\Testing\PHPUnit\AbstractRectorTestCase;
use Symplify\SmartFileSystem\SmartFileInfo;
final class Issue3222Test extends AbstractRectorTestCase
{
/**
* @dataProvider provideData()
*/
public function test(SmartFileInfo $fileInfo): void
{
$this->doTestFileInfo($fileInfo);
}
public function provideData(): Iterator
{
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
}
protected function provideConfig(): string
{
return __DIR__ . '/config3222.yaml';
}
}

View File

@ -1,2 +0,0 @@
services:
Rector\Php74\Rector\Property\TypedPropertyRector: null

View File

@ -2,13 +2,14 @@
declare(strict_types=1);
namespace Rector\Core\Tests\Issues\Issue2863;
namespace Rector\Core\Tests\PhpParser\Printer\CommentPreserving;
use Iterator;
use Rector\Core\Testing\PHPUnit\AbstractRectorTestCase;
use Rector\Php74\Rector\Property\TypedPropertyRector;
use Symplify\SmartFileSystem\SmartFileInfo;
final class Issue2863Test extends AbstractRectorTestCase
final class CommentPreservingTest extends AbstractRectorTestCase
{
/**
* @dataProvider provideData()
@ -23,8 +24,8 @@ final class Issue2863Test extends AbstractRectorTestCase
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
}
protected function provideConfig(): string
protected function getRectorClass(): string
{
return __DIR__ . '/config2863.yaml';
return TypedPropertyRector::class;
}
}

View File

@ -0,0 +1,75 @@
<?php
namespace Rector\Core\Tests\PhpParser\Printer\CommentPreserving\Fixture;
use Rector\Core\Tests\PhpParser\Printer\CommentPreserving\Source\LocalEventDispatcher;
/**
* This docblock is being deleted when there's an empty docblock after it.
*/
/**
*
*/
/**
* Another dockblock.
*
*
* first_function()
*
*
* second_function()
* third_function()
* fourth_function()
*/
final class CommentsForTypedProperty
{
private $eventDispatcher;
public function __construct(LocalEventDispatcher $eventDispatcher)
{
$this->eventDispatcher = $eventDispatcher;
}
}
?>
-----
<?php
namespace Rector\Core\Tests\PhpParser\Printer\CommentPreserving\Fixture;
use Rector\Core\Tests\PhpParser\Printer\CommentPreserving\Source\LocalEventDispatcher;
/**
* This docblock is being deleted when there's an empty docblock after it.
*/
/**
*
*/
/**
* Another dockblock.
*
*
* first_function()
*
*
* second_function()
* third_function()
* fourth_function()
*/
final class CommentsForTypedProperty
{
private \Rector\Core\Tests\PhpParser\Printer\CommentPreserving\Source\LocalEventDispatcher $eventDispatcher;
public function __construct(LocalEventDispatcher $eventDispatcher)
{
$this->eventDispatcher = $eventDispatcher;
}
}
?>

View File

@ -0,0 +1,19 @@
<?php
namespace Rector\Core\Tests\PhpParser\Printer\CommentPreserving\Fixture;
class KeepComment
{
public function foo($foo)
{
//thiscommentshouldnotberemoved
return $foo;
}
public function bar($bar)
{
// @var string $bar['should_not_be_changed]
return $bar['should_not_be_changed'];
}
}

View File

@ -1,8 +1,8 @@
<?php
namespace Rector\Core\Tests\Issues\Issue2863\Fixture;
namespace Rector\Core\Tests\PhpParser\Printer\CommentPreserving\Fixture;
class Fixture2863KeepDoubleComments
class KeepDoubleComments
{
/*****************************************
* should not be removed

View File

@ -1,8 +1,8 @@
<?php
namespace Rector\Core\Tests\Issues\Issue2863\Fixture;
namespace Rector\Core\Tests\PhpParser\Printer\CommentPreserving\Fixture;
class Fixture2863KeepMultilineSingleAsterisk
class KeepMultilineSingleAsterisk
{
public function baz($baz)
{

View File

@ -0,0 +1,10 @@
<?php
declare(strict_types=1);
namespace Rector\Core\Tests\PhpParser\Printer\CommentPreserving\Source;
final class LocalEventDispatcher
{
}