lynxsolutions / php-static-analysis
Laravel项目静态分析工具配置
0.1.0
2024-08-09 03:35 UTC
Requires
- php: ^8.3
- slevomat/coding-standard: ^8.15
- squizlabs/php_codesniffer: ^3.10
Requires (Dev)
README
本仓库除了包含PHPCS LynxSolutionsCodingStandard,还包含用于LynxSolutions PHP(主要是Laravel)项目中使用的各种静态分析工具的配置文件。
安装
Composer
composer require --dev lynxsolutions/php-static-analysis
使用
PHP_CodeSniffer
在你的项目的phpcs.xml
文件中添加以下行
<rule ref="LynxSolutionsCodingStandard"/>
如果你没有phpcs.xml
文件,这里有一个简单的例子
<?xml version="1.0"?> <ruleset name="LynxSolutions PHPCS default configuration" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="./vendor/squizlabs/php_codesniffer/phpcs.xsd" > <description>LynxSolutions PHPCS default configuration.</description> <arg name="extensions" value="php"/> <arg name="colors" /> <arg value="sp"/> <file>app</file> <file>bootstrap</file> <file>config</file> <file>database</file> <file>routes</file> <file>tests</file> <exclude-pattern>cache/*</exclude-pattern> <rule ref="LynxSolutionsCodingStandard"/> </ruleset>
现在你应该可以运行
vendor/bin/phpcs
PHP Mess Detector
如果你没有安装phpmd/phpmd
包,你可以通过运行以下命令来安装它
composer require --dev phpmd/phpmd
然后,在你的项目的phpmd.xml
文件中添加以下行
<rule ref="vendor/lynxsolutions/php-static-analysis/phpmd/phpmd.xml"/>
如果你没有phpmd.xml
文件,这里有一个简单的例子
<?xml version="1.0"?> <ruleset name="LynxSolutions PHPMD default configuration" xmlns="http://pmd.sf.net/ruleset/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd" xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd" > <description>LynxSolutions PHPMD default configuration.</description> <rule ref="vendor/lynxsolutions/php-static-analysis/phpmd/phpmd.xml"/> </ruleset>
现在你可以运行
vendor/bin/phpmd app,bootstrap,config,database,routes,tests text phpmd.xml