Bug #67641 [Nab]: SoapFault Traversable ?

From: Date: Fri, 18 Jul 2014 09:14:35 +0000
Subject: Bug #67641 [Nab]: SoapFault Traversable ?
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-186720@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=67641&edit=1

 ID:                 67641
 Updated by:         requinix@php.net
 Reported by:        vosa at binaryparadise dot com
 Summary:            SoapFault Traversable ?
 Status:             Not a bug
 Type:               Bug
 Package:            SOAP related
 Operating System:   debian
 PHP Version:        Irrelevant
 Block user comment: N
 Private report:     N

 New Comment:

>"faultstring" and "faultcode" are NOT visible (or documented) properties.
They certainly are visible. Undocumented, but visible.

>Developers don't want to search "in a few places", but in official PHP reference.
I'm not saying the docs are perfect as they are. I merely took the extra minute to do some
research to see where those values were coming from - something I'd like to think other
developers would do too.

I was kinda hoping you would make the doc bug for it, but I can do that:


Previous Comments:
------------------------------------------------------------------------
[2014-07-18 07:16:17] vosa at binaryparadise dot com

Your link about object iterations says: "By default, all visible properties will be used for
the iteration."

"faultstring" and "faultcode" are NOT visible (or documented) properties.
Developers don't want to search "in a few places", but in official PHP reference.

I think it's not much work to write few words in documentation about this "feature".

------------------------------------------------------------------------
[2014-07-17 19:29:36] requinix@php.net

Objects that are not Traversable can still be iterated over using a default behavior: the set of
accessible properties and their values.

http://php.net/manual/en/language.oop5.iterations.php

As mentioned in a few places, SoapFault has undocumented properties "faultstring" and
"faultcode". Adding that to the default foreach behavior results in the output you see.

------------------------------------------------------------------------
[2014-07-17 11:50:12] vosa at binaryparadise dot com

Description:
------------
---
From manual page: http://www.php.net/class.soapfault
---
There's strange behavior of SoapFault instance when used in foreach construct. It behave almost
like Transversable object, but it shouldn't. SoapFault extends Exception and none of these
classes implements Transversable interface...

Test script:
---------------
print "Exception:\n";
foreach(new Exception('message') as $k => $v) 
    print "$k: $v\n";
    
print "SoapFault:\n";
foreach(new Soapfault('faultcode', 'faultstring') as $k => $v) 
    print "$k: $v\n";

Expected result:
----------------
Exception:
SoapFault:

Actual result:
--------------
Exception:
SoapFault:
faultstring: faultstring
faultcode: faultcode


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=67641&edit=1


Thread (7 messages)

« previous php.bugs (#186720) next »