예제 #1
0
파일: ArrayDirect.php 프로젝트: uaiti/alice
 /**
  * {@inheritDoc}
  */
 public function set(Fixture $fixture, $object, $property, $value)
 {
     foreach ($value as $index => $param) {
         $value[$index] = $this->typeHintChecker->check($object, $property, $param, $index);
     }
     call_user_func_array(array($object, $property), $value);
 }
예제 #2
0
파일: ArrayAdd.php 프로젝트: devster/alice
 /**
  * {@inheritDoc}
  */
 public function set(Fixture $fixture, $object, $property, $value)
 {
     $method = $this->findAdderMethod($object, $property);
     foreach ($value as $val) {
         $val = $this->typeHintChecker->check($object, $method, $val);
         $object->{$method}($val);
     }
 }
예제 #3
0
파일: Direct.php 프로젝트: uaiti/alice
 /**
  * {@inheritDoc}
  */
 public function set(Fixture $fixture, $object, $property, $value)
 {
     $setter = $this->setterFor($property);
     $value = $this->typeHintChecker->check($object, $setter, $value);
     if (!is_callable(array($object, $setter))) {
         $refl = new \ReflectionMethod($object, $setter);
         $refl->setAccessible(true);
         $refl->invoke($object, $value);
     } else {
         $object->{$setter}($value);
     }
 }
예제 #4
0
 /**
  * {@inheritDoc}
  */
 public function instantiate(Fixture $fixture)
 {
     $class = $fixture->getClass();
     $constructorMethod = $fixture->getConstructorMethod();
     $constructorArgs = $fixture->getConstructorArgs();
     $reflClass = new \ReflectionClass($class);
     $constructorArgs = $this->processor->process($constructorArgs, array(), $fixture->getValueForCurrent());
     foreach ($constructorArgs as $index => $value) {
         $constructorArgs[$index] = $this->typeHintChecker->check($class, $constructorMethod, $value, $index);
     }
     if ($constructorMethod === '__construct') {
         $instance = $reflClass->newInstanceArgs($constructorArgs);
     } else {
         $instance = forward_static_call_array(array($class, $constructorMethod), $constructorArgs);
         if (!$instance instanceof $class) {
             throw new \UnexpectedValueException("The static constructor '{$constructorMethod}' for object '{$fixture}' returned an object that is not an instance of '{$class}'");
         }
     }
     return $instance;
 }
예제 #5
0
파일: Loader.php 프로젝트: uaiti/alice
 /**
  * public interface to set the ORM interface
  *
  * @param ORMInterface $manager
  */
 public function setORM(ORMInterface $manager)
 {
     $this->manager = $manager;
     $this->typeHintChecker->setORM($manager);
 }
예제 #6
0
파일: Loader.php 프로젝트: mablae/alice
 /**
  * public interface to set the Persister interface
  *
  * @param PersisterInterface $manager
  */
 public function setPersister(PersisterInterface $manager)
 {
     $this->manager = $manager;
     $this->typeHintChecker->setPersister($manager);
 }