@@ -295,6 +295,76 @@ interface Stringable
295
295
public function __toString (): string ;
296
296
}
297
297
298
+ /**
299
+ * @since 8.1
300
+ */
301
+ interface UnitEnum
302
+ {
303
+ /**
304
+ * @return static[]
305
+ */
306
+ #[Pure]
307
+ public static function cases (): array ;
308
+ }
309
+
310
+ /**
311
+ * @since 8.1
312
+ */
313
+ interface BackedEnum extends UnitEnum
314
+ {
315
+ /**
316
+ * @param int|string $value
317
+ * @return static
318
+ */
319
+ #[Pure]
320
+ public static function from (int |string $ value ): static ;
321
+
322
+ /**
323
+ * @param int|string $value
324
+ * @return static|null
325
+ */
326
+ #[Pure]
327
+ public static function tryFrom (int |string $ value ): ?static ;
328
+ }
329
+
330
+ /**
331
+ * @since 8.1
332
+ * @internal
333
+ *
334
+ * Internal interface to ensure precise type inference
335
+ */
336
+ interface IntBackedEnum extends BackedEnum
337
+ {
338
+ /**
339
+ * @param int $value
340
+ * @return static
341
+ */
342
+ #[Pure]
343
+ public static function from (int $ value ): static ;
344
+
345
+ /**
346
+ * @param int $value
347
+ * @return static|null
348
+ */
349
+ #[Pure]
350
+ public static function tryFrom (int $ value ): ?static ;
351
+ }
352
+
353
+ /**
354
+ * @since 8.1
355
+ * @internal
356
+ *
357
+ * Internal interface to ensure precise type inference
358
+ */
359
+ interface StringBackedEnum extends BackedEnum
360
+ {
361
+ #[Pure]
362
+ public static function from (string $ value ): static ;
363
+
364
+ #[Pure]
365
+ public static function tryFrom (string $ value ): ?static ;
366
+ }
367
+
298
368
/**
299
369
* Created by typecasting to object.
300
370
* @link https://php.net/manual/en/reserved.classes.php
@@ -315,10 +385,10 @@ class Exception implements Throwable
315
385
protected $ code ;
316
386
317
387
/** The filename where the error happened */
318
- protected $ file ;
388
+ protected string $ file ;
319
389
320
390
/** The line where the error happened */
321
- protected $ line ;
391
+ protected int $ line ;
322
392
323
393
/**
324
394
* Construct the exception. Note: The message is NOT binary safe.
@@ -407,7 +477,7 @@ public function __wakeup(): void {}
407
477
* @link https://php.net/manual/en/exception.clone.php
408
478
* @return void
409
479
*/
410
- final private function __clone (): void {}
480
+ private function __clone (): void {}
411
481
}
412
482
413
483
/**
@@ -424,10 +494,10 @@ class Error implements Throwable
424
494
protected $ code ;
425
495
426
496
/** The filename where the error happened */
427
- protected $ file ;
497
+ protected string $ file ;
428
498
429
499
/** The line where the error happened */
430
- protected $ line ;
500
+ protected int $ line ;
431
501
432
502
/**
433
503
* Construct the error object.
@@ -514,7 +584,7 @@ public function __wakeup(): void {}
514
584
* @return void
515
585
* @link https://php.net/manual/en/error.clone.php
516
586
*/
517
- final private function __clone (): void {}
587
+ private function __clone (): void {}
518
588
}
519
589
520
590
class ValueError extends Error {}
@@ -579,7 +649,7 @@ class UnhandledMatchError extends Error {}
579
649
*/
580
650
class ErrorException extends Exception
581
651
{
582
- protected $ severity ;
652
+ protected int $ severity ;
583
653
584
654
/**
585
655
* Constructs the exception
@@ -842,3 +912,119 @@ public function valid(): bool {}
842
912
843
913
public function rewind (): void {}
844
914
}
915
+
916
+ /**
917
+ * @since 8.1
918
+ *
919
+ * @template TStart
920
+ * @template TResume
921
+ * @template TReturn
922
+ * @template TSuspend
923
+ */
924
+ final class Fiber
925
+ {
926
+ /**
927
+ * @param callable $callback Function to invoke when starting the fiber.
928
+ */
929
+ public function __construct (callable $ callback ) {}
930
+
931
+ /**
932
+ * @return self|null Returns the currently executing fiber instance or NULL if in {main}.
933
+ */
934
+ public static function getCurrent (): ?Fiber {}
935
+
936
+ /**
937
+ * Suspend execution of the fiber. The fiber may be resumed with {@see Fiber::resume()} or {@see Fiber::throw()}.
938
+ *
939
+ * Cannot be called from {main}.
940
+ *
941
+ * @param TSuspend $value Value to return from {@see Fiber::resume()} or {@see Fiber::throw()}.
942
+ *
943
+ * @return TResume Value provided to {@see Fiber::resume()}.
944
+ *
945
+ * @throws FiberError Thrown if not within a fiber (i.e., if called from {main}).
946
+ * @throws Throwable Exception provided to {@see Fiber::throw()}.
947
+ */
948
+ public static function suspend (mixed $ value = null ): mixed {}
949
+
950
+ /**
951
+ * Starts execution of the fiber. Returns when the fiber suspends or terminates.
952
+ *
953
+ * @param TStart ...$args Arguments passed to fiber function.
954
+ *
955
+ * @return TSuspend|null Value from the first suspension point or NULL if the fiber returns.
956
+ *
957
+ * @throws FiberError If the fiber has already been started.
958
+ * @throws Throwable If the fiber callable throws an uncaught exception.
959
+ */
960
+ public function start (mixed ...$ args ): mixed {}
961
+
962
+ /**
963
+ * Resumes the fiber, returning the given value from {@see Fiber::suspend()}.
964
+ * Returns when the fiber suspends or terminates.
965
+ *
966
+ * @param TResume $value
967
+ *
968
+ * @return TSuspend|null Value from the next suspension point or NULL if the fiber returns.
969
+ *
970
+ * @throws FiberError If the fiber has not started, is running, or has terminated.
971
+ * @throws Throwable If the fiber callable throws an uncaught exception.
972
+ */
973
+ public function resume (mixed $ value = null ): mixed {}
974
+
975
+ /**
976
+ * Throws the given exception into the fiber from {@see Fiber::suspend()}.
977
+ * Returns when the fiber suspends or terminates.
978
+ *
979
+ * @param Throwable $exception
980
+ *
981
+ * @return TSuspend|null Value from the next suspension point or NULL if the fiber returns.
982
+ *
983
+ * @throws FiberError If the fiber has not started, is running, or has terminated.
984
+ * @throws Throwable If the fiber callable throws an uncaught exception.
985
+ */
986
+ public function throw (Throwable $ exception ): mixed {}
987
+
988
+ /**
989
+ * @return bool True if the fiber has been started.
990
+ */
991
+ public function isStarted (): bool {}
992
+
993
+ /**
994
+ * @return bool True if the fiber is suspended.
995
+ */
996
+ public function isSuspended (): bool {}
997
+
998
+ /**
999
+ * @return bool True if the fiber is currently running.
1000
+ */
1001
+ public function isRunning (): bool {}
1002
+
1003
+ /**
1004
+ * @return bool True if the fiber has completed execution (returned or threw).
1005
+ */
1006
+ public function isTerminated (): bool {}
1007
+
1008
+ /**
1009
+ * @return TReturn Return value of the fiber callback. NULL is returned if the fiber does not have a return statement.
1010
+ *
1011
+ * @throws FiberError If the fiber has not terminated or the fiber threw an exception.
1012
+ */
1013
+ public function getReturn (): mixed {}
1014
+ }
1015
+
1016
+ /**
1017
+ * @since 8.1
1018
+ */
1019
+ final class FiberError extends Error
1020
+ {
1021
+ public function __construct () {}
1022
+ }
1023
+
1024
+ /**
1025
+ * @since 8.1
1026
+ */
1027
+ final class ReturnTypeWillChange
1028
+ {
1029
+ public function __construct () {}
1030
+ }
0 commit comments