Example #1
0
 /**
  * @param string $key
  *
  * @throws ParameterNotFoundException
  *
  * @return mixed
  */
 public function get(string $key)
 {
     if ($this->has($key)) {
         return deep_clone($this->parameters[$key]);
     }
     throw ParameterNotFoundExceptionFactory::create($key);
 }
 /**
  * @depends Nelmio\Alice\FixtureBagTest::testIsImmutable
  */
 public function testIsImmutable()
 {
     $fixture = new MutableFixture('user0', 'Nelmio\\Alice\\Entity\\User', SpecificationBagFactory::create());
     $originalFixture = deep_clone($fixture);
     $bag = (new TemplatingFixtureBag())->with($fixture);
     // Mutate injected value
     $fixture->setSpecs(SpecificationBagFactory::create(new FakeMethodCall()));
     // Mutate retrieved fixture
     $bag->getFixtures()->get('user0')->setSpecs(SpecificationBagFactory::create(new NoMethodCall()));
     $this->assertEquals($originalFixture, $bag->getFixtures()->get('user0'));
 }
Example #3
0
 public function testDeepCloneClosure()
 {
     $foo = new \stdClass();
     $bar = new \stdClass();
     $c1 = function () use($foo) {
         return $foo;
     };
     $foo->name = 'foo';
     $foo->bar = $bar;
     $bar->name = 'bar';
     $bar->foo = $foo;
     $fooClone = deep_clone($c1)();
     $this->assertSame($foo, $fooClone);
     $this->assertSame($bar, $fooClone->bar);
 }
Example #4
0
 /**
  * Creates a new instance of the bag with the given flag. If a flag with the same identifier already exists, the
  * existing value will be replaced.
  *
  * @param FlagInterface $flag
  *
  * @return FlagBag
  */
 public function withFlag(FlagInterface $flag) : self
 {
     $clone = clone $this;
     $clone->flags[$flag->__toString()] = deep_clone($flag);
     return $clone;
 }
Example #5
0
 public function __get(string $name)
 {
     return deep_clone($name);
 }
Example #6
0
 public function getArguments() : array
 {
     return deep_clone($this->arguments);
 }
Example #7
0
 /**
  * @inheritdoc
  */
 public function getInstance()
 {
     return deep_clone($this->instance);
 }
Example #8
0
 /**
  * {@inheritdoc}
  *
  * @return array The first element is the quantifier and the second the element.
  */
 public function getValue() : array
 {
     return deep_clone($this->values);
 }
Example #9
0
 /**
  * @inheritdoc
  */
 public function getValue()
 {
     return deep_clone($this->parameterKey);
 }
Example #10
0
 /**
  * @inheritdoc
  */
 public function getValue()
 {
     return deep_clone($this->value);
 }
Example #11
0
 /**
  * @return string|ValueInterface
  */
 public function getElement()
 {
     return deep_clone($this->element);
 }