Skip to content

Commit a396085

Browse files
committed
fmt
1 parent b6a2d18 commit a396085

File tree

2 files changed

+20
-47
lines changed

2 files changed

+20
-47
lines changed

src/zend/globals.rs

Lines changed: 18 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ use std::ops::{Deref, DerefMut};
44
use std::slice;
55
use std::str;
66

7-
87
use parking_lot::{const_rwlock, RwLock, RwLockReadGuard, RwLockWriteGuard};
98

109
use crate::boxed::ZBox;
1110
use crate::ffi::{
12-
_zend_executor_globals, ext_php_rs_executor_globals, ext_php_rs_process_globals, ext_php_rs_sapi_globals,
13-
php_core_globals, sapi_globals_struct, TRACK_VARS_COOKIE, TRACK_VARS_ENV, TRACK_VARS_FILES, TRACK_VARS_GET,
14-
TRACK_VARS_POST, TRACK_VARS_REQUEST, TRACK_VARS_SERVER, sapi_request_info, zend_is_auto_global, sapi_headers_struct, sapi_header_struct
11+
_zend_executor_globals, ext_php_rs_executor_globals, ext_php_rs_process_globals,
12+
ext_php_rs_sapi_globals, php_core_globals, sapi_globals_struct, sapi_header_struct,
13+
sapi_headers_struct, sapi_request_info, zend_is_auto_global, TRACK_VARS_COOKIE, TRACK_VARS_ENV,
14+
TRACK_VARS_FILES, TRACK_VARS_GET, TRACK_VARS_POST, TRACK_VARS_REQUEST, TRACK_VARS_SERVER,
1515
};
1616

