Skip to content

Commit

Permalink
Applying phpstorm code style PSR refs matomo-org#3771
Browse files Browse the repository at this point in the history
  • Loading branch information
mattab committed Oct 8, 2013
1 parent 1fa8da9 commit 84eba85
Show file tree
Hide file tree
Showing 98 changed files with 828 additions and 809 deletions.
4 changes: 3 additions & 1 deletion plugins/API/API.php
Expand Up @@ -156,7 +156,9 @@ public function getSegmentsMetadata($idSites = array(), $_hideImplementationData
'segment' => 'visitorType',
'acceptedValues' => 'new, returning, returningCustomer' . ". " . Piwik_Translate('General_VisitTypeExample', '"&segment=visitorType==returning,visitorType==returningCustomer"'),
'sqlSegment' => 'log_visit.visitor_returning',
'sqlFilter' => function($type) { return $type == "new" ? 0 : ($type == "returning" ? 1 : 2); }
'sqlFilter' => function ($type) {
return $type == "new" ? 0 : ($type == "returning" ? 1 : 2);
}
);
$segments[] = array(
'type' => 'metric',
Expand Down
14 changes: 7 additions & 7 deletions plugins/API/RowEvolution.php
Expand Up @@ -79,7 +79,7 @@ public function getRowEvolution($idSite, $period, $date, $apiModule, $apiAction,
}

/**
* @param array $labels
* @param array $labels
* @param DataTable\Map $dataTable
* @return mixed
*/
Expand All @@ -99,8 +99,8 @@ protected function enrichRowAddMetadataLabelIndex($labels, $dataTable)
}

/**
* @param DataTable\Map $dataTable
* @param array $labels
* @param DataTable\Map $dataTable
* @param array $labels
* @return array
*/
protected function getLabelsFromDataTable($dataTable, $labels)
Expand Down Expand Up @@ -186,10 +186,10 @@ private function getSingleRowEvolution($dataTable, $metadata, $apiModule, $apiAc
}

/**
* @param Row $row
* @param string $apiModule
* @param string $apiAction
* @param bool $labelUseAbsoluteUrl
* @param Row $row
* @param string $apiModule
* @param string $apiAction
* @param bool $labelUseAbsoluteUrl
* @return bool|string
*/
private function getRowUrlForEvolutionLabel($row, $apiModule, $apiAction, $labelUseAbsoluteUrl)
Expand Down
22 changes: 13 additions & 9 deletions plugins/Actions/API.php
Expand Up @@ -15,11 +15,11 @@
use Piwik\Common;
use Piwik\DataTable;
use Piwik\Date;
use Piwik\Metrics;

use Piwik\Metrics;
use Piwik\Piwik;
use Piwik\Plugins\CustomVariables\API as APICustomVariables;

use Piwik\Plugins\CustomVariables\API as APICustomVariables;
use Piwik\Tracker\Action;

