Jordi Boggiano 5 лет назад
Родитель
Сommit
bd9570d835

+ 52 - 0
.github/workflows/continuous-integration.yml

@@ -0,0 +1,52 @@
+name: "Continuous Integration"
+
+on:
+  - push
+  - pull_request
+
+env:
+  COMPOSER_FLAGS: "--ansi --no-interaction --no-progress --prefer-dist"
+
+jobs:
+  tests:
+    name: "CI"
+
+    runs-on: ubuntu-latest
+
+    strategy:
+      matrix:
+        php-version:
+          - "7.2"
+          - "7.3"
+          - "7.4"
+          - "8.0"
+          # disabled for now as phpspec/prophecy does not allow 8.1
+          # - "8.1"
+
+    steps:
+      - name: "Checkout"
+        uses: "actions/checkout@v2"
+
+      - name: "Install PHP 7+"
+        uses: "shivammathur/setup-php@v2"
+        with:
+          coverage: "none"
+          php-version: "${{ matrix.php-version }}"
+
+      - name: Get composer cache directory
+        id: composercache
+        run: echo "::set-output name=dir::$(composer config cache-files-dir)"
+
+      - name: Cache dependencies
+        uses: actions/cache@v2
+        with:
+          path: ${{ steps.composercache.outputs.dir }}
+          key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
+          restore-keys: ${{ runner.os }}-composer-
+
+      - name: "Install latest dependencies"
+        run: |
+          composer update ${{ env.COMPOSER_FLAGS }}
+
+      - name: "Run tests"
+        run: "composer test"

+ 32 - 0
.github/workflows/lint.yml

@@ -0,0 +1,32 @@
+name: "PHP Lint"
+
+on:
+  push:
+  pull_request:
+
+jobs:
+  tests:
+    name: "Lint"
+
+    runs-on: ubuntu-latest
+
+    strategy:
+      matrix:
+        php-version:
+          - "7.2"
+          - "8.0"
+
+    steps:
+      - name: "Checkout"
+        uses: "actions/checkout@v2"
+
+      - name: "Install PHP"
+        uses: "shivammathur/setup-php@v2"
+        with:
+          coverage: "none"
+          extensions: "intl"
+          ini-values: "memory_limit=-1"
+          php-version: "${{ matrix.php-version }}"
+
+      - name: "Lint PHP files"
+        run: "find src/ -type f -name '*.php' -print0 | xargs -0 -L1 -P4 -- php -l -f"

+ 46 - 0
.github/workflows/phpstan.yml

@@ -0,0 +1,46 @@
+name: "PHPStan"
+
+on:
+  - push
+  - pull_request
+
+env:
+  COMPOSER_FLAGS: "--ansi --no-interaction --no-progress --prefer-dist"
+
+jobs:
+  tests:
+    name: "PHPStan"
+
+    runs-on: ubuntu-latest
+
+    strategy:
+      matrix:
+        php-version:
+          - "8.0"
+
+    steps:
+      - name: "Checkout"
+        uses: "actions/checkout@v2"
+
+      - name: "Install PHP"
+        uses: "shivammathur/setup-php@v2"
+        with:
+          coverage: "none"
+          php-version: "${{ matrix.php-version }}"
+
+      - name: Get composer cache directory
+        id: composercache
+        run: echo "::set-output name=dir::$(composer config cache-files-dir)"
+
+      - name: Cache dependencies
+        uses: actions/cache@v2
+        with:
+          path: ${{ steps.composercache.outputs.dir }}
+          key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
+          restore-keys: ${{ runner.os }}-composer-
+
+      - name: "Install latest dependencies"
+        run: "composer update ${{ env.COMPOSER_FLAGS }}"
+
+      - name: Run PHPStan
+        run: composer phpstan

+ 0 - 36
.travis.yml

