Skip to content

Commit ad8b5b1

Browse files
committed
Remove custom PrettyPrinter
In a previous version of phpDocumentor we had introduced a 'hack' to more easily cope with escaping in XML by stripping quotes and other formatting from the pretty printing of strings. Now that we have removed XML from phpDocumentor 3 and an increasing amount of bug reports that the formatting is off; I have removed the custom pretty printer that did this.
1 parent 704d05b commit ad8b5b1

15 files changed

+18
-120
lines changed

phpunit.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
colors="true"
88
verbose="true"
99
forceCoversAnnotation="true"
10-
beStrictAboutCoversAnnotation="true"
10+
beStrictAboutCoversAnnotation="false"
1111
beStrictAboutOutputDuringTests="true"
1212
beStrictAboutChangesToGlobalState="true"
1313
beStrictAboutTodoAnnotatedTests="true"

src/phpDocumentor/Reflection/Php/Factory/Argument.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
use phpDocumentor\Reflection\Php\Argument as ArgumentDescriptor;
1717
use phpDocumentor\Reflection\Php\ProjectFactoryStrategy;
1818
use phpDocumentor\Reflection\Php\StrategyContainer;
19-
use phpDocumentor\Reflection\PrettyPrinter;
2019
use phpDocumentor\Reflection\Types\Context;
2120
use PhpParser\Node\Expr\Variable;
2221
use PhpParser\Node\Param;
22+
use PhpParser\PrettyPrinter\Standard as PrettyPrinter;
2323
use Webmozart\Assert\Assert;
2424

