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)
来触发过期标记的测试失败。