shopsys/coding-standards
Composer 安装命令:
composer require shopsys/coding-standards
包简介
Coding standards definition compatible with PSR-2
README 文档
README
Shopsys Coding Standards are based on PSR-2.
This project bundles tools along with predefined rulesets for automated checks of Shopsys Coding Standards that we use in many Shopsys projects. The repository also contains few custom rules.
This repository is maintained by shopsys/shopsys monorepo, information about changes is in its CHANGELOG file.
Provided tools:
- PHP-Parallel-Lint
- EasyCodingStandard that combines PHP-CS-Fixer and PHP_CodeSniffer
For further information see official documentation of those tools.
Installation
php composer require shopsys/coding-standards
Usage
Create ecs.php config file in your project which includes predefined ruleset.
You can take the config from the project-base repository as an inspiration.
You can also customize the rules and even add your own sniffs and fixers in the config.
In terminal, run following commands:
php vendor/bin/parallel-lint /path/to/project php vendor/bin/ecs check /path/to/project --config=/path/to/project/custom-coding-standard.yml
Custom rules
Rules for PHP-CS-Fixer
Shopsys/missing_button_type
All <button> HTML tags in .html and .html.twig files must have explicit type attribute.
If the type is not specified it will be fixed to type="button"" because the implicit value is submit which makes it behave differently based on the context (<button> inside <form> element submits the form).
Shopsys/orm_join_column_require_nullable
Doctrine attributes #[ORM\ManyToOne] and #[ORM\OneToOne] must have nullable option defined explicitly in #[ORM\JoinColumn].
If the nullable option is not specified it will be fixed to nullable: false because the implicit value is true but this is the opposite to the implicit value of nullable for #[ORM\Column] attribute.
This makes it consistent.
Rules for PHP_CodeSniffer
ForbiddenExitSniff
Function exit() is not allowed.
ForbiddenSuperGlobalSniff
Usage of superglobals ($_COOKIE, $_GET, $_FILES, $_POST, $_REQUEST, $_SERVER) is not allowed.
ObjectIsCreatedByFactorySniff
Instantiation of objects that can be created by their factories is not allowed outside of the factory.
ValidVariableNameSniff
Default \PHP_CodeSniffer\Standards\Squiz\Sniffs\NamingConventions\ValidVariableNameSniff
does not report method parameters in $_var format as an violation but it should.
It also skips checking of private members when PrivateNoUnderscore property is disabled.
This sniff provides the missing functionality and is intended to be used as an addition to the default ValidVariableNameSniff.
Contributing
Thank you for your contributions to Shopsys Coding Standards package. Together we are making Shopsys Platform better.
This repository is READ-ONLY. If you want to report issues and/or send pull requests, please use the main Shopsys repository.
Please check our Contribution Guide before contributing.
Support
What to do when you are in troubles or need some help? The best way is to join our Slack.
If you want to report issues, please use the main Shopsys repository.
shopsys/coding-standards 适用场景与选型建议
shopsys/coding-standards 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 280.18k 次下载、GitHub Stars 达 20, 最近一次更新时间为 2017 年 03 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「PSR-2」 「Code style」 「coding standards」 「code quality」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 shopsys/coding-standards 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 shopsys/coding-standards 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 shopsys/coding-standards 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Memio's PrettyPrinter, used to generate PHP code from given Model
A Symfony bundle for using the CssToInlineStyles translator by tijsverkoyen
Fixing php code style
Parse your BBCode easy with this library.
Generate and display your API documentation with Swagger from your source code.
The coding standard applying to all Youdot PHP projects, based on Doctrine set of PHPCS rules, with additional checks.
统计信息
- 总下载量: 280.18k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 20
- 点击次数: 36
- 依赖项目数: 15
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-03-14