namespace wcf\acp\action;
use wcf\action\AbstractSecureAction;
use wcf\action\AJAXInvokeAction;
+use wcf\system\exception\ImplementationException;
use wcf\system\exception\SystemException;
use wcf\system\worker\IWorker;
use wcf\system\WCF;
}
if (!is_subclass_of($this->className, IWorker::class)) {
- throw new SystemException("'".$this->className."' does not implement '".IWorker::class."'");
+ throw new ImplementationException($this->className, IWorker::class);
}
}
namespace wcf\action;
use wcf\system\exception\AJAXException;
use wcf\system\exception\IllegalLinkException;
+use wcf\system\exception\ImplementationException;
use wcf\system\exception\InvalidSecurityTokenException;
use wcf\system\exception\NamedUserException;
+use wcf\system\exception\ParentClassException;
use wcf\system\exception\PermissionDeniedException;
use wcf\system\exception\SystemException;
use wcf\system\exception\UserInputException;
protected function invoke() {
// check for interface and inheritance of SingletonFactory
if (!is_subclass_of($this->className, IAJAXInvokeAction::class)) {
- throw new SystemException("'".$this->className."' does not implement '".IAJAXInvokeAction::class."'");
+ throw new ImplementationException($this->className, IAJAXInvokeAction::class);
}
else if (!is_subclass_of($this->className, SingletonFactory::class)) {
- throw new SystemException("'".$this->className."' does not extend '".SingletonFactory::class."'");
+ throw new ParentClassException($this->className, SingletonFactory::class);
}
// validate action name
<?php
namespace wcf\action;
use wcf\data\IDatabaseObjectAction;
-use wcf\system\exception\SystemException;
+use wcf\system\exception\ImplementationException;
use wcf\system\WCF;
use wcf\util\ArrayUtil;
use wcf\util\StringUtil;
*/
protected function invoke() {
if (!is_subclass_of($this->className, IDatabaseObjectAction::class)) {
- throw new SystemException("'".$this->className."' does not implement '".IDatabaseObjectAction::class."'");
+ throw new ImplementationException($this->className, IDatabaseObjectAction::class);
}
if (!empty($this->interfaceName)) {
if (!is_subclass_of($this->className, $this->interfaceName)) {
- throw new SystemException("'".$this->className."' does not implement '".$this->interfaceName."'");
+ throw new ImplementationException($this->className, $this->interfaceName);
}
}
<?php
namespace wcf\data;
+use wcf\system\exception\ImplementationException;
use wcf\system\exception\SystemException;
use wcf\system\SingletonFactory;
throw new SystemException("Unable to find class '".$this->className."'");
}
if (!is_subclass_of($this->className, static::$processorInterface)) {
- throw new SystemException("'".$this->className."' does not implement '".static::$processorInterface."'");
+ throw new ImplementationException($this->className, static::$processorInterface);
}
if (is_subclass_of($this->className, SingletonFactory::class)) {
}
else {
if (!is_subclass_of($this->className, IDatabaseObjectProcessor::class)) {
- throw new SystemException("'".$this->className."' does not implement '".IDatabaseObjectProcessor::class."'");
+ throw new ImplementationException($this->className, IDatabaseObjectProcessor::class);
}
$this->processor = new $this->className($this);
<?php
namespace wcf\data;
use wcf\data\category\AbstractDecoratedCategory;
+use wcf\system\exception\ParentClassException;
use wcf\system\exception\SystemException;
use wcf\system\WCF;
$className = static::getCategoryClassName();
if (!is_subclass_of($className, AbstractDecoratedCategory::class)) {
- throw new SystemException("'".$className."' does not extend '".AbstractDecoratedCategory::class."'.");
+ throw new ParentClassException($className, AbstractDecoratedCategory::class);
}
if (!empty($this->categoryIDs)) {
use wcf\data\ProcessibleDatabaseObject;
use wcf\data\TDatabaseObjectOptions;
use wcf\data\TDatabaseObjectPermissions;
+use wcf\system\exception\ImplementationException;
use wcf\system\exception\SystemException;
use wcf\system\SingletonFactory;
throw new SystemException("Unable to find class '".$this->className."'");
}
if (($definitionInterface = ObjectTypeCache::getInstance()->getDefinition($this->definitionID)->interfaceName) && !is_subclass_of($this->className, $definitionInterface)) {
- throw new SystemException("'".$this->className."' does not implement '".$definitionInterface."'");
+ throw new ImplementationException($this->className, $definitionInterface);
}
if (is_subclass_of($this->className, SingletonFactory::class)) {
use wcf\data\DatabaseObject;
use wcf\data\TDatabaseObjectOptions;
use wcf\data\TDatabaseObjectPermissions;
+use wcf\system\exception\ImplementationException;
use wcf\system\exception\SystemException;
use wcf\system\sitemap\ISitemapProvider;
}
if (!is_subclass_of($this->className, ISitemapProvider::class)) {
- throw new SystemException("'".$this->className."' does not implement '".ISitemapProvider::class."'");
+ throw new ImplementationException($this->className, ISitemapProvider::class);
}
$this->sitemapObj = new $this->className();
use wcf\data\user\User;
use wcf\data\DatabaseObjectDecorator;
use wcf\system\cache\builder\UserOptionCacheBuilder;
+use wcf\system\exception\ImplementationException;
use wcf\system\exception\SystemException;
use wcf\system\option\user\IUserOptionOutput;
use wcf\util\StringUtil;
// validate interface
if (!is_subclass_of($this->outputClass, IUserOptionOutput::class)) {
- throw new SystemException("'".$this->outputClass."' does not implement '".IUserOptionOutput::class."'");
+ throw new ImplementationException($this->outputClass, IUserOptionOutput::class);
}
self::$outputObjects[$this->outputClass] = new $this->outputClass();
<?php
namespace wcf\data\user\profile\menu\item;
+use wcf\system\exception\ImplementationException;
+use wcf\system\exception\ParentClassException;
use wcf\system\menu\user\profile\content\IUserProfileMenuContent;
use wcf\data\DatabaseObject;
use wcf\data\TDatabaseObjectOptions;
}
if (!is_subclass_of($this->className, SingletonFactory::class)) {
- throw new SystemException("'".$this->className."' does not extend '".SingletonFactory::class."'");
+ throw new ParentClassException($this->className, SingletonFactory::class);
}
if (!is_subclass_of($this->className, IUserProfileMenuContent::class)) {
- throw new SystemException("'".$this->className."' does not implement '".IUserProfileMenuContent::class."'");
+ throw new ImplementationException($this->className, IUserProfileMenuContent::class);
}
$this->contentManager = call_user_func([$this->className, 'getInstance']);
namespace wcf\page;
use wcf\data\DatabaseObjectList;
use wcf\system\event\EventHandler;
+use wcf\system\exception\ParentClassException;
use wcf\system\exception\SystemException;
use wcf\system\WCF;
}
if (!is_subclass_of($this->objectListClassName, DatabaseObjectList::class)) {
- throw new SystemException("'".$this->objectListClassName."' does not extend '".DatabaseObjectList::class."'");
+ throw new ParentClassException($this->objectListClassName, DatabaseObjectList::class);
}
$this->objectList = new $this->objectListClassName();
use wcf\system\application\ApplicationHandler;
use wcf\system\event\EventHandler;
use wcf\system\exception\IllegalLinkException;
-use wcf\system\exception\SystemException;
+use wcf\system\exception\ImplementationException;
use wcf\system\page\PageLocationManager;
use wcf\system\search\SearchEngine;
use wcf\system\WCF;
$objectType = SearchEngine::getInstance()->getObjectType($type);
if (($message = $objectType->getObject($objectID)) !== null) {
if (!($message instanceof ISearchResultObject)) {
- throw new SystemException("'".get_class($message)."' does not implement '".ISearchResultObject::class."'");
+ throw new ImplementationException(get_class($message), ISearchResultObject::class);
}
$this->messages[] = $message;
use wcf\system\exception\ErrorException;
use wcf\system\exception\IPrintableException;
use wcf\system\exception\NamedUserException;
+use wcf\system\exception\ParentClassException;
use wcf\system\exception\PermissionDeniedException;
use wcf\system\exception\SystemException;
use wcf\system\language\LanguageFactory;
if (class_exists($objectName)) {
if (!(is_subclass_of($objectName, SingletonFactory::class))) {
- throw new SystemException("class '".$objectName."' does not implement the interface '".SingletonFactory::class."'");
+ throw new ParentClassException($objectName, SingletonFactory::class);
}
self::$coreObject[$className] = call_user_func([$objectName, 'getInstance']);
namespace wcf\system\background;
use wcf\data\user\User;
use wcf\system\background\job\AbstractBackgroundJob;
+use wcf\system\exception\ParentClassException;
use wcf\system\exception\SystemException;
use wcf\system\session\SessionHandler;
use wcf\system\SingletonFactory;
if (!is_array($jobs)) $jobs = [$jobs];
foreach ($jobs as $job) {
if (!($job instanceof AbstractBackgroundJob)) {
- throw new SystemException('$jobs contains an item that does not extend \''.AbstractBackgroundJob::class.'\'.');
+ throw new ParentClassException(get_class($job), AbstractBackgroundJob::class);
}
}
<?php
namespace wcf\system\cache\builder;
use wcf\system\database\util\PreparedStatementConditionBuilder;
+use wcf\system\exception\ImplementationException;
use wcf\system\exception\SystemException;
use wcf\system\option\user\group\IUserGroupOptionType;
use wcf\system\WCF;
throw new SystemException("unable to find class '".$className."'");
}
if (!is_subclass_of($className, IUserGroupOptionType::class)) {
- throw new SystemException("'".$className."' does not implement '".IUserGroupOptionType::class."'");
+ throw new ImplementationException($className, IUserGroupOptionType::class);
}
// create instance
use wcf\system\cache\builder\ClipboardPageCacheBuilder;
use wcf\system\clipboard\action\IClipboardAction;
use wcf\system\database\util\PreparedStatementConditionBuilder;
+use wcf\system\exception\ImplementationException;
use wcf\system\exception\SystemException;
use wcf\system\SingletonFactory;
use wcf\system\WCF;
if (!isset($actions[$actionClassName])) {
// validate class
if (!is_subclass_of($actionClassName, IClipboardAction::class)) {
- throw new SystemException("'".$actionClassName."' does not implement '".IClipboardAction::class."'");
+ throw new ImplementationException($actionClassName, IClipboardAction::class);
}
$actions[$actionClassName] = [
use wcf\data\cronjob\Cronjob;
use wcf\data\cronjob\CronjobEditor;
use wcf\system\cache\builder\CronjobCacheBuilder;
+use wcf\system\exception\ImplementationException;
use wcf\system\exception\SystemException;
use wcf\system\SingletonFactory;
use wcf\system\WCF;
// verify class signature
if (!(is_subclass_of($className, ICronjob::class))) {
- throw new SystemException("'".$className."' does not implement '".ICronjob::class."'");
+ throw new ImplementationException($className, ICronjob::class);
}
// execute cronjob
use wcf\system\cache\builder\EventListenerCacheBuilder;
use wcf\system\event\listener\IParameterizedEventListener;
use wcf\system\event\IEventListener as ILegacyEventListener;
+use wcf\system\exception\ImplementationException;
use wcf\system\exception\SystemException;
use wcf\system\SingletonFactory;
if (!is_subclass_of($eventListener->listenerClassName, IParameterizedEventListener::class)) {
// legacy event listeners
if (!is_subclass_of($eventListener->listenerClassName, IEventListener::class)) {
- throw new SystemException("'".$eventListener->listenerClassName."' does not implement '".IParameterizedEventListener::class."'");
+ throw new ImplementationException($eventListener->listenerClassName, IParameterizedEventListener::class);
}
}
if (!is_subclass_of($eventListener->listenerClassName, IParameterizedEventListener::class)) {
// legacy event listeners
if (!is_subclass_of($eventListener->listenerClassName, IEventListener::class)) {
- throw new SystemException("'".$eventListener->listenerClassName."' does not implement '".IParameterizedEventListener::class."'");
+ throw new ImplementationException($eventListener->listenerClassName, IParameterizedEventListener::class);
}
}
--- /dev/null
+<?php
+namespace wcf\system\exception;
+
+/**
+ * Exception implementation for cases when a class is expected to implement a certain
+ * interface but that is not the case.
+ *
+ * @author Matthias Schmidt
+ * @copyright 2001-2016 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package com.woltlab.wcf
+ * @subpackage system.exception
+ * @category Community Framework
+ * @since 2.2
+ */
+class ImplementationException extends \LogicException {
+ /**
+ * ImplementationException constructor.
+ *
+ * @param string $className
+ * @param string $interfaceName
+ */
+ public function __construct($className, $interfaceName) {
+ parent::__construct("Class '{$className}' does not implement interface '{$interfaceName}'.");
+ }
+}
--- /dev/null
+<?php
+namespace wcf\system\exception;
+
+/**
+ * Exception implementation for cases when a class is expected to have a certain class
+ * as a parent class but that is not the case.
+ *
+ * @author Matthias Schmidt
+ * @copyright 2001-2016 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package com.woltlab.wcf
+ * @subpackage system.exception
+ * @category Community Framework
+ * @since 2.2
+ */
+class ParentClassException extends \LogicException {
+ /**
+ * ImplementationException constructor.
+ *
+ * @param string $className
+ * @param string $parentClassName
+ */
+ public function __construct($className, $parentClassName) {
+ parent::__construct("Class '{$className}' does not extend class '{$parentClassName}'.");
+ }
+}
<?php
namespace wcf\system\html\input\node;
-use wcf\system\bbcode\HtmlBBCodeParser;
-use wcf\system\exception\SystemException;
use wcf\system\html\metacode\converter\IMetacodeConverter;
use wcf\system\html\metacode\converter\SimpleMetacodeConverter;
use wcf\system\html\node\AbstractHtmlNode;
use wcf\data\IVisitableObjectAction;
use wcf\system\bbcode\PreParser;
use wcf\system\event\EventHandler;
+use wcf\system\exception\ParentClassException;
use wcf\system\exception\SystemException;
use wcf\system\exception\UserInputException;
use wcf\system\SingletonFactory;
$this->container = new $containerClassName($parameters['objectID']);
if (!empty($containerDecoratorClassName)) {
if (!is_subclass_of($containerDecoratorClassName, DatabaseObjectDecorator::class)) {
- throw new SystemException("'".$containerDecoratorClassName."' does not extend '".DatabaseObjectDecorator::class."'");
+ throw new ParentClassException($containerDecoratorClassName, DatabaseObjectDecorator::class);
}
$this->container = new $containerDecoratorClassName($this->container);
use wcf\system\application\ApplicationHandler;
use wcf\system\cache\builder\OptionCacheBuilder;
use wcf\system\event\EventHandler;
+use wcf\system\exception\ImplementationException;
use wcf\system\exception\SystemException;
use wcf\system\exception\UserInputException;
use wcf\system\language\I18nHandler;
}
if (!is_subclass_of($className, IOptionType::class)) {
- throw new SystemException("'".$className."' does not implement '".IOptionType::class."'");
+ throw new ImplementationException($className, IOptionType::class);
}
return $className;
use wcf\data\option\Option;
use wcf\data\user\group\UserGroup;
use wcf\system\cache\builder\UserGroupOptionCacheBuilder;
-use wcf\system\exception\SystemException;
+use wcf\system\exception\ImplementationException;
use wcf\system\exception\UserInputException;
use wcf\system\option\OptionHandler;
use wcf\system\WCF;
return null;
}
if (!is_subclass_of($className, IUserGroupOptionType::class)) {
- throw new SystemException("'".$className."' does not implement '".IUserGroupOptionType::class."'");
+ throw new ImplementationException($className, IUserGroupOptionType::class);
}
return $className;
use wcf\system\database\statement\PreparedStatement;
use wcf\system\database\util\PreparedStatementConditionBuilder;
use wcf\system\event\EventHandler;
+use wcf\system\exception\ImplementationException;
use wcf\system\exception\SystemException;
use wcf\system\form\container\GroupFormElementContainer;
use wcf\system\form\container\MultipleSelectionFormElementContainer;
$plugin = new $className($this, $nodeData);
if (!($plugin instanceof IPackageInstallationPlugin)) {
- throw new SystemException("'".$className."' does not implement '".IPackageInstallationPlugin::class."'");
+ throw new ImplementationException($className, IPackageInstallationPlugin::class);
}
// execute PIP
use wcf\data\poll\PollAction;
use wcf\data\poll\PollList;
use wcf\system\database\util\PreparedStatementConditionBuilder;
+use wcf\system\exception\ImplementationException;
+use wcf\system\exception\ParentClassException;
use wcf\system\exception\SystemException;
use wcf\system\exception\UserInputException;
use wcf\system\SingletonFactory;
// validates against object type's class
$className = $this->cache[$objectType]->className;
if (!is_subclass_of($className, IPollHandler::class)) {
- throw new SystemException("'".$className."' does not implement '".IPollHandler::class."'");
+ throw new ImplementationException($className, IPollHandler::class);
}
else if (!is_subclass_of($className, SingletonFactory::class)) {
- throw new SystemException("'".$className."' does not extend '".SingletonFactory::class."'");
+ throw new ParentClassException($className, SingletonFactory::class);
}
$object = call_user_func([$className, 'getInstance']);
use wcf\data\acp\search\provider\ACPSearchProvider;
use wcf\system\application\ApplicationHandler;
use wcf\system\cache\builder\ACPSearchProviderCacheBuilder;
+use wcf\system\exception\ImplementationException;
use wcf\system\exception\SystemException;
use wcf\system\SingletonFactory;
foreach ($this->cache as $acpSearchProvider) {
$className = $acpSearchProvider->className;
if (!is_subclass_of($className, IACPSearchResultProvider::class)) {
- throw new SystemException("'".$className."' does not implement '".IACPSearchResultProvider::class."'");
+ throw new ImplementationException($className, IACPSearchResultProvider::class);
}
$provider = new $className();
use wcf\data\AbstractDatabaseObjectAction;
use wcf\data\IFile;
use wcf\data\IThumbnailFile;
+use wcf\system\exception\ImplementationException;
+use wcf\system\exception\ParentClassException;
use wcf\system\exception\SystemException;
use wcf\system\image\ImageHandler;
use wcf\system\WCF;
$this->data = $data;
if (!is_subclass_of($this->actionClassName, AbstractDatabaseObjectAction::class)) {
- throw new SystemException("'".$this->actionClassName."' does not extend '".AbstractDatabaseObjectAction::class."'");
+ throw new ParentClassException($this->actionClassName, AbstractDatabaseObjectAction::class);
}
$this->editorClassName = (new $this->actionClassName([], ''))->getClassName();
$baseClass = call_user_func([$this->editorClassName, 'getBaseClass']);
if (!is_subclass_of($baseClass, IFile::class)) {
- throw new SystemException("'".$this->editorClassName."' does not implement '".IFile::class."'");
+ throw new ImplementationException($baseClass, IFile::class);
}
if (is_subclass_of($baseClass, IThumbnailFile::class)) {
$this->options['thumbnailSizes'] = call_user_func([$baseClass, 'getThumbnailSizes']);
<?php
namespace wcf\system\user\authentication;
use wcf\system\event\EventHandler;
-use wcf\system\exception\SystemException;
+use wcf\system\exception\ImplementationException;
use wcf\system\SingletonFactory;
/**
EventHandler::getInstance()->fireAction($this, 'init');
if (!is_subclass_of($this->className, IUserAuthentication::class)) {
- throw new SystemException("'" . $this->className . "' does not implement '".IUserAuthentication::class."'");
+ throw new ImplementationException($this->className, IUserAuthentication::class);
}
$this->userAuthentication = call_user_func([$this->className, 'getInstance']);
namespace wcf\system\worker;
use wcf\data\DatabaseObjectList;
use wcf\system\event\EventHandler;
+use wcf\system\exception\ParentClassException;
use wcf\system\exception\SystemException;
use wcf\system\request\LinkHandler;
use wcf\system\search\SearchIndexManager;
}
if (!is_subclass_of($this->objectListClassName, DatabaseObjectList::class)) {
- throw new SystemException("'".$this->objectListClassName."' does not extend '".DatabaseObjectList::class."'");
+ throw new ParentClassException($this->objectListClassName, DatabaseObjectList::class);
}
$this->objectList = new $this->objectListClassName();
<?php
namespace wcf\util;
-use wcf\system\exception\SystemException;
/**
* Provides helper methods to work with PHP's DOM implementation.