Skip to content

Commit ec76a45

Browse files
committed
Removed invalid T template parameter from methods where it is not bound to any template
These functions had a `T` template parameter in them, but this `T` is completely decoupled from the one defined at class-level (and therefore at `Enum` instance level, rather than statically): * `Enum::from()` * `Enum::isValid()` * `Enum::assertValidValue()` * `Enum::assertValidValueReturningKey()` (internal detail) In practice, this means that myclabs#135 (Added new named constructor to create enum from mixed) was not a valid approach to infer types for enumerable values, when performed statically. A new approach will be attempted, but the current one will likely need to be scrapped for now. In practice, `@psalm-assert`, `@psalm-assert-if-true` and `@psalm-return static<T>` had no effect on these methods, due to a design-level issue that wasn't spotted (by myself either) at review.
1 parent 96598da commit ec76a45

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

src/Enum.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public function __wakeup()
9595
/**
9696
* @param mixed $value
9797
* @return static
98-
* @psalm-return static<T>
98+
* @psalm-return static
9999
*/
100100
public static function from($value): self
101101
{
@@ -212,7 +212,6 @@ public static function toArray()
212212
* @param $value
213213
* @psalm-param mixed $value
214214
* @psalm-pure
215-
* @psalm-assert-if-true T $value
216215
* @return bool
217216
*/
218217
public static function isValid($value)
@@ -224,7 +223,6 @@ public static function isValid($value)
224223
* Asserts valid enum value
225224
*
226225
* @psalm-pure
227-
* @psalm-assert T $value
228226
* @param mixed $value
229227
*/
230228
public static function assertValidValue($value): void
@@ -236,7 +234,6 @@ public static function assertValidValue($value): void
236234
* Asserts valid enum value
237235
*
238236
* @psalm-pure
239-
* @psalm-assert T $value
240237
* @param mixed $value
241238
* @return string
242239
*/

0 commit comments

Comments
 (0)