Repository navigation
Add a standalone YAML parser and document editor - #807
Conversation
Provide native PHP APIs for parsing and emitting YAML streams, editing document nodes, and retaining comments, scalar styles, anchors, and source ranges. Expose schema and tag selection, exact integers, parser diagnostics, and resource limits for native conversion. Register the standalone component in Composer with PHP and mbstring as its only runtime requirements. Include the upstream ISC notice for code derived from eemeli/yaml.
Exercise the parser and emitter against the YAML conformance suite, JSON edge cases, and workflow documents. Cover source positions, node editing, tag resolution, exact scalar conversion, and round trips through PHP values. Verify coroutine isolation and standalone operation without the framework autoloader. Preserve fixture bytes, line endings, symlinks, and third-party licenses.
Provide matching workloads for parsing, retained source tokens, document lookup and editing, and single- and multi-document emission. Each runner reports its median operation time and runtime memory measurements. Document the command-line arguments and load the PHP component directly so the benchmark can run independently of framework bootstrap.
Add the YAML guide to the package index. Explain how to choose between native values and editable documents, customize schemas and tags, retain source information, and interpret diagnostics and resource limits. Record the upstream revision, source mapping, and PHP-specific behavior alongside the package, with links to the guide and upstream license.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
|
@cubic-dev-ai review |
@binaryfire cubic can't start this review because your workspace has reached its free monthly review limit. cubic has reviewed 164,098 of the 160,000 allowed lines of code this month. Reviews resume on 10 December 2026 (in 9 days). Paid plans include much higher monthly review limits. Upgrade now to resume reviews. To help optimise your usage, you can tune cubic to get the most out of your usage limits:
|
PR Summary by QodoAdd standalone YAML parser and comment-preserving document editor
AI Description
Merge Risk
|
Confidence Score: 5/5
[Medium impact] The reviewed changes appear safe to merge; both numbered findings are fixed and no new blocking issue was found. SummaryAdds standalone
Reviews (3) · Last reviewed commit: "Keep surviving YAML aliases and syntax e..." · Reviewed by Greptile |
Code Review by Qodo
1.
|
Keep empty flow items and stream documents when emitting an empty null spelling. Preserve comment boundaries and tag directive prefixes on round trips, remove the orphan comma after a CST edit, and attach parser diagnostics to the document that owns them. Reserve anchor names against the graph that survives a replacement. Keep reviver writes local to each occurrence, including when a custom scalar contains PHP references. Cover negative sequence indexes, self-references, and naming failures without changing the original document. Charge omitted entries while reading collections, bound consecutive serialization wrappers, and reuse Unicode column counts for diagnostics on long lines. Use PHP 8.5-safe list lookups and format the JavaScript benchmark runner. Add focused regressions and document the editing and construction behavior.
|
The collection replacement now retains its anchor when assigning a native value. Existing aliases and a new self-reference both resolve to the replacement. Anchor reservation still checks the rest of the document before installing the change. Consecutive |
Reserve names mentioned by surviving aliases when generating an anchor for a shared value. Removing an anchored descendant now leaves a detectable dangling alias, and an editor can still explicitly assign its name to repair the document. Keep unexpected leading tokens in the concrete document so reconstruction preserves their original order. Attach trailing errors to the open document and report malformed standalone end markers on the stream. Cover recovery beside valid documents and anchor resolution after explicit repair.
This adds
hypervel/yamlfor applications that read configuration or edit YAML on someone’s behalf. A reader can work with native PHP values. An editor can keep the document structure, including comments, tags, anchors, and scalar styles, while changing an individual value.For example, a deployment tool can update the replica count without rebuilding the rest of the manifest from a PHP array:
For a plain configuration file,
Yaml::parse($source)returns the values directly andYaml::dump($values)writes YAML. The package requires PHP 8.4 and mbstring and can run independently of the framework.Documents and diagnostics
The document API supports multiple documents in a stream, custom schemas and tags, and traversal of nodes and tokens. A parser diagnostic includes a code and source range. Editors can inspect recoverable errors, and configuration consumers can reject them with
throwIfInvalid(). Resource limits bound nesting and alias expansion. Integers outside PHP’s native range retain their exact value.The implementation derives from eemeli/yaml. The package records the upstream revision and retains its ISC notice. The documentation covers the PHP value conversions, source positions, and editing APIs.
Verification
The YAML suite exercises the parser against the YAML conformance fixtures, JSON edge cases, and workflow manifests. It also covers document round trips, coroutine isolation, and use without the framework autoloader. The fixture files and symlinks retain their original contents.
The package tests, static analysis, and formatting checks passed locally. The PHP and Node benchmark runners were syntax-checked.
Note
Add a standalone YAML parser and document editor package
Hypervel\Yamlpackage undersrc/yaml/src/: a lexer, streaming CST parser, node composer, andYaml::parse/Yaml::dumpentry points with support for YAML 1.1, 1.2 core, JSON, and failsafe schemasDocumentand node types (Mapping,Sequence,Scalar,Pair,Set,OrderedMap,Pairs) with path-based reads and writes, anchor/alias resolution, bounded copy operations, and visitor traversalBigIntegerfor out-of-range integers,DateTimeImmutabletimestamps with sub-microsecond precision, binary base64 tags, and sexagesimal integer/float valuescomposer.jsonregisters the package dependency and autoloadingMacroscope summarized 0bde351.