Skip to content

Commit c4952e9

Browse files
committed
Downgrade to remove 7.0 support because of unresolved problem.
1 parent 8dc9881 commit c4952e9

File tree

9 files changed

+25
-30
lines changed

9 files changed

+25
-30
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
os:
2222
- ubuntu-latest
2323
php-version:
24-
- "7.0"
24+
# - "7.0"
2525
- "7.1"
2626
- "7.2"
2727
- "7.3"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ A library that allows us to write PHP extensions using pure Rust and using safe
2525

2626
*version*
2727

28-
- [x] 7.0
28+
- [ ] 7.0
2929
- [x] 7.1
3030
- [x] 7.2
3131
- [x] 7.3

phper-sys/php_wrapper.c

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -90,28 +90,6 @@ void *phper_zend_hash_str_find_ptr(const HashTable *ht, const char *str, size_t
9090
return zend_hash_str_find_ptr(ht, str, len);
9191
}
9292

93-
void phper_zend_hash_merge_with_key(HashTable *target, HashTable *source) {
94-
uint32_t idx;
95-
Bucket *p;
96-
zval *s;
97-
98-
for (idx = 0; idx < source->nNumUsed; idx++) {
99-
p = source->arData + idx;
100-
s = &p->val;
101-
if (UNEXPECTED(Z_TYPE_P(s) == IS_INDIRECT)) {
102-
s = Z_INDIRECT_P(s);
103-
}
104-
if (UNEXPECTED(Z_TYPE_P(s) == IS_UNDEF)) {
105-
continue;
106-
}
107-
if (p->key) {
108-
zend_hash_str_update(target, ZSTR_VAL(p->key), ZSTR_LEN(p->key), s);
109-
} else {
110-
zend_hash_index_update(target, p->h, s);
111-
}
112-
}
113-
}
114-
11593
void phper_zval_obj(zval *z, zend_object *o) {
11694
ZVAL_OBJ(z, o);
11795
}

phper-sys/php_wrapper.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ zval* phper_zend_hash_index_update(HashTable *ht, zend_ulong h, zval *pData);
3737

3838
void phper_array_init(zval *arg);
3939
void *phper_zend_hash_str_find_ptr(const HashTable *ht, const char *str, size_t len);
40-
void phper_zend_hash_merge_with_key(HashTable *target, HashTable *source);
4140

4241
void phper_zval_obj(zval *z, zend_object *o);
4342

phper/src/arrays.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl Array {
3636
pub fn new() -> Self {
3737
unsafe {
3838
let mut array = zeroed::<Array>();
39-
_zend_hash_init(array.as_mut_ptr(), 0, None, false.into());
39+
_zend_hash_init(array.as_mut_ptr(), 0, Some(_zval_ptr_dtor), false.into());
4040
array
4141
}
4242
}

phper/src/errors.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! The errors for crate and php.
22
3-
use crate::{classes::ClassEntry, Error::Other};
3+
use crate::{classes::ClassEntry, Error::Other, sys::*};
44
use anyhow::anyhow;
55
use std::{error, ffi::FromBytesWithNulError, io, str::Utf8Error};
66

@@ -132,6 +132,11 @@ impl ArgumentCountError {
132132

133133
impl Throwable for ArgumentCountError {
134134
fn class_entry(&self) -> &ClassEntry {
135-
ClassEntry::from_globals("ArgumentCountError").unwrap()
135+
let class_name = if PHP_VERSION_ID >= 70100 {
136+
"ArgumentCountError"
137+
} else {
138+
"TypeError"
139+
};
140+
ClassEntry::from_globals(class_name).unwrap()
136141
}
137142
}

tests/integration/src/arguments.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ fn integrate_arguments(module: &mut Module) {
4444
|arguments: &mut [Val]| -> phper::Result<EBox<Array>> {
4545
let a = arguments[0].as_array()?;
4646
let mut a = a.clone();
47+
a.insert("a", Val::new(1));
4748
a.insert("foo", Val::new("bar"));
4849
Ok(EBox::new(a))
4950
},

tests/integration/tests/php/_common.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
ini_set("display_startup_errors", "On");
55
error_reporting(E_ALL);
66

7+
if (!defined('PHP_VERSION_ID')) {
8+
$version = explode('.', PHP_VERSION);
9+
define('PHP_VERSION_ID', ($version[0] * 10000 + $version[1] * 100 + $version[2]));
10+
}
11+
712
function assert_eq($left, $right) {
813
if ($left !== $right) {
914
throw new AssertionError(sprintf("left != right,\n left: %s,\n right: %s", var_export($left, true), var_export($right, true)));

tests/integration/tests/php/arguments.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,15 @@
22

33
require_once __DIR__ . '/_common.php';
44

5+
if (PHP_VERSION_ID >= 70100) {
6+
$argumentCountErrorName = "ArgumentCountError";
7+
} else {
8+
$argumentCountErrorName = "TypeError";
9+
}
10+
511
assert_eq(integrate_arguments_null(null), null);
6-
assert_throw(function () { integrate_arguments_null(); }, "ArgumentCountError", 0, "integrate_arguments_null(): expects at least 1 parameter(s), 0 given");
12+
13+
assert_throw(function () { integrate_arguments_null(); }, $argumentCountErrorName, 0, "integrate_arguments_null(): expects at least 1 parameter(s), 0 given");
714
assert_throw(function () { integrate_arguments_null(1); }, "TypeError", 0, "type error: must be of type null, int given");
815

916
assert_eq(integrate_arguments_long(1, 2), 3);
@@ -25,7 +32,7 @@
2532
assert_object(integrate_arguments_object($obj), "stdClass", ["a" => 1, "foo" => "bar"]);
2633
assert_throw(function () { integrate_arguments_object(1); }, "TypeError", 0, "type error: must be of type object, int given");
2734

28-
assert_throw(function () { integrate_arguments_optional(); }, "ArgumentCountError", 0, "integrate_arguments_optional(): expects at least 1 parameter(s), 0 given");
35+
assert_throw(function () { integrate_arguments_optional(); }, $argumentCountErrorName, 0, "integrate_arguments_optional(): expects at least 1 parameter(s), 0 given");
2936
assert_eq(integrate_arguments_optional("foo"), "foo: false");
3037
assert_eq(integrate_arguments_optional("foo", true), "foo: true");
3138
assert_eq(integrate_arguments_optional("foo", true, "bar"), "foo: true");

0 commit comments

Comments
 (0)