Skip to content

Commit 4056a73

Browse files
authored
Merge pull request #2250 from divine/php-cs-fixer-changes
Apply fixes produced by php-cs-fixer
2 parents 09fa31b + 97260f4 commit 4056a73

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+230
-187
lines changed

.github/workflows/build-ci.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ on:
99
jobs:
1010
php-cs-fixer:
1111
runs-on: ubuntu-latest
12+
env:
13+
PHP_CS_FIXER_VERSION: v2.18.7
1214
strategy:
1315
matrix:
1416
php:
@@ -21,9 +23,9 @@ jobs:
2123
with:
2224
php-version: ${{ matrix.php }}
2325
extensions: curl,mbstring
24-
tools: php-cs-fixer
26+
tools: php-cs-fixer:${{ env.PHP_CS_FIXER_VERSION }}
2527
coverage: none
26-
- name: Run PHP-CS-Fixer Fix
28+
- name: Run PHP-CS-Fixer Fix, version ${{ env.PHP_CS_FIXER_VERSION }}
2729
run: php-cs-fixer fix --dry-run --diff --ansi
2830

2931
build:

src/Collection.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function __call($method, $parameters)
6464
}
6565
}
6666

67-
$queryString = $this->collection->getCollectionName() . '.' . $method . '(' . implode(',', $query) . ')';
67+
$queryString = $this->collection->getCollectionName().'.'.$method.'('.implode(',', $query).')';
6868

6969
$this->connection->logQuery($queryString, [], $time);
7070

src/Connection.php

+14-14
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public function getDatabaseName()
119119
}
120120

121121
/**
122-
* Get the name of the default database based on db config or try to detect it from dsn
122+
* Get the name of the default database based on db config or try to detect it from dsn.
123123
* @param string $dsn
124124
* @param array $config
125125
* @return string
@@ -131,7 +131,7 @@ protected function getDefaultDatabaseName($dsn, $config)
131131
if (preg_match('/^mongodb(?:[+]srv)?:\\/\\/.+\\/([^?&]+)/s', $dsn, $matches)) {
132132
$config['database'] = $matches[1];
133133
} else {
134-
throw new InvalidArgumentException("Database is not properly configured.");
134+
throw new InvalidArgumentException('Database is not properly configured.');
135135
}
136136
}
137137

@@ -155,10 +155,10 @@ protected function createConnection($dsn, array $config, array $options)
155155
}
156156

157157
// Check if the credentials are not already set in the options
158-
if (!isset($options['username']) && !empty($config['username'])) {
158+
if (! isset($options['username']) && ! empty($config['username'])) {
159159
$options['username'] = $config['username'];
160160
}
161-
if (!isset($options['password']) && !empty($config['password'])) {
161+
if (! isset($options['password']) && ! empty($config['password'])) {
162162
$options['password'] = $config['password'];
163163
}
164164

@@ -180,7 +180,7 @@ public function disconnect()
180180
*/
181181
protected function hasDsnString(array $config)
182182
{
183-
return isset($config['dsn']) && !empty($config['dsn']);
183+
return isset($config['dsn']) && ! empty($config['dsn']);
184184
}
185185

186186
/**
@@ -205,14 +205,15 @@ protected function getHostDsn(array $config)
205205

206206
foreach ($hosts as &$host) {
207207
// Check if we need to add a port to the host
208-
if (strpos($host, ':') === false && !empty($config['port'])) {
209-
$host = $host . ':' . $config['port'];
208+
if (strpos($host, ':') === false && ! empty($config['port'])) {
209+
$host = $host.':'.$config['port'];
210210
}
211211
}
212212

213213
// Check if we want to authenticate against a specific database.
214-
$auth_database = isset($config['options']) && !empty($config['options']['database']) ? $config['options']['database'] : null;
215-
return 'mongodb://' . implode(',', $hosts) . ($auth_database ? '/' . $auth_database : '');
214+
$auth_database = isset($config['options']) && ! empty($config['options']['database']) ? $config['options']['database'] : null;
215+
216+
return 'mongodb://'.implode(',', $hosts).($auth_database ? '/'.$auth_database : '');
216217
}
217218

218219
/**
@@ -266,16 +267,15 @@ protected function getDefaultSchemaGrammar()
266267
{
267268
return new Schema\Grammar();
268269
}
269-
270+
270271
/**
271272
* Set database.
272273
* @param \MongoDB\Database $db
273274
*/
274275
public function setDatabase(\MongoDB\Database $db)
275-
{
276-
$this->db = $db;
277-
}
278-
276+
{
277+
$this->db = $db;
278+
}
279279

