-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Introduce FFI::Scope class #16327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Introduce FFI::Scope class #16327
Conversation
@dstogov This is the RFC that made the static methods deprecated: https://wiki.php.net/rfc/deprecate_functions_with_overloaded_signatures#fficast_ffinew_and_ffitype this happened in 8.3. It was part of a larger RFC. |
@nielsdos Thanks for pointing to the RFC. The implementation should be good enough, but this PR requires RFC and I don't like to post it now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think, this path forward makes sense.
@@ -71,6 +71,19 @@ public static function isNull(FFI\CData $ptr): bool {} | |||
|
|||
namespace FFI { | |||
|
|||
/** @not-serializable */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Often, @strict-properties
is added to final non-serializable classes alike these. But no strong preference.
I understand that the goal is to address https://wiki.php.net/rfc/deprecate_functions_with_overloaded_signatures#fficast_ffinew_and_ffitype in an alternative way? This makes sense, and there are almost no BC breaks, except in at least these two cases:
One issue that is not solved is that the methods |
Yes. This is an API re-factoring to avoid static/non-static mess.
There is no sense in static methods, because they can't reach symbols loaded into the instance of the
These non-static methods are necessary (now static methods are deprecated). |
This is a refactoring of user level ext/FFI API. The most important changes are in ``ffi.stub.php``. Now FFI::cdef, FFI::load and FFI::scope return an instance of new FFI\Scope class instead of FFI. There us no way to instantiate an object of class FFI. Methods FFI::new, FFI:cast, FFI::type may be called only statically. The deprecation introduced by https://wiki.php.net/rfc/ffi-non-static-deprecated is removed. FFI\Scope::new, FFI\Scope::cast, FFI\Scope::type can't be called as static methods. Most tests are not affcted by this change, but of course this may break some user code.
This is a refactoring of user level ext/FFI API.
The most important changes are in
ffi.stub.php
.Now FFI::cdef, FFI::load and FFI::scope return an instance of new FFI\Scope class instead of FFI.
There is no way to instantiate an object of class FFI. Methods FFI::new, FFI:cast, FFI::type may be called only statically. The deprecation introduced by 4acf008 is removed. (I can't find the RFC corresponding to this deprecation).
FFI\Scope::new, FFI\Scope::cast, FFI\Scope::type can't be called as static methods.
Most tests are not affected by this change, but of course this patch may break some user code.