This wasn't the case because of `PhantomData<T>` inside the metadata.
Replacing this with `PhantomData<AtomicPtr<T>>` ensures that the
metadata will always be `Send + Sync`.
* Bump PHP API version, remove flags removed from PHP API
See following commits:
- 70195c3561
- b5746a4c7f
* Add PHP 8.1 to CI
* Clippy lint
* Fix PHP 8.1 support with new features
* Change describe types to C ABI, check ext-php-rs version
Rust doesn't have a stable ABI so the describe function and types are
now C ABI compatible, however, the internal types `Cow`, `Vec`, `Option`
aren't.
Check `ext-php-rs` versions to check compatibility between the CLI and
the extension.
* CLI requires 0.7.1
* Bump versions
* Replace standard library types with ABI-stable replacements
* Change option type
* started work on stub generator
* Worked on stub CLI tool
* Unused import
* Account for namespaces in function and class names
* Add support for docblocks on structs
* Push Rust comments to stubs
* Add indentation to stub generation
* Add CLI application to install and generate stubs
This time CLI application is defined on user side, called with `cargo
run -- ..args..`
* Export anyhow result
* Add constants to stub file
* Removed stub symbols
No longer required as we are now building while also linking to PHP.
Keeping the stubs causes the stubs to override the real symbols in the
extension.
* Fix stubs for real this time
Removed stub symbols as they were being included in the extension
dylib, fix by loading the PHP executable as a dylib, loading the
required symbols globally.
* Maybe actually fix stubs this time
* Forgot to remove PHP binary loading
* let's give this another go... cargo subcommand
Now called via `cargo php <install,stubs>`.
* Added `remove` command
* Tidied up cargo-php, commented, set up CI
* Fix return types with non-ident types
* define namespace ordering
* Fix tests, replace `Self` when in outer context
* Moved allowed bindings into separate file
* Update guide with CLI instructions
* Disable serialization and unserialization on classes
Classes that have associated Rust types cannot be serialized for
obvious reasons so these need to be disabled. Disabling these actions
changes in PHP 8.1 to use a flag, so that will need to be solved with
PHP 8.1 support. Closes#97
* update docs stubs
* Fixed `ArgParser` lifetimes
Now stores a mutable reference to the underlying zval. Instead of
passing the execution data to the arg parser, a vector of args is now
passed to prevent a shared lifetime issue with the `$this` object.
* Implememt from traits for classes
* Added `ZBox` and `ZBoxable`
* Implement `ZBoxable` for `ZendStr`
Build for all f eatures on CI
* Replace `OwnedZendObject` with `ZBox<ZendObject>`
* Replace `ClassObject` with `ZBox<ZendClassObject>`
Fixed deserialization bug
Panic when uninitialized - better than UB
* Replace `OwnedHashTable` with `ZBox<HashTable>`
* Remove `MaybeUninit` from `ZendClassObject`
* Remove lifetime from `PhpException`
All class entries are effectively static (module start to module end) so
it's just a hassle carrying the lifetime everywhere.
* Removed forgotten lifetimes
* Implement `IntoZval` for `Result<T, E>`
Fixes function return error with `PhpResult` as the return type
* Updated changelog
* Rough implementation of struct properties
* Store properties hashtable once
* Tidy up handler functions with exceptions
* Add stub `get_properties` function for codegen structs
* Remove nightly features
* Revert storing properties
Technically, the zend object _could_ move in memory, leaving dangling
references in the properties hashtable. We will just build the hashtable
when required.
* Added `#[prop]` attribute
* Add pointer type to zval, tidy up zend string
* Add support for method properties
* Add `#[getter]` and `#[setter]` attributes
* Update documentation with method properties
* Tidy up macros code
* Remove string gc checks (done on PHP side)
* Move `RegisteredClass` implementation to module, update docs
* Fix read property `rv` segfault
* Fixed doctests
* Call zval destructor when changing zval type and dropping
* Remove `ZendHashTable` wrapper
Replaced by returning references to the actual hashtable, and having a
new type `OwnedHashTable` when creating a new hashtable.
* Refactor `ZendString` into a borrowed and owned variant
`&ZendStr` is now equivalent to `&str`, while `ZendString` is equivalent
to `String`.
* Tidy up `ZendString`, add `Debug` implementation
* Call zval destructor when changing zval type and dropping
* Remove zval return from array insert functions #73
The functions actually returned references to the new zval value, so
there's not much point in returning.
* Remove `ZendHashTable` wrapper
Replaced by returning references to the actual hashtable, and having a
new type `OwnedHashTable` when creating a new hashtable.
* Remove pointless `drop` field from `OwnedHashTable`
* Added `Values` iterator for Zend hashtable
* Change iterators to double ended and exact size
* Change the case of method identifiers to comply with PSR-1
* Expose methods as camelCase and add attributes for controlling renaming
Add an attribute to methods to control the name they're exported under
and an attribute to php_impl to override automatic case conversion
conventions.
* Cargo fmt
* Add option for no method renaming
Default to camel case renaming
Co-authored-by: David Cole <david.cole1340@gmail.com>
* Allowlist types generated by bindgen
Tidied up build script as well, layout tests are no longer generated
unless `EXT_PHP_RS_TEST` env variable is set. Much quicker build times
and smaller output size.
* Fix build
* Override Rust toolchain when running CI
* Start work on returning new objects
Change `IntoZval` to consume `self`
* Add conversion from vector reference to PHP hashtable through clones
* `set_binary` now only takes `Vec`
Used to take `AsRef<[T]>` to allow users to pass arrays, however, this
causes the data to be cloned even if the user passes a `Vec`.
* Rename `as_zval` to `into_zval` to match Rust conventions
* Started work on closures
* Finish implementation of closures
* Document closures, add to prelude, feature gate
* Fixed closure example
The object memory is automatically deallocated, however, anything that
has been allocated on the heap (strings, vectors etc.) must be
deallocated while we are freeing the object.