Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix #222.

  • Loading branch information...
commit 2beb84e68375c14cd36f0ed6adc9f6257692d7b2 1 parent 338e4aa
@sebastianbergmann sebastianbergmann authored
Showing with 19 additions and 21 deletions.
  1. +19 −21 PHPUnit/Util/Class.php
View
40 PHPUnit/Util/Class.php
@@ -299,10 +299,6 @@ public static function getObjectAttribute($object, $attributeName)
throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'string');
}
- PHPUnit_Framework_Assert::assertObjectHasAttribute(
- $attributeName, $object
- );
-
try {
$attribute = new ReflectionProperty($object, $attributeName);
}
@@ -321,27 +317,29 @@ public static function getObjectAttribute($object, $attributeName)
}
}
- if ($attribute == NULL || $attribute->isPublic()) {
- return $object->$attributeName;
- } else {
- $array = (array)$object;
- $protectedName = "\0*\0" . $attributeName;
-
- if (array_key_exists($protectedName, $array)) {
- return $array[$protectedName];
+ if (isset($attribute)) {
+ if ($attribute == NULL || $attribute->isPublic()) {
+ return $object->$attributeName;
} else {
- $classes = self::getHierarchy(get_class($object));
+ $array = (array)$object;
+ $protectedName = "\0*\0" . $attributeName;
+
+ if (array_key_exists($protectedName, $array)) {
+ return $array[$protectedName];
+ } else {
+ $classes = self::getHierarchy(get_class($object));
- foreach ($classes as $class) {
- $privateName = sprintf(
- "\0%s\0%s",
+ foreach ($classes as $class) {
+ $privateName = sprintf(
+ "\0%s\0%s",
- $class,
- $attributeName
- );
+ $class,
+ $attributeName
+ );
- if (array_key_exists($privateName, $array)) {
- return $array[$privateName];
+ if (array_key_exists($privateName, $array)) {
+ return $array[$privateName];
+ }
}
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.