mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-19 23:32:17 +02:00
N°8834 - Add compatibility with PHP 8.4 (#819)
* N°8834 - Add compatibility with PHP 8.4 * Rollback of scssphp/scssphp version upgrade due to compilation error
This commit is contained in:
@@ -41,7 +41,7 @@ final class FFICaster
|
||||
$type = \FFI::typeof($data);
|
||||
}
|
||||
|
||||
$stub->class = sprintf('%s<%s> size %d align %d', ($data ?? $type)::class, $type->getName(), $type->getSize(), $type->getAlignment());
|
||||
$stub->class = \sprintf('%s<%s> size %d align %d', ($data ?? $type)::class, $type->getName(), $type->getSize(), $type->getAlignment());
|
||||
|
||||
return match ($type->getKind()) {
|
||||
CType::TYPE_FLOAT,
|
||||
@@ -86,7 +86,7 @@ final class FFICaster
|
||||
CType::ABI_MS => '[ms]',
|
||||
CType::ABI_SYSV => '[sysv]',
|
||||
CType::ABI_VECTORCALL => '[vectorcall]',
|
||||
default => '[unknown abi]'
|
||||
default => '[unknown abi]',
|
||||
};
|
||||
|
||||
$returnType = $type->getFuncReturnType();
|
||||
@@ -97,7 +97,7 @@ final class FFICaster
|
||||
return [Caster::PREFIX_VIRTUAL.'returnType' => $returnType];
|
||||
}
|
||||
|
||||
private static function castFFIPointer(Stub $stub, CType $type, CData $data = null): array
|
||||
private static function castFFIPointer(Stub $stub, CType $type, ?CData $data = null): array
|
||||
{
|
||||
$ptr = $type->getPointerType();
|
||||
|
||||
@@ -115,11 +115,21 @@ final class FFICaster
|
||||
private static function castFFIStringValue(CData $data): string|CutStub
|
||||
{
|
||||
$result = [];
|
||||
$ffi = \FFI::cdef(<<<C
|
||||
size_t zend_get_page_size(void);
|
||||
C);
|
||||
|
||||
for ($i = 0; $i < self::MAX_STRING_LENGTH; ++$i) {
|
||||
$pageSize = $ffi->zend_get_page_size();
|
||||
|
||||
// get cdata address
|
||||
$start = $ffi->cast('uintptr_t', $ffi->cast('char*', $data))->cdata;
|
||||
// accessing memory in the same page as $start is safe
|
||||
$max = min(self::MAX_STRING_LENGTH, ($start | ($pageSize - 1)) - $start);
|
||||
|
||||
for ($i = 0; $i < $max; ++$i) {
|
||||
$result[$i] = $data[$i];
|
||||
|
||||
if ("\0" === $result[$i]) {
|
||||
if ("\0" === $data[$i]) {
|
||||
return implode('', $result);
|
||||
}
|
||||
}
|
||||
@@ -132,7 +142,7 @@ final class FFICaster
|
||||
return $stub;
|
||||
}
|
||||
|
||||
private static function castFFIStructLike(CType $type, CData $data = null): array
|
||||
private static function castFFIStructLike(CType $type, ?CData $data = null): array
|
||||
{
|
||||
$isUnion = ($type->getAttributes() & CType::ATTR_UNION) === CType::ATTR_UNION;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user