Don't use reflections when possible

This commit is contained in:
Ener-Getick 2016-03-05 12:41:21 +01:00
parent d791d78d34
commit a46270a61a
3 changed files with 10 additions and 7 deletions

View File

@ -363,9 +363,8 @@ class Container implements IntrospectableContainerInterface
public function getServiceIds()
{
$ids = array();
$r = new \ReflectionClass($this);
foreach ($r->getMethods() as $method) {
if (preg_match('/^get(.+)Service$/', $method->name, $match)) {
foreach (get_class_methods($this) as $method) {
if (preg_match('/^get(.+)Service$/', $method, $match)) {
$ids[] = self::underscore($match[1]);
}
}

View File

@ -298,6 +298,11 @@ class GetSetDummy
{
throw new \RuntimeException('Dummy::otherMethod() should not be called');
}
protected function getPrivate()
{
throw new \RuntimeException('Dummy::getPrivate() should not be called');
}
}
class GetConstructorDummy

View File

@ -45,12 +45,11 @@ class PropertyMetadata extends MemberMetadata
*/
protected function newReflectionMember($objectOrClassName)
{
$class = new \ReflectionClass($objectOrClassName);
while (!$class->hasProperty($this->getName())) {
$class = $class->getParentClass();
while (!property_exists($objectOrClassName, $this->getName())) {
$objectOrClassName = get_parent_class($objectOrClassName);
}
$member = new \ReflectionProperty($class->getName(), $this->getName());
$member = new \ReflectionProperty($objectOrClassName, $this->getName());
$member->setAccessible(true);
return $member;