diff --git a/.gitattributes b/.gitattributes index fc0be87..e3b263e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2,6 +2,7 @@ /.github/ export-ignore /.gitignore export-ignore /examples/ export-ignore +/phpstan.neon.dist export-ignore /phpunit.xml.dist export-ignore /phpunit.xml.legacy export-ignore /tests/ export-ignore diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c169b47..86561cc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -52,3 +52,25 @@ jobs: - run: docker run -d --name mysql --net=host -e MYSQL_RANDOM_ROOT_PASSWORD=yes -e MYSQL_DATABASE=test -e MYSQL_USER=test -e MYSQL_PASSWORD=test mysql:5 - run: bash tests/wait-for-mysql.sh - run: docker run -i --rm --workdir=/data -v "$(pwd):/data" --net=host hhvm/hhvm:3.30-lts-latest hhvm vendor/bin/phpunit + + PHPStan: + name: PHPStan (PHP ${{ matrix.php }}) + runs-on: ubuntu-22.04 + strategy: + matrix: + php: + - 8.2 + - 8.1 + - 8.0 + - 7.4 + - 7.3 + - 7.2 + - 7.1 + steps: + - uses: actions/checkout@v3 + - uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + coverage: none + - run: composer install + - run: vendor/bin/phpstan \ No newline at end of file diff --git a/README.md b/README.md index d81fb86..f8bbd9e 100644 --- a/README.md +++ b/README.md @@ -455,6 +455,12 @@ To run the test suite, go to the project root and run: vendor/bin/phpunit ``` +On top of this, we use PHPStan on max level to ensure type safety across the project: + +```bash +vendor/bin/phpstan +``` + ## License MIT, see [LICENSE file](LICENSE). diff --git a/composer.json b/composer.json index 5b7824c..4517688 100644 --- a/composer.json +++ b/composer.json @@ -13,6 +13,7 @@ "react/socket": "^1.12" }, "require-dev": { + "phpstan/phpstan": "1.10.20 || 1.4.10", "phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36", "react/async": "^4 || ^3 || ^2" }, diff --git a/phpstan.neon.dist b/phpstan.neon.dist new file mode 100644 index 0000000..cba5e96 --- /dev/null +++ b/phpstan.neon.dist @@ -0,0 +1,6 @@ +parameters: + level: max + + paths: + - src/ + - tests/ \ No newline at end of file diff --git a/src/MysqlClient.php b/src/MysqlClient.php index a7d8aa8..2879ac2 100644 --- a/src/MysqlClient.php +++ b/src/MysqlClient.php @@ -8,6 +8,7 @@ use React\Mysql\Io\Factory; use React\Promise\Deferred; use React\Promise\Promise; +use React\Promise\PromiseInterface; use React\Socket\ConnectorInterface; use React\Stream\ReadableStreamInterface;