Skip to content

Commit

Permalink
Remove custom PrettyPrinter
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mvriel committed Jan 27, 2020
1 parent 704d05b commit ad8b5b1
Show file tree
Hide file tree
Showing 15 changed files with 18 additions and 120 deletions.
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
colors="true"
verbose="true"
forceCoversAnnotation="true"
beStrictAboutCoversAnnotation="true"
beStrictAboutCoversAnnotation="false"
beStrictAboutOutputDuringTests="true"
beStrictAboutChangesToGlobalState="true"
beStrictAboutTodoAnnotatedTests="true"
Expand Down
2 changes: 1 addition & 1 deletion src/phpDocumentor/Reflection/Php/Factory/Argument.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
use phpDocumentor\Reflection\Php\Argument as ArgumentDescriptor;
use phpDocumentor\Reflection\Php\ProjectFactoryStrategy;
use phpDocumentor\Reflection\Php\StrategyContainer;
use phpDocumentor\Reflection\PrettyPrinter;
use phpDocumentor\Reflection\Types\Context;
use PhpParser\Node\Expr\Variable;
use PhpParser\Node\Param;
use PhpParser\PrettyPrinter\Standard as PrettyPrinter;
use Webmozart\Assert\Assert;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/phpDocumentor/Reflection/Php/Factory/ClassConstant.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
use phpDocumentor\Reflection\Php\Constant as ConstantElement;
use phpDocumentor\Reflection\Php\StrategyContainer;
use phpDocumentor\Reflection\Php\Visibility;
use phpDocumentor\Reflection\PrettyPrinter;
use phpDocumentor\Reflection\Types\Context;
use PhpParser\PrettyPrinter\Standard as PrettyPrinter;

