Code Monkey home page Code Monkey logo

Comments (3)

khoerintus avatar khoerintus commented on June 14, 2024 1

Hi @SerafimArts,
Noted. Thanks for your explanation and suggestion.
I will update my code to use DTO suggested by @wolfy-j instead of using associative array.

from sdk-php.

SerafimArts avatar SerafimArts commented on June 14, 2024

Hello!

It is worth noting that Temporal can communicate with external services that can be written in an arbitrary language. The default codec used is JSON, where there is no such thing as an associative array, as in most programming languages existing in the world.

Therefore, when packing such data into this format, the types are converted from an hash-map to an object:

['key' => 'value'] 
// ->
{"key": "value"}

Which is the representation of the anonymous object.

That is, in this case, this is not an bug, but rather a limitation of the transport protocol.

To solve this problem, you should convert the result explicitly back from anonymous object to PHP hash-map:

$assocArray = (array)(yield $simple->getAssocArray($input));

@wolfy-j perhaps can tell if switching to a different codec will help solve this problem. And if so, how to do it technically.

from sdk-php.

wolfy-j avatar wolfy-j commented on June 14, 2024

I would strongly recommend using proper DTO for such purposes. You can create objects with public properties. Temporal should typecast it if this object is set as the return type of the activity.

from sdk-php.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.