Skip to content

Conversation

@Cyberking99
Copy link
Contributor

@Cyberking99 Cyberking99 commented May 29, 2025

This PR adds support for forwarding method calls from the DateString class to its internal DateTime instance. This allows for more intuitive usage, such as calling $post->date->format('Y-m-d') directly instead of accessing $post->date->dateTimeObject->format('Y-m-d').

  • Implemented the __call() magic method to intercept and forward undefined method calls to the DateTime object.
  • Throws a BadMethodCallException if a method does not exist on DateTime, maintaining robustness.
  • Refactored calls like $post->date->dateTimeObject->format('Y-m-d') to the cleaner $post->date->format('Y-m-d').
  • Updated relevant usages in RssFeedGenerator and MarkdownPost classes.
  • Added a unit test to ensure that method forwarding behaves correctly and throws appropriate exceptions for undefined methods.
     
  • Fixes Forward DateString method calls to DateTime object hyde#284

@emmadesilva
Copy link
Member

Looks great! Make sure to unmark your PR as draft and fix style issues when you're ready for this to be merged 🔥

@Cyberking99 Cyberking99 marked this pull request as ready for review May 29, 2025 13:51
@Cyberking99
Copy link
Contributor Author

All done @caendesilva 💯

@emmadesilva emmadesilva added the ODHack14 Part of the OnlyDust 14 Hackaton label May 29, 2025
@codecov
Copy link

codecov bot commented May 29, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (f61f4b8) to head (d80e269).
Report is 7 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##              master     #2235   +/-   ##
===========================================
  Coverage     100.00%   100.00%           
- Complexity      1971      1973    +2     
===========================================
  Files            198       198           
  Lines           5270      5274    +4     
===========================================
+ Hits            5270      5274    +4     

☔ View full report in Codecov by Sentry.
📢 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@emmadesilva emmadesilva changed the title feat: forward method calls to DateTime in DateString Forward DateString method calls to DateTime instances May 29, 2025
@emmadesilva emmadesilva force-pushed the feature/forward-datetime-calls branch from 725e22f to d80e269 Compare May 29, 2025 14:34
@emmadesilva emmadesilva merged commit 9fbb0c7 into hydephp:master May 29, 2025
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ODHack14 Part of the OnlyDust 14 Hackaton

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Forward DateString method calls to DateTime object

2 participants