Add phpstan
This commit is contained in:
parent
0e3d47f2e1
commit
9396a49412
175
.gitlab-ci.yml
175
.gitlab-ci.yml
|
@ -12,6 +12,7 @@ variables:
|
||||||
DOCROOT: /var/www/
|
DOCROOT: /var/www/
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
|
- prepare
|
||||||
- validate
|
- validate
|
||||||
- build
|
- build
|
||||||
- test
|
- test
|
||||||
|
@ -20,56 +21,90 @@ stages:
|
||||||
- deploy-production
|
- deploy-production
|
||||||
- stop
|
- stop
|
||||||
|
|
||||||
#
|
.use_cache: &use_cache
|
||||||
# Validation
|
cache:
|
||||||
#
|
key: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
|
||||||
|
paths:
|
||||||
|
- .yarn-cache/
|
||||||
|
- vendor/
|
||||||
|
|
||||||
check-php-style:
|
# for jobs that depend on composer
|
||||||
image: composer:latest
|
.use_composer: &use_composer
|
||||||
stage: validate
|
<<: *use_cache
|
||||||
before_script:
|
|
||||||
- composer --no-ansi global config --no-plugins allow-plugins.dealerdirect/phpcodesniffer-composer-installer true
|
|
||||||
- composer --no-ansi global require slevomat/coding-standard squizlabs/php_codesniffer
|
|
||||||
- export PATH=$PATH:$COMPOSER_HOME/vendor/bin
|
|
||||||
script:
|
|
||||||
- phpcs -p --no-colors --basepath="$PWD"
|
|
||||||
|
|
||||||
# does everything that depends on packages installed by yarn
|
|
||||||
check-frontend:
|
|
||||||
image: node:alpine
|
|
||||||
stage: validate
|
|
||||||
needs:
|
needs:
|
||||||
- validate-yarn
|
- composer install
|
||||||
before_script:
|
before_script:
|
||||||
- yarn --frozen-lockfile
|
- composer install --no-ansi --no-progress
|
||||||
script:
|
|
||||||
- yarn check
|
|
||||||
- yarn lint
|
|
||||||
|
|
||||||
check-editorconfig:
|
# for jobs that depend on yarn
|
||||||
image: mstruebing/editorconfig-checker
|
.use_yarn: &use_yarn
|
||||||
stage: validate
|
<<: *use_cache
|
||||||
script:
|
needs:
|
||||||
- ec -v
|
- yarn install
|
||||||
|
before_script:
|
||||||
|
- yarn install --check-frontend --cache-folder .yarn-cache
|
||||||
|
|
||||||
validate-composer:
|
#
|
||||||
|
# Preparation
|
||||||
|
#
|
||||||
|
|
||||||
|
composer validate:
|
||||||
image: composer:latest
|
image: composer:latest
|
||||||
stage: validate
|
stage: prepare
|
||||||
script:
|
script:
|
||||||
- composer --no-ansi validate --strict
|
- composer --no-ansi validate --strict
|
||||||
|
|
||||||
validate-yarn:
|
composer install:
|
||||||
|
<<: *use_cache
|
||||||
|
image: composer:latest
|
||||||
|
stage: prepare
|
||||||
|
needs:
|
||||||
|
- composer audit
|
||||||
|
- composer validate
|
||||||
|
script:
|
||||||
|
- composer install --no-ansi --no-progress
|
||||||
|
|
||||||
|
composer audit:
|
||||||
|
image: php:latest
|
||||||
|
stage: prepare
|
||||||
|
needs:
|
||||||
|
- composer validate
|
||||||
|
before_script:
|
||||||
|
- curl -Ls https://github.com/symfony/cli/releases/latest/download/symfony_linux_amd64.gz | gzip -d > /bin/symfony
|
||||||
|
- chmod +x /bin/symfony
|
||||||
|
script:
|
||||||
|
- symfony check:security --no-ansi
|
||||||
|
|
||||||
|
yarn-validate:
|
||||||
image: node:alpine
|
image: node:alpine
|
||||||
stage: validate
|
stage: prepare
|
||||||
before_script:
|
before_script:
|
||||||
- yarn global add package-json-validator
|
- yarn global add package-json-validator
|
||||||
- export PATH=$PATH:~/.yarn/bin
|
- export PATH=$PATH:~/.yarn/bin
|
||||||
script:
|
script:
|
||||||
- pjv
|
- pjv
|
||||||
|
|
||||||
|
yarn install:
|
||||||
|
<<: *use_cache
|
||||||
|
image: node:alpine
|
||||||
|
stage: prepare
|
||||||
|
needs:
|
||||||
|
- yarn-validate
|
||||||
|
- yarn audit
|
||||||
|
script:
|
||||||
|
- yarn install --check-frontend --cache-folder .yarn-cache
|
||||||
|
|
||||||
|
yarn audit:
|
||||||
|
image: node:alpine
|
||||||
|
stage: prepare
|
||||||
|
needs:
|
||||||
|
- yarn-validate
|
||||||
|
script:
|
||||||
|
- yarn audit
|
||||||
|
|
||||||
generate-version:
|
generate-version:
|
||||||
image: alpine
|
image: alpine
|
||||||
stage: validate
|
stage: prepare
|
||||||
artifacts:
|
artifacts:
|
||||||
name: "${CI_JOB_NAME}_${CI_JOB_ID}_version"
|
name: "${CI_JOB_NAME}_${CI_JOB_ID}_version"
|
||||||
expire_in: 1 day
|
expire_in: 1 day
|
||||||
|
@ -82,6 +117,44 @@ generate-version:
|
||||||
- echo "${VERSION}"
|
- echo "${VERSION}"
|
||||||
- echo -n "${VERSION}" > storage/app/VERSION
|
- echo -n "${VERSION}" > storage/app/VERSION
|
||||||
|
|
||||||
|
#
|
||||||
|
# Validation
|
||||||
|
#
|
||||||
|
|
||||||
|
phpcs:
|
||||||
|
<<: *use_composer
|
||||||
|
image: composer:latest
|
||||||
|
stage: validate
|
||||||
|
script:
|
||||||
|
- ./vendor/bin/phpcs -p --no-colors --basepath="$PWD"
|
||||||
|
|
||||||
|
phpstan:
|
||||||
|
<<: *use_composer
|
||||||
|
image: composer:latest
|
||||||
|
stage: validate
|
||||||
|
script:
|
||||||
|
- ./vendor/bin/phpstan --no-progress
|
||||||
|
|
||||||
|
yarn check:
|
||||||
|
<<: *use_yarn
|
||||||
|
image: node:alpine
|
||||||
|
stage: validate
|
||||||
|
script:
|
||||||
|
- yarn check
|
||||||
|
|
||||||
|
eslint:
|
||||||
|
<<: *use_yarn
|
||||||
|
image: node:alpine
|
||||||
|
stage: validate
|
||||||
|
script:
|
||||||
|
- yarn lint
|
||||||
|
|
||||||
|
check-editorconfig:
|
||||||
|
image: mstruebing/editorconfig-checker
|
||||||
|
stage: validate
|
||||||
|
script:
|
||||||
|
- ec -v
|
||||||
|
|
||||||
#
|
#
|
||||||
# Build
|
# Build
|
||||||
#
|
#
|
||||||
|
@ -100,11 +173,12 @@ build-image:
|
||||||
stage: build
|
stage: build
|
||||||
needs:
|
needs:
|
||||||
- check-editorconfig
|
- check-editorconfig
|
||||||
- check-php-style
|
- phpcs
|
||||||
- check-frontend
|
- phpstan
|
||||||
|
- composer validate
|
||||||
|
- yarn check
|
||||||
|
- eslint
|
||||||
- generate-version
|
- generate-version
|
||||||
- validate-composer
|
|
||||||
- validate-yarn
|
|
||||||
dependencies:
|
dependencies:
|
||||||
- generate-version
|
- generate-version
|
||||||
script:
|
script:
|
||||||
|
@ -116,23 +190,6 @@ build-image:
|
||||||
# Test
|
# Test
|
||||||
#
|
#
|
||||||
|
|
||||||
audit-composer:
|
|
||||||
image: php:latest
|
|
||||||
stage: test
|
|
||||||
needs: [ ]
|
|
||||||
before_script:
|
|
||||||
- curl -Ls https://github.com/symfony/cli/releases/latest/download/symfony_linux_amd64.gz | gzip -d > /bin/symfony
|
|
||||||
- chmod +x /bin/symfony
|
|
||||||
script:
|
|
||||||
- symfony check:security --no-ansi
|
|
||||||
|
|
||||||
audit-yarn:
|
|
||||||
image: node:alpine
|
|
||||||
stage: test
|
|
||||||
needs: [ ]
|
|
||||||
script:
|
|
||||||
- yarn audit
|
|
||||||
|
|
||||||
test:
|
test:
|
||||||
image:
|
image:
|
||||||
name: ${TEST_IMAGE}
|
name: ${TEST_IMAGE}
|
||||||
|
@ -231,8 +288,8 @@ build-release-file:
|
||||||
stage: release
|
stage: release
|
||||||
needs:
|
needs:
|
||||||
- build-image
|
- build-image
|
||||||
- audit-yarn
|
- yarn audit
|
||||||
- audit-composer
|
- composer audit
|
||||||
- test
|
- test
|
||||||
- dump-database
|
- dump-database
|
||||||
- generate-assets
|
- generate-assets
|
||||||
|
@ -394,8 +451,8 @@ deploy-production:
|
||||||
stage: deploy-production
|
stage: deploy-production
|
||||||
needs:
|
needs:
|
||||||
- test
|
- test
|
||||||
- audit-yarn
|
- yarn audit
|
||||||
- audit-composer
|
- composer audit
|
||||||
- build-image
|
- build-image
|
||||||
- generate-assets
|
- generate-assets
|
||||||
dependencies:
|
dependencies:
|
||||||
|
@ -422,8 +479,8 @@ deploy-k8s-production:
|
||||||
stage: deploy-production
|
stage: deploy-production
|
||||||
needs:
|
needs:
|
||||||
- release-image
|
- release-image
|
||||||
- audit-yarn
|
- yarn audit
|
||||||
- audit-composer
|
- composer audit
|
||||||
environment:
|
environment:
|
||||||
name: production
|
name: production
|
||||||
on_stop: stop-k8s-production
|
on_stop: stop-k8s-production
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
You may use `composer run phpcs` and [Editorconfig-Checker](https://editorconfig-checker.github.io) to verify that.
|
You may use `composer run phpcs` and [Editorconfig-Checker](https://editorconfig-checker.github.io) to verify that.
|
||||||
* You should use an [editorconfig plugin for your editor](https://editorconfig.org/#pre-installed) for automatic basic code formatting.
|
* You should use an [editorconfig plugin for your editor](https://editorconfig.org/#pre-installed) for automatic basic code formatting.
|
||||||
* Use `use` statements wherever possible instead of writing the fully qualified name.
|
* Use `use` statements wherever possible instead of writing the fully qualified name.
|
||||||
|
* Code must pass PHPStan checks (`composer phpstan`)
|
||||||
* Order the composer/npm dependencies alphabetically.
|
* Order the composer/npm dependencies alphabetically.
|
||||||
* Do not use code from the [includes](includes) directory anywhere else.
|
* Do not use code from the [includes](includes) directory anywhere else.
|
||||||
* Please cover your code by unit tests, our goal is to stay at 100% line coverage.
|
* Please cover your code by unit tests, our goal is to stay at 100% line coverage.
|
||||||
|
|
|
@ -108,6 +108,14 @@ PRODUCTION_REMOTE # Same as STAGING_REMOTE but for the production environm
|
||||||
PRODUCTION_REMOTE_PATH # Same as STAGING_REMOTE_PATH but for the production environment
|
PRODUCTION_REMOTE_PATH # Same as STAGING_REMOTE_PATH but for the production environment
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Static code analysis
|
||||||
|
|
||||||
|
You can run a static code analysis with this command:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
composer phpstan
|
||||||
|
```
|
||||||
|
|
||||||
## Docker
|
## Docker
|
||||||
|
|
||||||
If unspecific issues appear try using Docker version >= 20.10.14.
|
If unspecific issues appear try using Docker version >= 20.10.14.
|
||||||
|
|
|
@ -15,7 +15,8 @@
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"phpcs": "phpcs -p",
|
"phpcs": "phpcs -p",
|
||||||
"phpcbf": "phpcbf -p"
|
"phpcbf": "phpcbf -p",
|
||||||
|
"phpstan": "phpstan"
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=7.4.0",
|
"php": ">=7.4.0",
|
||||||
|
@ -51,6 +52,7 @@
|
||||||
"dms/phpunit-arraysubset-asserts": "^0.3.1",
|
"dms/phpunit-arraysubset-asserts": "^0.3.1",
|
||||||
"fakerphp/faker": "^1.17",
|
"fakerphp/faker": "^1.17",
|
||||||
"filp/whoops": "^2.14",
|
"filp/whoops": "^2.14",
|
||||||
|
"phpstan/phpstan": "^1.9",
|
||||||
"phpunit/phpunit": "^9.5",
|
"phpunit/phpunit": "^9.5",
|
||||||
"slevomat/coding-standard": "^7.1",
|
"slevomat/coding-standard": "^7.1",
|
||||||
"squizlabs/php_codesniffer": "^3.6",
|
"squizlabs/php_codesniffer": "^3.6",
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "b2eb1187f2e6d351073c1f8cdde0495d",
|
"content-hash": "753487aad9b4365e8f96952f4fb98d00",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "composer/package-versions-deprecated",
|
"name": "composer/package-versions-deprecated",
|
||||||
|
@ -5854,6 +5854,65 @@
|
||||||
},
|
},
|
||||||
"time": "2022-04-14T12:24:06+00:00"
|
"time": "2022-04-14T12:24:06+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "phpstan/phpstan",
|
||||||
|
"version": "1.9.2",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/phpstan/phpstan.git",
|
||||||
|
"reference": "d6fdf01c53978b6429f1393ba4afeca39cc68afa"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/d6fdf01c53978b6429f1393ba4afeca39cc68afa",
|
||||||
|
"reference": "d6fdf01c53978b6429f1393ba4afeca39cc68afa",
|
||||||
|
"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": {
|
||||||
|
"issues": "https://github.com/phpstan/phpstan/issues",
|
||||||
|
"source": "https://github.com/phpstan/phpstan/tree/1.9.2"
|
||||||
|
},
|
||||||
|
"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": "2022-11-10T09:56:11+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "phpunit/php-code-coverage",
|
"name": "phpunit/php-code-coverage",
|
||||||
"version": "9.2.10",
|
"version": "9.2.10",
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
parameters:
|
||||||
|
phpVersion: 70400
|
||||||
|
level: 1
|
||||||
|
paths:
|
||||||
|
- config
|
||||||
|
- db
|
||||||
|
- src
|
||||||
|
- tests
|
||||||
|
scanDirectories:
|
||||||
|
- includes
|
|
@ -82,7 +82,7 @@ class LegacyDevelopment extends Legacy
|
||||||
|
|
||||||
$return[] = [
|
$return[] = [
|
||||||
'file' => $path . ':' . $line,
|
'file' => $path . ':' . $line,
|
||||||
$functionName => $args ?? null,
|
$functionName => $args,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ class MailerServiceProvider extends ServiceProvider
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $transport
|
* @param string|null $transport
|
||||||
* @param array $config
|
* @param array $config
|
||||||
* @return TransportInterface
|
* @return TransportInterface
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -9,6 +9,8 @@ use Engelsystem\Test\Unit\TestCase;
|
||||||
|
|
||||||
class ChecksArrivalsAndDeparturesTest extends TestCase
|
class ChecksArrivalsAndDeparturesTest extends TestCase
|
||||||
{
|
{
|
||||||
|
private Config $config;
|
||||||
|
|
||||||
public function invalidArrivalCombinations(): array
|
public function invalidArrivalCombinations(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
|
|
@ -41,7 +41,7 @@ class ControllerTest extends TestCase
|
||||||
|
|
||||||
$engine->expects($this->once())
|
$engine->expects($this->once())
|
||||||
->method('get')
|
->method('get')
|
||||||
->willReturnCallback(function ($path, $data) use ($response) {
|
->willReturnCallback(function ($path, $data) {
|
||||||
$this->assertEquals('/metrics', $path);
|
$this->assertEquals('/metrics', $path);
|
||||||
$this->assertArrayHasKey('info', $data);
|
$this->assertArrayHasKey('info', $data);
|
||||||
$this->assertArrayHasKey('users', $data);
|
$this->assertArrayHasKey('users', $data);
|
||||||
|
|
Loading…
Reference in New Issue