swivl/php-coding-standard
Composer 安装命令:
composer require swivl/php-coding-standard
包简介
Swivl Coding Standard for PHP_CodeSniffer
README 文档
README
This coding standard is much more strict version of PSR-12.
Installation
Install coding standard using composer:
composer require --dev swivl/php-coding-standard
Configuration
Create file phpcs.xml.dist in the root of your project with the content similar to:
<?xml version="1.0" encoding="UTF-8"?> <ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd"> <arg name="basepath" value="."/> <arg name="cache" value=".phpcs-cache"/> <arg name="colors"/> <arg value="p"/> <arg name="extensions" value="php"/> <arg name="tab-width" value="4"/> <arg name="report-width" value="120"/> <rule ref="vendor/swivl/php-coding-standard/Swivl/ruleset.xml"/> <rule ref="Generic.Files.LineLength.TooLong"> <exclude-pattern>*/src/Migrations/*</exclude-pattern> </rule> <file>src/</file> <file>tests/</file> <exclude-pattern>*/Resources/*</exclude-pattern> </ruleset>
Configure your IDE to use phpcs.xml.dist as the default ruleset for PHP_CodeSniffer.
Checking code style in your project
Check the whole project:
bin/phpcs
Check a single file or directory:
bin/phpcs path/to/file/or/directory
Automatically fix errors:
bin/phpcbf
Advanced configuration
Swivl.Commenting.DoctrineEntity
This sniff provides the following options:
<rule ref="Swivl.Commenting.DoctrineEntity"> <properties> <property name="concreteTypeToBaseTypeMap" type="array"> <element key="FeedItemComment" value="CommentInterface"/> </property> <property name="useDynamicalCalculationForEnumColumnType" value="true"/> </properties> </rule>
concreteTypeToBaseTypeMap- when column is mapped to concrete type FeedItemComment, but modification methods are type hinted with base class CommentInterfaceuseDynamicalCalculationForEnumColumnType- when enum is mapped to some PHP type. For example,type="auth_enum_type"is mapped to PHP AuthType.
Swivl.Commenting.FunctionComment
This sniff provides the option:
<rule ref="Swivl.Commenting.FunctionComment"> <properties> <property name="requiredPhpdoc" value="always"/> <property name="minimumVisibility" value="private"/> </properties> </rule>
requiredPhpdoc- configures when PHPDoc is required for a method. Possible values:always- PHPDoc is required for all methods.map- PHPDoc is required for a method if at least 1 type hint or return type is in the list which is defined in the sniff in FunctionCommentSniff::REQUIRED_PHPDOC_MAP. It is the default behavior.never- PHPDoc isn't required for all methods.
Swivl.Functions.ConstructorPropertyPromotion
This sniff provides the following options:
<rule ref="Swivl.Functions.ConstructorPropertyPromotion"> <properties> <property name="indent" value="4"/> </properties> </rule>
Swivl.Commenting.UselessFunctionComment
This sniff provides the following options:
<rule ref="Swivl.Commenting.UselessFunctionComment"> <properties> <property name="ignoreClasses" value="false"/> <property name="ignoreInterfaces" value="false"/> <property name="ignoreTraits" value="false"/> <property name="includeNames" type="array"> <element value="__construct"/> </property> <property name="excludeNames" type="array"> <element value="__serialize"/> </property> <property name="maxDescriptionLines" value="1"/> </properties> </rule>
Swivl.Commenting.UselessClassComment
This sniff provides the following options:
<rule ref="Swivl.Commenting.UselessClassComment"> <properties> <property name="maxDescriptionLines" value="1"/> <property name="uselessTags" type="array"> <element value="@package"/> </property> <property name="uselessDescriptions" type="array"> <element value="Doctrine migration"/> </property> </properties> </rule>
Dependencies update
Some sniffs from Swivl Coding Standard override sniffs from libraries which are in dependencies list. The following sniffs should be synchronized with the original code during dependencies update:
swivl/php-coding-standard 适用场景与选型建议
swivl/php-coding-standard 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 49.49k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2019 年 09 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「symfony」 「phpcs」 「Coding Standard」 「Swivl」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 swivl/php-coding-standard 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 swivl/php-coding-standard 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 swivl/php-coding-standard 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
The bundle for easy using json-rpc api on your project
Vanio Coding Standard Ruleset for PHP_CodeSniffer.
The coding standard applying to all Youdot PHP projects, based on Doctrine set of PHPCS rules, with additional checks.
CodeSniffer ruleset for the ZettaCMS coding standard
CodeSniffer ruleset for the Superbrave coding standard
Bundle Symfony DaplosBundle
统计信息
- 总下载量: 49.49k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 3
- 依赖项目数: 7
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-09-19