Skip to content

Commit 0a8a4ef

Browse files
committed
Apply coding standards (#119)
1 parent 903d7e4 commit 0a8a4ef

File tree

4 files changed

+98
-118
lines changed

4 files changed

+98
-118
lines changed

composer.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@
1010
"homepage": "https://github.com/php-stubs/wordpress-stubs",
1111
"require-dev": {
1212
"php": "^7.4 || ~8.0.0",
13+
"dealerdirect/phpcodesniffer-composer-installer": "^1.0",
1314
"nikic/php-parser": "^4.13",
1415
"php-stubs/generator": "^0.8.3",
1516
"phpdocumentor/reflection-docblock": "^5.3",
1617
"phpstan/phpstan": "^1.10.12",
17-
"phpunit/phpunit": "^9.5"
18+
"phpunit/phpunit": "^9.5",
19+
"szepeviktor/phpcs-psr-12-neutron-hybrid-ruleset": "^0.8"
1820
},
1921
"suggest": {
2022
"paragonie/sodium_compat": "Pure PHP implementation of libsodium",
@@ -41,9 +43,12 @@
4143
"post-update-cmd": "@composer --working-dir=source/ update --no-interaction",
4244
"cleanup": "git status --short --ignored | sed -n -e 's#^!! ##p' | xargs -r rm -vrf",
4345
"test": [
46+
"@test:cs",
4447
"@test:phpstan",
4548
"@test:phpunit"
4649
],
50+
"test:cs": "phpcs",
51+
"test:cs:fix": "phpcbf",
4752
"test:phpstan": "phpstan analyze",
4853
"test:phpunit": "phpunit"
4954
},

functionMap.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,45 +31,45 @@
3131
'stripslashes_deep' => ['T', '@phpstan-template' => 'T', 'value' => 'T'],
3232
'urldecode_deep' => ['T', '@phpstan-template' => 'T', 'value' => 'T'],
3333
'urlencode_deep' => ['T', '@phpstan-template' => 'T', 'value' => 'T'],
34-
'wp_clear_scheduled_hook' => ['(0|positive-int|($wp_error is false ? false : \WP_Error))', 'args'=>$cronArgsType],
35-
'wp_get_schedule' => [null, 'args'=>$cronArgsType],
36-
'wp_get_scheduled_event' => [null, 'args'=>$cronArgsType],
34+
'wp_clear_scheduled_hook' => ['(0|positive-int|($wp_error is false ? false : \WP_Error))', 'args' => $cronArgsType],
35+
'wp_get_schedule' => [null, 'args' => $cronArgsType],
36+
'wp_get_scheduled_event' => [null, 'args' => $cronArgsType],
3737
'WP_Http::get' => [$httpReturnType],
3838
'WP_Http::head' => [$httpReturnType],
3939
'WP_Http::post' => [$httpReturnType],
4040
'WP_Http::request' => [$httpReturnType],
4141
'WP_List_Table::display_tablenav' => ['void', 'which' => '"top"|"bottom"'],
4242
'WP_List_Table::pagination' => ['void', 'which' => '"top"|"bottom"'],
4343
'WP_List_Table::set_pagination_args' => ['void', 'args' => 'array{total_items?: int, total_pages?: int, per_page?: int}'],
44-
'wp_next_scheduled' => [null, 'args'=>$cronArgsType],
44+
'wp_next_scheduled' => [null, 'args' => $cronArgsType],
4545
'WP_Query::have_posts' => [null, '@phpstan-impure' => ''],
4646
'wp_remote_get' => [$httpReturnType],
4747
'wp_remote_head' => [$httpReturnType],
4848
'wp_remote_post' => [$httpReturnType],
4949
'wp_remote_request' => [$httpReturnType],
50-
'wp_reschedule_event' => ['($wp_error is false ? bool : true|\WP_Error)', 'args'=>$cronArgsType],
50+
'wp_reschedule_event' => ['($wp_error is false ? bool : true|\WP_Error)', 'args' => $cronArgsType],
5151
'wp_safe_remote_get' => [$httpReturnType],
5252
'wp_safe_remote_head' => [$httpReturnType],
5353
'wp_safe_remote_post' => [$httpReturnType],
5454
'wp_safe_remote_request' => [$httpReturnType],
55-
'wp_schedule_event' => ['($wp_error is false ? bool : true|\WP_Error)', 'args'=>$cronArgsType],
56-
'wp_schedule_single_event' => ['($wp_error is false ? bool : true|\WP_Error)', 'args'=>$cronArgsType],
55+
'wp_schedule_event' => ['($wp_error is false ? bool : true|\WP_Error)', 'args' => $cronArgsType],
56+
'wp_schedule_single_event' => ['($wp_error is false ? bool : true|\WP_Error)', 'args' => $cronArgsType],
5757
'wp_slash' => ['T', '@phpstan-template' => 'T', 'value' => 'T'],
58-
'wp_unschedule_event' => ['($wp_error is false ? bool : true|\WP_Error)', 'args'=>$cronArgsType],
58+
'wp_unschedule_event' => ['($wp_error is false ? bool : true|\WP_Error)', 'args' => $cronArgsType],
5959
'wp_unslash' => ['T', '@phpstan-template' => 'T', 'value' => 'T'],
60-
'wp_widget_rss_form' => ['void', 'args' => $wpWidgetRssFormArgsType, 'inputs' => $wpWidgetRssFormInputType],
60+
'wp_widget_rss_form' => ['void', 'args' => $wpWidgetRssFormArgsType, 'inputs' => $wpWidgetRssFormInputsType],
6161
'WP_REST_Request' => [null, '@phpstan-template' => 'T of array', '@phpstan-implements' => 'ArrayAccess<key-of<T>, value-of<T>>'],
6262
'WP_REST_Request::offsetExists' => [null, 'offset' => '@param key-of<T>'],
6363
'WP_REST_Request::offsetGet' => ['T[TOffset]', '@phpstan-template' => 'TOffset of key-of<T>', 'offset' => 'TOffset'],
6464
'WP_REST_Request::offsetSet' => ['void', '@phpstan-template' => 'TOffset of key-of<T>', 'offset' => 'TOffset', 'value' => 'T[TOffset]'],
6565
'WP_REST_Request::offsetUnset' => ['void', '@phpstan-template' => 'TOffset of key-of<T>', 'offset' => 'TOffset'],
66-
'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'"],
66+
'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'"],
6767
'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)"],
6868
'WP_Theme::offsetExists' => ['($offset is ThemeKey ? true : false)'],
6969
'WP_Theme::offsetGet' => ['($offset is ThemeKey ? mixed : null)'],
7070
'WP_Block_List' => [null, '@phpstan-implements' => 'ArrayAccess<int, WP_Block>'],
7171
'WP_Block_List::offsetExists' => [null, 'offset' => 'int'],
72-
'WP_Block_List::offsetGet' => ['WP_Block|null', 'offset'=>'int'],
72+
'WP_Block_List::offsetGet' => ['WP_Block|null', 'offset' => 'int'],
7373
'WP_Block_List::offsetSet' => ['void', 'offset' => 'int|null'],
7474
'WP_Block_List::offsetUnset' => ['void', 'offset' => 'int'],
7575
'is_wp_error' => ['($thing is \WP_Error ? true : false)', '@phpstan-assert-if-true' => '\WP_Error $thing'],

phpcs.xml.dist

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0"?>
2+
<ruleset>
3+
<file>visitor.php</file>
4+
5+
<rule ref="PSR12NeutronRuleset">
6+
<exclude name="Generic.Files.LineLength"/>
7+
<exclude name="PEAR.Commenting.ClassComment"/>
8+
<exclude name="PEAR.Commenting.FileComment"/>
9+
</rule>
10+
</ruleset>

0 commit comments

Comments
 (0)