Skip to content

Function Helpers#299

Merged
rmcdaniel merged 2 commits intomasterfrom
feature/helpers
Dec 9, 2025
Merged

Function Helpers#299
rmcdaniel merged 2 commits intomasterfrom
feature/helpers

Conversation

@rmcdaniel
Copy link
Copy Markdown
Member

This PR introduces convenient global helper functions in the Workflow namespace to simplify workflow definitions and make the code more readable and concise.

New Helper Functions

Workflow Control:

  • await($condition) - Wait for a condition to become true
  • timer($duration) - Create a timer
  • awaitWithTimeout($timeout, $condition) - Wait for a condition with timeout
  • sideEffect($callable) - Execute deterministic side effects
  • continueAsNew(...$arguments) - Continue workflow as a new execution
  • getVersion($changeId, $minSupported, $maxSupported) - Manage workflow versioning

Activity & Child Workflows:

  • activity($activity, ...$arguments) - Execute an activity
  • child($workflow, ...$arguments) - Execute a child workflow
  • all($promises) - Wait for all promises to resolve
  • async($callback) - Execute async operations

Time Helpers:

  • seconds($seconds) - Timer for seconds
  • minutes($minutes) - Timer for minutes
  • hours($hours) - Timer for hours
  • days($days) - Timer for days
  • weeks($weeks) - Timer for weeks
  • months($months) - Timer for months
  • years($years) - Timer for years

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a set of convenient global helper functions in the Workflow namespace to simplify workflow definitions and improve code readability. The changes wrap existing WorkflowStub, ActivityStub, and ChildWorkflowStub static methods with more concise function calls, and include time-based helper functions (seconds, minutes, hours, days, weeks, months, years) for easier duration specification.

Key Changes:

  • Added 18 global helper functions covering workflow control, activity execution, child workflows, and time helpers
  • Refactored 30+ fixture test files to use the new helper functions
  • Added comprehensive unit tests for all new helper functions

Reviewed changes

Copilot reviewed 50 out of 50 changed files in this pull request and generated 22 comments.

File Description
src/functions.php Introduces all new global helper functions with appropriate existence checks
composer.json Adds autoload configuration to load the functions file
tests/Unit/FunctionsTest.php Comprehensive test suite with test workflows for all helper functions
tests/Fixtures/*.php (30+ files) Updates existing test fixtures to use new helper functions instead of static method calls

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link
Copy Markdown

codecov bot commented Dec 9, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (efa4d03) to head (a05fdb1).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##              master      #299   +/-   ##
===========================================
  Coverage     100.00%   100.00%           
  Complexity       350       350           
===========================================
  Files             48        49    +1     
  Lines           1425      1442   +17     
===========================================
+ Hits            1425      1442   +17     

☔ 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.

@rmcdaniel rmcdaniel merged commit 79accc3 into master Dec 9, 2025
3 checks passed
@rmcdaniel rmcdaniel deleted the feature/helpers branch December 9, 2025 02:22
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