Skip to content

Commit

Permalink
fix psr2 cs
Browse files Browse the repository at this point in the history
  • Loading branch information
antograssiot committed Jan 22, 2015
1 parent da10b6b commit dee3130
Show file tree
Hide file tree
Showing 26 changed files with 49 additions and 69 deletions.
3 changes: 1 addition & 2 deletions src/Controller/Component/SecurityComponent.php
Expand Up @@ -250,8 +250,7 @@ protected function _authRequired(Controller $controller)
if ($this->session->check('_Token')) {
$tData = $this->session->read('_Token');

if (
!empty($tData['allowedControllers']) &&
if (!empty($tData['allowedControllers']) &&
!in_array($this->request->params['controller'], $tData['allowedControllers']) ||
!empty($tData['allowedActions']) &&
!in_array($this->request->params['action'], $tData['allowedActions'])
Expand Down
3 changes: 1 addition & 2 deletions src/Database/Expression/ValuesExpression.php
Expand Up @@ -76,8 +76,7 @@ public function __construct(array $columns, $typeMap)
*/
public function add($data)
{
if (
(count($this->_values) && $data instanceof Query) ||
if ((count($this->_values) && $data instanceof Query) ||
($this->_query && is_array($data))
) {
throw new Exception(
Expand Down
12 changes: 4 additions & 8 deletions src/Database/Schema/MysqlSchema.php
Expand Up @@ -316,16 +316,14 @@ public function columnSql(Table $table, $name)
}

$hasPrecision = ['float', 'decimal'];
if (
in_array($data['type'], $hasPrecision, true) &&
if (in_array($data['type'], $hasPrecision, true) &&
(isset($data['length']) || isset($data['precision']))
) {
$out .= '(' . (int)$data['length'] . ',' . (int)$data['precision'] . ')';
}

$hasUnsigned = ['float', 'decimal', 'integer', 'biginteger'];
if (
in_array($data['type'], $hasUnsigned, true) &&
if (in_array($data['type'], $hasUnsigned, true) &&
isset($data['unsigned']) && $data['unsigned'] === true
) {
$out .= ' UNSIGNED';
Expand All @@ -334,8 +332,7 @@ public function columnSql(Table $table, $name)
if (isset($data['null']) && $data['null'] === false) {
$out .= ' NOT NULL';
}
if (
in_array($data['type'], ['integer', 'biginteger']) &&
if (in_array($data['type'], ['integer', 'biginteger']) &&
([$name] == (array)$table->primaryKey() || $data['autoIncrement'] === true)
) {
$out .= ' AUTO_INCREMENT';
Expand All @@ -347,8 +344,7 @@ public function columnSql(Table $table, $name)
if (isset($data['default']) && $data['type'] !== 'timestamp') {
$out .= ' DEFAULT ' . $this->_driver->schemaValue($data['default']);
}
if (
isset($data['default']) &&
if (isset($data['default']) &&
$data['type'] === 'timestamp' &&
strtolower($data['default']) === 'current_timestamp'
) {
Expand Down
6 changes: 2 additions & 4 deletions src/Database/Schema/PostgresSchema.php
Expand Up @@ -115,8 +115,7 @@ protected function _convertColumn($column)
if ($col === 'real' || strpos($col, 'double') !== false) {
return ['type' => 'float', 'length' => null];
}
if (
strpos($col, 'numeric') !== false ||
if (strpos($col, 'numeric') !== false ||
strpos($col, 'money') !== false ||
strpos($col, 'decimal') !== false
) {
Expand Down Expand Up @@ -232,8 +231,7 @@ public function convertIndexDescription(Table $table, $row)
// If there is only one column in the primary key and it is integery,
// make it autoincrement.
$columnDef = $table->column($columns[0]);
if (
count($columns) === 1 &&
if (count($columns) === 1 &&
in_array($columnDef['type'], ['integer', 'biginteger']) &&
$type === Table::CONSTRAINT_PRIMARY
) {
Expand Down
9 changes: 3 additions & 6 deletions src/Database/Schema/SqliteSchema.php
Expand Up @@ -239,8 +239,7 @@ public function columnSql(Table $table, $name)
$out = $this->_driver->quoteIdentifier($name);
$hasUnsigned = ['biginteger', 'integer', 'float', 'decimal'];

if (
in_array($data['type'], $hasUnsigned, true) &&
if (in_array($data['type'], $hasUnsigned, true) &&
isset($data['unsigned']) && $data['unsigned'] === true
) {
$out .= ' UNSIGNED';
Expand All @@ -252,8 +251,7 @@ public function columnSql(Table $table, $name)
$out .= '(' . (int)$data['length'] . ')';
}
$hasPrecision = ['float', 'decimal'];
if (
in_array($data['type'], $hasPrecision, true) &&
if (in_array($data['type'], $hasPrecision, true) &&
(isset($data['length']) || isset($data['precision']))
) {
$out .= '(' . (int)$data['length'] . ',' . (int)$data['precision'] . ')';
Expand Down Expand Up @@ -287,8 +285,7 @@ public function columnSql(Table $table, $name)
public function constraintSql(Table $table, $name)
{
$data = $table->constraint($name);
if (
$data['type'] === Table::CONSTRAINT_PRIMARY &&
if ($data['type'] === Table::CONSTRAINT_PRIMARY &&
count($data['columns']) === 1 &&
$table->column($data['columns'][0])['type'] === 'integer'
) {
Expand Down
3 changes: 1 addition & 2 deletions src/Database/Schema/SqlserverSchema.php
Expand Up @@ -97,8 +97,7 @@ protected function _convertColumn($col, $length = null, $precision = null, $scal
if ($col === 'bit') {
return ['type' => 'boolean', 'length' => null];
}
if (
strpos($col, 'numeric') !== false ||
if (strpos($col, 'numeric') !== false ||
strpos($col, 'money') !== false ||
strpos($col, 'decimal') !== false
) {
Expand Down
6 changes: 2 additions & 4 deletions src/Database/Type/DateTimeType.php
Expand Up @@ -138,8 +138,7 @@ public function marshal($value)
$value += ['hour' => 0, 'minute' => 0, 'second' => 0];

$format = '';
if (
isset($value['year'], $value['month'], $value['day']) &&
if (isset($value['year'], $value['month'], $value['day']) &&
(is_numeric($value['year']) && is_numeric($value['month']) && is_numeric($value['day']))
) {
$format .= sprintf('%d-%02d-%02d', $value['year'], $value['month'], $value['day']);
Expand Down Expand Up @@ -172,8 +171,7 @@ public function useLocaleParser($enable = true)
$this->_useLocaleParser = $enable;
return $this;
}
if (
static::$dateTimeClass === 'Cake\I18n\Time' ||
if (static::$dateTimeClass === 'Cake\I18n\Time' ||
is_subclass_of(static::$dateTimeClass, 'Cake\I18n\Time')
) {
$this->_useLocaleParser = $enable;
Expand Down
3 changes: 1 addition & 2 deletions src/Datasource/EntityTrait.php
Expand Up @@ -703,8 +703,7 @@ protected function _nestedErrors($field)
$val = isset($entity[$part]) ? $entity[$part] : false;
}

if (
is_array($val) ||
if (is_array($val) ||
$val instanceof Traversable ||
$val instanceof EntityInterface
) {
Expand Down
3 changes: 1 addition & 2 deletions src/Network/Email/Email.php
Expand Up @@ -1948,8 +1948,7 @@ protected function _checkViewVars(&$item, $key)
$item = (string)$item;
}

if (
is_resource($item) ||
if (is_resource($item) ||
$item instanceof Closure ||
$item instanceof PDO
) {
Expand Down
3 changes: 1 addition & 2 deletions src/ORM/Behavior/TimestampBehavior.php
Expand Up @@ -99,8 +99,7 @@ public function handleEvent(Event $event, Entity $entity)
sprintf('When should be one of "always", "new" or "existing". The passed value "%s" is invalid', $when)
);
}
if (
$when === 'always' ||
if ($when === 'always' ||
($when === 'new' && $new) ||
($when === 'existing' && !$new)
) {
Expand Down
3 changes: 1 addition & 2 deletions src/ORM/Marshaller.php
Expand Up @@ -371,8 +371,7 @@ public function merge(EntityInterface $entity, array $data, array $options = [])
$converter = Type::build($columnType);
$value = $converter->marshal($value);
$isObject = is_object($value);
if (
(!$isObject && $original === $value) ||
if ((!$isObject && $original === $value) ||
($isObject && $original == $value)
) {
continue;
Expand Down
6 changes: 2 additions & 4 deletions src/Routing/Route/Route.php
Expand Up @@ -400,8 +400,7 @@ public function match(array $url, array $context = [])

// Check for properties that will cause an
// absolute url. Copy the other properties over.
if (
isset($hostOptions['_scheme']) ||
if (isset($hostOptions['_scheme']) ||
isset($hostOptions['_port']) ||
isset($hostOptions['_host'])
) {
Expand Down Expand Up @@ -571,8 +570,7 @@ protected function _writeUrl($params, $pass = [], $query = [])
}

$out = str_replace('//', '/', $out);
if (
isset($params['_scheme']) ||
if (isset($params['_scheme']) ||
isset($params['_host']) ||
isset($params['_port'])
) {
Expand Down
3 changes: 1 addition & 2 deletions src/Routing/Router.php
Expand Up @@ -582,8 +582,7 @@ public static function url($url = null, $full = false)

if (!isset($url['_name'])) {
// Copy the current action if the controller is the current one.
if (
empty($url['action']) &&
if (empty($url['action']) &&
(empty($url['controller']) || $params['controller'] === $url['controller'])
) {
$url['action'] = $params['action'];
Expand Down
3 changes: 1 addition & 2 deletions src/Utility/MergeVariablesTrait.php
Expand Up @@ -71,8 +71,7 @@ protected function _mergeProperty($property, $parentClasses, $options)
{
$thisValue = $this->{$property};
$isAssoc = false;
if (
isset($options['associative']) &&
if (isset($options['associative']) &&
in_array($property, (array)$options['associative'])
) {
$isAssoc = true;
Expand Down
3 changes: 1 addition & 2 deletions src/Validation/Validation.php
Expand Up @@ -982,8 +982,7 @@ public static function uploadedFile($file, $options = [])
protected static function _getDateString($value)
{
$formatted = '';
if (
isset($value['year'], $value['month'], $value['day']) &&
if (isset($value['year'], $value['month'], $value['day']) &&
(is_numeric($value['year']) && is_numeric($value['month']) && is_numeric($value['day']))
) {
$formatted .= sprintf('%d-%02d-%02d ', $value['year'], $value['month'], $value['day']);
Expand Down
3 changes: 1 addition & 2 deletions src/View/Form/ArrayContext.php
Expand Up @@ -99,8 +99,7 @@ public function __construct(Request $request, array $context)
*/
public function primaryKey()
{
if (
empty($this->_context['schema']['_constraints']) ||
if (empty($this->_context['schema']['_constraints']) ||
!is_array($this->_context['schema']['_constraints'])
) {
return [];
Expand Down
12 changes: 4 additions & 8 deletions src/View/Helper/FormHelper.php
Expand Up @@ -498,8 +498,7 @@ protected function _csrfField()
public function end($secureAttributes = [])
{
$out = '';
if (
$this->requestType !== 'get' &&
if ($this->requestType !== 'get' &&
!empty($this->request['_Token'])
) {
$out .= $this->secure($this->fields, $secureAttributes);
Expand Down Expand Up @@ -1799,8 +1798,7 @@ public function select($fieldName, $options = [], array $attributes = [])

// Secure the field if there are options, or it's a multi select.
// Single selects with no options don't submit, but multiselects do.
if (
$attributes['secure'] &&
if ($attributes['secure'] &&
empty($options) &&
empty($attributes['empty']) &&
empty($attributes['multiple'])
Expand Down Expand Up @@ -2146,8 +2144,7 @@ protected function _datetimeOptions($options)
}

// Pass empty boolean to each type.
if (
!empty($options['empty']) &&
if (!empty($options['empty']) &&
is_bool($options['empty']) &&
is_array($options[$type])
) {
Expand Down Expand Up @@ -2469,8 +2466,7 @@ public function addWidget($name, $spec)
public function widget($name, array $data = [])
{
$widget = $this->_registry->get($name);
if (
isset($data['secure'], $data['name']) &&
if (isset($data['secure'], $data['name']) &&
$data['secure'] !== self::SECURE_SKIP
) {
foreach ($widget->secureFields($data) as $field) {
Expand Down
3 changes: 1 addition & 2 deletions src/View/Helper/PaginatorHelper.php
Expand Up @@ -436,8 +436,7 @@ public function generateUrl(array $options = [], $model = null, $full = false)
if (!empty($url['page']) && $url['page'] == 1) {
$url['page'] = null;
}
if (
isset($paging['sortDefault'], $paging['directionDefault'], $url['sort'], $url['direction']) &&
if (isset($paging['sortDefault'], $paging['directionDefault'], $url['sort'], $url['direction']) &&
$url['sort'] === $paging['sortDefault'] &&
$url['direction'] === $paging['directionDefault']
) {
Expand Down
3 changes: 1 addition & 2 deletions src/View/Helper/UrlHelper.php
Expand Up @@ -66,8 +66,7 @@ public function assetUrl($path, array $options = [])
if (!empty($options['pathPrefix']) && $path[0] !== '/') {
$path = $options['pathPrefix'] . $path;
}
if (
!empty($options['ext']) &&
if (!empty($options['ext']) &&
strpos($path, '?') === false &&
substr($path, -strlen($options['ext'])) !== $options['ext']
) {
Expand Down
3 changes: 1 addition & 2 deletions src/View/Widget/RadioWidget.php
Expand Up @@ -192,8 +192,7 @@ protected function _renderInput($val, $text, $data, $context)
$escape
);

if (
$label === false &&
if ($label === false &&
strpos($this->_templates->get('radioWrapper'), '{{input}}') === false
) {
$label = $input;
Expand Down
3 changes: 1 addition & 2 deletions src/View/Widget/SelectBoxWidget.php
Expand Up @@ -227,8 +227,7 @@ protected function _renderOptions($options, $disabled, $selected, $escape)
foreach ($options as $key => $val) {
// Option groups
$arrayVal = (is_array($val) || $val instanceof Traversable);
if (
(!is_int($key) && $arrayVal) ||
if ((!is_int($key) && $arrayVal) ||
(is_int($key) && $arrayVal && isset($val['options']))
) {
$out[] = $this->_renderOptgroup($key, $val, $disabled, $selected, $escape);
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Collection/Iterator/TreeIteratorTest.php
Expand Up @@ -61,7 +61,7 @@ public function testPrinter()
*/
public function testPrinterCustomKeyAndSpacer()
{
$items = [
$items = [
[
'id' => 1,
'name' => 'a',
Expand Down
3 changes: 1 addition & 2 deletions tests/TestCase/Database/Schema/SqliteSchemaTest.php
Expand Up @@ -202,8 +202,7 @@ protected function _createTables($connection)

$schema = new SchemaCollection($connection);
$result = $schema->listTables();
if (
in_array('schema_articles', $result) &&
if (in_array('schema_articles', $result) &&
in_array('schema_authors', $result)
) {
return;
Expand Down
3 changes: 1 addition & 2 deletions tests/TestCase/Log/Engine/ConsoleLogTest.php
Expand Up @@ -68,8 +68,7 @@ public function testlogToFileStream()
*/
public function testDefaultOutputAs()
{
if (
(DS === '\\' && !(bool)env('ANSICON')) ||
if ((DS === '\\' && !(bool)env('ANSICON')) ||
(function_exists('posix_isatty') && !posix_isatty(null))
) {
$expected = ConsoleOutput::PLAIN;
Expand Down

0 comments on commit dee3130

Please sign in to comment.