/**
* Strategy to convert ClassConstantIterator to ConstantElement
Expand Down
2 changes: 1 addition & 1 deletion src/phpDocumentor/Reflection/Php/Factory/Define.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
use phpDocumentor\Reflection\Location;
use phpDocumentor\Reflection\Php\Constant as ConstantElement;
use phpDocumentor\Reflection\Php\StrategyContainer;
use phpDocumentor\Reflection\PrettyPrinter;
use phpDocumentor\Reflection\Types\Context;
use PhpParser\Node\Arg;
use PhpParser\Node\Expr\FuncCall;
use PhpParser\Node\Name;
use PhpParser\Node\Scalar\String_;
use PhpParser\Node\Stmt\Expression;
use PhpParser\PrettyPrinter\Standard as PrettyPrinter;
use RuntimeException;
use function sprintf;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
use phpDocumentor\Reflection\Location;
use phpDocumentor\Reflection\Php\Constant as ConstantElement;
use phpDocumentor\Reflection\Php\StrategyContainer;
use phpDocumentor\Reflection\PrettyPrinter;
use phpDocumentor\Reflection\Types\Context;
use PhpParser\PrettyPrinter\Standard as PrettyPrinter;

/**
* Strategy to convert GlobalConstantIterator to ConstantElement
Expand Down
2 changes: 1 addition & 1 deletion src/phpDocumentor/Reflection/Php/Factory/Property.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
use phpDocumentor\Reflection\Php\Property as PropertyDescriptor;
use phpDocumentor\Reflection\Php\StrategyContainer;
use phpDocumentor\Reflection\Php\Visibility;
use phpDocumentor\Reflection\PrettyPrinter;
use phpDocumentor\Reflection\Types\Context;
use PhpParser\PrettyPrinter\Standard as PrettyPrinter;

/**
* Strategy to convert PropertyIterator to PropertyDescriptor
Expand Down
2 changes: 1 addition & 1 deletion src/phpDocumentor/Reflection/Php/ProjectFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
use phpDocumentor\Reflection\Exception;
use phpDocumentor\Reflection\File as SourceFile;
use phpDocumentor\Reflection\Fqsen;
use phpDocumentor\Reflection\PrettyPrinter;
use phpDocumentor\Reflection\Project as ProjectInterface;
use phpDocumentor\Reflection\ProjectFactory as ProjectFactoryInterface;
use PhpParser\PrettyPrinter\Standard as PrettyPrinter;

/**
* Factory class to transform files into a project description.
Expand Down
52 changes: 0 additions & 52 deletions src/phpDocumentor/Reflection/PrettyPrinter.php

This file was deleted.

2 changes: 1 addition & 1 deletion tests/integration/ProjectCreationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function testCreateProjectWithClass() : void
);
$constant = $project->getFiles()[$fileName]->getClasses()['\\Pizza']->getConstants()['\\Pizza::PACKAGING'];

$this->assertEquals('box', $constant->getValue());
$this->assertEquals('\'box\'', $constant->getValue());
}

public function testTypedPropertiesReturnTheirType() : void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,15 @@
use Mockery as m;
use phpDocumentor\Reflection\Php\Argument as ArgumentDescriptor;
use phpDocumentor\Reflection\Php\ProjectFactoryStrategies;
use phpDocumentor\Reflection\PrettyPrinter;
use PhpParser\Node\Expr\Variable;
use PhpParser\Node\Param;
use PhpParser\Node\Scalar\String_;
use PhpParser\PrettyPrinter\Standard as PrettyPrinter;
use stdClass;

/**
* @uses \phpDocumentor\Reflection\Php\Argument
* @uses \phpDocumentor\Reflection\Php\Factory\Argument::matches
* @uses \phpDocumentor\Reflection\PrettyPrinter
* @uses \phpDocumentor\Reflection\Php\ProjectFactoryStrategies
* @uses \phpDocumentor\Reflection\Php\Factory\Type
*
Expand Down Expand Up @@ -70,6 +69,6 @@ public function testCreate() : void
$this->assertEquals('myArgument', $argument->getName());
$this->assertTrue($argument->isByReference());
$this->assertTrue($argument->isVariadic());
$this->assertEquals('MyDefault', $argument->getDefault());
$this->assertEquals('\'MyDefault\'', $argument->getDefault());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,19 @@
use phpDocumentor\Reflection\Php\ProjectFactoryStrategies;
use phpDocumentor\Reflection\Php\ProjectFactoryStrategy;
use phpDocumentor\Reflection\Php\StrategyContainer;
use phpDocumentor\Reflection\PrettyPrinter;
use PhpParser\Comment\Doc;
use PhpParser\Node\Const_;
use PhpParser\Node\Scalar\String_;
use PhpParser\Node\Stmt\Class_ as ClassNode;
use PhpParser\Node\Stmt\ClassConst;
use PhpParser\PrettyPrinter\Standard as PrettyPrinter;
use stdClass;

/**
* @uses \phpDocumentor\Reflection\Php\Factory\ClassConstantIterator
* @uses \phpDocumentor\Reflection\Php\ProjectFactoryStrategies
* @uses \phpDocumentor\Reflection\Php\Constant
* @uses \phpDocumentor\Reflection\Php\Visibility
* @uses \phpDocumentor\Reflection\PrettyPrinter
*
* @covers \phpDocumentor\Reflection\Php\Factory\ClassConstant
* @covers \phpDocumentor\Reflection\Php\Factory\AbstractFactory
Expand Down Expand Up @@ -126,7 +125,7 @@ private function assertConstant(ConstantDescriptor $constant, string $visibility
{
$this->assertInstanceOf(ConstantDescriptor::class, $constant);
$this->assertEquals('\Space\MyClass::MY_CONST1', (string) $constant->getFqsen());
$this->assertEquals('a', $constant->getValue());
$this->assertEquals('\'a\'', $constant->getValue());
$this->assertEquals($visibility, (string) $constant->getVisibility());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
use phpDocumentor\Reflection\Php\ProjectFactoryStrategies;
use phpDocumentor\Reflection\Php\ProjectFactoryStrategy;
use phpDocumentor\Reflection\Php\StrategyContainer;
use phpDocumentor\Reflection\PrettyPrinter;
use phpDocumentor\Reflection\Types\Context;
use PhpParser\Comment\Doc;
use PhpParser\Node\Arg;
Expand All @@ -28,13 +27,13 @@
use PhpParser\Node\Name;
use PhpParser\Node\Scalar\String_;
use PhpParser\Node\Stmt\Expression;
use PhpParser\PrettyPrinter\Standard as PrettyPrinter;
use stdClass;

/**
* @uses \phpDocumentor\Reflection\Php\ProjectFactoryStrategies
* @uses \phpDocumentor\Reflection\Php\Constant
* @uses \phpDocumentor\Reflection\Php\Visibility
* @uses \phpDocumentor\Reflection\PrettyPrinter
*
* @covers \phpDocumentor\Reflection\Php\Factory\Define
* @covers \phpDocumentor\Reflection\Php\Factory\AbstractFactory
Expand Down Expand Up @@ -127,7 +126,7 @@ private function assertConstant(ConstantDescriptor $constant) : void
{
$this->assertInstanceOf(ConstantDescriptor::class, $constant);
$this->assertEquals('\Space\MyClass\MY_CONST1', (string) $constant->getFqsen());
$this->assertEquals('a', $constant->getValue());
$this->assertEquals('\'a\'', $constant->getValue());
$this->assertEquals('public', (string) $constant->getVisibility());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,18 @@
use phpDocumentor\Reflection\Php\ProjectFactoryStrategies;
use phpDocumentor\Reflection\Php\ProjectFactoryStrategy;
use phpDocumentor\Reflection\Php\StrategyContainer;
use phpDocumentor\Reflection\PrettyPrinter;
use PhpParser\Comment\Doc;
use PhpParser\Node\Const_;
use PhpParser\Node\Scalar\String_;
use PhpParser\Node\Stmt\Const_ as ConstStatement;
use PhpParser\PrettyPrinter\Standard as PrettyPrinter;
use stdClass;

/**
* @uses \phpDocumentor\Reflection\Php\Factory\GlobalConstantIterator
* @uses \phpDocumentor\Reflection\Php\ProjectFactoryStrategies
* @uses \phpDocumentor\Reflection\Php\Constant
* @uses \phpDocumentor\Reflection\Php\Visibility
* @uses \phpDocumentor\Reflection\PrettyPrinter
*
* @covers \phpDocumentor\Reflection\Php\Factory\GlobalConstant
* @covers \phpDocumentor\Reflection\Php\Factory\AbstractFactory
Expand Down Expand Up @@ -101,7 +100,7 @@ private function assertConstant(ConstantDescriptor $constant) : void
{
$this->assertInstanceOf(ConstantDescriptor::class, $constant);
$this->assertEquals('\Space\MyClass\MY_CONST1', (string) $constant->getFqsen());
$this->assertEquals('a', $constant->getValue());
$this->assertEquals('\'a\'', $constant->getValue());
$this->assertEquals('public', (string) $constant->getVisibility());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,18 @@
use phpDocumentor\Reflection\Php\ProjectFactoryStrategy;
use phpDocumentor\Reflection\Php\Property as PropertyDescriptor;
use phpDocumentor\Reflection\Php\StrategyContainer;
use phpDocumentor\Reflection\PrettyPrinter;
use PhpParser\Comment\Doc;
use PhpParser\Node\Scalar\String_;
use PhpParser\Node\Stmt\Class_ as ClassNode;
use PhpParser\Node\Stmt\Property as PropertyNode;
use PhpParser\Node\Stmt\PropertyProperty;
use PhpParser\PrettyPrinter\Standard as PrettyPrinter;
use stdClass;

/**
* @uses \phpDocumentor\Reflection\Php\Factory\PropertyIterator
* @uses \phpDocumentor\Reflection\Php\Property
* @uses \phpDocumentor\Reflection\Php\Visibility
* @uses \phpDocumentor\Reflection\PrettyPrinter
* @uses \phpDocumentor\Reflection\Php\ProjectFactoryStrategies
* @uses \phpDocumentor\Reflection\Php\Factory\Type
*
Expand Down Expand Up @@ -128,7 +127,7 @@ private function assertProperty(PropertyDescriptor $property, string $visibility
$this->assertInstanceOf(PropertyDescriptor::class, $property);
$this->assertEquals('\myClass::$property', (string) $property->getFqsen());
$this->assertTrue($property->isStatic());
$this->assertEquals('MyDefault', $property->getDefault());
$this->assertEquals('\'MyDefault\'', $property->getDefault());
$this->assertEquals($visibility, (string) $property->getVisibility());
}
}
45 changes: 0 additions & 45 deletions tests/unit/phpDocumentor/Reflection/PrettyPrinterTest.php

This file was deleted.

0 comments on commit ad8b5b1

Please sign in to comment.