Skip to content

Language features & cross-implementation parity - #1

Merged
issadicko merged 1 commit into
mainfrom
feat/language-features-and-parity
Jul 24, 2026
Merged

Language features & cross-implementation parity#1
issadicko merged 1 commit into
mainfrom
feat/language-features-and-parity

Conversation

@issadicko

Copy link
Copy Markdown
Owner

Brings the PHP SDK to full feature parity with the Go, Kotlin, and TypeScript engines. Verified against the shared compliance-tests suite — all features/*.kodi now produce byte-identical canonical output across all five SDKs.

Note: the PHP compliance runner previously had a hardcoded category list that excluded features/, so the new tests never ran. This PR adds 'features' to that list.

What's added

  • Operators: compound assignment (+= -= *= /=), ++/--, ternary ?: (right-assoc), spread ....
  • Control flow: break, continue, else if, try/catch.
  • Functions: named declarations fn name() {}, method-call syntax (receiver.method(args) with chaining), spread arguments.
  • Destructuring: let [a, b] = ... and let {x, y} = ....
  • Lexer: backtick strings, block comments /* */.
  • Stdlib: some/every/flatMap/findIndex, sum/avg/range/unique/flatten/push/concat, keys/values/entries/has, parseInt/parseFloat, regexMatch/regexReplace.
  • Canonical formatting: whole numbers without trailing .0, [1, 2, 3], sorted-key {a: 1, b: 2}, consistent in print/+/templates.
  • Robustness: recursion guard (cap 1000 → maximum call depth exceeded), safe arithmetic (division/modulo by zero surface as catchable runtime errors).
  • API: withOutput(callable) streaming; typed ErrorKind enum (none/parse/runtime/timeout/max_operations) on ScriptResult.

Verification

  • Compliance runner: 39 passed, 0 failed, 0 skipped (all 9 new features/* + 30 pre-existing).
  • PHPUnit: OK (26 tests, 84 assertions) — no regressions.
  • Byte-exact probe vs the canonical .out files: exact match on every feature file.
  • Clean under error_reporting=E_ALL on PHP 8.5.
  • Mirrors the canonical Go implementation; compliance-tests/ was not modified.

Bring the PHP SDK to full feature parity with the Go, Kotlin, and
TypeScript engines, verified against the shared compliance-tests suite
(all features/*.kodi now produce byte-identical canonical output).

Lexer: compound-assign (+= -= *= /=), ++/--, block comments /* */,
  backtick strings, spread (...), ternary ?/:.
Parser: break/continue, compound-assign & inc/dec desugaring, right-assoc
  ternary, try/catch, named fn declarations, else-if, spread in arrays &
  call args, array/object destructuring, multiline object literals.
Interpreter: method-call syntax (receiver.method(args) with chaining),
  higher-order builtins (map/filter/reduce/find/findIndex/some/every/
  flatMap), try/catch (catches real errors only), spread, destructuring,
  break/continue, recursion guard (cap 1000 -> "maximum call depth
  exceeded"), safe arithmetic (division/modulo by zero throw), canonical
  value->string formatting.
Natives: canonical Stringify (no trailing .0, [1, 2, 3], sorted-key
  {a: 1, b: 2}, unquoted string elements); added sum/avg/range/unique/
  flatten/push/concat, keys/values/entries/has, parseInt/parseFloat,
  regexMatch/regexReplace, some/every/flatMap.
API: withOutput(callable) streaming; ErrorKind enum (none/parse/runtime/
  timeout/max_operations) on ScriptResult.
Tests: compliance_runner.php now includes the 'features' category.
@issadicko
issadicko merged commit df3bb58 into main Jul 24, 2026
6 checks passed
@issadicko
issadicko deleted the feat/language-features-and-parity branch July 24, 2026 23:35
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.

2 participants