Simplify now() to use new DateTimeImmutable('now', $utc) directly, avoiding costly microtime+createFromFormat roundtrip and locale-sensitive float formatting#8
Merged
gustavofreze merged 1 commit intomainfrom Apr 21, 2026
Conversation
…y, avoiding costly microtime+createFromFormat roundtrip and locale-sensitive float formatting; remove unused MICROSECOND_FORMAT constant and redundant setTimezone call.
There was a problem hiding this comment.
Pull request overview
This PR optimizes Instant::now() by constructing DateTimeImmutable('now', $utc) directly (removing the microtime() → sprintf() → createFromFormat() roundtrip), and updates repository/tooling metadata and contributor guidance.
Changes:
- Simplify
Instant::now()implementation and remove the no-longer-needed microsecond format constant. - Change timezone identifier validation to call
DateTimeZone::listIdentifiers()directly (and remove the cached helper). - Refresh project tooling/config/docs (Composer config/scripts, Infection mutators, Makefile targets, repo dotfiles, and new
.claude/rule docs).
Reviewed changes
Copilot reviewed 15 out of 16 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Timezone.php | Replaces cached identifier list with direct DateTimeZone::listIdentifiers() call and removes helper. |
| src/Instant.php | Simplifies now() to new DateTimeImmutable('now', $utc); removes microsecond format constant. |
| infection.json.dist | Changes disabled mutator from AssignCoalesce to ProtectedVisibility. |
| composer.json | Updates package metadata, bumps dependencies, adds composer-normalize, reorganizes scripts/config. |
| README.md | Updates overview wording to reflect library scope and immutability/value-object contract. |
| Makefile | Runs composer normalize in configure, adds show-outdated, updates help output. |
| .gitignore | Expands ignored IDE/agent artifacts; ignores composer.lock and coverage/build outputs. |
| .github/copilot-instructions.md | Adds Copilot guidance pointing to .claude rules as source of truth. |
| .gitattributes | Adds LF normalization and a clearer export-ignore list for Packagist tarballs. |
| .editorconfig | Adds editor defaults (LF, trimming, indent rules, Makefile tabs). |
| .claude/rules/php-library-testing.md | Adds PHPUnit + BDD Given/When/Then and strict coverage/mutation requirements. |
| .claude/rules/php-library-modeling.md | Adds library architecture/modeling rules and public/internal API boundary guidance. |
| .claude/rules/php-library-documentation.md | Adds README/documentation standards (TOC, badges, examples, FAQ, etc.). |
| .claude/rules/php-library-code-style.md | Adds semantic PHP style rules (naming, comparisons, no else, etc.). |
| .claude/rules/github-workflows.md | Adds workflow structure/security/style rules for GitHub Actions. |
| .claude/CLAUDE.md | Adds project meta-guidance + required validation commands after changes. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.