Skip to content

Commit 0726bff

Browse files
committed
Arrange ci.
1 parent edac5e8 commit 0726bff

File tree

10 files changed

+54
-88
lines changed

10 files changed

+54
-88
lines changed

.github/workflows/ci.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,25 @@ jobs:
4242
- name: Checkout
4343
uses: actions/checkout@v2
4444

45-
- name: Install Rust
45+
- name: Install Rust Nightly
4646
uses: actions-rs/toolchain@v1
4747
with:
4848
toolchain: nightly
4949
override: true
50-
components: rustfmt, clippy
50+
components: rustfmt
51+
52+
- name: Install Rust Stable
53+
uses: actions-rs/toolchain@v1
54+
with:
55+
toolchain: stable
56+
override: true
57+
components: rustfmt
5158

5259
- name: Cargo fmt
5360
uses: actions-rs/cargo@v1
5461
with:
5562
command: fmt
56-
args: --all -- --check
63+
args: +nightly --all -- --check
5764

5865
- name: Cargo build
5966
uses: actions-rs/cargo@v1

examples/hello/src/lib.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
11
use phper::{
22
arrays::Array,
3-
c_str_ptr,
4-
classes::{Class, StdClass, This},
5-
functions::{create_zend_arg_info, Argument},
3+
classes::{StdClass, This},
4+
functions::Argument,
65
ini::Policy,
7-
modules::{read_global_module, write_global_module, Module, ModuleArgs},
6+
modules::{Module, ModuleArgs},
87
php_get_module,
9-
sys::{
10-
php_info_print_table_end, php_info_print_table_row, php_info_print_table_start,
11-
zend_function_entry, OnUpdateBool, PHP_INI_SYSTEM,
12-
},
13-
values::{ExecuteData, SetVal, Val},
14-
Throwable,
8+
values::{SetVal, Val},
159
};
16-
use std::{fs::OpenOptions, io::Write};
1710

