temporalio / samples-php

Temporal PHP SDK samples
Other
93 stars 42 forks source link

[Bug] Wrong prefix in the samples #43

Open azngeek opened 1 year ago

azngeek commented 1 year ago

What are you really trying to do?

Describe the bug

The current samples need to have their own prefix, which is basically the last part of the Namespace of the Activity. At least in this setup.

However, if you do not know, that the LocalActivity-Interfaces uses SimpleActivity as a prefix, any change made to the class Temporal\Samples\SimpleActivity\GreetingActivity will not be respected.


<?php

/**
 * This file is part of Temporal package.
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

declare(strict_types=1);

namespace Temporal\Samples\LocalActivity;

use Temporal\Activity\LocalActivityInterface;
use Temporal\Activity\ActivityMethod;

#[LocalActivityInterface(prefix: 'SimpleActivity.')]
interface GreetingActivityInterface
{
    #[ActivityMethod(name: "ComposeGreeting")]
    public function composeGreeting(
        string $greeting,
        string $name
    ): string;
}

Minimal Reproduction

  1. Change any code in the method Temporal\Samples\SimpleActivity\GreetingActivity::composeGreeting().
  2. Ensure that you edited the method in the namespace SimpleActivity!
  3. Reset the worker ./rr reset
  4. Run php app.php simple-activity
  5. You will see that the output comes from Temporal\Samples\LocalActivity\GreetingActivity::composeGreeting()
<?php

/**
 * This file is part of Temporal package.
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

declare(strict_types=1);

namespace Temporal\Samples\SimpleActivity;

use Temporal\Activity;

// @@@SNIPSTART php-hello-activity
class GreetingActivity implements GreetingActivityInterface
{
    public function composeGreeting(string $greeting, string $name): string
    {
        return $greeting . ' my code changes ' . $name;
    }
}
// @@@SNIPEND

Environment/Versions

Additional context