Skip to content

Commit

Permalink
PHP 8.3 Support
Browse files Browse the repository at this point in the history
  • Loading branch information
joehoyle committed Nov 28, 2023
1 parent 1d16d32 commit 9fc5e52
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 40 deletions.
25 changes: 24 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,42 @@ jobs:
target: x86_64-unknown-linux-gnu
platform: linux/amd64
php-version: '8.0'
distro: bullseye
-
target: aarch64-unknown-linux-gnu
platform: linux/arm64
php-version: '8.0'
distro: bullseye
-
target: x86_64-unknown-linux-gnu
platform: linux/amd64
php-version: '8.1'
distro: bookworm
-
target: aarch64-unknown-linux-gnu
platform: linux/arm64
php-version: '8.1'
distro: bookworm
-
target: x86_64-unknown-linux-gnu
platform: linux/amd64
php-version: '8.2'
distro: bookworm
-
target: aarch64-unknown-linux-gnu
platform: linux/arm64
php-version: '8.2'
distro: bookworm
-
target: aarch64-unknown-linux-gnu
platform: linux/arm64
php-version: '8.3'
distro: bookworm
-
target: aarch64-unknown-linux-gnu
platform: linux/amd64
php-version: '8.3'
distro: bookworm
steps:
- name: Checkout
uses: actions/checkout@v1
Expand Down Expand Up @@ -67,6 +83,7 @@ jobs:
tags: localhost:5000/phpv8js-build:latest
build-args: |
FROM_PHP=${{ matrix.php-version }}
FROM_DISTRO=${{ matrix.distro }}
- run: mkdir ~/.cargo-registry

Expand Down Expand Up @@ -112,6 +129,12 @@ jobs:
-
target: x86_64-apple-darwin
php-version: '8.2'
-
target: aarch64-apple-darwin
php-version: '8.3'
-
target: x86_64-apple-darwin
php-version: '8.3'
steps:
- name: Checkout
uses: actions/checkout@v1
Expand All @@ -124,7 +147,7 @@ jobs:
default: true
override: true
- name: Setup PHP version
run: brew install php@${{ matrix.php-version }} && brew unlink php && brew link --force php@${{ matrix.php-version }}
run: brew tap shivammathur/php && brew install shivammathur/php/php@${{ matrix.php-version }} && brew unlink php && brew link --force shivammathur/php/php@${{ matrix.php-version }}

- name: Build
uses: actions-rs/cargo@v1
Expand Down
80 changes: 54 additions & 26 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[package]
name = "v8js"
version = "0.1.0"
version = "0.5.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
ext-php-rs = "0.10.0"
ext-php-rs = "0.11.1"
v8 = "0.38.1"

[lib]
Expand Down
14 changes: 3 additions & 11 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,20 +104,12 @@ pub fn js_value_from_zval<'a>(
let zend_array = zval.array().unwrap();
let mut values: Vec<v8::Local<'_, v8::Value>> = Vec::new();
let mut keys: Vec<v8::Local<'_, v8::Name>> = Vec::new();
let mut has_string_keys = false;
for (index, key, elem) in zend_array.iter() {
let key = match key {
Some(key) => {
has_string_keys = true;
key
}
None => index.to_string(),
};
keys.push(v8::String::new(scope, key.as_str()).unwrap().into());
for (key, elem) in zend_array.iter() {
keys.push(v8::String::new(scope, key.to_string().as_str()).unwrap().into());
values.push(js_value_from_zval(scope, elem));
}

if has_string_keys {
if ! zend_array.has_numerical_keys() {
let null: v8::Local<v8::Value> = v8::null(scope).into();
return v8::Object::with_prototype_and_properties(scope, null, &keys[..], &values[..])
.into();
Expand Down

0 comments on commit 9fc5e52

Please sign in to comment.