PluginProbe ʕ •ᴥ•ʔ
Paid Membership Plugin, Ecommerce, User Registration Form, Login Form, User Profile & Restrict Content – ProfilePress / trunk
Paid Membership Plugin, Ecommerce, User Registration Form, Login Form, User Profile & Restrict Content – ProfilePress vtrunk
4.17.2 4.17.1 4.17.0 4.16.19 4.16.18 4.16.17 4.16.16 trunk 1.0 1.0.1 1.0.2 1.1 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.5a 1.1.6 1.1.7 1.2 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.3 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.4 1.4.1 1.4.2 1.5 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.6 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.7 1.7.1 1.7.2 1.8 1.8.1 1.8.10 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9 1.9.1 1.9.10 1.9.11 1.9.12 1.9.13 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.1.9 2.2.10 2.2.11 2.2.12 2.2.13 2.2.14 2.2.15 2.2.16 2.2.2 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 3.0 3.1 3.1.1 3.1.10 3.1.11 3.1.12 3.1.13 3.1.14 3.1.15 3.1.16 3.1.17 3.1.18 3.1.19 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.10 3.2.11 3.2.12 3.2.13 3.2.14 3.2.15 3.2.16 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 4.0.0 4.0.1 4.0.2 4.0.3 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4 4.10.0 4.10.1 4.10.2 4.10.3 4.11.0 4.12.0 4.13.0 4.13.1 4.13.2 4.13.3 4.13.4 4.14.0 4.14.1 4.14.2 4.14.3 4.14.4 4.15.0 4.15.1 4.15.10 4.15.11 4.15.12 4.15.13 4.15.14 4.15.15 4.15.16 4.15.17 4.15.18 4.15.19 4.15.2 4.15.20 4.15.20.1 4.15.21 4.15.22 4.15.23 4.15.24 4.15.25 4.15.3 4.15.4 4.15.5 4.15.6 4.15.7 4.15.8 4.15.9 4.16.0 4.16.1 4.16.10 4.16.11 4.16.12 4.16.13 4.16.14 4.16.15 4.16.2 4.16.3 4.16.4 4.16.5 4.16.6 4.16.7 4.16.8 4.16.9 4.2.0 4.3.0 4.3.1 4.3.2 4.4.0 4.4.1 4.5.0 4.5.1 4.5.2 4.5.3 4.5.4 4.5.5 4.6.0 4.7.0 4.8.0 4.9.0
wp-user-avatar / third-party / vendor / thecodingmachine / safe / deprecated / libevent.php
wp-user-avatar / third-party / vendor / thecodingmachine / safe / deprecated Last commit date
Exceptions 3 days ago apc.php 3 days ago functionsList.php 3 days ago libevent.php 3 days ago mssql.php 3 days ago stats.php 3 days ago
libevent.php
460 lines
1 <?php
2
3 namespace ProfilePressVendor\Safe;
4
5 use ProfilePressVendor\Safe\Exceptions\LibeventException;
6 /**
7 * event_add schedules the execution of the event
8 * when the event specified in event_set occurs or in at least the time
9 * specified by the timeout argument. If
10 * timeout was not specified, not timeout is set. The
11 * event must be already initalized by event_set
12 * and event_base_set functions. If the
13 * event already has a timeout set, it is replaced by
14 * the new one.
15 *
16 * @param resource $event Valid event resource.
17 * @param int $timeout Optional timeout (in microseconds).
18 * @throws LibeventException
19 *
20 */
21 function event_add($event, int $timeout = -1): void
22 {
23 error_clear_last();
24 $result = \event_add($event, $timeout);
25 if ($result === \false) {
26 throw LibeventException::createFromPhpError();
27 }
28 }
29 /**
30 * Abort the active event loop immediately. The behaviour is similar to
31 * break statement.
32 *
33 * @param resource $event_base Valid event base resource.
34 * @throws LibeventException
35 *
36 */
37 function event_base_loopbreak($event_base): void
38 {
39 error_clear_last();
40 $result = \event_base_loopbreak($event_base);
41 if ($result === \false) {
42 throw LibeventException::createFromPhpError();
43 }
44 }
45 /**
46 * The next event loop iteration after the given timer expires will complete
47 * normally, then exit without blocking for events again.
48 *
49 * @param resource $event_base Valid event base resource.
50 * @param int $timeout Optional timeout parameter (in microseconds).
51 * @throws LibeventException
52 *
53 */
54 function event_base_loopexit($event_base, int $timeout = -1): void
55 {
56 error_clear_last();
57 $result = \event_base_loopexit($event_base, $timeout);
58 if ($result === \false) {
59 throw LibeventException::createFromPhpError();
60 }
61 }
62 /**
63 * Returns new event base, which can be used later in event_base_set,
64 * event_base_loop and other functions.
65 *
66 * @return resource event_base_new returns valid event base resource on
67 * success.
68 * @throws LibeventException
69 *
70 */
71 function event_base_new()
72 {
73 error_clear_last();
74 $result = \event_base_new();
75 if ($result === \false) {
76 throw LibeventException::createFromPhpError();
77 }
78 return $result;
79 }
80 /**
81 * Sets the number of different event priority levels.
82 *
83 * By default all events are scheduled with the same priority
84 * (npriorities/2).
85 * Using event_base_priority_init you can change the number
86 * of event priority levels and then set a desired priority for each event.
87 *
88 * @param resource $event_base Valid event base resource.
89 * @param int $npriorities The number of event priority levels.
90 * @throws LibeventException
91 *
92 */
93 function event_base_priority_init($event_base, int $npriorities): void
94 {
95 error_clear_last();
96 $result = \event_base_priority_init($event_base, $npriorities);
97 if ($result === \false) {
98 throw LibeventException::createFromPhpError();
99 }
100 }
101 /**
102 * Some event mechanisms do not survive across fork. The
103 * event_base needs to be reinitialized with this
104 * function.
105 *
106 * @param resource $event_base Valid event base resource that needs to be re-initialized.
107 * @throws LibeventException
108 *
109 */
110 function event_base_reinit($event_base): void
111 {
112 error_clear_last();
113 $result = \event_base_reinit($event_base);
114 if ($result === \false) {
115 throw LibeventException::createFromPhpError();
116 }
117 }
118 /**
119 * Associates the event_base with the
120 * event.
121 *
122 * @param resource $event Valid event resource.
123 * @param resource $event_base Valid event base resource.
124 * @throws LibeventException
125 *
126 */
127 function event_base_set($event, $event_base): void
128 {
129 error_clear_last();
130 $result = \event_base_set($event, $event_base);
131 if ($result === \false) {
132 throw LibeventException::createFromPhpError();
133 }
134 }
135 /**
136 * Assign the specified bevent to the
137 * event_base.
138 *
139 * @param resource $bevent Valid buffered event resource.
140 * @param resource $event_base Valid event base resource.
141 * @throws LibeventException
142 *
143 */
144 function event_buffer_base_set($bevent, $event_base): void
145 {
146 error_clear_last();
147 $result = \event_buffer_base_set($bevent, $event_base);
148 if ($result === \false) {
149 throw LibeventException::createFromPhpError();
150 }
151 }
152 /**
153 * Disables the specified buffered event.
154 *
155 * @param resource $bevent Valid buffered event resource.
156 * @param int $events Any combination of EV_READ and
157 * EV_WRITE.
158 * @throws LibeventException
159 *
160 */
161 function event_buffer_disable($bevent, int $events): void
162 {
163 error_clear_last();
164 $result = \event_buffer_disable($bevent, $events);
165 if ($result === \false) {
166 throw LibeventException::createFromPhpError();
167 }
168 }
169 /**
170 * Enables the specified buffered event.
171 *
172 * @param resource $bevent Valid buffered event resource.
173 * @param int $events Any combination of EV_READ and
174 * EV_WRITE.
175 * @throws LibeventException
176 *
177 */
178 function event_buffer_enable($bevent, int $events): void
179 {
180 error_clear_last();
181 $result = \event_buffer_enable($bevent, $events);
182 if ($result === \false) {
183 throw LibeventException::createFromPhpError();
184 }
185 }
186 /**
187 * Libevent provides an abstraction layer on top of the regular event API.
188 * Using buffered event you don't need to deal with the I/O manually, instead
189 * it provides input and output buffers that get filled and drained
190 * automatically.
191 *
192 * @param resource $stream Valid PHP stream resource. Must be castable to file descriptor.
193 * @param mixed $readcb Callback to invoke where there is data to read, or NULL if
194 * no callback is desired.
195 * @param mixed $writecb Callback to invoke where the descriptor is ready for writing,
196 * or NULL if no callback is desired.
197 * @param mixed $errorcb Callback to invoke where there is an error on the descriptor, cannot be
198 * NULL.
199 * @param mixed $arg An argument that will be passed to each of the callbacks (optional).
200 * @return resource event_buffer_new returns new buffered event resource
201 * on success.
202 * @throws LibeventException
203 *
204 */
205 function event_buffer_new($stream, $readcb, $writecb, $errorcb, $arg = null)
206 {
207 error_clear_last();
208 if ($arg !== null) {
209 $result = \event_buffer_new($stream, $readcb, $writecb, $errorcb, $arg);
210 } else {
211 $result = \event_buffer_new($stream, $readcb, $writecb, $errorcb);
212 }
213 if ($result === \false) {
214 throw LibeventException::createFromPhpError();
215 }
216 return $result;
217 }
218 /**
219 * Assign a priority to the bevent.
220 *
221 * @param resource $bevent Valid buffered event resource.
222 * @param int $priority Priority level. Cannot be less than zero and cannot exceed maximum
223 * priority level of the event base (see event_base_priority_init).
224 * @throws LibeventException
225 *
226 */
227 function event_buffer_priority_set($bevent, int $priority): void
228 {
229 error_clear_last();
230 $result = \event_buffer_priority_set($bevent, $priority);
231 if ($result === \false) {
232 throw LibeventException::createFromPhpError();
233 }
234 }
235 /**
236 * Sets or changes existing callbacks for the buffered event.
237 *
238 * @param resource $event Valid buffered event resource.
239 * @param mixed $readcb Callback to invoke where there is data to read, or NULL if
240 * no callback is desired.
241 * @param mixed $writecb Callback to invoke where the descriptor is ready for writing,
242 * or NULL if no callback is desired.
243 * @param mixed $errorcb Callback to invoke where there is an error on the descriptor, cannot be
244 * NULL.
245 * @param mixed $arg An argument that will be passed to each of the callbacks (optional).
246 * @throws LibeventException
247 *
248 */
249 function event_buffer_set_callback($event, $readcb, $writecb, $errorcb, $arg = null): void
250 {
251 error_clear_last();
252 if ($arg !== null) {
253 $result = \event_buffer_set_callback($event, $readcb, $writecb, $errorcb, $arg);
254 } else {
255 $result = \event_buffer_set_callback($event, $readcb, $writecb, $errorcb);
256 }
257 if ($result === \false) {
258 throw LibeventException::createFromPhpError();
259 }
260 }
261 /**
262 * Writes data to the specified buffered event. The data is appended to the
263 * output buffer and written to the descriptor when it becomes available for
264 * writing.
265 *
266 * @param resource $bevent Valid buffered event resource.
267 * @param string $data The data to be written.
268 * @param int $data_size Optional size parameter. event_buffer_write writes
269 * all the data by default.
270 * @throws LibeventException
271 *
272 */
273 function event_buffer_write($bevent, string $data, int $data_size = -1): void
274 {
275 error_clear_last();
276 $result = \event_buffer_write($bevent, $data, $data_size);
277 if ($result === \false) {
278 throw LibeventException::createFromPhpError();
279 }
280 }
281 /**
282 * Cancels the event.
283 *
284 * @param resource $event Valid event resource.
285 * @throws LibeventException
286 *
287 */
288 function event_del($event): void
289 {
290 error_clear_last();
291 $result = \event_del($event);
292 if ($result === \false) {
293 throw LibeventException::createFromPhpError();
294 }
295 }
296 /**
297 * Creates and returns a new event resource.
298 *
299 * @return resource event_new returns a new event resource on success.
300 * @throws LibeventException
301 *
302 */
303 function event_new()
304 {
305 error_clear_last();
306 $result = \event_new();
307 if ($result === \false) {
308 throw LibeventException::createFromPhpError();
309 }
310 return $result;
311 }
312 /**
313 * Assign a priority to the event.
314 *
315 * @param resource $event Valid event resource.
316 * @param int $priority Priority level. Cannot be less than zero and cannot exceed maximum
317 * priority level of the event base (see
318 * event_base_priority_init).
319 * @throws LibeventException
320 *
321 */
322 function event_priority_set($event, int $priority): void
323 {
324 error_clear_last();
325 $result = \event_priority_set($event, $priority);
326 if ($result === \false) {
327 throw LibeventException::createFromPhpError();
328 }
329 }
330 /**
331 * Prepares the event to be used in event_add. The event
332 * is prepared to call the function specified by the callback
333 * on the events specified in parameter events, which
334 * is a set of the following flags: EV_TIMEOUT,
335 * EV_SIGNAL, EV_READ,
336 * EV_WRITE and EV_PERSIST.
337 *
338 * If EV_SIGNAL bit is set in parameter events,
339 * the fd is interpreted as signal number.
340 *
341 * After initializing the event, use event_base_set to
342 * associate the event with its event base.
343 *
344 * In case of matching event, these three arguments are passed to the
345 * callback function:
346 *
347 *
348 * fd
349 *
350 *
351 * Signal number or resource indicating the stream.
352 *
353 *
354 *
355 *
356 * events
357 *
358 *
359 * A flag indicating the event. Consists of the following flags:
360 * EV_TIMEOUT, EV_SIGNAL,
361 * EV_READ, EV_WRITE
362 * and EV_PERSIST.
363 *
364 *
365 *
366 *
367 * arg
368 *
369 *
370 * Optional parameter, previously passed to event_set
371 * as arg.
372 *
373 *
374 *
375 *
376 *
377 * @param resource $event Valid event resource.
378 * @param mixed $fd Valid PHP stream resource. The stream must be castable to file
379 * descriptor, so you most likely won't be able to use any of filtered
380 * streams.
381 * @param int $events A set of flags indicating the desired event, can be
382 * EV_READ and/or EV_WRITE.
383 * The additional flag EV_PERSIST makes the event
384 * to persist until event_del is called, otherwise
385 * the callback is invoked only once.
386 * @param mixed $callback Callback function to be called when the matching event occurs.
387 * @param mixed $arg Optional callback parameter.
388 * @throws LibeventException
389 *
390 */
391 function event_set($event, $fd, int $events, $callback, $arg = null): void
392 {
393 error_clear_last();
394 if ($arg !== null) {
395 $result = \event_set($event, $fd, $events, $callback, $arg);
396 } else {
397 $result = \event_set($event, $fd, $events, $callback);
398 }
399 if ($result === \false) {
400 throw LibeventException::createFromPhpError();
401 }
402 }
403 /**
404 * Prepares the timer event to be used in event_add. The
405 * event is prepared to call the function specified by the
406 * callback when the event timeout elapses.
407 *
408 * After initializing the event, use event_base_set to
409 * associate the event with its event base.
410 *
411 * In case of matching event, these three arguments are passed to the
412 * callback function:
413 *
414 *
415 * fd
416 *
417 *
418 * Signal number or resource indicating the stream.
419 *
420 *
421 *
422 *
423 * events
424 *
425 *
426 * A flag indicating the event. This will always be
427 * EV_TIMEOUT for timer events.
428 *
429 *
430 *
431 *
432 * arg
433 *
434 *
435 * Optional parameter, previously passed to
436 * event_timer_set as arg.
437 *
438 *
439 *
440 *
441 *
442 * @param resource $event Valid event resource.
443 * @param callable $callback Callback function to be called when the matching event occurs.
444 * @param mixed $arg Optional callback parameter.
445 * @throws LibeventException
446 *
447 */
448 function event_timer_set($event, callable $callback, $arg = null): void
449 {
450 error_clear_last();
451 if ($arg !== null) {
452 $result = \event_timer_set($event, $callback, $arg);
453 } else {
454 $result = \event_timer_set($event, $callback);
455 }
456 if ($result === \false) {
457 throw LibeventException::createFromPhpError();
458 }
459 }
460