Skip to content
Merged
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
7 changes: 6 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
"homepage": "https://github.com/php-stubs/wordpress-stubs",
"require-dev": {
"php": "^7.4 || ~8.0.0",
"dealerdirect/phpcodesniffer-composer-installer": "^1.0",
"nikic/php-parser": "^4.13",
"php-stubs/generator": "^0.8.3",
"phpdocumentor/reflection-docblock": "^5.3",
"phpstan/phpstan": "^1.10.12",
"phpunit/phpunit": "^9.5"
"phpunit/phpunit": "^9.5",
"szepeviktor/phpcs-psr-12-neutron-hybrid-ruleset": "^0.8"
},
"suggest": {
"paragonie/sodium_compat": "Pure PHP implementation of libsodium",
Expand All @@ -41,9 +43,12 @@
"post-update-cmd": "@composer --working-dir=source/ update --no-interaction",
"cleanup": "git status --short --ignored | sed -n -e 's#^!! ##p' | xargs -r rm -vrf",
"test": [
"@test:cs",
"@test:phpstan",
"@test:phpunit"
],
"test:cs": "phpcs",
"test:cs:fix": "phpcbf",
"test:phpstan": "phpstan analyze",
"test:phpunit": "phpunit"
},
Expand Down
30 changes: 15 additions & 15 deletions functionMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
}
$cronArgsType = 'list<mixed>';
$wpWidgetRssFormArgsType = 'array{number: int, error: bool, title?: string, url?: string, items?: int, show_summary?: int, show_author?: int, show_date?: int}';
$wpWidgetRssFormInputType = 'array{title?: bool, url?: bool, items?: bool, show_summary?: bool, show_author?: bool, show_date?: bool}';
$wpWidgetRssFormInputsType = 'array{title?: bool, url?: bool, items?: bool, show_summary?: bool, show_author?: bool, show_date?: bool}';
$filesystemDirlistReturnType = "false|array<string, array{name: string, perms: string, permsn: string, owner: string|false, size: int|string|false, lastmodunix: int|string|false, lastmod: string|false, time: string|false, type: 'f'|'d'|'l', group?: string|false, number?: int|string|false, files?: array|false}>";

