diff --git a/src/Jenssegers/Mongodb/Auth/DatabaseTokenRepository.php b/src/Jenssegers/Mongodb/Auth/DatabaseTokenRepository.php index cf0f89ea1..f4dcadb75 100644 --- a/src/Jenssegers/Mongodb/Auth/DatabaseTokenRepository.php +++ b/src/Jenssegers/Mongodb/Auth/DatabaseTokenRepository.php @@ -11,7 +11,7 @@ class DatabaseTokenRepository extends BaseDatabaseTokenRepository { /** - * @inheritdoc + * {@inheritdoc} */ protected function getPayload($email, $token) { @@ -23,7 +23,7 @@ protected function getPayload($email, $token) } /** - * @inheritdoc + * {@inheritdoc} */ protected function tokenExpired($createdAt) { @@ -33,7 +33,7 @@ protected function tokenExpired($createdAt) } /** - * @inheritdoc + * {@inheritdoc} */ protected function tokenRecentlyCreated($createdAt) { diff --git a/src/Jenssegers/Mongodb/Auth/PasswordBrokerManager.php b/src/Jenssegers/Mongodb/Auth/PasswordBrokerManager.php index 281f8af75..62c9a0cbe 100644 --- a/src/Jenssegers/Mongodb/Auth/PasswordBrokerManager.php +++ b/src/Jenssegers/Mongodb/Auth/PasswordBrokerManager.php @@ -7,7 +7,7 @@ class PasswordBrokerManager extends BasePasswordBrokerManager { /** - * @inheritdoc + * {@inheritdoc} */ protected function createTokenRepository(array $config) { diff --git a/src/Jenssegers/Mongodb/Auth/PasswordResetServiceProvider.php b/src/Jenssegers/Mongodb/Auth/PasswordResetServiceProvider.php index 6e678d2ec..fc3f5acb0 100644 --- a/src/Jenssegers/Mongodb/Auth/PasswordResetServiceProvider.php +++ b/src/Jenssegers/Mongodb/Auth/PasswordResetServiceProvider.php @@ -29,7 +29,7 @@ protected function registerTokenRepository() } /** - * @inheritdoc + * {@inheritdoc} */ protected function registerPasswordBroker() { diff --git a/src/Jenssegers/Mongodb/Collection.php b/src/Jenssegers/Mongodb/Collection.php index 4192edd43..4a7e54d9d 100644 --- a/src/Jenssegers/Mongodb/Collection.php +++ b/src/Jenssegers/Mongodb/Collection.php @@ -65,7 +65,7 @@ public function __call($method, $parameters) } } - $queryString = $this->collection->getCollectionName() . '.' . $method . '(' . implode(',', $query) . ')'; + $queryString = $this->collection->getCollectionName().'.'.$method.'('.implode(',', $query).')'; $this->connection->logQuery($queryString, [], $time); } diff --git a/src/Jenssegers/Mongodb/Connection.php b/src/Jenssegers/Mongodb/Connection.php index b5ba23762..e658ea491 100644 --- a/src/Jenssegers/Mongodb/Connection.php +++ b/src/Jenssegers/Mongodb/Connection.php @@ -85,7 +85,7 @@ public function getCollection($name) } /** - * @inheritdoc + * {@inheritdoc} */ public function getSchemaBuilder() { @@ -119,7 +119,7 @@ public function getDatabaseName() } /** - * Get the name of the default database based on db config or try to detect it from dsn + * Get the name of the default database based on db config or try to detect it from dsn. * @param string $dsn * @param array $config * @return string @@ -131,7 +131,7 @@ protected function getDefaultDatabaseName($dsn, $config) if (preg_match('/^mongodb(?:[+]srv)?:\\/\\/.+\\/([^?&]+)/s', $dsn, $matches)) { $config['database'] = $matches[1]; } else { - throw new InvalidArgumentException("Database is not properly configured."); + throw new InvalidArgumentException('Database is not properly configured.'); } } @@ -155,10 +155,10 @@ protected function createConnection($dsn, array $config, array $options) } // Check if the credentials are not already set in the options - if (!isset($options['username']) && !empty($config['username'])) { + if (! isset($options['username']) && ! empty($config['username'])) { $options['username'] = $config['username']; } - if (!isset($options['password']) && !empty($config['password'])) { + if (! isset($options['password']) && ! empty($config['password'])) { $options['password'] = $config['password']; } @@ -166,7 +166,7 @@ protected function createConnection($dsn, array $config, array $options) } /** - * @inheritdoc + * {@inheritdoc} */ public function disconnect() { @@ -180,7 +180,7 @@ public function disconnect() */ protected function hasDsnString(array $config) { - return isset($config['dsn']) && !empty($config['dsn']); + return isset($config['dsn']) && ! empty($config['dsn']); } /** @@ -205,14 +205,15 @@ protected function getHostDsn(array $config) foreach ($hosts as &$host) { // Check if we need to add a port to the host - if (strpos($host, ':') === false && !empty($config['port'])) { - $host = $host . ':' . $config['port']; + if (strpos($host, ':') === false && ! empty($config['port'])) { + $host = $host.':'.$config['port']; } } // Check if we want to authenticate against a specific database. - $auth_database = isset($config['options']) && !empty($config['options']['database']) ? $config['options']['database'] : null; - return 'mongodb://' . implode(',', $hosts) . ($auth_database ? '/' . $auth_database : ''); + $auth_database = isset($config['options']) && ! empty($config['options']['database']) ? $config['options']['database'] : null; + + return 'mongodb://'.implode(',', $hosts).($auth_database ? '/'.$auth_database : ''); } /** @@ -228,7 +229,7 @@ protected function getDsn(array $config) } /** - * @inheritdoc + * {@inheritdoc} */ public function getElapsedTime($start) { @@ -236,7 +237,7 @@ public function getElapsedTime($start) } /** - * @inheritdoc + * {@inheritdoc} */ public function getDriverName() { @@ -244,7 +245,7 @@ public function getDriverName() } /** - * @inheritdoc + * {@inheritdoc} */ protected function getDefaultPostProcessor() { @@ -252,7 +253,7 @@ protected function getDefaultPostProcessor() } /** - * @inheritdoc + * {@inheritdoc} */ protected function getDefaultQueryGrammar() { @@ -260,7 +261,7 @@ protected function getDefaultQueryGrammar() } /** - * @inheritdoc + * {@inheritdoc} */ protected function getDefaultSchemaGrammar() { diff --git a/src/Jenssegers/Mongodb/Eloquent/Builder.php b/src/Jenssegers/Mongodb/Eloquent/Builder.php index 89206c0d6..7749fabda 100644 --- a/src/Jenssegers/Mongodb/Eloquent/Builder.php +++ b/src/Jenssegers/Mongodb/Eloquent/Builder.php @@ -31,7 +31,7 @@ class Builder extends EloquentBuilder ]; /** - * @inheritdoc + * {@inheritdoc} */ public function update(array $values, array $options = []) { @@ -39,7 +39,7 @@ public function update(array $values, array $options = []) } /** - * @inheritdoc + * {@inheritdoc} */ public function insert(array $values) { @@ -47,7 +47,7 @@ public function insert(array $values) } /** - * @inheritdoc + * {@inheritdoc} */ public function insertGetId(array $values, $sequence = null) { @@ -55,7 +55,7 @@ public function insertGetId(array $values, $sequence = null) } /** - * @inheritdoc + * {@inheritdoc} */ public function delete() { @@ -63,7 +63,7 @@ public function delete() } /** - * @inheritdoc + * {@inheritdoc} */ public function increment($column, $amount = 1, array $extra = []) { @@ -71,7 +71,7 @@ public function increment($column, $amount = 1, array $extra = []) } /** - * @inheritdoc + * {@inheritdoc} */ public function decrement($column, $amount = 1, array $extra = []) { @@ -79,7 +79,7 @@ public function decrement($column, $amount = 1, array $extra = []) } /** - * @inheritdoc + * {@inheritdoc} */ public function chunkById($count, callable $callback, $column = '_id', $alias = null) { @@ -87,7 +87,7 @@ public function chunkById($count, callable $callback, $column = '_id', $alias = } /** - * @inheritdoc + * {@inheritdoc} */ public function raw($expression = null) { @@ -116,13 +116,13 @@ public function raw($expression = null) * Add the "updated at" column to an array of values. * TODO Remove if https://github.com/laravel/framework/commit/6484744326531829341e1ff886cc9b628b20d73e * wiil be reverted - * Issue in laravel frawework https://github.com/laravel/framework/issues/27791 + * Issue in laravel frawework https://github.com/laravel/framework/issues/27791. * @param array $values * @return array */ protected function addUpdatedAtColumn(array $values) { - if (!$this->model->usesTimestamps() || $this->model->getUpdatedAtColumn() === null) { + if (! $this->model->usesTimestamps() || $this->model->getUpdatedAtColumn() === null) { return $values; } diff --git a/src/Jenssegers/Mongodb/Eloquent/HybridRelations.php b/src/Jenssegers/Mongodb/Eloquent/HybridRelations.php index 3cfea00bf..593accdde 100644 --- a/src/Jenssegers/Mongodb/Eloquent/HybridRelations.php +++ b/src/Jenssegers/Mongodb/Eloquent/HybridRelations.php @@ -9,8 +9,8 @@ use Jenssegers\Mongodb\Relations\BelongsToMany; use Jenssegers\Mongodb\Relations\HasMany; use Jenssegers\Mongodb\Relations\HasOne; -use Jenssegers\Mongodb\Relations\MorphTo; use Jenssegers\Mongodb\Relations\MorphMany; +use Jenssegers\Mongodb\Relations\MorphTo; trait HybridRelations { @@ -24,7 +24,7 @@ trait HybridRelations public function hasOne($related, $foreignKey = null, $localKey = null) { // Check if it is a relation with an original model. - if (!is_subclass_of($related, \Jenssegers\Mongodb\Eloquent\Model::class)) { + if (! is_subclass_of($related, \Jenssegers\Mongodb\Eloquent\Model::class)) { return parent::hasOne($related, $foreignKey, $localKey); } @@ -49,13 +49,13 @@ public function hasOne($related, $foreignKey = null, $localKey = null) public function morphOne($related, $name, $type = null, $id = null, $localKey = null) { // Check if it is a relation with an original model. - if (!is_subclass_of($related, \Jenssegers\Mongodb\Eloquent\Model::class)) { + if (! is_subclass_of($related, \Jenssegers\Mongodb\Eloquent\Model::class)) { return parent::morphOne($related, $name, $type, $id, $localKey); } $instance = new $related; - list($type, $id) = $this->getMorphs($name, $type, $id); + [$type, $id] = $this->getMorphs($name, $type, $id); $localKey = $localKey ?: $this->getKeyName(); @@ -72,7 +72,7 @@ public function morphOne($related, $name, $type = null, $id = null, $localKey = public function hasMany($related, $foreignKey = null, $localKey = null) { // Check if it is a relation with an original model. - if (!is_subclass_of($related, \Jenssegers\Mongodb\Eloquent\Model::class)) { + if (! is_subclass_of($related, \Jenssegers\Mongodb\Eloquent\Model::class)) { return parent::hasMany($related, $foreignKey, $localKey); } @@ -97,7 +97,7 @@ public function hasMany($related, $foreignKey = null, $localKey = null) public function morphMany($related, $name, $type = null, $id = null, $localKey = null) { // Check if it is a relation with an original model. - if (!is_subclass_of($related, \Jenssegers\Mongodb\Eloquent\Model::class)) { + if (! is_subclass_of($related, \Jenssegers\Mongodb\Eloquent\Model::class)) { return parent::morphMany($related, $name, $type, $id, $localKey); } @@ -106,7 +106,7 @@ public function morphMany($related, $name, $type = null, $id = null, $localKey = // Here we will gather up the morph type and ID for the relationship so that we // can properly query the intermediate table of a relation. Finally, we will // get the table and create the relationship instances for the developers. - list($type, $id) = $this->getMorphs($name, $type, $id); + [$type, $id] = $this->getMorphs($name, $type, $id); $table = $instance->getTable(); @@ -129,13 +129,13 @@ public function belongsTo($related, $foreignKey = null, $otherKey = null, $relat // the calling method's name and use that as the relationship name as most // of the time this will be what we desire to use for the relationships. if ($relation === null) { - list($current, $caller) = debug_backtrace(false, 2); + [$current, $caller] = debug_backtrace(false, 2); $relation = $caller['function']; } // Check if it is a relation with an original model. - if (!is_subclass_of($related, \Jenssegers\Mongodb\Eloquent\Model::class)) { + if (! is_subclass_of($related, \Jenssegers\Mongodb\Eloquent\Model::class)) { return parent::belongsTo($related, $foreignKey, $otherKey, $relation); } @@ -143,7 +143,7 @@ public function belongsTo($related, $foreignKey = null, $otherKey = null, $relat // foreign key name by using the name of the relationship function, which // when combined with an "_id" should conventionally match the columns. if ($foreignKey === null) { - $foreignKey = Str::snake($relation) . '_id'; + $foreignKey = Str::snake($relation).'_id'; } $instance = new $related; @@ -172,12 +172,12 @@ public function morphTo($name = null, $type = null, $id = null, $ownerKey = null // since that is most likely the name of the polymorphic interface. We can // use that to get both the class and foreign key that will be utilized. if ($name === null) { - list($current, $caller) = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2); + [$current, $caller] = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2); $name = Str::snake($caller['function']); } - list($type, $id) = $this->getMorphs($name, $type, $id); + [$type, $id] = $this->getMorphs($name, $type, $id); // If the type value is null it is probably safe to assume we're eager loading // the relationship. When that is the case we will pass in a dummy query as @@ -230,7 +230,7 @@ public function belongsToMany( } // Check if it is a relation with an original model. - if (!is_subclass_of($related, \Jenssegers\Mongodb\Eloquent\Model::class)) { + if (! is_subclass_of($related, \Jenssegers\Mongodb\Eloquent\Model::class)) { return parent::belongsToMany( $related, $collection, @@ -245,11 +245,11 @@ public function belongsToMany( // First, we'll need to determine the foreign key and "other key" for the // relationship. Once we have determined the keys we'll make the query // instances as well as the relationship instances we need for this. - $foreignKey = $foreignKey ?: $this->getForeignKey() . 's'; + $foreignKey = $foreignKey ?: $this->getForeignKey().'s'; $instance = new $related; - $otherKey = $otherKey ?: $instance->getForeignKey() . 's'; + $otherKey = $otherKey ?: $instance->getForeignKey().'s'; // If no table name was provided, we can guess it by concatenating the two // models using underscores in alphabetical order. The two model names @@ -289,7 +289,7 @@ protected function guessBelongsToManyRelation() } /** - * @inheritdoc + * {@inheritdoc} */ public function newEloquentBuilder($query) { diff --git a/src/Jenssegers/Mongodb/Eloquent/Model.php b/src/Jenssegers/Mongodb/Eloquent/Model.php index 27e0228fe..aafe49904 100644 --- a/src/Jenssegers/Mongodb/Eloquent/Model.php +++ b/src/Jenssegers/Mongodb/Eloquent/Model.php @@ -52,7 +52,7 @@ public function getIdAttribute($value = null) { // If we don't have a value for 'id', we will use the Mongo '_id' value. // This allows us to work with models in a more sql-like way. - if (!$value && array_key_exists('_id', $this->attributes)) { + if (! $value && array_key_exists('_id', $this->attributes)) { $value = $this->attributes['_id']; } @@ -67,7 +67,7 @@ public function getIdAttribute($value = null) } /** - * @inheritdoc + * {@inheritdoc} */ public function getQualifiedKeyName() { @@ -75,7 +75,7 @@ public function getQualifiedKeyName() } /** - * @inheritdoc + * {@inheritdoc} */ public function fromDateTime($value) { @@ -85,7 +85,7 @@ public function fromDateTime($value) } // Let Eloquent convert the value to a DateTime instance. - if (!$value instanceof DateTime) { + if (! $value instanceof DateTime) { $value = parent::asDateTime($value); } @@ -93,7 +93,7 @@ public function fromDateTime($value) } /** - * @inheritdoc + * {@inheritdoc} */ protected function asDateTime($value) { @@ -106,7 +106,7 @@ protected function asDateTime($value) } /** - * @inheritdoc + * {@inheritdoc} */ public function getDateFormat() { @@ -114,7 +114,7 @@ public function getDateFormat() } /** - * @inheritdoc + * {@inheritdoc} */ public function freshTimestamp() { @@ -122,7 +122,7 @@ public function freshTimestamp() } /** - * @inheritdoc + * {@inheritdoc} */ public function getTable() { @@ -130,11 +130,11 @@ public function getTable() } /** - * @inheritdoc + * {@inheritdoc} */ public function getAttribute($key) { - if (!$key) { + if (! $key) { return; } @@ -147,7 +147,7 @@ public function getAttribute($key) } /** - * @inheritdoc + * {@inheritdoc} */ protected function getAttributeFromArray($key) { @@ -160,7 +160,7 @@ protected function getAttributeFromArray($key) } /** - * @inheritdoc + * {@inheritdoc} */ public function setAttribute($key, $value) { @@ -184,7 +184,7 @@ public function setAttribute($key, $value) } /** - * @inheritdoc + * {@inheritdoc} */ public function attributesToArray() { @@ -213,7 +213,7 @@ public function attributesToArray() } /** - * @inheritdoc + * {@inheritdoc} */ public function getCasts() { @@ -221,11 +221,11 @@ public function getCasts() } /** - * @inheritdoc + * {@inheritdoc} */ public function originalIsEquivalent($key, $current) { - if (!array_key_exists($key, $this->original)) { + if (! array_key_exists($key, $this->original)) { return false; } @@ -274,7 +274,7 @@ public function drop($columns) } /** - * @inheritdoc + * {@inheritdoc} */ public function push() { @@ -282,9 +282,9 @@ public function push() $unique = false; if (count($parameters) === 3) { - list($column, $values, $unique) = $parameters; + [$column, $values, $unique] = $parameters; } else { - list($column, $values) = $parameters; + [$column, $values] = $parameters; } // Do batch push by default. @@ -330,7 +330,7 @@ protected function pushAttributeValues($column, array $values, $unique = false) foreach ($values as $value) { // Don't add duplicate values when we only want unique values. - if ($unique && (!is_array($current) || in_array($value, $current))) { + if ($unique && (! is_array($current) || in_array($value, $current))) { continue; } @@ -367,11 +367,11 @@ protected function pullAttributeValues($column, array $values) } /** - * @inheritdoc + * {@inheritdoc} */ public function getForeignKey() { - return Str::snake(class_basename($this)) . '_' . ltrim($this->primaryKey, '_'); + return Str::snake(class_basename($this)).'_'.ltrim($this->primaryKey, '_'); } /** @@ -393,7 +393,7 @@ public function getParentRelation() } /** - * @inheritdoc + * {@inheritdoc} */ public function newEloquentBuilder($query) { @@ -401,7 +401,7 @@ public function newEloquentBuilder($query) } /** - * @inheritdoc + * {@inheritdoc} */ protected function newBaseQueryBuilder() { @@ -411,7 +411,7 @@ protected function newBaseQueryBuilder() } /** - * @inheritdoc + * {@inheritdoc} */ protected function removeTableFromKey($key) { @@ -433,13 +433,13 @@ public function getQueueableRelations() if ($relation instanceof QueueableCollection) { foreach ($relation->getQueueableRelations() as $collectionValue) { - $relations[] = $key . '.' . $collectionValue; + $relations[] = $key.'.'.$collectionValue; } } if ($relation instanceof QueueableEntity) { foreach ($relation->getQueueableRelations() as $entityKey => $entityValue) { - $relations[] = $key . '.' . $entityValue; + $relations[] = $key.'.'.$entityValue; } } } @@ -463,7 +463,7 @@ protected function getRelationsWithoutParent() } /** - * @inheritdoc + * {@inheritdoc} */ public function __call($method, $parameters) { diff --git a/src/Jenssegers/Mongodb/Eloquent/SoftDeletes.php b/src/Jenssegers/Mongodb/Eloquent/SoftDeletes.php index 89e74b25a..a4fad87a6 100644 --- a/src/Jenssegers/Mongodb/Eloquent/SoftDeletes.php +++ b/src/Jenssegers/Mongodb/Eloquent/SoftDeletes.php @@ -7,7 +7,7 @@ trait SoftDeletes use \Illuminate\Database\Eloquent\SoftDeletes; /** - * @inheritdoc + * {@inheritdoc} */ public function getQualifiedDeletedAtColumn() { diff --git a/src/Jenssegers/Mongodb/Helpers/QueriesRelationships.php b/src/Jenssegers/Mongodb/Helpers/QueriesRelationships.php index 151ead62d..ee130ce79 100644 --- a/src/Jenssegers/Mongodb/Helpers/QueriesRelationships.php +++ b/src/Jenssegers/Mongodb/Helpers/QueriesRelationships.php @@ -71,7 +71,7 @@ protected function isAcrossConnections(Relation $relation) } /** - * Compare across databases + * Compare across databases. * @param Relation $relation * @param string $operator * @param int $count @@ -91,7 +91,7 @@ public function addHybridHas(Relation $relation, $operator = '>=', $count = 1, $ $not = in_array($operator, ['<', '<=', '!=']); // If we are comparing to 0, we need an additional $not flip. if ($count == 0) { - $not = !$not; + $not = ! $not; } $relations = $hasQuery->pluck($this->getHasCompareKey($relation)); @@ -149,7 +149,7 @@ protected function getConstrainedRelatedIds($relations, $operator, $count) } /** - * Returns key we are constraining this parent model's query with + * Returns key we are constraining this parent model's query with. * @param Relation $relation * @return string * @throws Exception @@ -164,10 +164,10 @@ protected function getRelatedConstraintKey(Relation $relation) return $relation->getForeignKeyName(); } - if ($relation instanceof BelongsToMany && !$this->isAcrossConnections($relation)) { + if ($relation instanceof BelongsToMany && ! $this->isAcrossConnections($relation)) { return $this->model->getKeyName(); } - throw new Exception(class_basename($relation) . ' is not supported for hybrid query constraints.'); + throw new Exception(class_basename($relation).' is not supported for hybrid query constraints.'); } } diff --git a/src/Jenssegers/Mongodb/MongodbQueueServiceProvider.php b/src/Jenssegers/Mongodb/MongodbQueueServiceProvider.php index 6c47b0d5d..68211a729 100644 --- a/src/Jenssegers/Mongodb/MongodbQueueServiceProvider.php +++ b/src/Jenssegers/Mongodb/MongodbQueueServiceProvider.php @@ -2,14 +2,14 @@ namespace Jenssegers\Mongodb; -use Illuminate\Support\Facades\DB; use Illuminate\Queue\QueueServiceProvider; +use Illuminate\Support\Facades\DB; use Jenssegers\Mongodb\Queue\Failed\MongoFailedJobProvider; class MongodbQueueServiceProvider extends QueueServiceProvider { /** - * @inheritdoc + * {@inheritdoc} */ protected function registerFailedJobServices() { diff --git a/src/Jenssegers/Mongodb/MongodbServiceProvider.php b/src/Jenssegers/Mongodb/MongodbServiceProvider.php index 99ec5e553..3afb69cf0 100644 --- a/src/Jenssegers/Mongodb/MongodbServiceProvider.php +++ b/src/Jenssegers/Mongodb/MongodbServiceProvider.php @@ -27,6 +27,7 @@ public function register() $this->app->resolving('db', function ($db) { $db->extend('mongodb', function ($config, $name) { $config['name'] = $name; + return new Connection($config); }); }); diff --git a/src/Jenssegers/Mongodb/Query/Builder.php b/src/Jenssegers/Mongodb/Query/Builder.php index 09860c74f..9f33ba758 100644 --- a/src/Jenssegers/Mongodb/Query/Builder.php +++ b/src/Jenssegers/Mongodb/Query/Builder.php @@ -116,7 +116,7 @@ class Builder extends BaseBuilder ]; /** - * @inheritdoc + * {@inheritdoc} */ public function __construct(Connection $connection, Processor $processor) { @@ -162,7 +162,7 @@ public function hint($index) } /** - * @inheritdoc + * {@inheritdoc} */ public function find($id, $columns = []) { @@ -170,7 +170,7 @@ public function find($id, $columns = []) } /** - * @inheritdoc + * {@inheritdoc} */ public function value($column) { @@ -180,7 +180,7 @@ public function value($column) } /** - * @inheritdoc + * {@inheritdoc} */ public function get($columns = []) { @@ -217,18 +217,18 @@ public function getFresh($columns = []) // Add grouping columns to the $group part of the aggregation pipeline. if ($this->groups) { foreach ($this->groups as $column) { - $group['_id'][$column] = '$' . $column; + $group['_id'][$column] = '$'.$column; // When grouping, also add the $last operator to each grouped field, // this mimics MySQL's behaviour a bit. - $group[$column] = ['$last' => '$' . $column]; + $group[$column] = ['$last' => '$'.$column]; } // Do the same for other columns that are selected. foreach ($this->columns as $column) { $key = str_replace('.', '_', $column); - $group[$key] = ['$last' => '$' . $column]; + $group[$key] = ['$last' => '$'.$column]; } } @@ -260,15 +260,16 @@ public function getFresh($columns = []) $results = [ [ '_id' => null, - 'aggregate' => $totalResults - ] + 'aggregate' => $totalResults, + ], ]; + return new Collection($results); } elseif ($function == 'count') { // Translate count into sum. $group['aggregate'] = ['$sum' => 1]; } else { - $group['aggregate'] = ['$' . $function => '$' . $column]; + $group['aggregate'] = ['$'.$function => '$'.$column]; } } } @@ -286,7 +287,7 @@ public function getFresh($columns = []) // apply unwinds for subdocument array aggregation foreach ($unwinds as $unwind) { - $pipeline[] = ['$unwind' => '$' . $unwind]; + $pipeline[] = ['$unwind' => '$'.$unwind]; } if ($group) { @@ -382,6 +383,7 @@ public function getFresh($columns = []) // Return results as an array with numeric keys $results = iterator_to_array($cursor, false); + return new Collection($results); } } @@ -408,7 +410,7 @@ public function generateCacheKey() } /** - * @inheritdoc + * {@inheritdoc} */ public function aggregate($function, $columns = []) { @@ -440,7 +442,7 @@ public function aggregate($function, $columns = []) } /** - * @inheritdoc + * {@inheritdoc} */ public function exists() { @@ -448,7 +450,7 @@ public function exists() } /** - * @inheritdoc + * {@inheritdoc} */ public function distinct($column = false) { @@ -462,7 +464,7 @@ public function distinct($column = false) } /** - * @inheritdoc + * {@inheritdoc} */ public function orderBy($column, $direction = 'asc') { @@ -497,7 +499,7 @@ public function whereAll($column, array $values, $boolean = 'and', $not = false) } /** - * @inheritdoc + * {@inheritdoc} */ public function whereBetween($column, array $values, $boolean = 'and', $not = false) { @@ -509,7 +511,7 @@ public function whereBetween($column, array $values, $boolean = 'and', $not = fa } /** - * @inheritdoc + * {@inheritdoc} */ public function forPage($page, $perPage = 15) { @@ -519,7 +521,7 @@ public function forPage($page, $perPage = 15) } /** - * @inheritdoc + * {@inheritdoc} */ public function insert(array $values) { @@ -530,24 +532,24 @@ public function insert(array $values) foreach ($values as $value) { // As soon as we find a value that is not an array we assume the user is // inserting a single document. - if (!is_array($value)) { + if (! is_array($value)) { $batch = false; break; } } - if (!$batch) { + if (! $batch) { $values = [$values]; } // Batch insert $result = $this->collection->insertMany($values); - return (1 == (int) $result->isAcknowledged()); + return 1 == (int) $result->isAcknowledged(); } /** - * @inheritdoc + * {@inheritdoc} */ public function insertGetId(array $values, $sequence = null) { @@ -564,12 +566,12 @@ public function insertGetId(array $values, $sequence = null) } /** - * @inheritdoc + * {@inheritdoc} */ public function update(array $values, array $options = []) { // Use $set as default operator. - if (!Str::startsWith(key($values), '$')) { + if (! Str::startsWith(key($values), '$')) { $values = ['$set' => $values]; } @@ -577,13 +579,13 @@ public function update(array $values, array $options = []) } /** - * @inheritdoc + * {@inheritdoc} */ public function increment($column, $amount = 1, array $extra = [], array $options = []) { $query = ['$inc' => [$column => $amount]]; - if (!empty($extra)) { + if (! empty($extra)) { $query['$set'] = $extra; } @@ -598,7 +600,7 @@ public function increment($column, $amount = 1, array $extra = [], array $option } /** - * @inheritdoc + * {@inheritdoc} */ public function decrement($column, $amount = 1, array $extra = [], array $options = []) { @@ -606,7 +608,7 @@ public function decrement($column, $amount = 1, array $extra = [], array $option } /** - * @inheritdoc + * {@inheritdoc} */ public function chunkById($count, callable $callback, $column = '_id', $alias = null) { @@ -614,7 +616,7 @@ public function chunkById($count, callable $callback, $column = '_id', $alias = } /** - * @inheritdoc + * {@inheritdoc} */ public function forPageAfterId($perPage = 15, $lastId = 0, $column = '_id') { @@ -622,7 +624,7 @@ public function forPageAfterId($perPage = 15, $lastId = 0, $column = '_id') } /** - * @inheritdoc + * {@inheritdoc} */ public function pluck($column, $key = null) { @@ -632,16 +634,18 @@ public function pluck($column, $key = null) if ($key == '_id') { $results = $results->map(function ($item) { $item['_id'] = (string) $item['_id']; + return $item; }); } $p = Arr::pluck($results, $column, $key); + return new Collection($p); } /** - * @inheritdoc + * {@inheritdoc} */ public function delete($id = null) { @@ -662,7 +666,7 @@ public function delete($id = null) } /** - * @inheritdoc + * {@inheritdoc} */ public function from($collection, $as = null) { @@ -674,7 +678,7 @@ public function from($collection, $as = null) } /** - * @inheritdoc + * {@inheritdoc} */ public function truncate() { @@ -684,7 +688,7 @@ public function truncate() $result = $this->collection->drop($options); - return (1 == (int) $result->ok); + return 1 == (int) $result->ok; } /** @@ -700,7 +704,7 @@ public function lists($column, $key = null) } /** - * @inheritdoc + * {@inheritdoc} */ public function raw($expression = null) { @@ -774,7 +778,7 @@ public function pull($column, $value = null) */ public function drop($columns) { - if (!is_array($columns)) { + if (! is_array($columns)) { $columns = [$columns]; } @@ -790,11 +794,11 @@ public function drop($columns) } /** - * @inheritdoc + * {@inheritdoc} */ public function newQuery() { - return new Builder($this->connection, $this->processor); + return new self($this->connection, $this->processor); } /** @@ -806,7 +810,7 @@ public function newQuery() protected function performUpdate($query, array $options = []) { // Update multiple items by default. - if (!array_key_exists('multiple', $options)) { + if (! array_key_exists('multiple', $options)) { $options['multiple'] = true; } @@ -838,7 +842,7 @@ public function convertKey($id) } /** - * @inheritdoc + * {@inheritdoc} */ public function where($column, $operator = null, $value = null, $boolean = 'and') { @@ -984,10 +988,10 @@ protected function compileWhereBasic(array $where) $regex = preg_replace('#(^|[^\\\])%#', '$1.*', preg_quote($value)); // Convert like to regular expression. - if (!Str::startsWith($value, '%')) { - $regex = '^' . $regex; + if (! Str::startsWith($value, '%')) { + $regex = '^'.$regex; } - if (!Str::endsWith($value, '%')) { + if (! Str::endsWith($value, '%')) { $regex .= '$'; } @@ -995,7 +999,7 @@ protected function compileWhereBasic(array $where) } // Manipulate regexp operations. elseif (in_array($operator, ['regexp', 'not regexp', 'regex', 'not regex'])) { // Automatically convert regular expression strings to Regex objects. - if (!$value instanceof Regex) { + if (! $value instanceof Regex) { $e = explode('/', $value); $flag = end($e); $regstr = substr($value, 1, -(strlen($flag) + 1)); @@ -1009,12 +1013,12 @@ protected function compileWhereBasic(array $where) } } - if (!isset($operator) || $operator == '=') { + if (! isset($operator) || $operator == '=') { $query = [$column => $value]; } elseif (array_key_exists($operator, $this->conversion)) { $query = [$column => [$this->conversion[$operator] => $value]]; } else { - $query = [$column => ['$' . $operator => $value]]; + $query = [$column => ['$'.$operator => $value]]; } return $query; @@ -1132,7 +1136,7 @@ public function options(array $options) } /** - * @inheritdoc + * {@inheritdoc} */ public function __call($method, $parameters) { diff --git a/src/Jenssegers/Mongodb/Queue/Failed/MongoFailedJobProvider.php b/src/Jenssegers/Mongodb/Queue/Failed/MongoFailedJobProvider.php index d350bb032..e130cbeab 100644 --- a/src/Jenssegers/Mongodb/Queue/Failed/MongoFailedJobProvider.php +++ b/src/Jenssegers/Mongodb/Queue/Failed/MongoFailedJobProvider.php @@ -34,6 +34,7 @@ public function all() $all = array_map(function ($job) { $job['id'] = (string) $job['_id']; + return (object) $job; }, $all); @@ -49,7 +50,7 @@ public function find($id) { $job = $this->getTable()->find($id); - if (!$job) { + if (! $job) { return; } diff --git a/src/Jenssegers/Mongodb/Queue/MongoQueue.php b/src/Jenssegers/Mongodb/Queue/MongoQueue.php index 369ef6b72..43b5a1416 100644 --- a/src/Jenssegers/Mongodb/Queue/MongoQueue.php +++ b/src/Jenssegers/Mongodb/Queue/MongoQueue.php @@ -22,7 +22,7 @@ class MongoQueue extends DatabaseQueue protected $connectionName; /** - * @inheritdoc + * {@inheritdoc} */ public function __construct(Connection $database, $table, $default = 'default', $retryAfter = 60) { @@ -31,7 +31,7 @@ public function __construct(Connection $database, $table, $default = 'default', } /** - * @inheritdoc + * {@inheritdoc} */ public function pop($queue = null) { @@ -125,7 +125,7 @@ protected function releaseJob($id, $attempts) } /** - * @inheritdoc + * {@inheritdoc} */ public function deleteReserved($queue, $id) { diff --git a/src/Jenssegers/Mongodb/Relations/BelongsTo.php b/src/Jenssegers/Mongodb/Relations/BelongsTo.php index b47e856fa..ef6f4a3b7 100644 --- a/src/Jenssegers/Mongodb/Relations/BelongsTo.php +++ b/src/Jenssegers/Mongodb/Relations/BelongsTo.php @@ -17,7 +17,7 @@ public function getHasCompareKey() } /** - * @inheritdoc + * {@inheritdoc} */ public function addConstraints() { @@ -30,7 +30,7 @@ public function addConstraints() } /** - * @inheritdoc + * {@inheritdoc} */ public function addEagerConstraints(array $models) { @@ -43,7 +43,7 @@ public function addEagerConstraints(array $models) } /** - * @inheritdoc + * {@inheritdoc} */ public function getRelationExistenceQuery(Builder $query, Builder $parentQuery, $columns = ['*']) { diff --git a/src/Jenssegers/Mongodb/Relations/BelongsToMany.php b/src/Jenssegers/Mongodb/Relations/BelongsToMany.php index 36de393dc..ac1ac7c02 100644 --- a/src/Jenssegers/Mongodb/Relations/BelongsToMany.php +++ b/src/Jenssegers/Mongodb/Relations/BelongsToMany.php @@ -21,7 +21,7 @@ public function getHasCompareKey() } /** - * @inheritdoc + * {@inheritdoc} */ public function getRelationExistenceQuery(Builder $query, Builder $parentQuery, $columns = ['*']) { @@ -29,7 +29,7 @@ public function getRelationExistenceQuery(Builder $query, Builder $parentQuery, } /** - * @inheritdoc + * {@inheritdoc} */ protected function hydratePivotRelation(array $models) { @@ -47,7 +47,7 @@ protected function getSelectColumns(array $columns = ['*']) } /** - * @inheritdoc + * {@inheritdoc} */ protected function shouldSelect(array $columns = ['*']) { @@ -55,7 +55,7 @@ protected function shouldSelect(array $columns = ['*']) } /** - * @inheritdoc + * {@inheritdoc} */ public function addConstraints() { @@ -78,7 +78,7 @@ protected function setWhere() } /** - * @inheritdoc + * {@inheritdoc} */ public function save(Model $model, array $joining = [], $touch = true) { @@ -90,7 +90,7 @@ public function save(Model $model, array $joining = [], $touch = true) } /** - * @inheritdoc + * {@inheritdoc} */ public function create(array $attributes = [], array $joining = [], $touch = true) { @@ -107,7 +107,7 @@ public function create(array $attributes = [], array $joining = [], $touch = tru } /** - * @inheritdoc + * {@inheritdoc} */ public function sync($ids, $detaching = true) { @@ -167,7 +167,7 @@ public function sync($ids, $detaching = true) } /** - * @inheritdoc + * {@inheritdoc} */ public function updateExistingPivot($id, array $attributes, $touch = true) { @@ -175,7 +175,7 @@ public function updateExistingPivot($id, array $attributes, $touch = true) } /** - * @inheritdoc + * {@inheritdoc} */ public function attach($id, array $attributes = [], $touch = true) { @@ -208,7 +208,7 @@ public function attach($id, array $attributes = [], $touch = true) } /** - * @inheritdoc + * {@inheritdoc} */ public function detach($ids = [], $touch = true) { @@ -242,7 +242,7 @@ public function detach($ids = [], $touch = true) } /** - * @inheritdoc + * {@inheritdoc} */ protected function buildDictionary(Collection $results) { @@ -263,7 +263,7 @@ protected function buildDictionary(Collection $results) } /** - * @inheritdoc + * {@inheritdoc} */ public function newPivotQuery() { @@ -289,7 +289,7 @@ public function getForeignKey() } /** - * @inheritdoc + * {@inheritdoc} */ public function getQualifiedForeignPivotKeyName() { @@ -297,7 +297,7 @@ public function getQualifiedForeignPivotKeyName() } /** - * @inheritdoc + * {@inheritdoc} */ public function getQualifiedRelatedPivotKeyName() { @@ -306,7 +306,7 @@ public function getQualifiedRelatedPivotKeyName() /** * Format the sync list so that it is keyed by ID. (Legacy Support) - * The original function has been renamed to formatRecordsList since Laravel 5.3 + * The original function has been renamed to formatRecordsList since Laravel 5.3. * @param array $records * @return array * @deprecated @@ -315,11 +315,12 @@ protected function formatSyncList(array $records) { $results = []; foreach ($records as $id => $attributes) { - if (!is_array($attributes)) { - list($id, $attributes) = [$attributes, []]; + if (! is_array($attributes)) { + [$id, $attributes] = [$attributes, []]; } $results[$id] = $attributes; } + return $results; } diff --git a/src/Jenssegers/Mongodb/Relations/HasMany.php b/src/Jenssegers/Mongodb/Relations/HasMany.php index b10426635..99e314abf 100644 --- a/src/Jenssegers/Mongodb/Relations/HasMany.php +++ b/src/Jenssegers/Mongodb/Relations/HasMany.php @@ -36,7 +36,7 @@ public function getHasCompareKey() } /** - * @inheritdoc + * {@inheritdoc} */ public function getRelationExistenceQuery(Builder $query, Builder $parentQuery, $columns = ['*']) { diff --git a/src/Jenssegers/Mongodb/Relations/HasOne.php b/src/Jenssegers/Mongodb/Relations/HasOne.php index 91741c297..0ca0039be 100644 --- a/src/Jenssegers/Mongodb/Relations/HasOne.php +++ b/src/Jenssegers/Mongodb/Relations/HasOne.php @@ -36,7 +36,7 @@ public function getPlainForeignKey() } /** - * @inheritdoc + * {@inheritdoc} */ public function getRelationExistenceQuery(Builder $query, Builder $parentQuery, $columns = ['*']) { diff --git a/src/Jenssegers/Mongodb/Relations/MorphTo.php b/src/Jenssegers/Mongodb/Relations/MorphTo.php index 704c4722c..00fa74f56 100644 --- a/src/Jenssegers/Mongodb/Relations/MorphTo.php +++ b/src/Jenssegers/Mongodb/Relations/MorphTo.php @@ -8,7 +8,7 @@ class MorphTo extends EloquentMorphTo { /** - * @inheritdoc + * {@inheritdoc} */ public function addConstraints() { @@ -21,7 +21,7 @@ public function addConstraints() } /** - * @inheritdoc + * {@inheritdoc} */ protected function getResultsByType($type) { diff --git a/src/Jenssegers/Mongodb/Schema/Blueprint.php b/src/Jenssegers/Mongodb/Schema/Blueprint.php index cc62ec6c1..dc7b26c8b 100644 --- a/src/Jenssegers/Mongodb/Schema/Blueprint.php +++ b/src/Jenssegers/Mongodb/Schema/Blueprint.php @@ -25,7 +25,7 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint protected $columns = []; /** - * @inheritdoc + * {@inheritdoc} */ public function __construct(Connection $connection, $collection) { @@ -35,7 +35,7 @@ public function __construct(Connection $connection, $collection) } /** - * @inheritdoc + * {@inheritdoc} */ public function index($columns = null, $name = null, $algorithm = null, $options = []) { @@ -63,7 +63,7 @@ public function index($columns = null, $name = null, $algorithm = null, $options } /** - * @inheritdoc + * {@inheritdoc} */ public function primary($columns = null, $name = null, $algorithm = null, $options = []) { @@ -71,7 +71,7 @@ public function primary($columns = null, $name = null, $algorithm = null, $optio } /** - * @inheritdoc + * {@inheritdoc} */ public function dropIndex($indexOrColumns = null) { @@ -93,6 +93,7 @@ public function dropIndexIfExists($indexOrColumns = null) if ($this->hasIndex($indexOrColumns)) { $this->dropIndex($indexOrColumns); } + return $this; } @@ -114,6 +115,7 @@ public function hasIndex($indexOrColumns = null) return true; } } + return false; } @@ -140,16 +142,17 @@ protected function transformColumns($indexOrColumns) $sorting = $value; } - $transform[$column] = $column . "_" . $sorting; + $transform[$column] = $column.'_'.$sorting; } $indexOrColumns = implode('_', $transform); } + return $indexOrColumns; } /** - * @inheritdoc + * {@inheritdoc} */ public function unique($columns = null, $name = null, $algorithm = null, $options = []) { @@ -249,7 +252,7 @@ public function create($options = []) } /** - * @inheritdoc + * {@inheritdoc} */ public function drop() { @@ -257,7 +260,7 @@ public function drop() } /** - * @inheritdoc + * {@inheritdoc} */ public function addColumn($type, $name, array $parameters = []) { diff --git a/src/Jenssegers/Mongodb/Schema/Builder.php b/src/Jenssegers/Mongodb/Schema/Builder.php index c01d12426..63ac0ea5c 100644 --- a/src/Jenssegers/Mongodb/Schema/Builder.php +++ b/src/Jenssegers/Mongodb/Schema/Builder.php @@ -8,7 +8,7 @@ class Builder extends \Illuminate\Database\Schema\Builder { /** - * @inheritdoc + * {@inheritdoc} */ public function __construct(Connection $connection) { @@ -16,7 +16,7 @@ public function __construct(Connection $connection) } /** - * @inheritdoc + * {@inheritdoc} */ public function hasColumn($table, $column) { @@ -24,7 +24,7 @@ public function hasColumn($table, $column) } /** - * @inheritdoc + * {@inheritdoc} */ public function hasColumns($table, array $columns) { @@ -50,7 +50,7 @@ public function hasCollection($name) } /** - * @inheritdoc + * {@inheritdoc} */ public function hasTable($collection) { @@ -73,7 +73,7 @@ public function collection($collection, Closure $callback) } /** - * @inheritdoc + * {@inheritdoc} */ public function table($collection, Closure $callback) { @@ -81,7 +81,7 @@ public function table($collection, Closure $callback) } /** - * @inheritdoc + * {@inheritdoc} */ public function create($collection, Closure $callback = null, array $options = []) { @@ -95,7 +95,7 @@ public function create($collection, Closure $callback = null, array $options = [ } /** - * @inheritdoc + * {@inheritdoc} */ public function dropIfExists($collection) { @@ -107,7 +107,7 @@ public function dropIfExists($collection) } /** - * @inheritdoc + * {@inheritdoc} */ public function drop($collection) { @@ -117,7 +117,7 @@ public function drop($collection) } /** - * @inheritdoc + * {@inheritdoc} */ public function dropAllTables() { @@ -127,7 +127,7 @@ public function dropAllTables() } /** - * @inheritdoc + * {@inheritdoc} */ protected function createBlueprint($collection, Closure $callback = null) { diff --git a/src/Jenssegers/Mongodb/Validation/DatabasePresenceVerifier.php b/src/Jenssegers/Mongodb/Validation/DatabasePresenceVerifier.php index a7d57a89b..5f6c4ed36 100644 --- a/src/Jenssegers/Mongodb/Validation/DatabasePresenceVerifier.php +++ b/src/Jenssegers/Mongodb/Validation/DatabasePresenceVerifier.php @@ -40,7 +40,7 @@ public function getCount($collection, $column, $value, $excludeId = null, $idCol public function getMultiCount($collection, $column, array $values, array $extra = []) { // Generates a regex like '/(a|b|c)/i' which can query multiple values - $regex = '/(' . implode('|', $values) . ')/i'; + $regex = '/('.implode('|', $values).')/i'; $query = $this->table($collection)->where($column, 'regex', $regex); diff --git a/tests/AuthTest.php b/tests/AuthTest.php index 84212b84b..912cc9061 100644 --- a/tests/AuthTest.php +++ b/tests/AuthTest.php @@ -29,6 +29,7 @@ public function testRemindOld() { if (Application::VERSION >= '5.2') { $this->expectNotToPerformAssertions(); + return; } diff --git a/tests/CollectionTest.php b/tests/CollectionTest.php index ab0b29b21..460e93e19 100644 --- a/tests/CollectionTest.php +++ b/tests/CollectionTest.php @@ -1,4 +1,5 @@ assertEquals('mongodb://' . $host . '/custom', (string) $connection->getMongoClient()); + $this->assertEquals('mongodb://'.$host.'/custom', (string) $connection->getMongoClient()); } public function testCustomHostAndPort() @@ -106,7 +107,7 @@ public function testCustomHostAndPort() Config::set('database.connections.mongodb.port', 27000); $connection = DB::connection('mongodb'); - $this->assertEquals("mongodb://db1:27000", (string) $connection->getMongoClient()); + $this->assertEquals('mongodb://db1:27000', (string) $connection->getMongoClient()); } public function testHostWithPorts() diff --git a/tests/DsnTest.php b/tests/DsnTest.php index 2eed354f4..85230f852 100644 --- a/tests/DsnTest.php +++ b/tests/DsnTest.php @@ -1,4 +1,5 @@ assertInstanceOf(MySqlConnection::class, $user->getConnection()); // Mysql User - $user->name = "John Doe"; + $user->name = 'John Doe'; $user->save(); $this->assertIsInt($user->id); @@ -54,7 +55,7 @@ public function testMysqlRelations() // MongoDB User $user = new User; - $user->name = "John Doe"; + $user->name = 'John Doe'; $user->save(); // MongoDB has many @@ -88,7 +89,7 @@ public function testHybridWhereHas() $this->assertInstanceOf(MySqlConnection::class, $otherUser->getConnection()); //MySql User - $user->name = "John Doe"; + $user->name = 'John Doe'; $user->id = 2; $user->save(); // Other user @@ -142,7 +143,7 @@ public function testHybridWith() $this->assertInstanceOf(MySqlConnection::class, $otherUser->getConnection()); //MySql User - $user->name = "John Doe"; + $user->name = 'John Doe'; $user->id = 2; $user->save(); // Other user diff --git a/tests/ModelTest.php b/tests/ModelTest.php index ce7177fe6..c374ea828 100644 --- a/tests/ModelTest.php +++ b/tests/ModelTest.php @@ -1,4 +1,5 @@ insert([ - ['name' => 'John Doe', 'birthday' => new UTCDateTime(Date::parse("1980-01-01 00:00:00")->format('Uv'))], - ['name' => 'Jane Doe', 'birthday' => new UTCDateTime(Date::parse("1981-01-01 00:00:00")->format('Uv'))], - ['name' => 'Robert Roe', 'birthday' => new UTCDateTime(Date::parse("1982-01-01 00:00:00")->format('Uv'))], - ['name' => 'Mark Moe', 'birthday' => new UTCDateTime(Date::parse("1983-01-01 00:00:00")->format('Uv'))], + ['name' => 'John Doe', 'birthday' => new UTCDateTime(Date::parse('1980-01-01 00:00:00')->format('Uv'))], + ['name' => 'Jane Doe', 'birthday' => new UTCDateTime(Date::parse('1981-01-01 00:00:00')->format('Uv'))], + ['name' => 'Robert Roe', 'birthday' => new UTCDateTime(Date::parse('1982-01-01 00:00:00')->format('Uv'))], + ['name' => 'Mark Moe', 'birthday' => new UTCDateTime(Date::parse('1983-01-01 00:00:00')->format('Uv'))], ]); $user = DB::collection('users') - ->where('birthday', new UTCDateTime(Date::parse("1980-01-01 00:00:00")->format('Uv'))) + ->where('birthday', new UTCDateTime(Date::parse('1980-01-01 00:00:00')->format('Uv'))) ->first(); $this->assertEquals('John Doe', $user['name']); - $user = DB::collection('users')->where('birthday', '=', new DateTime("1980-01-01 00:00:00"))->first(); + $user = DB::collection('users')->where('birthday', '=', new DateTime('1980-01-01 00:00:00'))->first(); $this->assertEquals('John Doe', $user['name']); - $start = new UTCDateTime(1000 * strtotime("1981-01-01 00:00:00")); - $stop = new UTCDateTime(1000 * strtotime("1982-01-01 00:00:00")); + $start = new UTCDateTime(1000 * strtotime('1981-01-01 00:00:00')); + $stop = new UTCDateTime(1000 * strtotime('1982-01-01 00:00:00')); $users = DB::collection('users')->whereBetween('birthday', [$start, $stop])->get(); $this->assertCount(2, $users); @@ -623,11 +624,11 @@ public function testOperators() $results = DB::collection('items')->where('tags', 'size', 4)->get(); $this->assertCount(1, $results); - $regex = new Regex(".*doe", "i"); + $regex = new Regex('.*doe', 'i'); $results = DB::collection('users')->where('name', 'regex', $regex)->get(); $this->assertCount(2, $results); - $regex = new Regex(".*doe", "i"); + $regex = new Regex('.*doe', 'i'); $results = DB::collection('users')->where('name', 'regexp', $regex)->get(); $this->assertCount(2, $results); diff --git a/tests/QueryTest.php b/tests/QueryTest.php index ab36d1886..12bebb474 100644 --- a/tests/QueryTest.php +++ b/tests/QueryTest.php @@ -1,4 +1,5 @@ [ 'driver' => 'mongodb', - 'dsn' => "mongodb://$mongoHost:$mongoPort/" . env('MONGO_DATABASE', 'unittest'), + 'dsn' => "mongodb://$mongoHost:$mongoPort/".env('MONGO_DATABASE', 'unittest'), ], 'mysql' => [ diff --git a/tests/models/Address.php b/tests/models/Address.php index d59f946ea..5e197c090 100644 --- a/tests/models/Address.php +++ b/tests/models/Address.php @@ -1,4 +1,5 @@ hasTable('books')) { + if (! $schema->hasTable('books')) { Schema::connection('mysql')->create('books', function (Blueprint $table) { $table->string('title'); $table->string('author_id')->nullable(); diff --git a/tests/models/MysqlRole.php b/tests/models/MysqlRole.php index c721ad8c0..a8a490d76 100644 --- a/tests/models/MysqlRole.php +++ b/tests/models/MysqlRole.php @@ -1,4 +1,5 @@ hasTable('roles')) { + if (! $schema->hasTable('roles')) { Schema::connection('mysql')->create('roles', function (Blueprint $table) { $table->string('type'); $table->string('user_id'); diff --git a/tests/models/MysqlUser.php b/tests/models/MysqlUser.php index 67b1052ee..8c1393fd5 100644 --- a/tests/models/MysqlUser.php +++ b/tests/models/MysqlUser.php @@ -1,4 +1,5 @@ hasTable('users')) { + if (! $schema->hasTable('users')) { Schema::connection('mysql')->create('users', function (Blueprint $table) { $table->increments('id'); $table->string('name'); diff --git a/tests/models/Photo.php b/tests/models/Photo.php index beff63825..8cb800922 100644 --- a/tests/models/Photo.php +++ b/tests/models/Photo.php @@ -1,4 +1,5 @@