-
Notifications
You must be signed in to change notification settings - Fork 59
Description
What are you really trying to do?
Register multiple activity classes on the same worker without activity type name collisions.
Describe the bug
ActivityInterface::$prefix defaults to an empty string, meaning activity type names are derived from method names alone. This makes collisions inevitable when multiple activity classes share method names — and the wrong implementation gets executed silently with no error.
Minimal Reproduction
#[ActivityInterface] // prefix = ''
class ActivityA {
#[ActivityMethod]
public function doWork(): string { return 'ActivityA'; }
}
#[ActivityInterface] // prefix = ''
class ActivityB {
#[ActivityMethod]
public function doWork(): string { return 'ActivityB'; }
}Both register as activity type doWork. Calling ActivityA::doWork() may execute ActivityB::doWork() instead.
Environment/Versions
- Temporal PHP SDK 2.14.0
- Docker
Additional context
The workaround is either manually setting a prefix: #[ActivityInterface(prefix: 'classA.')] or explicitly naming every method: #[ActivityMethod(name: 'classA.doWork')].
Both are easy to forget and not prominently documented as required practice.
Suggested fix: Default prefix to the short class name (e.g. ActivityA.) instead of an empty string, similar to the Java SDK behavior.