1212namespace Temporal \Internal \Workflow ;
1313
1414use React \Promise \PromiseInterface ;
15+ use Temporal \Activity \ActivityMethod ;
1516use Temporal \Activity \ActivityOptionsInterface ;
17+ use Temporal \Worker \FeatureFlags ;
1618use Temporal \Interceptor \WorkflowOutboundCalls \ExecuteActivityInput ;
1719use Temporal \Interceptor \WorkflowOutboundCalls \ExecuteLocalActivityInput ;
1820use Temporal \Interceptor \WorkflowOutboundCallsInterceptor ;
@@ -61,13 +63,24 @@ public function __construct(
6163 */
6264 public function __call (string $ method , array $ args = []): PromiseInterface
6365 {
64- $ handler = $ this ->findPrototypeByHandlerNameOrFail ($ method );
65- $ type = $ handler ->getHandler ()->getReturnType ();
66- $ options = $ this ->options ->mergeWith ($ handler ->getMethodRetry ());
66+ $ prototype = $ this ->findPrototypeByHandlerNameOrFail ($ method );
67+ $ type = $ prototype ->getHandler ()->getReturnType ();
68+ $ options = $ this ->options ->mergeWith ($ prototype ->getMethodRetry ());
6769
68- $ args = Reflection::orderArguments ($ handler ->getHandler (), $ args );
70+ $ args = Reflection::orderArguments ($ prototype ->getHandler (), $ args );
6971
70- return $ handler ->isLocalActivity ()
72+ if (FeatureFlags::$ warnOnActivityMethodWithoutAttribute && !$ prototype ->getHandler ()->getAttributes (ActivityMethod::class, \ReflectionAttribute::IS_INSTANCEOF )) {
73+ \trigger_error (
74+ \sprintf (
75+ 'Using implicit activity methods is deprecated. Explicitly mark activity method %s with #[%s] attribute instead. ' ,
76+ $ prototype ->getHandler ()->getDeclaringClass ()->getName () . ':: ' . $ method ,
77+ ActivityMethod::class,
78+ ),
79+ \E_USER_DEPRECATED ,
80+ );
81+ }
82+
83+ return $ prototype ->isLocalActivity ()
7184 // Run local activity through an interceptor pipeline
7285 ? $ this ->callsInterceptor ->with (
7386 fn (ExecuteLocalActivityInput $ input ): PromiseInterface => $ this ->ctx
@@ -77,11 +90,11 @@ public function __call(string $method, array $args = []): PromiseInterface
7790 'executeLocalActivity ' ,
7891 )(
7992 new ExecuteLocalActivityInput (
80- $ handler ->getID (),
93+ $ prototype ->getID (),
8194 $ args ,
8295 $ options ,
8396 $ type ,
84- $ handler ->getHandler (),
97+ $ prototype ->getHandler (),
8598 )
8699 )
87100
@@ -94,11 +107,11 @@ public function __call(string $method, array $args = []): PromiseInterface
94107 'executeActivity ' ,
95108 )(
96109 new ExecuteActivityInput (
97- $ handler ->getID (),
110+ $ prototype ->getID (),
98111 $ args ,
99112 $ options ,
100113 $ type ,
101- $ handler ->getHandler (),
114+ $ prototype ->getHandler (),
102115 )
103116 );
104117 }
0 commit comments