# What byte-for-byte parity covers (laravel-rust-format)

> The oracle is the output of PHP running pinned upstream packages. The target is PHP 8.4 behavior for the supported functions and inputs. Treat PHP and…

- Package: laravel-rust-format (Laravel for Rust, alpha), crates: `laravel-rust-format`, `laravel-rust-format-core`
- Maintenance: active; Latest release: 0.1.1 (2026-12-04); Framework: laravel-rust 0.2.x; MSRV: Rust 1.99 or later; Licence: MIT
- Links: [Repository](https://github.com/bowerbird-si/laravel-rust-format), [crates.io](https://crates.io/crates/laravel-rust-format/0.1.1), [docs.rs](https://docs.rs/laravel-rust-format/0.1.1), [Changelog](https://oss.bowerbird.si/format/docs/changelog/), [Contributing](https://github.com/bowerbird-si/laravel-rust-format/blob/16e2c1a95c60fb32c5ee2f37b7d58a9f72be23f7/CONTRIBUTING.md), [Security policy](https://github.com/bowerbird-si/laravel-rust-format/blob/16e2c1a95c60fb32c5ee2f37b7d58a9f72be23f7/SECURITY.md)
- Based on: [Laravel Str, Number and Pluralizer](https://github.com/laravel/framework): The behaviour of Illuminate\Support\Str, Number and Pluralizer, as typed Rust functions with English defaults.; [Carbon](https://github.com/briannesbitt/Carbon): The calendar, formats and relative-time translations, on Jiff with an explicit clock instant. The generated locale tables credit the authors of each language file.; [Doctrine Inflector](https://github.com/doctrine/inflector): English inflection rules, generated into Rust tables.; [Portable ASCII](https://github.com/voku/portable-ascii): Transliteration tables for Str::ascii and Str::slug, generated into Rust tables.; [League CommonMark](https://github.com/thephpleague/commonmark): Reference behaviour for Markdown in the PHP oracle; Comrak renders Markdown in Rust.; [Ramsey UUID](https://github.com/ramsey/uuid): Reference behaviour for identifiers in the PHP oracle; the core builds them in Rust.; [Symfony UID](https://github.com/symfony/uid): Reference behaviour for identifiers in the PHP oracle; the core builds them in Rust.
- PHP parity: core (465 covered, 4 diverged, 3 planned of 472 abilities; 133,206 fixtures; follows illuminate/support 13.39.0; verified 2026-12-04)
- Used in production across multiple projects.
- Community package, not affiliated with Laravel.
- HTML version: https://oss.bowerbird.si/format/docs/parity/
- Source: https://github.com/bowerbird-si/laravel-rust-format/blob/16e2c1a95c60fb32c5ee2f37b7d58a9f72be23f7/docs/parity.md

The oracle is the output of PHP running pinned upstream packages. The target is PHP 8.4 behavior for the supported functions and inputs. Treat PHP and dependency upgrades, locale changes, and time zone data changes as changes to the reference.

## How conformance works

1. [Case files](https://github.com/bowerbird-si/laravel-rust-format/tree/main/conformance/cases/) specify calls, exact inputs and, for relative dates, a fixed clock where needed.
2. The [PHP generator](https://github.com/bowerbird-si/laravel-rust-format/blob/main/conformance/php/generate.php) dispatches to PHP or the pinned Composer packages and captures the results. It fixes the default time zone to UTC and sets `precision=14` and `serialize_precision=-1`. Tagged values preserve types, exact float bits and exceptions that plain JSON cannot express.
3. The [Rust tests](https://github.com/bowerbird-si/laravel-rust-format/tree/main/crates/core/tests/) require all three runtime fixtures and verify their case IDs against the group’s case definitions, call the Rust implementation and compare values. String comparisons preserve every byte, including non-breaking spaces and NUL. The harness also checks distinctions such as signed zero, integer versus float and array key types and order. It treats all NaNs as equal and compares exception classes.
4. The adapter’s [render fixture](https://github.com/bowerbird-si/laravel-rust-format/tree/main/conformance/render/) checks the registered filters and globals in real MiniJinja markup, including whitespace and HTML escaping. The HTML check uses the core output with MiniJinja’s escaping rules.

## Reference versions and counts

| Fixture set | PHP | ICU / ICU data | Status |
| --- | --- | --- | --- |
| `php8.4-icu76` | 8.4.27 | 76.1 / 76.1 | Checked in |
| `php8.5-icu76` | 8.5.12 | 76.1 / 76.1 | Checked in, with Unicode comparison adjustments below |
| `php8.4-icu72` | 8.4.27 | 72.1 / 72.1 | Normative reference, regenerated and checked in CI inside the pinned PHP image |

The two ICU 76 sets use Debian PHP builds with system tzdata. Their headers record Illuminate Support 13.39.0, Carbon 3.15.1, Doctrine Inflector 2.1.1 and Portable ASCII 2.1.1. The headers’ `unicode` field comes from ICU’s `IntlChar`. mbstring and PCRE2 have their own Unicode data.

Run `python3 docs/tools/stats.py` from the repository root to regenerate the counts.

Counted from the checked-in fixtures on 2026-12-04 (UTC).

| Group | `php8.4-icu72` | `php8.4-icu76` | `php8.5-icu76` |
| --- | ---: | ---: | ---: |
| `arr` | — | 250 | 250 |
| `carbon_calendar` | 5404 | 5404 | 5404 |
| `carbon_diff` | 2320 | 2320 | 2320 |
| `carbon_format` | 673 | 673 | 673 |
| `carbon_interval` | — | 520 | 520 |
| `carbon_locale` | 1868 | 1868 | 1868 |
| `carbon_period` | — | 166 | 166 |
| `number` | 1110 | 1110 | 1110 |
| `number_ext` | 10837 | 10837 | 10837 |
| `number_parse` | — | 1255 | 1255 |
| `number_spell` | — | 5023 | 5023 |
| `php` | 1158 | 2348 | 2348 |
| `php_json` | 875 | 1009 | 1009 |
| `php_sprintf` | 1709 | 1733 | 1733 |
| `php_strings` | 2774 | 2774 | 2774 |
| `php_strtotime` | — | 3162 | 3162 |
| `php_values` | 1869 | 1869 | 1869 |
| `realworld` | 1484 | 1484 | 1484 |
| `str_ascii` | 629 | 629 | 629 |
| `str_case` | 1573 | 1573 | 1573 |
| `str_pattern` | 2349 | 2349 | 2349 |
| `str_plural` | 2138 | 2138 | 2138 |
| `str_search` | 3335 | 3335 | 3335 |
| `str_stringable` | — | 925 | 925 |
| `str_transform` | 2277 | 2277 | 2277 |
| `value` | 20 | 20 | 20 |
| **Total** | 44402 | 57051 | 57051 |

## Strings

- **Unicode versions.** Core case and display width follow PHP 8.4 mbstring’s Unicode 16. PHP 8.5 mbstring moved to Unicode 17. The PHP 8.5 fixtures expose a wider trombone emoji, new Beria Erfe case mappings, the capital double thorn mapping, and a title-case boundary change after U+0295. These can affect `limit`, case helpers and `headline`. New case data also change the case of English plural suffixes for some mixed-case words. The tests adapt those comparisons to the PHP 8.5 result. The public functions keep PHP 8.4 behavior.
- **PCRE2 versions.** Core `ucsplit` and the uppercase split in `headline` use the uppercase category from PCRE2 10.44 (Unicode 15), as bundled in the pinned normative build. The Debian fixtures use PCRE2 10.45 (Unicode 16). The test harness uses the additional uppercase letters when comparing to those fixtures. The core retains the 10.44 category.
- **UTF-8 boundaries.** Rust takes UTF-8 strings. PHP can accept byte strings, and its final slug trim treats the separator as a byte mask. A custom multibyte separator can remove part of a character. For example, with transliteration disabled, slugging `café` with `©` as the separator leaves the bytes `63 61 66 C3` in PHP. Rust returns `caf�`, replacing the incomplete sequence.
- **PHP counts and coercion.** The Rust string limits take nonnegative counts. In inflection, give the length of an array or Countable explicitly. The core provides English inflection and the language tables used by Portable ASCII for transliteration.

### Search and transformations

- Rust text arguments take valid UTF-8. Callers handle PHP's mixed input coercions, including null haystacks and non-string values passed to the predicates. The array overload of `substrReplace` accepts typed PHP strings and integer offsets or lengths, with null for defaults.
- The explicit encoding helpers support UTF-8, UTF-16, UTF-32, UCS-2, UCS-4, and the PHP single-byte encodings (including aliases). Legacy multibyte and transfer encodings such as SJIS, Big5, UTF-7, and Base64 return `ErrorKind::Unsupported`.
- `is`, `excerpt` and `is_url` use UTF mode and Unicode character classes, as Laravel does. The bundled Rust PCRE2 10.46 uses Unicode 16.0. The reference PHP 8.4.27 uses PCRE2 10.44 with Unicode 15.0. Unicode 16 added U+1C89 and U+1C8A as a case pair, so Rust matches `is_with("Ᲊ*", "ᲊ", true)` and `excerpt("before ᲊ after", "Ᲊ")`. The reference build misses both. Rust also accepts `https://Ᲊ.example` because its URL pattern sees U+1C89 as a letter. Other Unicode property or case-folding changes and differences in PCRE resource limits can affect results.
- `is_url_with` treats the protocol list as raw PCRE alternatives per Laravel. PHP warnings for invalid expressions become a false result.
- `is_json` applies PHP's 512 depth argument, so at most 511 arrays and objects can be nested. It accepts numbers with exponents outside Rust floating-point range and validates surrogate pairs without decoding the document.
- `counted` uses the crate's English number and pluralization rules. Pass the length of a Rust collection for a PHP countable argument.
- Case conversion and masking use UTF-8. These APIs do not expose mbstring's alternate encodings or PHP's implicit scalar coercions. Replacement helpers accept typed strings and slices, and `replace_array` accepts null entries through `Option<&str>`.
- `word_count` follows PHP's default C locale and treats custom characters as bytes. Unicode-aware reversal, masking, padding and wrapping count Unicode scalars.
- The reference case profiles are PHP 8.4 mbstring with Unicode 16 and PCRE2 10.44 with Unicode 15. The local PHP builds link PCRE2 10.45 with Unicode 16, adding Garay lowercase matches to `ucwords` and Garay case equivalence to case-insensitive replacement. PHP 8.5 mbstring uses Unicode 17, including new Beria Erfe and double thorn mappings and different title boundaries around U+0295. The fixture runner adapts the known differences explicitly.
- Non-strict transliteration uses voku/portable-ascii 2.1.1 tables. Rust computes each call independently, so it follows the uncached PHP pipeline when a prior call would affect voku's warm map. Strict transliteration requires a caller-supplied ICU adapter configured for `NFKC; [:Nonspacing Mark:] Remove; NFKC; Any-Latin; Latin-ASCII;`. Production uses ICU 72. The adapter returns errors to Rust callers.
- `flush_cache` is a no-op. The casing transforms keep no mutable caches.

### Fluent strings, splitting and scanning

- `Stringable` accepts UTF-8 string inputs. Use PHP helpers for raw byte outputs.
  A split, scan, trim or Base64 decode which would leave invalid UTF-8 in the fluent
  API returns an error. `php::preg_split` keeps arbitrary bytes.
- Invalid regexes return an error. Laravel's `Stringable::split` can return an
  empty collection after a PHP warning. An integer pattern uses `split_chars`
  and a delimited regex uses `split`. Regex work and output follow `RegexLimits`.
- `scan` implements PHP's collection-returning scan, using PHP's byte widths,
  NUL termination, numeric field limit and null fields. PHP's form that mutates
  reference parameters is outside this API. Format validation and results are bounded.
- `to_boolean` implements `FILTER_VALIDATE_BOOLEAN`. For example, `"false"` and
  `"00"` return false even though `php::boolval` returns true for them.
- Fluent methods use the string helper defaults. `new_line` uses LF, as on the
  reference runtime. `convert_case` and `mask` use UTF-8. See the `Stringable`
  rustdoc for the Laravel methods without a fluent equivalent.

### Regex

The core uses the same regex engine as PHP through safe `pcre2` bindings. This brings a native dependency. `pcre2-sys` can use PCRE2 discovered through `pkg-config` or compile its bundled
PCRE2 with a C toolchain. Use `PCRE2_SYS_STATIC=1` for the tested bundled 10.46 build. The reference
PHP 8.4.27 uses PCRE2 10.44 with Unicode 15.0. Debian's PHP 8.4 and 8.5 use PCRE2 10.45
with Unicode 16.0. The ICU version in the fixture directory identifies the PHP build.

Patterns use byte offsets. Without `u` or a leading `(*UTF)` (also spelled `(*UTF8)`), PCRE
interprets the pattern and subject byte by byte. For example, `/^..$/` matches `é`, and `/^é$/i`
matches `é` but misses `É`. The `u` modifier enables UTF mode and Unicode character classes.
An explicit `(*UTF)` enables UTF mode, and `(*UCP)` selects Unicode character classes independently.

In byte mode, Rust preserves the reference build's Script_Extensions sets for the 16 scripts that gained
U+00B7 MIDDLE DOT in Unicode 16. For example, Debian PHP matches `\p{Greek}` against the byte
`B7` inside the UTF-8 bytes `CE B7` for `η`. The reference build and Rust miss. The fixtures record
the Debian difference for the affected byte-mode cases. The script sets come from the Unicode
15.0 and 16.0 data.

In UTF mode Rust follows the linked PCRE2 Unicode tables. With bundled PCRE2 10.46 it matches
U+00B7 with `\p{Greek}`, recognizes U+1C89 as a letter, and folds U+1C89 and U+1C8A together.
Those results differ from the reference build. Other properties and folds changed between Unicode
versions can also differ. Older system builds may reject `r` or use different Unicode classes
and boundaries. PCRE resource limits and locale tables follow the linked engine, independently
of PHP's runtime INI or locale configuration.

The supported suffix modifiers are `i`, `m`, `s`, `u`, `x`, `J`, `U`, `n` and `r`. `S` and `X`
are accepted compatibility flags. The safe builder lacks PHP's `A` and `D` compile options, so those
modifiers give `ErrorKind::Unsupported`. Delimiters are ASCII punctuation, including PHP's paired
delimiters. Invalid patterns return an error where PHP emits a warning and returns a fallback.
An invalid pattern encountered before a match therefore stops a pattern-list search. PHP's `u`
rejects `\C`; the Rust check can also reject that token in extended-mode comments. After an empty
match, the compatibility retry anchors the whole expression with a noncapturing wrapper. In a
whole-pattern recursive expression such as `(?R)`, this wrapper can change the recursion on retry.

Input strings are UTF-8. Byte-mode matching and numeric replacements operate on bytes internally.
A returned capture or final replacement that cannot be represented as UTF-8 gives a typed error.
For array subjects, map the replacement helper across the Rust collection to retain its keys.
Callback captures expose numbered and named groups. PHP's associative `MARK` metadata and the
arbitrary scalar coercion of PHP arguments are outside this API.

### Markdown

Laravel 13.39.0 uses League CommonMark's GFM converter for block Markdown. Its inline path uses
GFM with the inlines-only extension, which disables most block syntax but retains the table
extension. The compatibility renderer has nine recorded output differences. The comparison against League CommonMark 2.10.7 used 652 CommonMark 0.31.2 examples, 30 pinned cmark-gfm extension
examples, 20 curated inputs and six option cases per method.

The compatibility renderer matched 704 of 708 block cases and 703 of 708 inline cases.
It adjusts task inputs, HTML handling, URLs, image alt text and inline block behavior.

The exact PHP and Rust HTML for each case is checked in
[`conformance/tools/str_pattern_markdown_differences.json`](https://github.com/bowerbird-si/laravel-rust-format/blob/main/conformance/tools/str_pattern_markdown_differences.json).

- CommonMark 602, both modes. Comrak autolinks the URL portion inside an invalid angle-bracket autolink containing a space. League CommonMark leaves it literal.
- GFM 019, both modes. Bare autolinks differ around quoted URLs, trailing punctuation in parentheses, host underscore and emoji handling, attached `mailto:` and `xmpp:` prefixes, and Unicode serialization in bare hrefs.
- GFM 020, both modes. League CommonMark recognizes the email-like input with underscores as an autolink. Comrak parses part of it as emphasis.
- Numeric references, both modes. For `&#57344;0&#57345;`, Comrak replaces U+E000 with U+FFFD. League CommonMark preserves U+E000.
- CommonMark 082, inline mode. Comrak removes a literal tab at the end of the line before the soft break.

League CommonMark options besides the exposed three, and PHP extension instances, are unavailable.
Inline mode adapts a block-capable parser, so additional differences are possible where inline
syntax spans lines that could open blocks, particularly multiline code, references and raw HTML.

The CommonMark 0.31.2 and cmark-gfm extension examples are adapted under CC BY-SA 4.0.
See [NOTICE](https://github.com/bowerbird-si/laravel-rust-format/tree/main/NOTICE) for attribution.

### Entropy and identifiers

The PHP oracle checks 24 samples per random case for length, allowed characters and coverage of
enabled password pools. When the length is shorter than the number of pools, Laravel chooses a
subset, using each chosen pool once. An all-disabled selection raises an error even at length zero.
For UUIDs and ULIDs the oracle checks uniqueness, alphabets, timestamp prefixes, version and variant
bits where applicable, and strict same-millisecond ordering for UUIDv7 and ULID. The exact sampled
IDs and password contents are deliberately excluded from fixtures.

The Rust implementation uses `getrandom` for OS entropy, unbiased sampling, and small explicit
encoders. A single generator increments its UUIDv7 and ULID entropy fields within a millisecond.
This preserves the ordering property. Ramsey's internal UUIDv7 generator uses random increments,
so the increments and sequences are different. In Rust, a changed explicit timestamp starts a new
sequence. Independent convenience calls have independent entropy and state. Ordered UUIDs are v4
COMBs with a leading 48-bit timestamp in 10-microsecond ticks, and only sort by tick. Rust rejects
timestamps outside the unsigned 48-bit range, including dates before the Unix epoch.

## Numbers

- English helpers include formatting, spellout, parsing and ranges. Use an explicit `number::Locale` for localized decimals, percentages, currencies, parsing, spellout and ordinals. Locale and currency settings are values owned by the caller.
- The core includes ICU 72.1 (default) and ICU 76.1 tables. The decimal, percentage, currency, spellout and parsing tables are generated from each runtime. Installing ICU locally does not change the selected data. Use `IcuData::Icu76` to match that runtime. See the [conformance guide](https://github.com/bowerbird-si/laravel-rust-format/blob/main/conformance/README.md#runtimes).
- Float text from `echo` and `strval` uses PHP’s default `precision=14`. JSON uses shortest round-tripping decimal output at `serialize_precision=-1`.
- `Number::pairs` returns an error when the floating-point step cannot advance. Iterating such a range in PHP could fail to terminate.

### Localized numbers and parsing

Decimal, percentage and currency output covers all 869 locale IDs from ICU 76.1 (including their default digit sets) and currency overrides from its public bundles. Locale IDs support hyphens and case variants. ICU alias resolution, arbitrary locale fallback and numbering-system keywords such as `en-u-nu-arab` are outside the table lookup and return `Unsupported`.

Locale parsing uses the selected decimal and exponent symbols, Unicode digits and ICU's accepted separator and sign variants. Grouping widths still apply to the numeric prefix. For example, French `1 234,50 kg` parses as 1234.5 and `12 34` returns `None`. Parse failure maps PHP's `false` to `None`. An integer parse of the locale's NaN token can return the signed minimum.

The default spellout and ordinal tables cover `ar`, `ar_EG`, `bn`, `cs`, `da`, `de`, `de_CH`, `el`, `en`, `en_AU`, `en_CA`, `en_GB`, `en_IN`, `en_US`, `es`, `es_MX`, `fa`, `fi`, `fr`, `fr_CA`, `fr_CH`, `he`, `hi`, `hi_IN`, `id`, `it`, `ja`, `ko`, `nb`, `nl`, `pl`, `pt`, `pt_BR`, `pt_PT`, `ru`, `sv`, `th`, `tr`, `uk`, `vi`, `zh`, `zh_Hans` and `zh_Hant`. Enable `number-locale-all` for the other bundled ICU locale IDs. Each runtime supplies its own rule sets and locale fallbacks. For example, ICU falls back to English spellout for Bengali and to ordinary spellout for French spelled ordinals. English India uses lakh and crore where its rules select them. With a locale outside the compiled spellout set, spelling and ordinal operations return `Unsupported`. Threshold-triggered decimal formatting works across the decimal table. Spelled ordinals have no thresholds.

The rule interpreter targets the shipped PHP ICU formatting rules. Custom rule text, arbitrary rule-set selection and parsing spelled numbers are outside the public API. ICU handles very large floating-point values differently from exact integers in spellout. For example, English 10¹⁸ as an integer displays as grouped digits, while the same value as a float uses ICU's bounded substitution and spells an amount based on 2⁵⁴.

## PHP values and formatting

- **PHP 8.5 precision syntax.** A bare dot in a floating-point `sprintf` directive, such as `%.f` or `%.g`, uses the default precision in PHP 8.4 and zero in PHP 8.5. The public Rust API follows 8.4. The 8.5 conformance cases with a bare dot compare against explicit zero precision in Rust. Write `.0` to request that spelling on either runtime.
- **Locale and bytes.** `sprintf` uses the C locale. PHP string precision, field width and character conversion count bytes. Use `sprintf_bytes` or `fprintf` when the result can include invalid UTF-8. `printf` and `vprintf` accept UTF-8 sinks. Input strings and keys in the shared value model are UTF-8.
- **JSON and arrays.** The same ordered array may encode as a list or object depending on its keys. The default depth is 512. The partial-output flag allows deeper output and substitutes values for nonfinite floats and recursive members. `json_encode_bytes` supports a standalone byte string, including the invalid-UTF-8 flags. Nested strings and keys use the UTF-8 value model. The JSON flags and cast rules are listed in the [PHP functions guide](https://oss.bowerbird.si/format/docs/php-functions/).

- **Laravel join.** An array or collection with one item and nonempty final glue returns the item in its original type. Collection field lookup supports PHP arrays in the shared value model. PHP objects and callback arguments are outside that model.

### PHP string functions

- Borrowed `&str` input guarantees valid UTF-8. PHP's invalid-input handling via `ENT_SUBSTITUTE` and `ENT_IGNORE` has no effect on that input. HTML and mbstring use UTF-8. The caller supplies application defaults such as the query separator when they differ from PHP's standard defaults.
- `AsPhpValue` supplies UTF-8 scalars and arrays. The caller resolves Laravel Htmlable values, deferred displayable values and backed enums before calling `e`. Object properties and cyclic arrays are outside the query builder's array model.
- `str_word_count` uses PHP's C-locale rules and format 0. `strtr` supports the replacement array form. PHP warnings and deprecations, including malformed character-mask warnings and the negative-width deprecation in `mb_strimwidth`, have no Rust diagnostic.
- `md5` and `sha1` are outside this module's dependency-free scope. `crc32` returns the unsigned 32-bit checksum that 64-bit PHP exposes as a positive integer.
- The HTML entity and mbstring width data were measured against PHP 8.4.27. Local PHP 8.5.12 widens 157 additional scalars, including U+1FAEF, from one column to two. This affects width measurement and truncation. The Rust helpers use the PHP 8.4 widths.

## Dates

- **Zero offset identity.** Jiff normalizes a fixed zero offset to UTC. As a result `e` and `T` can report `UTC` where PHP can preserve a fixed `+00:00` and `GMT+0000`, or its separate `Z` identity. A nonzero fixed offset retains its offset.
- **Time zone data.** Named zones use Jiff’s available IANA data. PHP’s time zone build and Jiff’s data source may use different versions or historical records. The daylight-saving flag (`format('I')`, `dst`, and the DST corrections in `diff`) does not depend on how the host compiled its data. Zones with negative daylight saving time are Europe/Dublin since 1971, Africa/Casablanca and Africa/El_Aaiun since 2018, Africa/Windhoek from 1994 to 2017, and Europe/Prague in the winter of 1946–47. In the default “vanguard” form these periods carry the flag. Some distributions and Jiff’s bundled database use the “rearguard” form, where the flag is on the other half of the year. The crate detects the form per zone and reports what PHP’s vanguard-based database reports. Offsets are another matter. At midnight on 1880-01-01 in Europe/Amsterdam, the system databases returned `AMT` at 1172 seconds east of UTC. Jiff 1.1.0’s bundled database, where Amsterdam links to Brussels, returned `BMT` at 1050 seconds east of UTC. Compare the deployed tzdata if historical offsets are part of your contract.
- **Offset seconds.** PHP can carry seconds in a fixed offset. For the RFC 9557 test annotations with offset seconds, the harness constructs a Jiff fixed zone explicitly instead of parsing those annotations as minute-precision Temporal offsets.
- **Range and precision.** The input must fit in the relevant Jiff type. PHP may represent more years. Date formatting truncates nanoseconds to the applicable microseconds or milliseconds. Carbon’s `toISOString()` rejects local year zero, represented by `Ok(None)` in Rust. English is the default locale.

### Free-form date grammar

`php::strtotime`, `php::date_create`, `carbon::parse` and `carbon::modify` use the
same grammar. Each takes a caller-supplied clock or receiver. The grammar follows
the [PHP date and time formats manual](https://www.php.net/manual/en/datetime.formats.php)
and tests compare PHP's output in both local runtimes.

| Constructs | Supported forms |
| --- | --- |
| Numeric dates | ISO basic and extended calendar dates, signed four-digit years, US month/day[/year], year/month/day, GNU year-month, European day-month-four-digit-year and dotted day/month/year forms |
| Textual dates | English full and abbreviated months, Roman months in calendar expressions, day ordinals, month/year, year/month, month/day, day/month, and three-field dates with a textual month |
| ISO weeks and ordinal dates | Basic or extended `YYYYWww` with an optional weekday, and `YYYYDDD` or `YYYY.DDD` |
| Clock | 12-hour am/pm with optional periods, hour-only forms with am/pm, 24-hour colon, dot and compact forms, a `T` prefix, fractional seconds, and the MS SQL fractional meridiem form |
| Offsets and zones | `Z`, `±H`, `±HHMM`, colon offsets, offset seconds, uppercase `GMT` followed by an offset, PHP's selected offsets for zone abbreviations, and named zones in Jiff's database |
| Compound dates | MySQL, SOAP, XML-RPC, EXIF, WDDX, Common Log Format, RFC 822/850/1036/1123/2822/3339/7231, ATOM, COOKIE, RSS and W3C spellings |
| Relative clock | `now`, `today`, `midnight`, `noon`, `tomorrow`, `yesterday`, `front of` and `back of` |
| Relative units | Signed quantities and English ordinal or direction words. Years, months, weeks, fortnights, days, weekdays, hours, minutes, seconds, milliseconds and microseconds. `ago` negates accumulated relative fields. |
| Relative weekdays and month boundaries | Weekdays alone, counted and ordinal weekdays, `last/this/next week` with or without a weekday, `first/last day of`, and `first/second/…/last <weekday> of` the current or a supplied month |
| Unix time | `@<seconds>`, with up to six fractional digits in the PHP grammar. Carbon's constructor also handles numeric strings and its own `@` timestamp conversion. |
| Normalization | Day and month zero, day overflow within 0–31, hour 24, leap seconds, month-end relative rollover, and PHP's upper/lower fold selection for the tested named zones |

A complete date with no time defaults to midnight. `modify` instead keeps the
receiver's time unless the expression sets it. An embedded zone normally overrides
the constructor's zone. A frozen Carbon parse of a clock-dependent expression goes
through Carbon's modification semantics, which keep the receiver's zone except for
`@` timestamps. `strtotime` reads missing wall fields in the default zone even
when the expression carries a different output zone. `date_create` reads those
fields in the effective output zone.

The `php_strtotime` oracle uses native `strtotime($text, $baseTimestamp)` and passes
the frozen receiver directly to native `modify` and Carbon's constructor. It
calls native `date_create` for fully specified dates. PHP exposes no clock argument
for `date_create`, so for incomplete expressions the oracle uses `date_parse` to
choose the effective zone, then freezes seconds with `strtotime` and reads the
fraction from `modify`. For fixed offsets, it adjusts the frozen base to UTC wall
fields before the `strtotime` call. The modifier's embedded zone is irrelevant
when reading its fractional field. The oracle drops the inherited fraction when
the constructor supplies a date or time and accounts for subsecond carry.

Known limits:

- The free-form grammar is English. Carbon's locale-specific parsers and the
  additional natural-language rewrites in Carbon's `change()` fallback are outside
  this API.
- Jiff's civil and timestamp range excludes PHP's five-or-more-digit expanded
  years and some timestamps PHP represents as 64-bit integers. Large relative
  amounts that exceed the supported range fail.
- Abbreviations preserve their effective offset. The returned Jiff date does
  not retain PHP's abbreviation identity or daylight-saving metadata for a fixed
  abbreviation. Named zones depend on the host's available IANA records. Some
  aliases accepted by a PHP `DateTimeZone` argument are outside PHP's free-form
  zone syntax. Offsets outside Jiff's supported range fail.
- PHP warnings are not returned. For example, PHP treats an otherwise unknown
  short word after a valid zone as a duplicate zone warning and can still accept
  the expression. PHP's byte-level quirks around repeated signs, uncommon
  punctuation, and combinations of several competing calendar or month-boundary
  tokens are outside the guaranteed grammar.
- RFC 9557 zone annotations are a `carbon::parse` extension. They use Jiff's
  annotation rules. The two PHP functions use PHP zone syntax.

Regenerate the cases with `python3 conformance/tools/php_strtotime.py`, followed by
`conformance/generate.sh php_strtotime`. The time zone abbreviation offsets come
from PHP's public timezone APIs via `conformance/tools/php_date_zones.php`.

### Calendar and locale

- The calendar follows Carbon's default English week (Monday to Sunday), weekend (Saturday and Sunday), and month overflow. Rust callers can choose the boundary weekday or no-overflow arithmetic explicitly. PHP's global settings, anchor-day overflow mode and locale-specific weekend settings are outside this API.
- Calendar functions use Jiff's civil date and timestamp ranges. A date calculation that cannot be represented returns an error. PHP supports years beyond Jiff's civil range of `-9999..=9999`.
- Typed inputs replace PHP's date strings, numeric-string coercions, interval strings and modifier strings. Use `PhpNumber` for amounts, `Span` for intervals and Jiff `Weekday` for weekday modifiers. `next()` and `previous()` take an explicit weekday. The functions that compare with now require an explicit reference date.
- `is_same_unit()` compares each operand's own wall-clock fields, so repeated local hours can match even when their instants differ. `eq()` compares instants. `is_long_year()` checks the Gregorian year, while `is_long_iso_year()` checks the ISO week year.
- Carbon's `decade` property numbers decades by rounding year/10 up. The decade boundary methods use calendar decades starting in years that end in zero.
- PHP can return an integer or float for `offsetHours`. Rust returns `f64`. The filtered difference functions return integers, and `diff_in_unit` casts them to float, like PHP. `timestamp_float` expresses Unix seconds via Carbon's precise microsecond timestamp.
- `average()` reproduces Carbon’s pre-epoch sign behavior when it rebuilds a negative Unix second with a positive fractional component.
- `nth_of_*` returns `None` for Carbon's false. Carbon accepts a negative `nthOfQuarter()` result in an earlier quarter of the same year.
- The default locale data covers `ar`, `cs`, `da`, `de`, `el`, `en`, `en_GB`, `es`, `fi`,
  `fr`, `he`, `hi`, `id`, `it`, `ja`, `ko`, `nb`, `nl`, `pl`, `pt`, `pt_BR`, `ru`, `sv`,
  `th`, `tr`, `uk`, `vi` and `zh_CN`. Enable `carbon-locale-all` for all 824 shipped codes.
  Other codes fall back through installed parents to English. `auto` is English.
- Locale data is pinned to Carbon 3.15.1. Custom translators, caller-defined aliases, custom
  calendar patterns, and the optional second argument to `isoFormat` are outside the Rust API.
- `diff_for_humans_in` uses Carbon’s default one-part options. `DiffForHumans::locale` applies options to the selected locale’s units, list punctuation and relative wording. Calendar references are plain dates or times without an independently selected locale.

### Intervals and periods

- Interval construction supports explicit integer fields, ISO duration designators
  and compact English unit definitions. It covers the standard Carbon fractional
  duration forms. PHP's alternative date-shaped duration syntax and natural-language
  relative phrases such as `next Monday` are outside this parser.
- Cascade factors are local positive integer ratios for adjacent units. Arbitrary
  graphs, disabled edges and global Carbon settings are outside this API.
- Period builders use an explicit start. Period text uses English, and ISO output
  follows Carbon's offset spelling and omits the implicit step. The format also
  omits exclusion flags, step signs and fractional seconds. Carbon's filter callbacks, custom translators and interval step closures are outside this API.
  Iteration needs a recurrence count, end or caller cap. Returning dates as a vector
  is subject to the crate's collection budget. Iteration stops at the Jiff range boundary.
- A Jiff span has a single sign and a limited field range. Period steps use that
  representation. Carbon interval fields can also be mixed-sign, and converting
  those fields to a Jiff span returns an error.

### Date constructors

The PHP fixture for RFC 9557 zone annotations sets the zone explicitly after parsing the instant. For format-driven parsing, rare time zone abbreviations and extended years are limited by the documented grammar and Jiff’s range.

## Template boundaries

MiniJinja has its own HTML escaping rules. Compare formatter text before escaping when verifying PHP parity, and compare the final HTML separately. `php_round` preserves the float type. Pipe it to `php_echo` for PHP numeric text. See the [template reference](https://oss.bowerbird.si/format/docs/templates/) for missing values, errors and date parsing.

## Randomized comparison

With PHP 8.4, Composer, Rust, Python 3 and the Linux timeout/prlimit commands, run these commands from the project root.

    php8.4 "$(command -v composer)" install --no-interaction --working-dir=conformance/php
    python3 conformance/random/prepare.py
    PCRE2_SYS_STATIC=1 nice -n 10 cargo build --locked --release --manifest-path conformance/random/Cargo.toml --target-dir target
    python3 conformance/random/run.py --seed 760084 --count 4000

The default is 200,000 comparisons split across numbers, strings, dates and values. The default seed is the current UTC date in YYYYMMDD form. Use `--family` to restrict the run. Use `--replay` with a JSONL file of cases including their group to rerun a finding. Set `PHP84` to the PHP 8.4 command and `PARITY_WORKER` to the compiled Rust worker if they live at different paths. Run the Compatibility workflow on demand in GitHub Actions to use the production PHP 8.4/ICU 72 container and Composer lock.

The harness compares tagged outputs including float bits, ordered arrays and exception classes. Its allowlist recognizes known Unicode differences in PCRE2, UTF-8 output boundaries where PHP emits byte strings, and Carbon's mock-clock shift in a folded hour when replaying the effective instant explains the full result. Other mismatches fail the job and print reduced case JSON by group.

Community package, not affiliated with Laravel.