1811
fn module_init(_args: ModuleArgs) -> bool {
1912
true

phper-test/src/lib.rs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
use once_cell::sync::OnceCell;
22
use std::{
3-
env, ffi::OsStr, fmt::Debug, fs::read_to_string, io::Write, path::Path, process::Command,
3+
env,
4+
ffi::{OsStr, OsString},
5+
fmt::Debug,
6+
fs::read_to_string,
7+
io::Write,
8+
path::{Path, PathBuf},
9+
process::Command,
410
};
511
use tempfile::NamedTempFile;
6-
use std::ffi::OsString;
7-
use std::path::PathBuf;
8-
use std::error::Error;
9-
10-
pub fn test_php_scripts(
11-
exe_path: impl AsRef<Path>,
12-
scripts: &[impl AsRef<Path>],
13-
) {
12+
13+
pub fn test_php_scripts(exe_path: impl AsRef<Path>, scripts: &[impl AsRef<Path>]) {
1414
let context = php_context();
1515

1616
let lib_path = get_lib_path(exe_path);
@@ -115,8 +115,12 @@ fn execute_command<S: AsRef<OsStr> + Debug>(argv: &[S]) -> String {
115115

116116
fn get_lib_path(exe_path: impl AsRef<Path>) -> PathBuf {
117117
let exe_path = exe_path.as_ref();
118-
let exe_stem = exe_path.file_stem().expect("failed to get current exe stem");
119-
let target_dir = exe_path.parent().expect("failed to get current exe directory");
118+
let exe_stem = exe_path
119+
.file_stem()
120+
.expect("failed to get current exe stem");
121+
let target_dir = exe_path
122+
.parent()
123+
.expect("failed to get current exe directory");
120124

121125
let mut ext_name = OsString::new();
122126
ext_name.push("lib");

phper/src/arrays.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use crate::{sys::*, values::Val};
22
use std::{
33
mem::zeroed,
44
ops::{Deref, DerefMut},
5-
ptr::null_mut,
65
};
76

87
pub struct Array {

phper/src/classes.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
use crate::{
2-
functions::{invoke, Argument, Callable, FunctionEntity, FunctionEntry, Method},
2+
functions::{Argument, Callable, FunctionEntity, FunctionEntry, Method},
33
sys::*,
44
values::{SetVal, Val},
55
};
66
use once_cell::sync::OnceCell;
77
use std::{
88
mem::zeroed,
99
os::raw::c_int,
10-
ptr::{null, null_mut},
11-
sync::{
12-
atomic::{AtomicPtr, Ordering},
13-
Arc, Once, RwLock,
14-
},
10+
ptr::null_mut,
11+
sync::atomic::{AtomicPtr, Ordering},
1512
};
1613

1714
pub trait Class: Send + Sync {
@@ -58,7 +55,7 @@ impl StdClass {
5855
}
5956

6057
pub fn extends(&mut self, name: impl ToString) {
61-
let mut name = name.to_string();
58+
let name = name.to_string();
6259
self.parent = Some(name);
6360
}
6461
}

phper/src/errors.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
1-
use crate::{
2-
classes::{ClassEntity, ClassEntry},
3-
modules::{read_global_module, write_global_module},
4-
Error::Other,
5-
};
1+
use crate::{classes::ClassEntity, modules::read_global_module, Error::Other};
62
use anyhow::anyhow;
7-
use once_cell::sync::Lazy;
8-
use std::{
9-
cell::RefCell, error, ffi::FromBytesWithNulError, io, ptr::null_mut, str::Utf8Error,
10-
sync::atomic::AtomicPtr,
11-
};
3+
use std::{error, ffi::FromBytesWithNulError, io, str::Utf8Error};
124

135
pub type Result<T> = std::result::Result<T, self::Error>;
146

phper/src/functions.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
use crate::{
22
classes::{ClassEntry, This},
3-
errors::Throwable,
4-
ini::create_ini_entry_ex,
53
sys::*,
64
values::{ExecuteData, SetVal, Val},
75
};
86
use std::{
9-
cell::Cell,
10-
ffi::CStr,
11-
mem::{size_of, transmute, zeroed},
12-
os::raw::{c_char, c_int},
13-
ptr::{null, null_mut},
7+
mem::zeroed,
8+
os::raw::c_char,
9+
ptr::null,
1410
sync::atomic::{AtomicPtr, Ordering},
1511
};
1612

@@ -51,6 +47,7 @@ pub(crate) enum Callable {
5147

5248
#[repr(transparent)]
5349
pub struct FunctionEntry {
50+
#[allow(dead_code)]
5451
inner: zend_function_entry,
5552
}
5653

@@ -88,9 +85,9 @@ impl FunctionEntity {
8885
));
8986
}
9087

91-
infos.push(unsafe { zeroed::<zend_internal_arg_info>() });
88+
infos.push(zeroed::<zend_internal_arg_info>());
9289

93-
let mut last_arg_info = unsafe { zeroed::<zend_internal_arg_info>() };
90+
let mut last_arg_info = zeroed::<zend_internal_arg_info>();
9491
last_arg_info.name = ((&self.handler) as *const _ as *mut i8).cast();
9592
infos.push(last_arg_info);
9693

phper/src/ini.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
use crate::sys::{
2-
phper_zend_ini_mh, zend_ini_entry, zend_ini_entry_def, zend_string, OnUpdateBool, OnUpdateLong,
3-
OnUpdateReal, OnUpdateString, PHP_INI_ALL, PHP_INI_PERDIR, PHP_INI_SYSTEM, PHP_INI_USER,
2+
phper_zend_ini_mh, zend_ini_entry_def, OnUpdateBool, OnUpdateLong, OnUpdateReal,
3+
OnUpdateString, PHP_INI_ALL, PHP_INI_PERDIR, PHP_INI_SYSTEM, PHP_INI_USER,
44
};
55
use std::{
6-
cell::Cell,
76
ffi::CStr,
8-
mem::{size_of, transmute},
9-
os::raw::{c_char, c_int, c_void},
7+
os::raw::{c_char, c_void},
108
ptr::null_mut,
119
str,
12-
sync::atomic::AtomicPtr,
1310
};
1411

1512
type OnModify = phper_zend_ini_mh;

phper/src/modules.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
11
use crate::{
22
c_str_ptr,
3-
classes::{Class, ClassEntity, ClassEntry, StdClass},
4-
functions::{create_zend_arg_info, invoke, Argument, Callable, Function, FunctionEntity},
3+
classes::{Class, ClassEntity, StdClass},
4+
functions::{Argument, Callable, Function, FunctionEntity},
55
ini::{IniEntity, IniValue, Policy, StrPtrBox},
66
sys::*,
77
EXCEPTION_CLASS_NAME,
88
};
99
use once_cell::sync::Lazy;
1010
use std::{
1111
borrow::BorrowMut,
12-
cell::{Cell, RefCell, RefMut},
12+
cell::RefCell,
1313
collections::HashMap,
14-
ffi::CStr,
15-
mem::{forget, size_of, transmute, zeroed},
16-
ops::DerefMut,
17-
os::raw::{c_char, c_int, c_uchar, c_uint, c_ushort, c_void},
14+
mem::{size_of, zeroed},
15+
os::raw::{c_int, c_uchar, c_uint, c_ushort},
1816
ptr::{null, null_mut},
19-
sync::{atomic::AtomicPtr, Arc, Mutex, RwLock, RwLockReadGuard, RwLockWriteGuard},
20-
thread::LocalKey,
17+
sync::RwLock,
2118
};
2219

2320
static GLOBAL_MODULE: Lazy<RwLock<Module>> = Lazy::new(Default::default);
@@ -293,7 +290,7 @@ impl Module {
293290
Self::STR_INI_ENTITIES
294291
.with(|entities| Self::push_ini_entry(&mut entries, &mut *entities.borrow_mut()));
295292

296-
entries.push(unsafe { zeroed::<zend_ini_entry_def>() });
293+
entries.push(zeroed::<zend_ini_entry_def>());
297294

298295
Box::into_raw(entries.into_boxed_slice()).cast()
299296
}
@@ -315,6 +312,7 @@ impl Module {
315312
}
316313

317314
pub struct ModuleArgs {
315+
#[allow(dead_code)]
318316
r#type: c_int,
319317
module_number: c_int,
320318
}

phper/src/values.rs

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,5 @@
1-
use crate::{
2-
arrays::Array,
3-
c_str_ptr,
4-
classes::{This, Visibility},
5-
errors::Throwable,
6-
sys::*,
7-
};
8-
use std::{
9-
borrow::Cow,
10-
cell::Cell,
11-
ffi::{c_void, CStr},
12-
io::empty,
13-
mem::{size_of, zeroed},
14-
os::raw::{c_char, c_int},
15-
ptr::null_mut,
16-
slice,
17-
slice::from_raw_parts,
18-
str,
19-
sync::atomic::Ordering,
20-
};
1+
use crate::{arrays::Array, errors::Throwable, sys::*};
2+
use std::{mem::zeroed, os::raw::c_int, slice::from_raw_parts, str, sync::atomic::Ordering};
213

224
#[repr(transparent)]
235
pub struct ExecuteData {

0 commit comments

Comments
 (0)