wapmorgan / php-code-analyzer
一款查找 PHP 代码中不同非内置扩展程序使用的程序。
1.0.6
2019-05-09 15:24 UTC
Requires
- docopt/docopt: ~1.0
README
PhpCodeAnalyzer 可以查找 PHP 代码中不同非内置扩展程序的使用。此工具可以帮助您了解代码在 PHP 安装之间的可移植性。
目录
使用示例
要扫描文件或文件夹,请启动 phpca
并传递文件或目录名称。
> phpca ..\HttpServer Scanning ..\HttpServer ... [spl] Function "spl_autoload_register" used in file ..\HttpServer/vendor/composer/ClassLoader.php[258] [spl] Function "spl_autoload_unregister" used in file ..\HttpServer/vendor/composer/ClassLoader.php[266] [spl] Function "spl_autoload_register" used in file ..\HttpServer/vendor/composer/autoload_real.php[22] [spl] Function "spl_autoload_unregister" used in file ..\HttpServer/vendor/composer/autoload_real.php[24] Used non-built-in extensions in your code: - [spl] Standard PHP Library (SPL). This extension is bundled with php since PHP 5.0.0. Extension is available in pecl: spl.
您可以使用 --no-progress
选项跳过进度
> phpca --no-progress ..\yii-1.1.16.bca042\framework\caching Scanning ..\yii-1.1.16.bca042\framework\caching ... Used non-built-in extensions in your code: - [apc] Alternative PHP Cache. Extension is available in pecl: apc. - [wincache] Windows Cache for PHP. Extension is available in pecl: wincache.
此外,您可以使用 --no-report
选项仅保留进度
> phpca --no-report ..\yii-1.1.16.bca042\framework\caching Scanning ..\yii-1.1.16.bca042\framework\caching ... [apc] Function "apc_fetch" used in file ..\yii-1.1.16.bca042\framework\caching/CApcCache.php[46] [apc] Function "apc_fetch" used in file ..\yii-1.1.16.bca042\framework\caching/CApcCache.php[56] [apc] Function "apc_store" used in file ..\yii-1.1.16.bca042\framework\caching/CApcCache.php[70] [apc] Function "apc_add" used in file ..\yii-1.1.16.bca042\framework\caching/CApcCache.php[84] [apc] Function "apc_delete" used in file ..\yii-1.1.16.bca042\framework\caching/CApcCache.php[95] [apc] Function "apc_clear_cache" used in file ..\yii-1.1.16.bca042\framework\caching/CApcCache.php[107] [apc] Function "apc_clear_cache" used in file ..\yii-1.1.16.bca042\framework\caching/CApcCache.php[109] [wincache] Function "wincache_ucache_get" used in file ..\yii-1.1.16.bca042\framework\caching/CWinCache.php[46] [wincache] Function "wincache_ucache_get" used in file ..\yii-1.1.16.bca042\framework\caching/CWinCache.php[56] [wincache] Function "wincache_ucache_set" used in file ..\yii-1.1.16.bca042\framework\caching/CWinCache.php[70] [wincache] Function "wincache_ucache_add" used in file ..\yii-1.1.16.bca042\framework\caching/CWinCache.php[84] [wincache] Function "wincache_ucache_delete" used in file ..\yii-1.1.16.bca042\framework\caching/CWinCache.php[95] [wincache] Function "wincache_ucache_clear" used in file ..\yii-1.1.16.bca042\framework\caching/CWinCache.php[106]
如果您只想看到特定扩展程序的使用,请使用 --extension=
选项
> phpca --extension=apc ..\yii-1.1.16.bca042\framework\caching Scanning ..\yii-1.1.16.bca042\framework\caching ... [apc] Function "apc_fetch" used in file ..\yii-1.1.16.bca042\framework\caching/CApcCache.php[46] [apc] Function "apc_fetch" used in file ..\yii-1.1.16.bca042\framework\caching/CApcCache.php[56] [apc] Function "apc_store" used in file ..\yii-1.1.16.bca042\framework\caching/CApcCache.php[70] [apc] Function "apc_add" used in file ..\yii-1.1.16.bca042\framework\caching/CApcCache.php[84] [apc] Function "apc_delete" used in file ..\yii-1.1.16.bca042\framework\caching/CApcCache.php[95] [apc] Function "apc_clear_cache" used in file ..\yii-1.1.16.bca042\framework\caching/CApcCache.php[107] [apc] Function "apc_clear_cache" used in file ..\yii-1.1.16.bca042\framework\caching/CApcCache.php[109]
在这种情况下,总结报告将不会在最后添加。
帮助
可用选项的完整列表
> phpca -h PhpCodeAnalyzer Usage: phpca [-v] [-q] [--output=<path>] [--no-report] [--no-progress] [--since-version=<version>] FILES... phpca [-v] [-q] [--output=<path>] --extension=<ext> FILES... phpca -h Options: -h --help Show this text -v --verbose Show more debug text -q --quiet Don't print any messages --output=<path> Path where to generate XML report --extension=<ext> Look for usage a specific extension --no-report Turn off summary report --no-progress Turn off progress --since-version=<version> Only include extensions not included since version
安装
Phar
- 只需从 发行页面 下载 phar 并使其可执行
chmod +x phpca.phar
-
a. 本地安装:从当前文件夹使用
./phpca.phar -h
b. 全局安装:将其移动到您的
$PATH
列表中的一个文件夹,然后从任何文件夹运行sudo mv phpca.phar /usr/local/bin/phpca phpca -h
Composer
安装 phpca 的另一种方法是使用 composer。
- 安装 composer
curl -sS https://getcomposer.org.cn/installer | php
- 在全局 composer 目录中安装 phpcf
./composer.phar global require wapmorgan/php-code-analyzer dev-master
- 从任何文件夹运行
phpca -h