Commit Graph

216 Commits

Author SHA1 Message Date
David Cole
1f0582b10d
fix describe when using #[implements] (#169)
[ci skip]
2022-10-23 12:02:00 +13:00
Denzyl Dick
ad048d0e05
Update lib.rs (#168)
Correct field name.

[ci skip]
2022-10-22 21:33:48 +13:00
David Cole
296c3add84 add note to update docs.rs bindings
[ci skip]
2022-10-16 13:13:17 +13:00
Niklas Mollenhauer
24d703d955
Add some standard zend interfaces (#164)
* Add some standard zend interfaces

The zend API also has some standard interfaces it exposes:
c8c09b4aae/Zend/zend_interfaces.h (L27-L33)
```
extern ZEND_API zend_class_entry *zend_ce_traversable;
extern ZEND_API zend_class_entry *zend_ce_aggregate;
extern ZEND_API zend_class_entry *zend_ce_iterator;
extern ZEND_API zend_class_entry *zend_ce_arrayaccess;
extern ZEND_API zend_class_entry *zend_ce_serializable;
extern ZEND_API zend_class_entry *zend_ce_countable;
extern ZEND_API zend_class_entry *zend_ce_stringable;
```

This surfaced in #163 and should make it possible to implement these interfaces.

* Add some links to the php documentation

* update docs.rs bindings

Co-authored-by: David Cole <david.cole1340@gmail.com>
2022-10-16 13:13:09 +13:00
David Cole
6a598ded3d
fix building docs on docs.rs (#165)
* fix building docs on docs.rs

accidentally removed the docs.rs stub bindings feature in
664981f4fb. docs.rs only has php 7.4 and
therefore cannot build ext-php-rs, so stub bindings are generated prior.

* update docs.rs stub bindings
2022-10-16 12:49:02 +13:00
Dirk Stolle
6766786db5
Update changelog for latest versions (#161)
[ci skip]
2022-10-13 10:37:17 +13:00
David Cole
669e024feb Bump version to v0.8.1 2022-10-12 11:18:22 +13:00
Robert O'Rourke
8a81c4b7f8
Allow passing --yes parameter to bypass prompts (#135)
* Allow passing `--yes` parameter to bypass prompts

Makes this tool usable in automated builds such as Docker containers.

Addresses https://github.com/davidcole1340/ext-php-rs/issues/133

* Update readme and guides

* rustfmt

Co-authored-by: David Cole <david.cole1340@gmail.com>
2022-10-01 12:14:15 +13:00
Robert O'Rourke
7dac4010a0
Fix INI file truncation and duplication (#136)
Addresses https://github.com/davidcole1340/ext-php-rs/issues/134

Also prevents adding the extension include line twice.
2022-10-01 11:24:36 +13:00
Bradley Schofield
1da812cf78
Add php-scrypt as a example project (#146) 2022-10-01 11:24:19 +13:00
Joe Hoyle
d4ef116b31
Support marking methods as abstract (#154)
For classes that are registered with `#[php_impl]` this allows functions to be marked as abstract.
2022-10-01 11:24:04 +13:00
Joe Hoyle
5d1fda4666
Support marking classes as interfaces (#155)
* Support marking classes as interfaces

This allows passing flags as part of `#[php_class(flags=Interface]` etc, which allows one to mark a class as being an interface.

When a class is an interface, it also shouldn't get a constructor created for it.

* rustfmt
2022-10-01 11:23:48 +13:00
Joe Hoyle
90cbbc0fca
Specify classes as fully-qualified names in stubs (#156)
* Specify classes as fully-qualified names in stubs

When stubs are generated, the type annotations don't use a loading `\`, which means they are interpreted as relative to the current namespace. That's wrong, as all types are relative to the root namespace.

* rustfmt
2022-10-01 11:23:27 +13:00
Tobias Bengtsson
73902ef017
Merge pull request #153 from joehoyle/add-name-function-macro
Add ability to set function name on php_function macro
2022-09-30 13:04:22 +02:00
Joe Hoyle
18ede97712 Add ability to set function name on php_function macro
This is much the same as `php_class(name="ABC")`
2022-09-30 12:01:35 +02:00
Tobias Bengtsson
199962ce3f
Merge pull request #151 from striezel-stash/gh-action-update
update actions/checkout in GitHub Actions workflows to v3
2022-09-28 23:04:44 +02:00
Tobias Bengtsson
0d8aec2a77
Merge pull request #159 from striezel-stash/run-clippy-only-on-stable
ci: run clippy only on stable Rust channel
2022-09-28 23:02:39 +02:00
Dirk Stolle
a13f2b99cc update actions/checkout in GitHub Actions workflows to v3 2022-09-28 22:11:20 +02:00
Dirk Stolle
ca5a7c21f7 ci: run clippy only on stable Rust channel
Sparked by the comments about nightly clippy breaking the build
too often (see <https://github.com/davidcole1340/ext-php-rs/pull/151#issuecomment-1261151479>),
this change will limit clippy to builds with a stable Rust
version only.
2022-09-28 22:08:10 +02:00
Tobias Bengtsson
81d1861a1d
Merge pull request #158 from striezel-stash/fix-clap-errors
Use arg instead of deprecated clap attribute
2022-09-28 22:01:28 +02:00
Dirk Stolle
7b238eede1 attempt to fix errors related to clap
This should fix the errors from the build at
<https://github.com/davidcole1340/ext-php-rs/actions/runs/3145521955/jobs/5112909446>:

       Compiling clap v4.0.0
    error: Unknown `#[clap(long)]` attribute (`#[arg(long)] exists)
      --> crates/cli/src/lib.rs:92:12
       |
    92 |     #[clap(long)]
       |            ^^^^

    error: Unknown `#[clap(long)]` attribute (`#[arg(long)] exists)
       --> crates/cli/src/lib.rs:115:12
        |
    115 |     #[clap(long)]
        |            ^^^^

    error: Unknown `#[clap(short)]` attribute (`#[arg(short)] exists)
       --> crates/cli/src/lib.rs:134:12
        |
    134 |     #[clap(short, long)]
        |            ^^^^^

    error: could not compile `cargo-php` due to 3 previous errors
    warning: build failed, waiting for other jobs to finish...
    Error: Process completed with exit code 101.

These errors were probably caused by the release of `clap` 4.0.0
a few hours ago.
2022-09-28 21:05:56 +02:00
Tobias Bengtsson
04dd0cc990
Merge pull request #157 from striezel-stash/clippy-strikes-again
fix more causes of clippy warnings
2022-09-28 18:21:08 +02:00
Dirk Stolle
ee45e8dc73 fix more causes of clippy warnings
Clippy linting had more errors:

    error: iterating on a map's values
    Error:   --> crates/macros/src/module.rs:56:36
       |
    56 |       let registered_classes_impls = state
       |  ____________________________________^
    57 | |         .classes
    58 | |         .iter()
    59 | |         .map(|(_, class)| generate_registered_class_impl(class))
       | |________________________________________________________________^
       |
       = note: `-D clippy::iter-kv-map` implied by `-D warnings`
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#iter_kv_map
    help: try
       |
    56 ~     let registered_classes_impls = state
    57 +         .classes.values().map(|class| generate_registered_class_impl(class))
       |

    error: iterating on a map's values
    Error:    --> crates/macros/src/module.rs:366:23
        |
    366 |         let classes = self.classes.iter().map(|(_, class)| class.describe());
        |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `self.classes.values().map(|class| class.describe())`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#iter_kv_map

    error: could not compile `ext-php-rs-derive` due to 2 previous errors
2022-09-28 12:34:12 +02:00
Tobias Bengtsson
9c5d172d28
Merge pull request #152 from striezel-stash/make-clippy-happy
fix causes of some clippy warnings
2022-09-28 11:45:03 +02:00
Dirk Stolle
b192841cfa fix causes of some clippy warnings
Clippy linting had some errors:

    error: boolean to int conversion using if
    Error:   --> src/builders/module.rs:59:29
       |
    59 |                 zend_debug: if PHP_DEBUG { 1 } else { 0 },
       |                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with from: `u8::from(PHP_DEBUG)`
       |
       = note: `-D clippy::bool-to-int-with-if` implied by `-D warnings`
       = note: `PHP_DEBUG as u8` or `PHP_DEBUG.into()` can also be valid options
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#bool_to_int_with_if

    error: boolean to int conversion using if
    Error:   --> src/builders/module.rs:60:22
       |
    60 |                 zts: if PHP_ZTS { 1 } else { 0 },
       |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with from: `u8::from(PHP_ZTS)`
       |
       = note: `PHP_ZTS as u8` or `PHP_ZTS.into()` can also be valid options
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#bool_to_int_with_if

    error: could not compile `ext-php-rs` due to 2 previous errors

This commit tries to fix those.
2022-09-13 00:43:11 +02:00
Tobias Bengtsson
8f1cfece32
Merge pull request #150 from striezel-stash/fix-typos
Fix a few typos
2022-09-12 11:39:39 +02:00
Dirk Stolle
4bb0559ab8 Fix a few typos 2022-09-10 16:40:38 +02:00
Tobias Bengtsson
72f39df4fe
Merge pull request #148 from denzyldick/master
Fixed some typos
2022-08-27 21:32:26 +02:00
Tobias Bengtsson
c0a76e714b
Merge pull request #149 from denzyldick/404
404 /guide doesn't exists.
2022-08-27 21:31:21 +02:00
Denzyl Dick
5b001cc717 404 /guide doesn't exists. 2022-08-27 18:05:24 +02:00
Denzyl Dick
1e4044b423 Fixed some typos 2022-08-26 21:43:01 +02:00
Tobias Bengtsson
70f8badd27
Merge pull request #147 from TobiasBengtsson/master
Release 0.8.0
2022-08-14 12:25:51 +02:00
Tobias Bengtsson
fb9d0797cc Release 0.8.0 2022-08-14 11:50:42 +02:00
Tobias Bengtsson
a40483473b
Merge pull request #139 from TobiasBengtsson/master
Support for BinarySlice to avoid allocation
2022-08-13 18:51:29 +02:00
Tobias Bengtsson
976bc7d686 Fix clippy errors 2022-08-13 18:29:15 +02:00
Tobias Bengtsson
231b3005c4 Support for BinarySlice to avoid allocation 2022-07-10 11:24:27 +02:00
Tobias Bengtsson
b230928bed
Merge pull request #144 from ptondereau/chore/update-deps
Bump dependencies.
2022-06-17 10:14:43 +02:00
Pierre Tondereau
f6207e033c Update clap. 2022-06-16 10:25:04 +02:00
Pierre Tondereau
d1cb7cc114 Update dependancies. 2022-06-14 10:45:27 +02:00
Tobias Bengtsson
b1c32c4dc5
Merge pull request #142 from TobiasBengtsson/bindgen-version060
Switch back to using version for bindgen
2022-06-07 15:18:17 +02:00
Tobias Bengtsson
58a5e1bcd3 Switch back to using version for bindgen 2022-06-07 14:43:42 +02:00
Tobias Bengtsson
ccb81f0cd6
Merge pull request #143 from TobiasBengtsson/fix-clippy-useless-transmute
Fix clippy errors in nightly - useless transmute, useless ref-deref in Windows build
2022-06-07 14:42:57 +02:00
Tobias Bengtsson
993b79ed3f Fix clippy error in Windows build 2022-06-07 13:17:55 +02:00
Tobias Bengtsson
a110c1710c Fix clippy error in nightly - useless transmute 2022-06-07 12:22:23 +02:00
Tobias Bengtsson
b93571e377
Merge pull request #141 from TobiasBengtsson/fix-lifetime-clippy-ci
Fix clippy warning, unused lifetime parameter
2022-06-07 09:22:36 +02:00
Tobias Bengtsson
ab85298b37 Fix clippy warning, unused lifetime parameter 2022-05-30 16:14:32 +02:00
David Cole
faa452ecd1
Added tomlrs-php to examples 2022-03-31 01:52:46 +13:00
David Cole
664981f4fb
Windows support (#128)
* Preliminary Windows support

* Start work on cross-platform build script

* Fix compilation on macOS

* Updated README, tidied up build script

* Check linker version before starting compilation

It doesn't seem like it's possible to change the linker from within the
build script, however, we can retrieve the linker in use and give the
user a suggestion if the linker will not work.

* Switch to using Github repository for bindgen

* Split Windows and Unix implementations into two files

* Fix building on Windows

* Remove `reqwest` and `zip` as dependencies on Unix

* Fix guide tests on Windows

* Started work on Windows CI

* runs -> run

* Use preinstalled LLVM on Windows

* Debugging for Windows CI

* Switch to upstream `rust-bindgen` master branch

* Switch to `rust-lld` for Windows linking

* Don't compile `cargo-php` on Windows

* Switch to using skeptic for tests

* cargo-php: Disable stub generation, fix ext install/remove

The plan is to replace the stub generation by generating them with PHP
code. This is cross-platform and means we don't need to worry about ABI.
We also don't need to embed information into the library.

* cargo-php: Fix on unix OS

* Fix clippy lint

* Updated README

* Re-add CI for Unix + PHP 8.0

* Fix building on thread-safe PHP

* Tidy up build scripts

* Use dynamic lookup on Linux, test with TS Windows

* Define `ZTS` when compiling PHP ZTS

* Combine Windows and Unix CI, fix linking for Win32TS

* Fix exclusions in build CI

* rust-toolchain -> rust

* Set LLVM version

* Only build docs.rs on Ubuntu PHP 8.1

* Fix build on Linux thread-safe

* Update guide example
2022-03-18 16:36:51 +13:00
David Cole
7520720558 Release 0.7.4 2022-03-17 23:57:56 +13:00
David Cole
4468656563
Add ability to pass modifier function for classes (#127) 2022-03-08 15:01:16 +13:00