Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions BACKERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ Check out all the tiers - higher ones include additional goodies like placing th
- Kerrial Newham
- Jan Mikeš
- Jan Kuchař
- Martin Čermák
- Jakob Oberhummer
- Tomáš Pilař
- Stefan Melbinger
- Attila Fulop

## $1+

- Arnaud TIERANT
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@
use PhpParser\BuilderFactory;
use PhpParser\Node;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\Nop;
use PhpParser\Node\Stmt\Property;
use Rector\BetterPhpDocParser\Tests\PhpDocInfo\PhpDocInfoPrinter\Source\AnotherPropertyClass;
use Rector\BetterPhpDocParser\Tests\PhpDocInfo\PhpDocInfoPrinter\Source\Class_\SomeEntityClass;
use Rector\BetterPhpDocParser\Tests\PhpDocInfo\PhpDocInfoPrinter\Source\DoctrinePropertyClass;
use Rector\BetterPhpDocParser\Tests\PhpDocInfo\PhpDocInfoPrinter\Source\ManyToPropertyClass;
use Rector\BetterPhpDocParser\Tests\PhpDocInfo\PhpDocInfoPrinter\Source\RoutePropertyClass;
use Rector\BetterPhpDocParser\Tests\PhpDocInfo\PhpDocInfoPrinter\Source\SinglePropertyClass;
use Rector\BetterPhpDocParser\Tests\PhpDocInfo\PhpDocInfoPrinter\Source\TableClass;
use Rector\NodeTypeResolver\Node\AttributeKey;

final class MultilineTest extends AbstractPhpDocInfoPrinterTest
Expand Down Expand Up @@ -43,6 +46,8 @@ public function provideData(): Iterator
public function provideDataClass(): Iterator
{
yield [__DIR__ . '/Source/Class_/some_entity_class.txt', new Class_(SomeEntityClass::class)];

yield [__DIR__ . '/Source/Multiline/table.txt', new Class_(TableClass::class)];
}

public function provideDataForProperty(): Iterator
Expand All @@ -58,6 +63,9 @@ public function provideDataForProperty(): Iterator

$property = $this->createPublicPropertyUnderClass('someProperty', DoctrinePropertyClass::class);
yield [__DIR__ . '/Source/Multiline/multiline6.txt', $property];

$property = $this->createMethodUnderClass('someMethod', RoutePropertyClass::class);
yield [__DIR__ . '/Source/Multiline/route_property.txt', $property];
}

private function createPublicPropertyUnderClass(string $name, string $class): Property
Expand All @@ -72,4 +80,17 @@ private function createPublicPropertyUnderClass(string $name, string $class): Pr

return $property;
}

private function createMethodUnderClass(string $name, string $class): ClassMethod
{
$builderFactory = new BuilderFactory();

$methodBuilder = $builderFactory->method($name);
$methodBuilder->makePublic();

$method = $methodBuilder->getNode();
$method->setAttribute(AttributeKey::CLASS_NAME, $class);

return $method;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@

final class PhpDocInfoPrinterTest extends AbstractPhpDocInfoPrinterTest
{
/**
* @dataProvider provideData()
*/
public function test(string $docFilePath): void
{
$docComment = FileSystem::read($docFilePath);
$phpDocInfo = $this->createPhpDocInfoFromDocCommentAndNode($docComment, new Nop());

$this->assertSame($docComment, $this->phpDocInfoPrinter->printFormatPreserving($phpDocInfo));
}

public function provideData(): Iterator
{
yield [__DIR__ . '/Source/Basic/doc.txt'];
Expand All @@ -21,27 +32,11 @@ public function provideData(): Iterator
yield [__DIR__ . '/Source/Basic/doc9.txt'];
yield [__DIR__ . '/Source/Basic/doc10.txt'];
yield [__DIR__ . '/Source/Basic/doc11.txt'];
yield [__DIR__ . '/Source/Basic/doc12.txt'];
yield [__DIR__ . '/Source/Basic/doc13.txt'];
yield [__DIR__ . '/Source/Basic/doc14.txt'];
yield [__DIR__ . '/Source/Basic/doc15.txt'];
}

/**
* @dataProvider provideData()
*/
public function test(string $docFilePath): void
{
$docComment = FileSystem::read($docFilePath);
$phpDocInfo = $this->createPhpDocInfoFromDocCommentAndNode($docComment, new Nop());

$this->assertSame(
$docComment,
$this->phpDocInfoPrinter->printFormatPreserving($phpDocInfo),
'Caused in ' . $docFilePath
);
}

/**
* @dataProvider provideDataEmpty()
*/
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* @Route(
* "/{arg1}/{arg2}",
* defaults={"arg1"=null, "arg2"=""},
* requirements={"arg1"="\d+", "arg2"=".*"}
* )
*/
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/**
* @ORM\Table("Table_Name")
* @ORM\Entity()
* @ORM\InheritanceType("SINGLE_TABLE")
*/
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php declare(strict_types=1);

namespace Rector\BetterPhpDocParser\Tests\PhpDocInfo\PhpDocInfoPrinter\Source;

use Symfony\Component\Routing\Annotation\Route;

class RoutePropertyClass
{
/**
* @Route(
* "/{arg1}/{arg2}",
* defaults={"arg1"=null, "arg2"=""},
* requirements={"arg1"="\d+", "arg2"=".*"}
* )
*/
public function nothing(): void
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php declare(strict_types=1);

namespace Rector\BetterPhpDocParser\Tests\PhpDocInfo\PhpDocInfoPrinter\Source;

use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\Table("Table_Name")
* @ORM\Entity()
* @ORM\InheritanceType("SINGLE_TABLE")
*/
class TableClass
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ public function importNames(
): bool {
$phpDocNode = $phpDocInfo->getPhpDocNode();

$this->hasPhpDocChanged = false;

$this->phpDocNodeTraverser->traverseWithCallable($phpDocNode, function (PhpDocParserNode $docNode) use (
$phpParserNode,
$shouldImportRootNamespaceClasses
Expand Down