forked from vimeo/psalm
/
psl-psalm-plugin.diff
138 lines (121 loc) · 6.28 KB
/
psl-psalm-plugin.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
diff --git a/src/EventHandler/Iter/First/FunctionReturnTypeProvider.php b/src/EventHandler/Iter/First/FunctionReturnTypeProvider.php
index 7168824..dfd0a8a 100644
--- a/src/EventHandler/Iter/First/FunctionReturnTypeProvider.php
+++ b/src/EventHandler/Iter/First/FunctionReturnTypeProvider.php
@@ -34,20 +34,20 @@ final class FunctionReturnTypeProvider implements FunctionReturnTypeProviderInte
}
if ($array_argument_type instanceof Type\Atomic\TNonEmptyArray) {
- return clone $array_argument_type->type_params[1];
+ return $array_argument_type->type_params[1];
}
if ($array_argument_type instanceof Type\Atomic\TNonEmptyList) {
- return clone $array_argument_type->type_param;
+ return $array_argument_type->type_param;
}
if ($array_argument_type instanceof Type\Atomic\TKeyedArray) {
// TODO(azjezz): add support for this once psalm starts enforcing the shape order ( if ever ).
//
// foreach ($properties as $property) {
- // return clone $property;
+ // return $property;
// }
- return clone $array_argument_type->getGenericValueType();
+ return $array_argument_type->getGenericValueType();
}
return null;
diff --git a/src/EventHandler/Iter/FirstKey/FunctionReturnTypeProvider.php b/src/EventHandler/Iter/FirstKey/FunctionReturnTypeProvider.php
index f95ebfd..d276046 100644
--- a/src/EventHandler/Iter/FirstKey/FunctionReturnTypeProvider.php
+++ b/src/EventHandler/Iter/FirstKey/FunctionReturnTypeProvider.php
@@ -34,7 +34,7 @@ final class FunctionReturnTypeProvider implements FunctionReturnTypeProviderInte
}
if ($array_argument_type instanceof Type\Atomic\TNonEmptyArray) {
- return clone $array_argument_type->type_params[0];
+ return $array_argument_type->type_params[0];
}
if ($array_argument_type instanceof Type\Atomic\TNonEmptyList) {
@@ -45,9 +45,9 @@ final class FunctionReturnTypeProvider implements FunctionReturnTypeProviderInte
// TODO(azjezz): add support for this once psalm starts enforcing the shape order ( if ever ).
//
// foreach ($properties as $property) {
- // return clone $property;
+ // return $property;
// }
- return clone $array_argument_type->getGenericKeyType();
+ return $array_argument_type->getGenericKeyType();
}
return null;
diff --git a/src/EventHandler/Iter/Last/FunctionReturnTypeProvider.php b/src/EventHandler/Iter/Last/FunctionReturnTypeProvider.php
index 6a7a8c8..5f79bb7 100644
--- a/src/EventHandler/Iter/Last/FunctionReturnTypeProvider.php
+++ b/src/EventHandler/Iter/Last/FunctionReturnTypeProvider.php
@@ -34,11 +34,11 @@ final class FunctionReturnTypeProvider implements FunctionReturnTypeProviderInte
}
if ($array_argument_type instanceof Type\Atomic\TNonEmptyArray) {
- return clone $array_argument_type->type_params[1];
+ return $array_argument_type->type_params[1];
}
if ($array_argument_type instanceof Type\Atomic\TNonEmptyList) {
- return clone $array_argument_type->type_param;
+ return $array_argument_type->type_param;
}
if ($array_argument_type instanceof Type\Atomic\TKeyedArray) {
@@ -50,8 +50,8 @@ final class FunctionReturnTypeProvider implements FunctionReturnTypeProviderInte
// $last_property = $property;
// }
//
- // return clone $last_property;
- return clone $array_argument_type->getGenericValueType();
+ // return $last_property;
+ return $array_argument_type->getGenericValueType();
}
return null;
diff --git a/src/EventHandler/Iter/LastKey/FunctionReturnTypeProvider.php b/src/EventHandler/Iter/LastKey/FunctionReturnTypeProvider.php
index 7e98609..19abf16 100644
--- a/src/EventHandler/Iter/LastKey/FunctionReturnTypeProvider.php
+++ b/src/EventHandler/Iter/LastKey/FunctionReturnTypeProvider.php
@@ -34,7 +34,7 @@ final class FunctionReturnTypeProvider implements FunctionReturnTypeProviderInte
}
if ($array_argument_type instanceof Type\Atomic\TNonEmptyArray) {
- return clone $array_argument_type->type_params[0];
+ return $array_argument_type->type_params[0];
}
if ($array_argument_type instanceof Type\Atomic\TNonEmptyList) {
@@ -50,8 +50,8 @@ final class FunctionReturnTypeProvider implements FunctionReturnTypeProviderInte
// $last_property = $property;
// }
//
- // return clone $last_property;
- return clone $array_argument_type->getGenericKeyType();
+ // return $last_property;
+ return $array_argument_type->getGenericKeyType();
}
return null;
diff --git a/src/EventHandler/Type/Optional/FunctionReturnTypeProvider.php b/src/EventHandler/Type/Optional/FunctionReturnTypeProvider.php
index 2c0fbb3..896f434 100644
--- a/src/EventHandler/Type/Optional/FunctionReturnTypeProvider.php
+++ b/src/EventHandler/Type/Optional/FunctionReturnTypeProvider.php
@@ -28,9 +28,6 @@ final class FunctionReturnTypeProvider implements FunctionReturnTypeProviderInte
return null;
}
- $clone = clone $argument_type;
- $clone->possibly_undefined = true;
-
- return $clone;
+ return $argument_type->setPossiblyUndefined(true);
}
}
diff --git a/src/EventHandler/Type/Shape/FunctionReturnTypeProvider.php b/src/EventHandler/Type/Shape/FunctionReturnTypeProvider.php
index 3650a1a..b51bf63 100644
--- a/src/EventHandler/Type/Shape/FunctionReturnTypeProvider.php
+++ b/src/EventHandler/Type/Shape/FunctionReturnTypeProvider.php
@@ -57,8 +57,9 @@ final class FunctionReturnTypeProvider implements FunctionReturnTypeProviderInte
return null;
}
- $property_type = clone $type->type_params[0];
- $property_type->possibly_undefined = $value->possibly_undefined;
+ $property_type = $type->type_params[0]->setPossiblyUndefined(
+ $value->possibly_undefined
+ );
$properties[$name] = $property_type;
}