Skip to content

Commit

Permalink
PHPstan support
Browse files Browse the repository at this point in the history
  • Loading branch information
Guido W. Pettinari committed Jun 6, 2022
1 parent 0d84872 commit 081b167
Show file tree
Hide file tree
Showing 7 changed files with 339 additions and 5 deletions.
15 changes: 15 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ For example:

```xml
<php>
<env name="wordPressPath" value="path/to/wordpress/wp-load.php"/>
<env name="wordPressPath" value="/path/to/wordpress/wp-load.php"/>
</php>
````
11 changes: 9 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
297 changes: 296 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions examples/phpunit.example.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd" backupGlobals="false" backupStaticAttributes="false" bootstrap="vendor/autoload.php" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false">
<testsuites>
<testsuite name="Tests">
<directory suffix="Test.php">./tests/</directory>
</testsuite>
</testsuites>
<php>
<env name="wordPressPath" value="../../../../../../"/>
<env name="blogId" value="20"/>
</php>
</phpunit>
5 changes: 5 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Make sure to use https://github.com/szepeviktor/phpstan-wordpress
parameters:
level: 0
paths:
- src
2 changes: 1 addition & 1 deletion src/WordPressTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'] );
}

/**
Expand Down

0 comments on commit 081b167

Please sign in to comment.