taptima/php-cs-fixer
Composer 安装命令:
composer require taptima/php-cs-fixer
包简介
Taptima PHP-CS-Fixer fixers
README 文档
README
This repository appeared thanks to the PedroTroller/PhpCSFixer-Custom-Fixers and the code from this repository is used here.
Installation
composer require --dev taptima/php-cs-fixer dev-master
Configuration
// .php-cs-fixer.php <?php $config = PhpCsFixer\Config::create() // ... ->registerCustomFixers(new Taptima\CS\Fixers()) // ... ; return $config;
You can also include the ruleset used by the Taptima company. It includes the @Symfony, @PSR and other rules to get the best codestyle result. @Taptima rule set can be viewed here.
// .php-cs-fixer.php <?php $config = PhpCsFixer\Config::create() ->setRules( Taptima\CS\RuleSetFactory::create([ '@Taptima' => true, // other rules ]) ->taptima() ->getRules() ) ->registerCustomFixers( new Taptima\CS\Fixers() ) return $config;
Fixers
Taptima/doctrine_migrations
Remove useless getDescription(), up(), down() and comments from Doctrine\Migrations\AbstractMigration if needed.
Configuration
// .php-cs-fixer.php <?php $config = PhpCsFixer\Config::create() // ... ->setRules([ // ... 'Taptima/doctrine_migrations' => true, // ... ]) // ... ->registerCustomFixers(new Taptima\CS\Fixers()) ; return $config;
OR using my rule list builder.
// .php-cs-fixer.php.dist <?php $config = PhpCsFixer\Config::create() // ... ->setRules(Taptima\CS\RuleSetFactory::create() ->enable('Taptima/doctrine_migrations') ->getRules() ]) // ... ->registerCustomFixers(new Taptima\CS\Fixers()) ; return $config;
Fixes
--- Original // 80 chars +++ New // @@ @@ // use Doctrine\DBAL\Schema\Schema; // use Doctrine\Migrations\AbstractMigration; // // -/** // - * Auto-generated Migration: Please modify to your needs! // - */ // final class Version20190323095102 extends AbstractMigration // { // - public function getDescription() // - { // - return ''; // - } // // public function up(Schema $schema) // { // - // this up() migration is auto-generated, please modify it to your needs// $this->abortIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.'); // $this->addSql('CREATE TABLE admin (identifier CHAR(36) NOT NULL COMMENT \'(DC2Type:guid)\', PRIMARY KEY(identifier)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB'); @@ @@ // // public function down(Schema $schema) // { // - // this down() migration is auto-generated, please modify it to your needs $this->abortIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.'); // $this->addSql('DROP TABLE admin'); // } // } // //
Configuration
// .php-cs-fixer.php <?php $config = PhpCsFixer\Config::create() // ... ->setRules([ // ... 'Taptima/doctrine_migrations' => [ 'instanceof' => [ 'Doctrine\Migrations\AbstractMigration' ] ], // ... ]) // ... ->registerCustomFixers(new Taptima\CS\Fixers()) ; return $config;
OR using my rule list builder.
// .php-cs-fixer.php.dist <?php $config = PhpCsFixer\Config::create() // ... ->setRules(Taptima\CS\RuleSetFactory::create() ->enable('Taptima/doctrine_migrations', [ 'instanceof' => [ 'Doctrine\Migrations\AbstractMigration' ] ]) ->getRules() ]) // ... ->registerCustomFixers(new Taptima\CS\Fixers()) ; return $config;
Fixes
--- Original // 80 chars +++ New // @@ @@ // use Doctrine\DBAL\Schema\Schema; // use Doctrine\Migrations\AbstractMigration; // // -/** // - * Auto-generated Migration: Please modify to your needs! // - */ // final class Version20190323095102 extends AbstractMigration // { // - public function getDescription() // - { // - return ''; // - } // // public function up(Schema $schema) // { // - // this up() migration is auto-generated, please modify it to your needs// $this->abortIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.'); // $this->addSql('CREATE TABLE admin (identifier CHAR(36) NOT NULL COMMENT \'(DC2Type:guid)\', PRIMARY KEY(identifier)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB'); @@ @@ // // public function down(Schema $schema) // { // - // this down() migration is auto-generated, please modify it to your needs $this->abortIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.'); // $this->addSql('DROP TABLE admin'); // } // } // //
Taptima/ordered_setters_and_getters
Class/interface/trait setters and getters MUST BE ordered (order is setter, isser, hasser, adder, remover, getter).
Configuration
// .php-cs-fixer.php <?php $config = PhpCsFixer\Config::create() // ... ->setRules([ // ... 'Taptima/ordered_setters_and_getters' => true, // ... ]) // ... ->registerCustomFixers(new Taptima\CS\Fixers()) ; return $config;
OR using my rule list builder.
// .php-cs-fixer.php.dist <?php $config = PhpCsFixer\Config::create() // ... ->setRules(Taptima\CS\RuleSetFactory::create() ->enable('Taptima/ordered_setters_and_getters') ->getRules() ]) // ... ->registerCustomFixers(new Taptima\CS\Fixers()) ; return $config;
Fixes
--- Original // 80 chars +++ New // @@ @@ // $this->firstName = $firstName; // } // // - public function setName($name) // + public function getFirstName() // { // - $this->name = $name; // + return $this->firstName; // } // // - public function isEnabled() // + public function setName($name) // { // - return $this->enabled; // + $this->name = $name; // } // // public function getName() // @@ @@ // return $this->name; // } // // - public function getIdentifier() // + public function isEnabled() // { // - return $this->identifier; // + return $this->enabled; // } // // - public function getFirstName() // + public function getIdentifier() // { // - return $this->firstName; // + return $this->identifier; // } // // public function enable() // @@ @@ // } // // /** // - * @return Item // - */ // - public function getItems() // - { // - return $this->items; // - } // - // - /** // * @param Item $item // * @return User // */ // @@ @@ // $this->items->removeElement($item); // // return $this; // + } // + // + /** // + * @return Item // + */ // + public function getItems() // + { // + return $this->items; // } // } // //
Contributions
Before to create a pull request to submit your contributon, you must:
- run tests and be sure nothing is broken
- rebuilt the documentation
How to run tests
composer tests
How to rebuild the documentation
tools/doc > README.md
taptima/php-cs-fixer 适用场景与选型建议
taptima/php-cs-fixer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 17.48k 次下载、GitHub Stars 达 13, 最近一次更新时间为 2020 年 03 月 31 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「code quality」 「php-cs-fixer」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 taptima/php-cs-fixer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 taptima/php-cs-fixer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 taptima/php-cs-fixer 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Memio's PrettyPrinter, used to generate PHP code from given Model
A simple tool for checking that your PHP classes and methods use PHPDocs (PHP DocBlocks Checker fork).
HiDev plugin for PHP-CS-Fixer
Static analyzer tool for PHP : Coupling, Cyclomatic complexity, Maintainability Index, Halstead's metrics... and more !
Axa Zara PHP Code style configuration for `php-cs-fixer` based on PSR-12.
Extensible package of custom rules for PHPStan.
统计信息
- 总下载量: 17.48k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 13
- 点击次数: 5
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-03-31