Skip to content

Commit b204b48

Browse files
authored
Merge branch 'master' into 453_ZendHashTable_numeric_keys
2 parents fcf9980 + 688201a commit b204b48

File tree

25 files changed

+232
-78
lines changed

25 files changed

+232
-78
lines changed

.envrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
use flake

.github/workflows/build.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,6 @@ jobs:
9494
# ext-php-rs requires nightly Rust when on Windows.
9595
- os: windows-latest
9696
rust: stable
97-
# setup-php doesn't support thread safe PHP on Linux and macOS.
98-
- os: macos-latest
99-
phpts: ts
100-
- os: ubuntu-latest
101-
phpts: ts
10297
- os: macos-latest
10398
clang: "17"
10499
- os: ubuntu-latest

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ Cargo.lock
33
/.vscode
44
/.idea
55
/tmp
6-
expand.rs
6+
/.direnv
7+
expand.rs

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ Contributions welcome include:
193193
When contributing, please keep in mind the following:
194194
- Create tests if possible.
195195
- Update the documentation if necessary.
196-
- If your change is a [braking change](https://semver.org) a migration guide MUST be included. This
196+
- If your change is a [breaking change](https://semver.org) a migration guide MUST be included. This
197197
should be placed in the `guide/src/migration-guides` directory.
198198
- Use [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/). We use these to automatically generate changelogs.
199199

crates/cli/src/lib.rs

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,12 @@ struct Install {
111111
/// the directory the command is called.
112112
#[arg(long)]
113113
manifest: Option<PathBuf>,
114+
#[arg(short = 'F', long, num_args = 1..)]
115+
features: Option<Vec<String>>,
116+
#[arg(long)]
117+
all_features: bool,
118+
#[arg(long)]
119+
no_default_features: bool,
114120
/// Whether to bypass the install prompt.
115121
#[clap(long)]
116122
yes: bool,
@@ -156,6 +162,12 @@ struct Stubs {
156162
/// provides a direct path to the extension shared library.
157163
#[arg(long, conflicts_with = "ext")]
158164
manifest: Option<PathBuf>,
165+
#[arg(short = 'F', long, num_args = 1..)]
166+
features: Option<Vec<String>>,
167+
#[arg(long)]
168+
all_features: bool,
169+
#[arg(long)]
170+
no_default_features: bool,
159171
}
160172

161173
impl Args {
@@ -172,7 +184,13 @@ impl Args {
172184
impl Install {
173185
pub fn handle(self) -> CrateResult {
174186
let artifact = find_ext(self.manifest.as_ref())?;
175-
let ext_path = build_ext(&artifact, self.release)?;
187+
let ext_path = build_ext(
188+
&artifact,
189+
self.release,
190+
self.features,
191+
self.all_features,
192+
self.no_default_features,
193+
)?;
176194

177195
let (mut ext_dir, mut php_ini) = if let Some(install_dir) = self.install_dir {
178196
(install_dir, None)
@@ -371,7 +389,14 @@ impl Stubs {
371389
ext_path
372390
} else {
373391
let target = find_ext(self.manifest.as_ref())?;
374-
build_ext(&target, false)?.into()
392+
build_ext(
393+
&target,
394+
false,
395+
self.features,
396+
self.all_features,
397+
self.no_default_features,
398+
)?
399+
.into()
375400
};
376401

377402
if !ext_path.is_file() {
@@ -469,17 +494,38 @@ fn find_ext(manifest: Option<&PathBuf>) -> AResult<cargo_metadata::Target> {
469494
///
470495
/// * `target` - The target to compile.
471496
/// * `release` - Whether to compile the target in release mode.
497+
/// * `features` - Optional list of features.
472498
///
473499
/// # Returns
474500
///
475501
/// The path to the target artifact.
476-
fn build_ext(target: &Target, release: bool) -> AResult<Utf8PathBuf> {
502+
fn build_ext(
503+
target: &Target,
504+
release: bool,
505+
features: Option<Vec<String>>,
506+
all_features: bool,
507+
no_default_features: bool,
508+
) -> AResult<Utf8PathBuf> {
477509
let mut cmd = Command::new("cargo");
478510
cmd.arg("build")
479511
.arg("--message-format=json-render-diagnostics");
480512
if release {
481513
cmd.arg("--release");
482514
}
515+
if let Some(features) = features {
516+
cmd.arg("--features");
517+
for feature in features {
518+
cmd.arg(feature);
519+
}
520+
}
521+
522+
if all_features {
523+
cmd.arg("--all-features");
524+
}
525+
526+
if no_default_features {
527+
cmd.arg("--no-default-features");
528+
}
483529

484530
let mut spawn = cmd
485531
.stdout(Stdio::piped())

crates/macros/src/class.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ fn generate_registered_class_impl(
153153
};
154154

155155
let docs = quote! {
156-
#(#docs)*
156+
#(#docs,)*
157157
};
158158

159159
let extends = if let Some(extends) = extends {

crates/macros/src/lib.rs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,11 @@ extern crate proc_macro;
200200
/// # fn main() {}
201201
/// ````
202202
#[proc_macro_attribute]
203-
pub fn php_class(_args: TokenStream, input: TokenStream) -> TokenStream {
203+
pub fn php_class(args: TokenStream, input: TokenStream) -> TokenStream {
204204
let input = parse_macro_input!(input as ItemStruct);
205+
if !args.is_empty() {
206+
return err!(input => "`#[php_class(<args>)]` args are no longer supported. Please use `#[php(<args>)]` instead.").to_compile_error().into();
207+
}
205208

206209
class::parser(input)
207210
.unwrap_or_else(|e| e.to_compile_error())
@@ -363,8 +366,11 @@ pub fn php_class(_args: TokenStream, input: TokenStream) -> TokenStream {
363366
/// translated into an exception and thrown. See the section on
364367
/// [exceptions](../exceptions.md) for more details.
365368
#[proc_macro_attribute]
366-
pub fn php_function(_args: TokenStream, input: TokenStream) -> TokenStream {
369+
pub fn php_function(args: TokenStream, input: TokenStream) -> TokenStream {
367370
let input = parse_macro_input!(input as ItemFn);
371+
if !args.is_empty() {
372+
return err!(input => "`#[php_function(<args>)]` args are no longer supported. Please use `#[php(<args>)]` instead.").to_compile_error().into();
373+
}
368374

369375
function::parser(input)
370376
.unwrap_or_else(|e| e.to_compile_error())
@@ -423,8 +429,11 @@ pub fn php_function(_args: TokenStream, input: TokenStream) -> TokenStream {
423429
/// var_dump(MANUAL_CONSTANT); // string(12) "Hello world!"
424430
/// ```
425431
#[proc_macro_attribute]
426-
pub fn php_const(_args: TokenStream, input: TokenStream) -> TokenStream {
432+
pub fn php_const(args: TokenStream, input: TokenStream) -> TokenStream {
427433
let input = parse_macro_input!(input as ItemConst);
434+
if !args.is_empty() {
435+
return err!(input => "`#[php_const(<args>)]` args are no longer supported. Please use `#[php(<args>)]` instead.").to_compile_error().into();
436+
}
428437

429438
constant::parser(input)
430439
.unwrap_or_else(|e| e.to_compile_error())
@@ -498,8 +507,11 @@ pub fn php_const(_args: TokenStream, input: TokenStream) -> TokenStream {
498507
/// # fn main() {}
499508
/// ```
500509
#[proc_macro_attribute]
501-
pub fn php_module(_args: TokenStream, input: TokenStream) -> TokenStream {
510+
pub fn php_module(args: TokenStream, input: TokenStream) -> TokenStream {
502511
let input = parse_macro_input!(input as ItemFn);
512+
if !args.is_empty() {
513+
return err!(input => "`#[php_module(<args>)]` args are no longer supported. Please use `#[php(<args>)]` instead.").to_compile_error().into();
514+
}
503515

504516
module::parser(input)
505517
.unwrap_or_else(|e| e.to_compile_error())
@@ -685,8 +697,11 @@ pub fn php_module(_args: TokenStream, input: TokenStream) -> TokenStream {
685697
///
686698
/// [`php_async_impl`]: ./async_impl.md
687699
#[proc_macro_attribute]
688-
pub fn php_impl(_args: TokenStream, input: TokenStream) -> TokenStream {
700+
pub fn php_impl(args: TokenStream, input: TokenStream) -> TokenStream {
689701
let input = parse_macro_input!(input as ItemImpl);
702+
if !args.is_empty() {
703+
return err!(input => "`#[php_impl(<args>)]` args are no longer supported. Please use `#[php(<args>)]` instead.").to_compile_error().into();
704+
}
690705

691706
impl_::parser(input)
692707
.unwrap_or_else(|e| e.to_compile_error())

flake.lock

Lines changed: 48 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
description = "ext-php-rs dev environment";
3+
4+
inputs = {
5+
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
6+
rust-overlay = {
7+
url = "github:oxalica/rust-overlay";
8+
inputs = {
9+
nixpkgs.follows = "nixpkgs";
10+
};
11+
};
12+
};
13+
14+
outputs =
15+
{ nixpkgs, rust-overlay, ... }:
16+
let
17+
system = "x86_64-linux";
18+
overlays = [ (import rust-overlay) ];
19+
pkgs = import nixpkgs { inherit system overlays; };
20+
php-dev = pkgs.php.unwrapped.dev;
21+
in
22+
{
23+
devShells.${system} = {
24+
default = pkgs.mkShell {
25+
buildInputs = with pkgs; [
26+
php
27+
php-dev
28+
libclang.lib
29+
clang
30+
];
31+
32+
nativeBuildInputs = [ pkgs.rust-bin.stable.latest.default ];
33+
34+
shellHook = ''
35+
export LIBCLANG_PATH="''$LIBCLANG_PATH ${pkgs.libclang.lib}/lib"
36+
'';
37+
};
38+
};
39+
};
40+
}

src/builders/class.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ impl ClassBuilder {
303303

304304
let class = unsafe {
305305
zend_register_internal_class_ex(
306-
&mut self.ce,
306+
&raw mut self.ce,
307307
match self.extends {
308308
Some((ptr, _)) => ptr::from_ref(ptr()).cast_mut(),
309309
None => std::ptr::null_mut(),

0 commit comments

Comments
 (0)