@@ -20,7 +20,7 @@ Static analysis for the WordPress ecosystem.
20
20
- [ PHPStan] ( https://phpstan.org/ )
21
21
- [ WordPress] ( https://wordpress.org/ )
22
22
23
- ### Installation
23
+ ## Installation
24
24
25
25
Add this package to your project.
26
26
@@ -41,7 +41,7 @@ includes:
41
41
- vendor/szepeviktor/phpstan-wordpress/extension.neon
42
42
```
43
43
44
- ### Configuration
44
+ ## Configuration
45
45
46
46
Needs no extra configuration. :smiley : Simply configure PHPStan - for example - this way.
47
47
@@ -58,19 +58,19 @@ Please read [PHPStan Config Reference](https://phpstan.org/config-reference).
58
58
:bulb : Use Composer autoloader or a
59
59
[ custom autoloader] ( https://github.com/szepeviktor/debian-server-tools/blob/master/webserver/wp-install/wordpress-autoloader.php ) !
60
60
61
- ### Usage
61
+ ## Usage
62
62
63
63
Just start the analysis: ` vendor/bin/phpstan analyze `
64
64
then fix an error and ` GOTO 10 ` !
65
65
66
66
You find further information in the ` examples ` directory
67
67
e.g. [ ` examples/phpstan.neon.dist ` ] ( /examples/phpstan.neon.dist )
68
68
69
- ### Usage in WooCommerce webshops
69
+ ## Usage in WooCommerce webshops
70
70
71
71
Please see [ WooCommerce Stubs] ( https://github.com/php-stubs/woocommerce-stubs )
72
72
73
- ### What this extension does
73
+ ## What this extension does
74
74
75
75
- Makes it possible to run PHPStan on WordPress plugins and themes
76
76
- Loads [ ` php-stubs/wordpress-stubs ` ] ( https://github.com/php-stubs/wordpress-stubs ) package
@@ -79,7 +79,7 @@ Please see [WooCommerce Stubs](https://github.com/php-stubs/woocommerce-stubs)
79
79
- Handles special functions and classes e.g. ` is_wp_error() `
80
80
- Validates the optional docblock that precedes a call to ` apply_filters() ` and treats the type of its first ` @param ` as certain
81
81
82
- ### Usage of an ` apply_filters() ` docblock
82
+ ## Usage of an ` apply_filters() ` docblock
83
83
84
84
WordPress core - and the wider WordPress ecosystem - uses PHPDoc docblocks
85
85
in a non-standard manner to document the parameters passed to ` apply_filters() ` .
@@ -102,7 +102,7 @@ according to the first `@param` tag. In the example above this means PHPStan tre
102
102
To make the best use of this feature,
103
103
ensure that the type of the first ` @param ` tag in each of these such docblocks is accurate and correct.
104
104
105
- ### Make your code testable
105
+ ## Make your code testable
106
106
107
107
- Write clean OOP code: 1 class per file, no other code in class files outside ` class Name { ... } `
108
108
- Structure your code: uniform class names (WPCS or PSR-4), keep classes in a separate directory ` inc/ `
@@ -118,7 +118,7 @@ ensure that the type of the first `@param` tag in each of these such docblocks i
118
118
[ Neutron Standard] ( https://github.com/Automattic/phpcs-neutron-standard )
119
119
- Do not enable ` exit_error ` in ` WP_CLI::launch ` or ` WP_CLI::runcommand ` to keep your code testable
120
120
121
- ### Dirty corner (FAQ)
121
+ ## Dirty corner (FAQ)
122
122
123
123
WordPress uses conditional function and class definition for override purposes.
124
124
Use ` sed ` command to exclude function stubs when they are previously defined.
0 commit comments