Skip to content

FFI::new(), FFI::type(), FFI::cast() are marked as deprecated is a bad implementation #14608

@chopins

Description

@chopins

Description

Haven't been paying attention for a while and found that FFI::new(), FFI::type(), FFI::cast() 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 4acf008. On this issue, I submitted a proposal on May 14, 2022 #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.

PHP Version

master

Operating System

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions