From cd23c77a333c9efe02436806dafb4363ff1f8433 Mon Sep 17 00:00:00 2001 From: Dennis Snell Date: Wed, 11 Feb 2026 21:22:39 -0600 Subject: [PATCH 1/5] Up with NullableTypes and BinaryExpression --- composer.json | 2 +- .../FunctionReflector/ArgumentReflector.php | 4 ++++ .../Reflection/IncludeReflector.php | 16 ++++++++++++++++ src/phpDocumentor/Reflection/PrettyPrinter.php | 3 +-- src/phpDocumentor/Reflection/Traverser.php | 5 +++-- 5 files changed, 25 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index b4445922..5cb3dee4 100644 --- a/composer.json +++ b/composer.json @@ -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": { diff --git a/src/phpDocumentor/Reflection/FunctionReflector/ArgumentReflector.php b/src/phpDocumentor/Reflection/FunctionReflector/ArgumentReflector.php index 8b338711..0f1bfcba 100644 --- a/src/phpDocumentor/Reflection/FunctionReflector/ArgumentReflector.php +++ b/src/phpDocumentor/Reflection/FunctionReflector/ArgumentReflector.php @@ -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 \ diff --git a/src/phpDocumentor/Reflection/IncludeReflector.php b/src/phpDocumentor/Reflection/IncludeReflector.php index 8b2eb5ca..4360366d 100644 --- a/src/phpDocumentor/Reflection/IncludeReflector.php +++ b/src/phpDocumentor/Reflection/IncludeReflector.php @@ -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; } } diff --git a/src/phpDocumentor/Reflection/PrettyPrinter.php b/src/phpDocumentor/Reflection/PrettyPrinter.php index 0d9d0704..a9ff8c13 100644 --- a/src/phpDocumentor/Reflection/PrettyPrinter.php +++ b/src/phpDocumentor/Reflection/PrettyPrinter.php @@ -13,7 +13,6 @@ namespace phpDocumentor\Reflection; use PhpParser\Node\Scalar\String_; -use PhpParser\PrettyPrinter\Standard; /** * Custom PrettyPrinter for phpDocumentor. @@ -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 diff --git a/src/phpDocumentor/Reflection/Traverser.php b/src/phpDocumentor/Reflection/Traverser.php index 31c3890b..abcd8bbe 100644 --- a/src/phpDocumentor/Reflection/Traverser.php +++ b/src/phpDocumentor/Reflection/Traverser.php @@ -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; @@ -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); } /** @@ -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) { From f31fc56ef84897ccb9d6dd84b48cc3235678c7ca Mon Sep 17 00:00:00 2001 From: Dennis Snell Date: Wed, 11 Feb 2026 22:16:28 -0600 Subject: [PATCH 2/5] Print a substitute string for anonymous classes. --- src/phpDocumentor/Reflection/BaseReflector.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/phpDocumentor/Reflection/BaseReflector.php b/src/phpDocumentor/Reflection/BaseReflector.php index 543da1cd..b62d24e0 100644 --- a/src/phpDocumentor/Reflection/BaseReflector.php +++ b/src/phpDocumentor/Reflection/BaseReflector.php @@ -169,7 +169,7 @@ public function getShortName() { return isset($this->node->name) ? $this->node->name - : (string) $this->node; + : '(anonymous)'; } /** From a88facc51f3a02ae982808b07a792103bd114633 Mon Sep 17 00:00:00 2001 From: Dennis Snell Date: Thu, 12 Feb 2026 11:32:07 -0600 Subject: [PATCH 3/5] Rename project with dmsnell repo name and new branch alias --- composer.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 5cb3dee4..71e21acf 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "phpdocumentor/reflection", + "name": "dmsnell/reflection", "description": "Reflection library to do Static Analysis for PHP Projects", "keywords": ["phpdoc", "phpDocumentor", "reflection", "static analysis"], "homepage": "http://www.phpdoc.org", @@ -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" } } } From 7c9a1c104cb342f3ee42e69634ee10290b0a6c86 Mon Sep 17 00:00:00 2001 From: Dennis Snell Date: Thu, 12 Feb 2026 11:36:58 -0600 Subject: [PATCH 4/5] Undo rename --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 71e21acf..c3e34cd3 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "dmsnell/reflection", + "name": "phpdocumentor/reflection", "description": "Reflection library to do Static Analysis for PHP Projects", "keywords": ["phpdoc", "phpDocumentor", "reflection", "static analysis"], "homepage": "http://www.phpdoc.org", From 50f8afbf7ca6f83de8120a2fd4655d88bc04c235 Mon Sep 17 00:00:00 2001 From: Dennis Snell Date: Thu, 12 Feb 2026 16:45:38 -0600 Subject: [PATCH 5/5] cApitalHPdangit --- src/phpDocumentor/Reflection/PrettyPrinter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/phpDocumentor/Reflection/PrettyPrinter.php b/src/phpDocumentor/Reflection/PrettyPrinter.php index a9ff8c13..c99f456f 100644 --- a/src/phpDocumentor/Reflection/PrettyPrinter.php +++ b/src/phpDocumentor/Reflection/PrettyPrinter.php @@ -27,7 +27,7 @@ * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ -class PrettyPrinter extends \PHPParser\PrettyPrinter\Standard +class PrettyPrinter extends \PhpParser\PrettyPrinter\Standard { /** * Converts the string into it's original representation without converting