From 727983a182b3a77bbcb9d69de9479a25e0a78453 Mon Sep 17 00:00:00 2001 From: Javier Spagnoletti Date: Wed, 28 Oct 2015 11:55:11 -0300 Subject: [PATCH] [bugfix] Add check for `\SoapFault::$detail` | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | Add check for existence of `\SoapFault::$detail` property in `Vmwarephp\Exception\Soap::makeFaultDetailsString()` since it can be unset. --- library/Vmwarephp/Exception/Soap.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/library/Vmwarephp/Exception/Soap.php b/library/Vmwarephp/Exception/Soap.php index 6f357ca..5018629 100644 --- a/library/Vmwarephp/Exception/Soap.php +++ b/library/Vmwarephp/Exception/Soap.php @@ -22,11 +22,16 @@ private function makeMessageHeader($soapFault) { return "{$soapFault->faultcode}: {$soapFault->faultstring}. "; } - private function makeFaultDetailsString($soapFault) { + private function makeFaultDetailsString(\SoapFault $soapFault) { $faults = array(); - foreach ($soapFault->detail as $fault) { - $faults[] = "{$fault->enc_stype}: " . print_r($fault->enc_value, true); - } - return count($faults) ? implode(', ', $faults) : ''; + // \SoapFault::$detail property can be unexistent + // @link https://bugs.php.net/bug.php?id=46792 + if (isset($soapFault->detail)) { + foreach ($soapFault->detail as $fault) { + $faults[] = "{$fault->enc_stype}: " . print_r($fault->enc_value, true); + } + } + + return implode(', ', $faults); } }