Ejemplo n.º 1
0
 /**
  * Run closure remotely or locally
  *
  * @param $closure
  *
  * @throws \Exception
  *
  * @return mixed
  */
 public function run(\Closure $closure)
 {
     try {
         $closure = new SerializableClosure($closure);
         if (!$this->communicator->isConnected()) {
             $this->communicator->connect();
         }
         $serialize = base64_encode(serialize($closure));
         $output = $this->communicator->run(sprintf('php -r \'%s $c=unserialize(base64_decode("%s")); echo %s($c());\'', $this->getClosureUnserializerAsString(), $serialize, $this->stringifier->getSerializeFunctionName()));
         return $this->stringifier->toObject($output);
     } catch (\RuntimeException $e) {
         throw new ExecutorException('An error occurs when execution php on target host with the following message: ' . $e->getMessage());
     } catch (\Exception $e) {
         // todo Manage exception
         throw $e;
     }
 }
Ejemplo n.º 2
0
 /**
  * @test
  */
 public function objectUnserializationShouldExpected()
 {
     $this->assertEquals(new stdClass(), $this->stringifier->toObject('O:8:"stdClass":0:{}'));
 }
Ejemplo n.º 3
0
 /**
  * @test
  * @expectedException \Jumper\Exception\StringifierException
  * @expectedExceptionMessage VarExportEval has a limited support. Object serialization is not possible. Consider using \Jumper\Stringifier\Native stringifier.
  */
 public function objectSerializationShouldExpected()
 {
     $this->assertEquals("stdClass::__set_state(array(\n))", $this->stringifier->toString(new stdClass()));
 }
Ejemplo n.º 4
0
 /**
  * @test
  * @expectedException \Jumper\Exception\StringifierException
  * @expectedExceptionMessage Json has a limited support. Object serialization is not possible. Consider using \Jumper\Stringifier\Native stringifier.
  */
 public function objectSerializationShouldThrowStringifierException()
 {
     $this->stringifier->toString(new stdClass());
 }