Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:phpDocumentor/phpDocumentor2 int…
Browse files Browse the repository at this point in the history
…o develop
  • Loading branch information
mvriel committed Jun 27, 2014
2 parents 47e0c74 + 3eb14b9 commit f6bba74
Show file tree
Hide file tree
Showing 20 changed files with 402 additions and 142 deletions.
2 changes: 1 addition & 1 deletion src/phpDocumentor/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function __construct($autoloader = null)
{
$this->defineIniSettings();

self::$VERSION = file_get_contents(__DIR__ . '/../../VERSION');
self::$VERSION = trim(file_get_contents(__DIR__ . '/../../VERSION'));

parent::__construct('phpDocumentor', self::$VERSION);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ public function create($data)
'\\' . (strtolower($data->getNamespace()) == 'global' ? '' :$data->getNamespace())
);
$constantDescriptor->setFullyQualifiedStructuralElementName(
$constantDescriptor->getNamespace() . '\\' . $data->getShortName()
(trim($constantDescriptor->getNamespace(), '\\') ? $constantDescriptor->getNamespace() : '')
. '\\' . $data->getShortName()
);

$this->assembleDocBlock($data->getDocBlock(), $constantDescriptor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ protected function createArgumentDescriptor($functionDescriptor, $argument)
{
$params = $functionDescriptor->getTags()->get('param', array());

if (!$this->argumentAssembler->getBuilder()) {
$this->argumentAssembler->setBuilder($this->builder);
}

return $this->argumentAssembler->create($argument, $params);
}

Expand Down
3 changes: 3 additions & 0 deletions src/phpDocumentor/Plugin/Core/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ public function register(Application $app)
$writerCollection['checkstyle']->setTranslator($translator);
$writerCollection['xml']->setTranslator($translator);

Xslt\Extension::$routers = $app['transformer.routing.queue'];
Xslt\Extension::$descriptorBuilder = $app['descriptor.builder'];

$app->register(new \phpDocumentor\Plugin\Graphs\ServiceProvider());
$app->register(new \phpDocumentor\Plugin\Twig\ServiceProvider());
$app->register(new \phpDocumentor\Plugin\Pdf\ServiceProvider());
Expand Down
77 changes: 77 additions & 0 deletions src/phpDocumentor/Plugin/Core/Transformer/Writer/Pathfinder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php

namespace phpDocumentor\Plugin\Core\Transformer\Writer;

class Pathfinder
{
/**
* Combines the query and an object to retrieve a list of nodes that are to be used as node-point in a template.
*
* This method interprets the provided query string and walks through the given object to find the correct
* element. This method will silently fail if an invalid query was provided; in such a case the given object
* is returned.
*
* @param object $object
* @param string $query
*
* @return \Traversable|mixed[]
*/
public function find($object, $query)
{
if ($query) {
$node = $this->walkObjectTree($object, $query);

if (!is_array($node) && (!$node instanceof \Traversable)) {
$node = array($node);
}

return $node;
}

return array($object);
}

/**
* Walks an object graph and/or array using a twig query string.
*
* @param \Traversable|mixed $objectOrArray
* @param string $query A path to walk separated by dots, i.e. `namespace.namespaces`.
*
* @return mixed
*/
private function walkObjectTree($objectOrArray, $query)
{
$node = $objectOrArray;
$objectPath = explode('.', $query);

// walk through the tree
foreach ($objectPath as $pathNode) {
if (is_array($node)) {
if (isset($node[$pathNode])) {
$node = $node[$pathNode];
continue;
}
} elseif (is_object($node)) {
if (isset($node->$pathNode) || (method_exists($node, '__get') && $node->$pathNode)) {
$node = $node->$pathNode;
continue;
} elseif (method_exists($node, $pathNode)) {
$node = $node->$pathNode();
continue;
} elseif (method_exists($node, 'get' . $pathNode)) {
$pathNode = 'get' . $pathNode;
$node = $node->$pathNode();
continue;
} elseif (method_exists($node, 'is' . $pathNode)) {
$pathNode = 'is' . $pathNode;
$node = $node->$pathNode();
continue;
}
}

return null;
}

return $node;
}
}
5 changes: 3 additions & 2 deletions src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,13 @@ protected function buildFile(\DOMElement $parent, FileDescriptor $file, Transfor
}
}

if (count($file->getErrors()) > 0) {
$errors = $file->getAllErrors();
if (count($errors) > 0) {
$parse_errors = new \DOMElement('parse_markers');
$child->appendChild($parse_errors);

/** @var Error $error */
foreach ($file->getAllErrors() as $error) {
foreach ($errors as $error) {
$this->createErrorEntry($error, $parse_errors);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace phpDocumentor\Plugin\Core\Transformer\Writer\Xml;

use phpDocumentor\Descriptor\ArgumentDescriptor;
use phpDocumentor\Descriptor\DescriptorAbstract;

class ArgumentConverter
{
Expand Down Expand Up @@ -39,7 +40,14 @@ public function convert(\DOMElement $parent, ArgumentDescriptor $argument)
->appendChild(new \DOMText($argument->getDefault()));

$types = $argument->getTypes();
$child->appendChild(new \DOMElement('type', implode('|', $types)));

$typeStrings = array();
foreach ($types as $type) {
$typeStrings[] = $type instanceof DescriptorAbstract
? $type->getFullyQualifiedStructuralElementName()
: $type;
}
$child->appendChild(new \DOMElement('type', implode('|', $typeStrings)));

return $child;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function convert(\DOMElement $parent, ConstantDescriptor $constant)
$child = new \DOMElement('constant');
$parent->appendChild($child);

$child->setAttribute('namespace', $fullyQualifiedNamespaceName);
$child->setAttribute('namespace', ltrim($fullyQualifiedNamespaceName, '\\'));
$child->setAttribute('line', $constant->getLine());

$child->appendChild(new \DOMElement('name', $constant->getName()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ protected function addDescription(\DOMElement $node, DescriptorAbstract $element
protected function addTags(\DOMElement $docBlock, $descriptor)
{
foreach ($descriptor->getTags() as $tagGroup) {
if ($tagGroup === null) {
if (! $tagGroup) {
continue;
}

Expand Down

0 comments on commit f6bba74

Please sign in to comment.