bypassflow / standards
共有コーディング規約、php-cs-fixer custom fixer、関連文書を提供する standards package。
v0.0.0
2026-04-10 17:06 UTC
Requires
- php: >=8.5.0
- friendsofphp/php-cs-fixer: ^3.68
Requires (Dev)
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^13.0
README
bypassflow/standards は、bypassflow の PHP コーディング規約を実装で支える package です。
php-cs-fixer 向け custom fixer と、改行スタイルを機械検査する checker を提供します。
概要
- custom fixer:
Bypassflow/leading_continuation_indent - checker:
tools/php/check-line-break-style.php - 対象スタイル: 行頭継続演算子、method chain、ternary の改行インデント
Requirements
- PHP 8.5+
friendsofphp/php-cs-fixer3.68+
Installation
composer require --dev bypassflow/standards
Quick Start
LeadingContinuationIndentFixer は、行頭継続演算子、method chain、ternary の改行インデントを workspace 規約へ揃えます。
まず .php-cs-fixer.dist.php で fixer を有効化します。
<?php declare(strict_types=1); use bypassflow\Standards\PhpCsFixer\CustomFixer\LeadingContinuationIndentFixer; use PhpCsFixer\Config; use PhpCsFixer\Finder; return (new Config())->setFinder((new Finder())->in([ \sprintf('%s/src', __DIR__), \sprintf('%s/tests', __DIR__), ]))->registerCustomFixers([ new LeadingContinuationIndentFixer(), ])->setRules([ 'Bypassflow/leading_continuation_indent' => true, ]);
適用後の形は次のようになります。
<?php declare(strict_types=1); function resolve_label(?string $display_name, string $fallback_name, bool $is_enabled): string { $name = $display_name ?? $fallback_name; return $is_enabled ? $name : 'disabled'; }
if とメソッドチェーンを組み合わせた例:
<?php declare(strict_types=1); function resolve_schedule_label(\DateTimeImmutable $baseAt, bool $prefer_jst): string { if ($prefer_jst && $baseAt ->setTimezone(new \DateTimeZone('Asia/Tokyo')) ->format('N') !== '7') { return $baseAt ->setTimezone(new \DateTimeZone('Asia/Tokyo')) ->setTime(9, 0) ->format(\DateTimeInterface::ATOM); } return $baseAt ->setTimezone(new \DateTimeZone('UTC')) ->setTime(0, 0) ->format(\DateTimeInterface::ATOM); }
改行スタイル checker は次で実行できます。
php tools/php/check-line-break-style.php src tests
主要 API
bypassflow\Standards\PhpCsFixer\CustomFixer\LeadingContinuationIndentFixertools/php/check-line-break-style.php
functions/helper
- package から公開している関数 helper はありません
補助文書
- 詳細な利用例と CI への組み込み:
USAGE.md