PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Web Services » XML_RPC » Bug #3608

[patch] add makeValue method XML_RPC_Client

Details

Request #3608[patch] add makeValue method XML_RPC_Client
Submitted2005-02-26 17:25 UTC
Frombzoller at cavoksolutions dot com
Assigneddanielc
StatusBogus
PackageXML_RPC
PHP Version5.0.3
OSlinux
Roadmaps(Not assigned)

Comments

[2005-02-26 17:25 UTC] bzoller at cavoksolutions dot com

Description:
------------
We deal with structs a ton in our application, and I was tired of buildling them "by hand." I propose the following solution: add a method makeValue($val) to XML_RPC_Client that takes one argument (the PHP variable you want to turn into an XML_RPC_Value), and returns the equivalent XML_RPC_Value object.

patch located at:
http://www.kludgebox.com/stuff/XML_RPC-1.2.0RC7-makeValue.patch

Warning: My coding style may not 100% match PEAR standards (I don't typically use them), but I think it's close.. hopefully someone can tweak where necessary.

It should handle all types of variables, excluding object, resource, user function, and "unknown type", as defined by php's gettype(): http://us4.php.net/gettype

Thanks!
--Bob

Reproduce code:
---------------
<?php
//sample code
$key = 'bill';
$data['jack'] = 'funk';
$data['harry'] = 'larry';
$client = new XML_RPC_Client('/','localhost',80);
$message = new XML_RPC_Message("signup",array(
$client->makeValue($key),
$client->makeValue($data)
));
?>

[2005-03-27 16:09 UTC] mfriedman at symcor dot com

Check RPC.php for the *_encode() and *_decode() functions which do what you want. Also check bug: http://pear.php.net/bugs/bug.php?id=3373

[2005-05-04 18:50 UTC] bzoller at cavoksolutions dot com

My apologies.. I had replied to this bug but I gather the comment didn't stick for some reason..

Yes, encode and decode do what I wanted. I think I was sidetracked by the makeVal() method.. which might do well to be refactored into a call to decode() (?)

Anyway, thanks for the quick response.
--Bob