Skip to content

Commit 1560d66

Browse files
committed
Provide an ability to allocate zend_object in persistent memory, will be usable to survive request boundary
1 parent fdc0539 commit 1560d66

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/Reflection/ReflectionClass.php

+4-6
Original file line numberDiff line numberDiff line change
@@ -852,15 +852,16 @@ public function setInterfaceGetsImplementedHandler(Closure $handler): void
852852
* This method is useful within create_object handler
853853
*
854854
* @param CData $classType zend_class_entry type to create
855+
* @param bool $persistent Whether object should be allocated persistent or not. Low-level feature!
855856
*
856857
* @return CData Instance of zend_object *
857858
* @see zend_objects.c:zend_objects_new
858859
*/
859-
public static function newInstanceRaw(CData $classType): CData
860+
public static function newInstanceRaw(CData $classType, bool $persistent = false): CData
860861
{
861862
$objectSize = Core::sizeof(Core::type('zend_object'));
862863
$totalSize = $objectSize + self::getObjectPropertiesSize($classType);
863-
$memory = Core::new("char[{$totalSize}]", false);
864+
$memory = Core::new("char[{$totalSize}]", false, $persistent);
864865
$object = Core::cast('zend_object *', $memory);
865866

866867
Core::call('zend_object_std_init', $object, $classType);
@@ -939,10 +940,7 @@ private static function getObjectHandlers(CData $classType): CData
939940
{
940941
$className = (StringEntry::fromCData($classType->name)->getStringValue());
941942
if (!isset(self::$objectHandlers[$className])) {
942-
throw new \RuntimeException(
943-
'Object handlers for class ' . $className . ' are not configured.' . PHP_EOL .
944-
'Have you installed the create_object handler first?'
945-
);
943+
self::allocateClassObjectHandlers($className);
946944
}
947945

948946
return self::$objectHandlers[$className];

0 commit comments

Comments
 (0)