[Bug] Wrong activity response type
Describe the bug I send an array from my activity as a result, but in promise step then I get stdClass instead of array.
To Reproduce Steps to reproduce the behavior:
- Create activity that will send an associative array.
- Create workflow where you call activity and add post-processing in then step.
- Try to get value from result as if it array.
Expected behavior I get value
Expected behavior
I get an error PanicError: Cannot use object of type stdClass as array (type: Error, retryable: true)
Screenshots/Terminal ouput

You can use this snippet:
#[\Temporal\Activity\ActivityInterface(prefix: "app.")]
class CommonActivity
{
public function slow(string $name): array
{
return [
'result' => 'Hello, ' . $name,
];
}
}
#[\Temporal\Workflow\WorkflowInterface]
final class FastWorkflow
{
#[\Temporal\Workflow\WorkflowMethod("wf")]
public function run(string $name, int $count): \Generator
{
$activity = Workflow::newActivityStub(
CommonActivity::class
);
$activity->slow($name)->then(function ($result) {
$result['result'];
});
return 0;
}
}
As I understand the problem is locating here. But I don't know how to solve it.
Hello! This is not a bug (More precisely, this is documented behavior). Please use DTO instead. Related issue https://github.com/temporalio/sdk-php/issues/93#issuecomment-804008399
Then can you make behaviour more predictable:
if you return ['key' => 'test'] it will be converted to an object, but if you return ['test'] it will be converted to an array.
if you return ['key' => 'test'] it will be converted to an object, but if you return ['test'] it will be converted to an array.
Now that's how it works, isn't it?
Yes, it is. But it isn't clear.