From ec4bf4ea8f41f0febe1a421b486511a6109225cd Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Tue, 12 Mar 2013 11:47:29 -0500 Subject: [PATCH 1/3] [zendframework/zf2#3981] Fixes to exception strings - No need to use `__CLASS__::__METHOD__` in exception strings; `__METHOD__` already contains the class. - Changes to quotes in exception messages required changes to two unit tests --- src/AutoDiscover.php | 8 +++----- test/Wsdl/CompositeStrategyTest.php | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/AutoDiscover.php b/src/AutoDiscover.php index 097d27fa..c53a4e7d 100644 --- a/src/AutoDiscover.php +++ b/src/AutoDiscover.php @@ -204,8 +204,7 @@ public function setUri($uri) { if (!is_string($uri) && !($uri instanceof Uri\Uri)) { throw new Exception\InvalidArgumentException(sprintf( - 'No uri given to %s::%s() as string or \Zend\Uri\Uri instance.', - __CLASS__, + 'No uri given to %s() as string or \Zend\Uri\Uri instance.', __METHOD__ )); } @@ -246,9 +245,8 @@ public function setWsdlClass($wsdlClass) { if (!is_string($wsdlClass) && !is_subclass_of($wsdlClass, 'Zend\Soap\Wsdl')) { throw new Exception\InvalidArgumentException(sprintf( - 'No %s\Wsdl subclass given to %s::%s() as string.', + 'No %s\Wsdl subclass given to %s() as string.', __NAMESPACE__, - __CLASS__, __METHOD__ )); } @@ -568,4 +566,4 @@ public function handle() header('Content-Type: text/xml'); echo $this->toXml(); } -} \ No newline at end of file +} diff --git a/test/Wsdl/CompositeStrategyTest.php b/test/Wsdl/CompositeStrategyTest.php index 090adf03..e9d71476 100644 --- a/test/Wsdl/CompositeStrategyTest.php +++ b/test/Wsdl/CompositeStrategyTest.php @@ -72,7 +72,7 @@ public function testCompositeThrowsExceptionOnInvalidStrategy() $strategy = new ComplexTypeStrategy\Composite(array(), 'invalid'); $strategy->connectTypeToStrategy('Book', 'strategy'); - $this->setExpectedException('Zend\Soap\Exception\InvalidArgumentException', 'Strategy for Complex Type \'Book\' is not a valid strategy'); + $this->setExpectedException('Zend\Soap\Exception\InvalidArgumentException', 'Strategy for Complex Type "Book" is not a valid strategy'); $book = $strategy->getStrategyOfType('Book'); } @@ -105,7 +105,7 @@ public function testCompositeRequiresContextForAddingComplexTypesOtherwiseThrows { $strategy = new ComplexTypeStrategy\Composite(); - $this->setExpectedException('Zend\Soap\Exception\InvalidArgumentException', 'Cannot add complex type \'Test\''); + $this->setExpectedException('Zend\Soap\Exception\InvalidArgumentException', 'Cannot add complex type "Test"'); $strategy->addComplexType('Test'); } } From cc2a9f681ac031f0c49f41a5c45ca42e4b220dd1 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Tue, 12 Mar 2013 11:47:46 -0500 Subject: [PATCH 2/3] [zendframework/zf2#3981] CS fixes - EOF ending --- src/Client.php | 2 +- src/Server.php | 2 +- src/Server/DocumentLiteralWrapper.php | 2 +- src/Wsdl.php | 2 +- src/Wsdl/ComplexTypeStrategy/Composite.php | 2 +- src/Wsdl/ComplexTypeStrategy/DefaultComplexType.php | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Client.php b/src/Client.php index d56321ff..5d409e6f 100644 --- a/src/Client.php +++ b/src/Client.php @@ -1178,4 +1178,4 @@ public function setCookie($cookieName, $cookieValue=null) $soapClient->__setCookie($cookieName, $cookieValue); return $this; } -} \ No newline at end of file +} diff --git a/src/Server.php b/src/Server.php index a7486aac..151b3f45 100644 --- a/src/Server.php +++ b/src/Server.php @@ -957,4 +957,4 @@ public function handlePhpErrors($errno, $errstr, $errfile = null, $errline = nul { throw $this->fault($errstr, 'Receiver'); } -} \ No newline at end of file +} diff --git a/src/Server/DocumentLiteralWrapper.php b/src/Server/DocumentLiteralWrapper.php index 4d4607b5..90b415fd 100644 --- a/src/Server/DocumentLiteralWrapper.php +++ b/src/Server/DocumentLiteralWrapper.php @@ -164,4 +164,4 @@ protected function _assertOnlyOneArgument($args) )); } } -} \ No newline at end of file +} diff --git a/src/Wsdl.php b/src/Wsdl.php index 618c4308..61918e47 100644 --- a/src/Wsdl.php +++ b/src/Wsdl.php @@ -738,4 +738,4 @@ public function addElement($element) $schema->appendChild($elementXml); return self::TYPES_NS . ':' . $element['name']; } -} \ No newline at end of file +} diff --git a/src/Wsdl/ComplexTypeStrategy/Composite.php b/src/Wsdl/ComplexTypeStrategy/Composite.php index bbed3ab1..9939c824 100644 --- a/src/Wsdl/ComplexTypeStrategy/Composite.php +++ b/src/Wsdl/ComplexTypeStrategy/Composite.php @@ -152,4 +152,4 @@ public function addComplexType($type) $strategy->setContext($this->context); return $strategy->addComplexType($type); } -} \ No newline at end of file +} diff --git a/src/Wsdl/ComplexTypeStrategy/DefaultComplexType.php b/src/Wsdl/ComplexTypeStrategy/DefaultComplexType.php index 3b4ec2c4..2a10aaf4 100644 --- a/src/Wsdl/ComplexTypeStrategy/DefaultComplexType.php +++ b/src/Wsdl/ComplexTypeStrategy/DefaultComplexType.php @@ -79,4 +79,4 @@ public function addComplexType($type) return $soapType; } -} \ No newline at end of file +} From 83759802d681dcd0082ab9eb87bb21fc5c08b953 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Tue, 12 Mar 2013 11:53:31 -0500 Subject: [PATCH 3/3] [zendframework/zf2#3982] revert several BC-incompatible changes - constructor class map argument should default to array - setClassMap should not typehint $classmap - however, argument checking is valid; added test to ensure only an array is provided --- src/AutoDiscover.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/AutoDiscover.php b/src/AutoDiscover.php index 55e60d52..dbe6f606 100644 --- a/src/AutoDiscover.php +++ b/src/AutoDiscover.php @@ -100,7 +100,7 @@ class AutoDiscover * @param null|string $wsdlClass * @param null|array $classMap */ - public function __construct(ComplexTypeStrategy $strategy = null, $endpointUri = null, $wsdlClass = null, array $classMap = null) + public function __construct(ComplexTypeStrategy $strategy = null, $endpointUri = null, $wsdlClass = null, array $classMap = array()) { $this->reflection = new Reflection(); $this->discoveryStrategy = new ReflectionDiscovery(); @@ -114,9 +114,7 @@ public function __construct(ComplexTypeStrategy $strategy = null, $endpointUri = if (null !== $wsdlClass) { $this->setWsdlClass($wsdlClass); } - if (null !== $classMap) { - $this->setClassMap($classMap); - } + $this->setClassMap($classMap); } /** @@ -155,8 +153,15 @@ public function getClassMap() * @param array $classmap * @return AutoDiscover */ - public function setClassMap(array $classMap) + public function setClassMap($classMap) { + if (!is_array($classMap)) { + throw new Exception\InvalidArgumentException(sprintf( + '%s expects an array; received "%s"', + __METHOD__, + (is_object($classMap) ? get_class($classMap) : gettype($classMap)) + )); + } $this->classMap = $classMap; return $this; }