Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replacing NamedArgumentConstructorAttribute with NamedArgumentConstructor #292

Merged
merged 2 commits into from Apr 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -30,7 +30,7 @@
"nesbot/carbon": "^2.55.0",
"psr/log": "^1.0.1 || ^2.0 || ^3.0",
"react/promise": "^2.8",
"spiral/attributes": "^2.7 || ^3.0",
"spiral/attributes": "^2.8 || ^3.0",
"spiral/roadrunner-cli": "^2.2",
"spiral/roadrunner-kv": "^2.1 || ^3.0",
"spiral/roadrunner-worker": "^2.1.3",
Expand Down
7 changes: 4 additions & 3 deletions src/Activity/ActivityInterface.php
Expand Up @@ -13,7 +13,7 @@

use Doctrine\Common\Annotations\Annotation\Target;
use JetBrains\PhpStorm\Immutable;
use Spiral\Attributes\NamedArgumentConstructorAttribute;
use Spiral\Attributes\NamedArgumentConstructor;

/**
* Indicates that an interface is an activity interface. Only interfaces
Expand All @@ -29,10 +29,11 @@
* distinct.
*
* @Annotation
* @NamedArgumentConstructor
* @Target({ "CLASS" })
*/
#[\Attribute(\Attribute::TARGET_CLASS)]
class ActivityInterface implements NamedArgumentConstructorAttribute
#[\Attribute(\Attribute::TARGET_CLASS), NamedArgumentConstructor]
class ActivityInterface
{
/**
* Prefix to prepend to method names to generate activity types. Default is
Expand Down
7 changes: 4 additions & 3 deletions src/Activity/ActivityMethod.php
Expand Up @@ -13,14 +13,15 @@

use Doctrine\Common\Annotations\Annotation\Target;
use JetBrains\PhpStorm\Immutable;
use Spiral\Attributes\NamedArgumentConstructorAttribute;
use Spiral\Attributes\NamedArgumentConstructor;

/**
* @Annotation
* @NamedArgumentConstructor
* @Target({ "METHOD" })
*/
#[\Attribute(\Attribute::TARGET_METHOD)]
final class ActivityMethod implements NamedArgumentConstructorAttribute
#[\Attribute(\Attribute::TARGET_METHOD), NamedArgumentConstructor]
final class ActivityMethod
{
/**
* Name of the activity type.
Expand Down
5 changes: 3 additions & 2 deletions src/Activity/LocalActivityInterface.php
Expand Up @@ -13,7 +13,7 @@

use Doctrine\Common\Annotations\Annotation\Target;
use JetBrains\PhpStorm\Immutable;
use Spiral\Attributes\NamedArgumentConstructorAttribute;
use Spiral\Attributes\NamedArgumentConstructor;

/**
* Indicates that an interface is a local activity interface. Only interfaces
Expand All @@ -29,9 +29,10 @@
* distinct.
*
* @Annotation
* @NamedArgumentConstructor
* @Target({ "CLASS" })
*/
#[\Attribute(\Attribute::TARGET_CLASS)]
#[\Attribute(\Attribute::TARGET_CLASS), NamedArgumentConstructor]
final class LocalActivityInterface extends ActivityInterface
{
/**
Expand Down
7 changes: 4 additions & 3 deletions src/Common/CronSchedule.php
Expand Up @@ -12,7 +12,7 @@
namespace Temporal\Common;

use JetBrains\PhpStorm\Immutable;
use Spiral\Attributes\NamedArgumentConstructorAttribute;
use Spiral\Attributes\NamedArgumentConstructor;
use Temporal\Internal\Support\DateInterval;

/**
Expand All @@ -30,10 +30,11 @@
* @see DateInterval
*
* @Annotation
* @NamedArgumentConstructor
* @Target({ "METHOD" })
*/
#[\Attribute(\Attribute::TARGET_METHOD)]
final class CronSchedule implements NamedArgumentConstructorAttribute, \Stringable
#[\Attribute(\Attribute::TARGET_METHOD), NamedArgumentConstructor]
final class CronSchedule implements \Stringable
{
/**
* The cron spec is as following:
Expand Down
7 changes: 4 additions & 3 deletions src/Common/MethodRetry.php
Expand Up @@ -11,7 +11,7 @@

namespace Temporal\Common;

use Spiral\Attributes\NamedArgumentConstructorAttribute;
use Spiral\Attributes\NamedArgumentConstructor;
use Temporal\Internal\Support\DateInterval;

/**
Expand All @@ -27,10 +27,11 @@
* @psalm-import-type ExceptionsList from RetryOptions
*
* @Annotation
* @NamedArgumentConstructor
* @Target({ "METHOD" })
*/
#[\Attribute(\Attribute::TARGET_METHOD)]
final class MethodRetry extends RetryOptions implements NamedArgumentConstructorAttribute
#[\Attribute(\Attribute::TARGET_METHOD), NamedArgumentConstructor]
final class MethodRetry extends RetryOptions
{
/**
* @param DateIntervalValue|null $initialInterval
Expand Down
7 changes: 4 additions & 3 deletions src/Internal/Marshaller/Meta/Marshal.php
Expand Up @@ -11,16 +11,17 @@

namespace Temporal\Internal\Marshaller\Meta;

use Spiral\Attributes\NamedArgumentConstructorAttribute;
use Spiral\Attributes\NamedArgumentConstructor;
use Temporal\Internal\Marshaller\MarshallingRule;
use Temporal\Internal\Marshaller\Type\NullableType;

/**
* @Annotation
* @NamedArgumentConstructor
* @Target({ "PROPERTY" })
*/
#[\Attribute(\Attribute::TARGET_PROPERTY)]
class Marshal extends MarshallingRule implements NamedArgumentConstructorAttribute
#[\Attribute(\Attribute::TARGET_PROPERTY), NamedArgumentConstructor]
class Marshal extends MarshallingRule
{
/**
* @param string|null $name
Expand Down
4 changes: 3 additions & 1 deletion src/Internal/Marshaller/Meta/MarshalArray.php
Expand Up @@ -11,13 +11,15 @@

namespace Temporal\Internal\Marshaller\Meta;

use Spiral\Attributes\NamedArgumentConstructor;
use Temporal\Internal\Marshaller\Type\ArrayType;

/**
* @Annotation
* @NamedArgumentConstructor
* @Target({ "PROPERTY", "METHOD" })
*/
#[\Attribute(\Attribute::TARGET_PROPERTY)]
#[\Attribute(\Attribute::TARGET_PROPERTY), NamedArgumentConstructor]
final class MarshalArray extends Marshal
{
/**
Expand Down
7 changes: 4 additions & 3 deletions src/Internal/Marshaller/Meta/Scope.php
Expand Up @@ -12,16 +12,17 @@
namespace Temporal\Internal\Marshaller\Meta;

use JetBrains\PhpStorm\ExpectedValues;
use Spiral\Attributes\NamedArgumentConstructorAttribute;
use Spiral\Attributes\NamedArgumentConstructor;

/**
* @psalm-type ExportScope = Scope::VISIBILITY_*
*
* @Annotation
* @NamedArgumentConstructor
* @Target({ "CLASS" })
*/
#[\Attribute(\Attribute::TARGET_CLASS)]
class Scope implements NamedArgumentConstructorAttribute
#[\Attribute(\Attribute::TARGET_CLASS), NamedArgumentConstructor]
class Scope
{
/**
* @var int
Expand Down
7 changes: 4 additions & 3 deletions src/Workflow/QueryMethod.php
Expand Up @@ -13,7 +13,7 @@

use Doctrine\Common\Annotations\Annotation\Target;
use JetBrains\PhpStorm\Immutable;
use Spiral\Attributes\NamedArgumentConstructorAttribute;
use Spiral\Attributes\NamedArgumentConstructor;

/**
* Indicates that the method is a query method. Query method can be used to
Expand All @@ -24,10 +24,11 @@
* activities or block threads in any way.
*
* @Annotation
* @NamedArgumentConstructor
* @Target({ "METHOD" })
*/
#[\Attribute(\Attribute::TARGET_METHOD)]
final class QueryMethod implements NamedArgumentConstructorAttribute
#[\Attribute(\Attribute::TARGET_METHOD), NamedArgumentConstructor]
final class QueryMethod
{
/**
* Name of the query type. Default is method name.
Expand Down
7 changes: 4 additions & 3 deletions src/Workflow/ReturnType.php
Expand Up @@ -13,15 +13,16 @@

use JetBrains\PhpStorm\ExpectedValues;
use JetBrains\PhpStorm\Immutable;
use Spiral\Attributes\NamedArgumentConstructorAttribute;
use Spiral\Attributes\NamedArgumentConstructor;
use Temporal\DataConverter\Type;

/**
* @Annotation
* @NamedArgumentConstructor
* @Target({ "METHOD" })
*/
#[\Attribute(\Attribute::TARGET_METHOD)]
final class ReturnType implements NamedArgumentConstructorAttribute
#[\Attribute(\Attribute::TARGET_METHOD), NamedArgumentConstructor]
final class ReturnType
{
public const TYPE_ANY = Type::TYPE_ANY;
public const TYPE_STRING = Type::TYPE_STRING;
Expand Down
7 changes: 4 additions & 3 deletions src/Workflow/SignalMethod.php
Expand Up @@ -13,18 +13,19 @@

use Doctrine\Common\Annotations\Annotation\Target;
use JetBrains\PhpStorm\Immutable;
use Spiral\Attributes\NamedArgumentConstructorAttribute;
use Spiral\Attributes\NamedArgumentConstructor;

/**
* Indicates that the method is a signal handler method. Signal method is
* executed when workflow receives signal. This annotation applies only to
* workflow interface methods.
*
* @Annotation
* @NamedArgumentConstructor
* @Target({ "METHOD" })
*/
#[\Attribute(\Attribute::TARGET_METHOD)]
final class SignalMethod implements NamedArgumentConstructorAttribute
#[\Attribute(\Attribute::TARGET_METHOD), NamedArgumentConstructor]
final class SignalMethod
{
/**
* Name of the signal type. Default is method name.
Expand Down
11 changes: 1 addition & 10 deletions src/Workflow/WorkflowInterface.php
Expand Up @@ -17,16 +17,7 @@
* @Annotation
* @Target({ "CLASS" })
*
* Note: We can not implement "NamedArgumentConstructorAttribute" interface
* on attribute classes without "__construct" method.
*
* Otherwise, we may receive a NPE inside DocParser class, like:
* > Call to a member function getParameters() on null
* > in vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/DocParser.php:518
*
* Problem is relevant for doctrine/annotations 1.11 or lower on PHP 7.4 or lower.
*
* Note #2: We can not comment this problematic piece of code, because
* Note: We can not comment this problematic piece of code, because
* otherwise a second doctrine bug occurs (WTF!111?) due to which the doctrine
* cannot correctly read the annotations (like "Annotation") in the class.
*
Expand Down
7 changes: 4 additions & 3 deletions src/Workflow/WorkflowMethod.php
Expand Up @@ -13,14 +13,15 @@

use Doctrine\Common\Annotations\Annotation\Target;
use JetBrains\PhpStorm\Immutable;
use Spiral\Attributes\NamedArgumentConstructorAttribute;
use Spiral\Attributes\NamedArgumentConstructor;

/**
* @Annotation
* @NamedArgumentConstructor
* @Target({ "METHOD" })
*/
#[\Attribute(\Attribute::TARGET_METHOD)]
final class WorkflowMethod implements NamedArgumentConstructorAttribute
#[\Attribute(\Attribute::TARGET_METHOD), NamedArgumentConstructor]
final class WorkflowMethod
{
/**
* Name of the workflow type. Default is "{class_name :: method_name}".
Expand Down