7
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

PHPStan, phan を Docker Compose から実行する

Posted at

Docker イメージ

PHPStan は公式で docker イメージを提供しているので、それを使う。

phpstan/phpstan

phan は公式で docker イメージを提供していないので、ここでは cloudflare が提供しているイメージを利用する。

cloudflare/phan

設定

ディレクトリ構成
- src/
    - .phan/
        - config.php  # phan 用設定ファイル
    - index.php       # 解析対象
    - phpstan.neon    # PHPStan 用設定ファイル
- docker-compose.yml
docker-compose.yml
version: "3"
services:

  phpstan:
    image: phpstan/phpstan:latest
    volumes:
      - ./src/:/app
    command: analyze

  phan:
    image: cloudflare/phan:latest
    volumes:
      - ./src:/mnt/src

それぞれマウント先を /app/mnt/src とする。

設定ファイル例

以下、PHPStan と phan 用の最低限の設定例。

実際の目的に合わせて適宜書き換える。

設定項目については各ドキュメントを参照のこと。

src/phpstan.neon
parameters:
	level: 7 # 目的に合わせて変える
	paths:
		- %currentWorkingDirectory%
src/.phan/config.php
<?php

return [
    'target_php_version' => 7.1, // 目的に合わせて変える

    'directory_list' => [
        './',
    ],

    "exclude_analysis_directory_list" => [
    ],
];

実行

PHPStanの実行
$ docker-compose run --rm phpstan
phanの実行
$ docker-compose run --rm phan
7
6
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?