Skip to content

Commit b379bd3

Browse files
authored
Merge pull request #1986 from divine/analysis-KZ0ZE3
[4.x] Apply fixes from StyleCI
2 parents 444e90d + 56b874d commit b379bd3

Some content is hidden

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

53 files changed

+242
-202
lines changed

src/Jenssegers/Mongodb/Auth/DatabaseTokenRepository.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
class DatabaseTokenRepository extends BaseDatabaseTokenRepository
1212
{
1313
/**
14-
* @inheritdoc
14+
* {@inheritdoc}
1515
*/
1616
protected function getPayload($email, $token)
1717
{
@@ -23,7 +23,7 @@ protected function getPayload($email, $token)
2323
}
2424

2525
/**
26-
* @inheritdoc
26+
* {@inheritdoc}
2727
*/
2828
protected function tokenExpired($createdAt)
2929
{
@@ -33,7 +33,7 @@ protected function tokenExpired($createdAt)
3333
}
3434

3535
/**
36-
* @inheritdoc
36+
* {@inheritdoc}
3737
*/
3838
protected function tokenRecentlyCreated($createdAt)
3939
{

src/Jenssegers/Mongodb/Auth/PasswordBrokerManager.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
class PasswordBrokerManager extends BasePasswordBrokerManager
88
{
99
/**
10-
* @inheritdoc
10+
* {@inheritdoc}
1111
*/
1212
protected function createTokenRepository(array $config)
1313
{

src/Jenssegers/Mongodb/Auth/PasswordResetServiceProvider.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ protected function registerTokenRepository()
2929
}
3030

3131
/**
32-
* @inheritdoc
32+
* {@inheritdoc}
3333
*/
3434
protected function registerPasswordBroker()
3535
{

src/Jenssegers/Mongodb/Collection.php

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

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

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

src/Jenssegers/Mongodb/Connection.php

+17-16
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function getCollection($name)
8585
}
8686

8787
/**
88-
* @inheritdoc
88+
* {@inheritdoc}
8989
*/
9090
public function getSchemaBuilder()
9191
{
@@ -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,18 +155,18 @@ 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

165165
return new Client($dsn, $options, $driverOptions);
166166
}
167167

168168
/**
169-
* @inheritdoc
169+
* {@inheritdoc}
170170
*/
171171
public function disconnect()
172172
{
@@ -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
/**
@@ -228,39 +229,39 @@ protected function getDsn(array $config)
228229
}
229230

230231
/**
231-
* @inheritdoc
232+
* {@inheritdoc}
232233
*/
233234
public function getElapsedTime($start)
234235
{
235236
return parent::getElapsedTime($start);
236237
}
237238

238239
/**
239-
* @inheritdoc
240+
* {@inheritdoc}
240241
*/
241242
public function getDriverName()
242243
{
243244
return 'mongodb';
244245
}
245246

246247
/**
247-
* @inheritdoc
248+
* {@inheritdoc}
248249
*/
249250
protected function getDefaultPostProcessor()
250251
{
251252
return new Query\Processor();
252253
}
253254

254255
/**
255-
* @inheritdoc
256+
* {@inheritdoc}
256257
*/
257258
protected function getDefaultQueryGrammar()
258259
{
259260
return new Query\Grammar();
260261
}
261262

262263
/**
263-
* @inheritdoc
264+
* {@inheritdoc}
264265
*/
265266
protected function getDefaultSchemaGrammar()
266267
{

src/Jenssegers/Mongodb/Eloquent/Builder.php

+10-10
Original file line numberDiff line numberDiff line change
@@ -31,63 +31,63 @@ class Builder extends EloquentBuilder
3131
];
3232

3333
/**
34-
* @inheritdoc
34+
* {@inheritdoc}
3535
*/
3636
public function update(array $values, array $options = [])
3737
{
3838
return $this->toBase()->update($this->addUpdatedAtColumn($values), $options);
3939
}
4040

4141
/**
42-
* @inheritdoc
42+
* {@inheritdoc}
4343
*/
4444
public function insert(array $values)
4545
{
4646
return parent::insert($values);
4747
}
4848

4949
/**
50-
* @inheritdoc
50+
* {@inheritdoc}
5151
*/
5252
public function insertGetId(array $values, $sequence = null)
5353
{
5454
return parent::insertGetId($values, $sequence);
5555
}
5656

5757
/**
58-
* @inheritdoc
58+
* {@inheritdoc}
5959
*/
6060
public function delete()
6161
{
6262
return parent::delete();
6363
}
6464

6565
/**
66-
* @inheritdoc
66+
* {@inheritdoc}
6767
*/
6868
public function increment($column, $amount = 1, array $extra = [])
6969
{
7070
return parent::increment($column, $amount, $extra);
7171
}
7272

7373
/**
74-
* @inheritdoc
74+
* {@inheritdoc}
7575
*/
7676
public function decrement($column, $amount = 1, array $extra = [])
7777
{
7878
return parent::decrement($column, $amount, $extra);
7979
}
8080

8181
/**
82-
* @inheritdoc
82+
* {@inheritdoc}
8383
*/
8484
public function chunkById($count, callable $callback, $column = '_id', $alias = null)
8585
{
8686
return parent::chunkById($count, $callback, $column, $alias);
8787
}
8888

8989
/**
90-
* @inheritdoc
90+
* {@inheritdoc}
9191
*/
9292
public function raw($expression = null)
9393
{
@@ -116,13 +116,13 @@ public function raw($expression = null)
116116
* Add the "updated at" column to an array of values.
117117
* TODO Remove if https://github.com/laravel/framework/commit/6484744326531829341e1ff886cc9b628b20d73e
118118
* wiil be reverted
119-
* Issue in laravel frawework https://github.com/laravel/framework/issues/27791
119+
* Issue in laravel frawework https://github.com/laravel/framework/issues/27791.
120120
* @param array $values
121121
* @return array
122122
*/
123123
protected function addUpdatedAtColumn(array $values)
124124
{
125-
if (!$this->model->usesTimestamps() || $this->model->getUpdatedAtColumn() === null) {
125+
if (! $this->model->usesTimestamps() || $this->model->getUpdatedAtColumn() === null) {
126126
return $values;
127127
}
128128

src/Jenssegers/Mongodb/Eloquent/HybridRelations.php

+16-16
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
@@ -289,7 +289,7 @@ protected function guessBelongsToManyRelation()
289289
}
290290

291291
/**
292-
* @inheritdoc
292+
* {@inheritdoc}
293293
*/
294294
public function newEloquentBuilder($query)
295295
{

0 commit comments

Comments
 (0)