Skip to content

Reject a trailing lowercase t in Duration::parse() - #147

Open
gnutix wants to merge 2 commits into
brick:mainfrom
gnutix:fix/duration-parse-lowercase-t
Open

gnutix wants to merge 2 commits into
brick:mainfrom
gnutix:fix/duration-parse-lowercase-t

Conversation

@gnutix

@gnutix gnutix commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Item 7 of #137.

Problem

The pattern is case-insensitive, but the check that a T must be followed by a time field compared the captured separator with 'T' exactly, so a lowercase t got through:

Duration::parse('P1DT'); // DateTimeParseException (correct)
Duration::parse('P1Dt'); // PT24H (expected DateTimeParseException)

Change

The check now tests whether the separator was captured at all ($t !== ''), whatever its case.

New failure cases P1Dt, p1dt and -P1Dt, and a valid all-lowercase case p1dt2h, in DurationTest.

CI

The last commit is #133's Install tzdata-legacy in CI, cherry-picked: the ubuntu-26.04 runner image no longer ships legacy zone names such as CET and Asia/Rangoon, so PHPUnit fails on every branch based on main (#143 and #144 too). It is the same change as in #133, so it merges cleanly whichever lands first.

🤖 Generated with Claude Code (Opus 5.5)

@codecov

codecov Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.24%. Comparing base (81915a3) to head (963bb3b).

Additional details and impacted files
@@            Coverage Diff            @@
##               main     #147   +/-   ##
=========================================
  Coverage     99.24%   99.24%           
  Complexity     1143     1143           
=========================================
  Files            48       48           
  Lines          2517     2517           
=========================================
  Hits           2498     2498           
  Misses           19       19           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

joelbutcher and others added 2 commits November 9, 2026 09:46
ubuntu-latest now points to Ubuntu 26.04, which no longer installs
tzdata-legacy. Without it, PHP doesn't know legacy time zone names such as
CET and Asia/Rangoon, which the tests use.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FQhVM8scWxQrMU3djngjpv
(cherry picked from commit 1c48e3b)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gnutix
gnutix force-pushed the fix/duration-parse-lowercase-t branch from 50d337e to 963bb3b Compare November 9, 2026 08:46
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