# FFI::new(), FFI::type(), FFI::cast() statically RFC is stupid implementation

- Thread: https://externals.io/message/123690
- Original archive: https://news-web.php.net/php.internals/123690
- Started by chopins xiao on 2024-06-20T03:01:58+00:00
- Messages: 1
- RFC: Remove functions with overloaded signatures (Accepted) — https://externals.io/rfc/deprecate_functions_with_overloaded_signatures.md
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #123690 — chopins xiao — 2024-06-20T03:01:58+00:00

URL: https://externals.io/message/123690#123690

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.
