diff --git a/Cargo.lock b/Cargo.lock index ae665eb7..01c39136 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "addr2line" @@ -26,17 +26,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "async-trait" -version = "0.1.85" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f934833b4b7233644e5848f235df3f57ed8c80f1528a26c3dfa13d2147fa056" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "atomic-waker" version = "1.1.2" @@ -51,13 +40,13 @@ checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "axum" -version = "0.7.9" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edca88bc138befd0323b20752846e6587272d3b03b0343c8ea28a6f819e6e71f" +checksum = "6d6fd624c75e18b3b4c6b9caf42b1afe24437daaee904069137d8bab077be8b8" dependencies = [ - "async-trait", "axum-core", "bytes", + "form_urlencoded", "futures-util", "http", "http-body", @@ -85,11 +74,10 @@ dependencies = [ [[package]] name = "axum-core" -version = "0.4.5" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09f2bd6146b97ae3359fa0cc6d6b376d9539582c7b4220f041a33ec24c226199" +checksum = "df1362f362fd16024ae199c1970ce98f9661bf5ef94b9808fee734bc3698b733" dependencies = [ - "async-trait", "bytes", "futures-util", "http", @@ -127,16 +115,14 @@ checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "bindgen" -version = "0.69.5" +version = "0.71.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "271383c67ccabffb7381723dea0672a673f292304fcb45c01cc648c7a8d58088" +checksum = "5f58bf3d7db68cfbac37cfc485a8d711e87e064c3d0fe0435b92f7a407f9d6b3" dependencies = [ "bitflags", "cexpr", "clang-sys", "itertools", - "lazy_static", - "lazycell", "log", "prettyplease", "proc-macro2", @@ -145,32 +131,31 @@ dependencies = [ "rustc-hash", "shlex", "syn", - "which", ] [[package]] name = "bitflags" -version = "2.6.0" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" +checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36" [[package]] name = "bumpalo" -version = "3.16.0" +version = "3.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" +checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf" [[package]] name = "bytes" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "325918d6fe32f23b19878fe4b34794ae41fc19ddbe53b10571a4874d44ffd39b" +checksum = "f61dac84819c6588b558454b194026eb1f09c293b9036ae9b159e74e73ab6cf9" [[package]] name = "cc" -version = "1.2.7" +version = "1.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a012a0df96dd6d06ba9a1b29d6402d1a5d77c6befd2566afdc26e10603dc93d7" +checksum = "0c3d1b2e905a3a7b00a6141adb0e4c0bb941d11caf55349d863942a1cc44e3c9" dependencies = [ "shlex", ] @@ -201,12 +186,6 @@ dependencies = [ "libloading", ] -[[package]] -name = "convert_case" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" - [[package]] name = "cookie" version = "0.18.1" @@ -263,14 +242,21 @@ dependencies = [ [[package]] name = "derive_more" -version = "0.99.18" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce" +checksum = "093242cf7570c207c83073cf82f79706fe7b8317e98620a47d5be7c3d8497678" +dependencies = [ + "derive_more-impl", +] + +[[package]] +name = "derive_more-impl" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bda628edc44c4bb645fbe0f758797143e4e07926f7ebf4e9bdfbd3d2ce621df3" dependencies = [ - "convert_case", "proc-macro2", "quote", - "rustc_version", "syn", ] @@ -287,9 +273,9 @@ dependencies = [ [[package]] name = "document-features" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb6969eaabd2421f8a2775cfd2471a2b634372b4a25d41e3bd647b79912850a0" +checksum = "95249b50c6c185bee49034bcb378a49dc2b5dff0be90ff6616d31d64febab05d" dependencies = [ "litrs", ] @@ -311,9 +297,9 @@ dependencies = [ [[package]] name = "equivalent" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" [[package]] name = "errno" @@ -331,7 +317,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "888aa43e6b500bb98788503b19ec2bafc9de5c4e1e513b84ecfc9d2d34ccd2e8" dependencies = [ - "thiserror", + "thiserror 1.0.69", "tokio", "tracing", ] @@ -430,7 +416,19 @@ checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "libc", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", +] + +[[package]] +name = "getrandom" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a49c392881ce6d5c3b8cb70f98717b7c07aabbdff06687b9030dbfbe2725f8" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.13.3+wasi-0.2.2", + "windows-targets", ] [[package]] @@ -447,9 +445,9 @@ checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2" [[package]] name = "h2" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccae279728d634d083c00f6099cb58f01cc99c145b84b8be2f6c74618d79922e" +checksum = "5017294ff4bb30944501348f6f8e42e6ad28f42c8bbef7a74029aff064a4e3c2" dependencies = [ "atomic-waker", "bytes", @@ -470,15 +468,6 @@ version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" -[[package]] -name = "home" -version = "0.5.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" -dependencies = [ - "windows-sys 0.52.0", -] - [[package]] name = "http" version = "1.2.0" @@ -515,9 +504,9 @@ dependencies = [ [[package]] name = "httparse" -version = "1.9.5" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d71d3574edd2771538b901e6549113b4006ece66150fb69c0fb6d9a2adae946" +checksum = "f2d708df4e7140240a16cd6ab0ab65c972d7433ab77819ea693fde9c43811e2a" [[package]] name = "httpdate" @@ -527,9 +516,9 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "hyper" -version = "1.5.2" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "256fb8d4bd6413123cc9d91832d78325c48ff41677595be797d90f42969beae0" +checksum = "cc2b571658e38e0c01b1fdca3bbbe93c00d3d71693ff2770043f8c29bc7d6f80" dependencies = [ "bytes", "futures-channel", @@ -739,9 +728,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.7.0" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62f822373a4fe84d4bb149bf54e584a7f4abec90e072ed49cda0edea5b95471f" +checksum = "8c9c992b02b5b4c94ea26e32fe5bccb7aa7d9f390ab5c1221ff895bc7ea8b652" dependencies = [ "equivalent", "hashbrown", @@ -759,15 +748,15 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.10.1" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddc24109865250148c2e0f3d25d4f0f479571723792d3802153c60922a4fb708" +checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130" [[package]] name = "itertools" -version = "0.12.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" dependencies = [ "either", ] @@ -780,26 +769,14 @@ checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" [[package]] name = "js-sys" -version = "0.3.76" +version = "0.3.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6717b6b5b077764fb5966237269cb3c64edddde4b14ce42647430a78ced9e7b7" +checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" dependencies = [ "once_cell", "wasm-bindgen", ] -[[package]] -name = "lazy_static" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" - -[[package]] -name = "lazycell" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" - [[package]] name = "libc" version = "0.2.169" @@ -818,9 +795,9 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.4.14" +version = "0.4.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" +checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" [[package]] name = "litemap" @@ -846,15 +823,15 @@ dependencies = [ [[package]] name = "log" -version = "0.4.22" +version = "0.4.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" +checksum = "04cbf5b083de1c7e0222a7a51dbfdba1cbe1c6ab0b15e29fff3f6c077fd9cd9f" [[package]] name = "matchit" -version = "0.7.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" +checksum = "47e1ffaa40ddd1f3ed91f717a33c8c0ee23fff369e3aa8772b9605cc1d22f4c3" [[package]] name = "memchr" @@ -876,9 +853,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.8.2" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ffbe83022cedc1d264172192511ae958937694cd57ce297164951b8b3568394" +checksum = "b3b1c9bd4fe1f0f8b387f6eb9eb3b4a1aa26185e5750efb9140301703f62cd1b" dependencies = [ "adler2", ] @@ -890,15 +867,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" dependencies = [ "libc", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", "windows-sys 0.52.0", ] [[package]] name = "native-tls" -version = "0.2.12" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8614eb2c83d59d1c8cc974dd3f920198647674a0a035e1af1fa58707e317466" +checksum = "87de3442987e9dbec73158d5c715e7ad9072fda936bb03d19d7fa10e00520f0e" dependencies = [ "libc", "log", @@ -938,15 +915,15 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.20.2" +version = "1.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" +checksum = "945462a4b81e43c4e3ba96bd7b49d834c6f61198356aa858733bc4acf3cbe62e" [[package]] name = "openssl" -version = "0.10.68" +version = "0.10.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6174bc48f102d208783c2c84bf931bb75927a617866870de8a4ea85597f871f5" +checksum = "5e14130c6a98cd258fdcb0fb6d744152343ff729cbfcb28c656a9d12b999fbcd" dependencies = [ "bitflags", "cfg-if", @@ -970,15 +947,15 @@ dependencies = [ [[package]] name = "openssl-probe" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" +checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" [[package]] name = "openssl-sys" -version = "0.9.104" +version = "0.9.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45abf306cbf99debc8195b66b7346498d7b10c210de50418b5ccd7ceba08c741" +checksum = "8bb61ea9811cc39e3c2069f40b8b8e2e70d8569b361f879786cc7ed48b777cdd" dependencies = [ "cc", "libc", @@ -1027,7 +1004,7 @@ dependencies = [ "phper-build", "phper-macros", "phper-sys", - "thiserror", + "thiserror 2.0.11", ] [[package]] @@ -1051,7 +1028,7 @@ version = "0.14.1" dependencies = [ "phper", "reqwest", - "thiserror", + "thiserror 2.0.11", ] [[package]] @@ -1077,7 +1054,7 @@ dependencies = [ "phper", "phper-test", "reqwest", - "thiserror", + "thiserror 2.0.11", ] [[package]] @@ -1089,7 +1066,7 @@ dependencies = [ "phper", "phper-test", "reqwest", - "thiserror", + "thiserror 2.0.11", "tokio", ] @@ -1117,7 +1094,6 @@ version = "0.14.1" dependencies = [ "bindgen", "cc", - "home", "regex", ] @@ -1159,9 +1135,9 @@ checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "prettyplease" -version = "0.2.27" +version = "0.2.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "483f8c21f64f3ea09fe0f30f5d48c3e8eefe5dac9129f0075f76593b4c1da705" +checksum = "6924ced06e1f7dfe3fa48d57b9f74f55d8915f5036121bef647ef4b204895fac" dependencies = [ "proc-macro2", "syn", @@ -1169,9 +1145,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.92" +version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" +checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" dependencies = [ "unicode-ident", ] @@ -1288,15 +1264,14 @@ dependencies = [ [[package]] name = "ring" -version = "0.17.8" +version = "0.17.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" +checksum = "e75ec5e92c4d8aede845126adc388046234541629e76029599ed35a003c7ed24" dependencies = [ "cc", "cfg-if", - "getrandom", + "getrandom 0.2.15", "libc", - "spin", "untrusted", "windows-sys 0.52.0", ] @@ -1309,24 +1284,15 @@ checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "rustc-hash" -version = "1.1.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" - -[[package]] -name = "rustc_version" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" -dependencies = [ - "semver", -] +checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d" [[package]] name = "rustix" -version = "0.38.42" +version = "0.38.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93dc38ecbab2eb790ff964bb77fa94faf256fd3e73285fd7ba0903b76bedb85" +checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" dependencies = [ "bitflags", "errno", @@ -1337,9 +1303,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.20" +version = "0.23.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5065c3f250cbd332cd894be57c40fa52387247659b14a2d6041d121547903b1b" +checksum = "47796c98c480fce5406ef69d1c76378375492c3b0a0de587be0c1d9feb12f395" dependencies = [ "once_cell", "rustls-pki-types", @@ -1359,9 +1325,9 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.10.1" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2bf47e6ff922db3825eb750c4e2ff784c6ff8fb9e13046ef6a1d1c5401b0b37" +checksum = "917ce264624a4b4db1c364dcc35bfca9ded014d0a958cd47ad3e960e988ea51c" [[package]] name = "rustls-webpki" @@ -1382,9 +1348,9 @@ checksum = "f7c45b9784283f1b2e7fb61b42047c2fd678ef0960d4f6f1eba131594cc369d4" [[package]] name = "ryu" -version = "1.0.18" +version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" +checksum = "6ea1a2d0a644769cc99faa24c3ad26b379b786fe7c36fd3c546254801650e6dd" [[package]] name = "schannel" @@ -1416,34 +1382,28 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.13.0" +version = "2.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1863fd3768cd83c56a7f60faa4dc0d403f1b6df0a38c3c25f44b7894e45370d5" +checksum = "49db231d56a190491cb4aeda9527f1ad45345af50b0851622a7adb8c03b01c32" dependencies = [ "core-foundation-sys", "libc", ] -[[package]] -name = "semver" -version = "1.0.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cb6eb87a131f756572d7fb904f6e7b68633f09cca868c5df1c4b8d1a694bbba" - [[package]] name = "serde" -version = "1.0.217" +version = "1.0.218" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70" +checksum = "e8dfc9d19bdbf6d17e22319da49161d5d0108e4188e8b680aef6299eed22df60" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.217" +version = "1.0.218" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" +checksum = "f09503e191f4e797cb8aac08e9a4a4695c5edf6a2e70e376d961ddd5c969f82b" dependencies = [ "proc-macro2", "quote", @@ -1452,9 +1412,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.135" +version = "1.0.139" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b0d7ba2887406110130a978386c4e1befb98c674b4fba677954e4db976630d9" +checksum = "44f86c3acccc9c65b153fe1b85a3be07fe5515274ec9f0653b4a0875731c72a6" dependencies = [ "itoa", "memchr", @@ -1510,9 +1470,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.13.2" +version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" +checksum = "7fcf8323ef1faaee30a44a340193b1ac6814fd9b7b4e88e9d4519a3e4abe1cfd" [[package]] name = "socket2" @@ -1524,12 +1484,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "spin" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" - [[package]] name = "stable_deref_trait" version = "1.2.0" @@ -1544,9 +1498,9 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "syn" -version = "2.0.95" +version = "2.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46f71c0377baf4ef1cc3e3402ded576dccc315800fbc62dfc7fe04b009773b4a" +checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1" dependencies = [ "proc-macro2", "quote", @@ -1596,13 +1550,13 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.15.0" +version = "3.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a8a559c81686f576e8cd0290cd2a24a2a9ad80c98b3478856500fcbd7acd704" +checksum = "22e5a0acb1f3f55f65cc4a866c361b2fb2a0ff6366785ae6fbb5f85df07ba230" dependencies = [ "cfg-if", "fastrand", - "getrandom", + "getrandom 0.3.1", "once_cell", "rustix", "windows-sys 0.59.0", @@ -1614,7 +1568,16 @@ version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" dependencies = [ - "thiserror-impl", + "thiserror-impl 1.0.69", +] + +[[package]] +name = "thiserror" +version = "2.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d452f284b73e6d76dd36758a0c8684b1d5be31f92b89d07fd5822175732206fc" +dependencies = [ + "thiserror-impl 2.0.11", ] [[package]] @@ -1628,6 +1591,17 @@ dependencies = [ "syn", ] +[[package]] +name = "thiserror-impl" +version = "2.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26afc1baea8a989337eeb52b6e72a039780ce45c3edfcc9c5b9d112feeb173c2" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "time" version = "0.3.37" @@ -1671,9 +1645,9 @@ dependencies = [ [[package]] name = "tokio" -version = "1.42.0" +version = "1.43.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cec9b21b0450273377fc97bd4c33a8acffc8c996c987a7c5b319a0083707551" +checksum = "3d61fa4ffa3de412bfea335c6ecff681de2b609ba3c77ef3e00e521813a9ed9e" dependencies = [ "backtrace", "bytes", @@ -1689,9 +1663,9 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" +checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" dependencies = [ "proc-macro2", "quote", @@ -1799,9 +1773,9 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "unicode-ident" -version = "1.0.14" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" +checksum = "00e2473a93778eb0bad35909dff6a10d28e63f792f16ed15e404fca9d5eeedbe" [[package]] name = "untrusted" @@ -1859,22 +1833,32 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "wasi" +version = "0.13.3+wasi-0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26816d2e1a4a36a2940b96c5296ce403917633dff8f3440e9b236ed6f6bacad2" +dependencies = [ + "wit-bindgen-rt", +] + [[package]] name = "wasm-bindgen" -version = "0.2.99" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a474f6281d1d70c17ae7aa6a613c87fce69a127e2624002df63dcb39d6cf6396" +checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" dependencies = [ "cfg-if", "once_cell", + "rustversion", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.99" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f89bb38646b4f81674e8f5c3fb81b562be1fd936d84320f3264486418519c79" +checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" dependencies = [ "bumpalo", "log", @@ -1886,9 +1870,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.49" +version = "0.4.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38176d9b44ea84e9184eff0bc34cc167ed044f816accfe5922e54d84cf48eca2" +checksum = "555d470ec0bc3bb57890405e5d4322cc9ea83cebb085523ced7be4144dac1e61" dependencies = [ "cfg-if", "js-sys", @@ -1899,9 +1883,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.99" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cc6181fd9a7492eef6fef1f33961e3695e4579b9872a6f7c83aee556666d4fe" +checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1909,9 +1893,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.99" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30d7a95b763d3c45903ed6c81f156801839e5ee968bb07e534c44df0fcd330c2" +checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" dependencies = [ "proc-macro2", "quote", @@ -1922,32 +1906,23 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.99" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "943aab3fdaaa029a6e0271b35ea10b72b943135afe9bffca82384098ad0e06a6" +checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" +dependencies = [ + "unicode-ident", +] [[package]] name = "web-sys" -version = "0.3.76" +version = "0.3.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04dd7223427d52553d3702c004d3b2fe07c148165faa56313cb00211e31c12bc" +checksum = "33b6dd2ef9186f1f2072e409e99cd22a975331a6b3591b12c764e0e55c60d5d2" dependencies = [ "js-sys", "wasm-bindgen", ] -[[package]] -name = "which" -version = "4.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" -dependencies = [ - "either", - "home", - "once_cell", - "rustix", -] - [[package]] name = "windows-registry" version = "0.2.0" @@ -2060,6 +2035,15 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" +[[package]] +name = "wit-bindgen-rt" +version = "0.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3268f3d866458b787f390cf61f4bbb563b922d091359f9608842999eaee3943c" +dependencies = [ + "bitflags", +] + [[package]] name = "write16" version = "1.0.0" diff --git a/Cargo.toml b/Cargo.toml index 72702237..fc86e2f4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,10 +27,10 @@ members = [ [workspace.package] version = "0.14.1" authors = ["PHPER Framework Team", "jmjoy "] -edition = "2021" +edition = "2024" license = "MulanPSL-2.0" repository = "https://github.com/phper-framework/phper" -rust-version = "1.79" +rust-version = "1.85" [workspace.dependencies] phper = { version = "0.14.1", path = "./phper" } diff --git a/README.md b/README.md index 6469444e..fafb8611 100644 --- a/README.md +++ b/README.md @@ -18,36 +18,33 @@ The framework that allows us to write PHP extensions using pure and safe Rust wh ### Necessary -- **rust** 1.79 or later +- **rust** 1.85 or later - **libclang** 9.0 or later - **php** 7.0 or later ### Tested Support -- **OS** - - [x] linux - - [x] macos - - [ ] ~~windows~~ -- **PHP** - - **version** - - [x] 7.0 - - [x] 7.1 - - [x] 7.2 - - [x] 7.3 - - [x] 7.4 - - [x] 8.0 - - [x] 8.1 - - [x] 8.2 - - [x] 8.3 - - **mode** - - [x] nts - - [ ] ~~zts~~ - - **sapi** - - [x] cli - - [x] fpm - - **debug** - - [x] disable - - [ ] ~~enable~~ +| **Category** | **Item** | **Status** | +| --------------- | -------- | ---------- | +| **OS** | Linux | ✅ | +| | macOS | ✅ | +| | Windows | ❌ | +| **PHP Version** | 7.0 | ✅ | +| | 7.1 | ✅ | +| | 7.2 | ✅ | +| | 7.3 | ✅ | +| | 7.4 | ✅ | +| | 8.0 | ✅ | +| | 8.1 | ✅ | +| | 8.2 | ✅ | +| | 8.3 | ✅ | +| | 8.4 | ✅ | +| **PHP Mode** | NTS | ✅ | +| | ZTS | ❌ | +| **SAPI** | CLI | ✅ | +| | FPM | ✅ | +| **Debug** | Disable | ✅ | +| | Enable | ❌ | ## Examples diff --git a/examples/complex/src/lib.rs b/examples/complex/src/lib.rs index 2c8eb4a8..9566040f 100644 --- a/examples/complex/src/lib.rs +++ b/examples/complex/src/lib.rs @@ -12,7 +12,7 @@ use phper::{ arrays::ZArray, classes::{ClassEntity, Visibility}, functions::Argument, - ini::{ini_get, Policy}, + ini::{Policy, ini_get}, modules::Module, objects::StateObj, php_get_module, diff --git a/examples/http-client/Cargo.toml b/examples/http-client/Cargo.toml index cf08da3d..648f26cf 100644 --- a/examples/http-client/Cargo.toml +++ b/examples/http-client/Cargo.toml @@ -23,8 +23,8 @@ crate-type = ["lib", "cdylib"] [dependencies] phper = { workspace = true } -reqwest = { version = "0.12.5", features = ["blocking", "cookies"] } -thiserror = "1.0.63" +reqwest = { version = "0.12.12", features = ["blocking", "cookies"] } +thiserror = "2.0.11" [dev-dependencies] phper-test = { workspace = true } diff --git a/examples/http-client/src/errors.rs b/examples/http-client/src/errors.rs index 4e085aa2..69859abb 100644 --- a/examples/http-client/src/errors.rs +++ b/examples/http-client/src/errors.rs @@ -10,7 +10,7 @@ use phper::{ classes::{ClassEntity, ClassEntry}, - errors::{exception_class, Throwable}, + errors::{Throwable, exception_class}, }; /// The exception class name of extension. diff --git a/examples/http-server/Cargo.toml b/examples/http-server/Cargo.toml index 2e733082..a2d81c03 100644 --- a/examples/http-server/Cargo.toml +++ b/examples/http-server/Cargo.toml @@ -22,13 +22,13 @@ name = "http_server" crate-type = ["lib", "cdylib"] [dependencies] -hyper = { version = "1.4.1", features = ["http1", "server"] } -axum = "0.7.5" +hyper = { version = "1.6.0", features = ["http1", "server"] } +axum = "0.8.1" phper = { workspace = true } -thiserror = "1.0.63" -tokio = { version = "1.39.2", features = ["full"] } -reqwest = { version = "0.12.5", features = ["blocking"] } +thiserror = "2.0.11" +tokio = { version = "1.43.0", features = ["full"] } +reqwest = { version = "0.12.12", features = ["blocking"] } [dev-dependencies] phper-test = { workspace = true } -reqwest = "0.12.5" +reqwest = "0.12.12" diff --git a/examples/http-server/src/errors.rs b/examples/http-server/src/errors.rs index ce7c4c9d..eeb217f0 100644 --- a/examples/http-server/src/errors.rs +++ b/examples/http-server/src/errors.rs @@ -10,7 +10,7 @@ use phper::{ classes::{ClassEntity, ClassEntry}, - errors::{exception_class, Throwable}, + errors::{Throwable, exception_class}, }; use std::error::Error; diff --git a/examples/http-server/src/server.rs b/examples/http-server/src/server.rs index d79038f7..961066d7 100644 --- a/examples/http-server/src/server.rs +++ b/examples/http-server/src/server.rs @@ -10,10 +10,10 @@ use crate::{errors::HttpServerError, request::RequestClass, response::ResponseClass}; use axum::{ + Router, body::{self, Body}, http::{Request, Response, StatusCode}, routing::any, - Router, }; use phper::{ alloc::ToRefOwned, diff --git a/phper-alloc/src/lib.rs b/phper-alloc/src/lib.rs index 55b26a62..32b569fd 100644 --- a/phper-alloc/src/lib.rs +++ b/phper-alloc/src/lib.rs @@ -18,7 +18,7 @@ mod macros; use phper_sys::*; use std::{ borrow::Borrow, - mem::{size_of, ManuallyDrop}, + mem::{ManuallyDrop, size_of}, ops::{Deref, DerefMut}, }; diff --git a/phper-alloc/src/macros.rs b/phper-alloc/src/macros.rs index d603ee14..399bfa77 100644 --- a/phper-alloc/src/macros.rs +++ b/phper-alloc/src/macros.rs @@ -17,7 +17,5 @@ /// ``` #[macro_export] macro_rules! ebox { - ($arg:tt) => {{ - $crate::EBox::new($arg) - }}; + ($arg:tt) => {{ $crate::EBox::new($arg) }}; } diff --git a/phper-doc/Cargo.toml b/phper-doc/Cargo.toml index 0109c0c6..64f91503 100644 --- a/phper-doc/Cargo.toml +++ b/phper-doc/Cargo.toml @@ -23,5 +23,5 @@ license = { workspace = true } phper = { workspace = true } [dev-dependencies] -thiserror = "1.0.63" -reqwest = { version = "0.12.5", features = ["blocking", "cookies"] } +thiserror = "2.0.11" +reqwest = { version = "0.12.12", features = ["blocking", "cookies"] } diff --git a/phper-doc/doc/_03_integrate_with_pecl/index.md b/phper-doc/doc/_03_integrate_with_pecl/index.md index f4053956..3a2e7e00 100644 --- a/phper-doc/doc/_03_integrate_with_pecl/index.md +++ b/phper-doc/doc/_03_integrate_with_pecl/index.md @@ -10,8 +10,7 @@ This chapter will guide you on how to integrate the phper project with `pecl` an ### Adapt to `phpize` -1. At first, imagine you have finished the hello project follow [write your first extension](_02_quick_start::_01_write_your_first_extension), can build the -php extension `.so` file successfully. +1. At first, imagine you have finished the hello project follow [write your first extension](_02_quick_start::_01_write_your_first_extension), can build the php extension `.so` file successfully. 1. And then, create the `config.m4` file using by `phpize` (In theory, `config.w32` is also required for compatibility with Windows, but now phper diff --git a/phper-doc/doc/_05_internal_types/_01_z_str/index.md b/phper-doc/doc/_05_internal_types/_01_z_str/index.md index ca8a346a..501a9d4e 100644 --- a/phper-doc/doc/_05_internal_types/_01_z_str/index.md +++ b/phper-doc/doc/_05_internal_types/_01_z_str/index.md @@ -50,7 +50,7 @@ use phper::sys; use phper::strings::ZStr; use phper::alloc::ToRefOwned; -extern "C" { +unsafe extern "C" { fn something() -> *mut sys::zend_string; } diff --git a/phper-doc/doc/_05_internal_types/_02_z_arr/index.md b/phper-doc/doc/_05_internal_types/_02_z_arr/index.md index 0569f68e..248c8676 100644 --- a/phper-doc/doc/_05_internal_types/_02_z_arr/index.md +++ b/phper-doc/doc/_05_internal_types/_02_z_arr/index.md @@ -66,7 +66,7 @@ use phper::sys; use phper::arrays::ZArr; use phper::alloc::ToRefOwned; -extern "C" { +unsafe extern "C" { fn something() -> *mut sys::zend_array; } diff --git a/phper-doc/doc/_05_internal_types/_03_z_obj/index.md b/phper-doc/doc/_05_internal_types/_03_z_obj/index.md index be7bdfe9..d913a463 100644 --- a/phper-doc/doc/_05_internal_types/_03_z_obj/index.md +++ b/phper-doc/doc/_05_internal_types/_03_z_obj/index.md @@ -26,7 +26,7 @@ use phper::sys; use phper::objects::ZObj; use phper::alloc::ToRefOwned; -extern "C" { +unsafe extern "C" { fn something() -> *mut sys::zend_object; } diff --git a/phper-macros/Cargo.toml b/phper-macros/Cargo.toml index 62ab3a75..ec7d76c3 100644 --- a/phper-macros/Cargo.toml +++ b/phper-macros/Cargo.toml @@ -23,9 +23,9 @@ license = { workspace = true } proc-macro = true [dependencies] -quote = "1.0.36" -syn = { version = "2.0.72", features = ["full"] } -proc-macro2 = "1.0.86" +quote = "1.0.38" +syn = { version = "2.0.98", features = ["full"] } +proc-macro2 = "1.0.93" [dev-dependencies] -syn = { version = "2.0.72", features = ["full", "extra-traits"] } +syn = { version = "2.0.98", features = ["full", "extra-traits"] } diff --git a/phper-macros/src/inner.rs b/phper-macros/src/inner.rs index 29ecca7e..9840fdbc 100644 --- a/phper-macros/src/inner.rs +++ b/phper-macros/src/inner.rs @@ -10,7 +10,7 @@ use proc_macro::TokenStream; use quote::quote; -use syn::{parse_macro_input, ItemFn, Visibility}; +use syn::{ItemFn, Visibility, parse_macro_input}; pub(crate) fn php_get_module(_attr: TokenStream, input: TokenStream) -> TokenStream { let input = parse_macro_input!(input as ItemFn); @@ -31,7 +31,7 @@ pub(crate) fn php_get_module(_attr: TokenStream, input: TokenStream) -> TokenStr } let result = quote! { - #[no_mangle] + #[unsafe(no_mangle)] #[doc(hidden)] #(#attrs)* #vis extern "C" fn #name() -> *const ::phper::sys::zend_module_entry { diff --git a/phper-sys/Cargo.toml b/phper-sys/Cargo.toml index 1dc69779..14d049c1 100644 --- a/phper-sys/Cargo.toml +++ b/phper-sys/Cargo.toml @@ -20,7 +20,6 @@ repository = { workspace = true } license = { workspace = true } [build-dependencies] -bindgen = "0.69.4" -cc = "1.1.7" -home = "=0.5.9" -regex = "1.10.6" +bindgen = "0.71.1" +cc = "1.2.14" +regex = "1.11.1" diff --git a/phper-sys/src/lib.rs b/phper-sys/src/lib.rs index 1912e0e9..e8d618c4 100644 --- a/phper-sys/src/lib.rs +++ b/phper-sys/src/lib.rs @@ -16,6 +16,8 @@ // TODO Because `bindgen` generates codes contains deref nullptr, temporary suppression. #![allow(deref_nullptr)] #![allow(clippy::all)] +// TODO unsafe_op_in_unsafe_fn warning in edition 2024, temporary suppression. +#![allow(unsafe_op_in_unsafe_fn)] #![doc = include_str!("../README.md")] include!(concat!(env!("OUT_DIR"), "/php_bindings.rs")); diff --git a/phper-test/Cargo.toml b/phper-test/Cargo.toml index 97706815..26972980 100644 --- a/phper-test/Cargo.toml +++ b/phper-test/Cargo.toml @@ -21,11 +21,11 @@ license = { workspace = true } [dependencies] fastcgi-client = "0.9.0" -libc = "0.2.155" -once_cell = "1.19.0" +libc = "0.2.169" +once_cell = "1.20.3" phper-macros = { workspace = true } -tempfile = "3.11.0" -tokio = { version = "1.39.2", features = ["full"] } +tempfile = "3.17.1" +tokio = { version = "1.43.0", features = ["full"] } [package.metadata.docs.rs] rustdoc-args = ["--cfg", "docsrs"] diff --git a/phper-test/src/cli.rs b/phper-test/src/cli.rs index d1e40c77..e3207b55 100644 --- a/phper-test/src/cli.rs +++ b/phper-test/src/cli.rs @@ -12,7 +12,7 @@ use crate::context::Context; use std::{ - panic::{catch_unwind, resume_unwind, UnwindSafe}, + panic::{UnwindSafe, catch_unwind, resume_unwind}, path::Path, process::{Child, Output}, }; @@ -41,8 +41,7 @@ pub type ScriptCondition<'a> = (&'a dyn AsRef, &'a dyn Fn(Output) -> bool) /// checkers are pass, than the test is pass. /// /// - `exec_path` is the path of the make executable, which will be used to -/// detect the path of -/// extension lib. +/// detect the path of extension lib. /// /// - `scripts` is the slice of the tuple, format is `(path of your php test /// script, checker function or closure)`. @@ -93,6 +92,7 @@ pub fn test_php_scripts_with_condition( /// Check your extension by executing the long term php script such as http /// server, if the all your specified checkers are pass, than the test is pass. +#[allow(clippy::zombie_processes)] pub fn test_long_term_php_script_with_condition( lib_path: impl AsRef, script: impl AsRef, condition: impl FnOnce(&Child) + UnwindSafe, diff --git a/phper-test/src/context.rs b/phper-test/src/context.rs index 8843e155..b3d5104e 100644 --- a/phper-test/src/context.rs +++ b/phper-test/src/context.rs @@ -98,7 +98,7 @@ impl Context { .and_then(|name| { let mut p = p.to_path_buf(); p.push("sbin"); - p.push(&format!( + p.push(format!( "php-fpm{}", if name.starts_with("php") { name.chars().skip(3).collect::() diff --git a/phper-test/src/fpm.rs b/phper-test/src/fpm.rs index 6709d97f..94ad0257 100644 --- a/phper-test/src/fpm.rs +++ b/phper-test/src/fpm.rs @@ -11,11 +11,11 @@ //! Test tools for php fpm program. use crate::{context::Context, utils::spawn_command}; use fastcgi_client::{Client, Params, Request}; -use libc::{atexit, kill, pid_t, SIGTERM}; +use libc::{SIGTERM, atexit, kill, pid_t}; use once_cell::sync::OnceCell; use std::{ fs, - mem::{forget, ManuallyDrop}, + mem::{ManuallyDrop, forget}, path::{Path, PathBuf}, process::Child, sync::Mutex, diff --git a/phper/Cargo.toml b/phper/Cargo.toml index 241bded4..5f644efe 100644 --- a/phper/Cargo.toml +++ b/phper/Cargo.toml @@ -23,13 +23,13 @@ license = { workspace = true } [dependencies] cfg-if = "1.0.0" -derive_more = "0.99.18" -indexmap = "2.3.0" -once_cell = "1.19.0" +derive_more = { version = "2.0.1", features = ["from", "constructor"] } +indexmap = "2.7.1" +once_cell = "1.20.3" phper-alloc = { workspace = true } phper-macros = { workspace = true } phper-sys = { workspace = true } -thiserror = "1.0.63" +thiserror = "2.0.11" [build-dependencies] phper-build = { workspace = true } diff --git a/phper/src/arrays.rs b/phper/src/arrays.rs index adc609e7..0b855549 100644 --- a/phper/src/arrays.rs +++ b/phper/src/arrays.rs @@ -49,6 +49,12 @@ pub enum InsertKey<'a> { ZStr(&'a ZStr), } +impl From<()> for InsertKey<'_> { + fn from(_: ()) -> Self { + Self::NextIndex + } +} + impl<'a> From> for InsertKey<'a> { fn from(k: Key<'a>) -> Self { match k { @@ -79,7 +85,7 @@ impl ZArr { /// Panics if pointer is null. #[inline] pub unsafe fn from_ptr<'a>(ptr: *const zend_array) -> &'a Self { - (ptr as *const Self).as_ref().expect("ptr should't be null") + unsafe { (ptr as *const Self).as_ref().expect("ptr should't be null") } } /// Wraps a raw pointer, return None if pointer is null. @@ -89,7 +95,7 @@ impl ZArr { /// Create from raw pointer. #[inline] pub unsafe fn try_from_ptr<'a>(ptr: *const zend_array) -> Option<&'a Self> { - (ptr as *const Self).as_ref() + unsafe { (ptr as *const Self).as_ref() } } /// Wraps a raw pointer. @@ -103,7 +109,7 @@ impl ZArr { /// Panics if pointer is null. #[inline] pub unsafe fn from_mut_ptr<'a>(ptr: *mut zend_array) -> &'a mut Self { - (ptr as *mut Self).as_mut().expect("ptr should't be null") + unsafe { (ptr as *mut Self).as_mut().expect("ptr should't be null") } } /// Wraps a raw pointer, return None if pointer is null. @@ -113,7 +119,7 @@ impl ZArr { /// Create from raw pointer. #[inline] pub unsafe fn try_from_mut_ptr<'a>(ptr: *mut zend_array) -> Option<&'a mut Self> { - (ptr as *mut Self).as_mut() + unsafe { (ptr as *mut Self).as_mut() } } /// Returns a raw pointer wrapped. @@ -392,8 +398,10 @@ impl ZArray { /// twice on the same raw pointer. #[inline] pub unsafe fn from_raw(ptr: *mut zend_array) -> Self { - Self { - inner: ZArr::from_mut_ptr(ptr), + unsafe { + Self { + inner: ZArr::from_mut_ptr(ptr), + } } } @@ -468,7 +476,7 @@ struct RawIter<'a> { _p: PhantomData<&'a ()>, } -impl<'a> RawIter<'a> { +impl RawIter<'_> { fn new(arr: *mut zend_array) -> Self { let mut pos: HashPosition = 0; unsafe { diff --git a/phper/src/classes.rs b/phper/src/classes.rs index 5e980f58..2f1c3cd9 100644 --- a/phper/src/classes.rs +++ b/phper/src/classes.rs @@ -25,10 +25,10 @@ use crate::{ use std::{ any::Any, cell::RefCell, - ffi::{c_char, c_void, CString}, + ffi::{CString, c_char, c_void}, fmt::Debug, marker::PhantomData, - mem::{replace, size_of, zeroed, ManuallyDrop}, + mem::{ManuallyDrop, replace, size_of, zeroed}, os::raw::c_int, ptr::null_mut, rc::Rc, @@ -66,7 +66,7 @@ impl ClassEntry { /// Panics if pointer is null. #[inline] pub unsafe fn from_ptr<'a>(ptr: *const zend_class_entry) -> &'a Self { - (ptr as *const Self).as_ref().expect("ptr should't be null") + unsafe { (ptr as *const Self).as_ref().expect("ptr should't be null") } } /// Wraps a raw pointer, return None if pointer is null. @@ -76,7 +76,7 @@ impl ClassEntry { /// Create from raw pointer. #[inline] pub unsafe fn try_from_ptr<'a>(ptr: *const zend_class_entry) -> Option<&'a Self> { - (ptr as *const Self).as_ref() + unsafe { (ptr as *const Self).as_ref() } } /// Wraps a raw pointer. @@ -90,7 +90,7 @@ impl ClassEntry { /// Panics if pointer is null. #[inline] pub unsafe fn from_mut_ptr<'a>(ptr: *mut zend_class_entry) -> &'a mut Self { - (ptr as *mut Self).as_mut().expect("ptr should't be null") + unsafe { (ptr as *mut Self).as_mut().expect("ptr should't be null") } } /// Wraps a raw pointer, return None if pointer is null. @@ -100,7 +100,7 @@ impl ClassEntry { /// Create from raw pointer. #[inline] pub unsafe fn try_from_mut_ptr<'a>(ptr: *mut zend_class_entry) -> Option<&'a mut Self> { - (ptr as *mut Self).as_mut() + unsafe { (ptr as *mut Self).as_mut() } } /// Returns a raw pointer wrapped. @@ -604,35 +604,37 @@ impl ClassEntity { #[allow(clippy::useless_conversion)] pub(crate) unsafe fn init(&self) -> *mut zend_class_entry { - let parent: *mut zend_class_entry = self - .parent - .as_ref() - .map(|parent| parent()) - .map(|entry| entry.as_ptr() as *mut _) - .unwrap_or(null_mut()); - - let class_ce = phper_init_class_entry_ex( - self.class_name.as_ptr().cast(), - self.class_name.as_bytes().len().try_into().unwrap(), - self.function_entries(), - Some(class_init_handler), - parent.cast(), - ); - - self.bind_class.bind(class_ce); - - for interface in &self.interfaces { - let interface_ce = interface().as_ptr(); - zend_class_implements(class_ce, 1, interface_ce); - } + unsafe { + let parent: *mut zend_class_entry = self + .parent + .as_ref() + .map(|parent| parent()) + .map(|entry| entry.as_ptr() as *mut _) + .unwrap_or(null_mut()); + + let class_ce = phper_init_class_entry_ex( + self.class_name.as_ptr().cast(), + self.class_name.as_bytes().len().try_into().unwrap(), + self.function_entries(), + Some(class_init_handler), + parent.cast(), + ); + + self.bind_class.bind(class_ce); + + for interface in &self.interfaces { + let interface_ce = interface().as_ptr(); + zend_class_implements(class_ce, 1, interface_ce); + } - for constant in &self.constants { - add_class_constant(class_ce, constant); - } + for constant in &self.constants { + add_class_constant(class_ce, constant); + } - *phper_get_create_object(class_ce) = Some(create_object); + *phper_get_create_object(class_ce) = Some(create_object); - class_ce + class_ce + } } pub(crate) unsafe fn declare_properties(&self, ce: *mut zend_class_entry) { @@ -642,39 +644,45 @@ impl ClassEntity { } unsafe fn function_entries(&self) -> *const zend_function_entry { - let mut methods = self - .method_entities - .iter() - .map(|method| FunctionEntry::from_method_entity(method)) - .collect::>(); + unsafe { + let mut methods = self + .method_entities + .iter() + .map(|method| FunctionEntry::from_method_entity(method)) + .collect::>(); - methods.push(zeroed::()); + methods.push(zeroed::()); - // Store the state constructor pointer to zend_class_entry. - methods.push(self.take_state_constructor_into_function_entry()); + // Store the state constructor pointer to zend_class_entry. + methods.push(self.take_state_constructor_into_function_entry()); - // Store the state cloner pointer to zend_class_entry. - methods.push(self.take_state_cloner_into_function_entry()); + // Store the state cloner pointer to zend_class_entry. + methods.push(self.take_state_cloner_into_function_entry()); - Box::into_raw(methods.into_boxed_slice()).cast() + Box::into_raw(methods.into_boxed_slice()).cast() + } } unsafe fn take_state_constructor_into_function_entry(&self) -> zend_function_entry { - let mut entry = zeroed::(); - let ptr = &mut entry as *mut _ as *mut *const StateConstructor; - let state_constructor = Rc::into_raw(self.state_constructor.clone()); - ptr.write(state_constructor); - entry + unsafe { + let mut entry = zeroed::(); + let ptr = &mut entry as *mut _ as *mut *const StateConstructor; + let state_constructor = Rc::into_raw(self.state_constructor.clone()); + ptr.write(state_constructor); + entry + } } unsafe fn take_state_cloner_into_function_entry(&self) -> zend_function_entry { - let mut entry = zeroed::(); - let ptr = &mut entry as *mut _ as *mut *const StateCloner; - if let Some(state_cloner) = &self.state_cloner { - let state_constructor = Rc::into_raw(state_cloner.clone()); - ptr.write(state_constructor); + unsafe { + let mut entry = zeroed::(); + let ptr = &mut entry as *mut _ as *mut *const StateCloner; + if let Some(state_cloner) = &self.state_cloner { + let state_constructor = Rc::into_raw(state_cloner.clone()); + ptr.write(state_constructor); + } + entry } - entry } pub(crate) fn handler_map(&self) -> HandlerMap { @@ -717,11 +725,13 @@ impl ClassEntity { unsafe extern "C" fn class_init_handler( class_ce: *mut zend_class_entry, argument: *mut c_void, ) -> *mut zend_class_entry { - let parent = argument as *mut zend_class_entry; - if parent.is_null() { - zend_register_internal_class(class_ce) - } else { - zend_register_internal_class_ex(class_ce, parent) + unsafe { + let parent = argument as *mut zend_class_entry; + if parent.is_null() { + zend_register_internal_class(class_ce) + } else { + zend_register_internal_class_ex(class_ce, parent) + } } } @@ -782,38 +792,42 @@ impl InterfaceEntity { #[allow(clippy::useless_conversion)] pub(crate) unsafe fn init(&self) -> *mut zend_class_entry { - let class_ce = phper_init_class_entry_ex( - self.interface_name.as_ptr().cast(), - self.interface_name.as_bytes().len().try_into().unwrap(), - self.function_entries(), - Some(interface_init_handler), - null_mut(), - ); - - self.bind_interface.bind(class_ce); - - for interface in &self.extends { - let interface_ce = interface().as_ptr(); - zend_class_implements(class_ce, 1, interface_ce); - } + unsafe { + let class_ce = phper_init_class_entry_ex( + self.interface_name.as_ptr().cast(), + self.interface_name.as_bytes().len().try_into().unwrap(), + self.function_entries(), + Some(interface_init_handler), + null_mut(), + ); + + self.bind_interface.bind(class_ce); + + for interface in &self.extends { + let interface_ce = interface().as_ptr(); + zend_class_implements(class_ce, 1, interface_ce); + } - for constant in &self.constants { - add_class_constant(class_ce, constant); - } + for constant in &self.constants { + add_class_constant(class_ce, constant); + } - class_ce + class_ce + } } unsafe fn function_entries(&self) -> *const zend_function_entry { - let mut methods = self - .method_entities - .iter() - .map(|method| FunctionEntry::from_method_entity(method)) - .collect::>(); + unsafe { + let mut methods = self + .method_entities + .iter() + .map(|method| FunctionEntry::from_method_entity(method)) + .collect::>(); - methods.push(zeroed::()); + methods.push(zeroed::()); - Box::into_raw(methods.into_boxed_slice()).cast() + Box::into_raw(methods.into_boxed_slice()).cast() + } } /// Get the bound interface. @@ -826,7 +840,7 @@ impl InterfaceEntity { unsafe extern "C" fn interface_init_handler( class_ce: *mut zend_class_entry, _argument: *mut c_void, ) -> *mut zend_class_entry { - zend_register_internal_interface(class_ce) + unsafe { zend_register_internal_interface(class_ce) } } /// Builder for registering class/interface constants @@ -933,115 +947,122 @@ pub(crate) type RawVisibility = u32; #[allow(clippy::useless_conversion)] unsafe extern "C" fn create_object(ce: *mut zend_class_entry) -> *mut zend_object { - // Get real ce which hold state_constructor. - let real_ce = find_real_ce(ce).unwrap(); - - // Alloc more memory size to store state data. - let state_object = phper_zend_object_alloc(size_of::>().try_into().unwrap(), ce); - let state_object = StateObj::<()>::from_mut_ptr(state_object); + unsafe { + // Get real ce which hold state_constructor. + let real_ce = find_real_ce(ce).unwrap(); + + // Alloc more memory size to store state data. + let state_object = + phper_zend_object_alloc(size_of::>().try_into().unwrap(), ce); + let state_object = StateObj::<()>::from_mut_ptr(state_object); + + // Find the hack elements hidden behind null builtin_function. + let mut func_ptr = (*real_ce).info.internal.builtin_functions; + while !(*func_ptr).fname.is_null() { + func_ptr = func_ptr.offset(1); + } - // Find the hack elements hidden behind null builtin_function. - let mut func_ptr = (*real_ce).info.internal.builtin_functions; - while !(*func_ptr).fname.is_null() { + // Get state constructor. func_ptr = func_ptr.offset(1); - } + let state_constructor = func_ptr as *mut *const StateConstructor; + let state_constructor = state_constructor.read().as_ref().unwrap(); - // Get state constructor. - func_ptr = func_ptr.offset(1); - let state_constructor = func_ptr as *mut *const StateConstructor; - let state_constructor = state_constructor.read().as_ref().unwrap(); - - // Get state cloner. - func_ptr = func_ptr.offset(1); - let has_state_cloner = - slice::from_raw_parts(func_ptr as *const u8, size_of::<*const StateCloner>()) - != [0u8; size_of::<*const StateCloner>()]; - - // Common initialize process. - let object = state_object.as_mut_object().as_mut_ptr(); - zend_object_std_init(object, ce); - object_properties_init(object, ce); - - cfg_if::cfg_if! { - if #[cfg(any( - phper_major_version = "7", - all( - phper_major_version = "8", - any( - phper_minor_version = "0", - phper_minor_version = "1", - phper_minor_version = "2", - phper_minor_version = "3", - ), - ) - ))] { - rebuild_object_properties(object); - } else { - rebuild_object_properties_internal(object); + // Get state cloner. + func_ptr = func_ptr.offset(1); + let has_state_cloner = + slice::from_raw_parts(func_ptr as *const u8, size_of::<*const StateCloner>()) + != [0u8; size_of::<*const StateCloner>()]; + + // Common initialize process. + let object = state_object.as_mut_object().as_mut_ptr(); + zend_object_std_init(object, ce); + object_properties_init(object, ce); + + cfg_if::cfg_if! { + if #[cfg(any( + phper_major_version = "7", + all( + phper_major_version = "8", + any( + phper_minor_version = "0", + phper_minor_version = "1", + phper_minor_version = "2", + phper_minor_version = "3", + ), + ) + ))] { + rebuild_object_properties(object); + } else { + rebuild_object_properties_internal(object); + } } - } - // Set handlers - let mut handlers = Box::new(std_object_handlers); - handlers.offset = StateObj::<()>::offset() as c_int; - handlers.free_obj = Some(free_object); - handlers.clone_obj = has_state_cloner.then_some(clone_object); - (*object).handlers = Box::into_raw(handlers); + // Set handlers + let mut handlers = Box::new(std_object_handlers); + handlers.offset = StateObj::<()>::offset() as c_int; + handlers.free_obj = Some(free_object); + handlers.clone_obj = has_state_cloner.then_some(clone_object); + (*object).handlers = Box::into_raw(handlers); - // Call the state constructor and store the state. - let data = (state_constructor)(); - *state_object.as_mut_any_state() = data; + // Call the state constructor and store the state. + let data = (state_constructor)(); + *state_object.as_mut_any_state() = data; - object + object + } } #[cfg(phper_major_version = "8")] unsafe extern "C" fn clone_object(object: *mut zend_object) -> *mut zend_object { - clone_object_common(object) + unsafe { clone_object_common(object) } } #[cfg(phper_major_version = "7")] unsafe extern "C" fn clone_object(object: *mut zval) -> *mut zend_object { - let object = phper_z_obj_p(object); - clone_object_common(object) + unsafe { + let object = phper_z_obj_p(object); + clone_object_common(object) + } } #[allow(clippy::useless_conversion)] unsafe fn clone_object_common(object: *mut zend_object) -> *mut zend_object { - let ce = (*object).ce; - let real_ce = find_real_ce(ce).unwrap(); - - // Alloc more memory size to store state data. - let new_state_object = - phper_zend_object_alloc(size_of::>().try_into().unwrap(), ce); - let new_state_object = StateObj::<()>::from_mut_ptr(new_state_object); - - // Find the hack elements hidden behind null builtin_function. - let mut func_ptr = (*real_ce).info.internal.builtin_functions; - while !(*func_ptr).fname.is_null() { - func_ptr = func_ptr.offset(1); - } + unsafe { + let ce = (*object).ce; + let real_ce = find_real_ce(ce).unwrap(); + + // Alloc more memory size to store state data. + let new_state_object = + phper_zend_object_alloc(size_of::>().try_into().unwrap(), ce); + let new_state_object = StateObj::<()>::from_mut_ptr(new_state_object); + + // Find the hack elements hidden behind null builtin_function. + let mut func_ptr = (*real_ce).info.internal.builtin_functions; + while !(*func_ptr).fname.is_null() { + func_ptr = func_ptr.offset(1); + } - // Get state cloner. - func_ptr = func_ptr.offset(2); - let state_cloner = func_ptr as *mut *const StateCloner; - let state_cloner = state_cloner.read().as_ref().unwrap(); + // Get state cloner. + func_ptr = func_ptr.offset(2); + let state_cloner = func_ptr as *mut *const StateCloner; + let state_cloner = state_cloner.read().as_ref().unwrap(); - // Initialize and clone members - let new_object = new_state_object.as_mut_object().as_mut_ptr(); - zend_object_std_init(new_object, ce); - object_properties_init(new_object, ce); - zend_objects_clone_members(new_object, object); + // Initialize and clone members + let new_object = new_state_object.as_mut_object().as_mut_ptr(); + zend_object_std_init(new_object, ce); + object_properties_init(new_object, ce); + zend_objects_clone_members(new_object, object); - // Set handlers - (*new_object).handlers = (*object).handlers; + // Set handlers + (*new_object).handlers = (*object).handlers; - // Call the state cloner and store the state. - let state_object = StateObj::<()>::from_mut_object_ptr(object); - let data = (state_cloner)(*state_object.as_mut_any_state()); - *new_state_object.as_mut_any_state() = data; + // Call the state cloner and store the state. + let state_object = StateObj::<()>::from_mut_object_ptr(object); + let data = (state_cloner)(*state_object.as_mut_any_state()); + *new_state_object.as_mut_any_state() = data; - new_object + new_object + } } unsafe fn add_class_constant(class_ce: *mut _zend_class_entry, constant: &ConstantEntity) { @@ -1086,27 +1107,31 @@ unsafe fn add_class_constant(class_ce: *mut _zend_class_entry, constant: &Consta } unsafe extern "C" fn free_object(object: *mut zend_object) { - let state_object = StateObj::<()>::from_mut_object_ptr(object); + unsafe { + let state_object = StateObj::<()>::from_mut_object_ptr(object); - // Drop the state. - state_object.drop_state(); + // Drop the state. + state_object.drop_state(); - // Original destroy call. - zend_object_std_dtor(object); + // Original destroy call. + zend_object_std_dtor(object); + } } /// Find the class that registered by phper. unsafe fn find_real_ce(mut ce: *mut zend_class_entry) -> Option<*mut zend_class_entry> { - let class_entities = global_module().class_entities(); + unsafe { + let class_entities = global_module().class_entities(); - while !ce.is_null() { - for entity in class_entities { - if ClassEntry::from_ptr(ce).get_name().to_c_str() == Ok(&entity.class_name) { - return Some(ce); + while !ce.is_null() { + for entity in class_entities { + if ClassEntry::from_ptr(ce).get_name().to_c_str() == Ok(&entity.class_name) { + return Some(ce); + } } + ce = phper_get_parent_class(ce); } - ce = phper_get_parent_class(ce); - } - None + None + } } diff --git a/phper/src/errors.rs b/phper/src/errors.rs index bd8a1472..13435b2d 100644 --- a/phper/src/errors.rs +++ b/phper/src/errors.rs @@ -21,7 +21,7 @@ use std::{ fmt::{self, Debug, Display}, io, marker::PhantomData, - mem::{replace, ManuallyDrop}, + mem::{ManuallyDrop, replace}, ops::{Deref, DerefMut}, ptr::null_mut, result, @@ -504,9 +504,11 @@ impl Drop for ExceptionGuard { /// You should always return the `Result` in the handler, /// rather than use this function. pub unsafe fn throw(e: impl Throwable) { - let obj = ThrowObject::from_throwable(e).into_inner(); - let mut val = ManuallyDrop::new(ZVal::from(obj)); - zend_throw_exception_object(val.as_mut_ptr()); + unsafe { + let obj = ThrowObject::from_throwable(e).into_inner(); + let mut val = ManuallyDrop::new(ZVal::from(obj)); + zend_throw_exception_object(val.as_mut_ptr()); + } } /// Equivalent to `Ok::<_, phper::Error>(value)`. diff --git a/phper/src/functions.rs b/phper/src/functions.rs index 71dfc302..7341be6a 100644 --- a/phper/src/functions.rs +++ b/phper/src/functions.rs @@ -14,7 +14,7 @@ use crate::{ classes::{ClassEntry, RawVisibility, Visibility}, - errors::{throw, ArgumentCountError, ExceptionGuard, ThrowObject, Throwable}, + errors::{ArgumentCountError, ExceptionGuard, ThrowObject, Throwable, throw}, modules::global_module, objects::{StateObj, ZObj, ZObject}, strings::{ZStr, ZString}, @@ -28,7 +28,7 @@ use std::{ collections::HashMap, ffi::{CStr, CString}, marker::PhantomData, - mem::{size_of, transmute, zeroed, ManuallyDrop}, + mem::{ManuallyDrop, size_of, transmute, zeroed}, ptr::{self, null_mut}, rc::Rc, slice, @@ -115,23 +115,27 @@ pub struct FunctionEntry { impl FunctionEntry { pub(crate) unsafe fn from_function_entity(entity: &FunctionEntity) -> zend_function_entry { - Self::entry( - &entity.name, - &entity.arguments, - entity.return_type.as_ref(), - Some(entity.handler.clone()), - None, - ) + unsafe { + Self::entry( + &entity.name, + &entity.arguments, + entity.return_type.as_ref(), + Some(entity.handler.clone()), + None, + ) + } } pub(crate) unsafe fn from_method_entity(entity: &MethodEntity) -> zend_function_entry { - Self::entry( - &entity.name, - &entity.arguments, - entity.return_type.as_ref(), - entity.handler.clone(), - Some(entity.visibility), - ) + unsafe { + Self::entry( + &entity.name, + &entity.arguments, + entity.return_type.as_ref(), + entity.handler.clone(), + Some(entity.visibility), + ) + } } /// Will leak memory @@ -139,62 +143,66 @@ impl FunctionEntry { name: &CStr, arguments: &[Argument], return_type: Option<&ReturnType>, handler: Option>, visibility: Option, ) -> zend_function_entry { - let mut infos = Vec::new(); + unsafe { + let mut infos = Vec::new(); - let require_arg_count = arguments.iter().filter(|arg| arg.required).count(); + let require_arg_count = arguments.iter().filter(|arg| arg.required).count(); - if let Some(return_type) = return_type { - infos.push(phper_zend_begin_arg_with_return_type_info_ex( - return_type.ret_by_ref, - require_arg_count, - return_type.type_info.into_raw(), - return_type.allow_null, - )); - } else { - infos.push(phper_zend_begin_arg_info_ex(false, require_arg_count)); - } + if let Some(return_type) = return_type { + infos.push(phper_zend_begin_arg_with_return_type_info_ex( + return_type.ret_by_ref, + require_arg_count, + return_type.type_info.into_raw(), + return_type.allow_null, + )); + } else { + infos.push(phper_zend_begin_arg_info_ex(false, require_arg_count)); + } - for arg in arguments { - infos.push(phper_zend_arg_info( - arg.pass_by_ref, - arg.name.as_ptr().cast(), - )); - } + for arg in arguments { + infos.push(phper_zend_arg_info( + arg.pass_by_ref, + arg.name.as_ptr().cast(), + )); + } - infos.push(zeroed::()); + infos.push(zeroed::()); - // Will be checked in `invoke` function. - infos.push(Self::create_mysterious_code()); + // Will be checked in `invoke` function. + infos.push(Self::create_mysterious_code()); - let raw_handler = handler.as_ref().map(|_| invoke as _); + let raw_handler = handler.as_ref().map(|_| invoke as _); - if let Some(handler) = handler { - let translator = CallableTranslator { - callable: Rc::into_raw(handler), - }; - let last_arg_info: zend_internal_arg_info = translator.internal_arg_info; - infos.push(last_arg_info); - } + if let Some(handler) = handler { + let translator = CallableTranslator { + callable: Rc::into_raw(handler), + }; + let last_arg_info: zend_internal_arg_info = translator.internal_arg_info; + infos.push(last_arg_info); + } - let flags = visibility.unwrap_or(Visibility::default() as u32); + let flags = visibility.unwrap_or(Visibility::default() as u32); - #[allow(clippy::needless_update)] - zend_function_entry { - fname: name.as_ptr().cast(), - handler: raw_handler, - arg_info: Box::into_raw(infos.into_boxed_slice()).cast(), - num_args: arguments.len() as u32, - flags, - ..Default::default() + #[allow(clippy::needless_update)] + zend_function_entry { + fname: name.as_ptr().cast(), + handler: raw_handler, + arg_info: Box::into_raw(infos.into_boxed_slice()).cast(), + num_args: arguments.len() as u32, + flags, + ..Default::default() + } } } unsafe fn create_mysterious_code() -> zend_internal_arg_info { - let mut mysterious_code = [0u8; size_of::()]; - for (i, n) in INVOKE_MYSTERIOUS_CODE.iter().enumerate() { - mysterious_code[i] = *n; + unsafe { + let mut mysterious_code = [0u8; size_of::()]; + for (i, n) in INVOKE_MYSTERIOUS_CODE.iter().enumerate() { + mysterious_code[i] = *n; + } + transmute(mysterious_code) } - transmute(mysterious_code) } } @@ -398,8 +406,10 @@ impl ZFunc { /// /// Panics if pointer is null. pub(crate) unsafe fn from_mut_ptr<'a>(ptr: *mut zend_function) -> &'a mut ZFunc { - let ptr = ptr as *mut Self; - ptr.as_mut().expect("ptr shouldn't be null") + unsafe { + let ptr = ptr as *mut Self; + ptr.as_mut().expect("ptr shouldn't be null") + } } /// Returns a raw pointer wrapped. @@ -531,74 +541,77 @@ pub(crate) union CallableTranslator { /// The entry for all registered PHP functions. unsafe extern "C" fn invoke(execute_data: *mut zend_execute_data, return_value: *mut zval) { - let execute_data = ExecuteData::from_mut_ptr(execute_data); - let return_value = ZVal::from_mut_ptr(return_value); - - let num_args = execute_data.common_num_args(); - let arg_info = execute_data.common_arg_info(); - - // should be mysterious code - let mysterious_arg_info = arg_info.offset((num_args + 1) as isize); - let mysterious_code = slice::from_raw_parts( - mysterious_arg_info as *const u8, - INVOKE_MYSTERIOUS_CODE.len(), - ); - - let handler = if mysterious_code == INVOKE_MYSTERIOUS_CODE { - // hiddden real handler - let last_arg_info = arg_info.offset((num_args + 2) as isize); - let translator = CallableTranslator { - arg_info: *last_arg_info, - }; - let handler = translator.callable; - handler.as_ref().expect("handler is null") - } else { - let function_name = execute_data - .func() - .get_function_name() - .and_then(|name| name.to_c_str().ok()) - .map(CString::from); - - function_name - .and_then(|function_name| { - let class_name = execute_data - .func() - .get_class() - .and_then(|cls| cls.get_name().to_c_str().ok()) - .map(CString::from); - - global_module() - .handler_map - .get(&(class_name, function_name)) - }) - .expect("invoke handler is not correct") - .as_ref() - }; - - // Check arguments count. - let num_args = execute_data.num_args(); - let required_num_args = execute_data.common_required_num_args(); - if num_args < required_num_args { - let func_name = execute_data.func().get_function_or_method_name(); - let err: crate::Error = match func_name.to_str() { - Ok(func_name) => { - ArgumentCountError::new(func_name.to_owned(), required_num_args, num_args).into() - } - Err(e) => e.into(), + unsafe { + let execute_data = ExecuteData::from_mut_ptr(execute_data); + let return_value = ZVal::from_mut_ptr(return_value); + + let num_args = execute_data.common_num_args(); + let arg_info = execute_data.common_arg_info(); + + // should be mysterious code + let mysterious_arg_info = arg_info.offset((num_args + 1) as isize); + let mysterious_code = slice::from_raw_parts( + mysterious_arg_info as *const u8, + INVOKE_MYSTERIOUS_CODE.len(), + ); + + let handler = if mysterious_code == INVOKE_MYSTERIOUS_CODE { + // hiddden real handler + let last_arg_info = arg_info.offset((num_args + 2) as isize); + let translator = CallableTranslator { + arg_info: *last_arg_info, + }; + let handler = translator.callable; + handler.as_ref().expect("handler is null") + } else { + let function_name = execute_data + .func() + .get_function_name() + .and_then(|name| name.to_c_str().ok()) + .map(CString::from); + + function_name + .and_then(|function_name| { + let class_name = execute_data + .func() + .get_class() + .and_then(|cls| cls.get_name().to_c_str().ok()) + .map(CString::from); + + global_module() + .handler_map + .get(&(class_name, function_name)) + }) + .expect("invoke handler is not correct") + .as_ref() }; - throw(err); - *return_value = ().into(); - return; - } - let mut arguments = execute_data.get_parameters_array(); - let arguments = arguments.as_mut_slice(); + // Check arguments count. + let num_args = execute_data.num_args(); + let required_num_args = execute_data.common_required_num_args(); + if num_args < required_num_args { + let func_name = execute_data.func().get_function_or_method_name(); + let err: crate::Error = match func_name.to_str() { + Ok(func_name) => { + ArgumentCountError::new(func_name.to_owned(), required_num_args, num_args) + .into() + } + Err(e) => e.into(), + }; + throw(err); + *return_value = ().into(); + return; + } + + let mut arguments = execute_data.get_parameters_array(); + let arguments = arguments.as_mut_slice(); - handler.call( - execute_data, - transmute::<&mut [ManuallyDrop], &mut [ZVal]>(arguments), - return_value, - ); + handler.call( + execute_data, + transmute::<&mut [ManuallyDrop], &mut [ZVal]>(arguments), + return_value, + ); + } } /// Call user function by name. diff --git a/phper/src/ini.rs b/phper/src/ini.rs index c042a58e..61d73b4e 100644 --- a/phper/src/ini.rs +++ b/phper/src/ini.rs @@ -12,7 +12,7 @@ use crate::sys::*; use std::{ - ffi::{c_int, CStr}, + ffi::{CStr, c_int}, mem::zeroed, os::raw::c_char, ptr::null_mut, @@ -58,11 +58,7 @@ pub trait IntoIniValue { impl IntoIniValue for bool { #[inline] fn into_ini_value(self) -> String { - if self { - "1".to_owned() - } else { - "0".to_owned() - } + if self { "1".to_owned() } else { "0".to_owned() } } } @@ -193,16 +189,18 @@ fn create_ini_entry_ex(name: &str, default_value: &str, modifiable: u32) -> zend } unsafe fn entries(ini_entries: &[IniEntity]) -> *const zend_ini_entry_def { - let mut entries = Vec::with_capacity(ini_entries.len() + 1); + unsafe { + let mut entries = Vec::with_capacity(ini_entries.len() + 1); - ini_entries.iter().for_each(|entity| { - // Ini entity will exist throughout the whole application life cycle. - entries.push(entity.entry()); - }); + ini_entries.iter().for_each(|entity| { + // Ini entity will exist throughout the whole application life cycle. + entries.push(entity.entry()); + }); - entries.push(zeroed::()); + entries.push(zeroed::()); - Box::into_raw(entries.into_boxed_slice()).cast() + Box::into_raw(entries.into_boxed_slice()).cast() + } } pub(crate) fn register(ini_entries: &[IniEntity], module_number: c_int) { diff --git a/phper/src/lib.rs b/phper/src/lib.rs index 52ca6a7c..fb22512b 100644 --- a/phper/src/lib.rs +++ b/phper/src/lib.rs @@ -31,7 +31,7 @@ pub mod types; mod utils; pub mod values; -pub use crate::errors::{ok, Error, Result}; +pub use crate::errors::{Error, Result, ok}; pub use phper_alloc as alloc; pub use phper_macros::*; pub use phper_sys as sys; diff --git a/phper/src/modules.rs b/phper/src/modules.rs index 2a084e8b..3adcacc8 100644 --- a/phper/src/modules.rs +++ b/phper/src/modules.rs @@ -38,83 +38,93 @@ static mut GLOBAL_MODULE_ENTRY: *mut zend_module_entry = null_mut(); #[inline] pub(crate) unsafe fn global_module<'a>() -> &'a Module { - GLOBAL_MODULE.as_ref().unwrap() + unsafe { GLOBAL_MODULE.as_ref().unwrap() } } unsafe extern "C" fn module_startup(_type: c_int, module_number: c_int) -> c_int { - let module = GLOBAL_MODULE.as_mut().unwrap(); + unsafe { + let module = GLOBAL_MODULE.as_mut().unwrap(); - ini::register(&module.ini_entities, module_number); + ini::register(&module.ini_entities, module_number); - for constant in &module.constants { - constant.register(module_number); - } + for constant in &module.constants { + constant.register(module_number); + } - for class_entity in &module.class_entities { - let ce = class_entity.init(); - class_entity.declare_properties(ce); - module.handler_map.extend(class_entity.handler_map()); - } + for class_entity in &module.class_entities { + let ce = class_entity.init(); + class_entity.declare_properties(ce); + module.handler_map.extend(class_entity.handler_map()); + } - for interface_entity in &module.interface_entities { - interface_entity.init(); - } + for interface_entity in &module.interface_entities { + interface_entity.init(); + } - if let Some(f) = take(&mut module.module_init) { - f(); - } + if let Some(f) = take(&mut module.module_init) { + f(); + } - ZEND_RESULT_CODE_SUCCESS + ZEND_RESULT_CODE_SUCCESS + } } unsafe extern "C" fn module_shutdown(_type: c_int, module_number: c_int) -> c_int { - let module = GLOBAL_MODULE.as_mut().unwrap(); + unsafe { + let module = GLOBAL_MODULE.as_mut().unwrap(); - ini::unregister(module_number); + ini::unregister(module_number); - if let Some(f) = take(&mut module.module_shutdown) { - f(); - } + if let Some(f) = take(&mut module.module_shutdown) { + f(); + } - ZEND_RESULT_CODE_SUCCESS + ZEND_RESULT_CODE_SUCCESS + } } unsafe extern "C" fn request_startup(_type: c_int, _module_number: c_int) -> c_int { - let module = GLOBAL_MODULE.as_ref().unwrap(); + unsafe { + let module = GLOBAL_MODULE.as_ref().unwrap(); - if let Some(f) = &module.request_init { - f(); - } + if let Some(f) = &module.request_init { + f(); + } - ZEND_RESULT_CODE_SUCCESS + ZEND_RESULT_CODE_SUCCESS + } } unsafe extern "C" fn request_shutdown(_type: c_int, _module_number: c_int) -> c_int { - let module = GLOBAL_MODULE.as_ref().unwrap(); + unsafe { + let module = GLOBAL_MODULE.as_ref().unwrap(); - if let Some(f) = &module.request_shutdown { - f(); - } + if let Some(f) = &module.request_shutdown { + f(); + } - ZEND_RESULT_CODE_SUCCESS + ZEND_RESULT_CODE_SUCCESS + } } unsafe extern "C" fn module_info(zend_module: *mut zend_module_entry) { - let module = GLOBAL_MODULE.as_ref().unwrap(); + unsafe { + let module = GLOBAL_MODULE.as_ref().unwrap(); - php_info_print_table_start(); - if !module.version.as_bytes().is_empty() { - php_info_print_table_row(2, c"version", module.version.as_ptr()); - } - if !module.author.as_bytes().is_empty() { - php_info_print_table_row(2, c"authors", module.author.as_ptr()); - } - for (key, value) in &module.infos { - php_info_print_table_row(2, key.as_ptr(), value.as_ptr()); - } - php_info_print_table_end(); + php_info_print_table_start(); + if !module.version.as_bytes().is_empty() { + php_info_print_table_row(2, c"version", module.version.as_ptr()); + } + if !module.author.as_bytes().is_empty() { + php_info_print_table_row(2, c"authors", module.author.as_ptr()); + } + for (key, value) in &module.infos { + php_info_print_table_row(2, key.as_ptr(), value.as_ptr()); + } + php_info_print_table_end(); - display_ini_entries(zend_module); + display_ini_entries(zend_module); + } } /// Builder for registering PHP Module. @@ -237,52 +247,54 @@ impl Module { /// Leak memory to generate `zend_module_entry` pointer. #[doc(hidden)] pub unsafe fn module_entry(self) -> *const zend_module_entry { - if !GLOBAL_MODULE_ENTRY.is_null() { - return GLOBAL_MODULE_ENTRY; + unsafe { + if !GLOBAL_MODULE_ENTRY.is_null() { + return GLOBAL_MODULE_ENTRY; + } + + assert!(!self.name.as_bytes().is_empty(), "module name must be set"); + assert!( + !self.version.as_bytes().is_empty(), + "module version must be set" + ); + + let module = Box::new(self); + + let entry: Box = Box::new(zend_module_entry { + size: size_of::() as c_ushort, + zend_api: ZEND_MODULE_API_NO as c_uint, + zend_debug: ZEND_DEBUG as c_uchar, + zts: USING_ZTS as c_uchar, + ini_entry: null(), + deps: null(), + name: module.name.as_ptr(), + functions: module.function_entries(), + module_startup_func: Some(module_startup), + module_shutdown_func: Some(module_shutdown), + request_startup_func: Some(request_startup), + request_shutdown_func: Some(request_shutdown), + info_func: Some(module_info), + version: module.version.as_ptr(), + globals_size: 0, + #[cfg(phper_zts)] + globals_id_ptr: std::ptr::null_mut(), + #[cfg(not(phper_zts))] + globals_ptr: std::ptr::null_mut(), + globals_ctor: None, + globals_dtor: None, + post_deactivate_func: None, + module_started: 0, + type_: 0, + handle: null_mut(), + module_number: 0, + build_id: phper_get_zend_module_build_id(), + }); + + GLOBAL_MODULE = Box::into_raw(module); + GLOBAL_MODULE_ENTRY = Box::into_raw(entry); + + GLOBAL_MODULE_ENTRY } - - assert!(!self.name.as_bytes().is_empty(), "module name must be set"); - assert!( - !self.version.as_bytes().is_empty(), - "module version must be set" - ); - - let module = Box::new(self); - - let entry: Box = Box::new(zend_module_entry { - size: size_of::() as c_ushort, - zend_api: ZEND_MODULE_API_NO as c_uint, - zend_debug: ZEND_DEBUG as c_uchar, - zts: USING_ZTS as c_uchar, - ini_entry: null(), - deps: null(), - name: module.name.as_ptr(), - functions: module.function_entries(), - module_startup_func: Some(module_startup), - module_shutdown_func: Some(module_shutdown), - request_startup_func: Some(request_startup), - request_shutdown_func: Some(request_shutdown), - info_func: Some(module_info), - version: module.version.as_ptr(), - globals_size: 0, - #[cfg(phper_zts)] - globals_id_ptr: std::ptr::null_mut(), - #[cfg(not(phper_zts))] - globals_ptr: std::ptr::null_mut(), - globals_ctor: None, - globals_dtor: None, - post_deactivate_func: None, - module_started: 0, - type_: 0, - handle: null_mut(), - module_number: 0, - build_id: phper_get_zend_module_build_id(), - }); - - GLOBAL_MODULE = Box::into_raw(module); - GLOBAL_MODULE_ENTRY = Box::into_raw(entry); - - GLOBAL_MODULE_ENTRY } fn function_entries(&self) -> *const zend_function_entry { diff --git a/phper/src/objects.rs b/phper/src/objects.rs index 15de8fd2..5969772c 100644 --- a/phper/src/objects.rs +++ b/phper/src/objects.rs @@ -12,7 +12,7 @@ use crate::{ classes::ClassEntry, - functions::{call_internal, call_raw_common, ZFunc}, + functions::{ZFunc, call_internal, call_raw_common}, sys::*, values::ZVal, }; @@ -23,7 +23,7 @@ use std::{ ffi::c_void, fmt::{self, Debug}, marker::PhantomData, - mem::{replace, size_of, ManuallyDrop}, + mem::{ManuallyDrop, replace, size_of}, ops::{Deref, DerefMut}, ptr::null_mut, }; @@ -47,7 +47,7 @@ impl ZObj { /// Panics if pointer is null. #[inline] pub unsafe fn from_ptr<'a>(ptr: *const zend_object) -> &'a Self { - (ptr as *const Self).as_ref().expect("ptr should't be null") + unsafe { (ptr as *const Self).as_ref().expect("ptr should't be null") } } /// Wraps a raw pointer, return None if pointer is null. @@ -57,7 +57,7 @@ impl ZObj { /// Create from raw pointer. #[inline] pub unsafe fn try_from_ptr<'a>(ptr: *const zend_object) -> Option<&'a Self> { - (ptr as *const Self).as_ref() + unsafe { (ptr as *const Self).as_ref() } } /// Wraps a raw pointer. @@ -71,7 +71,7 @@ impl ZObj { /// Panics if pointer is null. #[inline] pub unsafe fn from_mut_ptr<'a>(ptr: *mut zend_object) -> &'a mut Self { - (ptr as *mut Self).as_mut().expect("ptr should't be null") + unsafe { (ptr as *mut Self).as_mut().expect("ptr should't be null") } } /// Wraps a raw pointer, return None if pointer is null. @@ -81,7 +81,7 @@ impl ZObj { /// Create from raw pointer. #[inline] pub unsafe fn try_from_mut_ptr<'a>(ptr: *mut zend_object) -> Option<&'a mut Self> { - (ptr as *mut Self).as_mut() + unsafe { (ptr as *mut Self).as_mut() } } /// Returns a raw pointer wrapped. @@ -102,7 +102,7 @@ impl ZObj { /// Should only call this method for the class of object defined by the /// extension created by `phper`, otherwise, memory problems will caused. pub unsafe fn as_state_obj(&self) -> &StateObj { - StateObj::from_object_ptr(self.as_ptr()) + unsafe { StateObj::from_object_ptr(self.as_ptr()) } } /// Upgrade to mutable state obj. @@ -112,7 +112,7 @@ impl ZObj { /// Should only call this method for the class of object defined by the /// extension created by `phper`, otherwise, memory problems will caused. pub unsafe fn as_mut_state_obj(&mut self) -> &mut StateObj { - StateObj::from_mut_object_ptr(self.as_mut_ptr()) + unsafe { StateObj::from_mut_object_ptr(self.as_mut_ptr()) } } /// Get the inner handle of object. @@ -262,7 +262,7 @@ impl ZObj { } pub(crate) unsafe fn gc_refcount(&self) -> u32 { - phper_zend_object_gc_refcount(self.as_ptr()) + unsafe { phper_zend_object_gc_refcount(self.as_ptr()) } } } @@ -319,8 +319,10 @@ impl ZObject { /// twice on the same raw pointer. #[inline] pub unsafe fn from_raw(ptr: *mut zend_object) -> Self { - Self { - inner: ZObj::from_mut_ptr(ptr), + unsafe { + Self { + inner: ZObj::from_mut_ptr(ptr), + } } } @@ -391,23 +393,29 @@ impl StateObj { #[inline] pub(crate) unsafe fn from_mut_ptr<'a>(ptr: *mut c_void) -> &'a mut Self { - (ptr as *mut Self).as_mut().expect("ptr should't be null") + unsafe { (ptr as *mut Self).as_mut().expect("ptr should't be null") } } pub(crate) unsafe fn from_object_ptr<'a>(ptr: *const zend_object) -> &'a Self { - ((ptr as usize - Self::offset()) as *const Self) - .as_ref() - .unwrap() + unsafe { + ((ptr as usize - Self::offset()) as *const Self) + .as_ref() + .unwrap() + } } pub(crate) unsafe fn from_mut_object_ptr<'a>(ptr: *mut zend_object) -> &'a mut Self { - ((ptr as usize - Self::offset()) as *mut Self) - .as_mut() - .unwrap() + unsafe { + ((ptr as usize - Self::offset()) as *mut Self) + .as_mut() + .unwrap() + } } pub(crate) unsafe fn drop_state(&mut self) { - drop(Box::from_raw(self.any_state)); + unsafe { + drop(Box::from_raw(self.any_state)); + } } #[inline] diff --git a/phper/src/output.rs b/phper/src/output.rs index 452d633c..49e637de 100644 --- a/phper/src/output.rs +++ b/phper/src/output.rs @@ -33,7 +33,7 @@ pub fn log(level: LogLevel, message: impl Into) { unsafe { php_error_docref1( null(), - "\0".as_ptr().cast(), + c"".as_ptr().cast(), level as i32, message.as_ptr().cast(), ); diff --git a/phper/src/references.rs b/phper/src/references.rs index f4ff295e..57ff8470 100644 --- a/phper/src/references.rs +++ b/phper/src/references.rs @@ -30,9 +30,11 @@ impl ZRef { /// /// Panics if pointer is null. pub unsafe fn from_ptr<'a>(ptr: *const zend_reference) -> &'a Self { - (ptr as *const Self) - .as_ref() - .expect("ptr should not be null") + unsafe { + (ptr as *const Self) + .as_ref() + .expect("ptr should not be null") + } } /// Wraps a raw pointer, return None if pointer is null. @@ -41,7 +43,7 @@ impl ZRef { /// /// Create from raw pointer. pub unsafe fn try_from_ptr<'a>(ptr: *const zend_reference) -> Option<&'a Self> { - (ptr as *const Self).as_ref() + unsafe { (ptr as *const Self).as_ref() } } /// Wraps a raw pointer. @@ -54,7 +56,7 @@ impl ZRef { /// /// Panics if pointer is null. pub unsafe fn from_mut_ptr<'a>(ptr: *mut zend_reference) -> &'a mut Self { - (ptr as *mut Self).as_mut().expect("ptr should not be null") + unsafe { (ptr as *mut Self).as_mut().expect("ptr should not be null") } } /// Wraps a raw pointer, return None if pointer is null. @@ -63,7 +65,7 @@ impl ZRef { /// /// Create from raw pointer. pub unsafe fn try_from_mut_ptr<'a>(ptr: *mut zend_reference) -> Option<&'a mut Self> { - (ptr as *mut Self).as_mut() + unsafe { (ptr as *mut Self).as_mut() } } /// Returns a raw pointer wrapped. diff --git a/phper/src/resources.rs b/phper/src/resources.rs index eb210d4b..feee8b19 100644 --- a/phper/src/resources.rs +++ b/phper/src/resources.rs @@ -30,9 +30,11 @@ impl ZRes { /// /// Panics if pointer is null. pub unsafe fn from_ptr<'a>(ptr: *const zend_resource) -> &'a Self { - (ptr as *const Self) - .as_ref() - .expect("ptr should not be null") + unsafe { + (ptr as *const Self) + .as_ref() + .expect("ptr should not be null") + } } /// Wraps a raw pointer, return None if pointer is null. @@ -41,7 +43,7 @@ impl ZRes { /// /// Create from raw pointer. pub unsafe fn try_from_ptr<'a>(ptr: *const zend_resource) -> Option<&'a Self> { - (ptr as *const Self).as_ref() + unsafe { (ptr as *const Self).as_ref() } } /// Wraps a raw pointer. @@ -54,7 +56,7 @@ impl ZRes { /// /// Panics if pointer is null. pub unsafe fn from_mut_ptr<'a>(ptr: *mut zend_resource) -> &'a mut Self { - (ptr as *mut Self).as_mut().expect("ptr should not be null") + unsafe { (ptr as *mut Self).as_mut().expect("ptr should not be null") } } /// Wraps a raw pointer, return None if pointer is null. @@ -63,7 +65,7 @@ impl ZRes { /// /// Create from raw pointer. pub unsafe fn try_from_mut_ptr<'a>(ptr: *mut zend_resource) -> Option<&'a mut Self> { - (ptr as *mut Self).as_mut() + unsafe { (ptr as *mut Self).as_mut() } } /// Returns a raw pointer wrapped. diff --git a/phper/src/strings.rs b/phper/src/strings.rs index 29ad4547..933ed805 100644 --- a/phper/src/strings.rs +++ b/phper/src/strings.rs @@ -44,7 +44,7 @@ impl ZStr { /// Panics if pointer is null. #[inline] pub unsafe fn from_ptr<'a>(ptr: *const zend_string) -> &'a Self { - (ptr as *const Self).as_ref().expect("ptr should't be null") + unsafe { (ptr as *const Self).as_ref().expect("ptr should't be null") } } /// Wraps a raw pointer, return None if pointer is null. @@ -54,7 +54,7 @@ impl ZStr { /// Create from raw pointer. #[inline] pub unsafe fn try_from_ptr<'a>(ptr: *const zend_string) -> Option<&'a Self> { - (ptr as *const Self).as_ref() + unsafe { (ptr as *const Self).as_ref() } } /// Wraps a raw pointer. @@ -68,7 +68,7 @@ impl ZStr { /// Panics if pointer is null. #[inline] pub unsafe fn from_mut_ptr<'a>(ptr: *mut zend_string) -> &'a mut Self { - (ptr as *mut Self).as_mut().expect("ptr should't be null") + unsafe { (ptr as *mut Self).as_mut().expect("ptr should't be null") } } /// Wraps a raw pointer, return None if pointer is null. @@ -78,7 +78,7 @@ impl ZStr { /// Create from raw pointer. #[inline] pub unsafe fn try_from_mut_ptr<'a>(ptr: *mut zend_string) -> Option<&'a mut Self> { - (ptr as *mut Self).as_mut() + unsafe { (ptr as *mut Self).as_mut() } } /// Returns a raw pointer wrapped. @@ -200,8 +200,10 @@ impl ZString { /// twice on the same raw pointer. #[inline] pub unsafe fn from_raw(ptr: *mut zend_string) -> Self { - Self { - inner: ZStr::from_mut_ptr(ptr), + unsafe { + Self { + inner: ZStr::from_mut_ptr(ptr), + } } } diff --git a/phper/src/types.rs b/phper/src/types.rs index 4321127f..1a69938b 100644 --- a/phper/src/types.rs +++ b/phper/src/types.rs @@ -200,6 +200,12 @@ pub enum Scalar { Bytes(Vec), } +impl From<()> for Scalar { + fn from(_: ()) -> Self { + Self::Null + } +} + impl From<&str> for Scalar { fn from(s: &str) -> Self { Self::String(s.to_owned()) diff --git a/phper/src/values.rs b/phper/src/values.rs index 5b8a3340..f45a14f0 100644 --- a/phper/src/values.rs +++ b/phper/src/values.rs @@ -14,7 +14,7 @@ use crate::{ alloc::EBox, arrays::{ZArr, ZArray}, errors::ExpectTypeError, - functions::{call_internal, ZFunc}, + functions::{ZFunc, call_internal}, objects::{StateObject, ZObj, ZObject}, references::ZRef, resources::ZRes, @@ -28,7 +28,7 @@ use std::{ fmt, fmt::Debug, marker::PhantomData, - mem::{transmute, zeroed, ManuallyDrop, MaybeUninit}, + mem::{ManuallyDrop, MaybeUninit, transmute, zeroed}, str, }; @@ -51,7 +51,7 @@ impl ExecuteData { #[inline] #[allow(dead_code)] pub unsafe fn from_ptr<'a>(ptr: *const zend_execute_data) -> &'a Self { - (ptr as *const Self).as_ref().expect("ptr should't be null") + unsafe { (ptr as *const Self).as_ref().expect("ptr should't be null") } } /// Wraps a raw pointer, return None if pointer is null. @@ -62,7 +62,7 @@ impl ExecuteData { #[inline] #[allow(dead_code)] pub unsafe fn try_from_ptr<'a>(ptr: *const zend_execute_data) -> Option<&'a Self> { - (ptr as *const Self).as_ref() + unsafe { (ptr as *const Self).as_ref() } } /// Wraps a raw pointer. @@ -76,7 +76,7 @@ impl ExecuteData { /// Panics if pointer is null. #[inline] pub unsafe fn from_mut_ptr<'a>(ptr: *mut zend_execute_data) -> &'a mut Self { - (ptr as *mut Self).as_mut().expect("ptr should't be null") + unsafe { (ptr as *mut Self).as_mut().expect("ptr should't be null") } } /// Wraps a raw pointer, return None if pointer is null. @@ -87,7 +87,7 @@ impl ExecuteData { #[inline] #[allow(dead_code)] pub unsafe fn try_from_mut_ptr<'a>(ptr: *mut zend_execute_data) -> Option<&'a mut Self> { - (ptr as *mut Self).as_mut() + unsafe { (ptr as *mut Self).as_mut() } } /// Returns a raw pointer wrapped. @@ -148,15 +148,17 @@ impl ExecuteData { } pub(crate) unsafe fn get_parameters_array(&mut self) -> Vec> { - let num_args = self.num_args(); - let mut arguments = vec![zeroed::(); num_args]; - if num_args > 0 { - phper_zend_get_parameters_array_ex( - num_args.try_into().unwrap(), - arguments.as_mut_ptr(), - ); + unsafe { + let num_args = self.num_args(); + let mut arguments = vec![zeroed::(); num_args]; + if num_args > 0 { + phper_zend_get_parameters_array_ex( + num_args.try_into().unwrap(), + arguments.as_mut_ptr(), + ); + } + transmute(arguments) } - transmute(arguments) } /// Gets parameter by index. @@ -195,7 +197,7 @@ impl ZVal { /// Panics if pointer is null. #[inline] pub unsafe fn from_ptr<'a>(ptr: *const zval) -> &'a Self { - (ptr as *const Self).as_ref().expect("ptr should't be null") + unsafe { (ptr as *const Self).as_ref().expect("ptr should't be null") } } /// Wraps a raw pointer, return None if pointer is null. @@ -205,7 +207,7 @@ impl ZVal { /// Create from raw pointer. #[inline] pub unsafe fn try_from_ptr<'a>(ptr: *const zval) -> Option<&'a Self> { - (ptr as *const Self).as_ref() + unsafe { (ptr as *const Self).as_ref() } } /// Wraps a raw pointer. @@ -219,7 +221,7 @@ impl ZVal { /// Panics if pointer is null. #[inline] pub unsafe fn from_mut_ptr<'a>(ptr: *mut zval) -> &'a mut Self { - (ptr as *mut Self).as_mut().expect("ptr should't be null") + unsafe { (ptr as *mut Self).as_mut().expect("ptr should't be null") } } /// Wraps a raw pointer, return None if pointer is null. @@ -229,7 +231,7 @@ impl ZVal { /// Create from raw pointer. #[inline] pub unsafe fn try_from_mut_ptr<'a>(ptr: *mut zval) -> Option<&'a mut Self> { - (ptr as *mut Self).as_mut() + unsafe { (ptr as *mut Self).as_mut() } } /// Returns a raw pointer wrapped. diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 688a0416..9ac0ee51 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -9,5 +9,5 @@ # See the Mulan PSL v2 for more details. [toolchain] -channel = "1.79" +channel = "1.85" components = ["clippy", "rustfmt"] diff --git a/tests/integration/Cargo.toml b/tests/integration/Cargo.toml index fe65c6df..039e552c 100644 --- a/tests/integration/Cargo.toml +++ b/tests/integration/Cargo.toml @@ -21,7 +21,7 @@ license = { workspace = true } crate-type = ["lib", "cdylib"] [dependencies] -indexmap = "2.3.0" +indexmap = "2.7.1" phper = { workspace = true } [dev-dependencies] diff --git a/tests/integration/src/classes.rs b/tests/integration/src/classes.rs index b20036f4..01057959 100644 --- a/tests/integration/src/classes.rs +++ b/tests/integration/src/classes.rs @@ -11,7 +11,7 @@ use phper::{ alloc::RefClone, classes::{ - array_access_class, iterator_class, ClassEntity, ClassEntry, InterfaceEntity, Visibility, + ClassEntity, ClassEntry, InterfaceEntity, Visibility, array_access_class, iterator_class, }, functions::Argument, modules::Module, diff --git a/tests/integration/src/errors.rs b/tests/integration/src/errors.rs index 6d922721..18d997a8 100644 --- a/tests/integration/src/errors.rs +++ b/tests/integration/src/errors.rs @@ -9,7 +9,7 @@ // See the Mulan PSL v2 for more details. use phper::{ - errors::{exception_class, ThrowObject}, + errors::{ThrowObject, exception_class}, modules::Module, }; use std::io; diff --git a/tests/integration/src/functions.rs b/tests/integration/src/functions.rs index cb024cd0..3a4d9a7d 100644 --- a/tests/integration/src/functions.rs +++ b/tests/integration/src/functions.rs @@ -11,7 +11,7 @@ use phper::{ arrays::ZArray, errors::throw, - functions::{call, Argument}, + functions::{Argument, call}, modules::Module, values::ZVal, }; diff --git a/tests/integration/src/ini.rs b/tests/integration/src/ini.rs index cf949833..55765be1 100644 --- a/tests/integration/src/ini.rs +++ b/tests/integration/src/ini.rs @@ -9,7 +9,7 @@ // See the Mulan PSL v2 for more details. use phper::{ - ini::{ini_get, Policy}, + ini::{Policy, ini_get}, modules::Module, }; use std::{convert::Infallible, ffi::CStr}; diff --git a/tests/integration/src/values.rs b/tests/integration/src/values.rs index 3ed47ee9..c8a206e3 100644 --- a/tests/integration/src/values.rs +++ b/tests/integration/src/values.rs @@ -9,7 +9,7 @@ // See the Mulan PSL v2 for more details. use phper::{ - alloc::{ebox, EBox}, + alloc::{EBox, ebox}, arrays::{InsertKey, ZArray}, modules::Module, objects::ZObject, @@ -150,7 +150,9 @@ fn integration_values_return_ebox_i64(_: &mut [ZVal]) -> Result, Infal Ok(ebox!(64)) } -fn integration_values_return_result_string_ok(_: &mut [ZVal]) -> phper::Result> { +fn integration_values_return_result_string_ok( + _: &mut [ZVal], +) -> phper::Result + use<>> { Ok("foo".to_string()) }