Skip to content

Commit eca0d7d

Browse files
Francois Morinfacebook-github-bot
authored andcommitted
Change the templating type for ThriftImmutableWrapper
Summary: This change is required to make a generic toShape functionality (so it can be stringly typed). See next diff. Differential Revision: D76818825 fbshipit-source-id: 0ea793da4c1dd0624301aedcb918383d4626267d
1 parent 90fd17e commit eca0d7d

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

third-party/thrift/src/thrift/lib/hack/src/ThriftImmutableWrapper.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,14 @@
2323
* allow a caller to mutate the underlying thrift object.
2424
*/
2525
<<__ConsistentConstruct, Oncalls('signals_infra')>>
26-
abstract class ThriftImmutableWrapper<T as \IThriftShapishSyncStruct>
26+
abstract class ThriftImmutableWrapper
2727
implements JsonSerializable, \HH\IMemoizeParam {
28-
final public function __construct(protected T $data) {}
2928

30-
final public static function createInstance(?T $data): ?this {
29+
abstract const type TThrift as IThriftShapishSyncStruct;
30+
31+
final public function __construct(protected this::TThrift $data) {}
32+
33+
final public static function createInstance(?this::TThrift $data): ?this {
3134
return $data is null ? null : new static($data);
3235
}
3336

@@ -41,7 +44,7 @@ final public function getInstanceKey(): string {
4144
return $this->data->getInstanceKey();
4245
}
4346

44-
final public function createDeepCopy(): T {
47+
final public function createDeepCopy(): this::TThrift {
4548
return TCompactSerializer::deserialize(
4649
TCompactSerializer::serialize($this->data),
4750
Classnames::get($this->data) as nonnull

third-party/thrift/src/thrift/lib/hack/src/__tests__/ThriftImmutableWrapperTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,9 @@ final class ThriftImmutableWrapperTest extends WWWTest {
9191
}
9292
}
9393

94-
final class TestThriftImmutableWrapper
95-
extends ThriftImmutableWrapper<AdsConsentPlatformParams> {
94+
final class TestThriftImmutableWrapper extends ThriftImmutableWrapper {
95+
96+
const type TThrift = AdsConsentPlatformParams;
9697

9798
public function getTraceId(): ?string {
9899
return $this->data->traceID;

0 commit comments

Comments
 (0)