|
1 | 1 | #![cfg_attr(windows, feature(abi_vectorcall))] |
2 | | -use ext_php_rs::{binary::Binary, prelude::*, types::ZendObject, types::Zval}; |
| 2 | +use ext_php_rs::{ |
| 3 | + binary::Binary, |
| 4 | + boxed::ZBox, |
| 5 | + prelude::*, |
| 6 | + types::{ZendHashTable, ZendObject, Zval}, |
| 7 | + zend::ProcessGlobals, |
| 8 | +}; |
3 | 9 | use std::collections::HashMap; |
4 | 10 |
|
5 | 11 | #[php_function] |
@@ -57,6 +63,41 @@ pub fn test_object(a: &mut ZendObject) -> &mut ZendObject { |
57 | 63 | a |
58 | 64 | } |
59 | 65 |
|
| 66 | +// GLOBALS |
| 67 | +#[php_function] |
| 68 | +pub fn test_globals_http_get() -> ZBox<ZendHashTable> { |
| 69 | + ProcessGlobals::get().http_get_vars().to_owned() |
| 70 | +} |
| 71 | + |
| 72 | +#[php_function] |
| 73 | +pub fn test_globals_http_post() -> ZBox<ZendHashTable> { |
| 74 | + ProcessGlobals::get().http_post_vars().to_owned() |
| 75 | +} |
| 76 | + |
| 77 | +#[php_function] |
| 78 | +pub fn test_globals_http_cookie() -> ZBox<ZendHashTable> { |
| 79 | + ProcessGlobals::get().http_cookie_vars().to_owned() |
| 80 | +} |
| 81 | + |
| 82 | +#[php_function] |
| 83 | +pub fn test_globals_http_server() -> ZBox<ZendHashTable> { |
| 84 | + println!("{:?}", ProcessGlobals::get().http_server_vars()); |
| 85 | + ProcessGlobals::get().http_server_vars().unwrap().to_owned() |
| 86 | +} |
| 87 | + |
| 88 | +#[php_function] |
| 89 | +pub fn test_globals_http_request() -> ZBox<ZendHashTable> { |
| 90 | + ProcessGlobals::get() |
| 91 | + .http_request_vars() |
| 92 | + .unwrap() |
| 93 | + .to_owned() |
| 94 | +} |
| 95 | + |
| 96 | +#[php_function] |
| 97 | +pub fn test_globals_http_files() -> ZBox<ZendHashTable> { |
| 98 | + ProcessGlobals::get().http_files_vars().to_owned() |
| 99 | +} |
| 100 | + |
60 | 101 | #[php_function] |
61 | 102 | pub fn test_closure() -> Closure { |
62 | 103 | Closure::wrap(Box::new(|a| a) as Box<dyn Fn(String) -> String>) |
@@ -179,6 +220,7 @@ mod integration { |
179 | 220 | mod callable; |
180 | 221 | mod class; |
181 | 222 | mod closure; |
| 223 | + mod globals; |
182 | 224 | mod nullable; |
183 | 225 | mod number; |
184 | 226 | mod object; |
|
0 commit comments