Skip to content

Commit 01376ec

Browse files
committed
wip
1 parent 3e71793 commit 01376ec

13 files changed

Lines changed: 2376 additions & 58064 deletions

File tree

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
},
4646
"require": {
4747
"php": ">=8.2",
48-
"phpdocumentor/reflection": "^4.0",
48+
"phpdocumentor/reflection": "^6.4",
4949
"phpdocumentor/reflection-docblock": "^5.6",
5050
"symfony/console": "^5.0 || ^6.0 || ^6.1 || ^6.2",
5151
"symfony/filesystem": "^5.0 || ^6.0 || ^6.1 || ^6.2",
@@ -56,7 +56,7 @@
5656
"dealerdirect/phpcodesniffer-composer-installer": "^1.2",
5757
"phpcompatibility/php-compatibility": "^9.3",
5858
"phpcompatibility/phpcompatibility-wp": "^2.1",
59-
"phpdocumentor/phpdocumentor": "^3.0",
59+
"phpdocumentor/phpdocumentor": "^3.9",
6060
"rector/rector": "^2.3",
6161
"roots/wordpress": "^5.9",
6262
"squizlabs/php_codesniffer": "^3.13",

composer.lock

Lines changed: 2310 additions & 1840 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Documentor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ private function get_statement_doc_comment( Node $statement ) {
199199
public function parse( $file ) {
200200
$parser_factory = new ParserFactory();
201201

202-
$parser = $parser_factory->create( ParserFactory::PREFER_PHP7 );
202+
$parser = $parser_factory->createForNewestSupportedVersion();
203203

204204
$node_finder = new NodeFinder();
205205

src/TagPrinter.php

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ class TagPrinter {
2424
* Print PHP Parser epxression.
2525
*
2626
* @throws \Exception Throws exception when epxression can not be transformed to string.
27-
* @param Expr $expr PHP Parser epxression.
27+
* @param Expr|mixed $expr PHP Parser epxression or string part.
2828
* @return string
2929
*/
30-
public function print( Expr $expr ) {
30+
public function print( $expr ) {
3131
/**
3232
* String.
3333
*
@@ -80,6 +80,30 @@ public function print( Expr $expr ) {
8080
return $expr->value;
8181
}
8282

83+
/**
84+
* Interpolated String (PHP-Parser 5.x).
85+
*
86+
* @link https://github.com/nikic/PHP-Parser/blob/v5.0.0/lib/PhpParser/Node/Scalar/InterpolatedString.php
87+
*/
88+
if ( $expr instanceof \PhpParser\Node\Scalar\InterpolatedString ) {
89+
return implode(
90+
'',
91+
\array_map(
92+
__METHOD__,
93+
$expr->parts
94+
)
95+
);
96+
}
97+
98+
/**
99+
* Interpolated String Part (PHP-Parser 5.x).
100+
*
101+
* @link https://github.com/nikic/PHP-Parser/blob/v5.0.0/lib/PhpParser/Node/InterpolatedStringPart.php
102+
*/
103+
if ( $expr instanceof \PhpParser\Node\InterpolatedStringPart ) {
104+
return $expr->value;
105+
}
106+
83107
/**
84108
* Function Call.
85109
*
@@ -102,8 +126,10 @@ public function print( Expr $expr ) {
102126
* @todo What todo with method call arguments?
103127
* @link https://github.com/nikic/PHP-Parser/blob/v4.10.4/lib/PhpParser/Node/Expr/MethodCall.php
104128
*/
105-
if ( $expr instanceof \PhpParser\Node\Expr\MethodCall ) { // phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedIf
106-
// Currently not supported.
129+
if ( $expr instanceof \PhpParser\Node\Expr\MethodCall ) {
130+
if ( $expr->var instanceof \PhpParser\Node\Expr\Variable ) {
131+
return '{$' . $expr->var->name . '->' . $expr->name . '()}';
132+
}
107133
}
108134

109135
/**

tests/docs/hooks.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliqu
1616

1717
Argument | Type | Description
1818
-------- | ---- | -----------
19-
20-
Deprecated: Non-canonical cast (double) is deprecated, use the (float) cast instead in /Users/remco/Projects/wp-hooks-documentor/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinter/Standard.php on line 226
2119
`$option` | `string` | Name of the option to update.
2220
`$old_value` | `mixed` | The old option value.
2321
`$value` | `mixed` | The new option value.

tests/docs/phpdocumentor-actions.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliqu
1616
+----------+------+-------------+
1717
| Argument | Type | Description |
1818
+==========+======+=============+
19-
|
20-
Deprecated: Non-canonical cast (double) is deprecated, use the (float) cast instead in /Users/remco/Projects/wp-hooks-documentor/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinter/Standard.php on line 226
21-
$option | string | Name of the option to update. |
19+
| $option | string | Name of the option to update. |
2220
| $old_value | mixed | The old option value. |
2321
| $value | mixed | The new option value. |
2422
+----------+------+-------------+

tests/docs/phpdocumentor-filters.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliqu
1616
+----------+------+-------------+
1717
| Argument | Type | Description |
1818
+==========+======+=============+
19-
|
20-
Deprecated: Non-canonical cast (double) is deprecated, use the (float) cast instead in /Users/remco/Projects/wp-hooks-documentor/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinter/Standard.php on line 226
21-
$mce_translation | array | Key/value pairs of strings. |
19+
| $mce_translation | array | Key/value pairs of strings. |
2220
| $mce_locale | string | Locale. |
2321
+----------+------+-------------+
2422

0 commit comments

Comments
 (0)