0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

PHP 静的解析

Last updated at Posted at 2025-09-30

プログラムでの静的解析の意味とPHPでの使い方

静的解析とは

プログラムを実行せずにソースコードを解析し、バグや脆弱性、コーディング規約違反などを検出すること

静的解析でできること

コーディング規約違反

  • 変数名の不統一
  • インデントのずれ

バグ

  • メモリリーク
  • Nullポインタ参照
  • 未初期化変数の使用

セキュリティ

  • クロスサイトスクリプティング
  • SQLインジェクション
  • 不適切なパスワード管理

Laravelでの使い方

  1. PHPStanのインストール
     composer require --dev phpstan/phpstan phpstan/phpstan-laravel
     
  2. プロジェクトのルートにphpstan.neonという設定ファイルを作成し、以下を記述
     includes:
        - vendor/phpstan/phpstan-laravel/extension.neon
    parameters:
        level: 5 //解析レベル(0~10) 数字が大きいほど厳格になる
        paths:  // 解析対象のディレクトリを指定
            - app/
    

 
3. コマンドを実行
 ./vendor/bin/phpstan analyse

0
0
1

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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?