sndsgd / yaml
PHP 的 YAML 解析增强
v0.0.7
2023-03-15 15:43 UTC
Requires
- php: >=7.4
- ext-yaml: *
- sndsgd/util: >=2.1.0
Requires (Dev)
- php-parallel-lint/php-parallel-lint: ^1.2
- phpstan/phpstan: 1.4.6
- phpstan/phpstan-phpunit: ^1.0
- phpunit/phpunit: 9.5.13
- slevomat/coding-standard: ~8
- squizlabs/php_codesniffer: 3.*
README
PHP 的 YAML 解析增强。
上下文
sndsgd\yaml\ParserContext
对象是一个数据包,您可以将其用于回调函数中。
回调函数
您可以通过实现 sndsgd\yaml\Callback
来定义自己的回调函数。此存储库包含一个示例:sndsgd\yaml\callbacks\SecondsCallback
。
解析
-
使用所有回调函数创建解析器实例
$parser = new sndsgd\yaml\Parser( new sndsgd\yaml\ParserContext(), sndsgd\yaml\callbacks\SecondsCallback::class, your\fun\CoolCallback::class, );
-
使用
->parse(string $yaml, int $maxDocuments)
解析字符串 -
使用
->parseFile(string $path, int $maxDocuments)
解析文件