From e4ba6edab71cda0dac7a43402eb854a1e02f24b2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Sat, 10 Mar 2012 13:56:26 +0100 Subject: [PATCH] Adding ClassUtil::equals() --- .../files/lib/util/ClassUtil.class.php | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/wcfsetup/install/files/lib/util/ClassUtil.class.php b/wcfsetup/install/files/lib/util/ClassUtil.class.php index bb39deda74..9232ad46f5 100644 --- a/wcfsetup/install/files/lib/util/ClassUtil.class.php +++ b/wcfsetup/install/files/lib/util/ClassUtil.class.php @@ -4,14 +4,28 @@ namespace wcf\util; /** * Provides methods for class interactions. * - * @author Alexander Ebert - * @copyright 2001-2011 WoltLab GmbH + * @author Tim Düsterhus, Alexander Ebert + * @copyright 2001-2012 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage util * @category Community Framework */ class ClassUtil { + /** + * Checks whether the given objects are equal. + * Objects are considered equal, when they are instances of the same class and all attributes are equal. + * + * @param object $a + * @param object $b + * @return boolean + */ + public static function equals($a, $b) { + if (!is_object($a)) return false; + + return print_r($a, true) === print_r($b, true); + } + /** * Checks wether given class extends or implements the target class or interface. * You SHOULD NOT call this method if 'instanceof' satisfies your request! @@ -33,4 +47,4 @@ class ClassUtil { return false; } -} \ No newline at end of file +} -- 2.20.1