Code Monkey home page Code Monkey logo

Comments (2)

seregazhuk avatar seregazhuk commented on June 14, 2024 1

@benkelukas I have investigated the problem. Try to do the following:

  1. In your WorkflowInterface add explicit attribute for the return type:
interface GreetingWorkflowInterface
{
    /**
     * @param string $name
     * @return WorkflowResult
     */
    #[WorkflowMethod(name: "SimpleActivity.greet")]
    #[ReturnType(WorkflowResult::class)]
    public function greet(string $name);
}
  1. In the command don't forget that the result object is now WorkflowResult. Don't try to print it, and use on of the getters:
$output->writeln(sprintf("Result:\n<info>%s</info>", $run->getResult()->getGreeting()));

Hope, it will help you. Waiting for you feedback.

from sdk-php.

benkelukas avatar benkelukas commented on June 14, 2024

Hi @seregazhuk

thanks a lot for taking a look at this, it works! :)

I suppose I could've tried this by myself, however, there is the ExpectedType attribute on the ReturnType attribute's type argument, so I kinda supposed (wrongly) that this is not possible.

Maybe it would be also good to update docs to mention that one can, in fact, use PHP protobuf messages and what to do when one wants to use it for Workflow return types, as I think it's a pretty good way how to structure data passing between activities / worfklows - but I understand that not everybody wants to go through the hassle of generating PHP code from .proto files - not sure if it is in scope for the docs.

There remains one little caveat for me: PHPStorm complains that I've provided unexpected type to the ReturnType annotation, it's nothing serious and I can disable inspections for statement, but maybe the attribute could be expanded to allow custom types somehow?

Thanks again for taking the time to help me, You guys rock! :)

I'm closing the issue, cheers!

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.