Download the PHP package lipemat/phpstan-wordpress without Composer
On this page you can find all versions of the php package lipemat/phpstan-wordpress. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download lipemat/phpstan-wordpress
More information about lipemat/phpstan-wordpress
Files in lipemat/phpstan-wordpress
Package phpstan-wordpress
Short Description Phpstan extension for working with WordPress
License MIT
Informations about the package phpstan-wordpress
PHPStan for WordPress
Usage
Install via composer
Included Stubs
- The semi-official phpstan-wordpress stubs.
- Custom stubs
wp.php
some additional stubs for WordPress
Optional Stubs
- WP-CLI stubs.
- WP-CLI Tools Stubs.
- CMB2 stubs
- Genesis stubs
- VIP stubs some stubs for WP VIP environments.
These may be selectively added to your phpstan.neon
or phpstan.neon.dist
like so:
When using library as a global install
When using library as composer dependency
Alternatively, you may replace %rootDir%/../../
with the relative path to your vendor
directory.
Example wp-content/plugins/core/vendor/lipemat/phpstan-wordpress/stubs/cmb2/cmb2-3.10.php
Utility Types
\AtLeast<T, U>
Mark a set of array shape keys as required while making the rest optional.
\Exclude<T, K>
Exclude the specified keys from an array shape.
\Partial<T>
Mark either all or specified keys in an array shape as optional.
\Partial<T>
: Mark all keys as optional.\Partial<T, K>
: Mark only the specified keys as optional.
\Pick<T, K>
Pick only the specified keys from an array shape.
\Required<T>
Mark either all or specified keys in an array shape as required.
\Required<T>
: Mark all keys as required.\Required<T, K>
: Mark only the specified keys as required.
\Sarcastic<T>
Mark a type as an unpredictable random value.
This utility is extremely useful in everyday projects.
\Union<T, U, ...X>
Combine two or more array shapes as if you were using array_merge
with the second array overwriting the first.
Optional Included Rules
As we move toward a world where we use composition over inheritance, we need to be more strict about how we write our code. These optional rules do not get us all the way there, but they are a step in the right direction while still being viable for a WordPress project.
Enable in your phpstan.neon
or phpstan.neon.dist
like so:
- Prevent using the
compact
function. - Require all classes to be either abstract or final.
- Require a
declare(strict_types=1)
statement in every non-empty file. - Prevent using default values in class constructors.
- Prevent declaring a method
protected
in a final class in favor ofprivate
. - Prevent using the
switch
statement in favor ofmatch
. - Require any concrete methods in abstract classes to be
private
orfinal
. - Prevent child classes from skipping parent parameter types.
- Prevent calls to methods on unknown classes.
- Prefer returning null over false unless boolean is expected.
- Prohibit using
ArrayAccess
to access class data. - Require
instance of
instead ofisset
for object verification.
Distributed plugins or themes
Some rules assume you are working on a private project which will not be distributed to the community.
If your project will be distributed, you may add the nonDistributed
parameter to the lipemat
parameter.
The nonDistributed
set to false
parameter will disable the following rules:
- Require all classes to be either abstract or final.
- Require a
declare(strict_types=1)
statement in every non-empty file. - Require any concrete methods in abstract classes to be
private
orfinal
.
Prevent any inheritance
Adding the noExtends
parameter to the lipemat
parameter will prevent having or extending any unlisted abstract classes.
You may omit the allowedToBeExtended
parameter to prevent extending any abstract classes.
All versions of phpstan-wordpress with dependencies
php-stubs/wp-cli-stubs Version ^2.6.0
phpstan/extension-installer Version ^1.1.0
phpstan/phpstan Version ^1.10.38
szepeviktor/phpstan-wordpress Version ^1.1.2