diff vendor/doctrine/common/lib/Doctrine/Common/Persistence/PersistentObject.php @ 12:7a779792577d

Update Drupal core to v8.4.5 (via Composer)
author Chris Cannam
date Fri, 23 Feb 2018 15:52:07 +0000
parents 4c8ae668cc8c
children
line wrap: on
line diff
--- a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/PersistentObject.php	Fri Feb 23 15:51:18 2018 +0000
+++ b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/PersistentObject.php	Fri Feb 23 15:52:07 2018 +0000
@@ -119,8 +119,6 @@
      */
     private function set($field, $args)
     {
-        $this->initializeDoctrine();
-
         if ($this->cm->hasField($field) && !$this->cm->isIdentifier($field)) {
             $this->$field = $args[0];
         } else if ($this->cm->hasAssociation($field) && $this->cm->isSingleValuedAssociation($field)) {
@@ -146,13 +144,11 @@
      */
     private function get($field)
     {
-        $this->initializeDoctrine();
-
         if ( $this->cm->hasField($field) || $this->cm->hasAssociation($field) ) {
             return $this->$field;
-        } else {
-            throw new \BadMethodCallException("no field with name '".$field."' exists on '".$this->cm->getName()."'");
         }
+
+        throw new \BadMethodCallException("no field with name '".$field."' exists on '".$this->cm->getName()."'");
     }
 
     /**
@@ -190,8 +186,6 @@
      */
     private function add($field, $args)
     {
-        $this->initializeDoctrine();
-
         if ($this->cm->hasAssociation($field) && $this->cm->isCollectionValuedAssociation($field)) {
             $targetClass = $this->cm->getAssociationTargetClass($field);
             if (!($args[0] instanceof $targetClass)) {
@@ -239,6 +233,8 @@
      */
     public function __call($method, $args)
     {
+        $this->initializeDoctrine();
+
         $command = substr($method, 0, 3);
         $field = lcfirst(substr($method, 3));
         if ($command == "set") {