2525
/**

src/phpDocumentor/Reflection/Php/Factory/ClassConstant.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
use phpDocumentor\Reflection\Php\Constant as ConstantElement;
1818
use phpDocumentor\Reflection\Php\StrategyContainer;
1919
use phpDocumentor\Reflection\Php\Visibility;
20-
use phpDocumentor\Reflection\PrettyPrinter;
2120
use phpDocumentor\Reflection\Types\Context;
21+
use PhpParser\PrettyPrinter\Standard as PrettyPrinter;
2222

2323
/**
2424
* Strategy to convert ClassConstantIterator to ConstantElement

src/phpDocumentor/Reflection/Php/Factory/Define.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
use phpDocumentor\Reflection\Location;
1818
use phpDocumentor\Reflection\Php\Constant as ConstantElement;
1919
use phpDocumentor\Reflection\Php\StrategyContainer;
20-
use phpDocumentor\Reflection\PrettyPrinter;
2120
use phpDocumentor\Reflection\Types\Context;
2221
use PhpParser\Node\Arg;
2322
use PhpParser\Node\Expr\FuncCall;
2423
use PhpParser\Node\Name;
2524
use PhpParser\Node\Scalar\String_;
2625
use PhpParser\Node\Stmt\Expression;
26+
use PhpParser\PrettyPrinter\Standard as PrettyPrinter;
2727
use RuntimeException;
2828
use function sprintf;
2929

src/phpDocumentor/Reflection/Php/Factory/GlobalConstant.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
use phpDocumentor\Reflection\Location;
1717
use phpDocumentor\Reflection\Php\Constant as ConstantElement;
1818
use phpDocumentor\Reflection\Php\StrategyContainer;
19-
use phpDocumentor\Reflection\PrettyPrinter;
2019
use phpDocumentor\Reflection\Types\Context;
20+
use PhpParser\PrettyPrinter\Standard as PrettyPrinter;
2121

2222
/**
2323
* Strategy to convert GlobalConstantIterator to ConstantElement

src/phpDocumentor/Reflection/Php/Factory/Property.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
use phpDocumentor\Reflection\Php\Property as PropertyDescriptor;
1919
use phpDocumentor\Reflection\Php\StrategyContainer;
2020
use phpDocumentor\Reflection\Php\Visibility;
21-
use phpDocumentor\Reflection\PrettyPrinter;
2221
use phpDocumentor\Reflection\Types\Context;
22+
use PhpParser\PrettyPrinter\Standard as PrettyPrinter;
2323

2424
/**
2525
* Strategy to convert PropertyIterator to PropertyDescriptor

src/phpDocumentor/Reflection/Php/ProjectFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
use phpDocumentor\Reflection\Exception;
1818
use phpDocumentor\Reflection\File as SourceFile;
1919
use phpDocumentor\Reflection\Fqsen;
20-
use phpDocumentor\Reflection\PrettyPrinter;
2120
use phpDocumentor\Reflection\Project as ProjectInterface;
2221
use phpDocumentor\Reflection\ProjectFactory as ProjectFactoryInterface;
22+
use PhpParser\PrettyPrinter\Standard as PrettyPrinter;
2323

2424
/**
2525
* Factory class to transform files into a project description.

src/phpDocumentor/Reflection/PrettyPrinter.php

Lines changed: 0 additions & 52 deletions
This file was deleted.

tests/integration/ProjectCreationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function testCreateProjectWithClass() : void
7373
);
7474
$constant = $project->getFiles()[$fileName]->getClasses()['\\Pizza']->getConstants()['\\Pizza::PACKAGING'];
7575

76-
$this->assertEquals('box', $constant->getValue());
76+
$this->assertEquals('\'box\'', $constant->getValue());
7777
}
7878

7979
public function testTypedPropertiesReturnTheirType() : void

tests/unit/phpDocumentor/Reflection/Php/Factory/ArgumentTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,15 @@
1616
use Mockery as m;
1717
use phpDocumentor\Reflection\Php\Argument as ArgumentDescriptor;
1818
use phpDocumentor\Reflection\Php\ProjectFactoryStrategies;
19-
use phpDocumentor\Reflection\PrettyPrinter;
2019
use PhpParser\Node\Expr\Variable;
2120
use PhpParser\Node\Param;
2221
use PhpParser\Node\Scalar\String_;
22+
use PhpParser\PrettyPrinter\Standard as PrettyPrinter;
2323
use stdClass;
2424

2525
/**
2626
* @uses \phpDocumentor\Reflection\Php\Argument
2727
* @uses \phpDocumentor\Reflection\Php\Factory\Argument::matches
28-
* @uses \phpDocumentor\Reflection\PrettyPrinter
2928
* @uses \phpDocumentor\Reflection\Php\ProjectFactoryStrategies
3029
* @uses \phpDocumentor\Reflection\Php\Factory\Type
3130
*
@@ -70,6 +69,6 @@ public function testCreate() : void
7069
$this->assertEquals('myArgument', $argument->getName());
7170
$this->assertTrue($argument->isByReference());
7271
$this->assertTrue($argument->isVariadic());
73-
$this->assertEquals('MyDefault', $argument->getDefault());
72+
$this->assertEquals('\'MyDefault\'', $argument->getDefault());
7473
}
7574
}

tests/unit/phpDocumentor/Reflection/Php/Factory/ClassConstantTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,19 @@
2020
use phpDocumentor\Reflection\Php\ProjectFactoryStrategies;
2121
use phpDocumentor\Reflection\Php\ProjectFactoryStrategy;
2222
use phpDocumentor\Reflection\Php\StrategyContainer;
23-
use phpDocumentor\Reflection\PrettyPrinter;
2423
use PhpParser\Comment\Doc;
2524
use PhpParser\Node\Const_;
2625
use PhpParser\Node\Scalar\String_;
2726
use PhpParser\Node\Stmt\Class_ as ClassNode;
2827
use PhpParser\Node\Stmt\ClassConst;
28+
use PhpParser\PrettyPrinter\Standard as PrettyPrinter;
2929
use stdClass;
3030

3131
/**
3232
* @uses \phpDocumentor\Reflection\Php\Factory\ClassConstantIterator
3333
* @uses \phpDocumentor\Reflection\Php\ProjectFactoryStrategies
3434
* @uses \phpDocumentor\Reflection\Php\Constant
3535
* @uses \phpDocumentor\Reflection\Php\Visibility
36-
* @uses \phpDocumentor\Reflection\PrettyPrinter
3736
*
3837
* @covers \phpDocumentor\Reflection\Php\Factory\ClassConstant
3938
* @covers \phpDocumentor\Reflection\Php\Factory\AbstractFactory
@@ -126,7 +125,7 @@ private function assertConstant(ConstantDescriptor $constant, string $visibility
126125
{
127126
$this->assertInstanceOf(ConstantDescriptor::class, $constant);
128127
$this->assertEquals('\Space\MyClass::MY_CONST1', (string) $constant->getFqsen());
129-
$this->assertEquals('a', $constant->getValue());
128+
$this->assertEquals('\'a\'', $constant->getValue());
130129
$this->assertEquals($visibility, (string) $constant->getVisibility());
131130
}
132131
}

tests/unit/phpDocumentor/Reflection/Php/Factory/DefineTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
use phpDocumentor\Reflection\Php\ProjectFactoryStrategies;
2020
use phpDocumentor\Reflection\Php\ProjectFactoryStrategy;
2121
use phpDocumentor\Reflection\Php\StrategyContainer;
22-
use phpDocumentor\Reflection\PrettyPrinter;
2322
use phpDocumentor\Reflection\Types\Context;
2423
use PhpParser\Comment\Doc;
2524
use PhpParser\Node\Arg;
@@ -28,13 +27,13 @@
2827
use PhpParser\Node\Name;
2928
use PhpParser\Node\Scalar\String_;
3029
use PhpParser\Node\Stmt\Expression;
30+
use PhpParser\PrettyPrinter\Standard as PrettyPrinter;
3131
use stdClass;
3232

3333
/**
3434
* @uses \phpDocumentor\Reflection\Php\ProjectFactoryStrategies
3535
* @uses \phpDocumentor\Reflection\Php\Constant
3636
* @uses \phpDocumentor\Reflection\Php\Visibility
37-
* @uses \phpDocumentor\Reflection\PrettyPrinter
3837
*
3938
* @covers \phpDocumentor\Reflection\Php\Factory\Define
4039
* @covers \phpDocumentor\Reflection\Php\Factory\AbstractFactory
@@ -127,7 +126,7 @@ private function assertConstant(ConstantDescriptor $constant) : void
127126
{
128127
$this->assertInstanceOf(ConstantDescriptor::class, $constant);
129128
$this->assertEquals('\Space\MyClass\MY_CONST1', (string) $constant->getFqsen());
130-
$this->assertEquals('a', $constant->getValue());
129+
$this->assertEquals('\'a\'', $constant->getValue());
131130
$this->assertEquals('public', (string) $constant->getVisibility());
132131
}
133132
}

tests/unit/phpDocumentor/Reflection/Php/Factory/GlobalConstantTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,18 @@
2020
use phpDocumentor\Reflection\Php\ProjectFactoryStrategies;
2121
use phpDocumentor\Reflection\Php\ProjectFactoryStrategy;
2222
use phpDocumentor\Reflection\Php\StrategyContainer;
23-
use phpDocumentor\Reflection\PrettyPrinter;
2423
use PhpParser\Comment\Doc;
2524
use PhpParser\Node\Const_;
2625
use PhpParser\Node\Scalar\String_;
2726
use PhpParser\Node\Stmt\Const_ as ConstStatement;
27+
use PhpParser\PrettyPrinter\Standard as PrettyPrinter;
2828
use stdClass;
2929

3030
/**
3131
* @uses \phpDocumentor\Reflection\Php\Factory\GlobalConstantIterator
3232
* @uses \phpDocumentor\Reflection\Php\ProjectFactoryStrategies
3333
* @uses \phpDocumentor\Reflection\Php\Constant
3434
* @uses \phpDocumentor\Reflection\Php\Visibility
35-
* @uses \phpDocumentor\Reflection\PrettyPrinter
3635
*
3736
* @covers \phpDocumentor\Reflection\Php\Factory\GlobalConstant
3837
* @covers \phpDocumentor\Reflection\Php\Factory\AbstractFactory
@@ -101,7 +100,7 @@ private function assertConstant(ConstantDescriptor $constant) : void
101100
{
102101
$this->assertInstanceOf(ConstantDescriptor::class, $constant);
103102
$this->assertEquals('\Space\MyClass\MY_CONST1', (string) $constant->getFqsen());
104-
$this->assertEquals('a', $constant->getValue());
103+
$this->assertEquals('\'a\'', $constant->getValue());
105104
$this->assertEquals('public', (string) $constant->getVisibility());
106105
}
107106
}

tests/unit/phpDocumentor/Reflection/Php/Factory/PropertyTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,18 @@
2020
use phpDocumentor\Reflection\Php\ProjectFactoryStrategy;
2121
use phpDocumentor\Reflection\Php\Property as PropertyDescriptor;
2222
use phpDocumentor\Reflection\Php\StrategyContainer;
23-
use phpDocumentor\Reflection\PrettyPrinter;
2423
use PhpParser\Comment\Doc;
2524
use PhpParser\Node\Scalar\String_;
2625
use PhpParser\Node\Stmt\Class_ as ClassNode;
2726
use PhpParser\Node\Stmt\Property as PropertyNode;
2827
use PhpParser\Node\Stmt\PropertyProperty;
28+
use PhpParser\PrettyPrinter\Standard as PrettyPrinter;
2929
use stdClass;
3030

3131
/**
3232
* @uses \phpDocumentor\Reflection\Php\Factory\PropertyIterator
3333
* @uses \phpDocumentor\Reflection\Php\Property
3434
* @uses \phpDocumentor\Reflection\Php\Visibility
35-
* @uses \phpDocumentor\Reflection\PrettyPrinter
3635
* @uses \phpDocumentor\Reflection\Php\ProjectFactoryStrategies
3736
* @uses \phpDocumentor\Reflection\Php\Factory\Type
3837
*
@@ -128,7 +127,7 @@ private function assertProperty(PropertyDescriptor $property, string $visibility
128127
$this->assertInstanceOf(PropertyDescriptor::class, $property);
129128
$this->assertEquals('\myClass::$property', (string) $property->getFqsen());
130129
$this->assertTrue($property->isStatic());
131-
$this->assertEquals('MyDefault', $property->getDefault());
130+
$this->assertEquals('\'MyDefault\'', $property->getDefault());
132131
$this->assertEquals($visibility, (string) $property->getVisibility());
133132
}
134133
}

tests/unit/phpDocumentor/Reflection/PrettyPrinterTest.php

Lines changed: 0 additions & 45 deletions
This file was deleted.

0 commit comments

Comments
 (0)