/**
Expand All @@ -31,47 +31,47 @@
'stripslashes_deep' => ['T', '@phpstan-template' => 'T', 'value' => 'T'],
'urldecode_deep' => ['T', '@phpstan-template' => 'T', 'value' => 'T'],
'urlencode_deep' => ['T', '@phpstan-template' => 'T', 'value' => 'T'],
'wp_clear_scheduled_hook' => ['(0|positive-int|($wp_error is false ? false : \WP_Error))', 'args'=>$cronArgsType],
'wp_get_schedule' => [null, 'args'=>$cronArgsType],
'wp_get_scheduled_event' => [null, 'args'=>$cronArgsType],
'wp_clear_scheduled_hook' => ['(0|positive-int|($wp_error is false ? false : \WP_Error))', 'args' => $cronArgsType],
'wp_get_schedule' => [null, 'args' => $cronArgsType],
'wp_get_scheduled_event' => [null, 'args' => $cronArgsType],
'WP_Http::get' => [$httpReturnType],
'WP_Http::head' => [$httpReturnType],
'WP_Http::post' => [$httpReturnType],
'WP_Http::request' => [$httpReturnType],
'WP_List_Table::display_tablenav' => ['void', 'which' => '"top"|"bottom"'],
'WP_List_Table::pagination' => ['void', 'which' => '"top"|"bottom"'],
'WP_List_Table::set_pagination_args' => ['void', 'args' => 'array{total_items?: int, total_pages?: int, per_page?: int}'],
'wp_next_scheduled' => [null, 'args'=>$cronArgsType],
'wp_next_scheduled' => [null, 'args' => $cronArgsType],
'WP_Query::have_posts' => [null, '@phpstan-impure' => ''],
'wp_remote_get' => [$httpReturnType],
'wp_remote_head' => [$httpReturnType],
'wp_remote_post' => [$httpReturnType],
'wp_remote_request' => [$httpReturnType],
'wp_reschedule_event' => ['($wp_error is false ? bool : true|\WP_Error)', 'args'=>$cronArgsType],
'wp_reschedule_event' => ['($wp_error is false ? bool : true|\WP_Error)', 'args' => $cronArgsType],
'wp_safe_remote_get' => [$httpReturnType],
'wp_safe_remote_head' => [$httpReturnType],
'wp_safe_remote_post' => [$httpReturnType],
'wp_safe_remote_request' => [$httpReturnType],
'wp_schedule_event' => ['($wp_error is false ? bool : true|\WP_Error)', 'args'=>$cronArgsType],
'wp_schedule_single_event' => ['($wp_error is false ? bool : true|\WP_Error)', 'args'=>$cronArgsType],
'wp_schedule_event' => ['($wp_error is false ? bool : true|\WP_Error)', 'args' => $cronArgsType],
'wp_schedule_single_event' => ['($wp_error is false ? bool : true|\WP_Error)', 'args' => $cronArgsType],
'wp_slash' => ['T', '@phpstan-template' => 'T', 'value' => 'T'],
'wp_unschedule_event' => ['($wp_error is false ? bool : true|\WP_Error)', 'args'=>$cronArgsType],
'wp_unschedule_event' => ['($wp_error is false ? bool : true|\WP_Error)', 'args' => $cronArgsType],
'wp_unslash' => ['T', '@phpstan-template' => 'T', 'value' => 'T'],
'wp_widget_rss_form' => ['void', 'args'=>$wpWidgetRssFormArgsType, 'input'=>$wpWidgetRssFormInputType],
'wp_widget_rss_form' => ['void', 'args' => $wpWidgetRssFormArgsType, 'inputs' => $wpWidgetRssFormInputsType],
'WP_REST_Request' => [null, '@phpstan-template' => 'T of array', '@phpstan-implements' => 'ArrayAccess<key-of<T>, value-of<T>>'],
'WP_REST_Request::offsetExists' => [null, 'offset' => '@param key-of<T>'],
'WP_REST_Request::offsetGet' => ['T[TOffset]', '@phpstan-template' => 'TOffset of key-of<T>', 'offset' => 'TOffset'],
'WP_REST_Request::offsetSet' => ['void', '@phpstan-template' => 'TOffset of key-of<T>', 'offset' => 'TOffset', 'value' => 'T[TOffset]'],
'WP_REST_Request::offsetUnset' => ['void', '@phpstan-template' => 'TOffset of key-of<T>', 'offset' => 'TOffset'],
'WP_Theme' => [null, '@phpstan-type'=>"ThemeKey 'Name'|'Version'|'Status'|'Title'|'Author'|'Author Name'|'Author URI'|'Description'|'Template'|'Stylesheet'|'Template Files'|'Stylesheet Files'|'Template Dir'|'Stylesheet Dir'|'Screenshot'|'Tags'|'Theme Root'|'Theme Root URI'|'Parent Theme'"],
'WP_Theme' => [null, '@phpstan-type' => "ThemeKey 'Name'|'Version'|'Status'|'Title'|'Author'|'Author Name'|'Author URI'|'Description'|'Template'|'Stylesheet'|'Template Files'|'Stylesheet Files'|'Template Dir'|'Stylesheet Dir'|'Screenshot'|'Tags'|'Theme Root'|'Theme Root URI'|'Parent Theme'"],
'WP_Theme::get' => ["(\$header is 'Name'|'ThemeURI'|'Description'|'Author'|'AuthorURI'|'Version'|'Template'|'Status'|'Tags'|'TextDomain'|'DomainPath'|'RequiresWP'|'RequiresPHP'|'UpdateURI' ? (\$header is 'Tags' ? string[] : string) : false)"],
'WP_Theme::offsetExists' => ['($offset is ThemeKey ? true : false)'],
'WP_Theme::offsetGet' => ['($offset is ThemeKey ? mixed : null)'],
'WP_Block_List' => [null, '@phpstan-implements' => 'ArrayAccess<int, WP_Block>'],
'WP_Block_List::offsetExists' => [null, 'index' => 'int'],
'WP_Block_List::offsetGet' => ['WP_Block|null', 'index' => 'int'],
'WP_Block_List::offsetSet' => ['void', 'index' => 'int|null'],
'WP_Block_List::offsetUnset' => ['void', 'index' => 'int'],
'WP_Block_List::offsetExists' => [null, 'offset' => 'int'],
'WP_Block_List::offsetGet' => ['WP_Block|null', 'offset' => 'int'],
'WP_Block_List::offsetSet' => ['void', 'offset' => 'int|null'],
'WP_Block_List::offsetUnset' => ['void', 'offset' => 'int'],
'is_wp_error' => ['($thing is \WP_Error ? true : false)', '@phpstan-assert-if-true' => '\WP_Error $thing'],
'current_time' => ["(\$type is 'timestamp'|'U' ? int : string)"],
'mysql2date' => ["(\$format is 'G'|'U' ? int|false : string|false)"],
Expand Down
12 changes: 12 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0"?>
<ruleset>
<file>finder.php</file>
<file>functionMap.php</file>
<file>visitor.php</file>

<rule ref="PSR12NeutronRuleset">
<exclude name="Generic.Files.LineLength"/>
<exclude name="PEAR.Commenting.ClassComment"/>
<exclude name="PEAR.Commenting.FileComment"/>
</rule>
</ruleset>
1 change: 1 addition & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ parameters:
level: 8
paths:
- finder.php
- functionMap.php
- visitor.php
- tests/
excludePaths:
Expand Down
Loading