PHP Quality & Security Tools

Statische Analyse, Code-Style-Prüfung und Security-Scanning für PHP. Stellt Codequalität, PSR-12 Konformität, Typsicherheit und OWASP-Compliance sicher.

PHPStan2.1.33 + Strict Rules
PHP-CS-Fixer3.92.3
Semgrep1.146.0 (OWASP Scanner)
Composer AuditCVE-Check für Dependencies
Installation/opt/php-tools/
Script/opt/scripts/php-check.sh

Verwendung

# Prüfung (dev)
/opt/scripts/php-check.sh

# Prüfung (beliebiges Projekt)
/opt/scripts/php-check.sh /pfad/zum/projekt

# Mit automatischer Korrektur
/opt/scripts/php-check.sh /pfad/zum/projekt --fix

PHPStan + Strict Rules

Statische Analyse für Typsicherheit, Null-Safety und Bug-Erkennung.

Level5 (von 10)
Strict Rulesphpstan-strict-rules 2.0.7
Konfig/opt/php-tools/phpstan.neon
Scopesrc/, app/ (ohne View/)

PHP-CS-Fixer

Automatische Code-Formatierung nach PSR-12 Standard.

StandardPSR-12
Konfig/opt/php-tools/.php-cs-fixer.php

Regeln

Semgrep (OWASP Security)

Pattern-basierter Security Scanner für OWASP-Vulnerabilities.

Version1.146.0
Konfig/opt/php-tools/semgrep-security.yml
Installation/root/.local/bin/semgrep (pipx)

Erkannte Vulnerabilities

TypOWASPCWE
Cross-Site Scripting (XSS)A03:2021CWE-79
XML External Entity (XXE)A05:2021CWE-611
Server-Side Template Injection (SSTI)A03:2021CWE-1336
Server-Side Request Forgery (SSRF)A10:2021CWE-918
Cross-Site Request Forgery (CSRF)A01:2021CWE-352
Command InjectionA03:2021CWE-78
SQL InjectionA03:2021CWE-89
File InclusionA03:2021CWE-98
Path TraversalA01:2021CWE-22
Eval/Code InjectionA03:2021CWE-94
Unsafe DeserializationA08:2021CWE-502
Header InjectionA03:2021CWE-113
LDAP InjectionA03:2021CWE-90

Direkt ausführen

/root/.local/bin/semgrep scan \
    --config /opt/php-tools/semgrep-security.yml \
    src app

Composer Audit

Prüft Composer-Dependencies auf bekannte CVEs.

composer audit --working-dir=/var/www/dev.campus.systemische-tools.de

Automatisierung

PostToolUse Hook (nach jeder Dateiänderung)

TriggerEdit, Write auf *.php
Script/opt/scripts/php-style-hook.py
PrüfungPHP-CS-Fixer (nur Style)
VerhaltenWarnung, kein Block

Pre-Sync Check (vor Deployment)

Trigger/opt/scripts/sync-dev-prod.sh
PrüfungPHPStan + PHP-CS-Fixer + Composer Audit + Semgrep
VerhaltenBlockiert bei Fehlern

Prinzipien & Prüfungen

PrinzipBedeutungTool
PSR-12Code StylePHP-CS-Fixer
Type SafetyTypsicherheitPHPStan + Strict Rules
OWASPSecurity VulnerabilitiesSemgrep
CVEDependency VulnerabilitiesComposer Audit
DRY/KISS/YAGNIClean CodeManuell / Review