diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b04a7ecc..77bac6dd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,10 +1,19 @@ +# Copyright (c) 2019 jmjoy +# PHPER is licensed under Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan +# PSL v2. You may obtain a copy of Mulan PSL v2 at: +# http://license.coscl.org.cn/MulanPSL2 +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY +# KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO +# NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. + name: CI on: push: branches: - master - - 0.4.x-dev pull_request: branches: [ "**" ] diff --git a/.github/workflows/license.yml b/.github/workflows/license.yml new file mode 100644 index 00000000..f0448bc7 --- /dev/null +++ b/.github/workflows/license.yml @@ -0,0 +1,30 @@ +# Copyright (c) 2019 jmjoy +# PHPER is licensed under Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan +# PSL v2. You may obtain a copy of Mulan PSL v2 at: +# http://license.coscl.org.cn/MulanPSL2 +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY +# KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO +# NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. + +name: License + +on: + push: + branches: + - master + pull_request: + branches: [ "**" ] + +jobs: + license-check: + name: License check + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Check License Header + uses: apache/skywalking-eyes/header/@d5466651aaded6fbd588d2278eccc469afc89d92 + with: + config: .licenserc.yaml diff --git a/.licenserc.yaml b/.licenserc.yaml new file mode 100644 index 00000000..52721594 --- /dev/null +++ b/.licenserc.yaml @@ -0,0 +1,33 @@ +# Copyright (c) 2019 jmjoy +# PHPER is licensed under Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan +# PSL v2. You may obtain a copy of Mulan PSL v2 at: +# http://license.coscl.org.cn/MulanPSL2 +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY +# KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO +# NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. + +header: + license: + spdx-id: MulanPSL-2.0 + copyright-owner: jmjoy + software-name: PHPER + + paths-ignore: + - 'LICENSE' + - 'NOTICE' + - '**/*.md' + - '**/*.lock' + - '**/.gitignore' + - '**/.gitmodules' + - 'vendor' + - '.cargo' + - '.vscode' + - '.idea' + + comment: on-failure + +dependency: + files: + - Cargo.toml diff --git a/.rustfmt.toml b/.rustfmt.toml index d5c73b2d..1c500095 100644 --- a/.rustfmt.toml +++ b/.rustfmt.toml @@ -1,3 +1,13 @@ +# Copyright (c) 2019 jmjoy +# PHPER is licensed under Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan +# PSL v2. You may obtain a copy of Mulan PSL v2 at: +# http://license.coscl.org.cn/MulanPSL2 +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY +# KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO +# NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. + fn_args_layout = "Compressed" format_code_in_doc_comments = true format_macro_bodies = true diff --git a/Cargo.toml b/Cargo.toml index 04cab855..04d47860 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,3 +1,13 @@ +# Copyright (c) 2019 jmjoy +# PHPER is licensed under Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan +# PSL v2. You may obtain a copy of Mulan PSL v2 at: +# http://license.coscl.org.cn/MulanPSL2 +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY +# KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO +# NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. + [workspace] members = [ "phper", diff --git a/examples/hello/Cargo.toml b/examples/hello/Cargo.toml index be3cfba2..1ed5d02c 100644 --- a/examples/hello/Cargo.toml +++ b/examples/hello/Cargo.toml @@ -1,3 +1,13 @@ +# Copyright (c) 2019 jmjoy +# PHPER is licensed under Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan +# PSL v2. You may obtain a copy of Mulan PSL v2 at: +# http://license.coscl.org.cn/MulanPSL2 +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY +# KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO +# NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. + [package] name = "hello" version = "0.0.0" diff --git a/examples/http-client/Cargo.toml b/examples/http-client/Cargo.toml index 3ebee03f..78662fdc 100644 --- a/examples/http-client/Cargo.toml +++ b/examples/http-client/Cargo.toml @@ -1,3 +1,13 @@ +# Copyright (c) 2019 jmjoy +# PHPER is licensed under Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan +# PSL v2. You may obtain a copy of Mulan PSL v2 at: +# http://license.coscl.org.cn/MulanPSL2 +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY +# KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO +# NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. + [package] name = "http-client" version = "0.0.0" diff --git a/examples/http-server/Cargo.toml b/examples/http-server/Cargo.toml index cc7ea236..b94cf00f 100644 --- a/examples/http-server/Cargo.toml +++ b/examples/http-server/Cargo.toml @@ -1,3 +1,13 @@ +# Copyright (c) 2019 jmjoy +# PHPER is licensed under Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan +# PSL v2. You may obtain a copy of Mulan PSL v2 at: +# http://license.coscl.org.cn/MulanPSL2 +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY +# KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO +# NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. + [package] name = "http-server" version = "0.0.0" diff --git a/examples/logging/Cargo.toml b/examples/logging/Cargo.toml index 2d8fd959..1d8b17ee 100644 --- a/examples/logging/Cargo.toml +++ b/examples/logging/Cargo.toml @@ -1,3 +1,13 @@ +# Copyright (c) 2019 jmjoy +# PHPER is licensed under Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan +# PSL v2. You may obtain a copy of Mulan PSL v2 at: +# http://license.coscl.org.cn/MulanPSL2 +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY +# KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO +# NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. + [package] name = "logging" version = "0.0.0" diff --git a/phper-alloc/Cargo.toml b/phper-alloc/Cargo.toml index 2f87c8a0..cadff571 100644 --- a/phper-alloc/Cargo.toml +++ b/phper-alloc/Cargo.toml @@ -1,3 +1,13 @@ +# Copyright (c) 2019 jmjoy +# PHPER is licensed under Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan +# PSL v2. You may obtain a copy of Mulan PSL v2 at: +# http://license.coscl.org.cn/MulanPSL2 +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY +# KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO +# NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. + [package] name = "phper-alloc" version = "0.4.0-alpha.3" diff --git a/phper-alloc/src/macros.rs b/phper-alloc/src/macros.rs index 3fc86ec5..9f9e0569 100644 --- a/phper-alloc/src/macros.rs +++ b/phper-alloc/src/macros.rs @@ -1,3 +1,13 @@ +// Copyright (c) 2019 jmjoy +// PHPER is licensed under Mulan PSL v2. +// You can use this software according to the terms and conditions of the Mulan +// PSL v2. You may obtain a copy of Mulan PSL v2 at: +// http://license.coscl.org.cn/MulanPSL2 +// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY +// KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO +// NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +// See the Mulan PSL v2 for more details. + /// Wrapper of `EBox::new`. /// /// # Examples diff --git a/phper-build/Cargo.toml b/phper-build/Cargo.toml index 3e14b506..76b1fd7d 100644 --- a/phper-build/Cargo.toml +++ b/phper-build/Cargo.toml @@ -1,3 +1,13 @@ +# Copyright (c) 2019 jmjoy +# PHPER is licensed under Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan +# PSL v2. You may obtain a copy of Mulan PSL v2 at: +# http://license.coscl.org.cn/MulanPSL2 +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY +# KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO +# NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. + [package] name = "phper-build" version = "0.4.0-alpha.3" diff --git a/phper-macros/Cargo.toml b/phper-macros/Cargo.toml index ce84e973..264a3be0 100644 --- a/phper-macros/Cargo.toml +++ b/phper-macros/Cargo.toml @@ -1,3 +1,13 @@ +# Copyright (c) 2019 jmjoy +# PHPER is licensed under Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan +# PSL v2. You may obtain a copy of Mulan PSL v2 at: +# http://license.coscl.org.cn/MulanPSL2 +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY +# KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO +# NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. + [package] name = "phper-macros" version = "0.4.0-alpha.3" diff --git a/phper-sys/Cargo.toml b/phper-sys/Cargo.toml index ea1f358b..5cd282c9 100644 --- a/phper-sys/Cargo.toml +++ b/phper-sys/Cargo.toml @@ -1,3 +1,13 @@ +# Copyright (c) 2019 jmjoy +# PHPER is licensed under Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan +# PSL v2. You may obtain a copy of Mulan PSL v2 at: +# http://license.coscl.org.cn/MulanPSL2 +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY +# KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO +# NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. + [package] name = "phper-sys" version = "0.4.0-alpha.3" diff --git a/phper-test/Cargo.toml b/phper-test/Cargo.toml index 43e6e6f7..90ee60f1 100644 --- a/phper-test/Cargo.toml +++ b/phper-test/Cargo.toml @@ -1,3 +1,13 @@ +# Copyright (c) 2019 jmjoy +# PHPER is licensed under Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan +# PSL v2. You may obtain a copy of Mulan PSL v2 at: +# http://license.coscl.org.cn/MulanPSL2 +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY +# KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO +# NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. + [package] name = "phper-test" version = "0.4.0-alpha.3" diff --git a/phper-test/etc/php-fpm.conf b/phper-test/etc/php-fpm.conf index 0f6860f4..c7908037 100644 --- a/phper-test/etc/php-fpm.conf +++ b/phper-test/etc/php-fpm.conf @@ -1,3 +1,13 @@ +; Copyright (c) 2019 jmjoy +; PHPER is licensed under Mulan PSL v2. +; You can use this software according to the terms and conditions of the Mulan +; PSL v2. You may obtain a copy of Mulan PSL v2 at: +; http://license.coscl.org.cn/MulanPSL2 +; THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY +; KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO +; NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +; See the Mulan PSL v2 for more details. + [global] error_log = /tmp/.php-fpm.log diff --git a/phper/Cargo.toml b/phper/Cargo.toml index 2a0e78d3..60c62d09 100644 --- a/phper/Cargo.toml +++ b/phper/Cargo.toml @@ -1,3 +1,13 @@ +# Copyright (c) 2019 jmjoy +# PHPER is licensed under Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan +# PSL v2. You may obtain a copy of Mulan PSL v2 at: +# http://license.coscl.org.cn/MulanPSL2 +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY +# KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO +# NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. + [package] name = "phper" version = "0.4.0-alpha.3" diff --git a/phper/src/values.rs b/phper/src/values.rs index 0fd298aa..50d1b6db 100644 --- a/phper/src/values.rs +++ b/phper/src/values.rs @@ -27,7 +27,6 @@ use std::{ convert::TryInto, marker::PhantomData, mem::{transmute, zeroed, MaybeUninit}, - os::raw::c_int, str, }; @@ -120,7 +119,7 @@ impl ExecuteData { pub fn get_parameter(&mut self, index: usize) -> &mut ZVal { unsafe { - let val = phper_zend_call_arg(self.as_mut_ptr(), index as c_int); + let val = phper_zend_call_var_num(self.as_mut_ptr(), index.try_into().unwrap()); ZVal::from_mut_ptr(val) } } @@ -306,7 +305,7 @@ impl ZVal { } fn inner_expect_z_res(&self) -> crate::Result<&mut ZRes> { - if self.get_type_info().is_object() { + if self.get_type_info().is_resource() { unsafe { Ok(ZRes::from_mut_ptr(phper_z_res_p(self.as_ptr()))) } } else { Err(ExpectTypeError::new(TypeInfo::RESOURCE, self.get_type_info()).into()) diff --git a/tests/integration/Cargo.toml b/tests/integration/Cargo.toml index d5914de5..cc6e5e04 100644 --- a/tests/integration/Cargo.toml +++ b/tests/integration/Cargo.toml @@ -1,3 +1,13 @@ +# Copyright (c) 2019 jmjoy +# PHPER is licensed under Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan +# PSL v2. You may obtain a copy of Mulan PSL v2 at: +# http://license.coscl.org.cn/MulanPSL2 +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY +# KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO +# NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. + [package] name = "integration" version = "0.0.0"