public static function getDifferingMembers($object1, $object2, $membersToConsider = array(), $recursive = false) {


        if (!($object1 instanceof SerialisableObject) || !($object2 instanceof SerialisableObject)) {
            throw new Exception("You cannot compare for differing members of none serialisable objects");
        }

        $members1 = $object1->__getSerialisablePropertyMap();
        $members2 = $object2->__getSerialisablePropertyMap();

        // Turn members to consider into a values array for ease of processing
        if (is_array($membersToConsider)) {
            $membersToConsider = array_values($membersToConsider);
        }


        // Go through first object, look for differences that way.
        $differingMembers = array();
        foreach ($members1 as $member => $value) {


            if (!is_object($value) && !is_array($value)) {
                if (isset($members2[$member]) && $members2[$member] != $value) {
                    if (!$membersToConsider || is_numeric(array_search($member, $membersToConsider))) {
                        $differingMembers[$member] = array("first" => $value, "second" => $members2[$member]);
                    }
                }
            }

            if (is_object($value) && is_object($members2[$member]) && $recursive) {
                $differingSubMembers = ObjectUtils::getDifferingMembers($value, $members2[$member], null, true);
                foreach ($differingSubMembers as $key => $subMember) {
                    if (!$membersToConsider || is_numeric(array_search($member . "." . $key, $membersToConsider))) {
                        $differingMembers[$member . "." . $key] = $subMember;
                    }
                }
            }

            if (is_array($value) && is_array($members2[$member]) && $recursive) {
                foreach ($value as $key => $memberEntry) {
                    if (is_object($memberEntry) && isset($members2[$member][$key]) && is_object($members2[$member][$key])) {
                        $differingSubMembers = ObjectUtils::getDifferingMembers($memberEntry, $members2[$member][$key], null, true);
                        foreach ($differingSubMembers as $subKey => $subMember) {
                            $differingMembers[$member . "[" . $key . "]" . "." . $subKey] = $subMember;
                        }
                    }
                }
            }

        }

        return $differingMembers;

    }
public static function getDifferingMembers($object1, $object2, $membersToConsider = array(), $recursive = false) {


        if (!($object1 instanceof SerialisableObject) || !($object2 instanceof SerialisableObject)) {
            throw new Exception("You cannot compare for differing members of none serialisable objects");
        }

        $members1 = $object1->__getSerialisablePropertyMap();
        $members2 = $object2->__getSerialisablePropertyMap();

        // Turn members to consider into a values array for ease of processing
        if (is_array($membersToConsider)) {
            $membersToConsider = array_values($membersToConsider);
        }


        // Go through first object, look for differences that way.
        $differingMembers = array();
        foreach ($members1 as $member => $value) {


            if (!is_object($value) && !is_array($value)) {
                if (isset($members2[$member]) && $members2[$member] != $value) {
                    if (!$membersToConsider || is_numeric(array_search($member, $membersToConsider))) {
                        $differingMembers[$member] = array("first" => $value, "second" => $members2[$member]);
                    }
                }
            }

            if (is_object($value) && is_object($members2[$member]) && $recursive) {
                $differingSubMembers = ObjectUtils::getDifferingMembers($value, $members2[$member], null, true);
                foreach ($differingSubMembers as $key => $subMember) {
                    if (!$membersToConsider || is_numeric(array_search($member . "." . $key, $membersToConsider))) {
                        $differingMembers[$member . "." . $key] = $subMember;
                    }
                }
            }

            if (is_array($value) && is_array($members2[$member]) && $recursive) {
                foreach ($value as $key => $memberEntry) {
                    if (is_object($memberEntry) && isset($members2[$member][$key]) && is_object($members2[$member][$key])) {
                        $differingSubMembers = ObjectUtils::getDifferingMembers($memberEntry, $members2[$member][$key], null, true);
                        foreach ($differingSubMembers as $subKey => $subMember) {
                            $differingMembers[$member . "[" . $key . "]" . "." . $subKey] = $subMember;
                        }
                    }
                }
            }

        }

        return $differingMembers;

    }
public static function getDifferingMembers ( $ object1 , $ object2 , $ membersToConsider = array ( ) , $ recursive = false ) { if ( ! ( $ object1 instanceof SerialisableObject ) || ! ( $ object2 instanceof SerialisableObject ) ) { throw new Exception ( "You cannot compare for differing members of none serialisable objects" ) ; } $ members1 = $ object1 -> __getSerialisablePropertyMap ( ) ; $ members2 = $ object2 -> __getSerialisablePropertyMap ( ) ; // Turn members to consider into a values array for ease of processing if ( is_array ( $ membersToConsider ) ) { $ membersToConsider = array_values ( $ membersToConsider ) ; } // Go through first object, look for differences that way. $ differingMembers = array ( ) ; foreach ( $ members1 as $ member => $ value ) { if ( ! is_object ( $ value ) && ! is_array ( $ value ) ) { if ( isset ( $ members2 [ $ member ] ) && $ members2 [ $ member ] != $ value ) { if ( ! $ membersToConsider || is_numeric ( array_search ( $ member , $ membersToConsider ) ) ) { $ differingMembers [ $ member ] = array ( "first" => $ value , "second" => $ members2 [ $ member ] ) ; } } } if ( is_object ( $ value ) && is_object ( $ members2 [ $ member ] ) && $ recursive ) { $ differingSubMembers = ObjectUtils :: getDifferingMembers ( $ value , $ members2 [ $ member ] , null , true ) ; foreach ( $ differingSubMembers as $ key => $ subMember ) { if ( ! $ membersToConsider || is_numeric ( array_search ( $ member . "." . $ key , $ membersToConsider ) ) ) { $ differingMembers [ $ member . "." . $ key ] = $ subMember ; } } } if ( is_array ( $ value ) && is_array ( $ members2 [ $ member ] ) && $ recursive ) { foreach ( $ value as $ key => $ memberEntry ) { if ( is_object ( $ memberEntry ) && isset ( $ members2 [ $ member ] [ $ key ] ) && is_object ( $ members2 [ $ member ] [ $ key ] ) ) { $ differingSubMembers = ObjectUtils :: getDifferingMembers ( $ memberEntry , $ members2 [ $ member ] [ $ key ] , null , true ) ; foreach ( $ differingSubMembers as $ subKey => $ subMember ) { $ differingMembers [ $ member . "[" . $ key . "]" . "." . $ subKey ] = $ subMember ; } } } } } return $ differingMembers ; }
Get differing members between two serialisable source objects - this will return a structured array detailing the differences.
If the membersToConsider array is passed only members contained within the array will be considered otherwise all members will be considered by default.

@param $object
@param $object2
Get differing members between two serialisable source objects - this will return a structured array detailing the differences . If the membersToConsider array is passed only members contained within the array will be considered otherwise all members will be considered by default .