laravel/serializable-closure

serialization crashes on typed properties

henzeb opened this issue · 1 comments

  • Serializable Closure Version: 1.2.0
  • Laravel Version: 9.17.0
  • PHP Version: 8.1.7
  • Database Driver & Version:

Description:

When a class is using a typed property that accepts closures, the code crashes, as you can't assign Native object where a Closure should be.

Steps To Reproduce:

class test {

    protected Closure $closure;

    public function __construct(Closure $closure)
    {
        $this->closure = $closure;
    }
}

$test = new test(function(){});

serialize(new SerializableClosure(
    function() use ($test){

    }
));

That's expected. The SerializableClosure serializes closures, not classes with closures properties.