diff --git a/.phpcs.xml.dist b/.phpcs.xml.dist
index 01fcd5b5..16d125ff 100644
--- a/.phpcs.xml.dist
+++ b/.phpcs.xml.dist
@@ -7,6 +7,7 @@
/vendor/
/node_modules/
+ /phpstan/
/tests/
diff --git a/composer.json b/composer.json
index fe9ea40b..b2bf0c59 100644
--- a/composer.json
+++ b/composer.json
@@ -14,12 +14,17 @@
"phpunit/phpunit": "^9.5",
"wpengine/wpengine-coding-standards": "dev-develop",
"yoast/phpunit-polyfills": "^1.0",
- "squizlabs/php_codesniffer": "^3.7"
+ "squizlabs/php_codesniffer": "^3.7",
+ "phpstan/phpstan": "^1.10",
+ "phpstan/extension-installer": "^1.3",
+ "szepeviktor/phpstan-wordpress": "^1.3",
+ "axepress/wp-graphql-stubs": "^1.14"
},
"scripts": {
"lint": "parallel-lint -e php --no-colors --exclude vendor .",
"phpcs": "phpcs",
"phpcs:fix": "phpcbf",
+ "phpstan": "phpstan analyze --ansi --memory-limit=1G",
"suite": [
"@lint",
"@phpcs",
@@ -29,7 +34,8 @@
},
"config": {
"allow-plugins": {
- "dealerdirect/phpcodesniffer-composer-installer": true
+ "dealerdirect/phpcodesniffer-composer-installer": true,
+ "phpstan/extension-installer": true
},
"platform": {
"php": "7.4"
diff --git a/composer.lock b/composer.lock
index 8b6e52d6..5cdfc408 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "bd0580e5bd2b21de0d479af4947ffaf3",
+ "content-hash": "2e54fb44a21e8cca155a7243694fad10",
"packages": [
{
"name": "imangazaliev/didom",
@@ -108,6 +108,58 @@
},
"time": "2023-02-19T12:51:24+00:00"
},
+ {
+ "name": "axepress/wp-graphql-stubs",
+ "version": "v1.14.3",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/AxeWP/wp-graphql-stubs.git",
+ "reference": "84399dce808db09a876fd79013db56af5d8da4da"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/AxeWP/wp-graphql-stubs/zipball/84399dce808db09a876fd79013db56af5d8da4da",
+ "reference": "84399dce808db09a876fd79013db56af5d8da4da",
+ "shasum": ""
+ },
+ "require": {
+ "php-stubs/wordpress-stubs": "^5.4 || ^6.0"
+ },
+ "require-dev": {
+ "php": "~7.3 || ~8.0",
+ "php-stubs/generator": "^0.8.0",
+ "phpstan/phpstan": "^1.8"
+ },
+ "suggest": {
+ "szepeviktor/phpstan-wordpress": "WordPress extensions for PHPStan"
+ },
+ "type": "library",
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "description": "WPGraphQL function and class declaration stubs for static analysis.",
+ "homepage": "https://github.com/axewp/wp-graphql-stubs",
+ "keywords": [
+ "PHPStan",
+ "graphql",
+ "static analysis",
+ "wordpress",
+ "wp-graphql",
+ "wpgraphql"
+ ],
+ "support": {
+ "issues": "https://github.com/AxeWP/wp-graphql-stubs/issues",
+ "source": "https://github.com/AxeWP/wp-graphql-stubs/tree/v1.14.3"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/AxeWp",
+ "type": "github"
+ }
+ ],
+ "time": "2023-04-28T12:31:19+00:00"
+ },
{
"name": "brain/monkey",
"version": "2.6.1",
@@ -729,6 +781,50 @@
},
"time": "2022-02-21T12:50:22+00:00"
},
+ {
+ "name": "php-stubs/wordpress-stubs",
+ "version": "v6.2.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/php-stubs/wordpress-stubs.git",
+ "reference": "b73fe99eadf9fb56363619dac0343b6d19907dce"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/php-stubs/wordpress-stubs/zipball/b73fe99eadf9fb56363619dac0343b6d19907dce",
+ "reference": "b73fe99eadf9fb56363619dac0343b6d19907dce",
+ "shasum": ""
+ },
+ "require-dev": {
+ "nikic/php-parser": "< 4.12.0",
+ "php": "~7.3 || ~8.0",
+ "php-stubs/generator": "^0.8.3",
+ "phpdocumentor/reflection-docblock": "^5.3",
+ "phpstan/phpstan": "^1.9"
+ },
+ "suggest": {
+ "paragonie/sodium_compat": "Pure PHP implementation of libsodium",
+ "symfony/polyfill-php73": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions",
+ "szepeviktor/phpstan-wordpress": "WordPress extensions for PHPStan"
+ },
+ "type": "library",
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "description": "WordPress function and class declaration stubs for static analysis.",
+ "homepage": "https://github.com/php-stubs/wordpress-stubs",
+ "keywords": [
+ "PHPStan",
+ "static analysis",
+ "wordpress"
+ ],
+ "support": {
+ "issues": "https://github.com/php-stubs/wordpress-stubs/issues",
+ "source": "https://github.com/php-stubs/wordpress-stubs/tree/v6.2.0"
+ },
+ "time": "2023-03-31T09:48:52+00:00"
+ },
{
"name": "phpcompatibility/php-compatibility",
"version": "9.3.5",
@@ -1040,6 +1136,117 @@
},
"time": "2023-04-17T16:27:27+00:00"
},
+ {
+ "name": "phpstan/extension-installer",
+ "version": "1.3.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/phpstan/extension-installer.git",
+ "reference": "f5e02d40f277d28513001976f444d9ff1dc15e9a"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/phpstan/extension-installer/zipball/f5e02d40f277d28513001976f444d9ff1dc15e9a",
+ "reference": "f5e02d40f277d28513001976f444d9ff1dc15e9a",
+ "shasum": ""
+ },
+ "require": {
+ "composer-plugin-api": "^2.0",
+ "php": "^7.2 || ^8.0",
+ "phpstan/phpstan": "^1.8.0"
+ },
+ "require-dev": {
+ "composer/composer": "^2.0",
+ "php-parallel-lint/php-parallel-lint": "^1.2.0",
+ "phpstan/phpstan-strict-rules": "^0.11 || ^0.12 || ^1.0"
+ },
+ "type": "composer-plugin",
+ "extra": {
+ "class": "PHPStan\\ExtensionInstaller\\Plugin",
+ "phpstan/extension-installer": {
+ "ignore": [
+ "phpstan/phpstan-phpunit"
+ ]
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "PHPStan\\ExtensionInstaller\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "description": "Composer plugin for automatic installation of PHPStan extensions",
+ "support": {
+ "issues": "https://github.com/phpstan/extension-installer/issues",
+ "source": "https://github.com/phpstan/extension-installer/tree/1.3.0"
+ },
+ "time": "2023-04-18T13:08:02+00:00"
+ },
+ {
+ "name": "phpstan/phpstan",
+ "version": "1.10.15",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/phpstan/phpstan.git",
+ "reference": "762c4dac4da6f8756eebb80e528c3a47855da9bd"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/phpstan/phpstan/zipball/762c4dac4da6f8756eebb80e528c3a47855da9bd",
+ "reference": "762c4dac4da6f8756eebb80e528c3a47855da9bd",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.2|^8.0"
+ },
+ "conflict": {
+ "phpstan/phpstan-shim": "*"
+ },
+ "bin": [
+ "phpstan",
+ "phpstan.phar"
+ ],
+ "type": "library",
+ "autoload": {
+ "files": [
+ "bootstrap.php"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "description": "PHPStan - PHP Static Analysis Tool",
+ "keywords": [
+ "dev",
+ "static analysis"
+ ],
+ "support": {
+ "docs": "https://phpstan.org/user-guide/getting-started",
+ "forum": "https://github.com/phpstan/phpstan/discussions",
+ "issues": "https://github.com/phpstan/phpstan/issues",
+ "security": "https://github.com/phpstan/phpstan/security/policy",
+ "source": "https://github.com/phpstan/phpstan-src"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/ondrejmirtes",
+ "type": "github"
+ },
+ {
+ "url": "https://github.com/phpstan",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2023-05-09T15:28:01+00:00"
+ },
{
"name": "phpunit/php-code-coverage",
"version": "9.2.26",
@@ -2482,6 +2689,144 @@
},
"time": "2023-02-22T23:07:41+00:00"
},
+ {
+ "name": "symfony/polyfill-php73",
+ "version": "v1.27.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/polyfill-php73.git",
+ "reference": "9e8ecb5f92152187c4799efd3c96b78ccab18ff9"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/9e8ecb5f92152187c4799efd3c96b78ccab18ff9",
+ "reference": "9e8ecb5f92152187c4799efd3c96b78ccab18ff9",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=7.1"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-main": "1.27-dev"
+ },
+ "thanks": {
+ "name": "symfony/polyfill",
+ "url": "https://github.com/symfony/polyfill"
+ }
+ },
+ "autoload": {
+ "files": [
+ "bootstrap.php"
+ ],
+ "psr-4": {
+ "Symfony\\Polyfill\\Php73\\": ""
+ },
+ "classmap": [
+ "Resources/stubs"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Nicolas Grekas",
+ "email": "p@tchwork.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions",
+ "homepage": "https://symfony.com",
+ "keywords": [
+ "compatibility",
+ "polyfill",
+ "portable",
+ "shim"
+ ],
+ "support": {
+ "source": "https://github.com/symfony/polyfill-php73/tree/v1.27.0"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-11-03T14:55:06+00:00"
+ },
+ {
+ "name": "szepeviktor/phpstan-wordpress",
+ "version": "v1.3.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/szepeviktor/phpstan-wordpress.git",
+ "reference": "5b5cc77ed51fdaf64efe3f00b5aae4b709d2cfa9"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/szepeviktor/phpstan-wordpress/zipball/5b5cc77ed51fdaf64efe3f00b5aae4b709d2cfa9",
+ "reference": "5b5cc77ed51fdaf64efe3f00b5aae4b709d2cfa9",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.2 || ^8.0",
+ "php-stubs/wordpress-stubs": "^4.7 || ^5.0 || ^6.0",
+ "phpstan/phpstan": "^1.10.0",
+ "symfony/polyfill-php73": "^1.12.0"
+ },
+ "require-dev": {
+ "composer/composer": "^2.1.14",
+ "dealerdirect/phpcodesniffer-composer-installer": "^1.0",
+ "php-parallel-lint/php-parallel-lint": "^1.1",
+ "phpstan/phpstan-strict-rules": "^1.2",
+ "phpunit/phpunit": "^8.0 || ^9.0",
+ "szepeviktor/phpcs-psr-12-neutron-hybrid-ruleset": "^0.8"
+ },
+ "type": "phpstan-extension",
+ "extra": {
+ "phpstan": {
+ "includes": [
+ "extension.neon"
+ ]
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "SzepeViktor\\PHPStan\\WordPress\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "description": "WordPress extensions for PHPStan",
+ "keywords": [
+ "PHPStan",
+ "code analyse",
+ "code analysis",
+ "static analysis",
+ "wordpress"
+ ],
+ "support": {
+ "issues": "https://github.com/szepeviktor/phpstan-wordpress/issues",
+ "source": "https://github.com/szepeviktor/phpstan-wordpress/tree/v1.3.0"
+ },
+ "time": "2023-04-23T06:15:06+00:00"
+ },
{
"name": "theseer/tokenizer",
"version": "1.2.1",
diff --git a/package-lock.json b/package-lock.json
index 6527c445..223ab915 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "@wpengine/wp-graphql-content-blocks",
- "version": "0.2.0",
+ "version": "0.2.1",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@wpengine/wp-graphql-content-blocks",
- "version": "0.2.0",
+ "version": "0.2.1",
"devDependencies": {
"@changesets/cli": "^2.26.0",
"@wordpress/e2e-test-utils": "^8.5.0",
diff --git a/phpstan.neon.dist b/phpstan.neon.dist
new file mode 100644
index 00000000..08c56625
--- /dev/null
+++ b/phpstan.neon.dist
@@ -0,0 +1,11 @@
+parameters:
+ level: 0 # Gotta start somewhere
+ inferPrivatePropertyTypeFromConstructor: true
+ checkMissingIterableValueType: false
+ bootstrapFiles:
+ - phpstan/constants.php
+ paths:
+ - wp-graphql-content-blocks.php
+ - includes/
+ scanFiles:
+ - vendor/axepress/wp-graphql-stubs/wp-graphql-stubs.php
diff --git a/phpstan/constants.php b/phpstan/constants.php
new file mode 100644
index 00000000..a625cddc
--- /dev/null
+++ b/phpstan/constants.php
@@ -0,0 +1,12 @@
+