Skip to content

feat(php): add native PHP implementation and composer package - #285

Merged
konard merged 5 commits into
mainfrom
issue-284-ed60ce81c8a6
Aug 20, 2026
Merged

feat(php): add native PHP implementation and composer package#285
konard merged 5 commits into
mainfrom
issue-284-ed60ce81c8a6

Conversation

@konard

@konard konard commented Aug 20, 2026

Copy link
Copy Markdown
Member

Closes #284

Adds a native PHP implementation of Links Notation and prepares the
link-foundation/links-notation package for Composer/Packagist, following the
structure of the existing JavaScript, Python, Rust, Go, Java and C# ports.

What is added

  • php/src/ — native port of the parser and formatter:
    • Parser — full lino parser (inline links, parenthesized groups, significant
      indentation, indented-id syntax, multi-quote strings, multiline quoted
      references, nested indentation contexts inside parentheses per Indentation is structural at the root but ignored inside ( ), so parenthesised groups cannot express nested records #282), with
      input size and depth limits
    • Link — link data structure (format, equals, simplify, combine,
      escapeReference, …)
    • Formatter — document formatting
    • FormatConfig — formatting options (line length, inline ref count,
      grouping, indent string, prefer-inline)
    • ParseException — parse error type
  • php/composer.json — Composer package link-foundation/links-notation
    (PSR-4 LinkFoundation\LinksNotation\, PHP >= 8.1, ext-mbstring,
    Unlicense, version 0.1.0) with test, lint and lint:fix scripts
  • php/tests/ — PHPUnit suite ported 1:1 from the Python test suite
  • .github/workflows/php.yml — lint (PSR-12 via PHP_CodeSniffer), test matrix
    on PHP 8.1/8.2/8.3/8.4, Packagist publish (skipped when the version is
    already published or when the Packagist secrets are absent) and GitHub
    release with the repo-standard php_<version> tag
  • php/README.md, php/README.ru.md, PHP entries in the root README.md /
    README.ru.md, and a CHANGELOG.md note
  • examples/php/quick_start.php — runnable version of every README snippet

How to reproduce / verify

cd php
composer install
composer run-script test   # PHPUnit
composer run-script lint   # PSR-12
php ../examples/php/quick_start.php

Automated tests

The PHP suite is a direct port of the Python one, so behaviour parity is
checked rather than assumed: single-line parsing, nested parsing, multiline
documents, multi-quote strings, multiline quoted strings, edge cases, nested
indentation (#282), nested self-references, indented-id syntax, indentation
consistency, mixed indentation modes, Link/FormatConfig unit tests and API
tests.

Local run: OK (173 tests, 469 assertions), phpcs clean.

Packagist note

Repository release tags use the php_<version> format, which Packagist cannot
parse as a version, so composer.json keeps an explicit version field and CI
validates with composer validate --strict --no-check-version. Publishing
requires the PACKAGIST_USERNAME and PACKAGIST_TOKEN repository secrets; the
publish step is skipped with a message when they are not configured.

Adding .gitkeep for PR creation (default mode).
This file will be removed when the task is complete.

Issue: #284
@konard konard self-assigned this Aug 20, 2026
konard added 3 commits August 20, 2026 05:31
- add php/README.md and php/README.ru.md
- link the PHP implementation from the root READMEs
- add examples/php/quick_start.php covering every documented snippet
- add .github/workflows/php.yml (lint, test matrix 8.1-8.4, Packagist publish, release)
- note the PHP implementation in CHANGELOG.md
@konard konard changed the title [WIP] Add native PHP support, and prepare links-notation package in composer feat(php): add native PHP implementation and composer package Aug 20, 2026
@konard
konard marked this pull request as ready for review August 20, 2026 05:41
@konard

konard commented Aug 20, 2026

Copy link
Copy Markdown
Member Author

Working session summary

The PHP port is complete and PR #285 is ready for review: #285

What landed (3 commits on issue-284-ed60ce81c8a6, 32 files, +4270 lines, nothing removed):

  • php/src/ — native Parser, Link, Formatter, FormatConfig, ParseException (namespace LinkFoundation\LinksNotation), covering inline links, parenthesized groups, significant indentation, indented-id syntax, multi-quote strings, multiline quoted references, and the nested-parenthesis indentation semantics from Indentation is structural at the root but ignored inside ( ), so parenthesised groups cannot express nested records #282, with input-size/depth limits.
  • php/composer.json — Composer package link-foundation/links-notation, PSR-4, PHP ≥ 8.1 + ext-mbstring, Unlicense, version 0.1.0, with test/lint/lint:fix scripts.
  • php/tests/ — 15 PHPUnit classes ported 1:1 from the Python suite. Local and CI: 173 tests, 469 assertions, all passing; phpcs (PSR-12) clean.
  • .github/workflows/php.yml — same shape as the other language workflows: changed-file detection, lint, test matrix 8.1/8.2/8.3/8.4, Packagist publish (skipped when the version is already published or the secrets are missing), release tagged php_<version> titled [PHP] <version>.
  • Docs: php/README.md, php/README.ru.md, PHP badge row + Quick Start in both root READMEs, CHANGELOG.md entry, and examples/php/quick_start.php — I ran that example and verified every documented snippet's output rather than asserting it.

CI on the pushed head e02e848: findChangedPhpFiles, lint, test (8.1–8.4) and check-bom-consistency all pass; publishToPackagist/publishRelease correctly skip on a PR branch. main was already merged (no divergence), working tree is clean, and there are no comments on the issue or PR to address.

One thing worth your decision: publishing to Packagist needs PACKAGIST_USERNAME and PACKAGIST_TOKEN repository secrets, which I cannot set. Until they exist the publish step exits 0 with a skip message. Also, because release tags here use the php_<version> format that Packagist cannot parse as a version, composer.json keeps an explicit version field and CI validates with composer validate --strict --no-check-version.


This summary was automatically extracted from the AI working session output.

@konard

konard commented Aug 20, 2026

Copy link
Copy Markdown
Member Author

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost: $7.870472

📊 Context and tokens usage:

Claude Opus 5: (3 sub-sessions)

  1. 114.9K / 1M (11%) input tokens, 30.3K / 128K (24%) output tokens
  2. 111.8K / 1M (11%) input tokens, 39.5K / 128K (31%) output tokens
  3. 51.0K / 1M (5%) input tokens, 4.8K / 128K (4%) output tokens

Total: (4.4K new + 236.5K cache writes + 6.4M cache reads) input tokens, 90.9K output tokens, $7.870472 cost

🤖 Models used:

  • Tool: Anthropic Claude Code
  • Requested: opus (claude-opus-5)
  • Thinking level: medium (~15999 tokens)
  • Model: Claude Opus 5 (claude-opus-5)

📎 Log file uploaded as Gist (2813KB)


Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard

konard commented Aug 20, 2026

Copy link
Copy Markdown
Member Author

✅ Ready to merge

This pull request is now ready to be merged:

  • All CI checks have passed
  • No merge conflicts
  • No pending changes

Monitored by hive-mind with --auto-restart-until-mergeable flag

@konard
konard merged commit 5e2070a into main Aug 20, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add native PHP support, and prepare links-notation package in composer

1 participant