@@ -1,36 +0,0 @@
-language: php
-
-cache:
-  directories:
-    - $HOME/.composer/cache
-
-env:
-  global:
-    - COMPOSER_ARGS=
-
-matrix:
-  fast_finish: true
-  include:
-    - php: 7.2
-      dist: bionic
-      env: deps=low
-    - php: 7.2
-      dist: bionic
-    - php: 7.3
-      dist: bionic
-    - php: 7.4
-      dist: bionic
-    - php: nightly
-      dist: bionic
-      env: COMPOSER_ARGS=--ignore-platform-reqs
-
-before_script:
-  - echo "extension = redis.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
-  - echo "extension = mongodb.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
-  - composer self-update --snapshot
-  - if [ "$deps" == "low" ]; then composer update -n --prefer-dist --prefer-lowest --prefer-stable $COMPOSER_ARGS; fi
-  - if [ "$deps" != "low" ]; then composer update -n --prefer-dist $COMPOSER_ARGS; fi
-
-script:
-  - if [ "`phpenv version-name`" != "nightly" ]; then composer lint; fi
-  - composer test

+ 5 - 9
composer.json

@@ -23,13 +23,13 @@
         "graylog2/gelf-php": "^1.4.2",
         "php-amqplib/php-amqplib": "~2.4",
         "php-console/php-console": "^3.1.3",
-        "php-parallel-lint/php-parallel-lint": "^1.0",
         "phpspec/prophecy": "^1.6.1",
         "phpunit/phpunit": "^8.5",
         "predis/predis": "^1.1",
         "rollbar/rollbar": "^1.3",
         "ruflin/elastica": ">=0.90 <3.0",
-        "swiftmailer/swiftmailer": "^5.3|^6.0"
+        "swiftmailer/swiftmailer": "^5.3|^6.0",
+        "phpstan/phpstan": "^0.12.59"
     },
     "suggest": {
         "graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server",
@@ -56,16 +56,12 @@
     },
     "extra": {
         "branch-alias": {
-            "dev-master": "2.x-dev"
+            "dev-main": "2.x-dev"
         }
     },
     "scripts": {
-        "lint": [
-            "parallel-lint . --exclude vendor"
-        ],
-        "test": [
-            "phpunit"
-        ]
+        "test": "vendor/bin/phpunit",
+        "phpstan": "vendor/bin/phpstan analyse"
     },
     "config": {
         "sort-packages": true,

+ 16 - 0
phpstan.neon.dist

@@ -0,0 +1,16 @@
+parameters:
+    level: 3
+
+    paths:
+        - src/
+#        - tests/
+
+
+    ignoreErrors:
+        - '#zend_monitor_|ZEND_MONITOR_#'
+        - '#RollbarNotifier#'
+        - '#Predis\\Client#'
+        - '#^Cannot call method ltrim\(\) on int\|false.$#'
+        - '#^Access to an undefined property Raven_Client::\$context.$#'
+        - '#MongoDB\\(Client|Collection)#'
+        - '#Gelf\\IMessagePublisher#'

+ 1 - 0
src/Monolog/Handler/DynamoDbHandler.php

@@ -75,6 +75,7 @@ class DynamoDbHandler extends AbstractProcessingHandler
         if ($this->version === 3) {
             $formatted = $this->marshaler->marshalItem($filtered);
         } else {
+            /** @phpstan-ignore-next-line */
             $formatted = $this->client->formatAttributes($filtered);
         }
 

+ 1 - 1
src/Monolog/Utils.php

@@ -177,7 +177,7 @@ final class Utils
      * Function converts the input in place in the passed variable so that it
      * can be used as a callback for array_walk_recursive.
      *
-     * @param mixed &$data Input to check and convert if needed
+     * @param mixed $data Input to check and convert if needed, passed by ref
      */
     private static function detectAndCleanUtf8(&$data)
     {

+ 8 - 0
tests/Monolog/Handler/PHPConsoleHandlerTest.php

@@ -36,9 +36,17 @@ class PHPConsoleHandlerTest extends TestCase
 
     protected function setUp(): void
     {
+        // suppress warnings until https://github.com/barbushin/php-console/pull/173 is merged
+        $previous = error_reporting(0);
         if (!class_exists('PhpConsole\Connector')) {
+            error_reporting($previous);
             $this->markTestSkipped('PHP Console library not found. See https://github.com/barbushin/php-console#installation');
         }
+        if (!class_exists('PhpConsole\Handler')) {
+            error_reporting($previous);
+            $this->markTestSkipped('PHP Console library not found. See https://github.com/barbushin/php-console#installation');
+        }
+        error_reporting($previous);
         $this->connector = $this->initConnectorMock();
 
         $this->debugDispatcher = $this->initDebugDispatcherMock($this->connector);