From f2863557f5a0196ac414670cd0b084504962f378 Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Wed, 20 Feb 2008 00:37:08 +0000 Subject: [PATCH] [3.1.0] Make static ConfigSchema methods throw errors. git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1571 48356398-32a2-884e-a903-53898d9a118a --- library/HTMLPurifier/ConfigSchema.php | 12 ++++++++++++ tests/HTMLPurifier/DefinitionCacheTest.php | 9 --------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/library/HTMLPurifier/ConfigSchema.php b/library/HTMLPurifier/ConfigSchema.php index ac473675..a55a9b79 100644 --- a/library/HTMLPurifier/ConfigSchema.php +++ b/library/HTMLPurifier/ConfigSchema.php @@ -80,8 +80,16 @@ class HTMLPurifier_ConfigSchema { return HTMLPurifier_ConfigSchema::$singleton; } + /** + * Throws an E_USER_NOTICE stating that a method is deprecated. + */ + private static function deprecated($method) { + trigger_error("Static HTMLPurifier_ConfigSchema::$method deprecated, use add*() method instead", E_USER_NOTICE); + } + /** @see HTMLPurifier_ConfigSchema->set() */ public static function define($namespace, $name, $default, $type, $description) { + HTMLPurifier_ConfigSchema::deprecated(__METHOD__); $def =& HTMLPurifier_ConfigSchema::instance(); $def->add($namespace, $name, $default, $type, $description); } @@ -155,6 +163,7 @@ class HTMLPurifier_ConfigSchema { /** @see HTMLPurifier_ConfigSchema->addNamespace() */ public static function defineNamespace($namespace, $description) { + HTMLPurifier_ConfigSchema::deprecated(__METHOD__); $def =& HTMLPurifier_ConfigSchema::instance(); $def->addNamespace($namespace, $description); } @@ -189,6 +198,7 @@ class HTMLPurifier_ConfigSchema { /** @see HTMLPurifier_ConfigSchema->addValueAliases() */ public static function defineValueAliases($namespace, $name, $aliases) { + HTMLPurifier_ConfigSchema::deprecated(__METHOD__); $def =& HTMLPurifier_ConfigSchema::instance(); $def->addValueAliases($namespace, $name, $aliases); } @@ -230,6 +240,7 @@ class HTMLPurifier_ConfigSchema { /** @see HTMLPurifier_ConfigSchema->addAllowedValues() */ public static function defineAllowedValues($namespace, $name, $allowed_values) { + HTMLPurifier_ConfigSchema::deprecated(__METHOD__); $def =& HTMLPurifier_ConfigSchema::instance(); $def->addAllowedValues($namespace, $name, $allowed_values); } @@ -273,6 +284,7 @@ class HTMLPurifier_ConfigSchema { /** @see HTMLPurifier_ConfigSchema->addAlias() */ public static function defineAlias($namespace, $name, $new_namespace, $new_name) { + HTMLPurifier_ConfigSchema::deprecated(__METHOD__); $def =& HTMLPurifier_ConfigSchema::instance(); $def->addAlias($namespace, $name, $new_namespace, $new_name); } diff --git a/tests/HTMLPurifier/DefinitionCacheTest.php b/tests/HTMLPurifier/DefinitionCacheTest.php index aac6ebf6..58ba8867 100644 --- a/tests/HTMLPurifier/DefinitionCacheTest.php +++ b/tests/HTMLPurifier/DefinitionCacheTest.php @@ -7,13 +7,6 @@ class HTMLPurifier_DefinitionCacheTest extends HTMLPurifier_Harness // using null subclass because parent is abstract $cache = new HTMLPurifier_DefinitionCache_Null('Test'); - $old_copy = HTMLPurifier_ConfigSchema::instance(); - $o = new HTMLPurifier_ConfigSchema(); - HTMLPurifier_ConfigSchema::instance($o); - - HTMLPurifier_ConfigSchema::defineNamespace('Test', 'Test namespace'); - HTMLPurifier_ConfigSchema::define('Test', 'DefinitionRev', 1, 'int', 'Definition revision.'); - generate_mock_once('HTMLPurifier_Config'); $config = new HTMLPurifier_ConfigMock(); $config->version = '1.0.0'; // hopefully no conflicts @@ -31,8 +24,6 @@ class HTMLPurifier_DefinitionCacheTest extends HTMLPurifier_Harness $this->assertIdentical($cache->isOld('1.0.0-hash2-1', $config), false); // if hash is different, don't touch! $this->assertIdentical($cache->isOld('1.0.0beta-hash2-11', $config), true); - HTMLPurifier_ConfigSchema::instance($old_copy); - } }