/** * Attaches a method to the entity * * Keep in mind, I'm trusting you to have checked to be sure the method doesn't * already exist. Otherwise, I will overwrite an existing transient method and * mayhem could ensue! * * @param Jstewmc\Refraction\RefractionMethod $method the method * @return self * @since 0.1.0 */ protected final function attachMethod(RefractionMethod $method) { $this->transientMethods[$method->getName()] = $method; return $this; }
/** * Returns true if the method is visible to the object * * A method is visible to a calling class if the method is public (and visible * to any calling class) or the calling class is this class (and the method is * protected or private). * * @param Jstewmc\Refraction\RefractionMethod $method the method * @param object $object the calling class * @return bool * @since 0.1.0 */ protected final function isMethodVisible($method, $object) { return $method->isPublic() || $object === $this; }
/** * getClosure() should return callable */ public function test_getClosure_returnsCallable() { $method = new RefractionMethod(new Child(), Child::METHOD_PUBLIC); return $this->assertTrue(is_callable($method->getClosure())); }