This is an automated email from the ASF dual-hosted git repository.

xuanwo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/opendal.git


The following commit(s) were added to refs/heads/main by this push:
     new 28c2eb83f fix: make php binding happy again (#5761)
28c2eb83f is described below

commit 28c2eb83fba38f20b4b93ddebbec063b94eaa560
Author: yihong <[email protected]>
AuthorDate: Fri Mar 14 22:25:26 2025 +0800

    fix: make php binding happy again (#5761)
    
    * fix: make php binding happy again
    
    Signed-off-by: yihong0618 <[email protected]>
    
    * fix: yml syntax error fix
    
    Signed-off-by: yihong0618 <[email protected]>
    
    * fix: clippy happy first
    
    Signed-off-by: yihong0618 <[email protected]>
    
    * fix: working dir
    
    Signed-off-by: yihong0618 <[email protected]>
    
    * fix: forget lint every time
    
    Signed-off-by: yihong0618 <[email protected]>
    
    ---------
    
    Signed-off-by: yihong0618 <[email protected]>
---
 .github/workflows/ci_bindings_php.yml | 32 ++++++++++++++++++--------------
 bindings/php/Cargo.toml               |  2 +-
 bindings/php/src/lib.rs               | 17 +++++++++++++----
 3 files changed, 32 insertions(+), 19 deletions(-)

diff --git a/.github/workflows/ci_bindings_php.yml 
b/.github/workflows/ci_bindings_php.yml
index 9534128d2..d3ac9b8ae 100644
--- a/.github/workflows/ci_bindings_php.yml
+++ b/.github/workflows/ci_bindings_php.yml
@@ -18,19 +18,17 @@
 name: Bindings PHP CI
 
 on:
-  # Disable PHP build until https://github.com/apache/opendal/issues/3055 
addressed
-  #
-  #  push:
-  #    branches:
-  #      - main
-  #    tags:
-  #      - '*'
-  #  pull_request:
-  #    branches:
-  #      - main
-  #    paths:
-  #      - "bindings/php/**"
-  #      - ".github/workflows/bindings_php.yml"
+  push:
+    branches:
+      - main
+    tags:
+      - '*'
+  pull_request:
+    branches:
+      - main
+    paths:
+      - "bindings/php/**"
+      - ".github/workflows/bindings_php.yml"
   workflow_dispatch:
 
 concurrency:
@@ -47,7 +45,7 @@ jobs:
     strategy:
       fail-fast: true
       matrix:
-        php: [8.1, 8.2]
+        php: [8.2, 8.4]
 
     steps:
       - name: Checkout code
@@ -64,11 +62,17 @@ jobs:
       - name: Setup Rust toolchain
         uses: ./.github/actions/setup
 
+      - name: Clippy Check
+        working-directory: "bindings/php"
+        run: |
+          cargo clippy -- -D warnings
+
       - name: Build opendal-php extension
         working-directory: "bindings/php"
         run: cargo build
 
       - name: Enable opendal-php extension in php.ini
+        working-directory: "bindings/php"
         run: |
           # 1. Find the extension_dir
           extension_dir=$(php -r "echo ini_get('extension_dir');")
diff --git a/bindings/php/Cargo.toml b/bindings/php/Cargo.toml
index ef085c62d..f5aaeb270 100644
--- a/bindings/php/Cargo.toml
+++ b/bindings/php/Cargo.toml
@@ -30,7 +30,7 @@ rust-version = "1.75"
 crate-type = ["cdylib"]
 
 [dependencies]
-ext-php-rs = "0.11.2"
+ext-php-rs = "0.13.1"
 # this crate won't be published, we always use the local version
 opendal = { version = ">=0", path = "../../core", features = [
   # These are default features before v0.46. TODO: change to optional features
diff --git a/bindings/php/src/lib.rs b/bindings/php/src/lib.rs
index eb91bd004..5999e0000 100644
--- a/bindings/php/src/lib.rs
+++ b/bindings/php/src/lib.rs
@@ -40,23 +40,32 @@ impl Operator {
 
     /// Write string into given path.
     pub fn write(&self, path: &str, content: String) -> PhpResult<()> {
-        self.0.write(path, content).map_err(format_php_err)
+        self.0
+            .write(path, content)
+            .map(|_| ())
+            .map_err(format_php_err)
     }
 
     /// Write bytes into given path, binary safe.
     pub fn write_binary(&self, path: &str, content: Vec<u8>) -> PhpResult<()> {
-        self.0.write(path, content).map_err(format_php_err)
+        self.0
+            .write(path, content)
+            .map(|_| ())
+            .map_err(format_php_err)
     }
 
     /// Read the whole path into bytes, binary safe.
     pub fn read(&self, path: &str) -> PhpResult<Binary<u8>> {
-        self.0.read(path).map_err(format_php_err).map(Binary::from)
+        self.0
+            .read(path)
+            .map_err(format_php_err)
+            .map(|buf| Binary::from(buf.to_vec()))
     }
 
     /// Check if this path exists or not, return 1 if exists, 0 otherwise.
     pub fn is_exist(&self, path: &str) -> PhpResult<u8> {
         self.0
-            .is_exist(path)
+            .exists(path)
             .map_err(format_php_err)
             .map(|b| if b { 1 } else { 0 })
     }

Reply via email to