mfn/php-analyzer
最新稳定版本:v0.0.2
Composer 安装命令:
composer require mfn/php-analyzer
包简介
Framework for performaing static PHP code analysis
README 文档
README
Homepage: https://github.com/mfn/php-analyzer
Blurb
A framework for performing static PHP source analysis. The modular concept hands analysis over to Analyzers which report back any possible warnings/errors.
Install
Via composer:
composer require mfn/php-analyzer 0.0.1
Usage
A command line tool is provided: php_analyzer.php analyze <files or dirs>
See the --help switch for more details.
What analysis is performed?
All files are run through the nikic/PHP-Parser and after that an internal graph of the classes/interfaces is built.
All analyzers available are run against the sources reports are generated.
The following analysis is currently performed:
- detection of missing method implementations of abstract classes
- detecting of missing method implementations of interfaces
- incompatibility of methods declared in interfaces
- methods defined abstract on an interface
Probably a bit pointless because the php linter detects this. - warns when using dynamic class instantiation, i.e.
new $foo - warns when encountering empty exception catch blocks
Learn more:
- The architecture of the Framework itself
- Documentations of all Analyzers
- Default Analyzer configuration
Graphviz
The internal ObjectGraph lends
itself to generate a class relationship diagram for which a graphviz generator
exists. This will produce a .dot file which can be further used with the
Graphviz package to generate graphics from it:
php_analyzer.php graphviz yoursource/ > myproject.dot
See --help for more options.
To convert this to e.g. png the aforementioned graphviz package has to be
installed on your system. This includes the dot command which can be used to
generate a PNG file:
dot -Tpng myproject.dot > myproject.png
Configuration
If you want to use a differnet set of analyzers or you've written your own and
want to use them, you can use the --config <file> option.
The file is a plain PHP file simply returning an array of analyzers you want to run. See res/defaultAnalyzerConfiguration.php for an example.
TODOs / Ideas
- the analyzers depending on the graph have no logic whether they've visited a node already or not; thus visiting the same nodes/methods multiple times
- Use
namespacedNameproperty generated by\PhpParser\NodeVisitor\NameResolver - Add support for traits
Contribution
- one feature per branch/PR
- coding standard is PSR-2
© Markus Fischer markus@fischer.name
mfn/php-analyzer 适用场景与选型建议
mfn/php-analyzer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 34 次下载、GitHub Stars 达 3, 最近一次更新时间为 2015 年 02 月 01 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「source」 「code」 「analysis」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 mfn/php-analyzer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mfn/php-analyzer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 mfn/php-analyzer 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Memio's PrettyPrinter, used to generate PHP code from given Model
A Laravel 5 Package for Using & Working With Emojis
A Laravel 5 Package Provider to Identify/detect a user's browser, device, operating system and Language
TwigStan is a static analyzer for Twig templates powered by PHPStan
Sentiment analysis library for PHP.
Database Standardization and Analysis Tool for Laravel
统计信息
- 总下载量: 34
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 25
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-02-01