Skip to content
Open
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
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"require": {
"php": ">=5.3.3",
"psr/log": "~1.0",
"nikic/php-parser": "^1.0",
"nikic/php-parser": "^3.0",
"phpdocumentor/reflection-docblock": "~2.0"
},
"suggests": {
Expand All @@ -25,7 +25,8 @@
},
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
"dev-master": "1.0.x-dev",
"dev-wp": "v3.0.2-dmsnell"
}
}
}
2 changes: 1 addition & 1 deletion src/phpDocumentor/Reflection/BaseReflector.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public function getShortName()
{
return isset($this->node->name)
? $this->node->name
: (string) $this->node;
: '(anonymous)';
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ public function getDefault()
*/
public function getType()
{
if ( $this->node->type instanceof \PhpParser\Node\NullableType ) {
return "?{$this->node->type->type}";
}

$type = (string) $this->node->type;

// in case of the callable of array keyword; do not prefix with a \
Expand Down
16 changes: 16 additions & 0 deletions src/phpDocumentor/Reflection/IncludeReflector.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,22 @@ public function getType()

public function getShortName()
{
if ( ! isset( $this->node->expr->value ) ) {
$name = [];
foreach ( $this->node->expr->getSubNodeNames() as $part ) {
$thing = $this->node->expr->{$part};

$name[] = ( is_object( $thing ) && method_exists( $thing, 'getName' ) )
? $thing->getName()
: ( ( is_array( $thing )
? array_key_exists( 'value', $thing )
: property_exists( $thing, 'value' )
)
? $thing->value
: '(unknown)' );
}
$name = implode( ' . ', $name );
}
return (string) $this->node->expr->value;
}
}
3 changes: 1 addition & 2 deletions src/phpDocumentor/Reflection/PrettyPrinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
namespace phpDocumentor\Reflection;

use PhpParser\Node\Scalar\String_;
use PhpParser\PrettyPrinter\Standard;

/**
* Custom PrettyPrinter for phpDocumentor.
Expand All @@ -28,7 +27,7 @@
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
class PrettyPrinter extends Standard
class PrettyPrinter extends \PhpParser\PrettyPrinter\Standard
{
/**
* Converts the string into it's original representation without converting
Expand Down
5 changes: 3 additions & 2 deletions src/phpDocumentor/Reflection/Traverser.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use PhpParser\Error;
use PhpParser\NodeVisitor\NameResolver;
use PhpParser\Parser;
use PhpParser\ParserFactory;
use PhpParser\NodeTraverser;
use PhpParser\NodeVisitor;
use PhpParser\NodeVisitorAbstract;
Expand Down Expand Up @@ -78,7 +79,7 @@ public function addVisitor(\PhpParser\NodeVisitor $visitor)
*/
protected function createParser()
{
return new Parser(new Lexer());
return (new ParserFactory)->create(ParserFactory::PREFER_PHP7);
}

/**
Expand All @@ -88,7 +89,7 @@ protected function createParser()
*/
protected function createTraverser()
{
$node_traverser = new NodeTraverser();
$node_traverser = new NodeTraverser(true);
$node_traverser->addVisitor(new NameResolver());

foreach ($this->visitors as $visitor) {
Expand Down