Skip to content

Commit

Permalink
reviewing imports usage and removing var_dump and exits - replaced by…
Browse files Browse the repository at this point in the history
… error_log and exceptions
  • Loading branch information
davispeixoto committed May 4, 2015
1 parent 6778c5b commit 257c38d
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 94 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,3 @@ About the fixes:
- I've just removed all unused code from composer point of view. I've ported all classes into src folder, and kept all of them into a separated file (there was some files with multiple classes).
- I've formatted code into PSR-1/PSR-2 format
- I've changed some methods signatures, changing their type, like from **date** to **string**, in order to give them the proper type according to current usage. I've not added/removed parameters from phpdoc signatures, despite the high amount of errors.
- I've added a backslash for some classes calls such as SoapClient, as needed by PSR context loading.
18 changes: 11 additions & 7 deletions src/Davispeixoto/ForceDotComToolkitForPhp/SObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

use Exception;
use stdClass;

class SObject
{
public $type;
Expand Down Expand Up @@ -56,7 +59,7 @@ public function __construct($response = null)

if (isset($response->any)) {
try {
if ($response->any instanceof \stdClass) {
if ($response->any instanceof stdClass) {
if ($this->isSObject($response->any)) {
$anArray = array();
$sobject = new SObject($response->any);
Expand All @@ -69,7 +72,7 @@ public function __construct($response = null)
if (is_array($response->any)) {
$anArray = array();
foreach ($response->any as $key => $item) {
if ($item instanceof \stdClass) {
if ($item instanceof stdClass) {
if ($this->isSObject($item)) {
$sobject = new SObject($item);
$anArray[$key] = $sobject;
Expand Down Expand Up @@ -108,7 +111,8 @@ public function __construct($response = null)
}
}
} catch (Exception $e) {
var_dump('exception: ', $e);
error_log('salesforce exception: ', $e->getMessage());
error_log('salesforce exception: ', $e->getTraceAsString());
}
}
}
Expand All @@ -135,7 +139,7 @@ public function convertFields($any)
$array = $this->xml2array('<Object xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' . $str . '</Object>',
2);

$xml = new \stdClass();
$xml = new stdClass();
if (!count($array['Object'])) {
return $xml;
}
Expand Down Expand Up @@ -229,7 +233,7 @@ public function xml2array($contents, $get_attributes = 1)
if ($type == "open") {//The starting of the tag '<tag>'
$parent[$level - 1] = &$current;

if (!is_array($current) or (!in_array($tag, array_keys($current)))) { //Insert New tag
if (!is_array($current) || (!in_array($tag, array_keys($current)))) { //Insert New tag
$current[$tag] = $result;
$current = &$current[$tag];

Expand All @@ -249,8 +253,8 @@ public function xml2array($contents, $get_attributes = 1)
$current[$tag] = $result;

} else { //If taken, put all things inside a list(array)
if ((is_array($current[$tag]) and $get_attributes == 0)//If it is already an array...
or (isset($current[$tag][0]) and is_array($current[$tag][0]) and ($get_attributes == 1 || $get_attributes == 2))
if ((is_array($current[$tag]) && $get_attributes == 0)//If it is already an array...
|| (isset($current[$tag][0]) && is_array($current[$tag][0]) && ($get_attributes == 1 || $get_attributes == 2))
) {
array_push($current[$tag], $result); // ...push the new element into that array.
} else { //If it is not an array...
Expand Down
Loading

0 comments on commit 257c38d

Please sign in to comment.