Skip to content

Commit

Permalink
Do not use broken PHP CS Fixer v3.9.1 (#1023)
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek authored Jul 11, 2022
1 parent 43cbe92 commit b763bb2
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 28 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"phpunit/phpunit": "^9.5.5"
},
"conflict": {
"friendsofphp/php-cs-fixer": "^3.9",
"jdorn/sql-formatter": "<1.2.9"
},
"suggest": {
Expand Down
2 changes: 1 addition & 1 deletion src/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -2040,7 +2040,7 @@ public function __debugInfo(): array
if ($this->isEntity()) {
return [
'entityId' => $this->id_field && $this->hasField($this->id_field)
? (($this->_entityId !== null ? $this->_entityId . ($this->getId() !== null ? '' : ' (unloaded)') : 'null'))
? ($this->_entityId !== null ? $this->_entityId . ($this->getId() !== null ? '' : ' (unloaded)') : 'null')
: 'no id field',
'model' => $this->getModel()->__debugInfo(),
];
Expand Down
2 changes: 1 addition & 1 deletion src/Model/Scope/Condition.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public function __construct($key, $operator = null, $value = null)

if ($operator === null) {
// at least MSSQL database always requires an operator
if (!($key instanceof Expressionable)) {
if (!$key instanceof Expressionable) {
throw new Exception('Operator must be specified');
}
} else {
Expand Down
32 changes: 16 additions & 16 deletions src/Persistence/Array_/Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,23 +71,23 @@ public function aggregate(string $fx, string $field, bool $coalesce = false)
case 'SUM':
$result = array_sum($column);

break;
break;
case 'AVG':
$column = $coalesce ? $column : array_filter($column, function ($value) {
return $value !== null;
});

$result = array_sum($column) / count($column);

break;
break;
case 'MAX':
$result = max($column);

break;
break;
case 'MIN':
$result = min($column);

break;
break;
default:
throw (new Exception('Array persistence driver action unsupported format'))
->addMoreInfo('action', $fx);
Expand Down Expand Up @@ -161,37 +161,37 @@ protected function evaluateIf($v1, string $operator, $v2): bool
case '=':
$result = is_array($v2) ? $this->evaluateIf($v1, 'IN', $v2) : $v1 === $v2;

break;
break;
case '>':
$result = $v1 > $v2;

break;
break;
case '>=':
$result = $v1 >= $v2;

break;
break;
case '<':
$result = $v1 < $v2;

break;
break;
case '<=':
$result = $v1 <= $v2;

break;
break;
case '!=':
$result = !$this->evaluateIf($v1, '=', $v2);

break;
break;
case 'LIKE':
$pattern = str_ireplace('%', '(.*?)', preg_quote($v2));

$result = (bool) preg_match('/^' . $pattern . '$/', (string) $v1);

break;
break;
case 'NOT LIKE':
$result = !$this->evaluateIf($v1, 'LIKE', $v2);

break;
break;
case 'IN':
$result = false;
foreach ($v2 as $v2Item) { // TODO flatten rows, this looses column names!
Expand All @@ -202,19 +202,19 @@ protected function evaluateIf($v1, string $operator, $v2): bool
}
}

break;
break;
case 'NOT IN':
$result = !$this->evaluateIf($v1, 'IN', $v2);

break;
break;
case 'REGEXP':
$result = (bool) preg_match('/' . $v2 . '/', $v1);

break;
break;
case 'NOT REGEXP':
$result = !$this->evaluateIf($v1, 'REGEXP', $v2);

break;
break;
default:
throw (new Exception('Unsupported operator'))
->addMoreInfo('operator', $operator);
Expand Down
4 changes: 2 additions & 2 deletions src/Persistence/Sql.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,8 @@ public function initQueryConditions(Model $model, Query $query): void

private function fixMssqlOracleMissingFieldsInGroup(Model $model, Query $query): void
{
if (($this->getDatabasePlatform() instanceof SQLServerPlatform
|| $this->getDatabasePlatform() instanceof OraclePlatform)) {
if ($this->getDatabasePlatform() instanceof SQLServerPlatform
|| $this->getDatabasePlatform() instanceof OraclePlatform) {
$isIdFieldInGroup = false;
foreach ($query->args['group'] ?? [] as $v) {
if ($model->id_field && $v === $model->getField($model->id_field)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Persistence/Sql/Join.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function initSelectQuery(Model $model, Query $query): void
$query->join(
$this->foreign_table,
$this->getOwner()->expr('{{}}.{} = {}', [
($this->foreign_alias ?: $this->foreign_table),
$this->foreign_alias ?: $this->foreign_table,
$this->foreign_field,
$this->getOwner()->getField($this->master_field),
]),
Expand Down
4 changes: 2 additions & 2 deletions tests/ModelNestedSqlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ public function testSelectSql(): void
$m->setOrder('birthday');

$this->assertSame(
($this->db->getConnection()->dsql())
$this->db->getConnection()->dsql()
->table(
($this->db->getConnection()->dsql())
$this->db->getConnection()->dsql()
->table('user')
->field('_id', 'uid')
->field('name')
Expand Down
4 changes: 2 additions & 2 deletions tests/Persistence/Sql/QueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -471,9 +471,9 @@ public function testVarDump4(): void
// should throw exception "Table cannot be Query in UPDATE, INSERT etc. query modes"
$this->assertStringContainsString(
'Table cannot be Query',
($this->q()
$this->q()
->mode('update')
->table($this->q()->table('test'), 'foo'))->__debugInfo()['R']
->table($this->q()->table('test'), 'foo')->__debugInfo()['R']
);
}

Expand Down
5 changes: 2 additions & 3 deletions tests/SmboTransferTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ protected function setUp(): void
->field('document_id', ['type' => 'integer'])
->field('account_id', ['type' => 'integer'])
->field('cheque_no')
// ->field('misc_payment', ['type' => 'enum(\'N\',\'Y\')'])
->field('misc_payment')
->field('transfer_document_id')
->field('misc_payment', ['type' => 'boolean'])
->field('transfer_document_id', ['type' => 'integer'])
->create();
}

Expand Down

0 comments on commit b763bb2

Please sign in to comment.