Skip to content

Instantly share code, notes, and snippets.

@doctrinebot
Created December 13, 2015 18:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save doctrinebot/dc6614ca813b2c141e6b to your computer and use it in GitHub Desktop.
Save doctrinebot/dc6614ca813b2c141e6b to your computer and use it in GitHub Desktop.
Attachments to Doctrine Jira Issue DDC-248 - https://github.com/doctrine/doctrine2/issues/3198
--- doctrine/lib/Doctrine/ORM/Mapping/ClassMetadata.php (r7029) Fri Jan 15 12:26:13 2010
+++ doctrine/lib/Doctrine/ORM/Mapping/ClassMetadata.php (working copy) Fri Jan 15 12:13:29 2010
@@ -359,16 +359,42 @@
// Restore ReflectionClass and properties
$this->reflClass = new \ReflectionClass($this->name);
foreach ($this->fieldNames as $field) {
- $this->reflFields[$field] = $this->reflClass->getProperty($field);
+ $this->reflFields[$field] = $this->_getReflectionProperty($this->reflClass, $field);
$this->reflFields[$field]->setAccessible(true);
}
foreach ($this->associationMappings as $field => $mapping) {
- $this->reflFields[$field] = $this->reflClass->getProperty($field);
+ $this->reflFields[$field] = $this->_getReflectionProperty($this->reflClass, $field);
$this->reflFields[$field]->setAccessible(true);
}
//$this->prototype = unserialize(sprintf('O:%d:"%s":0:{}', strlen($this->name), $this->name));
}
+ /**
+ * Gets a reflection property for a class.
+ * @param \ReflectionClass $refClass
+ * @param string $field
+ * @return \ReflectionProperty
+ */
+ private function _getReflectionProperty(\ReflectionClass $refClass, $field)
+ {
+ if(!$refClass->hasProperty($field))
+ {
+ return NULL;
+ }
+ foreach($refClass->getProperties() as $p)
+ {
+ if($p->getName() == $field)
+ {
+ return $p;
+ }
+ }
+ if($parent = $refClass->getParentClass())
+ {
+ return $this->_getReflectionProperty($parent, $field);
+ }
+ return NULL;
+ }
+
//public $prototype;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment