Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Calling FFI::type() statically is deprecated

type(), cast() and new() are instance methods of the object returned by FFI::cdef() or FFI::load(): each loaded C definition scope has its own set of types, so resolving a type name should happen on that specific instance. PHP used to allow calling these methods statically as FFI::type(), in which case they implicitly operated on an anonymous, definition-less scope. Since PHP 8.3, this static shortcut is deprecated, because it is ambiguous about which set of C declarations is being used.

PHP code

<?php

FFI::cdef('typedef struct { int x; int y; } point;');

$type = FFI::type('point');

var_dump($type);

?>

Before

object(FFI\CType)#2 (0) {
}

After

PHP Deprecated:  Calling FFI::type() statically is deprecated in /codes/ffiTypeStaticDeprecated.php on line 5

Deprecated: Calling FFI::type() statically is deprecated in /codes/ffiTypeStaticDeprecated.php on line 5
object(FFI\CType)#2 (0) {
}

PHP version change

This behavior changed in 8.3.

Error Messages

Extension

© 2023-2026, Damien Seguy - Exakat