Skip to content

Commit b9346fa

Browse files
authored
Fix BC in WorkerFactory constructor (#541)
1 parent fb4d5ec commit b9346fa

3 files changed

Lines changed: 10 additions & 7 deletions

File tree

psalm-baseline.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1443,6 +1443,9 @@
14431443
<DeprecatedClass>
14441444
<code><![CDATA[new AnnotationReader()]]></code>
14451445
</DeprecatedClass>
1446+
<ImpureMethodCall>
1447+
<code><![CDATA[create]]></code>
1448+
</ImpureMethodCall>
14461449
<InternalClass>
14471450
<code><![CDATA[new Client($this->responses)]]></code>
14481451
</InternalClass>
@@ -1477,7 +1480,7 @@
14771480
<code><![CDATA[new static(
14781481
$converter ?? DataConverter::createDefault(),
14791482
$rpc ?? Goridge::create(),
1480-
$credentials ?? ServiceCredentials::create(),
1483+
$credentials,
14811484
)]]></code>
14821485
</UnsafeInstantiation>
14831486
</file>

src/WorkerFactory.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,10 @@ class WorkerFactory implements WorkerFactoryInterface, LoopInterface
105105
public function __construct(
106106
DataConverterInterface $dataConverter,
107107
protected RPCConnectionInterface $rpc,
108-
ServiceCredentials $credentials,
108+
?ServiceCredentials $credentials = null,
109109
) {
110110
$this->converter = $dataConverter;
111-
$this->boot($credentials);
111+
$this->boot($credentials ?? ServiceCredentials::create());
112112
}
113113

114114
public static function create(
@@ -119,7 +119,7 @@ public static function create(
119119
return new static(
120120
$converter ?? DataConverter::createDefault(),
121121
$rpc ?? Goridge::create(),
122-
$credentials ?? ServiceCredentials::create(),
122+
$credentials,
123123
);
124124
}
125125

testing/src/WorkerFactory.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ public function __construct(
2828
DataConverterInterface $dataConverter,
2929
RPCConnectionInterface $rpc,
3030
ActivityInvocationCacheInterface $activityCache,
31-
ServiceCredentials $credentials,
31+
?ServiceCredentials $credentials = null,
3232
) {
3333
$this->activityCache = $activityCache;
3434

35-
parent::__construct($dataConverter, $rpc, $credentials);
35+
parent::__construct($dataConverter, $rpc, $credentials ?? ServiceCredentials::create());
3636
}
3737

3838
public static function create(
@@ -45,7 +45,7 @@ public static function create(
4545
$converter ?? DataConverter::createDefault(),
4646
$rpc ?? Goridge::create(),
4747
$activityCache ?? RoadRunnerActivityInvocationCache::create($converter),
48-
$credentials ?? ServiceCredentials::create(),
48+
$credentials,
4949
);
5050
}
5151

0 commit comments

Comments
 (0)