worksome/code-sniffer
最新稳定版本:v1.0.1
Composer 安装命令:
composer require worksome/code-sniffer
包简介
Worksome's preferences and custom sniffers for phpcs
README 文档
README
⚠️ Deprecated in favor of coding-style package ⚠️
Worksome's custom sniffs
This package contains all of Worksome's custom sniffs and configuration.
composer require worksome/code-sniffer --dev
Usage
Create a phpcs.xml in the root of your project with content like the following
<?xml version="1.0" encoding="UTF-8"?> <ruleset name="YourCompany"> <description>YourCompany Coding Standard</description> <file>./app</file> <file>./tests</file> <file>./config</file> <arg name="colors"/> <arg name="parallel" value="75"/> <!-- Adds all of Worksome's coding style --> <rule ref="WorksomeSniff"/> </ruleset>
Run phpcs for seeing if you have any errors
vendor/bin/phpcs
Or run phpcbf for automatically fixing the errors when possible
vendor/bin/phpcbf
We suggest adding the commands as scripts in your composer.json for easier execution.
... "scripts": { "phpcs": "vendor/bin/phpcs", "phpcbf": "vendor/bin/phpcbf" } ...
This way you can now execute them via composer
$ composer phpcs
$ composer phpcbf
Custom sniffs
List all the custom sniffs created by Worksome.
Laravel
All custom sniffs specific to Laravel.
Config filename kebab case
Checks if all config files are written in kebab case.
Disallow env usage
Makes sure that you don't use env helper in your code, except for config files.
Event listener suffix
Enforces event listeners to end with a specific suffix, this suffix is defaulted to Listener.
| parameters | defaults |
|---|---|
| suffix | Listener |
Disallow blade outside of the resources directory
Makes sure no .blade.php files exist outside of Laravel's resources directory.
| parameters | defaults |
|---|---|
| resourcesDirectory | {YOUR_PROJECT}/resources |
PhpDoc
All custom sniffs which are not specific to Laravel.
Property dollar sign
Makes sure that you always have a dollar sign in your properties defined in phpdoc.
/** * @property string $name */ class User {}
Param tags with no type or comment
This removes all @param tags which has no specified a type or comment
/** * @param string $name * @param $type some random type * @param $other // <-- will be removed */ public function someMethod($name, $type, $other): void {}
This is mainly because phpstan requires this before it sees the property as valid.
worksome/code-sniffer 适用场景与选型建议
worksome/code-sniffer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 334.26k 次下载、GitHub Stars 达 15, 最近一次更新时间为 2021 年 03 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 worksome/code-sniffer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 worksome/code-sniffer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 334.26k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 15
- 点击次数: 18
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-03-11