Skip to content

Commit

Permalink
Correct CS
Browse files Browse the repository at this point in the history
  • Loading branch information
sstok committed Sep 16, 2015
1 parent a9a6122 commit 15989ca
Show file tree
Hide file tree
Showing 34 changed files with 168 additions and 201 deletions.
2 changes: 1 addition & 1 deletion .php_cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ return Symfony\CS\Config\Config::create()
'ordered_use',
//'strict',
'strict_param',
//'short_array_syntax',
'short_array_syntax',
'phpdoc_order',
'header_comment',
'-psr0',
Expand Down
2 changes: 1 addition & 1 deletion src/EventSubscriber/SqliteConnectionSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ function ($pattern, $string, $flags) {
*/
public function getSubscribedEvents()
{
return array(Events::postConnect);
return [Events::postConnect];
}
}
8 changes: 4 additions & 4 deletions src/Extension/Conversion/AgeDateConversion.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ public function convertSqlField($column, array $options, ConversionHints $hints)

$platform = $hints->connection->getDatabasePlatform()->getName();

$convertMap = array();
$convertMap = [];
$convertMap['postgresql'] = "to_char(age(%1\$s), 'YYYY'::text)::integer";
$convertMap['mysql'] = "(DATE_FORMAT(NOW(), '%%Y') - DATE_FORMAT(%1\$s, '%%Y') - (DATE_FORMAT(NOW(), '00-%%m-%%d') < DATE_FORMAT(%1\$s, '00-%%m-%%d')))";
$convertMap['drizzle'] = $convertMap['mysql'];
$convertMap['mssql'] = "DATEDIFF(hour, %1\$s, GETDATE())/8766";
$convertMap['oracle'] = "trunc((months_between(sysdate, (sysdate - %1\$s)))/12)";
$convertMap['sqlite'] = "search_conversion_age(%1\$s)";
$convertMap['mssql'] = 'DATEDIFF(hour, %1$s, GETDATE())/8766';
$convertMap['oracle'] = 'trunc((months_between(sysdate, (sysdate - %1$s)))/12)';
$convertMap['sqlite'] = 'search_conversion_age(%1$s)';
$convertMap['mock'] = $convertMap['sqlite'];

if (isset($convertMap[$platform])) {
Expand Down
2 changes: 1 addition & 1 deletion src/Extension/Conversion/MoneyValueConversion.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private function getCastType($scale, ConversionHints $hints)
}

return $hints->connection->getDatabasePlatform()->getDecimalTypeDeclarationSQL(
array('scale' => $scale)
['scale' => $scale]
);
}
}
4 changes: 2 additions & 2 deletions src/Extension/DoctrineDbalExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ class DoctrineDbalExtension extends AbstractExtension
*/
protected function loadTypeExtensions()
{
return array(
return [
new Type\FieldTypeExtension(),
new Type\BirthdayTypeExtension(new AgeDateConversion()),
new Type\MoneyTypeExtension(new MoneyValueConversion()),
);
];
}
}
2 changes: 1 addition & 1 deletion src/Extension/Type/BirthdayTypeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function __construct(AgeDateConversion $conversion)
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(
array('doctrine_dbal_conversion' => $this->conversion)
['doctrine_dbal_conversion' => $this->conversion]
);
}

Expand Down
10 changes: 5 additions & 5 deletions src/Extension/Type/FieldTypeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@ class FieldTypeExtension extends AbstractFieldTypeExtension
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(
array('doctrine_dbal_conversion' => null)
['doctrine_dbal_conversion' => null]
);

$resolver->setAllowedTypes(
array(
'doctrine_dbal_conversion' => array(
[
'doctrine_dbal_conversion' => [
'null',
'Closure',
'Rollerworks\Component\Search\Doctrine\Dbal\SqlFieldConversionInterface',
'Rollerworks\Component\Search\Doctrine\Dbal\SqlValueConversionInterface',
'Rollerworks\Component\Search\Doctrine\Dbal\ValueConversionInterface',
),
)
],
]
);
}

Expand Down
6 changes: 3 additions & 3 deletions src/Extension/Type/MoneyTypeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ public function __construct(MoneyValueConversion $conversion)
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(
array(
[
'doctrine_dbal_conversion' => $this->conversion,
'doctrine_dbal_with_currency' => false,
)
]
);

$resolver->setAllowedTypes(
array('doctrine_dbal_with_currency' => array('bool'))
['doctrine_dbal_with_currency' => ['bool']]
);
}

