lynxsolutions/php-static-analysis

Laravel项目静态分析工具配置

安装: 2

依赖: 0

建议者: 0

安全: 0

星星: 1

关注者: 4

分支: 0

开放性问题: 0

类型:phpcodesniffer-standard

0.1.0 2024-08-09 03:35 UTC

This package is auto-updated.

Last update: 2024-09-09 10:50:07 UTC


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