# FFI Type Reflection API

- Thread: https://externals.io/message/115336
- Original archive: https://news-web.php.net/php.internals/115336
- Started by Dmitry Stogov on 2021-07-07T08:31:25+00:00
- Messages: 3
- 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

---

## #115336 — Dmitry Stogov — 2021-07-07T08:31:25+00:00

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

Hi,

Last week, at a PHP conference, we discussed some missing parts of ext/ffi
with one of the most extrimal FFI user - Alexandr Lisachenko. One of the
things he is missing is a FFI Type Reflection API. Actually, this is a
simple and self-contained feature, that implementation took me a couple of
hours.

https://github.com/php/php-src/pull/7217

This doesn't touch any existing code in ext/ffi, just add the API that is
better visible through stub:
https://github.com/php/php-src/pull/7217/files#diff-3651c407d02a2a152d9aba6e484f6ae7f4c2c85fa2992274d76c0e18364c7e6fL75-R96

Unfortunately, PHP-8.1 is closed for new RFC, so we can merge this as a
self-contained feature, or wait for the next version. I ask to merge this
into PHP-8.1, but won't do this, in case of any objections.

Thanks. Dmitry.

---

## #115354 — G. P. B. — 2021-07-07T19:38:09+00:00

URL: https://externals.io/message/115336#115354 · In reply to: #115336

> Hi,
>
> Last week, at a PHP conference, we discussed some missing parts of ext/ffi
> with one of the most extrimal FFI user - Alexandr Lisachenko. One of the
> things he is missing is a FFI Type Reflection API. Actually, this is a
> simple and self-contained feature, that implementation took me a couple of
> hours.
>
> https://github.com/php/php-src/pull/7217
>
> This doesn't touch any existing code in ext/ffi, just add the API that is
> better visible through stub:
>
> https://github.com/php/php-src/pull/7217/files#diff-3651c407d02a2a152d9aba6e484f6ae7f4c2c85fa2992274d76c0e18364c7e6fL75-R96
>
> Unfortunately, PHP-8.1 is closed for new RFC, so we can merge this as a
> self-contained feature, or wait for the next version. I ask to merge this
> into PHP-8.1, but won't do this, in case of any objections.
>
> Thanks. Dmitry.
>

Ideally the array/struct/function CTypes would be subclasses,
but if due to time constraints going down this route is impossible,
it is still better to have this information available then not at all.

So +0.5 on principle (seeing that there already is a naming bikeshed I'm
not going to chime in on this aspect).

Best regards,

George P. Banyard

---

## #115362 — Joe Watkins — 2021-07-08T04:20:40+00:00

URL: https://externals.io/message/115336#115362 · In reply to: #115354

Hi Dmitry,

It doesn't make sense to wait another year for this, and since it's self
contained it's fine to merge into 8.1 when ready.

Cheers
Joe



> 
>
> > […]
> ext/ffi
> > […]
> of
> > […]
> 3651c407d02a2a152d9aba6e484f6ae7f4c2c85fa2992274d76c0e18364c7e6fL75-R96
> > […]
>
> Ideally the array/struct/function CTypes would be subclasses,
> but if due to time constraints going down this route is impossible,
> it is still better to have this information available then not at all.
>
> So +0.5 on principle (seeing that there already is a naming bikeshed I'm
> not going to chime in on this aspect).
>
> Best regards,
>
> George P. Banyard
