php-stubs / wp-cli-stubs

WP-CLI function and class declaration stubs for static analysis.
https://packagist.org/packages/php-stubs/wp-cli-stubs
MIT License
23 stars 2 forks source link

WP_CLI\Formatter::display_items should use \Iterator, not Iterator #7

Open mundschenk-at opened 3 years ago

mundschenk-at commented 3 years ago

WP_CLI\Formatter::display_items has Iterator (without the \) set as the type of its parameter $items, expanding to WP_CLI\Iterator.

szepeviktor commented 3 years ago

Isn't it imported? https://github.com/wp-cli/wp-cli/blob/1e2aa1155ee20776fe81d22b6e79e6d48aa358b1/php/WP_CLI/Formatter.php#L7

szepeviktor commented 3 years ago

I see! Imported classes are not modified in PHPDoc blocks. FQCN should be used in PHPDoc (and in exceptions) but the WP-CLI project does not seem to be doing that.

szepeviktor commented 3 years ago

Talked about in https://github.com/GiacoCorsiglia/php-stubs-generator/issues/8

szepeviktor commented 3 years ago

@mundschenk-at If you convince @schlessera to always use FQCN ...

mundschenk-at commented 3 years ago

Unlikely. Always using FQCN in doc blocks makes them very unwieldy if you have deeply nested namespaces.

mundschenk-at commented 3 years ago

FQCN should be used in PHPDoc (and in exceptions) but the WP-CLI project does not seem to be doing that.

Not according to https://docs.phpdoc.org/3.0/guide/guides/types.html

szepeviktor commented 3 years ago

This is not a technical rule. It makes PHPDoc blocks easy to understand.