Haven't been paying attention for a while and found that FFI::new(), 
FFI::type(), FFI::cast()statically are marked as deprecated, which is a bad 
implementation.
Suggesting in 
RFC:https://wiki.php.net/rfc/deprecate_functions_with_overloaded_signatures#fficast_ffinew_and_ffitype
 that you should replace static calls with instances is a stupid suggestion. 
This RFC was implemented on July 18, 2023 in 
https://github.com/php/php-src/commit/4acf0084dcd63ec369a610ec966db33f322694c8. 
On this issue, I submitted a proposal on May 14, 2022 
https://github.com/php/php-src/issues/8554 here.

Here's why it's not advisable to remove static:

  1.  The non-static call through the FFI instance is the C function, and the 
new(), type(), cast() are PHP class methods, which is a very strange API 
implementation, and these three function names occupy the C function that may 
exist. Also, the function zend_ffi_get_func implementation in ffi.c is not so 
good on its own.
  2.  When you need to get non-PHP type data, you can get it directly through 
static new without getting an FFI object instance first. This is useful when 
using only C primitive data types, without thinking about performance, and 
without calling C libraries.
  3.  PHP programmers aren't all fools, PHP programmers who can use the FFI 
interface must have the relevant skills.

Reply via email to