From 9c12ab4812459b9d9144c65bd0cc9b83d27b6581 Mon Sep 17 00:00:00 2001 From: sgiehl <stefan@piwik.org> Date: Wed, 31 Jul 2013 21:51:48 +0200 Subject: [PATCH] refs #3741 fixing some namespaces --- core/API/ResponseBuilder.php | 2 +- core/Access.php | 8 ++--- core/Common.php | 2 +- core/DataTable/Map.php | 15 +++++----- core/DataTable/Row.php | 2 +- core/Db.php | 12 ++++---- core/FrontController.php | 4 +-- core/JqplotDataGenerator.php | 5 ++-- core/Plugin/MetadataLoader.php | 2 +- core/PluginsManager.php | 41 ++++++++++++++------------ core/ScheduledTime.php | 2 +- core/ScheduledTime/Daily.php | 2 +- core/ScheduledTime/Hourly.php | 2 +- core/ScheduledTime/Monthly.php | 2 +- core/ScheduledTime/Weekly.php | 2 +- core/ViewDataTable.php | 30 +++++++++---------- core/ViewDataTable/HtmlTable/Goals.php | 5 ++-- core/ViewDataTable/Properties.php | 2 +- core/Visualization/Cloud.php | 6 ++-- core/Visualization/JqplotGraph.php | 5 ++-- 20 files changed, 79 insertions(+), 72 deletions(-) diff --git a/core/API/ResponseBuilder.php b/core/API/ResponseBuilder.php index 512339ee62..e4db39b6d8 100644 --- a/core/API/ResponseBuilder.php +++ b/core/API/ResponseBuilder.php @@ -53,7 +53,7 @@ class ResponseBuilder * in the URL. For example to offset,limit the Table you can add the following parameters to any API * call that returns a DataTable: filter_limit=10&filter_offset=20 * - we apply the filters that have been previously queued on the DataTable - * @see Piwik_DataTable::queueFilter() + * @see DataTable::queueFilter() * - we apply the renderer that generate the DataTable in a given format (XML, PHP, HTML, JSON, etc.) * the format can be changed using the 'format' parameter in the request. * Example: format=xml diff --git a/core/Access.php b/core/Access.php index 7c0d265024..80922e30a2 100644 --- a/core/Access.php +++ b/core/Access.php @@ -103,9 +103,9 @@ class Access private static $availableAccess = array('noaccess', 'view', 'admin', 'superuser'); /** - * Authentification object (see Piwik_Auth) + * Authentification object (see Auth) * - * @var Piwik_Auth + * @var Auth */ private $auth = null; @@ -141,7 +141,7 @@ class Access * If the login/password is correct the user is either the SuperUser or a normal user. * We load the access levels for this user for all the websites. * - * @param null|Piwik_Auth $auth Auth adapter + * @param null|Auth $auth Auth adapter * @return bool true on success, false if reloading access failed (when auth object wasn't specified and user is not enforced to be Super User) */ public function reloadAccess(Auth $auth = null) @@ -150,7 +150,7 @@ class Access $this->auth = $auth; } - // if the Piwik_Auth wasn't set, we may be in the special case of setSuperUser(), otherwise we fail + // if the Auth wasn't set, we may be in the special case of setSuperUser(), otherwise we fail if (is_null($this->auth)) { if ($this->isSuperUser()) { return $this->reloadAccessSuperUser(); diff --git a/core/Common.php b/core/Common.php index d947fc6fd7..d80fc99b7c 100644 --- a/core/Common.php +++ b/core/Common.php @@ -775,7 +775,7 @@ class Common * This is a backward compatibility function for code that only expects * IPv4 addresses (i.e., doesn't support IPv6). * - * @see Piwik_IP::N2P() + * @see IP::N2P() * * This function does not support the long (or its string representation) * returned by the built-in ip2long() function, from Piwik 1.3 and earlier. diff --git a/core/DataTable/Map.php b/core/DataTable/Map.php index 538e824b7a..76a2c642f8 100644 --- a/core/DataTable/Map.php +++ b/core/DataTable/Map.php @@ -10,6 +10,7 @@ */ namespace Piwik\DataTable; use Piwik\DataTable; +use Piwik\DataTable\Renderer\Console; /** * The DataTable_Array is a way to store an array of dataTable. @@ -162,13 +163,13 @@ class Map */ public function __toString() { - $renderer = new Piwik_DataTable_Renderer_Console(); + $renderer = new Console(); $renderer->setTable($this); return (string)$renderer; } /** - * @see Piwik_DataTable::enableRecursiveSort() + * @see DataTable::enableRecursiveSort() */ public function enableRecursiveSort() { @@ -180,7 +181,7 @@ class Map /** * Renames the given column * - * @see Piwik_DataTable::renameColumn + * @see DataTable::renameColumn * @param string $oldName * @param string $newName */ @@ -194,7 +195,7 @@ class Map /** * Deletes the given columns * - * @see Piwik_DataTable::deleteColumns + * @see DataTable::deleteColumns * @param array $columns */ public function deleteColumns($columns) @@ -214,7 +215,7 @@ class Map /** * Deletes the given column * - * @see Piwik_DataTable::deleteColumn + * @see DataTable::deleteColumn * @param string $column */ public function deleteColumn($column) @@ -364,7 +365,7 @@ class Map * Returns a new DataTable_Array w/ child tables that have had their * subtables merged. * - * @see Piwik_DataTable::mergeSubtables + * @see DataTable::mergeSubtables * * @return Set */ @@ -409,7 +410,7 @@ class Map } /** - * @see Piwik_DataTable::getColumns() + * @see DataTable::getColumns() * * @return array */ diff --git a/core/DataTable/Row.php b/core/DataTable/Row.php index 841ff5f5d6..3b4a0d6df9 100644 --- a/core/DataTable/Row.php +++ b/core/DataTable/Row.php @@ -277,7 +277,7 @@ class Row * Then we add the values of the given DataTable to this row's DataTable. * * @param DataTable $subTable Table to sum to this row's subDatatable - * @see Piwik_DataTable::addDataTable() for the algorithm used for the sum + * @see DataTable::addDataTable() for the algorithm used for the sum */ public function sumSubtable(DataTable $subTable) { diff --git a/core/Db.php b/core/Db.php index 3b9c8132e5..a1dc835dd8 100644 --- a/core/Db.php +++ b/core/Db.php @@ -22,7 +22,7 @@ class Db /** * Returns the database adapter to use * - * @return Piwik_Tracker_Db|AdapterInterface + * @return \Piwik\Tracker\Db|AdapterInterface */ static private function getDb() { @@ -62,7 +62,7 @@ class Db * * @param string $sql SQL Query * @param array $parameters Parameters to bind in the query, array( param1 => value1, param2 => value2) - * @return Zend_Db_Statement + * @return \Zend_Db_Statement */ static public function query($sql, $parameters = array()) { @@ -146,7 +146,7 @@ class Db * Runs an OPTIMIZE TABLE query on the supplied table or tables. The table names must be prefixed. * * @param string|array $tables The name of the table to optimize or an array of tables to optimize. - * @return Zend_Db_Statement + * @return \Zend_Db_Statement */ static public function optimizeTables($tables) { @@ -184,7 +184,7 @@ class Db * Drops the supplied table or tables. The table names must be prefixed. * * @param string|array $tables The name of the table to drop or an array of table names to drop. - * @return Zend_Db_Statement + * @return \Zend_Db_Statement */ static public function dropTables($tables) { @@ -200,7 +200,7 @@ class Db * * @param string|array $tablesToRead The table or tables to obtain 'read' locks on. * @param string|array $tablesToWrite The table or tables to obtain 'write' locks on. - * @return Zend_Db_Statement + * @return \Zend_Db_Statement */ static public function lockTables($tablesToRead, $tablesToWrite = array()) { @@ -225,7 +225,7 @@ class Db /** * Releases all table locks. * - * @return Zend_Db_Statement + * @return \Zend_Db_Statement */ static public function unlockAllTables() { diff --git a/core/FrontController.php b/core/FrontController.php index 1e9e1ff681..6bc267e319 100644 --- a/core/FrontController.php +++ b/core/FrontController.php @@ -56,7 +56,7 @@ class FrontController /** * Dispatches the request to the right plugin and executes the requested action on the plugin controller. * - * @throws Exception|Piwik_FrontController_PluginDeactivatedException in case the plugin doesn't exist, the action doesn't exist, there is not enough permission, etc. + * @throws Exception|\Piwik\PluginDeactivatedException in case the plugin doesn't exist, the action doesn't exist, there is not enough permission, etc. * * @param string $module * @param string $action @@ -94,7 +94,7 @@ class FrontController } if (!\Piwik\PluginsManager::getInstance()->isPluginActivated($module)) { - throw new Piwik_FrontController_PluginDeactivatedException($module); + throw new PluginDeactivatedException($module); } $controllerClassName = 'Piwik_' . $module . '_Controller'; diff --git a/core/JqplotDataGenerator.php b/core/JqplotDataGenerator.php index 7deaa34c9b..a3c6ce5fd4 100644 --- a/core/JqplotDataGenerator.php +++ b/core/JqplotDataGenerator.php @@ -34,7 +34,7 @@ class JqplotDataGenerator /** * This object does most of the work in generating the JQPlot JSON data. * - * @var Piwik_Visualization + * @var \Piwik\Visualization\ */ protected $visualization; @@ -43,6 +43,7 @@ class JqplotDataGenerator * * @param string $type 'pie', 'bar', or 'evolution' * @param array $properties The view properties. + * @throws \Exception * @return \Piwik\JqplotDataGenerator */ public static function factory($type, $properties) @@ -64,7 +65,7 @@ class JqplotDataGenerator /** * Constructor. * - * @param Piwik_Visualization $visualization + * @param \Piwik\Visualization\ $visualization * @param array $properties */ public function __construct($visualization, $properties) diff --git a/core/Plugin/MetadataLoader.php b/core/Plugin/MetadataLoader.php index e0f198a505..6cec2615c4 100644 --- a/core/Plugin/MetadataLoader.php +++ b/core/Plugin/MetadataLoader.php @@ -45,7 +45,7 @@ class MetadataLoader } /** - * Loads plugin metadata. @see Piwik_Plugin::getInformation. + * Loads plugin metadata. @see Plugin::getInformation. * * @return array */ diff --git a/core/PluginsManager.php b/core/PluginsManager.php index f11698f202..0626db36a3 100644 --- a/core/PluginsManager.php +++ b/core/PluginsManager.php @@ -186,14 +186,16 @@ class PluginsManager * Only deactivated plugins can be uninstalled * * @param $pluginName + * @throws \Exception + * @return bool */ public function uninstallPlugin($pluginName) { if($this->isPluginActivated($pluginName)) { - throw new Exception("To uninstall the plugin $pluginName, first disable it in Piwik > Settings > Plugins"); + throw new \Exception("To uninstall the plugin $pluginName, first disable it in Piwik > Settings > Plugins"); } if(!$this->isPluginInFilesystem($pluginName)) { - throw new Exception("You are trying to uninstall the plugin $pluginName but it was not found in the directory piwik/plugins/"); + throw new \Exception("You are trying to uninstall the plugin $pluginName but it was not found in the directory piwik/plugins/"); } self::deletePluginFromFilesystem($pluginName); if($this->isPluginInFilesystem($pluginName)) { @@ -211,7 +213,8 @@ class PluginsManager * Deactivate plugin * * @param string $pluginName Name of plugin - * @param array $plugins Array of plugin names + * @param array|bool $plugins Array of plugin names + * @return array|bool */ public function deactivatePlugin($pluginName, $plugins = false) { @@ -253,7 +256,7 @@ class PluginsManager foreach ($this->getLoadedPlugins() as $plugin) { try { $this->installPluginIfNecessary($plugin); - } catch (Exception $e) { + } catch (\Exception $e) { echo $e->getMessage(); } } @@ -263,13 +266,13 @@ class PluginsManager * Activate the specified plugin and install (if needed) * * @param string $pluginName Name of plugin - * @throws Exception + * @throws \Exception */ public function activatePlugin($pluginName) { $plugins = Config::getInstance()->Plugins['Plugins']; if (in_array($pluginName, $plugins)) { - throw new Exception("Plugin '$pluginName' already activated."); + throw new \Exception("Plugin '$pluginName' already activated."); } if (!$this->isPluginInFilesystem($pluginName)) { @@ -422,13 +425,13 @@ class PluginsManager * Returns the given Plugin object * * @param string $name - * @throws Exception + * @throws \Exception * @return array */ public function getLoadedPlugin($name) { if (!isset($this->loadedPlugins[$name])) { - throw new Exception("The plugin '$name' has not been loaded."); + throw new \Exception("The plugin '$name' has not been loaded."); } return $this->loadedPlugins[$name]; } @@ -460,8 +463,8 @@ class PluginsManager * Do NOT give the class name ie. Piwik_UserCountry, but give the plugin name ie. UserCountry * * @param string $pluginName - * @throws Exception - * @return Piwik_Plugin|null + * @throws \Exception + * @return Plugin|null */ public function loadPlugin($pluginName) { @@ -479,8 +482,8 @@ class PluginsManager /** * @param $pluginName - * @return Piwik_Plugin - * @throws Exception + * @return Plugin + * @throws \Exception */ protected function makePluginClass($pluginName) { @@ -488,7 +491,7 @@ class PluginsManager $pluginClassName = sprintf('Piwik_%s', $pluginName); if (!Common::isValidFilename($pluginName)) { - throw new Exception(sprintf("The plugin filename '%s' is not a valid filename", $pluginFileName)); + throw new \Exception(sprintf("The plugin filename '%s' is not a valid filename", $pluginFileName)); } $path = self::getPluginsDirectory() . $pluginFileName; @@ -515,8 +518,8 @@ class PluginsManager /** * Unload plugin * - * @param Piwik_Plugin|string $plugin - * @throws Exception + * @param Plugin|string $plugin + * @throws \Exception */ public function unloadPlugin($plugin) { @@ -558,14 +561,14 @@ class PluginsManager * Install a specific plugin * * @param Plugin $plugin - * @throws Piwik_PluginsManager_PluginException if installation fails + * @throws PluginsManager_PluginException if installation fails */ private function installPlugin(Plugin $plugin) { try { $plugin->install(); - } catch (Exception $e) { - throw new Piwik_PluginsManager_PluginException($plugin->getPluginName(), $e->getMessage()); + } catch (\Exception $e) { + throw new PluginsManager_PluginException($plugin->getPluginName(), $e->getMessage()); } } @@ -585,7 +588,7 @@ class PluginsManager * * @param Plugin $plugin * @param string $langCode - * @throws Exception + * @throws \Exception * @return bool whether the translation was found and loaded */ private function loadTranslation($plugin, $langCode) diff --git a/core/ScheduledTime.php b/core/ScheduledTime.php index a2dd0bb7e5..af6c82c946 100644 --- a/core/ScheduledTime.php +++ b/core/ScheduledTime.php @@ -20,7 +20,7 @@ use Piwik\ScheduledTime\Weekly; * The ScheduledTime abstract class is used as a base class for different types of scheduling intervals. * ScheduledTime subclasses are used to schedule tasks within Piwik. * - * @see Piwik_ScheduledTask + * @see \Piwik\ScheduledTask * @package Piwik * @subpackage ScheduledTime */ diff --git a/core/ScheduledTime/Daily.php b/core/ScheduledTime/Daily.php index 83fe3ecfe8..af6a6e4f4f 100644 --- a/core/ScheduledTime/Daily.php +++ b/core/ScheduledTime/Daily.php @@ -16,7 +16,7 @@ use Piwik\ScheduledTime; /** * Daily class is used to schedule tasks every day. * - * @see Piwik_ScheduledTask + * @see ScheduledTask * @package Piwik * @subpackage ScheduledTime */ diff --git a/core/ScheduledTime/Hourly.php b/core/ScheduledTime/Hourly.php index 102359be86..70a62bb757 100644 --- a/core/ScheduledTime/Hourly.php +++ b/core/ScheduledTime/Hourly.php @@ -16,7 +16,7 @@ use Piwik\ScheduledTime; /** * Hourly class is used to schedule tasks every hour. * - * @see Piwik_ScheduledTask + * @see ScheduledTask * @package Piwik * @subpackage ScheduledTime */ diff --git a/core/ScheduledTime/Monthly.php b/core/ScheduledTime/Monthly.php index d4e3335867..2606dc5cce 100644 --- a/core/ScheduledTime/Monthly.php +++ b/core/ScheduledTime/Monthly.php @@ -16,7 +16,7 @@ use Piwik\ScheduledTime; /** * Monthly class is used to schedule tasks every month. * - * @see Piwik_ScheduledTask + * @see ScheduledTask * @package Piwik * @subpackage ScheduledTime */ diff --git a/core/ScheduledTime/Weekly.php b/core/ScheduledTime/Weekly.php index 497ca75d7e..40b348c153 100644 --- a/core/ScheduledTime/Weekly.php +++ b/core/ScheduledTime/Weekly.php @@ -16,7 +16,7 @@ use Piwik\ScheduledTime; /** * Weekly class is used to schedule tasks every week. * - * @see Piwik_ScheduledTask + * @see ScheduledTask * @package Piwik * @subpackage ScheduledTime */ diff --git a/core/ViewDataTable.php b/core/ViewDataTable.php index 1c311a87eb..8e457467d9 100644 --- a/core/ViewDataTable.php +++ b/core/ViewDataTable.php @@ -50,7 +50,7 @@ use Piwik_API_API; * } * </pre> * - * @see Piwik_ViewDataTable_Properties for core DataTable display properties. + * @see \Piwik\ViewDataTable\Properties - for core DataTable display properties. * @see factory() for all the available output (cloud tags, html table, pie chart, vertical bar chart) * @package Piwik * @subpackage ViewDataTable @@ -244,7 +244,7 @@ abstract class ViewDataTable * @param string $defaultType Any of these: table, cloud, graphPie, graphVerticalBar, graphEvolution, sparkline, generateDataChart* * @param string|bool $apiAction * @param string|bool $controllerAction - * @return Piwik_ViewDataTable + * @return ViewDataTable */ static public function factory($defaultType = null, $apiAction = false, $controllerAction = false) { @@ -447,13 +447,13 @@ abstract class ViewDataTable * Returns the View_Interface. * You can then call render() on this object. * - * @return Piwik_View_Interface - * @throws exception if the view object was not created + * @return View\Interface + * @throws \Exception if the view object was not created */ public function getView() { if (is_null($this->view)) { - throw new Exception('The $this->view object has not been created. + throw new \Exception('The $this->view object has not been created. It should be created in the main() method of the ViewDataTable_* subclass you are using.'); } return $this->view; @@ -483,12 +483,12 @@ abstract class ViewDataTable * Returns the DataTable loaded from the API * * @return DataTable - * @throws exception if not yet defined + * @throws \Exception if not yet defined */ public function getDataTable() { if (is_null($this->dataTable)) { - throw new Exception("The DataTable object has not yet been created"); + throw new \Exception("The DataTable object has not yet been created"); } return $this->dataTable; } @@ -597,7 +597,7 @@ abstract class ViewDataTable /** * Checks that the API returned a normal DataTable (as opposed to DataTable_Array) - * @throws Exception + * @throws \Exception * @return void */ protected function checkStandardDataTable() @@ -1194,8 +1194,8 @@ abstract class ViewDataTable /** * Sets the value to use for the Exclude low population filter. * - * @param int|float If a row value is less than this value, it will be removed from the dataTable - * @param string The name of the column for which we compare the value to $minValue + * @param int|float $columnName If a row value is less than this value, it will be removed from the dataTable + * @param string $minValue The name of the column for which we compare the value to $minValue */ public function setExcludeLowPopulation($columnName = null, $minValue = null) { @@ -1267,7 +1267,7 @@ abstract class ViewDataTable * * @param string $columnName column name * @param string $columnTranslation column name translation - * @throws Exception + * @throws \Exception */ public function setColumnTranslation($columnName, $columnTranslation) { @@ -1386,7 +1386,6 @@ abstract class ViewDataTable * Returns columns names to display, in order. * If no columns were specified to be displayed, return all columns found in the first row. * If the data table has empty_columns meta data set, those columns will be removed. - * @param array PHP array conversion of the data table * @return array */ public function getColumnsToDisplay() @@ -1460,12 +1459,12 @@ abstract class ViewDataTable * * @param string $parameter name * @param mixed $value - * @throws Exception + * @throws \Exception */ public function setCustomParameter($parameter, $value) { if (isset($this->viewProperties['custom_parameters'][$parameter])) { - throw new Exception("$parameter is already defined for this DataTable."); + throw new \Exception("$parameter is already defined for this DataTable."); } $this->viewProperties['custom_parameters'][$parameter] = $value; } @@ -1632,13 +1631,14 @@ abstract class ViewDataTable * @param string $pluginName The name of the plugin (eg, UserSettings). * @param string $apiAction The name of the API action (eg, getResolution). * @param bool $fetch If true, the result is returned, if false it is echo'd. + * @throws \Exception * @return string|null See $fetch. */ static public function renderReport($pluginName, $apiAction, $fetch = true) { $apiClassName = 'Piwik_' . $pluginName . '_API'; if (!method_exists($apiClassName::getInstance(), $apiAction)) { - throw new Exception("Invalid action name '$apiAction' for '$pluginName' plugin."); + throw new \Exception("Invalid action name '$apiAction' for '$pluginName' plugin."); } $view = self::factory(null, $pluginName.'.'.$apiAction); diff --git a/core/ViewDataTable/HtmlTable/Goals.php b/core/ViewDataTable/HtmlTable/Goals.php index af4f3cedd0..a85d0d7ccf 100644 --- a/core/ViewDataTable/HtmlTable/Goals.php +++ b/core/ViewDataTable/HtmlTable/Goals.php @@ -10,12 +10,11 @@ */ namespace Piwik\ViewDataTable\HtmlTable; -use Piwik\DataTable\Filter\AddColumnsProcessedMetricsGoal; use Piwik\Piwik; use Piwik\Common; use Piwik\Site; use Piwik\ViewDataTable\HtmlTable; -use Piwik_DataTable_Filter_AddColumnsProcessedMetricsGoal; +use Piwik\DataTable\Filter\AddColumnsProcessedMetricsGoal; use Piwik_Goals_API; /** @@ -39,7 +38,7 @@ class Goals extends HtmlTable } $this->idSite = Common::getRequestVar('idSite', null, 'int'); - $this->processOnlyIdGoal = Common::getRequestVar('idGoal', \Piwik\DataTable\Filter\AddColumnsProcessedMetricsGoal::GOALS_OVERVIEW, 'string'); + $this->processOnlyIdGoal = Common::getRequestVar('idGoal', AddColumnsProcessedMetricsGoal::GOALS_OVERVIEW, 'string'); $this->isEcommerce = $this->processOnlyIdGoal == Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER; $this->viewProperties['show_exclude_low_population'] = true; $this->viewProperties['show_goals'] = true; diff --git a/core/ViewDataTable/Properties.php b/core/ViewDataTable/Properties.php index 5c4c7e1fd4..dbca5408d1 100644 --- a/core/ViewDataTable/Properties.php +++ b/core/ViewDataTable/Properties.php @@ -17,7 +17,7 @@ use ReflectionClass; /** * Contains the list of all core DataTable display properties for use with ViewDataTable. * - * @see Piwik_ViewDataTable for more info. + * @see ViewDataTable - for more info. * * TODO: change the names of properties to match the const names where appropriate. */ diff --git a/core/Visualization/Cloud.php b/core/Visualization/Cloud.php index 8ea132f7aa..931ada572c 100644 --- a/core/Visualization/Cloud.php +++ b/core/Visualization/Cloud.php @@ -12,7 +12,7 @@ namespace Piwik\Visualization; use Piwik\Common; use Piwik\View; -use Piwik_DataTable; +use Piwik\DataTable; /** * Generates a tag cloud from a given data array. @@ -49,7 +49,9 @@ class Cloud /** * Renders this visualization. * - * @param Piwik_DataTable $dataTable + * @param DataTable $dataTable + * @param array $properties + * @return string */ public function render($dataTable, $properties) { diff --git a/core/Visualization/JqplotGraph.php b/core/Visualization/JqplotGraph.php index 6368880d7c..fc2cd9e6cb 100644 --- a/core/Visualization/JqplotGraph.php +++ b/core/Visualization/JqplotGraph.php @@ -13,7 +13,7 @@ namespace Piwik\Visualization; use Piwik\View; use Piwik\JqplotDataGenerator; -use Piwik_DataTable; +use Piwik\DataTable; /** * DataTable visualization that displays DataTable data in a JQPlot graph. @@ -23,8 +23,9 @@ class JqplotGraph /** * Renders this visualization. * - * @param Piwik_DataTable $dataTable + * @param DataTable $dataTable * @param array $properties View Properties. + * @return string */ public function render($dataTable, $properties) { -- GitLab