1717
use crate::types::{ZendHashTable, ZendObject, ZendStr};
@@ -112,10 +112,9 @@ impl ProcessGlobals {
112112

113113
/// Get the HTTP Server variables. Equivalent of $_SERVER.
114114
pub fn http_server_vars(&self) -> Option<&ZendHashTable> {
115-
116115
// $_SERVER is lazy-initted, we need to call zend_is_auto_global
117116
// if it's not already populated.
118-
if ! self.http_globals[TRACK_VARS_SERVER as usize].is_array() {
117+
if !self.http_globals[TRACK_VARS_SERVER as usize].is_array() {
119118
let name = ZendStr::new("_SERVER", false).as_mut_ptr();
120119
unsafe { zend_is_auto_global(name) };
121120
}
@@ -169,7 +168,6 @@ impl ProcessGlobals {
169168
}
170169
}
171170

172-
173171
/// Stores global variables used in the SAPI.
174172
pub type SapiGlobals = sapi_globals_struct;
175173

@@ -208,7 +206,7 @@ impl SapiGlobals {
208206
&self.request_info
209207
}
210208

211-
pub fn sapi_headers(&self) -> &SapiHeaders{
209+
pub fn sapi_headers(&self) -> &SapiHeaders {
212210
&self.sapi_headers
213211
}
214212
}
@@ -247,27 +245,21 @@ impl SapiRequestInfo {
247245
if self.request_method.is_null() {
248246
return None;
249247
}
250-
unsafe {
251-
CStr::from_ptr( self.request_method ).to_str().ok()
252-
}
248+
unsafe { CStr::from_ptr(self.request_method).to_str().ok() }
253249
}
254250

255251
pub fn query_string(&self) -> Option<&str> {
256252
if self.query_string.is_null() {
257253
return None;
258254
}
259-
unsafe {
260-
CStr::from_ptr( self.query_string ).to_str().ok()
261-
}
255+
unsafe { CStr::from_ptr(self.query_string).to_str().ok() }
262256
}
263257

264258
pub fn cookie_data(&self) -> Option<&str> {
265259
if self.cookie_data.is_null() {
266260
return None;
267261
}
268-
unsafe {
269-
CStr::from_ptr( self.cookie_data ).to_str().ok()
270-
}
262+
unsafe { CStr::from_ptr(self.cookie_data).to_str().ok() }
271263
}
272264

273265
pub fn content_length(&self) -> i64 {
@@ -278,18 +270,14 @@ impl SapiRequestInfo {
278270
if self.path_translated.is_null() {
279271
return None;
280272
}
281-
unsafe {
282-
CStr::from_ptr( self.path_translated ).to_str().ok()
283-
}
273+
unsafe { CStr::from_ptr(self.path_translated).to_str().ok() }
284274
}
285275

286276
pub fn request_uri(&self) -> Option<&str> {
287277
if self.request_uri.is_null() {
288278
return None;
289279
}
290-
unsafe {
291-
CStr::from_ptr( self.request_uri ).to_str().ok()
292-
}
280+
unsafe { CStr::from_ptr(self.request_uri).to_str().ok() }
293281
}
294282

295283
// Todo: request_body _php_stream
@@ -298,9 +286,7 @@ impl SapiRequestInfo {
298286
if self.content_type.is_null() {
299287
return None;
300288
}
301-
unsafe {
302-
CStr::from_ptr( self.content_type ).to_str().ok()
303-
}
289+
unsafe { CStr::from_ptr(self.content_type).to_str().ok() }
304290
}
305291

306292
pub fn headers_only(&self) -> bool {
@@ -321,45 +307,35 @@ impl SapiRequestInfo {
321307
if self.auth_user.is_null() {
322308
return None;
323309
}
324-
unsafe {
325-
CStr::from_ptr( self.auth_user ).to_str().ok()
326-
}
310+
unsafe { CStr::from_ptr(self.auth_user).to_str().ok() }
327311
}
328312

329313
pub fn auth_password(&self) -> Option<&str> {
330314
if self.auth_password.is_null() {
331315
return None;
332316
}
333-
unsafe {
334-
CStr::from_ptr( self.auth_password ).to_str().ok()
335-
}
317+
unsafe { CStr::from_ptr(self.auth_password).to_str().ok() }
336318
}
337319

338320
pub fn auth_digest(&self) -> Option<&str> {
339321
if self.auth_digest.is_null() {
340322
return None;
341323
}
342-
unsafe {
343-
CStr::from_ptr( self.auth_digest ).to_str().ok()
344-
}
324+
unsafe { CStr::from_ptr(self.auth_digest).to_str().ok() }
345325
}
346326

347327
pub fn argv0(&self) -> Option<&str> {
348328
if self.argv0.is_null() {
349329
return None;
350330
}
351-
unsafe {
352-
CStr::from_ptr( self.argv0 ).to_str().ok()
353-
}
331+
unsafe { CStr::from_ptr(self.argv0).to_str().ok() }
354332
}
355333

356334
pub fn current_user(&self) -> Option<&str> {
357335
if self.current_user.is_null() {
358336
return None;
359337
}
360-
unsafe {
361-
CStr::from_ptr( self.current_user ).to_str().ok()
362-
}
338+
unsafe { CStr::from_ptr(self.current_user).to_str().ok() }
363339
}
364340

365341
pub fn current_user_length(&self) -> i32 {
@@ -374,15 +350,12 @@ impl SapiRequestInfo {
374350
if self.argv.is_null() {
375351
return None;
376352
}
377-
unsafe {
378-
CStr::from_ptr( *self.argv ).to_str().ok()
379-
}
353+
unsafe { CStr::from_ptr(*self.argv).to_str().ok() }
380354
}
381355

382356
pub fn proto_num(&self) -> i32 {
383357
self.proto_num
384358
}
385-
386359
}
387360

388361
/// Executor globals rwlock.

src/zend/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ mod ex;
77
mod function;
88
mod globals;
99
mod handlers;
10-
mod module;
1110
mod linked_list;
11+
mod module;
1212

1313
use crate::{error::Result, ffi::php_printf};
1414
use std::ffi::CString;
@@ -21,8 +21,8 @@ pub use globals::ExecutorGlobals;
2121
pub use globals::ProcessGlobals;
2222
pub use globals::SapiGlobals;
2323
pub use handlers::ZendObjectHandlers;
24-
pub use module::ModuleEntry;
2524
pub use linked_list::ZendLinkedList;
25+
pub use module::ModuleEntry;
2626

2727
// Used as the format string for `php_printf`.
2828
const FORMAT_STR: &[u8] = b"%s\0";

0 commit comments

Comments
 (0)