/** * Test reflection method. */ public function testReflection() { $this->given($closure = function ($value = null) { return $value; })->when($reflection = Delegate::fromClosure($closure)->reflection())->then()->object($reflection)->isEqualTo(new \ReflectionFunction($closure)); $this->when($reflection = Delegate::fromMethod($this, 'sampleMethod')->reflection())->then()->object($reflection)->isEqualTo(new \ReflectionMethod($this, 'sampleMethod')); $this->given($foo = new FooCallable())->when($reflection = (new Delegate($foo))->reflection())->then()->object($reflection)->isEqualTo(new \ReflectionMethod($foo, '__invoke')); $this->when($reflection = Delegate::fromStaticMethod(self::class, 'sampleStaticMethod')->reflection())->then()->object($reflection)->isEqualTo(new \ReflectionMethod(self::class . '::sampleStaticMethod')); }