function testExactValue() { $this->assert(Argument::exact('foo')->accepts(new ExactArgument('foo'))); $this->assert(Argument::exact(new \DateTime('2011-12-13'))->accepts(new ExactArgument(new \DateTime('2011-12-13')))); $this->assert->not(Argument::exact('foo')->accepts(new ExactArgument('bar'))); $this->assert->not(Argument::exact('foo')->accepts(new IntegerArgument())); }
/** * @param $method * @param $arguments * @return array|Argument[] */ private function normalize($method, $arguments) { $normalized = []; $reflection = new \ReflectionMethod($this->class, $method); foreach ($reflection->getParameters() as $i => $parameter) { if (array_key_exists($i, $arguments)) { $argument = $arguments[$i]; if ($argument instanceof Argument) { $normalized[] = $argument; } else { $normalized[] = Argument::exact($argument); } } else { if ($parameter->isDefaultValueAvailable()) { $normalized[] = Argument::exact($parameter->getDefaultValue()); } } } return $normalized; }