From: Tim Düsterhus Date: Sat, 10 Mar 2012 12:56:26 +0000 (+0100) Subject: Adding ClassUtil::equals() X-Git-Tag: 2.0.0_Beta_1~1026^2~1^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=e4ba6edab71cda0dac7a43402eb854a1e02f24b2;p=GitHub%2FWoltLab%2FWCF.git Adding ClassUtil::equals() --- 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 +}