From 2b60cec19065b6cba65e2c320a937d803f87d8e0 Mon Sep 17 00:00:00 2001 From: Francis Besset Date: Thu, 21 Feb 2013 08:13:40 +0100 Subject: [PATCH] Fixed MessageBinder to avoid BC Break --- src/BeSimple/SoapCommon/Util/MessageBinder.php | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/BeSimple/SoapCommon/Util/MessageBinder.php b/src/BeSimple/SoapCommon/Util/MessageBinder.php index d018355..748c2c9 100644 --- a/src/BeSimple/SoapCommon/Util/MessageBinder.php +++ b/src/BeSimple/SoapCommon/Util/MessageBinder.php @@ -61,16 +61,15 @@ class MessageBinder // needed to support magic method __get $value = $this->message->{$property}; } elseif ($this->reflectionClass->hasProperty($property)) { - if (!$this->reflectionClass->getProperty($property)->isPublic()) { - throw new \RuntimeException(sprintf('Property "%s" is not public in class "%s". Maybe you should create the method "%s()" or "%s()" or "%s()"?', $property, $this->reflectionClass->name, $getter, $isser, $hasser)); + $p = $this->reflectionClass->getProperty($property); + if (!$p->isPublic()) { + $p->setAccessible(true); } - $value = $this->message->{$property}; + $value = $p->getValue($this->message); } elseif (property_exists($this->message, $property)) { // needed to support \stdClass instances $value = $this->message->{$property}; - } else { - throw new \RuntimeException(sprintf('Neither property "%s" nor method "%s()" nor method "%s()" exists in class "%s"', $property, $getter, $isser, $this->reflectionClass->name)); } return $value; @@ -88,16 +87,15 @@ class MessageBinder // needed to support magic method __set $this->message->{$property} = $value; } elseif ($this->reflectionClass->hasProperty($property)) { - if (!$this->reflectionClass->getProperty($property)->isPublic()) { - throw new \RuntimeException(sprintf('Property "%s" is not public in class "%s". Maybe you should create the method "%s()"?', $property, $this->reflectionClass->name, $setter)); + $p = $this->reflectionClass->getProperty($property); + if (!$p->isPublic()) { + $p->setAccessible(true); } - $this->message->{$property} = $value; + $p->setValue($this->message, $value); } elseif (property_exists($this->message, $property)) { // needed to support \stdClass instances $this->message->{$property} = $value; - } else { - throw new \RuntimeException(sprintf('Neither element "%s" nor method "%s()" exists in class "%s"', $property, $setter, $this->reflectionClass->name)); } } }