phan/phan
Phan is a static analyzer for PHP. Phan prefers to avoid false-positives and attempts to prove incorrectness rather than correctness.
Thành tựu nổi bật
Những danh hiệu mới nhất của dự án
#1 Repository của tháng
#1 Repository của tháng
#1 Repository của tháng
🛠️ Phan: Static analyzer PHP thông minh, chứng minh sai lẗn thay vì đúng
Phan ưu tiên giảm thiểu false-positive, chứng minh incorrectness thay vì correctness.
Phan là static analyzer dành cho PHP, được thiết kế để tìm kiếm các vấn đề phổ biến và kiểm tra tính tương thích kiểu dữ liệu khi thông tin kiểu khả dụng hoặc có thể suy luận được. Dự án hỗ trợ phân tích cú pháp PHP từ 8.1 đến 8.5, đòi hỏi PHP 8.1+ và php-ast extension (phiên bản 1.1.3+ cho PHP 8.4+).
✨ Điểm nổi bật
- Cài đặt qua Composer:
composer require phan/phan, khởi tạo cấu hình bằngphan --init. - Phân tích định nghĩa: kiểm tra methods, functions, classes, traits, interfaces, constants, properties và variables.
- Kiểu dữ liệu & arity: kiểm tra type safety và số lượng tham số gọi hàm/method/closure.
- Tương thích PHP 8.x: hỗ trợ kiểm tra backward compatibility và tính năng mới (property hooks, enums, union types...).
- Phát hiện code chết:
--dead-code-detectiontìm unused/dead/unreachable code. - Biến & use chưa dùng:
--unused-variable-detectionvà--unused-variable-detectioncho use statements. - Điều kiện dư thừa:
--redundant-condition-detectionphát hiện conditions luôn đúng/sai hoặc casts vô nghĩa. - Sửa tự động:
--automatic-fixtự động sửa một số loại lỗi như unused use statements. - Hỗ trợ namespace, traits, variadics: phân tích sâu các cấu trúc ngôn ngữ PHP.
- Union & Generic Types: hỗ trợ
@template,int[],array{key:string}...
💡 Vì sao đáng chú ý
Khác với các static analyzer chỉ kiểm tra surface-level, Phan mang tư duy "chứng minh sai lẗn" — ưu tiên tìm lỗi thực sự thay vì báo động giả. Phan hiểu biết flow control cơ bản, track giá trị trong arrays/integers/strings, giúp giảm false-positive đáng kể. Phù hợp tích hợp CI để bắt lỗi trước runtime, đặc biệt mạnh với legacy codebases cần nâng dần độ strictness.
#StaticAnalysis #PHP #CodeQuality #TiniX
Dự án tương tự
Khám phá các dự án và mô hình AI khác có sự tương đồng.
PHP Static Analysis Tool - discover bugs in your code without running it!
⚙️ A curated list of static analysis (SAST) tools and linters for all programming languages, config files, build tools, and more. The focus is on tools which improve code quality.
:coffee: SonarSource Static Analyzer for Java Code Quality and Security
Lightweight static analysis for many languages. Find bug variants with patterns that look like source code.
Checkstyle is a development tool to help programmers write Java code that adheres to a coding standard. By default it supports the Google Java Style Guide and Sun Code Conventions, but is highly configurable. It can be invoked with an ANT task and a command line program.