Skip to content
Closed
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
2 changes: 1 addition & 1 deletion 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": "^5.0",
"phpdocumentor/reflection-docblock": "~2.0"
},
"suggests": {
Expand Down
13 changes: 4 additions & 9 deletions src/phpDocumentor/Reflection/BaseReflector.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ protected function extractDocBlock($node)
$doc_block = new DocBlock(
(string) $comment,
$this->context,
new Location($comment->getLine())
new Location($comment->getStartLine())
);
} catch (Exception $e) {
$this->log($e->getMessage(), LogLevel::CRITICAL);
Expand Down Expand Up @@ -169,7 +169,7 @@ public function getShortName()
{
return isset($this->node->name)
? $this->node->name
: (string) $this->node;
: '';
}

/**
Expand Down Expand Up @@ -202,12 +202,7 @@ public function getNamespace()
return $this->context->getNamespace();
}

$parts = $this->node->namespacedName->parts;
array_pop($parts);

$namespace = implode('\\', $parts);

return $namespace ? $namespace : 'global';
return $this->node->namespacedName ?? 'global';
}

/**
Expand Down Expand Up @@ -256,7 +251,7 @@ public function setNamespaceAlias($alias, $fqnn)
*/
public function getLinenumber()
{
return $this->node->getLine();
return $this->node->getStartLine();
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/phpDocumentor/Reflection/FileReflector.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ function ($comment) {
$docblock = new DocBlock(
(string) $comments[0],
null,
new Location($comments[0]->getLine())
new Location($comments[0]->getStartLine())
);

// the first DocBlock in a file documents the file if
Expand Down Expand Up @@ -489,13 +489,13 @@ public function leaveNode(Node $node)
foreach ($node->uses as $use) {
$this->context->setNamespaceAlias(
$use->alias,
implode('\\', $use->name->parts)
$use->name
);
}
break;
case 'PhpParser\Node\Stmt\Namespace_':
$this->context->setNamespace(
isset($node->name) && ($node->name) ? implode('\\', $node->name->parts) : ''
$node->name ?: ''
);
break;
case 'PhpParser\Node\Stmt\Class_':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ public function getDefault()
*/
public function getType()
{
$type = (string) $this->node->type;
$type = $this->node->type instanceof \PHPParser\Node\NullableType
? "?{$this->node->type->type}"
: (string) $this->node->type;

// in case of the callable of array keyword; do not prefix with a \
if ($type == 'callable' || $type == 'array'
Expand Down
4 changes: 2 additions & 2 deletions src/phpDocumentor/Reflection/PrettyPrinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ class PrettyPrinter extends Standard
*
* @return string
*/
public function pScalar_String(String_ $node)
public function pScalar_String(String_ $node): string
{
if (method_exists($this, 'pSafe')) {
return $this->pSafe($node->getAttribute('originalValue'));
}

return $this->pNoIndent($node->getAttribute('originalValue'));
return $node->getAttribute('originalValue') ?? '(unknown)';
}

}
4 changes: 3 additions & 1 deletion src/phpDocumentor/Reflection/Traverser.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
use PhpParser\Error;
use PhpParser\NodeVisitor\NameResolver;
use PhpParser\Parser;
use PhpParser\ParserFactory;
use PhpParser\PhpVersion;
use PhpParser\NodeTraverser;
use PhpParser\NodeVisitor;
use PhpParser\NodeVisitorAbstract;
Expand Down Expand Up @@ -78,7 +80,7 @@ public function addVisitor(\PhpParser\NodeVisitor $visitor)
*/
protected function createParser()
{
return new Parser(new Lexer());
return (new ParserFactory)->createForVersion( PhpVersion::fromString( '7.4' ) );
}

/**
Expand Down