Skip to content

Commit 0ffec05

Browse files
Merge branch 'master' into fix/variadic-optional-arguments
2 parents 739967e + 464407b commit 0ffec05

File tree

20 files changed

+122
-57
lines changed

20 files changed

+122
-57
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
strategy:
1616
matrix:
1717
os: [ubuntu-latest, macos-latest, windows-latest]
18-
php: ["8.0", "8.1", "8.2", "8.3"]
18+
php: ["8.0", "8.1", "8.2", "8.3", "8.4"]
1919
rust: [stable, nightly]
2020
clang: ["15", "17"]
2121
phpts: [ts, nts]

README.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ Export a simple function `function hello_world(string $name): string` to PHP:
2222
use ext_php_rs::prelude::*;
2323

2424
/// Gives you a nice greeting!
25-
///
25+
///
2626
/// @param string $name Your name.
27-
///
27+
///
2828
/// @return string Nice greeting!
2929
#[php_function]
3030
pub fn hello_world(name: String) -> String {
@@ -114,8 +114,12 @@ best resource at the moment. This can be viewed at [docs.rs].
114114
## Requirements
115115

116116
- Linux, macOS or Windows-based operating system.
117-
- PHP 8.0 or later.
117+
- PHP 8.1 or later.
118118
- No support is planned for earlier versions of PHP.
119+
- PHP versions, that no longer receive security updates, will no longer be
120+
supported. They might still work, but no guarantees are made.
121+
- See <https://www.php.net/supported-versions.php> for information on PHP
122+
supported versions and their end of life dates.
119123
- Rust.
120124
- Currently, we maintain no guarantee of a MSRV, however lib.rs suggests Rust
121125
1.57 at the time of writing.
@@ -142,6 +146,10 @@ best resource at the moment. This can be viewed at [docs.rs].
142146
bundled with Microsoft Visual Studio.
143147
- `cargo-php`'s stub generation feature does not work on Windows. Rewriting this
144148
functionality to be cross-platform is on the roadmap.
149+
- To build the application in `DEBUG` mode on Windows,
150+
you must have a `PHP SDK` built with the `DEBUG` option enabled
151+
and specify the `PHP_LIB` to the folder containing the lib files.
152+
For example: set `PHP_LIB=C:\php-sdk\php-dev\vc16\x64\php-8.3.13-src\x64\Debug_TS`.
145153

146154
[vectorcall]: https://docs.microsoft.com/en-us/cpp/cpp/vectorcall?view=msvc-170
147155

allowed_bindings.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ bind! {
4545
// ext_php_rs_zend_object_release,
4646
// ext_php_rs_zend_string_init,
4747
// ext_php_rs_zend_string_release,
48-
// ext_php_rs_is_kown_valid_utf8,
49-
// ext_php_rs_set_kown_valid_utf8,
48+
// ext_php_rs_is_known_valid_utf8,
49+
// ext_php_rs_set_known_valid_utf8,
5050
object_properties_init,
5151
php_error_docref,
5252
php_info_print_table_end,

build.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,15 @@ fn check_php_version(info: &PHPInfo) -> Result<()> {
232232

233233
const PHP_84_API_VER: u32 = 20240924;
234234

235-
println!("cargo::rustc-check-cfg=cfg(php80, php81, php82, php83, php84, php_zts, php_debug, docs)");
235+
println!(
236+
"cargo::rustc-check-cfg=cfg(php80, php81, php82, php83, php84, php_zts, php_debug, docs)"
237+
);
236238
println!("cargo:rustc-cfg=php80");
237239

240+
if (MIN_PHP_API_VER..PHP_81_API_VER).contains(&version) {
241+
println!("cargo:warning=PHP version 8.0 is EOL and will no longer be supported in a future release. Please upgrade to a supported version of PHP. See https://www.php.net/supported-versions.php for information on version support timelines.");
242+
}
243+
238244
if (PHP_81_API_VER..PHP_82_API_VER).contains(&version) {
239245
println!("cargo:rustc-cfg=php81");
240246
}

guide/src/macros/function.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ pub fn greet(name: String, age: Option<i32>, description: Option<String>) -> Str
9999
## Variadic Functions
100100

101101
Variadic functions can be implemented by specifying the last argument in the Rust
102-
function to the type `&[&Zval]`. This is the equivelant of a PHP function using
102+
function to the type `&[&Zval]`. This is the equivalent of a PHP function using
103103
the `...$args` syntax.
104104

105105
```rust,no_run

src/args.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ impl<'a, 'b> ArgParser<'a, 'b> {
240240
let max_num_args = self.args.len();
241241
let min_num_args = self.min_num_args.unwrap_or(max_num_args);
242242
let num_args = self.arg_zvals.len();
243-
let has_variadic = self.args.last().map_or(false, |arg| arg.variadic);
243+
let has_variadic = self.args.last().is_some_and(|arg| arg.variadic);
244244

245245
if num_args < min_num_args || (!has_variadic && num_args > max_num_args) {
246246
// SAFETY: Exported C function is safe, return value is unused and parameters

src/builders/function.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ impl<'a> FunctionBuilder<'a> {
5757
}),
5858
arg_info: ptr::null(),
5959
num_args: 0,
60-
flags: 0,
60+
flags: 0, // TBD?
6161
#[cfg(php84)]
62-
frameless_function_infos: ptr::null(),
62+
doc_comment: ptr::null(),
6363
#[cfg(php84)]
64-
doc_comment: "".as_ptr() as *const c_char,
64+
frameless_function_infos: ptr::null(),
6565
},
6666
args: vec![],
6767
n_req: None,
@@ -87,9 +87,9 @@ impl<'a> FunctionBuilder<'a> {
8787
num_args: 0,
8888
flags: MethodFlags::Abstract.bits(),
8989
#[cfg(php84)]
90-
frameless_function_infos: ptr::null(),
90+
doc_comment: ptr::null(),
9191
#[cfg(php84)]
92-
doc_comment: "".as_ptr() as *const c_char,
92+
frameless_function_infos: ptr::null(),
9393
},
9494
args: vec![],
9595
n_req: None,

src/embed/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl Embed {
5454
/// # Returns
5555
///
5656
/// * `Ok(())` - The script was executed successfully
57-
/// * `Err(EmbedError)` - An error occured during the execution of the
57+
/// * `Err(EmbedError)` - An error occurred during the execution of the
5858
/// script
5959
///
6060
/// # Example
@@ -154,7 +154,7 @@ impl Embed {
154154
match unsafe { *Box::from_raw(panic as *mut std::thread::Result<R>) } {
155155
Ok(r) => r,
156156
Err(err) => {
157-
// we resume the panic here so it can be catched correctly by the test framework
157+
// we resume the panic here so it can be caught correctly by the test framework
158158
resume_unwind(err);
159159
}
160160
}
@@ -168,7 +168,7 @@ impl Embed {
168168
/// # Returns
169169
///
170170
/// * `Ok(Zval)` - The result of the evaluation
171-
/// * `Err(EmbedError)` - An error occured during the evaluation
171+
/// * `Err(EmbedError)` - An error occurred during the evaluation
172172
///
173173
/// # Example
174174
///

src/macros.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//! Macros for interacting with PHP, mainly when the function takes variadic
2-
//! arguments. Unforutunately, this is the best way to handle these.
2+
//! arguments. Unfortunately, this is the best way to handle these.
33
//! Note that most of these will introduce unsafe into your code base.
44
55
/// Starts the PHP extension information table displayed when running

src/types/array.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ impl ZendHashTable {
9191
/// Panics if memory for the hashtable could not be allocated.
9292
pub fn with_capacity(size: u32) -> ZBox<Self> {
9393
unsafe {
94-
// SAFETY: PHP allocater handles the creation of the array.
94+
// SAFETY: PHP allocator handles the creation of the array.
9595
let ptr = _zend_new_array(size);
9696

9797
// SAFETY: `as_mut()` checks if the pointer is null, and panics if it is not.
@@ -678,13 +678,13 @@ impl<'a> Iterator for Iter<'a> {
678678
}
679679
}
680680

681-
impl<'a> ExactSizeIterator for Iter<'a> {
681+
impl ExactSizeIterator for Iter<'_> {
682682
fn len(&self) -> usize {
683683
self.ht.len()
684684
}
685685
}
686686

687-
impl<'a> DoubleEndedIterator for Iter<'a> {
687+
impl DoubleEndedIterator for Iter<'_> {
688688
fn next_back(&mut self) -> Option<Self::Item> {
689689
let key_type = unsafe {
690690
zend_hash_get_current_key_type_ex(
@@ -730,8 +730,8 @@ impl<'a> DoubleEndedIterator for Iter<'a> {
730730
}
731731
}
732732

733-
impl<'a, 'b> Iter<'a> {
734-
pub fn next_zval(&'b mut self) -> Option<(Zval, &'a Zval)> {
733+
impl<'a> Iter<'a> {
734+
pub fn next_zval(&mut self) -> Option<(Zval, &'a Zval)> {
735735
let key_type = unsafe {
736736
zend_hash_get_current_key_type_ex(
737737
self.ht as *const ZendHashTable as *mut ZendHashTable,
@@ -805,13 +805,13 @@ impl<'a> Iterator for Values<'a> {
805805
}
806806
}
807807

808-
impl<'a> ExactSizeIterator for Values<'a> {
808+
impl ExactSizeIterator for Values<'_> {
809809
fn len(&self) -> usize {
810810
self.0.len()
811811
}
812812
}
813813

814-
impl<'a> DoubleEndedIterator for Values<'a> {
814+
impl DoubleEndedIterator for Values<'_> {
815815
fn next_back(&mut self) -> Option<Self::Item> {
816816
self.0.next_back().map(|(_, zval)| zval)
817817
}
@@ -847,7 +847,7 @@ impl<'a> FromZval<'a> for &'a ZendHashTable {
847847
}
848848

849849
///////////////////////////////////////////
850-
/// HashMap
850+
// HashMap
851851
///////////////////////////////////////////
852852

853853
impl<'a, V> TryFrom<&'a ZendHashTable> for HashMap<String, V>
@@ -916,7 +916,7 @@ where
916916
}
917917

918918
///////////////////////////////////////////
919-
/// Vec
919+
// Vec
920920
///////////////////////////////////////////
921921

922922
impl<'a, T> TryFrom<&'a ZendHashTable> for Vec<T>

0 commit comments

Comments
 (0)