/**
Expand Down Expand Up @@ -119,11 +119,11 @@ public function get($idSite, $period, $date, $segment = false, $columns = false)
}

/**
* @param int $idSite
* @param string $period
* @param Date $date
* @param bool $segment
* @param bool $expanded
* @param int $idSite
* @param string $period
* @param Date $date
* @param bool $segment
* @param bool $expanded
* @param bool|int $idSubtable
* @param bool|int $depth
*
Expand Down Expand Up @@ -181,7 +181,9 @@ protected function keepPagesFollowingSearch($dataTable)
// Keep only pages which are following site search
$dataTable->filter('ColumnCallbackDeleteRow', array(
'nb_hits_following_search',
function($value) { return $value > 0; }
function ($value) {
return $value > 0;
}
));
}

Expand Down Expand Up @@ -321,7 +323,9 @@ public function getSiteSearchNoResultKeywords($idSite, $period, $date, $segment
$dataTable->filter('ColumnCallbackDeleteRow',
array(
Metrics::INDEX_SITE_SEARCH_HAS_NO_RESULT,
function($value) { return $value >= 1; }
function ($value) {
return $value >= 1;
}
));
$dataTable->deleteRow(DataTable::ID_SUMMARY_ROW);
$dataTable->deleteColumn(Metrics::INDEX_SITE_SEARCH_HAS_NO_RESULT);
Expand Down
16 changes: 8 additions & 8 deletions plugins/Actions/Actions.php
Expand Up @@ -54,7 +54,7 @@ public function __construct()
public function getListHooksRegistered()
{
$hooks = array(
'ArchiveProcessor.Day.compute' => 'archiveDay',
'ArchiveProcessor.Day.compute' => 'archiveDay',
'ArchiveProcessor.Period.compute' => 'archivePeriod',
'WidgetsList.addWidgets' => 'addWidgets',
'Menu.Reporting.addItems' => 'addMenus',
Expand All @@ -76,7 +76,7 @@ public function getJsFiles(&$jsFiles)
{
$jsFiles[] = "plugins/Actions/javascripts/actionsDataTable.js";
}

public function getSegmentsMetadata(&$segments)
{
$sqlFilter = array($this, 'getIdActionFromSegment');
Expand Down Expand Up @@ -673,7 +673,7 @@ private function addBaseDisplayProperties(&$result)

if (ViewDataTable::shouldLoadExpanded()) {
$result['visualization_properties']['table']['show_expanded'] = true;

$result['filters'][] = function ($dataTable) {
Actions::setDataTableRowLevels($dataTable);
};
Expand Down Expand Up @@ -876,17 +876,17 @@ public function getDisplayPropertiesForSiteSearchNoResultKeywords()
public function getDisplayPropertiesForSiteSearchCategories()
{
return array(
'translations' => array(
'translations' => array(
'label' => Piwik_Translate('Actions_ColumnSearchCategory'),
'nb_visits' => Piwik_Translate('Actions_ColumnSearches'),
'nb_pages_per_search' => Piwik_Translate('Actions_ColumnPagesPerSearch')
),
'columns_to_display' => array('label', 'nb_visits', 'nb_pages_per_search'),
'show_table_all_columns' => false,
'show_bar_chart' => false,
'columns_to_display' => array('label', 'nb_visits', 'nb_pages_per_search'),
'show_table_all_columns' => false,
'show_bar_chart' => false,
'visualization_properties' => array(
'table' => array(
'disable_row_evolution' => false,
'disable_row_evolution' => false,
)
)
);
Expand Down
2 changes: 1 addition & 1 deletion plugins/Actions/ArchivingHelper.php
Expand Up @@ -506,7 +506,7 @@ private static function createSummaryRow()
{
return new Row(array(
Row::COLUMNS =>
array('label' => DataTable::LABEL_SUMMARY_ROW) + self::getDefaultRowColumns()
array('label' => DataTable::LABEL_SUMMARY_ROW) + self::getDefaultRowColumns()
));
}
}
4 changes: 2 additions & 2 deletions plugins/Annotations/API.php
Expand Up @@ -12,9 +12,9 @@

use Exception;
use Piwik\Date;

use Piwik\Period;
use Piwik\Period\Range;

use Piwik\Piwik;
use Piwik\Plugins\CoreVisualizations\Visualizations\JqplotGraph\Evolution as EvolutionViz;
use Piwik\ViewDataTable;
Expand Down Expand Up @@ -308,7 +308,7 @@ private static function checkUserCanAddNotesFor($idSite)
* @param string|bool $date The start date of the period (or the date range of a range
* period).
* @param string $period The period type ('day', 'week', 'month', 'year' or 'range').
* @param bool|int $lastN Whether to include the last N periods in the range or not.
* @param bool|int $lastN Whether to include the last N periods in the range or not.
* Ignored if period == range.
*
* @return Date[] array of Date objects or array(false, false)
Expand Down
2 changes: 1 addition & 1 deletion plugins/Annotations/AnnotationList.php
Expand Up @@ -421,7 +421,7 @@ public function compareAnnotationDate($lhs, $rhs)
public static function canUserAddNotesFor($idSite)
{
return Piwik::isUserHasViewAccess($idSite)
&& !Piwik::isUserIsAnonymous($idSite);
&& !Piwik::isUserIsAnonymous($idSite);
}

/**
Expand Down
1 change: 0 additions & 1 deletion plugins/Annotations/Controller.php
Expand Up @@ -11,7 +11,6 @@
namespace Piwik\Plugins\Annotations;

use Piwik\API\Request;

use Piwik\Common;
use Piwik\View;

Expand Down
2 changes: 1 addition & 1 deletion plugins/AnonymizeIP/AnonymizeIP.php
Expand Up @@ -55,7 +55,7 @@ public function getListHooksRegistered()
public static function applyIPMask($ip, $maskLength)
{
// IPv4 or mapped IPv4 in IPv6
if(IP::isIPv4($ip)) {
if (IP::isIPv4($ip)) {
$i = Common::strlen($ip);
if ($maskLength > $i) {
$maskLength = $i;
Expand Down
3 changes: 1 addition & 2 deletions plugins/CoreAdminHome/Controller.php
Expand Up @@ -72,8 +72,7 @@ public function generalSettings()
$directoryWritable = is_writable(PIWIK_DOCUMENT_ROOT . '/misc/user/');
$logoFilesWriteable = is_writeable(PIWIK_DOCUMENT_ROOT . '/misc/user/logo.png')
&& is_writeable(PIWIK_DOCUMENT_ROOT . '/misc/user/logo.svg')
&& is_writeable(PIWIK_DOCUMENT_ROOT . '/misc/user/logo-header.png');
;
&& is_writeable(PIWIK_DOCUMENT_ROOT . '/misc/user/logo-header.png');;
$view->logosWriteable = ($logoFilesWriteable || $directoryWritable) && ini_get('file_uploads') == 1;

$trustedHosts = array();
Expand Down
14 changes: 7 additions & 7 deletions plugins/CoreConsole/GenerateApi.php
Expand Up @@ -23,8 +23,8 @@ class GenerateApi extends GeneratePluginBase
protected function configure()
{
$this->setName('generate:api')
->setDescription('Adds an API to an existing plugin')
->addOption('pluginname', null, InputOption::VALUE_REQUIRED, 'The name of an existing plugin which does not have an API yet');
->setDescription('Adds an API to an existing plugin')
->addOption('pluginname', null, InputOption::VALUE_REQUIRED, 'The name of an existing plugin which does not have an API yet');
}

protected function execute(InputInterface $input, OutputInterface $output)
Expand All @@ -34,10 +34,10 @@ protected function execute(InputInterface $input, OutputInterface $output)
$this->copyTemplateToPlugin('api', $pluginName);

$this->writeSuccessMessage($output, array(
sprintf('API.php for %s generated.', $pluginName),
'You can now start adding API methods',
'Enjoy!'
));
sprintf('API.php for %s generated.', $pluginName),
'You can now start adding API methods',
'Enjoy!'
));
}

/**
Expand All @@ -61,7 +61,7 @@ private function getPluginName(InputInterface $input, OutputInterface $output)
$pluginName = $input->getOption('pluginname');

if (empty($pluginName)) {
$dialog = $this->getHelperSet()->get('dialog');
$dialog = $this->getHelperSet()->get('dialog');
$pluginName = $dialog->askAndValidate($output, 'Enter the name of your plugin: ', $validate, false, null, $pluginNames);
} else {
$validate($pluginName);
Expand Down
14 changes: 7 additions & 7 deletions plugins/CoreConsole/GenerateController.php
Expand Up @@ -23,8 +23,8 @@ class GenerateController extends GeneratePluginBase
protected function configure()
{
$this->setName('generate:controller')
->setDescription('Adds a Controller to an existing plugin')
->addOption('pluginname', null, InputOption::VALUE_REQUIRED, 'The name of an existing plugin which does not have a Controller yet');
->setDescription('Adds a Controller to an existing plugin')
->addOption('pluginname', null, InputOption::VALUE_REQUIRED, 'The name of an existing plugin which does not have a Controller yet');
}

protected function execute(InputInterface $input, OutputInterface $output)
Expand All @@ -34,10 +34,10 @@ protected function execute(InputInterface $input, OutputInterface $output)
$this->copyTemplateToPlugin('controller', $pluginName);

$this->writeSuccessMessage($output, array(
sprintf('Controller for %s generated.', $pluginName),
'You can now start adding Controller actions',
'Enjoy!'
));
sprintf('Controller for %s generated.', $pluginName),
'You can now start adding Controller actions',
'Enjoy!'
));
}

/**
Expand All @@ -61,7 +61,7 @@ private function getPluginName(InputInterface $input, OutputInterface $output)
$pluginName = $input->getOption('pluginname');

if (empty($pluginName)) {
$dialog = $this->getHelperSet()->get('dialog');
$dialog = $this->getHelperSet()->get('dialog');
$pluginName = $dialog->askAndValidate($output, 'Enter the name of your plugin: ', $validate, false, null, $pluginNames);
} else {
$validate($pluginName);
Expand Down
34 changes: 17 additions & 17 deletions plugins/CoreConsole/GeneratePlugin.php
Expand Up @@ -26,20 +26,20 @@ class GeneratePlugin extends GeneratePluginBase
protected function configure()
{
$this->setName('generate:plugin')
->setAliases(array('generate:theme'))
->setDescription('Generates a new plugin/theme including all needed files')
->addOption('name', null, InputOption::VALUE_REQUIRED, 'Plugin name ([a-Z0-9_-])')
->addOption('description', null, InputOption::VALUE_REQUIRED, 'Plugin description, max 150 characters')
->addOption('pluginversion', null, InputOption::VALUE_OPTIONAL, 'Plugin version')
->addOption('full', null, InputOption::VALUE_OPTIONAL, 'If a value is set, an API and a Controller will be created as well. Option is only available for creating plugins, not for creating themes.');
->setAliases(array('generate:theme'))
->setDescription('Generates a new plugin/theme including all needed files')
->addOption('name', null, InputOption::VALUE_REQUIRED, 'Plugin name ([a-Z0-9_-])')
->addOption('description', null, InputOption::VALUE_REQUIRED, 'Plugin description, max 150 characters')
->addOption('pluginversion', null, InputOption::VALUE_OPTIONAL, 'Plugin version')
->addOption('full', null, InputOption::VALUE_OPTIONAL, 'If a value is set, an API and a Controller will be created as well. Option is only available for creating plugins, not for creating themes.');
}

protected function execute(InputInterface $input, OutputInterface $output)
{
$isTheme = $this->isTheme($input);
$pluginName = $this->getPluginName($input, $output);
$isTheme = $this->isTheme($input);
$pluginName = $this->getPluginName($input, $output);
$description = $this->getPluginDescription($input, $output);
$version = $this->getPluginVersion($input, $output);
$version = $this->getPluginVersion($input, $output);
$createFullPlugin = !$isTheme && $this->getCreateFullPlugin($input, $output);

$this->generatePluginFolder($pluginName);
Expand All @@ -53,9 +53,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
}

$this->writeSuccessMessage($output, array(
sprintf('%s %s %s generated.', $isTheme ? 'Theme' : 'Plugin', $pluginName, $version),
'Enjoy!'
));
sprintf('%s %s %s generated.', $isTheme ? 'Theme' : 'Plugin', $pluginName, $version),
'Enjoy!'
));

if ($createFullPlugin) {
$this->executePluginCommand($output, 'generate:api', $pluginName);
Expand All @@ -65,7 +65,7 @@ protected function execute(InputInterface $input, OutputInterface $output)

private function executePluginCommand(OutputInterface $output, $commandName, $pluginName)
{
$command = $this->getApplication()->find($commandName);
$command = $this->getApplication()->find($commandName);
$arguments = array(
'command' => $commandName,
'--pluginname' => $pluginName
Expand Down Expand Up @@ -153,7 +153,7 @@ private function getPluginName(InputInterface $input, OutputInterface $output)
$pluginName = $input->getOption('name');

if (empty($pluginName)) {
$dialog = $this->getHelperSet()->get('dialog');
$dialog = $this->getHelperSet()->get('dialog');
$pluginName = $dialog->askAndValidate($output, 'Enter a plugin name: ', $validate);
} else {
$validate($pluginName);
Expand Down Expand Up @@ -186,7 +186,7 @@ private function getPluginDescription(InputInterface $input, OutputInterface $ou
$description = $input->getOption('description');

if (empty($description)) {
$dialog = $this->getHelperSet()->get('dialog');
$dialog = $this->getHelperSet()->get('dialog');
$description = $dialog->askAndValidate($output, 'Enter a plugin description: ', $validate);
} else {
$validate($description);
Expand All @@ -205,7 +205,7 @@ protected function getPluginVersion(InputInterface $input, OutputInterface $outp
$version = $input->getOption('pluginversion');

if (is_null($version)) {
$dialog = $this->getHelperSet()->get('dialog');
$dialog = $this->getHelperSet()->get('dialog');
$version = $dialog->ask($output, 'Enter a plugin version number (default to 0.1.0): ', '0.1.0');
}

Expand All @@ -223,7 +223,7 @@ protected function getCreateFullPlugin(InputInterface $input, OutputInterface $o

if (is_null($full)) {
$dialog = $this->getHelperSet()->get('dialog');
$full = $dialog->askConfirmation($output, 'Shall we also create an API and a Controller? (y/N)', false);
$full = $dialog->askConfirmation($output, 'Shall we also create an API and a Controller? (y/N)', false);
}

return !empty($full);
Expand Down
2 changes: 1 addition & 1 deletion plugins/CoreConsole/GeneratePluginBase.php
Expand Up @@ -44,7 +44,7 @@ protected function createFileWithinPluginIfNotExists($pluginName, $fileName, $co
}

/**
* @param string $templateName eg. 'controller' or 'api'
* @param string $templateName eg. 'controller' or 'api'
* @param string $pluginName
*/
protected function copyTemplateToPlugin($templateName, $pluginName)
Expand Down
6 changes: 3 additions & 3 deletions plugins/CoreConsole/RunTests.php
Expand Up @@ -33,11 +33,11 @@ protected function configure()
protected function execute(InputInterface $input, OutputInterface $output)
{
$options = $input->getOption('options');
$group = $input->getArgument('group');
$group = $input->getArgument('group');

if (!empty($group)) {
$groups = explode(',', $group);
$groups = array_map('ucfirst', $groups);
$groups = explode(',', $group);
$groups = array_map('ucfirst', $groups);
$options = '--group ' . implode(',', $groups) . ' ' . $options;
}

Expand Down

0 comments on commit 84eba85

Please sign in to comment.