|
17 | 17 | use phpDocumentor\Reflection\DocBlock\Description;
|
18 | 18 | use phpDocumentor\Reflection\DocBlock\StandardTagFactory;
|
19 | 19 | use phpDocumentor\Reflection\DocBlock\Tag;
|
| 20 | +use phpDocumentor\Reflection\DocBlock\Tags\Generic; |
20 | 21 | use phpDocumentor\Reflection\DocBlock\Tags\InvalidTag;
|
21 | 22 | use phpDocumentor\Reflection\DocBlock\Tags\Method;
|
22 | 23 | use phpDocumentor\Reflection\DocBlock\Tags\MethodParameter;
|
23 | 24 | use phpDocumentor\Reflection\DocBlock\Tags\Param;
|
24 | 25 | use phpDocumentor\Reflection\DocBlock\Tags\Return_;
|
25 | 26 | use phpDocumentor\Reflection\DocBlock\Tags\See;
|
| 27 | +use phpDocumentor\Reflection\DocBlock\Tags\Since; |
26 | 28 | use phpDocumentor\Reflection\PseudoTypes\ConstExpression;
|
27 | 29 | use phpDocumentor\Reflection\Types\Array_;
|
| 30 | +use phpDocumentor\Reflection\Types\Compound; |
| 31 | +use phpDocumentor\Reflection\Types\Context; |
28 | 32 | use phpDocumentor\Reflection\Types\Integer;
|
29 | 33 | use phpDocumentor\Reflection\Types\Mixed_;
|
| 34 | +use phpDocumentor\Reflection\Types\Object_; |
30 | 35 | use phpDocumentor\Reflection\Types\Self_;
|
31 | 36 | use phpDocumentor\Reflection\Types\String_;
|
32 | 37 | use phpDocumentor\Reflection\Types\Void_;
|
@@ -123,8 +128,8 @@ public function testInterpretingTags(): void
|
123 | 128 | $this->assertInstanceOf(See::class, $seeTags[0]);
|
124 | 129 |
|
125 | 130 | $seeTag = $seeTags[0];
|
126 |
| - $this->assertSame('\\' . StandardTagFactory::class, (string) $seeTag->getReference()); |
127 |
| - $this->assertSame('', (string) $seeTag->getDescription()); |
| 131 | + $this->assertSame('\\' . StandardTagFactory::class, (string)$seeTag->getReference()); |
| 132 | + $this->assertSame('', (string)$seeTag->getDescription()); |
128 | 133 | }
|
129 | 134 |
|
130 | 135 | public function testDescriptionsCanEscapeAtSignsAndClosingBraces(): void
|
@@ -268,4 +273,95 @@ public function testConstantReferenceTypes(): void
|
268 | 273 | $docblock->getTags()
|
269 | 274 | );
|
270 | 275 | }
|
| 276 | + |
| 277 | + public function testRegressionWordpressDocblocks(): void |
| 278 | + { |
| 279 | + $docCommment = <<<DOC |
| 280 | + /** |
| 281 | + * Install a package. |
| 282 | + * |
| 283 | + * Copies the contents of a package from a source directory, and installs them in |
| 284 | + * a destination directory. Optionally removes the source. It can also optionally |
| 285 | + * clear out the destination folder if it already exists. |
| 286 | + * |
| 287 | + * @since 2.8.0 |
| 288 | + * @since 6.2.0 Use move_dir() instead of copy_dir() when possible. |
| 289 | + * |
| 290 | + * @global WP_Filesystem_Base \$wp_filesystem WordPress filesystem subclass. |
| 291 | + * @global array \$wp_theme_directories |
| 292 | + * |
| 293 | + * @param array|string \$args { |
| 294 | + * Optional. Array or string of arguments for installing a package. Default empty array. |
| 295 | + * |
| 296 | + * @type string \$source Required path to the package source. Default empty. |
| 297 | + * @type string \$destination Required path to a folder to install the package in. |
| 298 | + * Default empty. |
| 299 | + * @type bool \$clear_destination Whether to delete any files already in the destination |
| 300 | + * folder. Default false. |
| 301 | + * @type bool \$clear_working Whether to delete the files from the working directory |
| 302 | + * after copying them to the destination. Default false. |
| 303 | + * @type bool \$abort_if_destination_exists Whether to abort the installation if |
| 304 | + * the destination folder already exists. Default true. |
| 305 | + * @type array \$hook_extra Extra arguments to pass to the filter hooks called by |
| 306 | + * WP_Upgrader::install_package(). Default empty array. |
| 307 | + * } |
| 308 | + * |
| 309 | + * @return array|WP_Error The result (also stored in `WP_Upgrader::\$result`), or a WP_Error on failure. |
| 310 | + */ |
| 311 | +DOC; |
| 312 | + |
| 313 | + $factory = DocBlockFactory::createInstance(); |
| 314 | + $docblock = $factory->create($docCommment); |
| 315 | + |
| 316 | + self::assertEquals( |
| 317 | + new DocBlock( |
| 318 | + 'Install a package.', |
| 319 | + new Description( |
| 320 | + 'Copies the contents of a package from a source directory, and installs them in' . PHP_EOL . |
| 321 | + 'a destination directory. Optionally removes the source. It can also optionally' . PHP_EOL . |
| 322 | + 'clear out the destination folder if it already exists.' |
| 323 | + ), |
| 324 | + [ |
| 325 | + new Since('2.8.0', new Description('')), |
| 326 | + new Since('6.2.0', new Description('Use move_dir() instead of copy_dir() when possible.')), |
| 327 | + new Generic( |
| 328 | + 'global', |
| 329 | + new Description('WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.') |
| 330 | + ), |
| 331 | + new Generic( |
| 332 | + 'global', |
| 333 | + new Description('array $wp_theme_directories') |
| 334 | + ), |
| 335 | + new Param( |
| 336 | + 'args', |
| 337 | + new Compound([new Array_(new Mixed_()), new String_()]), |
| 338 | + false, |
| 339 | + new Description( |
| 340 | + '{' . "\n" . |
| 341 | + 'Optional. Array or string of arguments for installing a package. Default empty array.' . "\n" . |
| 342 | + "\n" . |
| 343 | + ' @type string $source Required path to the package source. Default empty.' . "\n" . |
| 344 | + ' @type string $destination Required path to a folder to install the package in.' . "\n" . |
| 345 | + ' Default empty.' . "\n" . |
| 346 | + ' @type bool $clear_destination Whether to delete any files already in the destination' . "\n" . |
| 347 | + ' folder. Default false.' . "\n" . |
| 348 | + ' @type bool $clear_working Whether to delete the files from the working directory' . "\n" . |
| 349 | + ' after copying them to the destination. Default false.' . "\n" . |
| 350 | + ' @type bool $abort_if_destination_exists Whether to abort the installation if' . "\n" . |
| 351 | + ' the destination folder already exists. Default true.' . "\n" . |
| 352 | + ' @type array $hook_extra Extra arguments to pass to the filter hooks called by' . "\n" . |
| 353 | + ' WP_Upgrader::install_package(). Default empty array.' . "\n" . |
| 354 | + '}' |
| 355 | + ) |
| 356 | + ), |
| 357 | + new Return_( |
| 358 | + new Compound([new Array_(new Mixed_()), new Object_(new Fqsen('\WP_Error'))]), |
| 359 | + new Description('The result (also stored in `WP_Upgrader::$result`), or a WP_Error on failure.') |
| 360 | + ), |
| 361 | + ], |
| 362 | + new Context('\\') |
| 363 | + ), |
| 364 | + $docblock |
| 365 | + ); |
| 366 | + } |
271 | 367 | }
|
0 commit comments