diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..a7d94cc --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,15 @@ +{ + "intelephense.diagnostics.undefinedVariables": false, + "intelephense.diagnostics.undefinedTypes": false, + "intelephense.diagnostics.undefinedSymbols": false, + "intelephense.diagnostics.undefinedProperties": false, + "intelephense.diagnostics.undefinedFunctions": false, + "intelephense.diagnostics.undefinedConstants": false, + "intelephense.diagnostics.undefinedClassConstants": false, + "intelephense.diagnostics.typeErrors": false, + "intelephense.diagnostics.embeddedLanguages": false, + "intelephense.diagnostics.duplicateSymbols": false, + "intelephense.diagnostics.deprecated": false, + "intelephense.diagnostics.argumentCount": false, + "intelephense.diagnostics.undefinedMethods": false +} \ No newline at end of file diff --git a/README.md b/README.md index 77925a0..ab4a9b5 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,6 @@ For example: ```xml - + ```` diff --git a/composer.json b/composer.json index 0894d60..7d276db 100644 --- a/composer.json +++ b/composer.json @@ -12,10 +12,17 @@ }, "autoload": { "psr-4": { - "Idearia\\WpTests": "src/" + "Idearia\\WpTests\\": "src/" } }, "require-dev": { - "phpunit/phpunit": "^9.5" + "phpunit/phpunit": "^9.5", + "szepeviktor/phpstan-wordpress": "^1.1", + "phpstan/extension-installer": "^1.1" + }, + "config": { + "allow-plugins": { + "phpstan/extension-installer": true + } } } diff --git a/composer.lock b/composer.lock index 017af96..dd496b4 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": "d04a6a4216eec9684d7a430e94632a78", + "content-hash": "ccbaad56facaee32595a59eb166bedfa", "packages": [], "packages-dev": [ { @@ -303,6 +303,53 @@ }, "time": "2022-02-21T01:04:05+00:00" }, + { + "name": "php-stubs/wordpress-stubs", + "version": "v5.9.3", + "source": { + "type": "git", + "url": "https://github.com/php-stubs/wordpress-stubs.git", + "reference": "18d56875e5078a50b8ea4bc4b20b735ca61edeee" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-stubs/wordpress-stubs/zipball/18d56875e5078a50b8ea4bc4b20b735ca61edeee", + "reference": "18d56875e5078a50b8ea4bc4b20b735ca61edeee", + "shasum": "" + }, + "replace": { + "giacocorsiglia/wordpress-stubs": "*" + }, + "require-dev": { + "nikic/php-parser": "< 4.12.0", + "php": "~7.3 || ~8.0", + "php-stubs/generator": "^0.8.1", + "phpdocumentor/reflection-docblock": "^5.3", + "phpstan/phpstan": "^1.2" + }, + "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/v5.9.3" + }, + "time": "2022-04-06T15:33:59+00:00" + }, { "name": "phpdocumentor/reflection-common", "version": "2.2.0", @@ -530,6 +577,110 @@ }, "time": "2021-12-08T12:19:24+00:00" }, + { + "name": "phpstan/extension-installer", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/phpstan/extension-installer.git", + "reference": "66c7adc9dfa38b6b5838a9fb728b68a7d8348051" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/extension-installer/zipball/66c7adc9dfa38b6b5838a9fb728b68a7d8348051", + "reference": "66c7adc9dfa38b6b5838a9fb728b68a7d8348051", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.1 || ^2.0", + "php": "^7.1 || ^8.0", + "phpstan/phpstan": ">=0.11.6" + }, + "require-dev": { + "composer/composer": "^1.8", + "phing/phing": "^2.16.3", + "php-parallel-lint/php-parallel-lint": "^1.2.0", + "phpstan/phpstan-strict-rules": "^0.11 || ^0.12" + }, + "type": "composer-plugin", + "extra": { + "class": "PHPStan\\ExtensionInstaller\\Plugin" + }, + "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.1.0" + }, + "time": "2020-12-13T13:06:13+00:00" + }, + { + "name": "phpstan/phpstan", + "version": "1.7.10", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan.git", + "reference": "25e069474cf00215b0f64c60a26230908ef3eefa" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/25e069474cf00215b0f64c60a26230908ef3eefa", + "reference": "25e069474cf00215b0f64c60a26230908ef3eefa", + "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", + "support": { + "issues": "https://github.com/phpstan/phpstan/issues", + "source": "https://github.com/phpstan/phpstan/tree/1.7.10" + }, + "funding": [ + { + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://github.com/phpstan", + "type": "github" + }, + { + "url": "https://www.patreon.com/phpstan", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", + "type": "tidelift" + } + ], + "time": "2022-06-03T14:12:23+00:00" + }, { "name": "phpunit/php-code-coverage", "version": "9.2.15", @@ -1915,6 +2066,150 @@ ], "time": "2020-09-28T06:39:44+00:00" }, + { + "name": "symfony/polyfill-php73", + "version": "v1.26.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php73.git", + "reference": "e440d35fa0286f77fb45b79a03fedbeda9307e85" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/e440d35fa0286f77fb45b79a03fedbeda9307e85", + "reference": "e440d35fa0286f77fb45b79a03fedbeda9307e85", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.26-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.26.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-05-24T11:49:31+00:00" + }, + { + "name": "szepeviktor/phpstan-wordpress", + "version": "v1.1.1", + "source": { + "type": "git", + "url": "https://github.com/szepeviktor/phpstan-wordpress.git", + "reference": "99cfea6b4c15af12dec09110b25dbc7521363f78" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/szepeviktor/phpstan-wordpress/zipball/99cfea6b4c15af12dec09110b25dbc7521363f78", + "reference": "99cfea6b4c15af12dec09110b25dbc7521363f78", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0", + "php-stubs/wordpress-stubs": "^4.7 || ^5.0", + "phpstan/phpstan": "^1.6", + "symfony/polyfill-php73": "^1.12.0" + }, + "require-dev": { + "composer/composer": "^2.1.14", + "dealerdirect/phpcodesniffer-composer-installer": "^0.7", + "php-parallel-lint/php-parallel-lint": "^1.1", + "phpstan/phpstan-strict-rules": "^1.2", + "phpunit/phpunit": "^8 || ^9", + "szepeviktor/phpcs-psr-12-neutron-hybrid-ruleset": "^0.6" + }, + "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.1.1" + }, + "funding": [ + { + "url": "https://www.paypal.me/szepeviktor", + "type": "custom" + } + ], + "time": "2022-05-11T18:41:40+00:00" + }, { "name": "theseer/tokenizer", "version": "1.2.1", diff --git a/examples/phpunit.example.xml b/examples/phpunit.example.xml new file mode 100644 index 0000000..788b048 --- /dev/null +++ b/examples/phpunit.example.xml @@ -0,0 +1,12 @@ + + + + + ./tests/ + + + + + + + diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..67529ab --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,5 @@ +# Make sure to use https://github.com/szepeviktor/phpstan-wordpress +parameters: + level: 0 + paths: + - src diff --git a/src/WordPressTestCase.php b/src/WordPressTestCase.php index 1d37dbf..cd14bfc 100644 --- a/src/WordPressTestCase.php +++ b/src/WordPressTestCase.php @@ -22,7 +22,7 @@ class WordPressTestCase extends \PHPUnit\Framework\TestCase public static function setUpBeforeClass(): void { $wordPressPath = $_ENV['wordPressPath'] ?? '../../../../../../'; - static::loadWordPress( $_ENV['wordPressPath'], (int)$_ENV['blogId'] ); + static::loadWordPress( $wordPressPath, (int)$_ENV['blogId'] ); } /**