Don't use reflections when possible
This commit is contained in:
parent
d791d78d34
commit
a46270a61a
@ -363,9 +363,8 @@ class Container implements IntrospectableContainerInterface
|
|||||||
public function getServiceIds()
|
public function getServiceIds()
|
||||||
{
|
{
|
||||||
$ids = array();
|
$ids = array();
|
||||||
$r = new \ReflectionClass($this);
|
foreach (get_class_methods($this) as $method) {
|
||||||
foreach ($r->getMethods() as $method) {
|
if (preg_match('/^get(.+)Service$/', $method, $match)) {
|
||||||
if (preg_match('/^get(.+)Service$/', $method->name, $match)) {
|
|
||||||
$ids[] = self::underscore($match[1]);
|
$ids[] = self::underscore($match[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -298,6 +298,11 @@ class GetSetDummy
|
|||||||
{
|
{
|
||||||
throw new \RuntimeException('Dummy::otherMethod() should not be called');
|
throw new \RuntimeException('Dummy::otherMethod() should not be called');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getPrivate()
|
||||||
|
{
|
||||||
|
throw new \RuntimeException('Dummy::getPrivate() should not be called');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class GetConstructorDummy
|
class GetConstructorDummy
|
||||||
|
@ -45,12 +45,11 @@ class PropertyMetadata extends MemberMetadata
|
|||||||
*/
|
*/
|
||||||
protected function newReflectionMember($objectOrClassName)
|
protected function newReflectionMember($objectOrClassName)
|
||||||
{
|
{
|
||||||
$class = new \ReflectionClass($objectOrClassName);
|
while (!property_exists($objectOrClassName, $this->getName())) {
|
||||||
while (!$class->hasProperty($this->getName())) {
|
$objectOrClassName = get_parent_class($objectOrClassName);
|
||||||
$class = $class->getParentClass();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$member = new \ReflectionProperty($class->getName(), $this->getName());
|
$member = new \ReflectionProperty($objectOrClassName, $this->getName());
|
||||||
$member->setAccessible(true);
|
$member->setAccessible(true);
|
||||||
|
|
||||||
return $member;
|
return $member;
|
||||||
|
Reference in New Issue
Block a user