-
Notifications
You must be signed in to change notification settings - Fork 111
/
Swow.php
2535 lines (2231 loc) · 99.3 KB
/
Swow.php
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/** @noinspection PhpUnused, PhpInconsistentReturnPointsInspection, PhpMissingParentConstructorInspection, PhpReturnDocTypeMismatchInspection, PhpMixedReturnTypeCanBeReducedInspection */
namespace
{
!defined('AF_INET') && define('AF_INET', 2);
!defined('AF_INET6') && define('AF_INET6', 30);
!defined('AF_UNSPEC') && define('AF_UNSPEC', 0);
const STREAM_POLLNONE = 0;
const STREAM_POLLIN = 1;
const STREAM_POLLPRI = 2;
const STREAM_POLLOUT = 4;
const STREAM_POLLERR = 8;
const STREAM_POLLHUP = 16;
const STREAM_POLLNVAL = 32;
}
namespace
{
class Swow
{
public static function isLibraryLoaded(): bool { }
}
}
namespace
{
/**
* sleep milliseconds
*
* @param int $milli_seconds time to sleep, in ms
*/
function msleep(int $milli_seconds): int { }
}
namespace
{
function gethostbyname2(string $hostname, int $address_family = \AF_INET): string { }
}
namespace
{
/** unlimited version of stream_select() */
function stream_select_unlimited(?array &$read, ?array &$write, ?array &$except, ?int $seconds, ?int $microseconds = null): int|false { }
}
namespace
{
/**
* poll one stream for events
* @param int $events flags: STREAM_POLL* constants combinations
* @return int flags: STREAM_POLL* constants combinations, STREAM_POLLNONE means timeout
* @throws RuntimeException on runtime error, e.g. poll has been cancelled or poll failed
*/
function stream_poll_one($stream, int $events, int $timeout = -1): int { }
}
namespace Swow
{
class Extension
{
public const VERSION = '1.5.2';
public const VERSION_ID = 10502;
public const MAJOR_VERSION = 1;
public const MINOR_VERSION = 5;
public const RELEASE_VERSION = 2;
public const EXTRA_VERSION = '';
public static function isBuiltWith(string $lib): bool { }
}
}
namespace Swow
{
class Errno
{
/**
* This constant holds UV_E2BIG value, it's platform-dependent.
*
* At Linux and macOS platforms, this constant means "Argument list too long"
* At Windows platform, this constant may have a value `-4093`
*/
public const E2BIG = -7;
/**
* This constant holds UV_EACCES value, it's platform-dependent.
*
* At Linux and macOS platforms, this constant means "Permission denied"
* At Windows platform, this constant may have a value `-4092`
*/
public const EACCES = -13;
/**
* This constant holds UV_EADDRINUSE value, it's platform-dependent.
*
* At Linux platform, this constant means "Address already in use"
* At macOS platform, this constant may have a value `-48` means "Address already in use"
* At Windows platform, this constant may have a value `-4091`
*/
public const EADDRINUSE = -98;
/**
* This constant holds UV_EADDRNOTAVAIL value, it's platform-dependent.
*
* At Linux platform, this constant means "Cannot assign requested address"
* At macOS platform, this constant may have a value `-49` means "Can't assign requested address"
* At Windows platform, this constant may have a value `-4090`
*/
public const EADDRNOTAVAIL = -99;
/**
* This constant holds UV_EAFNOSUPPORT value, it's platform-dependent.
*
* At Linux platform, this constant means "Address family not supported by protocol"
* At macOS platform, this constant may have a value `-47` means "Address family not supported by protocol family"
* At Windows platform, this constant may have a value `-4089`
*/
public const EAFNOSUPPORT = -97;
/**
* This constant holds UV_EAGAIN value, it's platform-dependent.
*
* At Linux platform, this constant means "Try again"
* At macOS platform, this constant may have a value `-35` means "Resource temporarily unavailable"
* At Windows platform, this constant may have a value `-4088`
*/
public const EAGAIN = -11;
public const EAI_ADDRFAMILY = -3000;
public const EAI_AGAIN = -3001;
public const EAI_BADFLAGS = -3002;
public const EAI_BADHINTS = -3013;
public const EAI_CANCELED = -3003;
public const EAI_FAIL = -3004;
public const EAI_FAMILY = -3005;
public const EAI_MEMORY = -3006;
public const EAI_NODATA = -3007;
public const EAI_NONAME = -3008;
public const EAI_OVERFLOW = -3009;
public const EAI_PROTOCOL = -3014;
public const EAI_SERVICE = -3010;
public const EAI_SOCKTYPE = -3011;
/**
* This constant holds UV_EALREADY value, it's platform-dependent.
*
* At Linux platform, this constant means "Operation already in progress"
* At macOS platform, this constant may have a value `-37` means "Operation already in progress"
* At Windows platform, this constant may have a value `-4084`
*/
public const EALREADY = -114;
/**
* This constant holds UV_EBADF value, it's platform-dependent.
*
* At Linux platform, this constant means "Bad file number"
* At macOS platform, this constant means "Bad file descriptor"
* At Windows platform, this constant may have a value `-4083`
*/
public const EBADF = -9;
/**
* This constant holds UV_EBUSY value, it's platform-dependent.
*
* At Linux platform, this constant means "Device or resource busy"
* At macOS platform, this constant means "Device / Resource busy"
* At Windows platform, this constant may have a value `-4082`
*/
public const EBUSY = -16;
/**
* This constant holds UV_ECANCELED value, it's platform-dependent.
*
* At Linux platform, this constant means "Operation Canceled"
* At macOS platform, this constant may have a value `-89` means "Operation canceled"
* At Windows platform, this constant may have a value `-4081`
*/
public const ECANCELED = -125;
public const ECHARSET = -4080;
/**
* This constant holds UV_ECONNABORTED value, it's platform-dependent.
*
* At Linux platform, this constant means "Software caused connection abort"
* At macOS platform, this constant may have a value `-53` means "Software caused connection abort"
* At Windows platform, this constant may have a value `-4079`
*/
public const ECONNABORTED = -103;
/**
* This constant holds UV_ECONNREFUSED value, it's platform-dependent.
*
* At Linux platform, this constant means "Connection refused"
* At macOS platform, this constant may have a value `-61` means "Connection refused"
* At Windows platform, this constant may have a value `-4078`
*/
public const ECONNREFUSED = -111;
/**
* This constant holds UV_ECONNRESET value, it's platform-dependent.
*
* At Linux platform, this constant means "Connection reset by peer"
* At macOS platform, this constant may have a value `-54` means "Connection reset by peer"
* At Windows platform, this constant may have a value `-4077`
*/
public const ECONNRESET = -104;
/**
* This constant holds UV_EDESTADDRREQ value, it's platform-dependent.
*
* At Linux platform, this constant means "Destination address required"
* At macOS platform, this constant may have a value `-39` means "Destination address required"
* At Windows platform, this constant may have a value `-4076`
*/
public const EDESTADDRREQ = -89;
/**
* This constant holds UV_EEXIST value, it's platform-dependent.
*
* At Linux and macOS platforms, this constant means "File exists"
* At Windows platform, this constant may have a value `-4075`
*/
public const EEXIST = -17;
/**
* This constant holds UV_EFAULT value, it's platform-dependent.
*
* At Linux and macOS platforms, this constant means "Bad address"
* At Windows platform, this constant may have a value `-4074`
*/
public const EFAULT = -14;
/**
* This constant holds UV_EFBIG value, it's platform-dependent.
*
* At Linux and macOS platforms, this constant means "File too large"
* At Windows platform, this constant may have a value `-4036`
*/
public const EFBIG = -27;
/**
* This constant holds UV_EHOSTUNREACH value, it's platform-dependent.
*
* At Linux platform, this constant means "No route to host"
* At macOS platform, this constant may have a value `-65` means "No route to host"
* At Windows platform, this constant may have a value `-4073`
*/
public const EHOSTUNREACH = -113;
/**
* This constant holds UV_EINTR value, it's platform-dependent.
*
* At Linux and macOS platforms, this constant means "Interrupted system call"
* At Windows platform, this constant may have a value `-4072`
*/
public const EINTR = -4;
/**
* This constant holds UV_EINVAL value, it's platform-dependent.
*
* At Linux and macOS platforms, this constant means "Invalid argument"
* At Windows platform, this constant may have a value `-4071`
*/
public const EINVAL = -22;
/**
* This constant holds UV_EIO value, it's platform-dependent.
*
* At Linux platform, this constant means "I/O error"
* At macOS platform, this constant means "Input/output error"
* At Windows platform, this constant may have a value `-4070`
*/
public const EIO = -5;
/**
* This constant holds UV_EISCONN value, it's platform-dependent.
*
* At Linux platform, this constant means "Transport endpoint is already connected"
* At macOS platform, this constant may have a value `-56` means "Socket is already connected"
* At Windows platform, this constant may have a value `-4069`
*/
public const EISCONN = -106;
/**
* This constant holds UV_EISDIR value, it's platform-dependent.
*
* At Linux and macOS platforms, this constant means "Is a directory"
* At Windows platform, this constant may have a value `-4068`
*/
public const EISDIR = -21;
/**
* This constant holds UV_ELOOP value, it's platform-dependent.
*
* At Linux platform, this constant means "Too many symbolic links encountered"
* At macOS platform, this constant may have a value `-62` means "Too many levels of symbolic links"
* At Windows platform, this constant may have a value `-4067`
*/
public const ELOOP = -40;
/**
* This constant holds UV_EMFILE value, it's platform-dependent.
*
* At Linux and macOS platforms, this constant means "Too many open files"
* At Windows platform, this constant may have a value `-4066`
*/
public const EMFILE = -24;
/**
* This constant holds UV_EMSGSIZE value, it's platform-dependent.
*
* At Linux platform, this constant means "Message too long"
* At macOS platform, this constant may have a value `-40` means "Message too long"
* At Windows platform, this constant may have a value `-4065`
*/
public const EMSGSIZE = -90;
/**
* This constant holds UV_ENAMETOOLONG value, it's platform-dependent.
*
* At Linux platform, this constant means "File name too long"
* At macOS platform, this constant may have a value `-63` means "File name too long"
* At Windows platform, this constant may have a value `-4064`
*/
public const ENAMETOOLONG = -36;
/**
* This constant holds UV_ENETDOWN value, it's platform-dependent.
*
* At Linux platform, this constant means "Network is down"
* At macOS platform, this constant may have a value `-50` means "Network is down"
* At Windows platform, this constant may have a value `-4063`
*/
public const ENETDOWN = -100;
/**
* This constant holds UV_ENETUNREACH value, it's platform-dependent.
*
* At Linux platform, this constant means "Network is unreachable"
* At macOS platform, this constant may have a value `-51` means "Network is unreachable"
* At Windows platform, this constant may have a value `-4062`
*/
public const ENETUNREACH = -101;
/**
* This constant holds UV_ENFILE value, it's platform-dependent.
*
* At Linux platform, this constant means "File table overflow"
* At macOS platform, this constant means "Too many open files in system"
* At Windows platform, this constant may have a value `-4061`
*/
public const ENFILE = -23;
/**
* This constant holds UV_ENOBUFS value, it's platform-dependent.
*
* At Linux platform, this constant means "No buffer space available"
* At macOS platform, this constant may have a value `-55` means "No buffer space available"
* At Windows platform, this constant may have a value `-4060`
*/
public const ENOBUFS = -105;
/**
* This constant holds UV_ENODEV value, it's platform-dependent.
*
* At Linux platform, this constant means "No such device"
* At macOS platform, this constant means "Operation not supported by device"
* At Windows platform, this constant may have a value `-4059`
*/
public const ENODEV = -19;
/**
* This constant holds UV_ENOENT value, it's platform-dependent.
*
* At Linux and macOS platforms, this constant means "No such file or directory"
* At Windows platform, this constant may have a value `-4058`
*/
public const ENOENT = -2;
/**
* This constant holds UV_ENOMEM value, it's platform-dependent.
*
* At Linux platform, this constant means "Out of memory"
* At macOS platform, this constant means "Cannot allocate memory"
* At Windows platform, this constant may have a value `-4057`
*/
public const ENOMEM = -12;
/**
* This constant holds UV_ENONET value, it's platform-dependent.
*
* At Linux platform, this constant means "Machine is not on the network"
* At macOS and Windows platforms, this constant may have a value `-4056`
*/
public const ENONET = -64;
/**
* This constant holds UV_ENOPROTOOPT value, it's platform-dependent.
*
* At Linux platform, this constant means "Protocol not available"
* At macOS platform, this constant may have a value `-42` means "Protocol not available"
* At Windows platform, this constant may have a value `-4035`
*/
public const ENOPROTOOPT = -92;
/**
* This constant holds UV_ENOSPC value, it's platform-dependent.
*
* At Linux and macOS platforms, this constant means "No space left on device"
* At Windows platform, this constant may have a value `-4055`
*/
public const ENOSPC = -28;
/**
* This constant holds UV_ENOSYS value, it's platform-dependent.
*
* At Linux platform, this constant means "Invalid system call number"
* At macOS platform, this constant may have a value `-78` means "Function not implemented"
* At Windows platform, this constant may have a value `-4054`
*/
public const ENOSYS = -38;
/**
* This constant holds UV_ENOTCONN value, it's platform-dependent.
*
* At Linux platform, this constant means "Transport endpoint is not connected"
* At macOS platform, this constant may have a value `-57` means "Socket is not connected"
* At Windows platform, this constant may have a value `-4053`
*/
public const ENOTCONN = -107;
/**
* This constant holds UV_ENOTDIR value, it's platform-dependent.
*
* At Linux and macOS platforms, this constant means "Not a directory"
* At Windows platform, this constant may have a value `-4052`
*/
public const ENOTDIR = -20;
/**
* This constant holds UV_ENOTEMPTY value, it's platform-dependent.
*
* At Linux platform, this constant means "Directory not empty"
* At macOS platform, this constant may have a value `-66` means "Directory not empty"
* At Windows platform, this constant may have a value `-4051`
*/
public const ENOTEMPTY = -39;
/**
* This constant holds UV_ENOTSOCK value, it's platform-dependent.
*
* At Linux platform, this constant means "Socket operation on non-socket"
* At macOS platform, this constant may have a value `-38` means "Socket operation on non-socket"
* At Windows platform, this constant may have a value `-4050`
*/
public const ENOTSOCK = -88;
/**
* This constant holds UV_ENOTSUP value, it's platform-dependent.
*
* At macOS platform, this constant may have a value `-45` means "Operation not supported"
*/
public const ENOTSUP = -4049;
/**
* This constant holds UV_EOVERFLOW value, it's platform-dependent.
*
* At Linux platform, this constant means "Value too large for defined data type"
* At macOS platform, this constant may have a value `-84` means "Value too large to be stored in data type"
* At Windows platform, this constant may have a value `-4026`
*/
public const EOVERFLOW = -75;
/**
* This constant holds UV_EPERM value, it's platform-dependent.
*
* At Linux and macOS platforms, this constant means "Operation not permitted"
* At Windows platform, this constant may have a value `-4048`
*/
public const EPERM = -1;
/**
* This constant holds UV_EPIPE value, it's platform-dependent.
*
* At Linux and macOS platforms, this constant means "Broken pipe"
* At Windows platform, this constant may have a value `-4047`
*/
public const EPIPE = -32;
/**
* This constant holds UV_EPROTO value, it's platform-dependent.
*
* At Linux platform, this constant means "Protocol error"
* At macOS platform, this constant may have a value `-100` means "Protocol error"
* At Windows platform, this constant may have a value `-4046`
*/
public const EPROTO = -71;
/**
* This constant holds UV_EPROTONOSUPPORT value, it's platform-dependent.
*
* At Linux platform, this constant means "Protocol not supported"
* At macOS platform, this constant may have a value `-43` means "Protocol not supported"
* At Windows platform, this constant may have a value `-4045`
*/
public const EPROTONOSUPPORT = -93;
/**
* This constant holds UV_EPROTOTYPE value, it's platform-dependent.
*
* At Linux platform, this constant means "Protocol wrong type for socket"
* At macOS platform, this constant may have a value `-41` means "Protocol wrong type for socket"
* At Windows platform, this constant may have a value `-4044`
*/
public const EPROTOTYPE = -91;
/**
* This constant holds UV_ERANGE value, it's platform-dependent.
*
* At Linux platform, this constant means "Math result not representable"
* At macOS platform, this constant means "Result too large"
* At Windows platform, this constant may have a value `-4034`
*/
public const ERANGE = -34;
/**
* This constant holds UV_EROFS value, it's platform-dependent.
*
* At Linux and macOS platforms, this constant means "Read-only file system"
* At Windows platform, this constant may have a value `-4043`
*/
public const EROFS = -30;
/**
* This constant holds UV_ESHUTDOWN value, it's platform-dependent.
*
* At Linux platform, this constant means "Cannot send after transport endpoint shutdown"
* At macOS platform, this constant may have a value `-58` means "Can't send after socket shutdown"
* At Windows platform, this constant may have a value `-4042`
*/
public const ESHUTDOWN = -108;
/**
* This constant holds UV_ESPIPE value, it's platform-dependent.
*
* At Linux and macOS platforms, this constant means "Illegal seek"
* At Windows platform, this constant may have a value `-4041`
*/
public const ESPIPE = -29;
/**
* This constant holds UV_ESRCH value, it's platform-dependent.
*
* At Linux and macOS platforms, this constant means "No such process"
* At Windows platform, this constant may have a value `-4040`
*/
public const ESRCH = -3;
/**
* This constant holds UV_ETIMEDOUT value, it's platform-dependent.
*
* At Linux platform, this constant means "Connection timed out"
* At macOS platform, this constant may have a value `-60` means "Operation timed out"
* At Windows platform, this constant may have a value `-4039`
*/
public const ETIMEDOUT = -110;
/**
* This constant holds UV_ETXTBSY value, it's platform-dependent.
*
* At Linux and macOS platforms, this constant means "Text file busy"
* At Windows platform, this constant may have a value `-4038`
*/
public const ETXTBSY = -26;
/**
* This constant holds UV_EXDEV value, it's platform-dependent.
*
* At Linux and macOS platforms, this constant means "Cross-device link"
* At Windows platform, this constant may have a value `-4037`
*/
public const EXDEV = -18;
public const UNKNOWN = -4094;
public const EOF = -4095;
/**
* This constant holds UV_ENXIO value, it's platform-dependent.
*
* At Linux platform, this constant means "No such device or address"
* At macOS platform, this constant means "Device not configured"
* At Windows platform, this constant may have a value `-4033`
*/
public const ENXIO = -6;
/**
* This constant holds UV_EMLINK value, it's platform-dependent.
*
* At Linux and macOS platforms, this constant means "Too many links"
* At Windows platform, this constant may have a value `-4032`
*/
public const EMLINK = -31;
/**
* This constant holds UV_EHOSTDOWN value, it's platform-dependent.
*
* At Linux platform, this constant means "Host is down"
* At macOS platform, this constant may have a value `-64` means "Host is down"
* At Windows platform, this constant may have a value `-4031`
*/
public const EHOSTDOWN = -112;
/**
* This constant holds UV_EREMOTEIO value, it's platform-dependent.
*
* At Linux platform, this constant means "Remote I/O error"
* At macOS and Windows platforms, this constant may have a value `-4030`
*/
public const EREMOTEIO = -121;
/**
* This constant holds UV_ENOTTY value, it's platform-dependent.
*
* At Linux platform, this constant means "Not a typewriter"
* At macOS platform, this constant means "Inappropriate ioctl for device"
* At Windows platform, this constant may have a value `-4029`
*/
public const ENOTTY = -25;
/**
* This constant holds UV_EFTYPE value, it's platform-dependent.
*
* At macOS platform, this constant may have a value `-79` means "Inappropriate file type or format"
*/
public const EFTYPE = -4028;
/**
* This constant holds UV_EILSEQ value, it's platform-dependent.
*
* At Linux platform, this constant means "Illegal byte sequence"
* At macOS platform, this constant may have a value `-92` means "Illegal byte sequence"
* At Windows platform, this constant may have a value `-4027`
*/
public const EILSEQ = -84;
/**
* This constant holds UV_ESOCKTNOSUPPORT value, it's platform-dependent.
*
* At Linux platform, this constant means "Socket type not supported"
* At macOS platform, this constant may have a value `-44` means "Socket type not supported"
* At Windows platform, this constant may have a value `-4025`
*/
public const ESOCKTNOSUPPORT = -94;
public const ENODATA = -61;
/**
* This constant holds UV_ESTALE value, it's platform-dependent.
*
* At Linux platform, this constant means "Stale file handle"
* At macOS platform, this constant may have a value `-70` means "Stale NFS file handle"
* At Windows platform, this constant may have a value `-10070`
*/
public const ESTALE = -116;
public const UNCODED = -9763;
public const EPREV = -9762;
public const EMISUSE = -9761;
public const EVALUE = -9760;
public const ELOCKED = -9759;
public const ECLOSED = -9758;
public const EDEADLK = -9757;
public const ESSL = -9756;
public const ENOCERT = -9755;
public const ECERT = -9754;
public const ECHILD = -9753;
public const EHP_OK = -816000;
public const EHP_INTERNAL = -816001;
public const EHP_STRICT = -816002;
public const EHP_CR_EXPECTED = -816025;
public const EHP_LF_EXPECTED = -816003;
public const EHP_UNEXPECTED_CONTENT_LENGTH = -816004;
public const EHP_UNEXPECTED_SPACE = -816030;
public const EHP_CLOSED_CONNECTION = -816005;
public const EHP_INVALID_METHOD = -816006;
public const EHP_INVALID_URL = -816007;
public const EHP_INVALID_CONSTANT = -816008;
public const EHP_INVALID_VERSION = -816009;
public const EHP_INVALID_HEADER_TOKEN = -816010;
public const EHP_INVALID_CONTENT_LENGTH = -816011;
public const EHP_INVALID_CHUNK_SIZE = -816012;
public const EHP_INVALID_STATUS = -816013;
public const EHP_INVALID_EOF_STATE = -816014;
public const EHP_INVALID_TRANSFER_ENCODING = -816015;
public const EHP_CB_MESSAGE_BEGIN = -816016;
public const EHP_CB_HEADERS_COMPLETE = -816017;
public const EHP_CB_MESSAGE_COMPLETE = -816018;
public const EHP_CB_CHUNK_HEADER = -816019;
public const EHP_CB_CHUNK_COMPLETE = -816020;
public const EHP_PAUSED = -816021;
public const EHP_PAUSED_UPGRADE = -816022;
public const EHP_PAUSED_H2_UPGRADE = -816023;
public const EHP_USER = -816024;
public const EHP_CB_URL_COMPLETE = -816026;
public const EHP_CB_STATUS_COMPLETE = -816027;
public const EHP_CB_METHOD_COMPLETE = -816032;
public const EHP_CB_VERSION_COMPLETE = -816033;
public const EHP_CB_HEADER_FIELD_COMPLETE = -816028;
public const EHP_CB_HEADER_VALUE_COMPLETE = -816029;
public const EHP_CB_CHUNK_EXTENSION_NAME_COMPLETE = -816034;
public const EHP_CB_CHUNK_EXTENSION_VALUE_COMPLETE = -816035;
public const EHP_CB_RESET = -816031;
public const EHP_NOMEM = -816065;
public const EHP_MULTIPART = -816066;
public static function getDescriptionOf(int $error): string { }
}
}
namespace Swow
{
class Log
{
public const TYPE_DEBUG = 1;
public const TYPE_INFO = 2;
public const TYPE_NOTICE = 4;
public const TYPE_WARNING = 8;
public const TYPE_ERROR = 16;
public const TYPE_CORE_ERROR = 32;
public const TYPES_ALL = 63;
public const TYPES_DEFAULT = 62;
public const TYPES_ABNORMAL = 60;
public const TYPES_UNFILTERABLE = 48;
/**
* get enabled log types
*
* @return int the log type flag
*/
public static function getTypes(): int { }
/**
* set logging types
*
* @param int $types the log type flag
*/
public static function setTypes(int $types): void { }
}
}
namespace Swow
{
class Exception extends \RuntimeException { }
}
namespace Swow
{
class CallException extends \Swow\Exception
{
protected mixed $returnValue;
final public function getReturnValue(): mixed { }
}
}
namespace Swow
{
final class Defer
{
public function __construct() { }
}
}
namespace Swow
{
/**
* Coroutine class is the abstract of [coroutine](https://en.wikipedia.org/wiki/Coroutine).
*
* A coroutine is a subroutine actively suspend itself, and get resumed when there is no other running coroutines, it's co-operative so it was called co-routine.
*
* We call suspending self "yield", when yielding form a coroutine, the coroutine suspends its execution, the scheduler will find and execute another coroutine can continue.
*
* Swow have hooked most of IO operation functions in PHP, an IO coroutine will yield when calling these functions. When the IO operation is done, and current coroutine yield, the scheduler may continue the fore-mentioned IO coroutine. This is how Swow make IO concurrency.
*/
class Coroutine
{
public const STATE_NONE = 0;
public const STATE_WAITING = 1;
public const STATE_RUNNING = 2;
public const STATE_DEAD = 3;
public function __construct(callable $callable) { }
/**
* Create a coroutine and run it immediately
*
* @note context swap happens here
*
* @param callable $callable the coroutine body
* @param mixed ...$data arguments passed to the callable
* @return static the new created coroutine
*/
public static function run(callable $callable, mixed ...$data): static { }
/**
* Resume coroutine execution
*
* @note context swap happens here when success
*/
public function resume(mixed ...$data): mixed { }
/**
* Yield from current coroutine
*
* @note context swap happens here when success
*/
public static function yield(mixed $data = null): mixed { }
/** Get unique coroutine id */
public function getId(): int { }
/** Get current coroutine */
public static function getCurrent(): self|static { }
/** Get main (the most outter) coroutine */
public static function getMain(): self|static { }
/** Get previous coroutine */
public function getPrevious(): self|static { }
/**
* Get coroutine state
*
* @return int the enum number: static::STATE_* constants
*/
public function getState(): int { }
public function getStateName(): string { }
public function getSwitches(): int { }
public static function getGlobalSwitches(): int { }
public function getStartTime(): int { }
public function getEndTime(): int { }
public function getElapsed(): int { }
public function getElapsedAsString(): string { }
public function getExitStatus(): int { }
public function isAvailable(): bool { }
public function isAlive(): bool { }
public function isExecuting(): bool { }
/**
* get current executed code file name
*
* @see Coroutine::getTrace() for params usage
*/
public function getExecutedFilename(int $level = 0): string { }
/**
* get current executed code line
*
* @see Coroutine::getTrace() for params usage
*/
public function getExecutedLineno(int $level = 0): int { }
/**
* get executed function name
*
* @see Coroutine::getTrace() for params usage
*/
public function getExecutedFunctionName(int $level = 0): string { }
/**
* get trace information
*
* positive `$level` value count frame from current to top,
* negative `$level` value count frame from top to current.
*
* for example, a stack may be like:
*
* | $level | frame | getTrace(0, 0) | getTrace(-1, 0) or getTrace(4, 0) | getTrace(0, 3) |
* | - | - | - | - | - |
* | 5 | {main} | starts here | starts here | FIXME: main? |
* | 4 / -1 | Swow\Coroutine::run('a') | | ends here | |
* | 3 / -2 | a() | | | |
* | 2 / -3 | b() | | | starts here |
* | 1 / -4 | c() | | | |
* | 0 / -5 | Swow\Coroutine->getTraceAsString() | ends here | | ends here |
*
* @param int $level trace start level
* @param int $limit trace max length, negative or 0 meaning no limit
* @param int $options trace options, same as `debug_backtrace` options { @see https://www.php.net/manual/en/function.debug-backtrace.php }
* @phan-return array<
* array{
* 'file': string,
* 'line': int,
* 'function': string,
* 'args': array<mixed>,
* 'class'?: string
* }
* >
* @phpstan-return array<
* array{
* 'file': string,
* 'line': int,
* 'function': string,
* 'args': array<mixed>,
* 'class'?: string
* }
* >
* @psalm-return array<
* array{
* 'file': string,
* 'line': int,
* 'function': string,
* 'args': array<mixed>,
* 'class'?: string
* }
* >
* @return array<array>
*/
public function getTrace(int $level = 0, int $limit = 0, int $options = \DEBUG_BACKTRACE_PROVIDE_OBJECT): array { }
/**
* get trace information as string like original php strack trace format
*
* return value maybe like
* ```plain
* #0 some.php(7): Swow\Coroutine->getTraceAsString()
* #1 some.php(10): c()
* #2 some.php(13): b()
* #3 [internal function]: a(1, 'some str', Array)
* #4 some.php(16): Swow\Coroutine::run('a', 1, 'some str', Array)
* #5 {main}
* ```
*
* @see Coroutine::getTrace() for params usage
*/
public function getTraceAsString(int $level = 0, int $limit = 0, int $options = \DEBUG_BACKTRACE_PROVIDE_OBJECT): string { }
/**
* get trace information as string like original php strack trace format in array
*
* return value maybe like
* ```php
* [
* "#0 some.php(7): Swow\Coroutine->getTraceAsString()",
* "#1 some.php(10): c()",
* "#2 some.php(13): b()",
* "#3 [internal function]: a(1, 'some str', Array)",
* "#4 some.php(16): Swow\Coroutine::run('a', 1, 'some str', Array)",
* "#5 {main}",
* ]
* ```
*
* @return array<string>
* @see Coroutine::getTrace() for params usage
*/
public function getTraceAsList(int $level = 0, int $limit = 0, int $options = \DEBUG_BACKTRACE_PROVIDE_OBJECT): array { }
/**
* get trace depth
*
* @see Coroutine::getTrace() for params usage
*/
public function getTraceDepth(int $limit = 0): int { }
/**
* get defined variables in specified scope
*
* @return array<string, mixed>
* @see Coroutine::getTrace() for params usage
*/
public function getDefinedVars(int $level = 0): array { }
/**
* set variable in specified scope
*
* @param string $name variable name
* @param mixed $value variable value
* @param bool $force force rebuild symbol table, if you donot know this, keep its default value
* @see Coroutine::getTrace() for `$level` params usage
*/
public function setLocalVar(string $name, mixed $value, int $level = 0, bool $force = true): static { }
/**
* evaluate code in specified scope
*
* @TODO string $string? why not rename it to $code
* @param string $string code to evaluate
* @see Coroutine::getTrace() for `$level` params usage
*/
public function eval(string $string, int $level = 0): mixed { }
public function call(callable $callable, int $level = 0): mixed { }
public function throw(\Throwable $throwable): mixed { }
public function kill(): void { }
public static function killAll(): void { }
public static function count(): int { }
public static function get(int $id): ?static { }
/** @return array<int, Coroutine> */
public static function getAll(): array { }
/** @return array<string, mixed> debug information for var_dump */
public function __debugInfo(): array { }
public static function registerDeadlockHandler(callable $callable): Utils\Handler { }
}
}
namespace Swow
{
class CoroutineException extends \Swow\Exception { }
}
namespace Swow
{
/**
* channel transfers information across coroutines
*
* @phan-template T
* @phpstan-template T
* @psalm-template T
*/
class Channel
{
public function __construct(int $capacity = 0) { }
/**
* push data into channel
*
* @note context switching happens here when channel is full, context switching may also happen at this even channel is not full.
*
* @phan-param T $data
* @phpstan-param T $data
* @psalm-param T $data
* @param mixed $data
* @param int $timeout in microseconds
* @return static
*/
public function push(mixed $data, int $timeout = -1): static { }
/**
* pop data from channel
*
* @note context switching happens here when channel is empty, context switching may also happen at this even channel is not empty.
*
* @param int $timeout in microseconds
* @phan-return T $data
* @phpstan-return T $data
* @psalm-return T $data
* @return mixed
*/
public function pop(int $timeout = -1): mixed { }