From 5d531fbd2e9a34cc7f7677b0c64ccbb9dad21e57 Mon Sep 17 00:00:00 2001 From: Ash Allen Date: Tue, 21 Sep 2021 19:13:16 +0100 Subject: [PATCH 1/3] Added nunomaduro/larastan. --- .github/workflows/ci-phpstan.yml | 47 ++++++++++++++++++++++++++++++++ composer.json | 3 +- phpstan.neon | 13 +++++++++ src/Models/ShortURL.php | 36 ++++++++++++------------ src/Models/ShortURLVisit.php | 24 ++++++++-------- 5 files changed, 92 insertions(+), 31 deletions(-) create mode 100644 .github/workflows/ci-phpstan.yml create mode 100644 phpstan.neon diff --git a/.github/workflows/ci-phpstan.yml b/.github/workflows/ci-phpstan.yml new file mode 100644 index 0000000..b417c26 --- /dev/null +++ b/.github/workflows/ci-phpstan.yml @@ -0,0 +1,47 @@ +name: run-tests + +on: + pull_request: + +jobs: + run-tests: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php: [ 7.3, 7.4, 8.0 ] + laravel: [ 8.*, 7.*, 6.* ] + include: + - laravel: 8.* + testbench: 6.* + - laravel: 7.* + testbench: 5.* + - laravel: 6.* + testbench: 4.* + + name: PHP${{ matrix.php }} - Laravel ${{ matrix.laravel }} + + steps: + - name: Update apt + run: sudo apt-get update --fix-missing + + - name: Checkout code + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + coverage: none + + - name: Setup Problem Matches + run: | + echo "::add-matcher::${{ runner.tool_cache }}/php.json" + echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" + + - name: Install dependencies + run: | + composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update + composer update --prefer-dist --no-interaction --no-suggest + - name: Execute tests + run: vendor/bin/ diff --git a/composer.json b/composer.json index 58451d5..cf989f3 100755 --- a/composer.json +++ b/composer.json @@ -28,7 +28,8 @@ "require-dev": { "mockery/mockery": "^1.0", "orchestra/testbench": "^4.0|^5.0|^6.0", - "phpunit/phpunit": "^8.2" + "phpunit/phpunit": "^8.2", + "nunomaduro/larastan": "^0.7.12" }, "autoload": { "psr-4": { diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..60205d5 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,13 @@ +includes: + - ./vendor/nunomaduro/larastan/extension.neon + +parameters: + + paths: + - src + + level: 6 + + ignoreErrors: + + checkMissingIterableValueType: false diff --git a/src/Models/ShortURL.php b/src/Models/ShortURL.php index 49f042b..91d98d0 100755 --- a/src/Models/ShortURL.php +++ b/src/Models/ShortURL.php @@ -10,24 +10,24 @@ /** * Class ShortURL. * - * @property int id - * @property string destination_url - * @property string default_short_url - * @property string url_key - * @property bool single_use - * @property bool track_visits - * @property int redirect_status_code - * @property bool track_ip_address - * @property bool track_operating_system - * @property bool track_operating_system_version - * @property bool track_browser - * @property bool track_browser_version - * @property bool track_referer_url - * @property bool track_device_type - * @property Carbon activated_at - * @property Carbon deactivated_at - * @property Carbon created_at - * @property Carbon updated_at + * @property int $id + * @property string $destination_url + * @property string $default_short_url + * @property string $url_key + * @property bool $single_use + * @property bool $track_visits + * @property int $redirect_status_code + * @property bool $track_ip_address + * @property bool $track_operating_system + * @property bool $track_operating_system_version + * @property bool $track_browser + * @property bool $track_browser_version + * @property bool $track_referer_url + * @property bool $track_device_type + * @property Carbon $activated_at + * @property Carbon|null $deactivated_at + * @property Carbon $created_at + * @property Carbon $updated_at */ class ShortURL extends Model { diff --git a/src/Models/ShortURLVisit.php b/src/Models/ShortURLVisit.php index 11c613f..3ac5121 100755 --- a/src/Models/ShortURLVisit.php +++ b/src/Models/ShortURLVisit.php @@ -9,18 +9,18 @@ /** * Class ShortURLVisit. * - * @property int id - * @property int short_url_id - * @property string ip_address - * @property string operating_system - * @property string operating_system_version - * @property string browser - * @property string browser_version - * @property string device_type - * @property Carbon visited_at - * @property Carbon referer_url - * @property Carbon created_at - * @property Carbon updated_at + * @property int $id + * @property int $short_url_id + * @property string $ip_address + * @property string $operating_system + * @property string $operating_system_version + * @property string $browser + * @property string $browser_version + * @property string $device_type + * @property Carbon $visited_at + * @property string $referer_url + * @property Carbon $created_at + * @property Carbon $updated_at */ class ShortURLVisit extends Model { From 12a62ddeec6cc7d106fa7b44c44790eac08c18dc Mon Sep 17 00:00:00 2001 From: Ash Allen Date: Tue, 21 Sep 2021 19:14:33 +0100 Subject: [PATCH 2/3] Updated workflow name. --- .github/workflows/ci-phpstan.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-phpstan.yml b/.github/workflows/ci-phpstan.yml index b417c26..104ad1e 100644 --- a/.github/workflows/ci-phpstan.yml +++ b/.github/workflows/ci-phpstan.yml @@ -1,4 +1,4 @@ -name: run-tests +name: run-phpstan on: pull_request: From 119f8dc57c9900b0c21d83d1fece06a21b9d9e81 Mon Sep 17 00:00:00 2001 From: Ash Allen Date: Tue, 21 Sep 2021 19:16:26 +0100 Subject: [PATCH 3/3] Fixed broken workflow. --- .github/workflows/ci-phpstan.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-phpstan.yml b/.github/workflows/ci-phpstan.yml index 104ad1e..88393a0 100644 --- a/.github/workflows/ci-phpstan.yml +++ b/.github/workflows/ci-phpstan.yml @@ -43,5 +43,5 @@ jobs: run: | composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update composer update --prefer-dist --no-interaction --no-suggest - - name: Execute tests - run: vendor/bin/ + - name: Run Larastan + run: vendor/bin/phpstan analyse