From 9fcd0e48d418f36c94efcb1917062fa9ea7a0fcc Mon Sep 17 00:00:00 2001 From: Tim Wassenburg Date: Thu, 27 Apr 2023 11:49:57 +0200 Subject: [PATCH] add phpstan --- .github/workflows/phpstan.yml | 26 ++++ .gitignore | 12 +- README.md | 10 ++ build/report.junit.xml | 10 -- composer.json | 4 +- composer.lock | 247 ++++++++++++++++++++++++++++++++- phpstan-baseline.neon | 0 phpstan.neon.dist | 9 ++ src/Console/MakeController.php | 4 +- 9 files changed, 307 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/phpstan.yml delete mode 100644 build/report.junit.xml create mode 100644 phpstan-baseline.neon create mode 100644 phpstan.neon.dist diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml new file mode 100644 index 0000000..9d41c0c --- /dev/null +++ b/.github/workflows/phpstan.yml @@ -0,0 +1,26 @@ +name: PHPStan + +on: + push: + paths: + - '**.php' + - 'phpstan.neon.dist' + +jobs: + phpstan: + name: phpstan + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.1' + coverage: none + + - name: Install composer dependencies + uses: ramsey/composer-install@v2 + + - name: Run PHPStan + run: ./vendor/bin/phpstan --error-format=github diff --git a/.gitignore b/.gitignore index 0cc4ade..a7f372d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,11 @@ +.idea +.phpunit.cache +build +composer.lock +coverage +docs +phpunit.xml +phpstan.neon +testbench.yaml vendor -.phpunit.result.cache -.php_cs.cache +node_modules diff --git a/README.md b/README.md index 461bb0d..e05de56 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ Logo [![Latest Version on Packagist](https://img.shields.io/packagist/v/timwassenburg/laravel-service-generator.svg?style=flat-square)](https://packagist.org/packages/timwassenburg/laravel-service-generator) +[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/timwassenburg/laravel-service-generator/run-tests.yml?branch=master&label=tests&style=flat-square)](https://github.com/timwassenburg/laravel-service-generator/actions?query=workflow%3Arun-tests+branch%3Amaster) [![Total Downloads](https://img.shields.io/packagist/dt/timwassenburg/laravel-service-generator.svg?style=flat-square)](https://packagist.org/packages/timwassenburg/laravel-service-generator) [![License](https://img.shields.io/packagist/l/timwassenburg/laravel-service-generator)](https://packagist.org/packages/timwassenburg/laravel-service-generator) @@ -31,6 +32,7 @@ +
  • Testing
  • More generator packages
  • Contributing
  • License
  • @@ -211,6 +213,14 @@ class PostController extends Controller } ``` +## Testing + +Run the tests with: + +```bash +composer test +``` + ## More generator packages Looking for more ways to speed up your workflow? Make sure to check out these packages. diff --git a/build/report.junit.xml b/build/report.junit.xml deleted file mode 100644 index 4b84588..0000000 --- a/build/report.junit.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/composer.json b/composer.json index 6230be9..deadf04 100644 --- a/composer.json +++ b/composer.json @@ -29,6 +29,7 @@ }, "scripts": { "post-autoload-dump": "@php ./vendor/bin/testbench package:discover --ansi", + "analyse": "vendor/bin/phpstan analyse", "test": "vendor/bin/pest", "test-coverage": "vendor/bin/pest --coverage", "format": "vendor/bin/pint" @@ -44,7 +45,8 @@ "require-dev": { "pestphp/pest": "^2.5", "orchestra/testbench": "^8.5", - "laravel/pint": "^1.10" + "laravel/pint": "^1.10", + "nunomaduro/larastan": "^2.0" }, "config": { "allow-plugins": { diff --git a/composer.lock b/composer.lock index 1f1cafc..719804b 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": "423b5bae6b483c767fb3b01557a8c9f1", + "content-hash": "160f7f27c9aa68a476a4fcbc8a7742fd", "packages": [], "packages-dev": [ { @@ -2506,6 +2506,102 @@ ], "time": "2023-04-22T22:12:40+00:00" }, + { + "name": "nunomaduro/larastan", + "version": "v2.6.0", + "source": { + "type": "git", + "url": "https://github.com/nunomaduro/larastan.git", + "reference": "ccac5b25949576807862cf32ba1fce1769c06c42" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nunomaduro/larastan/zipball/ccac5b25949576807862cf32ba1fce1769c06c42", + "reference": "ccac5b25949576807862cf32ba1fce1769c06c42", + "shasum": "" + }, + "require": { + "ext-json": "*", + "illuminate/console": "^9.47.0 || ^10.0.0", + "illuminate/container": "^9.47.0 || ^10.0.0", + "illuminate/contracts": "^9.47.0 || ^10.0.0", + "illuminate/database": "^9.47.0 || ^10.0.0", + "illuminate/http": "^9.47.0 || ^10.0.0", + "illuminate/pipeline": "^9.47.0 || ^10.0.0", + "illuminate/support": "^9.47.0 || ^10.0.0", + "php": "^8.0.2", + "phpmyadmin/sql-parser": "^5.6.0", + "phpstan/phpstan": "~1.10.6" + }, + "require-dev": { + "nikic/php-parser": "^4.15.2", + "orchestra/testbench": "^7.19.0 || ^8.0.0", + "phpunit/phpunit": "^9.5.27" + }, + "suggest": { + "orchestra/testbench": "Using Larastan for analysing a package needs Testbench" + }, + "type": "phpstan-extension", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + }, + "phpstan": { + "includes": [ + "extension.neon" + ] + } + }, + "autoload": { + "psr-4": { + "NunoMaduro\\Larastan\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nuno Maduro", + "email": "enunomaduro@gmail.com" + } + ], + "description": "Larastan - Discover bugs in your code without running it. A phpstan/phpstan wrapper for Laravel", + "keywords": [ + "PHPStan", + "code analyse", + "code analysis", + "larastan", + "laravel", + "package", + "php", + "static analysis" + ], + "support": { + "issues": "https://github.com/nunomaduro/larastan/issues", + "source": "https://github.com/nunomaduro/larastan/tree/v2.6.0" + }, + "funding": [ + { + "url": "https://www.paypal.com/paypalme/enunomaduro", + "type": "custom" + }, + { + "url": "https://github.com/canvural", + "type": "github" + }, + { + "url": "https://github.com/nunomaduro", + "type": "github" + }, + { + "url": "https://www.patreon.com/nunomaduro", + "type": "patreon" + } + ], + "time": "2023-04-20T12:40:01+00:00" + }, { "name": "nunomaduro/termwind", "version": "v1.15.1", @@ -3245,6 +3341,93 @@ }, "time": "2023-03-27T19:02:04+00:00" }, + { + "name": "phpmyadmin/sql-parser", + "version": "5.7.0", + "source": { + "type": "git", + "url": "https://github.com/phpmyadmin/sql-parser.git", + "reference": "0f5895aab2b6002d00b6831b60983523dea30bff" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpmyadmin/sql-parser/zipball/0f5895aab2b6002d00b6831b60983523dea30bff", + "reference": "0f5895aab2b6002d00b6831b60983523dea30bff", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0", + "symfony/polyfill-mbstring": "^1.3", + "symfony/polyfill-php80": "^1.16" + }, + "conflict": { + "phpmyadmin/motranslator": "<3.0" + }, + "require-dev": { + "phpbench/phpbench": "^1.1", + "phpmyadmin/coding-standard": "^3.0", + "phpmyadmin/motranslator": "^4.0 || ^5.0", + "phpstan/extension-installer": "^1.1", + "phpstan/phpstan": "^1.9.12", + "phpstan/phpstan-phpunit": "^1.3.3", + "phpunit/php-code-coverage": "*", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", + "psalm/plugin-phpunit": "^0.16.1", + "vimeo/psalm": "^4.11", + "zumba/json-serializer": "^3.0" + }, + "suggest": { + "ext-mbstring": "For best performance", + "phpmyadmin/motranslator": "Translate messages to your favorite locale" + }, + "bin": [ + "bin/highlight-query", + "bin/lint-query", + "bin/tokenize-query" + ], + "type": "library", + "autoload": { + "psr-4": { + "PhpMyAdmin\\SqlParser\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-2.0-or-later" + ], + "authors": [ + { + "name": "The phpMyAdmin Team", + "email": "developers@phpmyadmin.net", + "homepage": "https://www.phpmyadmin.net/team/" + } + ], + "description": "A validating SQL lexer and parser with a focus on MySQL dialect.", + "homepage": "https://github.com/phpmyadmin/sql-parser", + "keywords": [ + "analysis", + "lexer", + "parser", + "query linter", + "sql", + "sql lexer", + "sql linter", + "sql parser", + "sql syntax highlighter", + "sql tokenizer" + ], + "support": { + "issues": "https://github.com/phpmyadmin/sql-parser/issues", + "source": "https://github.com/phpmyadmin/sql-parser" + }, + "funding": [ + { + "url": "https://www.phpmyadmin.net/donate/", + "type": "other" + } + ], + "time": "2023-01-25T10:43:40+00:00" + }, { "name": "phpoption/phpoption", "version": "1.9.1", @@ -3365,6 +3548,68 @@ }, "time": "2023-04-25T09:01:03+00:00" }, + { + "name": "phpstan/phpstan", + "version": "1.10.14", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan.git", + "reference": "d232901b09e67538e5c86a724be841bea5768a7c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/d232901b09e67538e5c86a724be841bea5768a7c", + "reference": "d232901b09e67538e5c86a724be841bea5768a7c", + "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-04-19T13:47:27+00:00" + }, { "name": "phpunit/php-code-coverage", "version": "10.1.1", diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon new file mode 100644 index 0000000..e69de29 diff --git a/phpstan.neon.dist b/phpstan.neon.dist new file mode 100644 index 0000000..561972e --- /dev/null +++ b/phpstan.neon.dist @@ -0,0 +1,9 @@ +includes: + - phpstan-baseline.neon + +parameters: + level: 4 + paths: + - src + tmpDir: build/phpstan + checkMissingIterableValueType: false diff --git a/src/Console/MakeController.php b/src/Console/MakeController.php index 2007ec0..c1d52d5 100644 --- a/src/Console/MakeController.php +++ b/src/Console/MakeController.php @@ -10,7 +10,7 @@ class MakeController extends ControllerMakeCommand { /** - * @return void + * @return bool|null * * @throws FileNotFoundException */ @@ -21,6 +21,8 @@ public function handle() if ($this->option('service')) { $this->createService(); } + + return false; } /**