280280
/**
281281
* Dynamically pass methods to the connection.

src/Eloquent/Builder.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class Builder extends EloquentBuilder
3737
'push',
3838
'raw',
3939
'sum',
40-
'toSql'
40+
'toSql',
4141
];
4242

4343
/**
@@ -190,13 +190,13 @@ public function raw($expression = null)
190190
* Add the "updated at" column to an array of values.
191191
* TODO Remove if https://github.com/laravel/framework/commit/6484744326531829341e1ff886cc9b628b20d73e
192192
* wiil be reverted
193-
* Issue in laravel frawework https://github.com/laravel/framework/issues/27791
193+
* Issue in laravel frawework https://github.com/laravel/framework/issues/27791.
194194
* @param array $values
195195
* @return array
196196
*/
197197
protected function addUpdatedAtColumn(array $values)
198198
{
199-
if (!$this->model->usesTimestamps() || $this->model->getUpdatedAtColumn() === null) {
199+
if (! $this->model->usesTimestamps() || $this->model->getUpdatedAtColumn() === null) {
200200
return $values;
201201
}
202202

src/Eloquent/EmbedsRelations.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ protected function embedsMany($related, $localKey = null, $foreignKey = null, $r
2222
// the calling method's name and use that as the relationship name as most
2323
// of the time this will be what we desire to use for the relationships.
2424
if ($relation === null) {
25-
list(, $caller) = debug_backtrace(false);
25+
[, $caller] = debug_backtrace(false);
2626

2727
$relation = $caller['function'];
2828
}
@@ -56,7 +56,7 @@ protected function embedsOne($related, $localKey = null, $foreignKey = null, $re
5656
// the calling method's name and use that as the relationship name as most
5757
// of the time this will be what we desire to use for the relationships.
5858
if ($relation === null) {
59-
list(, $caller) = debug_backtrace(false);
59+
[, $caller] = debug_backtrace(false);
6060

6161
$relation = $caller['function'];
6262
}

src/Eloquent/HybridRelations.php

+15-15
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
use Jenssegers\Mongodb\Relations\BelongsToMany;
1010
use Jenssegers\Mongodb\Relations\HasMany;
1111
use Jenssegers\Mongodb\Relations\HasOne;
12-
use Jenssegers\Mongodb\Relations\MorphTo;
1312
use Jenssegers\Mongodb\Relations\MorphMany;
13+
use Jenssegers\Mongodb\Relations\MorphTo;
1414

1515
trait HybridRelations
1616
{
@@ -24,7 +24,7 @@ trait HybridRelations
2424
public function hasOne($related, $foreignKey = null, $localKey = null)
2525
{
2626
// Check if it is a relation with an original model.
27-
if (!is_subclass_of($related, \Jenssegers\Mongodb\Eloquent\Model::class)) {
27+
if (! is_subclass_of($related, \Jenssegers\Mongodb\Eloquent\Model::class)) {
2828
return parent::hasOne($related, $foreignKey, $localKey);
2929
}
3030

@@ -49,13 +49,13 @@ public function hasOne($related, $foreignKey = null, $localKey = null)
4949
public function morphOne($related, $name, $type = null, $id = null, $localKey = null)
5050
{
5151
// Check if it is a relation with an original model.
52-
if (!is_subclass_of($related, \Jenssegers\Mongodb\Eloquent\Model::class)) {
52+
if (! is_subclass_of($related, \Jenssegers\Mongodb\Eloquent\Model::class)) {
5353
return parent::morphOne($related, $name, $type, $id, $localKey);
5454
}
5555

5656
$instance = new $related;
5757

58-
list($type, $id) = $this->getMorphs($name, $type, $id);
58+
[$type, $id] = $this->getMorphs($name, $type, $id);
5959

6060
$localKey = $localKey ?: $this->getKeyName();
6161

@@ -72,7 +72,7 @@ public function morphOne($related, $name, $type = null, $id = null, $localKey =
7272
public function hasMany($related, $foreignKey = null, $localKey = null)
7373
{
7474
// Check if it is a relation with an original model.
75-
if (!is_subclass_of($related, \Jenssegers\Mongodb\Eloquent\Model::class)) {
75+
if (! is_subclass_of($related, \Jenssegers\Mongodb\Eloquent\Model::class)) {
7676
return parent::hasMany($related, $foreignKey, $localKey);
7777
}
7878

@@ -97,7 +97,7 @@ public function hasMany($related, $foreignKey = null, $localKey = null)
9797
public function morphMany($related, $name, $type = null, $id = null, $localKey = null)
9898
{
9999
// Check if it is a relation with an original model.
100-
if (!is_subclass_of($related, \Jenssegers\Mongodb\Eloquent\Model::class)) {
100+
if (! is_subclass_of($related, \Jenssegers\Mongodb\Eloquent\Model::class)) {
101101
return parent::morphMany($related, $name, $type, $id, $localKey);
102102
}
103103

@@ -106,7 +106,7 @@ public function morphMany($related, $name, $type = null, $id = null, $localKey =
106106
// Here we will gather up the morph type and ID for the relationship so that we
107107
// can properly query the intermediate table of a relation. Finally, we will
108108
// get the table and create the relationship instances for the developers.
109-
list($type, $id) = $this->getMorphs($name, $type, $id);
109+
[$type, $id] = $this->getMorphs($name, $type, $id);
110110

111111
$table = $instance->getTable();
112112

@@ -129,21 +129,21 @@ public function belongsTo($related, $foreignKey = null, $otherKey = null, $relat
129129
// the calling method's name and use that as the relationship name as most
130130
// of the time this will be what we desire to use for the relationships.
131131
if ($relation === null) {
132-
list($current, $caller) = debug_backtrace(false, 2);
132+
[$current, $caller] = debug_backtrace(false, 2);
133133

134134
$relation = $caller['function'];
135135
}
136136

137137
// Check if it is a relation with an original model.
138-
if (!is_subclass_of($related, \Jenssegers\Mongodb\Eloquent\Model::class)) {
138+
if (! is_subclass_of($related, \Jenssegers\Mongodb\Eloquent\Model::class)) {
139139
return parent::belongsTo($related, $foreignKey, $otherKey, $relation);
140140
}
141141

142142
// If no foreign key was supplied, we can use a backtrace to guess the proper
143143
// foreign key name by using the name of the relationship function, which
144144
// when combined with an "_id" should conventionally match the columns.
145145
if ($foreignKey === null) {
146-
$foreignKey = Str::snake($relation) . '_id';
146+
$foreignKey = Str::snake($relation).'_id';
147147
}
148148

149149
$instance = new $related;
@@ -172,12 +172,12 @@ public function morphTo($name = null, $type = null, $id = null, $ownerKey = null
172172
// since that is most likely the name of the polymorphic interface. We can
173173
// use that to get both the class and foreign key that will be utilized.
174174
if ($name === null) {
175-
list($current, $caller) = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
175+
[$current, $caller] = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
176176

177177
$name = Str::snake($caller['function']);
178178
}
179179

180-
list($type, $id) = $this->getMorphs($name, $type, $id);
180+
[$type, $id] = $this->getMorphs($name, $type, $id);
181181

182182
// If the type value is null it is probably safe to assume we're eager loading
183183
// the relationship. When that is the case we will pass in a dummy query as
@@ -230,7 +230,7 @@ public function belongsToMany(
230230
}
231231

232232
// Check if it is a relation with an original model.
233-
if (!is_subclass_of($related, \Jenssegers\Mongodb\Eloquent\Model::class)) {
233+
if (! is_subclass_of($related, \Jenssegers\Mongodb\Eloquent\Model::class)) {
234234
return parent::belongsToMany(
235235
$related,
236236
$collection,
@@ -245,11 +245,11 @@ public function belongsToMany(
245245
// First, we'll need to determine the foreign key and "other key" for the
246246
// relationship. Once we have determined the keys we'll make the query
247247
// instances as well as the relationship instances we need for this.
248-
$foreignKey = $foreignKey ?: $this->getForeignKey() . 's';
248+
$foreignKey = $foreignKey ?: $this->getForeignKey().'s';
249249

250250
$instance = new $related;
251251

252-
$otherKey = $otherKey ?: $instance->getForeignKey() . 's';
252+
$otherKey = $otherKey ?: $instance->getForeignKey().'s';
253253

254254
// If no table name was provided, we can guess it by concatenating the two
255255
// models using underscores in alphabetical order. The two model names

src/Eloquent/Model.php

+12-12
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function getIdAttribute($value = null)
5252
{
5353
// If we don't have a value for 'id', we will use the Mongo '_id' value.
5454
// This allows us to work with models in a more sql-like way.
55-
if (!$value && array_key_exists('_id', $this->attributes)) {
55+
if (! $value && array_key_exists('_id', $this->attributes)) {
5656
$value = $this->attributes['_id'];
5757
}
5858

@@ -85,7 +85,7 @@ public function fromDateTime($value)
8585
}
8686

8787
// Let Eloquent convert the value to a DateTime instance.
88-
if (!$value instanceof DateTimeInterface) {
88+
if (! $value instanceof DateTimeInterface) {
8989
$value = parent::asDateTime($value);
9090
}
9191

@@ -140,7 +140,7 @@ public function getTable()
140140
*/
141141
public function getAttribute($key)
142142
{
143-
if (!$key) {
143+
if (! $key) {
144144
return;
145145
}
146146

@@ -150,7 +150,7 @@ public function getAttribute($key)
150150
}
151151

152152
// This checks for embedded relation support.
153-
if (method_exists($this, $key) && !method_exists(self::class, $key)) {
153+
if (method_exists($this, $key) && ! method_exists(self::class, $key)) {
154154
return $this->getRelationValue($key);
155155
}
156156

@@ -236,7 +236,7 @@ public function getCasts()
236236
*/
237237
public function originalIsEquivalent($key)
238238
{
239-
if (!array_key_exists($key, $this->original)) {
239+
if (! array_key_exists($key, $this->original)) {
240240
return false;
241241
}
242242

@@ -294,9 +294,9 @@ public function push()
294294
$unique = false;
295295

296296
if (count($parameters) === 3) {
297-
list($column, $values, $unique) = $parameters;
297+
[$column, $values, $unique] = $parameters;
298298
} else {
299-
list($column, $values) = $parameters;
299+
[$column, $values] = $parameters;
300300
}
301301

302302
// Do batch push by default.
@@ -342,7 +342,7 @@ protected function pushAttributeValues($column, array $values, $unique = false)
342342

343343
foreach ($values as $value) {
344344
// Don't add duplicate values when we only want unique values.
345-
if ($unique && (!is_array($current) || in_array($value, $current))) {
345+
if ($unique && (! is_array($current) || in_array($value, $current))) {
346346
continue;
347347
}
348348

@@ -383,7 +383,7 @@ protected function pullAttributeValues($column, array $values)
383383
*/
384384
public function getForeignKey()
385385
{
386-
return Str::snake(class_basename($this)) . '_' . ltrim($this->primaryKey, '_');
386+
return Str::snake(class_basename($this)).'_'.ltrim($this->primaryKey, '_');
387387
}
388388

389389
/**
@@ -445,13 +445,13 @@ public function getQueueableRelations()
445445

446446
if ($relation instanceof QueueableCollection) {
447447
foreach ($relation->getQueueableRelations() as $collectionValue) {
448-
$relations[] = $key . '.' . $collectionValue;
448+
$relations[] = $key.'.'.$collectionValue;
449449
}
450450
}
451451

452452
if ($relation instanceof QueueableEntity) {
453453
foreach ($relation->getQueueableRelations() as $entityKey => $entityValue) {
454-
$relations[] = $key . '.' . $entityValue;
454+
$relations[] = $key.'.'.$entityValue;
455455
}
456456
}
457457
}
@@ -476,7 +476,7 @@ protected function getRelationsWithoutParent()
476476

477477
/**
478478
* Checks if column exists on a table. As this is a document model, just return true. This also
479-
* prevents calls to non-existent function Grammar::compileColumnListing()
479+
* prevents calls to non-existent function Grammar::compileColumnListing().
480480
* @param string $key
481481
* @return bool
482482
*/

0 commit comments

Comments
 (0)