Expand Down
38 changes: 19 additions & 19 deletions src/Query/QueryGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ final class QueryGenerator
/**
* @var QueryField[]
*/
private $fields = array();
private $fields = [];

/**
* @var Connection
Expand Down Expand Up @@ -68,16 +68,16 @@ public function __construct(Connection $connection, QueryPlatformInterface $quer
*/
public function getGroupQuery(ValuesGroup $valuesGroup)
{
$query = array();
$query = [];

foreach ($valuesGroup->getFields() as $fieldName => $values) {
if (!isset($this->fields[$fieldName])) {
continue;
}

$groupSql = array();
$inclusiveSqlGroup = array();
$exclusiveSqlGroup = array();
$groupSql = [];
$inclusiveSqlGroup = [];
$exclusiveSqlGroup = [];

$this->processSingleValues(
$values->getSingleValues(),
Expand Down Expand Up @@ -131,23 +131,23 @@ public function getGroupQuery(ValuesGroup $valuesGroup)
true
);

$groupSql[] = self::implodeWithValue(' OR ', $inclusiveSqlGroup, array('(', ')'));
$groupSql[] = self::implodeWithValue(' AND ', $exclusiveSqlGroup, array('(', ')'));
$query[] = self::implodeWithValue(' AND ', $groupSql, array('(', ')', true));
$groupSql[] = self::implodeWithValue(' OR ', $inclusiveSqlGroup, ['(', ')']);
$groupSql[] = self::implodeWithValue(' AND ', $exclusiveSqlGroup, ['(', ')']);
$query[] = self::implodeWithValue(' AND ', $groupSql, ['(', ')', true]);
}

$finalQuery = array();
$finalQuery = [];

// Wrap all the fields as a group
$finalQuery[] = self::implodeWithValue(
' '.strtoupper($valuesGroup->getGroupLogical()).' ',
$query,
array('(', ')', true)
['(', ')', true]
);

$this->processGroups($valuesGroup->getGroups(), $finalQuery);

return (string) self::implodeWithValue(' AND ', $finalQuery, array('(', ')'));
return (string) self::implodeWithValue(' AND ', $finalQuery, ['(', ')']);
}

/**
Expand All @@ -156,13 +156,13 @@ public function getGroupQuery(ValuesGroup $valuesGroup)
*/
private function processGroups(array $groups, array &$query)
{
$groupSql = array();
$groupSql = [];

foreach ($groups as $group) {
$groupSql[] = $this->getGroupQuery($group);
}

$query[] = self::implodeWithValue(' OR ', $groupSql, array('(', ')', true));
$query[] = self::implodeWithValue(' OR ', $groupSql, ['(', ')', true]);
}

