This repository was archived by the owner on Jun 16, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed
Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -503,6 +503,25 @@ spawn "sleep"(5);
503503spawn (fn() => sleep(1))();
504504```
505505
506+ The ` spawn ` or ` with ` keywords does not affect the ability to define ` functions ` , ` constants ` , or ` classes `
507+ with the same name:
508+
509+ ``` php
510+ function spawn(): void {} // <- Allowed
511+
512+ const SPAWN = 1; // <- Allowed
513+
514+ class Spawn {} // <- Allowed
515+ ```
516+
517+ The `spawn` expression cannot appear before `namespace` or `use` declarations:
518+
519+ ```php
520+ spawn myFunction(); // <- Not allowed
521+ namespace MyNamespace;
522+ use MyNamespace\MyClass;
523+ ```
524+
506525#### Spawn closure expression
507526
508527Allows creating a coroutine from a closure directly when using `spawn`:
@@ -1103,6 +1122,25 @@ The `await` expression can be used just like any other expression together with
11031122 }
11041123```
11051124
1125+ The ` await ` or ` until ` keywords does not affect the ability to define ` functions ` , ` constants ` , or ` classes `
1126+ with the same name:
1127+
1128+ ``` php
1129+ function await(): void {} // <- Allowed
1130+
1131+ const AWAIT = 1; // <- Allowed
1132+ $x = AWAIT + 2; // <- Allowed
1133+
1134+ class Await {} // <- Allowed
1135+ ```
1136+
1137+ The `await` expression cannot appear before `namespace` or `use` declarations:
1138+
1139+ ```php
1140+ await file_get_contents( ' file1.txt' ); // <- Not allowed
1141+ namespace MyNamespace;
1142+ use MyNamespace\MyClass;
1143+ ```
11061144
11071145#### Await with cancellation
11081146
You can’t perform that action at this time.
0 commit comments