diff --git a/library/Icinga/Application/Loader.php b/library/Icinga/Application/Loader.php index 56e59f4b2..15c3a9316 100644 --- a/library/Icinga/Application/Loader.php +++ b/library/Icinga/Application/Loader.php @@ -39,11 +39,11 @@ class Loader public function registerNamespace($namespace, $directory) { if (!is_dir($directory)) { - throw new ProgrammingError(sprintf( + throw new ProgrammingError( 'Directory "%s" for namespace "%s" does not exist', $directory, $namespace - )); + ); } $this->namespaces[$namespace] = $directory; diff --git a/library/Icinga/Application/Modules/Manager.php b/library/Icinga/Application/Modules/Manager.php index 4154d2c20..9022d4907 100644 --- a/library/Icinga/Application/Modules/Manager.php +++ b/library/Icinga/Application/Modules/Manager.php @@ -323,10 +323,8 @@ class Manager } throw new ProgrammingError( - sprintf( - 'Trying to access uninstalled module dir: %s', - $name - ) + 'Trying to access uninstalled module dir: %s', + $name ); } @@ -392,10 +390,8 @@ class Manager { if (!$this->hasLoaded($name)) { throw new ProgrammingError( - sprintf( - 'Cannot access module %s as it hasn\'t been loaded', - $name - ) + 'Cannot access module %s as it hasn\'t been loaded', + $name ); } return $this->loadedModules[$name]; diff --git a/library/Icinga/Cli/Loader.php b/library/Icinga/Cli/Loader.php index ab8064370..11ca2b70b 100644 --- a/library/Icinga/Cli/Loader.php +++ b/library/Icinga/Cli/Loader.php @@ -332,7 +332,8 @@ class Loader { if (! $this->hasModule($module)) { throw new ProgrammingError( - sprintf('There is no such module: %s', $module) + 'There is no such module: %s', + $module ); } } @@ -341,7 +342,8 @@ class Loader { if (! $this->hasCommand($command)) { throw new ProgrammingError( - sprintf('There is no such command: %s', $command) + 'There is no such command: %s', + $command ); } } @@ -351,7 +353,9 @@ class Loader $this->assertModuleExists($module); if (! $this->hasModuleCommand($module, $command)) { throw new ProgrammingError( - sprintf("The module '%s' has no such command: %s", $module, $command) + 'The module \'%s\' has no such command: %s', + $module, + $command ); } } diff --git a/library/Icinga/Data/Filter/Filter.php b/library/Icinga/Data/Filter/Filter.php index dc62e206a..7e995bb59 100644 --- a/library/Icinga/Data/Filter/Filter.php +++ b/library/Icinga/Data/Filter/Filter.php @@ -34,9 +34,12 @@ abstract class Filter if ((string) $id === $this->getId()) { return $this; } - throw new ProgrammingError(sprintf( - 'Trying to get invalid filter index "%s" from "%s" ("%s")', $id, $this, $this->id - )); + throw new ProgrammingError( + 'Trying to get invalid filter index "%s" from "%s" ("%s")', + $id, + $this, + $this->id + ); } public function getId() @@ -136,7 +139,8 @@ abstract class Filter case '<=': return new FilterEqualOrLessThan($col, $op, $expression); case '!=': return new FilterNotEqual($col, $op, $expression); default: throw new ProgrammingError( - sprintf('There is no such filter sign: %s', $op) + 'There is no such filter sign: %s', + $op ); } } @@ -188,7 +192,7 @@ abstract class Filter $args = $args[0]; } } - if (count($args) > 1) { + if (count($args) > 1) { return new FilterNot(array(new FilterAnd($args))); } else { return new FilterNot($args); @@ -203,7 +207,8 @@ abstract class Filter case 'NOT': return self::not($filters); } throw new ProgrammingError( - sprintf('"%s" is not a valid filter chain operator', $operator) + '"%s" is not a valid filter chain operator', + $operator ); } diff --git a/library/Icinga/Data/ResourceFactory.php b/library/Icinga/Data/ResourceFactory.php index b7156bb50..87f99c0e4 100644 --- a/library/Icinga/Data/ResourceFactory.php +++ b/library/Icinga/Data/ResourceFactory.php @@ -78,7 +78,7 @@ class ResourceFactory implements ConfigAwareFactory { if (!isset(self::$resources)) { throw new ProgrammingError( - "The ResourceFactory must be initialised by setting a config, before it can be used" + 'The ResourceFactory must be initialised by setting a config, before it can be used' ); } } diff --git a/library/Icinga/Exception/ProgrammingError.php b/library/Icinga/Exception/ProgrammingError.php index 282d80db0..430d1510f 100644 --- a/library/Icinga/Exception/ProgrammingError.php +++ b/library/Icinga/Exception/ProgrammingError.php @@ -8,6 +8,6 @@ namespace Icinga\Exception; * Class ProgrammingError * @package Icinga\Exception */ -class ProgrammingError extends \Exception +class ProgrammingError extends IcingaException { } diff --git a/library/Icinga/Protocol/Commandpipe/Command.php b/library/Icinga/Protocol/Commandpipe/Command.php index b7332ce33..e89169f35 100644 --- a/library/Icinga/Protocol/Commandpipe/Command.php +++ b/library/Icinga/Protocol/Commandpipe/Command.php @@ -138,7 +138,10 @@ abstract class Command */ public function getHostgroupCommand($hostgroup) { - throw new ProgrammingError(get_class($this) . ' does not provide a hostgroup command'); + throw new ProgrammingError( + '%s does not provide a hostgroup command', + get_class($this) + ); } /** @@ -150,7 +153,10 @@ abstract class Command */ public function getServicegroupCommand($servicegroup) { - throw new ProgrammingError(get_class($this) . ' does not provide a servicegroup command'); + throw new ProgrammingError( + '%s does not provide a servicegroup command', + get_class($this) + ); } /** @@ -163,6 +169,9 @@ abstract class Command */ public function getGlobalCommand($instance = null) { - throw new ProgrammingError(getclass($this) . ' does not provide a global command'); + throw new ProgrammingError( + '%s does not provide a global command', + getclass($this) + ); } } diff --git a/library/Icinga/Util/Format.php b/library/Icinga/Util/Format.php index 0658b2a57..0c69fbde4 100644 --- a/library/Icinga/Util/Format.php +++ b/library/Icinga/Util/Format.php @@ -95,7 +95,10 @@ class Format return '-'; } if (! preg_match('~^\d+$~', $timestamp)) { - throw new ProgrammingError(sprintf('"%s" is not a number', $timestamp)); + throw new ProgrammingError( + '"%s" is not a number', + $timestamp + ); } $prefix = ''; if ($diff < 0) { diff --git a/library/Icinga/Web/Form.php b/library/Icinga/Web/Form.php index d6f07cd3a..65dc7c8d1 100644 --- a/library/Icinga/Web/Form.php +++ b/library/Icinga/Web/Form.php @@ -369,8 +369,8 @@ class Form extends Zend_Form $element->setAttrib('class', $class); } else { throw new ProgrammingError( - 'You need to add the element "' . $elementName . '" to' . - ' the form before automatic submission can be enabled!' + 'You need to add the element "%s" to the form before automatic submission can be enabled!', + $elementName ); } } diff --git a/library/Icinga/Web/Hook.php b/library/Icinga/Web/Hook.php index 2b776daca..76200493a 100644 --- a/library/Icinga/Web/Hook.php +++ b/library/Icinga/Web/Hook.php @@ -117,11 +117,9 @@ class Hook $base_class = self::$BASE_NS . ucfirst($name); if (!$instance instanceof $base_class) { throw new ProgrammingError( - sprintf( - '%s is not an instance of %s', - get_class($instance), - $base_class - ) + '%s is not an instance of %s', + get_class($instance), + $base_class ); } } @@ -185,7 +183,10 @@ class Hook public static function registerClass($name, $key, $class) { if (!class_exists($class)) { - throw new ProgrammingError('"' . $class . '" is not an existing class'); + throw new ProgrammingError( + '"%s" is not an existing class', + $class + ); } if (!isset(self::$hooks[$name])) { @@ -207,7 +208,10 @@ class Hook public static function registerObject($name, $key, $object) { if (!is_object($object)) { - throw new ProgrammingError('"' . $object . '" is not an instantiated class'); + throw new ProgrammingError( + '"%s" is not an instantiated class', + $object + ); } if (!isset(self::$instances[$name])) { diff --git a/library/Icinga/Web/Menu.php b/library/Icinga/Web/Menu.php index d5b7ba882..55bda29b3 100644 --- a/library/Icinga/Web/Menu.php +++ b/library/Icinga/Web/Menu.php @@ -277,7 +277,10 @@ class Menu implements RecursiveIterator public function getSubMenu($id) { if (false === $this->hasSubMenu($id)) { - throw new ProgrammingError('Tried to get invalid sub menu "' . $id . '"'); + throw new ProgrammingError( + 'Tried to get invalid sub menu "%s"', + $id + ); } return $this->subMenus[$id]; diff --git a/library/Icinga/Web/Notification.php b/library/Icinga/Web/Notification.php index 3dd04c615..178a07e0a 100644 --- a/library/Icinga/Web/Notification.php +++ b/library/Icinga/Web/Notification.php @@ -53,10 +53,8 @@ class Notification ) )) { throw new ProgrammingError( - sprintf( - '"%s" is not a valid notification type', - $type - ) + '"%s" is not a valid notification type', + $type ); } diff --git a/library/Icinga/Web/Url.php b/library/Icinga/Web/Url.php index ed3acf6a7..9f0294c3c 100644 --- a/library/Icinga/Web/Url.php +++ b/library/Icinga/Web/Url.php @@ -120,7 +120,10 @@ class Url } if (!is_string($url)) { - throw new ProgrammingError(sprintf('url "%s" is not a string', $url)); + throw new ProgrammingError( + 'url "%s" is not a string', + $url + ); } $urlObject = new Url(); diff --git a/library/Icinga/Web/View.php b/library/Icinga/Web/View.php index b74bca41c..22e8e6fbd 100644 --- a/library/Icinga/Web/View.php +++ b/library/Icinga/Web/View.php @@ -103,10 +103,8 @@ class View extends Zend_View_Abstract { if ($this->hasHelperFunction($name)) { throw new ProgrammingError( - sprintf( - 'Cannot assign the same helper function twice: "%s"', - $name - ) + 'Cannot assign the same helper function twice: "%s"', + $name ); } diff --git a/library/Icinga/Web/View/helpers/url.php b/library/Icinga/Web/View/helpers/url.php index 14b741e78..2fca99098 100644 --- a/library/Icinga/Web/View/helpers/url.php +++ b/library/Icinga/Web/View/helpers/url.php @@ -94,10 +94,10 @@ $this->addHelperFunction('attributeToString', function ($key, $value) { // TODO: Doublecheck this! if (! preg_match('~^[a-zA-Z0-9-]+$~', $key)) { - throw new ProgrammingError(sprintf( + throw new ProgrammingError( 'Trying to set an invalid HTML attribute name: %s', $key - )); + ); } return sprintf( diff --git a/library/Icinga/Web/Widget.php b/library/Icinga/Web/Widget.php index 4bb177341..b181a49ea 100644 --- a/library/Icinga/Web/Widget.php +++ b/library/Icinga/Web/Widget.php @@ -38,10 +38,8 @@ class Widget if (! class_exists($class)) { throw new ProgrammingError( - sprintf( - 'There is no such widget: %s', - $name - ) + 'There is no such widget: %s', + $name ); } diff --git a/library/Icinga/Web/Widget/AbstractWidget.php b/library/Icinga/Web/Widget/AbstractWidget.php index 37fb7ad36..fe4d2434d 100644 --- a/library/Icinga/Web/Widget/AbstractWidget.php +++ b/library/Icinga/Web/Widget/AbstractWidget.php @@ -52,11 +52,9 @@ abstract class AbstractWidget } throw new ProgrammingError( - sprintf( - 'Trying to get invalid "%s" property for %s', - $key, - get_class($this) - ) + 'Trying to get invalid "%s" property for %s', + $key, + get_class($this) ); } @@ -78,14 +76,12 @@ abstract class AbstractWidget } throw new ProgrammingError( - sprintf( - 'Trying to set invalid "%s" property in %s. Allowed are: %s', - $key, - get_class($this), - empty($this->properties) + 'Trying to set invalid "%s" property in %s. Allowed are: %s', + $key, + get_class($this), + empty($this->properties) ? 'none' : implode(', ', array_keys($this->properties)) - ) ); } diff --git a/library/Icinga/Web/Widget/Dashboard.php b/library/Icinga/Web/Widget/Dashboard.php index c87afa1ab..5ae6896d8 100644 --- a/library/Icinga/Web/Widget/Dashboard.php +++ b/library/Icinga/Web/Widget/Dashboard.php @@ -224,7 +224,8 @@ class Dashboard extends AbstractWidget { if (! array_key_exists($name, $this->panes)) { throw new ProgrammingError( - sprintf('Trying to retrieve invalid dashboard pane "%s"', $name) + 'Trying to retrieve invalid dashboard pane "%s"', + $name ); } return $this->panes[$name]; diff --git a/library/Icinga/Web/Widget/Dashboard/Pane.php b/library/Icinga/Web/Widget/Dashboard/Pane.php index 05d121385..2390b5e4f 100644 --- a/library/Icinga/Web/Widget/Dashboard/Pane.php +++ b/library/Icinga/Web/Widget/Dashboard/Pane.php @@ -105,7 +105,10 @@ class Pane extends AbstractWidget if ($this->hasComponent($title)) { return $this->components[$title]; } - throw new ProgrammingError(sprintf('Trying to access invalid component: %s', $title)); + throw new ProgrammingError( + 'Trying to access invalid component: %s', + $title + ); } /** diff --git a/library/Icinga/Web/Widget/Tabs.php b/library/Icinga/Web/Widget/Tabs.php index cd480ba32..716d5a959 100644 --- a/library/Icinga/Web/Widget/Tabs.php +++ b/library/Icinga/Web/Widget/Tabs.php @@ -154,10 +154,8 @@ EOT; { if ($this->has($name)) { throw new ProgrammingError( - sprintf( - 'Cannot add a tab named "%s" twice"', - $name - ) + 'Cannot add a tab named "%s" twice"', + $name ); } return $this->set($name, $tab); diff --git a/modules/monitoring/library/Monitoring/Backend.php b/modules/monitoring/library/Monitoring/Backend.php index 8131e7c1c..e10c70d4e 100644 --- a/modules/monitoring/library/Monitoring/Backend.php +++ b/modules/monitoring/library/Monitoring/Backend.php @@ -148,7 +148,10 @@ public function getResource() { $viewClass = '\\Icinga\\Module\\Monitoring\\DataView\\' . ucfirst($viewName); if (!class_exists($viewClass)) { - throw new ProgrammingError('DataView ' . ucfirst($viewName) . ' does not exist'); + throw new ProgrammingError( + 'DataView %s does not exist', + ucfirst($viewName) + ); } return $viewClass; } @@ -175,7 +178,9 @@ public function getResource() . 'Query'; if (!class_exists($queryClass)) { throw new ProgrammingError( - 'Query "' . ucfirst($queryName) . '" does not exist for backend ' . ucfirst($this->type) + 'Query "%s" does not exist for backend %s', + ucfirst($queryName), + ucfirst($this->type) ); } return $queryClass; diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php index f0f927487..df7118fe0 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php @@ -442,7 +442,11 @@ abstract class IdoQuery extends DbQuery } elseif ($this->isCustomVar($alias)) { $this->requireCustomvar($alias); } else { - throw new ProgrammingError(sprintf('%s : Got invalid column: %s', get_called_class(), $alias)); + throw new ProgrammingError( + '%s : Got invalid column: %s', + get_called_class(), + $alias + ); } return $this; } @@ -476,7 +480,8 @@ abstract class IdoQuery extends DbQuery { if ($this->hasJoinedVirtualTable($name)) { throw new ProgrammingError( - sprintf('IDO query virtual table conflict with "%s"', $name) + 'IDO query virtual table conflict with "%s"', + $name ); } return $this; @@ -499,10 +504,8 @@ abstract class IdoQuery extends DbQuery $this->$func(); } else { throw new ProgrammingError( - sprintf( - 'Cannot join "%s", no such table found', - $table - ) + 'Cannot join "%s", no such table found', + $table ); } $this->joinedVirtualTables[$table] = true; @@ -581,10 +584,8 @@ abstract class IdoQuery extends DbQuery // TODO: Improve this: if (! preg_match('~^_(host|service)_([a-zA-Z0-9_]+)$~', $customvar, $m)) { throw new ProgrammingError( - sprintf( - 'Got invalid custom var: "%s"', - $customvar - ) + 'Got invalid custom var: "%s"', + $customvar ); } return array($m[1], $m[2]); diff --git a/modules/monitoring/library/Monitoring/Timeline/TimeEntry.php b/modules/monitoring/library/Monitoring/Timeline/TimeEntry.php index 7a91bfc85..615999bdb 100644 --- a/modules/monitoring/library/Monitoring/Timeline/TimeEntry.php +++ b/modules/monitoring/library/Monitoring/Timeline/TimeEntry.php @@ -79,7 +79,9 @@ class TimeEntry $entry->{$methodName}($value); } else { throw new ProgrammingError( - 'Method "' . $methodName . '" does not exist on object of type "' . __CLASS__ . '"' + 'Method "%s" does not exist on object of type "%s"', + $methodName, + __CLASS__ ); } }