bartfeenstra / doobie
Doobie ("do by") 允许 PHP @todo 注释通过元数据扩展,以指定必须通过哪个事件采取所描述的操作。
Requires
- php: >=5.4
Requires (Dev)
- phpunit/phpunit: 3.7.*
- satooshi/php-coveralls: 0.6.*
This package is auto-updated.
Last update: 2024-01-29 02:05:29 UTC
README
Doobie ("do by") 允许 @todo
注释通过元数据扩展,以指定必须通过哪个事件采取所描述的操作。
Doobie 受 andyw8/do_by 的启发,后者是针对 Ruby 的。
使用方法
任何 @todo
注释都可以包含一个 Doobie 标记,格式为 [doobie:type:expected_value]
,其中 type
是必须检查的约束类型(例如 php-version
或 datetime
),而 expected_value
是约束类型必须具有的值,以便标记过期。
php-version
此内置约束类型比较预期和实际的 PHP 版本。使用方法如 [doobie:php-version:>=5.5]
。
datetime
此内置约束类型比较预期和实际的日期和时间。使用方法如 [doobie:datetime:2014-05-20 00:00 +0]
PHPUnit
为了通过 PHPUnit 测试所有标记,编写一个测试用例,实例化一个或多个文件查找器(\BartFeenstra\Doobie\FileFinder\FileFinderInterface
)、解析器(\BartFeenstra\Doobie\Parser\ParserInterface
)和约束评估器(\BartFeenstra\Doobie\Constraint\ConstriantEvaluatorInterface
)。然后,测试用例可以使用 \BartFeenstra\Doobie\PhpUnit\AssertTrait
和 $this->assertDoobieMarkers($file_finders, $parsers, $constraint_evaluators)
触发已过期标记的测试失败。