function it_can_be_protected(ReflectionMethod $reflectionMethod) { $reflectionMethod->isProtected()->willReturn(false); $this->isProtected()->shouldBe(false); $reflectionMethod->isProtected()->willReturn(true); $this->isProtected()->shouldBe(true); }
private function assertSameMethodAttributes(\ReflectionMethod $original, ReflectionMethod $stubbed) { $this->assertSame(array_map(function (\ReflectionParameter $parameter) { return $parameter->getDeclaringFunction()->getName() . '.' . $parameter->getName(); }, $original->getParameters()), array_map(function (ReflectionParameter $parameter) { return $parameter->getDeclaringFunction()->getName() . '.' . $parameter->getName(); }, $stubbed->getParameters())); foreach ($original->getParameters() as $parameter) { $this->assertSameParameterAttributes($parameter, $stubbed->getParameter($parameter->getName())); } $this->assertSame($original->isPublic(), $stubbed->isPublic()); $this->assertSame($original->isPrivate(), $stubbed->isPrivate()); $this->assertSame($original->isProtected(), $stubbed->isProtected()); $this->assertSame($original->returnsReference(), $stubbed->returnsReference()); $this->assertSame($original->isStatic(), $stubbed->isStatic()); $this->assertSame($original->isFinal(), $stubbed->isFinal()); }
/** * {@inheritDoc} */ public function isProtected() { return $this->betterReflectionMethod->isProtected(); }
/** * isMethodVisible returns true if the given method matches the visibility specified by `api.visibility`. * * @param \BetterReflection\Reflection\ReflectionMethod $method * * @return bool */ public function isMethodVisible(ReflectionMethod $method) { return $method->isPublic() && isset($this->visibilityMap['public']) || $method->isProtected() && isset($this->visibilityMap['protected']) || $method->isPrivate() && isset($this->visibilityMap['private']); }
/** * * * @param ReflectionMethod $reflection * @return Method */ public static function fromReflection(ReflectionMethod $reflection) { // gestion du type // $type = implode('|', $reflection->getDocBlockTypeStrings()); // // construction $method = new static($reflection->getName(), [], $reflection->getBodyCode()); // docblock $docblock = new \phpDocumentor\Reflection\DocBlock($reflection->getDocComment()); $method->setSummary($docblock->getShortDescription()); $method->setDescription($docblock->getLongDescription()); // gestion des modifiers $reflection->isPrivate() ? $method->enablePrivate() : $method->disablePrivate(); $reflection->isProtected() ? $method->enableProtected() : $method->disabledProtected(); $reflection->isPublic() ? $method->enablePublic() : $method->disablePublic(); $reflection->isStatic() ? $method->enableStatic() : $method->disableStatic(); $reflection->isFinal() ? $method->enableFinal() : $method->disableFinal(); foreach ($reflection->getParameters() as $parameter) { $method->addParameter(Parameter::fromReflection($parameter)); } return $method; }
public function isProtected() : bool { return $this->reflection->isProtected(); }