diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml new file mode 100644 index 0000000..225a807 --- /dev/null +++ b/.github/workflows/phpstan.yml @@ -0,0 +1,39 @@ +name: Tests PHPStan in environments + +on: [pull_request] + +jobs: + php82-laravel-latest-phpstan-postgres: + runs-on: ubuntu-latest + container: + image: escolalms/php:8.2 + + services: + postgres: + image: postgres:12 + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: test + TZ: Europe/Warsaw + ports: + - 5432:5432 + + steps: + - name: Instantiate package + uses: actions/checkout@v2 + + - name: Setup environment + run: cp env/postgres/* . + + - name: Update composer + run: COMPOSER_ROOT_VERSION=0.9.9 composer update + + - name: Clear config + run: vendor/bin/testbench config:clear + + - name: Publish things + run: vendor/bin/testbench migrate:fresh + + - name: Run tests + run: vendor/bin/phpstan analyse diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2631d56..72b995b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -101,12 +101,12 @@ jobs: - name: Instantiate package uses: actions/checkout@v2 - - name: Update composer - run: composer update - - name: Setup environment run: cp env/postgres/* . + - name: Update composer + run: composer update + - name: Clear config run: vendor/bin/testbench config:clear @@ -147,12 +147,12 @@ jobs: - name: Instantiate package uses: actions/checkout@v2 - - name: Update composer - run: composer update - - name: Setup environment run: cp env/postgres/* . + - name: Update composer + run: composer update + - name: Clear config run: vendor/bin/testbench config:clear diff --git a/composer.json b/composer.json index 2f77089..b89ae9f 100644 --- a/composer.json +++ b/composer.json @@ -28,8 +28,9 @@ "escolalms/topic-type-project": "^0", "escolalms/assign-without-account": "^0", "escolalms/video": "^0", - "orchestra/testbench": "^5.0|^6.0", - "phpunit/phpunit": "^9.0" + "orchestra/testbench": ">=5.0", + "phpunit/phpunit": "^9.0", + "nunomaduro/larastan": "^2.0" }, "suggest": { "escolalms/auth": "^0.1.54", diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..130082e --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,10 @@ +includes: + - ./vendor/nunomaduro/larastan/extension.neon + +parameters: + + paths: + - src/ + + # The level 9 is the highest level + level: 1 diff --git a/src/Core/EmailChannel.php b/src/Core/EmailChannel.php index 18fc969..aa544d9 100644 --- a/src/Core/EmailChannel.php +++ b/src/Core/EmailChannel.php @@ -73,8 +73,11 @@ private static function fixHtml(string $html): string public static function sections(): Collection { return new Collection([ + // @phpstan-ignore-next-line new TemplateSectionSchema('title', TemplateSectionTypeEnum::SECTION_TEXT(), true), + // @phpstan-ignore-next-line new TemplateSectionSchema('content', TemplateSectionTypeEnum::SECTION_MJML(), true), + // @phpstan-ignore-next-line new TemplateSectionSchema('contentHtml', TemplateSectionTypeEnum::SECTION_HTML(), false, true), ]); } diff --git a/src/Services/MjmlService.php b/src/Services/MjmlService.php index 7e23f24..c580324 100644 --- a/src/Services/MjmlService.php +++ b/src/Services/MjmlService.php @@ -20,7 +20,7 @@ public function render(string $mjml): string throw new Exception('Missing MJML API id and/or secret'); } - $renderer = new ApiRenderer($apiId, $apiSecret); + $renderer = new ApiRenderer($apiId); } else { $renderer = new BinaryRenderer(); }