예제 #1
0
파일: Executor.php 프로젝트: sayiho/Jumper
 /**
  * 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;
     }
 }
예제 #2
0
 /**
  * @test
  */
 public function objectUnserializationShouldExpected()
 {
     $this->assertEquals(new stdClass(), $this->stringifier->toObject('O:8:"stdClass":0:{}'));
 }
예제 #3
0
 /**
  * @test
  */
 public function assocArrayUnserializationShouldExpected()
 {
     $this->assertEquals(array('a' => 'string'), $this->stringifier->toObject("array (\n  'a' => 'string',\n)"));
 }
예제 #4
0
파일: JsonTest.php 프로젝트: sayiho/Jumper
 /**
  * @test
  */
 public function assocArrayUnserializationShouldExpected()
 {
     $this->assertEquals(array('a' => 'string'), $this->stringifier->toObject('{"a":"string"}'));
 }