Commit Graph

276 Commits

Author SHA1 Message Date
David Cole
8d2ad7d418
fix binary slice lifetimes (#181) 2022-11-19 08:58:18 +01:00
ju1ius
4ea01f8d98
fixes inifinte loop in ClassEntry::instance_of (#188) 2022-11-16 07:25:42 +01:00
David Cole
3b1e2e3848
check docs warnings in CI (#180)
* check docs warnings in CI

* works

* format
2022-11-13 21:13:25 +13:00
David Cole
a160f2a2a0 Bump version to v0.8.2 2022-11-11 12:11:33 +13:00
David Cole
eafd3b4471
fix type links in docs.rs (#179)
[ci skip]
2022-11-11 12:08:23 +13:00
Pierre Tondereau
b72d0555d6
chore(cli): Bump Clap for CLI tool (#177) 2022-11-10 10:59:49 +01:00
David Cole
4133a0fe78
add ability to define abstract methods (#171)
* add ability to define abstract methods

`new_abstract` can be used for interface and abstract class methods.

* rustfmt
2022-11-10 13:51:20 +13:00
David Cole
5f33598fcf
add before flag to #[php_startup] (#170)
* add `before` flag to `#[php_startup]`

this calls the user-provided startup function _before_ the classes and
constants registered by the macro system are registered with PHP. by
default the behaviour is to run this function after, which means you
cannot define an interface and use it on a struct.

* cargo fmt
2022-11-10 13:51:05 +13:00
Niklas Mollenhauer
997fded715
Add example that shows how to implement an interface (#167)
* Add example that shows how to implement an interface

* Add missing uses

* Fix some compilation issues
2022-10-23 13:09:56 +13:00
David Cole
76358ede3c rustfmt... 2022-10-23 12:06:22 +13:00
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