phactor icon indicating copy to clipboard operation
phactor copied to clipboard

Serialising closures in arrays

Open tpunt opened this issue 8 years ago • 0 comments

Closures cannot be serialised inside of arrays. This is because arrays are simply serialised with PHP's internal serialiser. Closures require special handling with serialisation, and so arrays will need to be serialised differently if this is going to work. The ph_hashtable_t type should be reusable for this, so it should be a matter of mapping PHP's hash table to phactor's hash table.

Example:

<?php

use phactor\{ActorSystem, Actor, ActorRef};

$as = new ActorSystem(1);

class A extends Actor
{
    public function __construct(array $a){}
    public function receive(){}
}


$a = new ActorRef(A::class, [[function(){}]], 'a');

ActorSystem::shutdown();

tpunt avatar Mar 03 '18 13:03 tpunt