Nelmio\Alice\Definition\MethodCall\SimpleMethodCall::withArguments PHP Method

withArguments() public method

public withArguments ( array $arguments = null ) : self
$arguments array
return self
    public function withArguments(array $arguments = null) : self
    {
        $clone = clone $this;
        $clone->arguments = $arguments;
        return $clone;
    }

Usage Example

Beispiel #1
0
 public function testCanCreateANewInstanceWithArguments()
 {
     $method = 'setUsername';
     $arguments = null;
     $definition = new SimpleMethodCall($method, $arguments);
     $newArguments = [$arg0 = new \stdClass()];
     $newDefinition = $definition->withArguments($newArguments);
     // Mutate before reading values
     $arg0->foo = 'bar';
     $this->assertInstanceOf(SimpleMethodCall::class, $newDefinition);
     $this->assertNull($definition->getCaller());
     $this->assertEquals($method, $definition->getMethod());
     $this->assertEquals($arguments, $definition->getArguments());
     $this->assertEquals($method, $definition->__toString());
     $this->assertNull($newDefinition->getCaller());
     $this->assertEquals($method, $newDefinition->getMethod());
     $this->assertEquals([StdClassFactory::create(['foo' => 'bar'])], $newDefinition->getArguments());
     $this->assertEquals($method, $newDefinition->__toString());
 }