diff --git a/.github/workflows/api-php-static-code-check.yml b/.github/workflows/api-php-static-code-check.yml new file mode 100644 index 000000000..cefac1657 --- /dev/null +++ b/.github/workflows/api-php-static-code-check.yml @@ -0,0 +1,51 @@ +name: Static analysis +on: + pull_request +jobs: + static-phpstan-analysis: + runs-on: ubuntu-latest + continue-on-error: true + strategy: + matrix: + php-versions: [ '7.4' ] + nextcloud: [ 'stable21' ] + database: [ 'sqlite' ] + name: "phpstan: Nextcloud ${{ matrix.nextcloud }}" + steps: + - name: Checkout + uses: actions/checkout@master + - name: Set up php + uses: shivammathur/setup-php@master + with: + php-version: 7.4 + extensions: pdo_sqlite,pdo_mysql,pdo_pgsql,gd,zip + coverage: none + + - name: Set up server non MySQL + uses: SMillerDev/nextcloud-actions/setup-nextcloud@main + with: + cron: true + version: ${{ matrix.nextcloud }} + database-type: ${{ matrix.database }} + + - name: Build app + run: make + + - name: Configure server with app + uses: SMillerDev/nextcloud-actions/setup-nextcloud-app@main + with: + app: 'news' + check-code: true + force: true + + - name: Prep code scanning + working-directory: ../server/apps/news + run: make php-test-dependencies + + - name: PHPCS + working-directory: ../server/apps/news + run: pwd && make phpcs #debug pwd + + - name: PHPStan + working-directory: ../server/apps/news + run: make phpstan \ No newline at end of file diff --git a/.github/workflows/api-php-tests.yml b/.github/workflows/api-php-tests.yml index fa4d4a9dd..2a152480b 100644 --- a/.github/workflows/api-php-tests.yml +++ b/.github/workflows/api-php-tests.yml @@ -47,12 +47,6 @@ jobs: - name: Prep PHP tests working-directory: ../server/apps/news run: make php-test-dependencies - - name: PHPCS - working-directory: ../server/apps/news - run: make phpcs - - name: PHPStan - working-directory: ../server/apps/news - run: make phpstan - name: Unittests working-directory: ../server/apps/news run: make unit-test diff --git a/composer.json b/composer.json index 0af736804..8858e3c83 100644 --- a/composer.json +++ b/composer.json @@ -57,6 +57,9 @@ "phpunit/phpunit": "9.5.*", "squizlabs/php_codesniffer": "^3.5.6", "phpstan/phpstan": "^0.12.43", + "phpstan/phpstan-doctrine": "^0.12.22", + "phpstan/phpstan-phpunit": "^0.12.16", + "phpstan/extension-installer": "^1.0", "guzzlehttp/guzzle": "^7.2", "doctrine/dbal": "^3.0", "symfony/console": "^4.4.18", diff --git a/composer.lock b/composer.lock index e47ffbe69..19aa60029 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": "bdc53136c5f4755e561fa4d088ceac0d", + "content-hash": "2e3812e44e38a2c33ac501d96007c786", "packages": [ { "name": "andreskrey/readability.php", @@ -1269,6 +1269,51 @@ }, "time": "2020-12-19T10:15:11+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": "0.12.77", @@ -1329,6 +1374,129 @@ ], "time": "2021-02-17T16:22:19+00:00" }, + { + "name": "phpstan/phpstan-doctrine", + "version": "0.12.32", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan-doctrine.git", + "reference": "815dd47ade8120c6850c5a3805649c96fbadbdca" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan-doctrine/zipball/815dd47ade8120c6850c5a3805649c96fbadbdca", + "reference": "815dd47ade8120c6850c5a3805649c96fbadbdca", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0", + "phpstan/phpstan": "^0.12.56" + }, + "conflict": { + "doctrine/collections": "<1.0", + "doctrine/common": "<2.7", + "doctrine/mongodb-odm": "<1.2", + "doctrine/orm": "<2.5", + "doctrine/persistence": "<1.3" + }, + "require-dev": { + "doctrine/annotations": "^1.11.0", + "doctrine/collections": "^1.6", + "doctrine/common": "^2.7 || ^3.0", + "doctrine/dbal": "^2.11.0", + "doctrine/mongodb-odm": "^1.3 || ^2.1", + "doctrine/orm": "^2.5", + "doctrine/persistence": "^1.1 || ^2.0", + "phing/phing": "^2.16.3", + "php-parallel-lint/php-parallel-lint": "^1.2", + "phpstan/phpstan-phpunit": "^0.12.16", + "phpstan/phpstan-strict-rules": "^0.12.5", + "phpunit/phpunit": "^7.5.20", + "ramsey/uuid-doctrine": "^1.5.0" + }, + "type": "phpstan-extension", + "extra": { + "branch-alias": { + "dev-master": "0.12-dev" + }, + "phpstan": { + "includes": [ + "extension.neon", + "rules.neon" + ] + } + }, + "autoload": { + "psr-4": { + "PHPStan\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Doctrine extensions for PHPStan", + "support": { + "issues": "https://github.com/phpstan/phpstan-doctrine/issues", + "source": "https://github.com/phpstan/phpstan-doctrine/tree/0.12.32" + }, + "time": "2021-02-09T19:07:47+00:00" + }, + { + "name": "phpstan/phpstan-phpunit", + "version": "0.12.17", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan-phpunit.git", + "reference": "432575b41cf2d4f44e460234acaf56119ed97d36" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/432575b41cf2d4f44e460234acaf56119ed97d36", + "reference": "432575b41cf2d4f44e460234acaf56119ed97d36", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0", + "phpstan/phpstan": "^0.12.60" + }, + "conflict": { + "phpunit/phpunit": "<7.0" + }, + "require-dev": { + "phing/phing": "^2.16.3", + "php-parallel-lint/php-parallel-lint": "^1.2", + "phpstan/phpstan-strict-rules": "^0.12.6", + "phpunit/phpunit": "^7.5.20" + }, + "type": "phpstan-extension", + "extra": { + "branch-alias": { + "dev-master": "0.12-dev" + }, + "phpstan": { + "includes": [ + "extension.neon", + "rules.neon" + ] + } + }, + "autoload": { + "psr-4": { + "PHPStan\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPUnit extensions and rules for PHPStan", + "support": { + "issues": "https://github.com/phpstan/phpstan-phpunit/issues", + "source": "https://github.com/phpstan/phpstan-phpunit/tree/0.12.17" + }, + "time": "2020-12-13T12:12:51+00:00" + }, { "name": "phpunit/php-code-coverage", "version": "9.2.5", diff --git a/psalm.xml b/psalm.xml deleted file mode 100644 index 45b8231b3..000000000 --- a/psalm.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/psalm-autoload.php b/tests/psalm-autoload.php deleted file mode 100644 index 3da2d7f55..000000000 --- a/tests/psalm-autoload.php +++ /dev/null @@ -1,13 +0,0 @@ - - * @copyright Sean Molenaar 2021 - */ - -require_once __DIR__ . '/../../../3rdparty/autoload.php'; -require_once __DIR__ . '/../vendor/autoload.php'; diff --git a/tests/psalm-baseline.xml b/tests/psalm-baseline.xml deleted file mode 100644 index b22549184..000000000 --- a/tests/psalm-baseline.xml +++ /dev/null @@ -1,76 +0,0 @@ - - - - - $fs - $fs - $fs - IRootFolder - - - - - TimedJob - - - - - - array - - - - - $event - - - - - $exception - - - - - $exception - - - - - $exception - - - - - findAllFromFolder - findByURL - read - - - - - TimeFactory - - - $this->timeFactory - TimeFactory - - - read - - - - - deleteOverThreshold - findAllAfter - findAllFeed - findAllFolder - findAllInFeedAfter - findAllInFolderAfter - findAllItems - findByGuidHash - findForUserByGuidHash - newest - readAll - - -