/**
Expand All @@ -177,14 +177,14 @@ private function processGroups(array $groups, array &$query)
*/
private function processSingleValuesInList(array $values, $fieldName, array &$query, $exclude = false)
{
$valuesQuery = array();
$valuesQuery = [];
$column = $this->queryPlatform->getFieldColumn($fieldName);

foreach ($values as $value) {
$valuesQuery[] = $this->queryPlatform->getValueAsSql($value->getValue(), $fieldName, $column);
}

$patterns = array('%s IN(%s)', '%s NOT IN(%s)');
$patterns = ['%s IN(%s)', '%s NOT IN(%s)'];

if (count($valuesQuery) > 0) {
$query[] = sprintf(
Expand Down Expand Up @@ -215,7 +215,7 @@ private function processSingleValues(array $values, $fieldName, array &$query, $
return;
}

$patterns = array('%s = %s', '%s <> %s');
$patterns = ['%s = %s', '%s <> %s'];

foreach ($values as $value) {
$strategy = $this->getConversionStrategy($fieldName, $value->getValue());
Expand Down Expand Up @@ -286,7 +286,7 @@ private function getRangePattern(Range $range, $exclude = false)
*/
private function processCompares(array $compares, $fieldName, array &$query, $exclude = false)
{
$valuesQuery = array();
$valuesQuery = [];

foreach ($compares as $comparison) {
if ($exclude !== ('<>' === $comparison->getOperator())) {
Expand All @@ -307,7 +307,7 @@ private function processCompares(array $compares, $fieldName, array &$query, $ex
$query[] = self::implodeWithValue(
' AND ',
$valuesQuery,
count($valuesQuery) > 1 && !$exclude ? array('(', ')') : array()
count($valuesQuery) > 1 && !$exclude ? ['(', ')'] : []
);
}

Expand Down Expand Up @@ -372,7 +372,7 @@ private function getConversionHints($fieldName, $column = null)
return $hints;
}

private static function implodeWithValue($glue, array $values, array $wrap = array())
private static function implodeWithValue($glue, array $values, array $wrap = [])
{
// Remove the empty values
$values = array_filter($values, 'strlen');
Expand Down
8 changes: 4 additions & 4 deletions src/QueryPlatform/AbstractQueryPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ abstract class AbstractQueryPlatform implements QueryPlatformInterface
/**
* @var QueryField[]
*/
protected $fields = array();
protected $fields = [];

/**
* @var array[]
*/
protected $fieldsMappingCache = array();
protected $fieldsMappingCache = [];

/**
* @var Connection
Expand Down Expand Up @@ -120,14 +120,14 @@ public function getPatternMatcher(PatternMatch $patternMatch, $column)
return $column.($patternMatch->isExclusive() ? ' <>' : ' =')." $value";
}

$patternMap = array(
$patternMap = [
PatternMatch::PATTERN_STARTS_WITH => '%%%s',
PatternMatch::PATTERN_NOT_STARTS_WITH => '%%%s',
PatternMatch::PATTERN_CONTAINS => '%%%s%%',
PatternMatch::PATTERN_NOT_CONTAINS => '%%%s%%',
PatternMatch::PATTERN_ENDS_WITH => '%s%%',
PatternMatch::PATTERN_NOT_ENDS_WITH => '%s%%',
);
];

$value = addcslashes($patternMatch->getValue(), $this->getLikeEscapeChars());
$value = $this->connection->quote(sprintf($patternMap[$patternMatch->getType()], $value));
Expand Down
4 changes: 0 additions & 4 deletions src/QueryPlatform/DrizzleQueryPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
* with this source code in the file LICENSE.
*/

/**
* PhpStorm.
*/

namespace Rollerworks\Component\Search\Doctrine\Dbal\QueryPlatform;

final class DrizzleQueryPlatform extends MysqlQueryPlatform
Expand Down
4 changes: 0 additions & 4 deletions src/QueryPlatform/MockQueryPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
* with this source code in the file LICENSE.
*/

/**
* PhpStorm.
*/

namespace Rollerworks\Component\Search\Doctrine\Dbal\QueryPlatform;

final class MockQueryPlatform extends AbstractQueryPlatform
Expand Down
4 changes: 0 additions & 4 deletions src/QueryPlatform/MssqlQueryPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
* with this source code in the file LICENSE.
*/

/**
* PhpStorm.
*/

namespace Rollerworks\Component\Search\Doctrine\Dbal\QueryPlatform;

class MssqlQueryPlatform extends AbstractQueryPlatform
Expand Down
4 changes: 0 additions & 4 deletions src/QueryPlatform/MysqlQueryPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
* with this source code in the file LICENSE.
*/

/**
* PhpStorm.
*/

namespace Rollerworks\Component\Search\Doctrine\Dbal\QueryPlatform;

class MysqlQueryPlatform extends AbstractQueryPlatform
Expand Down
4 changes: 0 additions & 4 deletions src/QueryPlatform/OracleQueryPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
* with this source code in the file LICENSE.
*/

/**
* PhpStorm.
*/

namespace Rollerworks\Component\Search\Doctrine\Dbal\QueryPlatform;

class OracleQueryPlatform extends AbstractQueryPlatform
Expand Down
4 changes: 0 additions & 4 deletions src/QueryPlatform/PostgresqlQueryPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
* with this source code in the file LICENSE.
*/

/**
* PhpStorm.
*/

namespace Rollerworks\Component\Search\Doctrine\Dbal\QueryPlatform;

final class PostgresqlQueryPlatform extends AbstractQueryPlatform
Expand Down
4 changes: 0 additions & 4 deletions src/QueryPlatform/SqliteQueryPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
* with this source code in the file LICENSE.
*/

/**
* PhpStorm.
*/

namespace Rollerworks\Component\Search\Doctrine\Dbal\QueryPlatform;

final class SqliteQueryPlatform extends AbstractQueryPlatform
Expand Down
4 changes: 0 additions & 4 deletions src/QueryPlatformInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
* with this source code in the file LICENSE.
*/

/**
* PhpStorm.
*/

namespace Rollerworks\Component\Search\Doctrine\Dbal;

use Rollerworks\Component\Search\Value\PatternMatch;
Expand Down
Loading

0 comments on commit 15989ca

Please sign in to comment.