mirror of
https://github.com/php/php-src.git
synced 2024-11-27 11:53:33 +08:00
bd9f4fa676
For rationale, see https://github.com/php/php-src/pull/6787 Make extension checks lowercase, add a special case for opcache that has internal name not matching .so filename. Extensions migrated in part 2: * dom * exif * fileinfo * ffi
72 lines
1.6 KiB
PHP
72 lines
1.6 KiB
PHP
--TEST--
|
|
FFI 020: read-only
|
|
--EXTENSIONS--
|
|
ffi
|
|
--INI--
|
|
ffi.enable=1
|
|
--FILE--
|
|
<?php
|
|
try {
|
|
$p = FFI::new("struct {int x; const int y;}");
|
|
$p->x = 1;
|
|
$p->y = 1;
|
|
echo "ok\n";
|
|
} catch (Throwable $e) {
|
|
echo get_class($e) . ": " . $e->getMessage()."\n";
|
|
}
|
|
try {
|
|
$p = FFI::new("struct {const int x; int y;}");
|
|
$p->y = 1;
|
|
$p->x = 1;
|
|
echo "ok\n";
|
|
} catch (Throwable $e) {
|
|
echo get_class($e) . ": " . $e->getMessage()."\n";
|
|
}
|
|
try {
|
|
$p = FFI::new("const struct {int x; int y;}");
|
|
$p->x = 1;
|
|
echo "ok\n";
|
|
} catch (Throwable $e) {
|
|
echo get_class($e) . ": " . $e->getMessage()."\n";
|
|
}
|
|
try {
|
|
$p = FFI::new("const int[10]");
|
|
$p[1] = 1;
|
|
echo "ok\n";
|
|
} catch (Throwable $e) {
|
|
echo get_class($e) . ": " . $e->getMessage()."\n";
|
|
}
|
|
try {
|
|
$p = FFI::new("const int * [1]");
|
|
$p[0] = null;
|
|
echo "ok\n";
|
|
} catch (Throwable $e) {
|
|
echo get_class($e) . ": " . $e->getMessage()."\n";
|
|
}
|
|
try {
|
|
$p = FFI::new("int * const [1]");
|
|
$p[0] = null;
|
|
echo "ok\n";
|
|
} catch (Throwable $e) {
|
|
echo get_class($e) . ": " . $e->getMessage()."\n";
|
|
}
|
|
try {
|
|
$f = FFI::cdef("typedef int * const t[1];");
|
|
$p = $f->new("t");
|
|
$p[0] = null;
|
|
echo "ok\n";
|
|
} catch (Throwable $e) {
|
|
echo get_class($e) . ": " . $e->getMessage()."\n";
|
|
}
|
|
?>
|
|
ok
|
|
--EXPECT--
|
|
FFI\Exception: Attempt to assign read-only field 'y'
|
|
FFI\Exception: Attempt to assign read-only field 'x'
|
|
FFI\Exception: Attempt to assign read-only location
|
|
FFI\Exception: Attempt to assign read-only location
|
|
ok
|
|
FFI\Exception: Attempt to assign read-only location
|
|
FFI\Exception: Attempt to assign read-only location
|
|
ok
|