From cc00aff8df5cbf52741a93661c5e64777812b7d2 Mon Sep 17 00:00:00 2001 From: Jens Segers Date: Sun, 8 Sep 2019 10:18:34 +0200 Subject: [PATCH] :rotating_light: Linting --- .../Mongodb/Auth/DatabaseTokenRepository.php | 6 +- .../Auth/PasswordResetServiceProvider.php | 1 - src/Jenssegers/Mongodb/Collection.php | 7 +- src/Jenssegers/Mongodb/Connection.php | 44 ++-- src/Jenssegers/Mongodb/Eloquent/Builder.php | 6 +- .../Mongodb/Eloquent/EmbedsRelations.php | 18 +- .../Mongodb/Eloquent/HybridRelations.php | 70 +++--- src/Jenssegers/Mongodb/Eloquent/Model.php | 41 ++-- .../Mongodb/Helpers/QueriesRelationships.php | 63 ++--- src/Jenssegers/Mongodb/Query/Builder.php | 60 ++--- .../Queue/Failed/MongoFailedJobProvider.php | 15 +- .../Mongodb/Queue/MongoConnector.php | 7 +- src/Jenssegers/Mongodb/Queue/MongoJob.php | 1 - src/Jenssegers/Mongodb/Queue/MongoQueue.php | 16 +- .../Mongodb/Relations/BelongsTo.php | 7 +- .../Mongodb/Relations/BelongsToMany.php | 20 +- .../Mongodb/Relations/EmbedsMany.php | 41 ++-- .../Mongodb/Relations/EmbedsOne.php | 19 +- .../Mongodb/Relations/EmbedsOneOrMany.php | 62 ++--- src/Jenssegers/Mongodb/Relations/HasMany.php | 22 +- src/Jenssegers/Mongodb/Relations/HasOne.php | 24 +- src/Jenssegers/Mongodb/Relations/MorphTo.php | 8 +- src/Jenssegers/Mongodb/Schema/Blueprint.php | 32 +-- src/Jenssegers/Mongodb/Schema/Builder.php | 9 +- .../Validation/DatabasePresenceVerifier.php | 22 +- tests/AuthTest.php | 17 +- tests/CollectionTest.php | 4 +- tests/EmbeddedRelationsTest.php | 218 +++++++++++++----- tests/GeospatialTest.php | 44 ++-- tests/HybridRelationsTest.php | 22 +- tests/ModelTest.php | 2 +- tests/QueryBuilderTest.php | 90 +++++--- tests/QueryTest.php | 50 ++-- tests/RelationsTest.php | 36 +-- tests/SchemaTest.php | 8 +- tests/TestCase.php | 16 +- tests/config/database.php | 28 +-- tests/config/queue.php | 6 +- tests/models/Book.php | 1 - tests/models/Item.php | 1 - tests/models/Scoped.php | 2 +- tests/models/Soft.php | 1 - tests/models/User.php | 7 +- 43 files changed, 570 insertions(+), 604 deletions(-) diff --git a/src/Jenssegers/Mongodb/Auth/DatabaseTokenRepository.php b/src/Jenssegers/Mongodb/Auth/DatabaseTokenRepository.php index 515fb60af..a825bbc44 100644 --- a/src/Jenssegers/Mongodb/Auth/DatabaseTokenRepository.php +++ b/src/Jenssegers/Mongodb/Auth/DatabaseTokenRepository.php @@ -14,7 +14,11 @@ class DatabaseTokenRepository extends BaseDatabaseTokenRepository */ protected function getPayload($email, $token) { - return ['email' => $email, 'token' => $this->hasher->make($token), 'created_at' => new UTCDateTime(time() * 1000)]; + return [ + 'email' => $email, + 'token' => $this->hasher->make($token), + 'created_at' => new UTCDateTime(time() * 1000), + ]; } /** diff --git a/src/Jenssegers/Mongodb/Auth/PasswordResetServiceProvider.php b/src/Jenssegers/Mongodb/Auth/PasswordResetServiceProvider.php index ba4e32e62..6e678d2ec 100644 --- a/src/Jenssegers/Mongodb/Auth/PasswordResetServiceProvider.php +++ b/src/Jenssegers/Mongodb/Auth/PasswordResetServiceProvider.php @@ -8,7 +8,6 @@ class PasswordResetServiceProvider extends BasePasswordResetServiceProvider { /** * Register the token repository implementation. - * * @return void */ protected function registerTokenRepository() diff --git a/src/Jenssegers/Mongodb/Collection.php b/src/Jenssegers/Mongodb/Collection.php index 7f5c42b9b..4192edd43 100644 --- a/src/Jenssegers/Mongodb/Collection.php +++ b/src/Jenssegers/Mongodb/Collection.php @@ -10,14 +10,12 @@ class Collection { /** * The connection instance. - * * @var Connection */ protected $connection; /** * The MongoCollection instance.. - * * @var MongoCollection */ protected $collection; @@ -34,9 +32,8 @@ public function __construct(Connection $connection, MongoCollection $collection) /** * Handle dynamic method calls. - * - * @param string $method - * @param array $parameters + * @param string $method + * @param array $parameters * @return mixed */ public function __call($method, $parameters) diff --git a/src/Jenssegers/Mongodb/Connection.php b/src/Jenssegers/Mongodb/Connection.php index 1d46c5f00..7920ec9f6 100644 --- a/src/Jenssegers/Mongodb/Connection.php +++ b/src/Jenssegers/Mongodb/Connection.php @@ -10,22 +10,19 @@ class Connection extends BaseConnection { /** * The MongoDB database handler. - * * @var \MongoDB\Database */ protected $db; /** * The MongoDB connection handler. - * * @var \MongoDB\Client */ protected $connection; /** * Create a new database connection instance. - * - * @param array $config + * @param array $config */ public function __construct(array $config) { @@ -52,8 +49,7 @@ public function __construct(array $config) /** * Begin a fluent query against a database collection. - * - * @param string $collection + * @param string $collection * @return Query\Builder */ public function collection($collection) @@ -65,9 +61,8 @@ public function collection($collection) /** * Begin a fluent query against a database collection. - * - * @param string $table - * @param string|null $as + * @param string $table + * @param string|null $as * @return Query\Builder */ public function table($table, $as = null) @@ -77,8 +72,7 @@ public function table($table, $as = null) /** * Get a MongoDB collection. - * - * @param string $name + * @param string $name * @return Collection */ public function getCollection($name) @@ -96,7 +90,6 @@ public function getSchemaBuilder() /** * Get the MongoDB database object. - * * @return \MongoDB\Database */ public function getMongoDB() @@ -106,7 +99,6 @@ public function getMongoDB() /** * return MongoDB object. - * * @return \MongoDB\Client */ public function getMongoClient() @@ -124,10 +116,9 @@ public function getDatabaseName() /** * Create a new MongoDB connection. - * - * @param string $dsn - * @param array $config - * @param array $options + * @param string $dsn + * @param array $config + * @param array $options * @return \MongoDB\Client */ protected function createConnection($dsn, array $config, array $options) @@ -160,19 +151,17 @@ public function disconnect() /** * Determine if the given configuration array has a dsn string. - * - * @param array $config + * @param array $config * @return bool */ protected function hasDsnString(array $config) { - return isset($config['dsn']) && ! empty($config['dsn']); + return isset($config['dsn']) && !empty($config['dsn']); } /** * Get the DSN string form configuration. - * - * @param array $config + * @param array $config * @return string */ protected function getDsnString(array $config) @@ -182,8 +171,7 @@ protected function getDsnString(array $config) /** * Get the DSN string for a host / port configuration. - * - * @param array $config + * @param array $config * @return string */ protected function getHostDsn(array $config) @@ -206,8 +194,7 @@ protected function getHostDsn(array $config) /** * Create a DSN string from a configuration. - * - * @param array $config + * @param array $config * @return string */ protected function getDsn(array $config) @@ -259,9 +246,8 @@ protected function getDefaultSchemaGrammar() /** * Dynamically pass methods to the connection. - * - * @param string $method - * @param array $parameters + * @param string $method + * @param array $parameters * @return mixed */ public function __call($method, $parameters) diff --git a/src/Jenssegers/Mongodb/Eloquent/Builder.php b/src/Jenssegers/Mongodb/Eloquent/Builder.php index 358be6b50..90b58484f 100644 --- a/src/Jenssegers/Mongodb/Eloquent/Builder.php +++ b/src/Jenssegers/Mongodb/Eloquent/Builder.php @@ -13,7 +13,6 @@ class Builder extends EloquentBuilder /** * The methods that should be returned from query builder. - * * @var array */ protected $passthru = [ @@ -182,13 +181,12 @@ public function raw($expression = null) * TODO Remove if https://github.com/laravel/framework/commit/6484744326531829341e1ff886cc9b628b20d73e * wiil be reverted * Issue in laravel frawework https://github.com/laravel/framework/issues/27791 - * - * @param array $values + * @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/EmbedsRelations.php b/src/Jenssegers/Mongodb/Eloquent/EmbedsRelations.php index c073e58a1..caef0e693 100644 --- a/src/Jenssegers/Mongodb/Eloquent/EmbedsRelations.php +++ b/src/Jenssegers/Mongodb/Eloquent/EmbedsRelations.php @@ -10,11 +10,10 @@ trait EmbedsRelations { /** * Define an embedded one-to-many relationship. - * - * @param string $related - * @param string $localKey - * @param string $foreignKey - * @param string $relation + * @param string $related + * @param string $localKey + * @param string $foreignKey + * @param string $relation * @return \Jenssegers\Mongodb\Relations\EmbedsMany */ protected function embedsMany($related, $localKey = null, $foreignKey = null, $relation = null) @@ -45,11 +44,10 @@ protected function embedsMany($related, $localKey = null, $foreignKey = null, $r /** * Define an embedded one-to-many relationship. - * - * @param string $related - * @param string $localKey - * @param string $foreignKey - * @param string $relation + * @param string $related + * @param string $localKey + * @param string $foreignKey + * @param string $relation * @return \Jenssegers\Mongodb\Relations\EmbedsOne */ protected function embedsOne($related, $localKey = null, $foreignKey = null, $relation = null) diff --git a/src/Jenssegers/Mongodb/Eloquent/HybridRelations.php b/src/Jenssegers/Mongodb/Eloquent/HybridRelations.php index b4af4dfc8..bfe9a2b2c 100644 --- a/src/Jenssegers/Mongodb/Eloquent/HybridRelations.php +++ b/src/Jenssegers/Mongodb/Eloquent/HybridRelations.php @@ -16,10 +16,9 @@ trait HybridRelations { /** * Define a one-to-one relationship. - * - * @param string $related - * @param string $foreignKey - * @param string $localKey + * @param string $related + * @param string $foreignKey + * @param string $localKey * @return \Illuminate\Database\Eloquent\Relations\HasOne */ public function hasOne($related, $foreignKey = null, $localKey = null) @@ -40,12 +39,11 @@ public function hasOne($related, $foreignKey = null, $localKey = null) /** * Define a polymorphic one-to-one relationship. - * - * @param string $related - * @param string $name - * @param string $type - * @param string $id - * @param string $localKey + * @param string $related + * @param string $name + * @param string $type + * @param string $id + * @param string $localKey * @return \Illuminate\Database\Eloquent\Relations\MorphOne */ public function morphOne($related, $name, $type = null, $id = null, $localKey = null) @@ -66,10 +64,9 @@ public function morphOne($related, $name, $type = null, $id = null, $localKey = /** * Define a one-to-many relationship. - * - * @param string $related - * @param string $foreignKey - * @param string $localKey + * @param string $related + * @param string $foreignKey + * @param string $localKey * @return \Illuminate\Database\Eloquent\Relations\HasMany */ public function hasMany($related, $foreignKey = null, $localKey = null) @@ -90,12 +87,11 @@ public function hasMany($related, $foreignKey = null, $localKey = null) /** * Define a polymorphic one-to-many relationship. - * - * @param string $related - * @param string $name - * @param string $type - * @param string $id - * @param string $localKey + * @param string $related + * @param string $name + * @param string $type + * @param string $id + * @param string $localKey * @return \Illuminate\Database\Eloquent\Relations\MorphMany */ public function morphMany($related, $name, $type = null, $id = null, $localKey = null) @@ -121,11 +117,10 @@ public function morphMany($related, $name, $type = null, $id = null, $localKey = /** * Define an inverse one-to-one or many relationship. - * - * @param string $related - * @param string $foreignKey - * @param string $otherKey - * @param string $relation + * @param string $related + * @param string $foreignKey + * @param string $otherKey + * @param string $relation * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function belongsTo($related, $foreignKey = null, $otherKey = null, $relation = null) @@ -165,11 +160,10 @@ public function belongsTo($related, $foreignKey = null, $otherKey = null, $relat /** * Define a polymorphic, inverse one-to-one or many relationship. - * - * @param string $name - * @param string $type - * @param string $id - * @param string $ownerKey + * @param string $name + * @param string $type + * @param string $id + * @param string $ownerKey * @return \Illuminate\Database\Eloquent\Relations\MorphTo */ public function morphTo($name = null, $type = null, $id = null, $ownerKey = null) @@ -208,14 +202,13 @@ public function morphTo($name = null, $type = null, $id = null, $ownerKey = null /** * Define a many-to-many relationship. - * - * @param string $related - * @param string $collection - * @param string $foreignKey - * @param string $otherKey - * @param string $parentKey - * @param string $relatedKey - * @param string $relation + * @param string $related + * @param string $collection + * @param string $foreignKey + * @param string $otherKey + * @param string $parentKey + * @param string $relatedKey + * @param string $relation * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ public function belongsToMany( @@ -282,7 +275,6 @@ public function belongsToMany( /** * Get the relationship name of the belongs to many. - * * @return string */ protected function guessBelongsToManyRelation() diff --git a/src/Jenssegers/Mongodb/Eloquent/Model.php b/src/Jenssegers/Mongodb/Eloquent/Model.php index de77b07bc..78e9b1efa 100644 --- a/src/Jenssegers/Mongodb/Eloquent/Model.php +++ b/src/Jenssegers/Mongodb/Eloquent/Model.php @@ -4,6 +4,8 @@ use Carbon\Carbon; use DateTime; +use Illuminate\Contracts\Queue\QueueableCollection; +use Illuminate\Contracts\Queue\QueueableEntity; use Illuminate\Database\Eloquent\Model as BaseModel; use Illuminate\Database\Eloquent\Relations\Relation; use Illuminate\Support\Arr; @@ -12,8 +14,6 @@ use MongoDB\BSON\Binary; use MongoDB\BSON\ObjectID; use MongoDB\BSON\UTCDateTime; -use Illuminate\Contracts\Queue\QueueableEntity; -use Illuminate\Contracts\Queue\QueueableCollection; abstract class Model extends BaseModel { @@ -21,36 +21,31 @@ abstract class Model extends BaseModel /** * The collection associated with the model. - * * @var string */ protected $collection; /** * The primary key for the model. - * * @var string */ protected $primaryKey = '_id'; /** * The primary key type. - * * @var string */ protected $keyType = 'string'; /** * The parent relation instance. - * * @var Relation */ protected $parentRelation; /** * Custom accessor for the model's id. - * - * @param mixed $value + * @param mixed $value * @return mixed */ public function getIdAttribute($value = null) @@ -267,8 +262,7 @@ public function originalIsEquivalent($key, $current) /** * Remove one or more fields. - * - * @param mixed $columns + * @param mixed $columns * @return int */ public function drop($columns) @@ -313,9 +307,8 @@ public function push() /** * Remove one or more values from an array. - * - * @param string $column - * @param mixed $values + * @param string $column + * @param mixed $values * @return mixed */ public function pull($column, $values) @@ -332,10 +325,9 @@ public function pull($column, $values) /** * Append one or more values to the underlying attribute value and sync with original. - * - * @param string $column - * @param array $values - * @param bool $unique + * @param string $column + * @param array $values + * @param bool $unique */ protected function pushAttributeValues($column, array $values, $unique = false) { @@ -357,9 +349,8 @@ protected function pushAttributeValues($column, array $values, $unique = false) /** * Remove one or more values to the underlying attribute value and sync with original. - * - * @param string $column - * @param array $values + * @param string $column + * @param array $values */ protected function pullAttributeValues($column, array $values) { @@ -390,8 +381,7 @@ public function getForeignKey() /** * Set the parent relation. - * - * @param \Illuminate\Database\Eloquent\Relations\Relation $relation + * @param \Illuminate\Database\Eloquent\Relations\Relation $relation */ public function setParentRelation(Relation $relation) { @@ -400,7 +390,6 @@ public function setParentRelation(Relation $relation) /** * Get the parent relation. - * * @return \Illuminate\Database\Eloquent\Relations\Relation */ public function getParentRelation() @@ -436,7 +425,6 @@ protected function removeTableFromKey($key) /** * Get the queueable relationships for the entity. - * * @return array */ public function getQueueableRelations() @@ -450,13 +438,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; } } } @@ -466,7 +454,6 @@ public function getQueueableRelations() /** * Get loaded relations for the instance without parent. - * * @return array */ protected function getRelationsWithoutParent() diff --git a/src/Jenssegers/Mongodb/Helpers/QueriesRelationships.php b/src/Jenssegers/Mongodb/Helpers/QueriesRelationships.php index 766567627..99798ea4f 100644 --- a/src/Jenssegers/Mongodb/Helpers/QueriesRelationships.php +++ b/src/Jenssegers/Mongodb/Helpers/QueriesRelationships.php @@ -3,6 +3,8 @@ namespace Jenssegers\Mongodb\Helpers; use Closure; +use Exception; +use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Illuminate\Database\Eloquent\Relations\HasOneOrMany; @@ -12,13 +14,12 @@ trait QueriesRelationships { /** * Add a relationship count / exists condition to the query. - * - * @param string $relation - * @param string $operator - * @param int $count - * @param string $boolean - * @param \Closure|null $callback - * @return \Illuminate\Database\Eloquent\Builder|static + * @param string $relation + * @param string $operator + * @param int $count + * @param string $boolean + * @param Closure|null $callback + * @return Builder|static */ public function has($relation, $operator = '>=', $count = 1, $boolean = 'and', Closure $callback = null) { @@ -74,7 +75,7 @@ protected function isAcrossConnections($relation) * @param string $boolean * @param Closure|null $callback * @return mixed - * @throws \Exception + * @throws Exception */ public function addHybridHas($relation, $operator = '>=', $count = 1, $boolean = 'and', Closure $callback = null) { @@ -97,29 +98,6 @@ public function addHybridHas($relation, $operator = '>=', $count = 1, $boolean = return $this->whereIn($this->getRelatedConstraintKey($relation), $relatedIds, $boolean, $not); } - /** - * Returns key we are constraining this parent model's query with - * @param $relation - * @return string - * @throws \Exception - */ - protected function getRelatedConstraintKey($relation) - { - if ($relation instanceof HasOneOrMany) { - return $this->model->getKeyName(); - } - - if ($relation instanceof BelongsTo) { - return $relation->getForeignKeyName(); - } - - if ($relation instanceof BelongsToMany && ! $this->isAcrossConnections($relation)) { - return $this->model->getKeyName(); - } - - throw new \Exception(class_basename($relation) . ' is not supported for hybrid query constraints.'); - } - /** * @param $relation * @return string @@ -166,4 +144,27 @@ protected function getConstrainedRelatedIds($relations, $operator, $count) // All related ids. return array_keys($relationCount); } + + /** + * Returns key we are constraining this parent model's query with + * @param $relation + * @return string + * @throws Exception + */ + protected function getRelatedConstraintKey($relation) + { + if ($relation instanceof HasOneOrMany) { + return $this->model->getKeyName(); + } + + if ($relation instanceof BelongsTo) { + return $relation->getForeignKeyName(); + } + + if ($relation instanceof BelongsToMany && !$this->isAcrossConnections($relation)) { + return $this->model->getKeyName(); + } + + throw new Exception(class_basename($relation) . ' is not supported for hybrid query constraints.'); + } } diff --git a/src/Jenssegers/Mongodb/Query/Builder.php b/src/Jenssegers/Mongodb/Query/Builder.php index 4ef855fb2..c706b24a4 100644 --- a/src/Jenssegers/Mongodb/Query/Builder.php +++ b/src/Jenssegers/Mongodb/Query/Builder.php @@ -20,49 +20,42 @@ class Builder extends BaseBuilder { /** * The database collection. - * * @var MongoCollection */ protected $collection; /** * The column projections. - * * @var array */ public $projections; /** * The cursor timeout value. - * * @var int */ public $timeout; /** * The cursor hint value. - * * @var int */ public $hint; /** * Custom options to add to the query. - * * @var array */ public $options = []; /** * Indicate if we are executing a pagination query. - * * @var bool */ public $paginating = false; /** * All of the available clause operators. - * * @var array */ public $operators = [ @@ -110,7 +103,6 @@ class Builder extends BaseBuilder /** * Operator conversion. - * * @var array */ protected $conversion = [ @@ -125,7 +117,6 @@ class Builder extends BaseBuilder /** * Check if we need to return Collections instead of plain arrays (laravel >= 5.3 ) - * * @var boolean */ protected $useCollections; @@ -143,7 +134,6 @@ public function __construct(Connection $connection, Processor $processor) /** * Returns true if Laravel or Lumen >= 5.3 - * * @return bool */ protected function shouldUseCollections() @@ -159,8 +149,7 @@ protected function shouldUseCollections() /** * Set the projections. - * - * @param array $columns + * @param array $columns * @return $this */ public function project($columns) @@ -172,8 +161,7 @@ public function project($columns) /** * Set the cursor timeout in seconds. - * - * @param int $seconds + * @param int $seconds * @return $this */ public function timeout($seconds) @@ -185,8 +173,7 @@ public function timeout($seconds) /** * Set the cursor hint. - * - * @param mixed $index + * @param mixed $index * @return $this */ public function hint($index) @@ -224,8 +211,7 @@ public function get($columns = []) /** * Execute the query as a fresh "select" statement. - * - * @param array $columns + * @param array $columns * @return array|static[]|Collection */ public function getFresh($columns = []) @@ -412,7 +398,6 @@ public function getFresh($columns = []) /** * Generate the unique cache key for the current query. - * * @return string */ public function generateCacheKey() @@ -506,11 +491,10 @@ public function orderBy($column, $direction = 'asc') /** * Add a "where all" clause to the query. - * - * @param string $column - * @param array $values - * @param string $boolean - * @param bool $not + * @param string $column + * @param array $values + * @param string $boolean + * @param bool $not * @return $this */ public function whereAll($column, array $values, $boolean = 'and', $not = false) @@ -711,11 +695,10 @@ public function truncate() /** * Get an array with the values of a given column. - * - * @deprecated - * @param string $column - * @param string $key + * @param string $column + * @param string $key * @return array + * @deprecated */ public function lists($column, $key = null) { @@ -743,7 +726,6 @@ public function raw($expression = null) /** * Append one or more values to an array. - * * @param mixed $column * @param mixed $value * @param bool $unique @@ -770,9 +752,8 @@ public function push($column, $value = null, $unique = false) /** * Remove one or more values from an array. - * - * @param mixed $column - * @param mixed $value + * @param mixed $column + * @param mixed $value * @return int */ public function pull($column, $value = null) @@ -794,8 +775,7 @@ public function pull($column, $value = null) /** * Remove one or more fields. - * - * @param mixed $columns + * @param mixed $columns * @return int */ public function drop($columns) @@ -825,9 +805,8 @@ public function newQuery() /** * Perform an update query. - * - * @param array $query - * @param array $options + * @param array $query + * @param array $options * @return int */ protected function performUpdate($query, array $options = []) @@ -848,8 +827,7 @@ protected function performUpdate($query, array $options = []) /** * Convert a key to ObjectID if needed. - * - * @param mixed $id + * @param mixed $id * @return mixed */ public function convertKey($id) @@ -886,7 +864,6 @@ public function where($column, $operator = null, $value = null, $boolean = 'and' /** * Compile the where array. - * * @return array */ protected function compileWheres() @@ -1146,8 +1123,7 @@ protected function compileWhereRaw(array $where) /** * Set custom options for the query. - * - * @param array $options + * @param array $options * @return $this */ public function options(array $options) diff --git a/src/Jenssegers/Mongodb/Queue/Failed/MongoFailedJobProvider.php b/src/Jenssegers/Mongodb/Queue/Failed/MongoFailedJobProvider.php index 5548dd86f..a02639f88 100644 --- a/src/Jenssegers/Mongodb/Queue/Failed/MongoFailedJobProvider.php +++ b/src/Jenssegers/Mongodb/Queue/Failed/MongoFailedJobProvider.php @@ -9,11 +9,9 @@ class MongoFailedJobProvider extends DatabaseFailedJobProvider { /** * Log a failed job into storage. - * - * @param string $connection - * @param string $queue - * @param string $payload - * + * @param string $connection + * @param string $queue + * @param string $payload * @return void */ public function log($connection, $queue, $payload, $exception) @@ -25,7 +23,6 @@ public function log($connection, $queue, $payload, $exception) /** * Get a list of all of the failed jobs. - * * @return object[] */ public function all() @@ -42,8 +39,7 @@ public function all() /** * Get a single failed job. - * - * @param mixed $id + * @param mixed $id * @return object */ public function find($id) @@ -57,8 +53,7 @@ public function find($id) /** * Delete a single failed job from storage. - * - * @param mixed $id + * @param mixed $id * @return bool */ public function forget($id) diff --git a/src/Jenssegers/Mongodb/Queue/MongoConnector.php b/src/Jenssegers/Mongodb/Queue/MongoConnector.php index 839ac027e..91cea8c35 100644 --- a/src/Jenssegers/Mongodb/Queue/MongoConnector.php +++ b/src/Jenssegers/Mongodb/Queue/MongoConnector.php @@ -10,15 +10,13 @@ class MongoConnector implements ConnectorInterface { /** * Database connections. - * * @var \Illuminate\Database\ConnectionResolverInterface */ protected $connections; /** * Create a new connector instance. - * - * @param \Illuminate\Database\ConnectionResolverInterface $connections + * @param \Illuminate\Database\ConnectionResolverInterface $connections */ public function __construct(ConnectionResolverInterface $connections) { @@ -27,8 +25,7 @@ public function __construct(ConnectionResolverInterface $connections) /** * Establish a queue connection. - * - * @param array $config + * @param array $config * @return \Illuminate\Contracts\Queue\Queue */ public function connect(array $config) diff --git a/src/Jenssegers/Mongodb/Queue/MongoJob.php b/src/Jenssegers/Mongodb/Queue/MongoJob.php index f1a61cf46..336515f09 100644 --- a/src/Jenssegers/Mongodb/Queue/MongoJob.php +++ b/src/Jenssegers/Mongodb/Queue/MongoJob.php @@ -8,7 +8,6 @@ class MongoJob extends DatabaseJob { /** * Indicates if the job has been reserved. - * * @return bool */ public function isReserved() diff --git a/src/Jenssegers/Mongodb/Queue/MongoQueue.php b/src/Jenssegers/Mongodb/Queue/MongoQueue.php index 5f08f7071..44249456a 100644 --- a/src/Jenssegers/Mongodb/Queue/MongoQueue.php +++ b/src/Jenssegers/Mongodb/Queue/MongoQueue.php @@ -11,14 +11,12 @@ class MongoQueue extends DatabaseQueue { /** * The expiration time of a job. - * * @var int|null */ protected $retryAfter = 60; /** * The connection name for the queue. - * * @var string */ protected $connectionName; @@ -52,17 +50,13 @@ public function pop($queue = null) /** * Get the next available job for the queue and mark it as reserved. - * * When using multiple daemon queue listeners to process jobs there * is a possibility that multiple processes can end up reading the * same record before one has flagged it as reserved. - * * This race condition can result in random jobs being run more then * once. To solve this we use findOneAndUpdate to lock the next jobs * record while flagging it as reserved at the same time. - * - * @param string|null $queue - * + * @param string|null $queue * @return \StdClass|null */ protected function getNextAvailableJobAndReserve($queue) @@ -94,8 +88,7 @@ protected function getNextAvailableJobAndReserve($queue) /** * Release the jobs that have been reserved for too long. - * - * @param string $queue + * @param string $queue * @return void */ protected function releaseJobsThatHaveBeenReservedTooLong($queue) @@ -124,9 +117,8 @@ protected function releaseJobsThatHaveBeenReservedTooLong($queue) /** * Release the given job ID from reservation. - * - * @param string $id - * @param int $attempts + * @param string $id + * @param int $attempts * @return void */ protected function releaseJob($id, $attempts) diff --git a/src/Jenssegers/Mongodb/Relations/BelongsTo.php b/src/Jenssegers/Mongodb/Relations/BelongsTo.php index 457e6bc1f..b47e856fa 100644 --- a/src/Jenssegers/Mongodb/Relations/BelongsTo.php +++ b/src/Jenssegers/Mongodb/Relations/BelongsTo.php @@ -9,7 +9,6 @@ class BelongsTo extends \Illuminate\Database\Eloquent\Relations\BelongsTo { /** * Get the key for comparing against the parent key in "has" query. - * * @return string */ public function getHasCompareKey() @@ -53,7 +52,6 @@ public function getRelationExistenceQuery(Builder $query, Builder $parentQuery, /** * Get the owner key with backwards compatible support. - * * @return string */ public function getOwnerKey() @@ -63,9 +61,8 @@ public function getOwnerKey() /** * Get the name of the "where in" method for eager loading. - * - * @param \Illuminate\Database\Eloquent\Model $model - * @param string $key + * @param \Illuminate\Database\Eloquent\Model $model + * @param string $key * @return string */ protected function whereInMethod(EloquentModel $model, $key) diff --git a/src/Jenssegers/Mongodb/Relations/BelongsToMany.php b/src/Jenssegers/Mongodb/Relations/BelongsToMany.php index 0e1b5280b..c57857638 100644 --- a/src/Jenssegers/Mongodb/Relations/BelongsToMany.php +++ b/src/Jenssegers/Mongodb/Relations/BelongsToMany.php @@ -5,15 +5,14 @@ use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Collection; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Model as EloquentModel; use Illuminate\Database\Eloquent\Relations\BelongsToMany as EloquentBelongsToMany; use Illuminate\Support\Arr; -use Illuminate\Database\Eloquent\Model as EloquentModel; class BelongsToMany extends EloquentBelongsToMany { /** * Get the key for comparing against the parent key in "has" query. - * * @return string */ public function getHasCompareKey() @@ -39,8 +38,7 @@ protected function hydratePivotRelation(array $models) /** * Set the select clause for the relation query. - * - * @param array $columns + * @param array $columns * @return array */ protected function getSelectColumns(array $columns = ['*']) @@ -68,7 +66,6 @@ public function addConstraints() /** * Set the where clause for the relation query. - * * @return $this */ protected function setWhere() @@ -275,7 +272,6 @@ protected function newPivotQuery() /** * Create a new query builder for the related model. - * * @return \Illuminate\Database\Query\Builder */ public function newRelatedQuery() @@ -285,7 +281,6 @@ public function newRelatedQuery() /** * Get the fully qualified foreign key for the relation. - * * @return string */ public function getForeignKey() @@ -312,10 +307,9 @@ 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 - * - * @deprecated - * @param array $records + * @param array $records * @return array + * @deprecated */ protected function formatSyncList(array $records) { @@ -331,7 +325,6 @@ protected function formatSyncList(array $records) /** * Get the related key with backwards compatible support. - * * @return string */ public function getRelatedKey() @@ -341,9 +334,8 @@ public function getRelatedKey() /** * Get the name of the "where in" method for eager loading. - * - * @param \Illuminate\Database\Eloquent\Model $model - * @param string $key + * @param \Illuminate\Database\Eloquent\Model $model + * @param string $key * @return string */ protected function whereInMethod(EloquentModel $model, $key) diff --git a/src/Jenssegers/Mongodb/Relations/EmbedsMany.php b/src/Jenssegers/Mongodb/Relations/EmbedsMany.php index e26658e69..9078b59c7 100644 --- a/src/Jenssegers/Mongodb/Relations/EmbedsMany.php +++ b/src/Jenssegers/Mongodb/Relations/EmbedsMany.php @@ -4,10 +4,10 @@ use Illuminate\Database\Eloquent\Collection; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Model as EloquentModel; use Illuminate\Pagination\LengthAwarePaginator; use Illuminate\Pagination\Paginator; use MongoDB\BSON\ObjectID; -use Illuminate\Database\Eloquent\Model as EloquentModel; class EmbedsMany extends EmbedsOneOrMany { @@ -33,8 +33,7 @@ public function getResults() /** * Save a new model and attach it to the parent model. - * - * @param Model $model + * @param Model $model * @return Model|bool */ public function performInsert(Model $model) @@ -63,8 +62,7 @@ public function performInsert(Model $model) /** * Save an existing model and attach it to the parent model. - * - * @param Model $model + * @param Model $model * @return Model|bool */ public function performUpdate(Model $model) @@ -95,8 +93,7 @@ public function performUpdate(Model $model) /** * Delete an existing model and detach it from the parent model. - * - * @param Model $model + * @param Model $model * @return int */ public function performDelete(Model $model) @@ -122,8 +119,7 @@ public function performDelete(Model $model) /** * Associate the model instance to the given parent, without saving it to the database. - * - * @param Model $model + * @param Model $model * @return Model */ public function associate(Model $model) @@ -137,8 +133,7 @@ public function associate(Model $model) /** * Dissociate the model instance from the given parent, without saving it to the database. - * - * @param mixed $ids + * @param mixed $ids * @return int */ public function dissociate($ids = []) @@ -166,8 +161,7 @@ public function dissociate($ids = []) /** * Destroy the embedded models for the given IDs. - * - * @param mixed $ids + * @param mixed $ids * @return int */ public function destroy($ids = []) @@ -191,7 +185,6 @@ public function destroy($ids = []) /** * Delete all embedded models. - * * @return int */ public function delete() @@ -208,8 +201,7 @@ public function delete() /** * Destroy alias. - * - * @param mixed $ids + * @param mixed $ids * @return int */ public function detach($ids = []) @@ -219,8 +211,7 @@ public function detach($ids = []) /** * Save alias. - * - * @param Model $model + * @param Model $model * @return Model */ public function attach(Model $model) @@ -230,8 +221,7 @@ public function attach(Model $model) /** * Associate a new model instance to the given parent, without saving it to the database. - * - * @param Model $model + * @param Model $model * @return Model */ protected function associateNew($model) @@ -251,8 +241,7 @@ protected function associateNew($model) /** * Associate an existing model instance to the given parent, without saving it to the database. - * - * @param Model $model + * @param Model $model * @return Model */ protected function associateExisting($model) @@ -277,8 +266,7 @@ protected function associateExisting($model) /** * Get a paginator for the "select" statement. - * - * @param int $perPage + * @param int $perPage * @return \Illuminate\Pagination\AbstractPaginator */ public function paginate($perPage = null) @@ -332,9 +320,8 @@ public function __call($method, $parameters) /** * Get the name of the "where in" method for eager loading. - * - * @param \Illuminate\Database\Eloquent\Model $model - * @param string $key + * @param \Illuminate\Database\Eloquent\Model $model + * @param string $key * @return string */ protected function whereInMethod(EloquentModel $model, $key) diff --git a/src/Jenssegers/Mongodb/Relations/EmbedsOne.php b/src/Jenssegers/Mongodb/Relations/EmbedsOne.php index 4640bdeb1..a0e713bc1 100644 --- a/src/Jenssegers/Mongodb/Relations/EmbedsOne.php +++ b/src/Jenssegers/Mongodb/Relations/EmbedsOne.php @@ -3,8 +3,8 @@ namespace Jenssegers\Mongodb\Relations; use Illuminate\Database\Eloquent\Model; -use MongoDB\BSON\ObjectID; use Illuminate\Database\Eloquent\Model as EloquentModel; +use MongoDB\BSON\ObjectID; class EmbedsOne extends EmbedsOneOrMany { @@ -30,8 +30,7 @@ public function getResults() /** * Save a new model and attach it to the parent model. - * - * @param Model $model + * @param Model $model * @return Model|bool */ public function performInsert(Model $model) @@ -59,8 +58,7 @@ public function performInsert(Model $model) /** * Save an existing model and attach it to the parent model. - * - * @param Model $model + * @param Model $model * @return Model|bool */ public function performUpdate(Model $model) @@ -85,7 +83,6 @@ public function performUpdate(Model $model) /** * Delete an existing model and detach it from the parent model. - * * @return int */ public function performDelete() @@ -109,8 +106,7 @@ public function performDelete() /** * Attach the model to its parent. - * - * @param Model $model + * @param Model $model * @return Model */ public function associate(Model $model) @@ -120,7 +116,6 @@ public function associate(Model $model) /** * Detach the model from its parent. - * * @return Model */ public function dissociate() @@ -130,7 +125,6 @@ public function dissociate() /** * Delete all embedded models. - * * @return int */ public function delete() @@ -140,9 +134,8 @@ public function delete() /** * Get the name of the "where in" method for eager loading. - * - * @param \Illuminate\Database\Eloquent\Model $model - * @param string $key + * @param \Illuminate\Database\Eloquent\Model $model + * @param string $key * @return string */ protected function whereInMethod(EloquentModel $model, $key) diff --git a/src/Jenssegers/Mongodb/Relations/EmbedsOneOrMany.php b/src/Jenssegers/Mongodb/Relations/EmbedsOneOrMany.php index f3bc58b8e..5a7f636e7 100644 --- a/src/Jenssegers/Mongodb/Relations/EmbedsOneOrMany.php +++ b/src/Jenssegers/Mongodb/Relations/EmbedsOneOrMany.php @@ -4,42 +4,38 @@ use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Collection; +use Illuminate\Database\Eloquent\Model as EloquentModel; use Illuminate\Database\Eloquent\Relations\Relation; use Jenssegers\Mongodb\Eloquent\Model; -use Illuminate\Database\Eloquent\Model as EloquentModel; abstract class EmbedsOneOrMany extends Relation { /** * The local key of the parent model. - * * @var string */ protected $localKey; /** * The foreign key of the parent model. - * * @var string */ protected $foreignKey; /** * The "name" of the relationship. - * * @var string */ protected $relation; /** * Create a new embeds many relationship instance. - * - * @param Builder $query - * @param Model $parent - * @param Model $related - * @param string $localKey - * @param string $foreignKey - * @param string $relation + * @param Builder $query + * @param Model $parent + * @param Model $related + * @param string $localKey + * @param string $foreignKey + * @param string $relation */ public function __construct(Builder $query, Model $parent, Model $related, $localKey, $foreignKey, $relation) { @@ -94,9 +90,7 @@ public function match(array $models, Collection $results, $relation) /** * Shorthand to get the results of the relationship. - * - * @param array $columns - * + * @param array $columns * @return Collection */ public function get($columns = ['*']) @@ -106,7 +100,6 @@ public function get($columns = ['*']) /** * Get the number of embedded models. - * * @return int */ public function count() @@ -116,8 +109,7 @@ public function count() /** * Attach a model instance to the parent model. - * - * @param Model $model + * @param Model $model * @return Model|bool */ public function save(Model $model) @@ -129,8 +121,7 @@ public function save(Model $model) /** * Attach a collection of models to the parent instance. - * - * @param Collection|array $models + * @param Collection|array $models * @return Collection|array */ public function saveMany($models) @@ -144,8 +135,7 @@ public function saveMany($models) /** * Create a new instance of the related model. - * - * @param array $attributes + * @param array $attributes * @return Model */ public function create(array $attributes = []) @@ -164,8 +154,7 @@ public function create(array $attributes = []) /** * Create an array of new instances of the related model. - * - * @param array $records + * @param array $records * @return array */ public function createMany(array $records) @@ -181,8 +170,7 @@ public function createMany(array $records) /** * Transform single ID, single Model or array of Models into an array of IDs. - * - * @param mixed $ids + * @param mixed $ids * @return array */ protected function getIdsArrayFrom($ids) @@ -236,8 +224,7 @@ protected function setEmbedded($records) /** * Get the foreign key value for the relation. - * - * @param mixed $id + * @param mixed $id * @return mixed */ protected function getForeignKeyValue($id) @@ -252,8 +239,7 @@ protected function getForeignKeyValue($id) /** * Convert an array of records to a Collection. - * - * @param array $records + * @param array $records * @return Collection */ protected function toCollection(array $records = []) @@ -273,8 +259,7 @@ protected function toCollection(array $records = []) /** * Create a related model instanced. - * - * @param array $attributes + * @param array $attributes * @return Model */ protected function toModel($attributes = []) @@ -302,7 +287,6 @@ protected function toModel($attributes = []) /** * Get the relation instance of the parent. - * * @return Relation */ protected function getParentRelation() @@ -332,7 +316,6 @@ public function getBaseQuery() /** * Check if this relation is nested in another relation. - * * @return bool */ protected function isNested() @@ -342,8 +325,7 @@ protected function isNested() /** * Get the fully qualified local key name. - * - * @param string $glue + * @param string $glue * @return string */ protected function getPathHierarchy($glue = '.') @@ -369,7 +351,6 @@ public function getQualifiedParentKeyName() /** * Get the primary key value of the parent. - * * @return string */ protected function getParentKey() @@ -379,7 +360,6 @@ protected function getParentKey() /** * Return update values - * * @param $array * @param string $prepend * @return array @@ -389,7 +369,7 @@ public static function getUpdateValues($array, $prepend = '') $results = []; foreach ($array as $key => $value) { - $results[$prepend.$key] = $value; + $results[$prepend . $key] = $value; } return $results; @@ -397,7 +377,6 @@ public static function getUpdateValues($array, $prepend = '') /** * Get the foreign key for the relationship. - * * @return string */ public function getQualifiedForeignKeyName() @@ -407,9 +386,8 @@ public function getQualifiedForeignKeyName() /** * Get the name of the "where in" method for eager loading. - * - * @param \Illuminate\Database\Eloquent\Model $model - * @param string $key + * @param \Illuminate\Database\Eloquent\Model $model + * @param string $key * @return string */ protected function whereInMethod(EloquentModel $model, $key) diff --git a/src/Jenssegers/Mongodb/Relations/HasMany.php b/src/Jenssegers/Mongodb/Relations/HasMany.php index 93a25425a..b10426635 100644 --- a/src/Jenssegers/Mongodb/Relations/HasMany.php +++ b/src/Jenssegers/Mongodb/Relations/HasMany.php @@ -3,14 +3,13 @@ namespace Jenssegers\Mongodb\Relations; use Illuminate\Database\Eloquent\Builder; -use Illuminate\Database\Eloquent\Relations\HasMany as EloquentHasMany; use Illuminate\Database\Eloquent\Model as EloquentModel; +use Illuminate\Database\Eloquent\Relations\HasMany as EloquentHasMany; class HasMany extends EloquentHasMany { /** * Get the plain foreign key. - * * @return string */ public function getForeignKeyName() @@ -20,7 +19,6 @@ public function getForeignKeyName() /** * Get the plain foreign key. - * * @return string */ public function getPlainForeignKey() @@ -30,7 +28,6 @@ public function getPlainForeignKey() /** * Get the key for comparing against the parent key in "has" query. - * * @return string */ public function getHasCompareKey() @@ -50,9 +47,8 @@ public function getRelationExistenceQuery(Builder $query, Builder $parentQuery, /** * Add the constraints for a relationship count query. - * - * @param Builder $query - * @param Builder $parent + * @param Builder $query + * @param Builder $parent * @return Builder */ public function getRelationCountQuery(Builder $query, Builder $parent) @@ -64,10 +60,9 @@ public function getRelationCountQuery(Builder $query, Builder $parent) /** * Add the constraints for a relationship query. - * - * @param Builder $query - * @param Builder $parent - * @param array|mixed $columns + * @param Builder $query + * @param Builder $parent + * @param array|mixed $columns * @return Builder */ public function getRelationQuery(Builder $query, Builder $parent, $columns = ['*']) @@ -81,9 +76,8 @@ public function getRelationQuery(Builder $query, Builder $parent, $columns = ['* /** * Get the name of the "where in" method for eager loading. - * - * @param \Illuminate\Database\Eloquent\Model $model - * @param string $key + * @param \Illuminate\Database\Eloquent\Model $model + * @param string $key * @return string */ protected function whereInMethod(EloquentModel $model, $key) diff --git a/src/Jenssegers/Mongodb/Relations/HasOne.php b/src/Jenssegers/Mongodb/Relations/HasOne.php index a8d65dba9..91741c297 100644 --- a/src/Jenssegers/Mongodb/Relations/HasOne.php +++ b/src/Jenssegers/Mongodb/Relations/HasOne.php @@ -3,14 +3,13 @@ namespace Jenssegers\Mongodb\Relations; use Illuminate\Database\Eloquent\Builder; -use Illuminate\Database\Eloquent\Relations\HasOne as EloquentHasOne; use Illuminate\Database\Eloquent\Model as EloquentModel; +use Illuminate\Database\Eloquent\Relations\HasOne as EloquentHasOne; class HasOne extends EloquentHasOne { /** * Get the key for comparing against the parent key in "has" query. - * * @return string */ public function getForeignKeyName() @@ -20,7 +19,6 @@ public function getForeignKeyName() /** * Get the key for comparing against the parent key in "has" query. - * * @return string */ public function getHasCompareKey() @@ -30,7 +28,6 @@ public function getHasCompareKey() /** * Get the plain foreign key. - * * @return string */ public function getPlainForeignKey() @@ -50,9 +47,8 @@ public function getRelationExistenceQuery(Builder $query, Builder $parentQuery, /** * Add the constraints for a relationship count query. - * - * @param Builder $query - * @param Builder $parent + * @param Builder $query + * @param Builder $parent * @return Builder */ public function getRelationCountQuery(Builder $query, Builder $parent) @@ -64,10 +60,9 @@ public function getRelationCountQuery(Builder $query, Builder $parent) /** * Add the constraints for a relationship query. - * - * @param Builder $query - * @param Builder $parent - * @param array|mixed $columns + * @param Builder $query + * @param Builder $parent + * @param array|mixed $columns * @return Builder */ public function getRelationQuery(Builder $query, Builder $parent, $columns = ['*']) @@ -78,12 +73,11 @@ public function getRelationQuery(Builder $query, Builder $parent, $columns = ['* return $query->where($this->getForeignKeyName(), 'exists', true); } - + /** * Get the name of the "where in" method for eager loading. - * - * @param \Illuminate\Database\Eloquent\Model $model - * @param string $key + * @param \Illuminate\Database\Eloquent\Model $model + * @param string $key * @return string */ protected function whereInMethod(EloquentModel $model, $key) diff --git a/src/Jenssegers/Mongodb/Relations/MorphTo.php b/src/Jenssegers/Mongodb/Relations/MorphTo.php index 32f3d3ab6..704c4722c 100644 --- a/src/Jenssegers/Mongodb/Relations/MorphTo.php +++ b/src/Jenssegers/Mongodb/Relations/MorphTo.php @@ -2,8 +2,8 @@ namespace Jenssegers\Mongodb\Relations; -use Illuminate\Database\Eloquent\Relations\MorphTo as EloquentMorphTo; use Illuminate\Database\Eloquent\Model as EloquentModel; +use Illuminate\Database\Eloquent\Relations\MorphTo as EloquentMorphTo; class MorphTo extends EloquentMorphTo { @@ -36,7 +36,6 @@ protected function getResultsByType($type) /** * Get the owner key with backwards compatible support. - * * @return string */ public function getOwnerKey() @@ -46,9 +45,8 @@ public function getOwnerKey() /** * Get the name of the "where in" method for eager loading. - * - * @param \Illuminate\Database\Eloquent\Model $model - * @param string $key + * @param \Illuminate\Database\Eloquent\Model $model + * @param string $key * @return string */ protected function whereInMethod(EloquentModel $model, $key) diff --git a/src/Jenssegers/Mongodb/Schema/Blueprint.php b/src/Jenssegers/Mongodb/Schema/Blueprint.php index 4b30c87fc..407e333de 100644 --- a/src/Jenssegers/Mongodb/Schema/Blueprint.php +++ b/src/Jenssegers/Mongodb/Schema/Blueprint.php @@ -8,21 +8,18 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint { /** * The MongoConnection object for this blueprint. - * * @var \Jenssegers\Mongodb\Connection */ protected $connection; /** * The MongoCollection object for this blueprint. - * * @var \Jenssegers\Mongodb\Collection|\MongoDB\Collection */ protected $collection; /** * Fluent columns. - * * @var array */ protected $columns = []; @@ -112,8 +109,7 @@ public function unique($columns = null, $name = null, $algorithm = null, $option /** * Specify a non blocking index for the collection. - * - * @param string|array $columns + * @param string|array $columns * @return Blueprint */ public function background($columns = null) @@ -127,9 +123,8 @@ public function background($columns = null) /** * Specify a sparse index for the collection. - * - * @param string|array $columns - * @param array $options + * @param string|array $columns + * @param array $options * @return Blueprint */ public function sparse($columns = null, $options = []) @@ -145,10 +140,9 @@ public function sparse($columns = null, $options = []) /** * Specify a geospatial index for the collection. - * - * @param string|array $columns - * @param string $index - * @param array $options + * @param string|array $columns + * @param string $index + * @param array $options * @return Blueprint */ public function geospatial($columns = null, $index = '2d', $options = []) @@ -171,9 +165,8 @@ public function geospatial($columns = null, $index = '2d', $options = []) /** * Specify the number of seconds after wich a document should be considered expired based, * on the given single-field index containing a date. - * - * @param string|array $columns - * @param int $seconds + * @param string|array $columns + * @param int $seconds * @return Blueprint */ public function expire($columns, $seconds) @@ -218,9 +211,8 @@ public function addColumn($type, $name, array $parameters = []) /** * Specify a sparse and unique index for the collection. - * - * @param string|array $columns - * @param array $options + * @param string|array $columns + * @param array $options * @return Blueprint */ public function sparse_and_unique($columns = null, $options = []) @@ -237,8 +229,7 @@ public function sparse_and_unique($columns = null, $options = []) /** * Allow fluent columns. - * - * @param string|array $columns + * @param string|array $columns * @return string|array */ protected function fluent($columns = null) @@ -254,7 +245,6 @@ protected function fluent($columns = null) /** * Allows the use of unsupported schema methods. - * * @param $method * @param $args * @return Blueprint diff --git a/src/Jenssegers/Mongodb/Schema/Builder.php b/src/Jenssegers/Mongodb/Schema/Builder.php index 0e352846d..1bca6c02e 100644 --- a/src/Jenssegers/Mongodb/Schema/Builder.php +++ b/src/Jenssegers/Mongodb/Schema/Builder.php @@ -33,8 +33,7 @@ public function hasColumns($table, array $columns) /** * Determine if the given collection exists. - * - * @param string $collection + * @param string $collection * @return bool */ public function hasCollection($collection) @@ -60,9 +59,8 @@ public function hasTable($collection) /** * Modify a collection on the schema. - * - * @param string $collection - * @param Closure $callback + * @param string $collection + * @param Closure $callback * @return bool */ public function collection($collection, Closure $callback) @@ -138,7 +136,6 @@ protected function createBlueprint($collection, Closure $callback = null) /** * Get all of the collections names for the database. - * * @return array */ protected function getAllCollections() diff --git a/src/Jenssegers/Mongodb/Validation/DatabasePresenceVerifier.php b/src/Jenssegers/Mongodb/Validation/DatabasePresenceVerifier.php index fa3d68854..a7d57a89b 100644 --- a/src/Jenssegers/Mongodb/Validation/DatabasePresenceVerifier.php +++ b/src/Jenssegers/Mongodb/Validation/DatabasePresenceVerifier.php @@ -6,13 +6,12 @@ class DatabasePresenceVerifier extends \Illuminate\Validation\DatabasePresenceVe { /** * Count the number of objects in a collection having the given value. - * - * @param string $collection - * @param string $column - * @param string $value - * @param int $excludeId - * @param string $idColumn - * @param array $extra + * @param string $collection + * @param string $column + * @param string $value + * @param int $excludeId + * @param string $idColumn + * @param array $extra * @return int */ public function getCount($collection, $column, $value, $excludeId = null, $idColumn = null, array $extra = []) @@ -32,11 +31,10 @@ public function getCount($collection, $column, $value, $excludeId = null, $idCol /** * Count the number of objects in a collection with the given values. - * - * @param string $collection - * @param string $column - * @param array $values - * @param array $extra + * @param string $collection + * @param string $column + * @param array $values + * @param array $extra * @return int */ public function getMultiCount($collection, $column, array $values, array $extra = []) diff --git a/tests/AuthTest.php b/tests/AuthTest.php index e81efed90..2628fa626 100644 --- a/tests/AuthTest.php +++ b/tests/AuthTest.php @@ -2,6 +2,7 @@ use Illuminate\Auth\Passwords\PasswordBroker; use Illuminate\Foundation\Application; +use MongoDB\BSON\UTCDateTime; class AuthTest extends TestCase { @@ -15,8 +16,8 @@ public function tearDown(): void public function testAuthAttempt() { $user = User::create([ - 'name' => 'John Doe', - 'email' => 'john@doe.com', + 'name' => 'John Doe', + 'email' => 'john@doe.com', 'password' => Hash::make('foobar'), ]); @@ -37,8 +38,8 @@ public function testRemindOld() $broker = new PasswordBroker($tokens, $users, $mailer, ''); $user = User::create([ - 'name' => 'John Doe', - 'email' => 'john@doe.com', + 'name' => 'John Doe', + 'email' => 'john@doe.com', 'password' => Hash::make('foobar'), ]); @@ -49,13 +50,13 @@ public function testRemindOld() $reminder = DB::collection('password_resets')->first(); $this->assertEquals('john@doe.com', $reminder['email']); $this->assertNotNull($reminder['token']); - $this->assertInstanceOf('MongoDB\BSON\UTCDateTime', $reminder['created_at']); + $this->assertInstanceOf(UTCDateTime::class, $reminder['created_at']); $credentials = [ - 'email' => 'john@doe.com', - 'password' => 'foobar', + 'email' => 'john@doe.com', + 'password' => 'foobar', 'password_confirmation' => 'foobar', - 'token' => $reminder['token'], + 'token' => $reminder['token'], ]; $response = $broker->reset($credentials, function ($user, $password) { diff --git a/tests/CollectionTest.php b/tests/CollectionTest.php index d38687a54..ab0b29b21 100644 --- a/tests/CollectionTest.php +++ b/tests/CollectionTest.php @@ -1,10 +1,10 @@ 'John Doe']); $address = new Address(['city' => 'London']); - $address->setEventDispatcher($events = Mockery::mock(\Illuminate\Events\Dispatcher::class)); + $address->setEventDispatcher($events = Mockery::mock(Dispatcher::class)); $events->shouldReceive('dispatch')->with('eloquent.retrieved: ' . get_class($address), Mockery::any()); - $events->shouldReceive('until')->once()->with('eloquent.saving: ' . get_class($address), $address)->andReturn(true); - $events->shouldReceive('until')->once()->with('eloquent.creating: ' . get_class($address), $address)->andReturn(true); + $events->shouldReceive('until') + ->once() + ->with('eloquent.saving: ' . get_class($address), $address) + ->andReturn(true); + $events->shouldReceive('until') + ->once() + ->with('eloquent.creating: ' . get_class($address), $address) + ->andReturn(true); $events->shouldReceive('dispatch')->once()->with('eloquent.created: ' . get_class($address), $address); $events->shouldReceive('dispatch')->once()->with('eloquent.saved: ' . get_class($address), $address); @@ -34,23 +44,29 @@ public function testEmbedsManySave() $this->assertNotNull($user->addresses); $this->assertInstanceOf(\Illuminate\Database\Eloquent\Collection::class, $user->addresses); $this->assertEquals(['London'], $user->addresses->pluck('city')->all()); - $this->assertInstanceOf('DateTime', $address->created_at); - $this->assertInstanceOf('DateTime', $address->updated_at); + $this->assertInstanceOf(DateTime::class, $address->created_at); + $this->assertInstanceOf(DateTime::class, $address->updated_at); $this->assertNotNull($address->_id); $this->assertIsString($address->_id); $raw = $address->getAttributes(); - $this->assertInstanceOf(\MongoDB\BSON\ObjectID::class, $raw['_id']); + $this->assertInstanceOf(ObjectId::class, $raw['_id']); $address = $user->addresses()->save(new Address(['city' => 'Paris'])); $user = User::find($user->_id); $this->assertEquals(['London', 'Paris'], $user->addresses->pluck('city')->all()); - $address->setEventDispatcher($events = Mockery::mock(\Illuminate\Events\Dispatcher::class)); + $address->setEventDispatcher($events = Mockery::mock(Dispatcher::class)); $events->shouldReceive('dispatch')->with('eloquent.retrieved: ' . get_class($address), Mockery::any()); - $events->shouldReceive('until')->once()->with('eloquent.saving: ' . get_class($address), $address)->andReturn(true); - $events->shouldReceive('until')->once()->with('eloquent.updating: ' . get_class($address), $address)->andReturn(true); + $events->shouldReceive('until') + ->once() + ->with('eloquent.saving: ' . get_class($address), $address) + ->andReturn(true); + $events->shouldReceive('until') + ->once() + ->with('eloquent.updating: ' . get_class($address), $address) + ->andReturn(true); $events->shouldReceive('dispatch')->once()->with('eloquent.updated: ' . get_class($address), $address); $events->shouldReceive('dispatch')->once()->with('eloquent.saved: ' . get_class($address), $address); @@ -69,9 +85,9 @@ public function testEmbedsManySave() $address = $user->addresses->first(); $this->assertEquals('London', $address->city); - $this->assertInstanceOf('DateTime', $address->created_at); - $this->assertInstanceOf('DateTime', $address->updated_at); - $this->assertInstanceOf('User', $address->user); + $this->assertInstanceOf(DateTime::class, $address->created_at); + $this->assertInstanceOf(DateTime::class, $address->updated_at); + $this->assertInstanceOf(User::class, $address->user); $this->assertEmpty($address->relationsToArray()); // prevent infinite loop $user = User::find($user->_id); @@ -176,12 +192,12 @@ public function testEmbedsManyCreate() { $user = User::create([]); $address = $user->addresses()->create(['city' => 'Bruxelles']); - $this->assertInstanceOf('Address', $address); + $this->assertInstanceOf(Address::class, $address); $this->assertIsString($address->_id); $this->assertEquals(['Bruxelles'], $user->addresses->pluck('city')->all()); $raw = $address->getAttributes(); - $this->assertInstanceOf(\MongoDB\BSON\ObjectID::class, $raw['_id']); + $this->assertInstanceOf(ObjectId::class, $raw['_id']); $freshUser = User::find($user->id); $this->assertEquals(['Bruxelles'], $freshUser->addresses->pluck('city')->all()); @@ -191,14 +207,14 @@ public function testEmbedsManyCreate() $this->assertIsString($address->_id); $raw = $address->getAttributes(); - $this->assertInstanceOf(\MongoDB\BSON\ObjectID::class, $raw['_id']); + $this->assertInstanceOf(ObjectId::class, $raw['_id']); } public function testEmbedsManyCreateMany() { $user = User::create([]); list($bruxelles, $paris) = $user->addresses()->createMany([['city' => 'Bruxelles'], ['city' => 'Paris']]); - $this->assertInstanceOf('Address', $bruxelles); + $this->assertInstanceOf(Address::class, $bruxelles); $this->assertEquals('Bruxelles', $bruxelles->city); $this->assertEquals(['Bruxelles', 'Paris'], $user->addresses->pluck('city')->all()); @@ -209,14 +225,23 @@ public function testEmbedsManyCreateMany() public function testEmbedsManyDestroy() { $user = User::create(['name' => 'John Doe']); - $user->addresses()->saveMany([new Address(['city' => 'London']), new Address(['city' => 'Bristol']), new Address(['city' => 'Bruxelles'])]); + $user->addresses()->saveMany([ + new Address(['city' => 'London']), + new Address(['city' => 'Bristol']), + new Address(['city' => 'Bruxelles']), + ]); $address = $user->addresses->first(); - $address->setEventDispatcher($events = Mockery::mock(\Illuminate\Events\Dispatcher::class)); + $address->setEventDispatcher($events = Mockery::mock(Dispatcher::class)); $events->shouldReceive('dispatch')->with('eloquent.retrieved: ' . get_class($address), Mockery::any()); - $events->shouldReceive('until')->once()->with('eloquent.deleting: ' . get_class($address), Mockery::type('Address'))->andReturn(true); - $events->shouldReceive('dispatch')->once()->with('eloquent.deleted: ' . get_class($address), Mockery::type('Address')); + $events->shouldReceive('until') + ->once() + ->with('eloquent.deleting: ' . get_class($address), Mockery::type(Address::class)) + ->andReturn(true); + $events->shouldReceive('dispatch') + ->once() + ->with('eloquent.deleted: ' . get_class($address), Mockery::type(Address::class)); $user->addresses()->destroy($address->_id); $this->assertEquals(['Bristol', 'Bruxelles'], $user->addresses->pluck('city')->all()); @@ -240,7 +265,11 @@ public function testEmbedsManyDestroy() $freshUser = User::find($user->id); $this->assertEquals([], $freshUser->addresses->pluck('city')->all()); - list($london, $bristol, $bruxelles) = $user->addresses()->saveMany([new Address(['city' => 'London']), new Address(['city' => 'Bristol']), new Address(['city' => 'Bruxelles'])]); + list($london, $bristol, $bruxelles) = $user->addresses()->saveMany([ + new Address(['city' => 'London']), + new Address(['city' => 'Bristol']), + new Address(['city' => 'Bruxelles']), + ]); $user->addresses()->destroy([$london, $bruxelles]); $this->assertEquals(['Bristol'], $user->addresses->pluck('city')->all()); } @@ -248,14 +277,23 @@ public function testEmbedsManyDestroy() public function testEmbedsManyDelete() { $user = User::create(['name' => 'John Doe']); - $user->addresses()->saveMany([new Address(['city' => 'London']), new Address(['city' => 'Bristol']), new Address(['city' => 'Bruxelles'])]); + $user->addresses()->saveMany([ + new Address(['city' => 'London']), + new Address(['city' => 'Bristol']), + new Address(['city' => 'Bruxelles']), + ]); $address = $user->addresses->first(); - $address->setEventDispatcher($events = Mockery::mock(\Illuminate\Events\Dispatcher::class)); + $address->setEventDispatcher($events = Mockery::mock(Dispatcher::class)); $events->shouldReceive('dispatch')->with('eloquent.retrieved: ' . get_class($address), Mockery::any()); - $events->shouldReceive('until')->once()->with('eloquent.deleting: ' . get_class($address), Mockery::type('Address'))->andReturn(true); - $events->shouldReceive('dispatch')->once()->with('eloquent.deleted: ' . get_class($address), Mockery::type('Address')); + $events->shouldReceive('until') + ->once() + ->with('eloquent.deleting: ' . get_class($address), Mockery::type(Address::class)) + ->andReturn(true); + $events->shouldReceive('dispatch') + ->once() + ->with('eloquent.deleted: ' . get_class($address), Mockery::type(Address::class)); $address->delete(); @@ -301,10 +339,16 @@ public function testEmbedsManyCreatingEventReturnsFalse() $user = User::create(['name' => 'John Doe']); $address = new Address(['city' => 'London']); - $address->setEventDispatcher($events = Mockery::mock(\Illuminate\Events\Dispatcher::class)); + $address->setEventDispatcher($events = Mockery::mock(Dispatcher::class)); $events->shouldReceive('dispatch')->with('eloquent.retrieved: ' . get_class($address), Mockery::any()); - $events->shouldReceive('until')->once()->with('eloquent.saving: ' . get_class($address), $address)->andReturn(true); - $events->shouldReceive('until')->once()->with('eloquent.creating: ' . get_class($address), $address)->andReturn(false); + $events->shouldReceive('until') + ->once() + ->with('eloquent.saving: ' . get_class($address), $address) + ->andReturn(true); + $events->shouldReceive('until') + ->once() + ->with('eloquent.creating: ' . get_class($address), $address) + ->andReturn(false); $this->assertFalse($user->addresses()->save($address)); $address->unsetEventDispatcher(); @@ -316,9 +360,12 @@ public function testEmbedsManySavingEventReturnsFalse() $address = new Address(['city' => 'Paris']); $address->exists = true; - $address->setEventDispatcher($events = Mockery::mock(\Illuminate\Events\Dispatcher::class)); + $address->setEventDispatcher($events = Mockery::mock(Dispatcher::class)); $events->shouldReceive('dispatch')->with('eloquent.retrieved: ' . get_class($address), Mockery::any()); - $events->shouldReceive('until')->once()->with('eloquent.saving: ' . get_class($address), $address)->andReturn(false); + $events->shouldReceive('until') + ->once() + ->with('eloquent.saving: ' . get_class($address), $address) + ->andReturn(false); $this->assertFalse($user->addresses()->save($address)); $address->unsetEventDispatcher(); @@ -330,10 +377,16 @@ public function testEmbedsManyUpdatingEventReturnsFalse() $address = new Address(['city' => 'New York']); $user->addresses()->save($address); - $address->setEventDispatcher($events = Mockery::mock(\Illuminate\Events\Dispatcher::class)); + $address->setEventDispatcher($events = Mockery::mock(Dispatcher::class)); $events->shouldReceive('dispatch')->with('eloquent.retrieved: ' . get_class($address), Mockery::any()); - $events->shouldReceive('until')->once()->with('eloquent.saving: ' . get_class($address), $address)->andReturn(true); - $events->shouldReceive('until')->once()->with('eloquent.updating: ' . get_class($address), $address)->andReturn(false); + $events->shouldReceive('until') + ->once() + ->with('eloquent.saving: ' . get_class($address), $address) + ->andReturn(true); + $events->shouldReceive('until') + ->once() + ->with('eloquent.updating: ' . get_class($address), $address) + ->andReturn(false); $address->city = 'Warsaw'; @@ -348,9 +401,12 @@ public function testEmbedsManyDeletingEventReturnsFalse() $address = $user->addresses->first(); - $address->setEventDispatcher($events = Mockery::mock(\Illuminate\Events\Dispatcher::class)); + $address->setEventDispatcher($events = Mockery::mock(Dispatcher::class)); $events->shouldReceive('dispatch')->with('eloquent.retrieved: ' . get_class($address), Mockery::any()); - $events->shouldReceive('until')->once()->with('eloquent.deleting: ' . get_class($address), Mockery::mustBe($address))->andReturn(false); + $events->shouldReceive('until') + ->once() + ->with('eloquent.deleting: ' . get_class($address), Mockery::mustBe($address)) + ->andReturn(false); $this->assertEquals(0, $user->addresses()->destroy($address)); $this->assertEquals(['New York'], $user->addresses->pluck('city')->all()); @@ -425,22 +481,52 @@ public function testEmbedsManyDeleteAll() public function testEmbedsManyCollectionMethods() { $user = User::create(['name' => 'John Doe']); - $user->addresses()->save(new Address(['city' => 'Paris', 'country' => 'France', 'visited' => 4, 'created_at' => new DateTime('3 days ago')])); - $user->addresses()->save(new Address(['city' => 'Bruges', 'country' => 'Belgium', 'visited' => 7, 'created_at' => new DateTime('5 days ago')])); - $user->addresses()->save(new Address(['city' => 'Brussels', 'country' => 'Belgium', 'visited' => 2, 'created_at' => new DateTime('4 days ago')])); - $user->addresses()->save(new Address(['city' => 'Ghent', 'country' => 'Belgium', 'visited' => 13, 'created_at' => new DateTime('2 days ago')])); + $user->addresses()->save(new Address([ + 'city' => 'Paris', + 'country' => 'France', + 'visited' => 4, + 'created_at' => new DateTime('3 days ago'), + ])); + $user->addresses()->save(new Address([ + 'city' => 'Bruges', + 'country' => 'Belgium', + 'visited' => 7, + 'created_at' => new DateTime('5 days ago'), + ])); + $user->addresses()->save(new Address([ + 'city' => 'Brussels', + 'country' => 'Belgium', + 'visited' => 2, + 'created_at' => new DateTime('4 days ago'), + ])); + $user->addresses()->save(new Address([ + 'city' => 'Ghent', + 'country' => 'Belgium', + 'visited' => 13, + 'created_at' => new DateTime('2 days ago'), + ])); $this->assertEquals(['Paris', 'Bruges', 'Brussels', 'Ghent'], $user->addresses()->pluck('city')->all()); - $this->assertEquals(['Bruges', 'Brussels', 'Ghent', 'Paris'], $user->addresses()->sortBy('city')->pluck('city')->all()); + $this->assertEquals(['Bruges', 'Brussels', 'Ghent', 'Paris'], $user->addresses() + ->sortBy('city') + ->pluck('city') + ->all()); $this->assertEquals([], $user->addresses()->where('city', 'New York')->pluck('city')->all()); - $this->assertEquals(['Bruges', 'Brussels', 'Ghent'], $user->addresses()->where('country', 'Belgium')->pluck('city')->all()); - $this->assertEquals(['Bruges', 'Brussels', 'Ghent'], $user->addresses()->where('country', 'Belgium')->sortBy('city')->pluck('city')->all()); + $this->assertEquals(['Bruges', 'Brussels', 'Ghent'], $user->addresses() + ->where('country', 'Belgium') + ->pluck('city') + ->all()); + $this->assertEquals(['Bruges', 'Brussels', 'Ghent'], $user->addresses() + ->where('country', 'Belgium') + ->sortBy('city') + ->pluck('city') + ->all()); $results = $user->addresses->first(); - $this->assertInstanceOf('Address', $results); + $this->assertInstanceOf(Address::class, $results); $results = $user->addresses()->where('country', 'Belgium'); - $this->assertInstanceOf('Illuminate\Database\Eloquent\Collection', $results); + $this->assertInstanceOf(Collection::class, $results); $this->assertEquals(3, $results->count()); $results = $user->addresses()->whereIn('visited', [7, 13]); @@ -452,10 +538,16 @@ public function testEmbedsOne() $user = User::create(['name' => 'John Doe']); $father = new User(['name' => 'Mark Doe']); - $father->setEventDispatcher($events = Mockery::mock(\Illuminate\Events\Dispatcher::class)); + $father->setEventDispatcher($events = Mockery::mock(Dispatcher::class)); $events->shouldReceive('dispatch')->with('eloquent.retrieved: ' . get_class($father), Mockery::any()); - $events->shouldReceive('until')->once()->with('eloquent.saving: ' . get_class($father), $father)->andReturn(true); - $events->shouldReceive('until')->once()->with('eloquent.creating: ' . get_class($father), $father)->andReturn(true); + $events->shouldReceive('until') + ->once() + ->with('eloquent.saving: ' . get_class($father), $father) + ->andReturn(true); + $events->shouldReceive('until') + ->once() + ->with('eloquent.creating: ' . get_class($father), $father) + ->andReturn(true); $events->shouldReceive('dispatch')->once()->with('eloquent.created: ' . get_class($father), $father); $events->shouldReceive('dispatch')->once()->with('eloquent.saved: ' . get_class($father), $father); @@ -464,18 +556,24 @@ public function testEmbedsOne() $this->assertNotNull($user->father); $this->assertEquals('Mark Doe', $user->father->name); - $this->assertInstanceOf('DateTime', $father->created_at); - $this->assertInstanceOf('DateTime', $father->updated_at); + $this->assertInstanceOf(DateTime::class, $father->created_at); + $this->assertInstanceOf(DateTime::class, $father->updated_at); $this->assertNotNull($father->_id); $this->assertIsString($father->_id); $raw = $father->getAttributes(); - $this->assertInstanceOf('MongoDB\BSON\ObjectID', $raw['_id']); + $this->assertInstanceOf(ObjectId::class, $raw['_id']); - $father->setEventDispatcher($events = Mockery::mock(\Illuminate\Events\Dispatcher::class)); + $father->setEventDispatcher($events = Mockery::mock(Dispatcher::class)); $events->shouldReceive('dispatch')->with('eloquent.retrieved: ' . get_class($father), Mockery::any()); - $events->shouldReceive('until')->once()->with('eloquent.saving: ' . get_class($father), $father)->andReturn(true); - $events->shouldReceive('until')->once()->with('eloquent.updating: ' . get_class($father), $father)->andReturn(true); + $events->shouldReceive('until') + ->once() + ->with('eloquent.saving: ' . get_class($father), $father) + ->andReturn(true); + $events->shouldReceive('until') + ->once() + ->with('eloquent.updating: ' . get_class($father), $father) + ->andReturn(true); $events->shouldReceive('dispatch')->once()->with('eloquent.updated: ' . get_class($father), $father); $events->shouldReceive('dispatch')->once()->with('eloquent.saved: ' . get_class($father), $father); @@ -488,10 +586,16 @@ public function testEmbedsOne() $father = new User(['name' => 'Jim Doe']); - $father->setEventDispatcher($events = Mockery::mock(\Illuminate\Events\Dispatcher::class)); + $father->setEventDispatcher($events = Mockery::mock(Dispatcher::class)); $events->shouldReceive('dispatch')->with('eloquent.retrieved: ' . get_class($father), Mockery::any()); - $events->shouldReceive('until')->once()->with('eloquent.saving: ' . get_class($father), $father)->andReturn(true); - $events->shouldReceive('until')->once()->with('eloquent.creating: ' . get_class($father), $father)->andReturn(true); + $events->shouldReceive('until') + ->once() + ->with('eloquent.saving: ' . get_class($father), $father) + ->andReturn(true); + $events->shouldReceive('until') + ->once() + ->with('eloquent.creating: ' . get_class($father), $father) + ->andReturn(true); $events->shouldReceive('dispatch')->once()->with('eloquent.created: ' . get_class($father), $father); $events->shouldReceive('dispatch')->once()->with('eloquent.saved: ' . get_class($father), $father); @@ -507,7 +611,7 @@ public function testEmbedsOneAssociate() $user = User::create(['name' => 'John Doe']); $father = new User(['name' => 'Mark Doe']); - $father->setEventDispatcher($events = Mockery::mock(\Illuminate\Events\Dispatcher::class)); + $father->setEventDispatcher($events = Mockery::mock(Dispatcher::class)); $events->shouldReceive('dispatch')->with('eloquent.retrieved: ' . get_class($father), Mockery::any()); $events->shouldReceive('until')->times(0)->with('eloquent.saving: ' . get_class($father), $father); diff --git a/tests/GeospatialTest.php b/tests/GeospatialTest.php index f1237e582..51d44abc7 100644 --- a/tests/GeospatialTest.php +++ b/tests/GeospatialTest.php @@ -54,28 +54,30 @@ public function testGeoWithin() $locations = Location::where('location', 'geoWithin', [ '$geometry' => [ 'type' => 'Polygon', - 'coordinates' => [[ - [ - -0.1450383, - 51.5069158, - ], - [ - -0.1367563, - 51.5100913, - ], - [ - -0.1270247, - 51.5013233, - ], - [ - -0.1460866, - 51.4952136, - ], + 'coordinates' => [ [ - -0.1450383, - 51.5069158, + [ + -0.1450383, + 51.5069158, + ], + [ + -0.1367563, + 51.5100913, + ], + [ + -0.1270247, + 51.5013233, + ], + [ + -0.1460866, + 51.4952136, + ], + [ + -0.1450383, + 51.5069158, + ], ], - ]], + ], ], ]); @@ -105,7 +107,7 @@ public function testGeoIntersects() 51.5078646, ], ], - ] + ], ]); $this->assertEquals(1, $locations->count()); diff --git a/tests/HybridRelationsTest.php b/tests/HybridRelationsTest.php index 303762ca2..025a1aa4d 100644 --- a/tests/HybridRelationsTest.php +++ b/tests/HybridRelationsTest.php @@ -1,6 +1,8 @@ assertInstanceOf('MysqlUser', $user); - $this->assertInstanceOf('Illuminate\Database\MySqlConnection', $user->getConnection()); + $this->assertInstanceOf(MysqlUser::class, $user); + $this->assertInstanceOf(MySqlConnection::class, $user->getConnection()); // Mysql User $user->name = "John Doe"; @@ -80,10 +82,10 @@ public function testHybridWhereHas() { $user = new MysqlUser; $otherUser = new MysqlUser; - $this->assertInstanceOf('MysqlUser', $user); - $this->assertInstanceOf('Illuminate\Database\MySqlConnection', $user->getConnection()); - $this->assertInstanceOf('MysqlUser', $otherUser); - $this->assertInstanceOf('Illuminate\Database\MySqlConnection', $otherUser->getConnection()); + $this->assertInstanceOf(MysqlUser::class, $user); + $this->assertInstanceOf(MySqlConnection::class, $user->getConnection()); + $this->assertInstanceOf(MysqlUser::class, $otherUser); + $this->assertInstanceOf(MySqlConnection::class, $otherUser->getConnection()); //MySql User $user->name = "John Doe"; @@ -134,10 +136,10 @@ public function testHybridWith() { $user = new MysqlUser; $otherUser = new MysqlUser; - $this->assertInstanceOf('MysqlUser', $user); - $this->assertInstanceOf('Illuminate\Database\MySqlConnection', $user->getConnection()); - $this->assertInstanceOf('MysqlUser', $otherUser); - $this->assertInstanceOf('Illuminate\Database\MySqlConnection', $otherUser->getConnection()); + $this->assertInstanceOf(MysqlUser::class, $user); + $this->assertInstanceOf(MySqlConnection::class, $user->getConnection()); + $this->assertInstanceOf(MysqlUser::class, $otherUser); + $this->assertInstanceOf(MySqlConnection::class, $otherUser->getConnection()); //MySql User $user->name = "John Doe"; diff --git a/tests/ModelTest.php b/tests/ModelTest.php index bbc747942..d774e5306 100644 --- a/tests/ModelTest.php +++ b/tests/ModelTest.php @@ -551,7 +551,7 @@ public function testGetDirtyDates(): void public function testChunkById(): void { - User::create(['name' => 'fork', 'tags' => ['sharp', 'pointy']]); + User::create(['name' => 'fork', 'tags' => ['sharp', 'pointy']]); User::create(['name' => 'spork', 'tags' => ['sharp', 'pointy', 'round', 'bowl']]); User::create(['name' => 'spoon', 'tags' => ['round', 'bowl']]); diff --git a/tests/QueryBuilderTest.php b/tests/QueryBuilderTest.php index 1a7a8ffb9..093436699 100644 --- a/tests/QueryBuilderTest.php +++ b/tests/QueryBuilderTest.php @@ -2,8 +2,12 @@ declare(strict_types=1); use Illuminate\Support\Facades\DB; -use MongoDB\BSON\UTCDateTime; +use Jenssegers\Mongodb\Collection; +use Jenssegers\Mongodb\Query\Builder; +use MongoDB\BSON\ObjectId; use MongoDB\BSON\Regex; +use MongoDB\BSON\UTCDateTime; +use MongoDB\Driver\Cursor; class QueryBuilderTest extends TestCase { @@ -49,7 +53,7 @@ public function testDeleteWithId() public function testCollection() { - $this->assertInstanceOf('Jenssegers\Mongodb\Query\Builder', DB::collection('users')); + $this->assertInstanceOf(Builder::class, DB::collection('users')); } public function testGet() @@ -93,7 +97,7 @@ public function testInsert() public function testInsertGetId() { $id = DB::collection('users')->insertGetId(['name' => 'John Doe']); - $this->assertInstanceOf('MongoDB\BSON\ObjectID', $id); + $this->assertInstanceOf(ObjectId::class, $id); } public function testBatchInsert() @@ -179,11 +183,11 @@ public function testSubKey() { DB::collection('users')->insert([ [ - 'name' => 'John Doe', + 'name' => 'John Doe', 'address' => ['country' => 'Belgium', 'city' => 'Ghent'], ], [ - 'name' => 'Jane Doe', + 'name' => 'Jane Doe', 'address' => ['country' => 'France', 'city' => 'Paris'], ], ]); @@ -222,14 +226,14 @@ public function testRaw() return $collection->find(['age' => 20]); }); - $this->assertInstanceOf('MongoDB\Driver\Cursor', $cursor); + $this->assertInstanceOf(Cursor::class, $cursor); $this->assertCount(1, $cursor->toArray()); $collection = DB::collection('users')->raw(); - $this->assertInstanceOf('Jenssegers\Mongodb\Collection', $collection); + $this->assertInstanceOf(Collection::class, $collection); $collection = User::raw(); - $this->assertInstanceOf('Jenssegers\Mongodb\Collection', $collection); + $this->assertInstanceOf(Collection::class, $collection); $results = DB::collection('users')->whereRaw(['age' => 20])->get(); $this->assertCount(1, $results); @@ -239,8 +243,8 @@ public function testRaw() public function testPush() { $id = DB::collection('users')->insertGetId([ - 'name' => 'John Doe', - 'tags' => [], + 'name' => 'John Doe', + 'tags' => [], 'messages' => [], ]); @@ -274,12 +278,20 @@ public function testPush() $this->assertEquals($message, $user['messages'][0]); // Raw - DB::collection('users')->where('_id', $id)->push(['tags' => 'tag3', 'messages' => ['from' => 'Mark', 'body' => 'Hi John']]); + DB::collection('users')->where('_id', $id)->push([ + 'tags' => 'tag3', + 'messages' => ['from' => 'Mark', 'body' => 'Hi John'], + ]); $user = DB::collection('users')->find($id); $this->assertCount(4, $user['tags']); $this->assertCount(2, $user['messages']); - DB::collection('users')->where('_id', $id)->push(['messages' => ['date' => new DateTime(), 'body' => 'Hi John']]); + DB::collection('users')->where('_id', $id)->push([ + 'messages' => [ + 'date' => new DateTime(), + 'body' => 'Hi John', + ], + ]); $user = DB::collection('users')->find($id); $this->assertCount(3, $user['messages']); } @@ -290,8 +302,8 @@ public function testPull() $message2 = ['from' => 'Mark', 'body' => 'Hi John']; $id = DB::collection('users')->insertGetId([ - 'name' => 'John Doe', - 'tags' => ['tag1', 'tag2', 'tag3', 'tag4'], + 'name' => 'John Doe', + 'tags' => ['tag1', 'tag2', 'tag3', 'tag4'], 'messages' => [$message1, $message2], ]); @@ -319,7 +331,7 @@ public function testDistinct() { DB::collection('items')->insert([ ['name' => 'knife', 'type' => 'sharp'], - ['name' => 'fork', 'type' => 'sharp'], + ['name' => 'fork', 'type' => 'sharp'], ['name' => 'spoon', 'type' => 'round'], ['name' => 'spoon', 'type' => 'round'], ]); @@ -339,7 +351,7 @@ public function testCustomId() { DB::collection('items')->insert([ ['_id' => 'knife', 'type' => 'sharp', 'amount' => 34], - ['_id' => 'fork', 'type' => 'sharp', 'amount' => 20], + ['_id' => 'fork', 'type' => 'sharp', 'amount' => 20], ['_id' => 'spoon', 'type' => 'round', 'amount' => 3], ]); @@ -362,7 +374,7 @@ public function testTake() { DB::collection('items')->insert([ ['name' => 'knife', 'type' => 'sharp', 'amount' => 34], - ['name' => 'fork', 'type' => 'sharp', 'amount' => 20], + ['name' => 'fork', 'type' => 'sharp', 'amount' => 20], ['name' => 'spoon', 'type' => 'round', 'amount' => 3], ['name' => 'spoon', 'type' => 'round', 'amount' => 14], ]); @@ -376,7 +388,7 @@ public function testSkip() { DB::collection('items')->insert([ ['name' => 'knife', 'type' => 'sharp', 'amount' => 34], - ['name' => 'fork', 'type' => 'sharp', 'amount' => 20], + ['name' => 'fork', 'type' => 'sharp', 'amount' => 20], ['name' => 'spoon', 'type' => 'round', 'amount' => 3], ['name' => 'spoon', 'type' => 'round', 'amount' => 14], ]); @@ -401,7 +413,7 @@ public function testList() { DB::collection('items')->insert([ ['name' => 'knife', 'type' => 'sharp', 'amount' => 34], - ['name' => 'fork', 'type' => 'sharp', 'amount' => 20], + ['name' => 'fork', 'type' => 'sharp', 'amount' => 20], ['name' => 'spoon', 'type' => 'round', 'amount' => 3], ['name' => 'spoon', 'type' => 'round', 'amount' => 14], ]); @@ -424,7 +436,7 @@ public function testAggregate() { DB::collection('items')->insert([ ['name' => 'knife', 'type' => 'sharp', 'amount' => 34], - ['name' => 'fork', 'type' => 'sharp', 'amount' => 20], + ['name' => 'fork', 'type' => 'sharp', 'amount' => 20], ['name' => 'spoon', 'type' => 'round', 'amount' => 3], ['name' => 'spoon', 'type' => 'round', 'amount' => 14], ]); @@ -443,7 +455,7 @@ public function testSubdocumentAggregate() { DB::collection('items')->insert([ ['name' => 'knife', 'amount' => ['hidden' => 10, 'found' => 3]], - ['name' => 'fork', 'amount' => ['hidden' => 35, 'found' => 12]], + ['name' => 'fork', 'amount' => ['hidden' => 35, 'found' => 12]], ['name' => 'spoon', 'amount' => ['hidden' => 14, 'found' => 21]], ['name' => 'spoon', 'amount' => ['hidden' => 6, 'found' => 4]], ]); @@ -459,7 +471,14 @@ public function testSubdocumentArrayAggregate() { DB::collection('items')->insert([ ['name' => 'knife', 'amount' => [['hidden' => 10, 'found' => 3], ['hidden' => 5, 'found' => 2]]], - ['name' => 'fork', 'amount' => [['hidden' => 35, 'found' => 12], ['hidden' => 7, 'found' => 17], ['hidden' => 1, 'found' => 19]]], + [ + 'name' => 'fork', + 'amount' => [ + ['hidden' => 35, 'found' => 12], + ['hidden' => 7, 'found' => 17], + ['hidden' => 1, 'found' => 19], + ], + ], ['name' => 'spoon', 'amount' => [['hidden' => 14, 'found' => 21]]], ['name' => 'teaspoon', 'amount' => []], ]); @@ -474,15 +493,15 @@ public function testSubdocumentArrayAggregate() public function testUpsert() { DB::collection('items')->where('name', 'knife') - ->update( - ['amount' => 1], - ['upsert' => true] - ); + ->update( + ['amount' => 1], + ['upsert' => true] + ); $this->assertEquals(1, DB::collection('items')->count()); Item::where('name', 'spoon') - ->update( + ->update( ['amount' => 1], ['upsert' => true] ); @@ -531,7 +550,9 @@ public function testDates() ['name' => 'Mark Moe', 'birthday' => new UTCDateTime(1000 * strtotime("1983-01-01 00:00:00"))], ]); - $user = DB::collection('users')->where('birthday', new UTCDateTime(1000 * strtotime("1980-01-01 00:00:00")))->first(); + $user = DB::collection('users') + ->where('birthday', new UTCDateTime(1000 * strtotime("1980-01-01 00:00:00"))) + ->first(); $this->assertEquals('John Doe', $user['name']); $user = DB::collection('users')->where('birthday', '=', new DateTime("1980-01-01 00:00:00"))->first(); @@ -578,7 +599,7 @@ public function testOperators() $this->assertCount(0, $results); DB::collection('items')->insert([ - ['name' => 'fork', 'tags' => ['sharp', 'pointy']], + ['name' => 'fork', 'tags' => ['sharp', 'pointy']], ['name' => 'spork', 'tags' => ['sharp', 'pointy', 'round', 'bowl']], ['name' => 'spoon', 'tags' => ['round', 'bowl']], ]); @@ -620,14 +641,14 @@ public function testOperators() DB::collection('users')->insert([ [ - 'name' => 'John Doe', + 'name' => 'John Doe', 'addresses' => [ ['city' => 'Ghent'], ['city' => 'Paris'], ], ], [ - 'name' => 'Jane Doe', + 'name' => 'Jane Doe', 'addresses' => [ ['city' => 'Brussels'], ['city' => 'Paris'], @@ -692,7 +713,7 @@ public function testIncrement() public function testProjections() { DB::collection('items')->insert([ - ['name' => 'fork', 'tags' => ['sharp', 'pointy']], + ['name' => 'fork', 'tags' => ['sharp', 'pointy']], ['name' => 'spork', 'tags' => ['sharp', 'pointy', 'round', 'bowl']], ['name' => 'spoon', 'tags' => ['round', 'bowl']], ]); @@ -707,11 +728,12 @@ public function testProjections() public function testValue() { DB::collection('books')->insert([ - ['title' => 'Moby-Dick', 'author' => ['first_name' => 'Herman', 'last_name' => 'Melville']] + ['title' => 'Moby-Dick', 'author' => ['first_name' => 'Herman', 'last_name' => 'Melville']], ]); $this->assertEquals('Moby-Dick', DB::collection('books')->value('title')); - $this->assertEquals(['first_name' => 'Herman', 'last_name' => 'Melville'], DB::collection('books')->value('author')); + $this->assertEquals(['first_name' => 'Herman', 'last_name' => 'Melville'], DB::collection('books') + ->value('author')); $this->assertEquals('Herman', DB::collection('books')->value('author.first_name')); $this->assertEquals('Melville', DB::collection('books')->value('author.last_name')); } diff --git a/tests/QueryTest.php b/tests/QueryTest.php index 646340ad2..b697555cc 100644 --- a/tests/QueryTest.php +++ b/tests/QueryTest.php @@ -131,7 +131,7 @@ public function testIn(): void $this->assertCount(4, $users); $users = User::whereNotNull('age') - ->whereNotIn('age', [33, 35])->get(); + ->whereNotIn('age', [33, 35])->get(); $this->assertCount(3, $users); } @@ -218,7 +218,7 @@ public function testSubQuery(): void { $users = User::where('title', 'admin')->orWhere(function ($query) { $query->where('name', 'Tommy Toe') - ->orWhere('name', 'Error'); + ->orWhere('name', 'Error'); }) ->get(); @@ -226,7 +226,7 @@ public function testSubQuery(): void $users = User::where('title', 'user')->where(function ($query) { $query->where('age', 35) - ->orWhere('name', 'like', '%harry%'); + ->orWhere('name', 'like', '%harry%'); }) ->get(); @@ -234,31 +234,31 @@ public function testSubQuery(): void $users = User::where('age', 35)->orWhere(function ($query) { $query->where('title', 'admin') - ->orWhere('name', 'Error'); + ->orWhere('name', 'Error'); }) ->get(); $this->assertCount(5, $users); $users = User::whereNull('deleted_at') - ->where('title', 'admin') - ->where(function ($query) { - $query->where('age', '>', 15) - ->orWhere('name', 'Harry Hoe'); - }) - ->get(); + ->where('title', 'admin') + ->where(function ($query) { + $query->where('age', '>', 15) + ->orWhere('name', 'Harry Hoe'); + }) + ->get(); $this->assertEquals(3, $users->count()); $users = User::whereNull('deleted_at') - ->where(function ($query) { - $query->where('name', 'Harry Hoe') - ->orWhere(function ($query) { - $query->where('age', '>', 15) - ->where('title', '<>', 'admin'); - }); - }) - ->get(); + ->where(function ($query) { + $query->where('name', 'Harry Hoe') + ->orWhere(function ($query) { + $query->where('age', '>', 15) + ->where('title', '<>', 'admin'); + }); + }) + ->get(); $this->assertEquals(5, $users->count()); } @@ -271,7 +271,7 @@ public function testWhereRaw(): void $this->assertCount(6, $users); $where1 = ['age' => ['$gt' => 30, '$lte' => 35]]; - $where2 = ['age' => ['$gt' => 35, '$lt' => 40]]; + $where2 = ['age' => ['$gt' => 35, '$lt' => 40]]; $users = User::whereRaw($where1)->orWhereRaw($where2)->get(); $this->assertCount(6, $users); @@ -282,18 +282,18 @@ public function testMultipleOr(): void $users = User::where(function ($query) { $query->where('age', 35)->orWhere('age', 33); }) - ->where(function ($query) { - $query->where('name', 'John Doe')->orWhere('name', 'Jane Doe'); - })->get(); + ->where(function ($query) { + $query->where('name', 'John Doe')->orWhere('name', 'Jane Doe'); + })->get(); $this->assertCount(2, $users); $users = User::where(function ($query) { $query->orWhere('age', 35)->orWhere('age', 33); }) - ->where(function ($query) { - $query->orWhere('name', 'John Doe')->orWhere('name', 'Jane Doe'); - })->get(); + ->where(function ($query) { + $query->orWhere('name', 'John Doe')->orWhere('name', 'Jane Doe'); + })->get(); $this->assertCount(2, $users); } diff --git a/tests/RelationsTest.php b/tests/RelationsTest.php index decc4f14b..a50329682 100644 --- a/tests/RelationsTest.php +++ b/tests/RelationsTest.php @@ -1,6 +1,8 @@ orderBy('user_id', 'desc')->get(); $user = $items[0]->getRelation('user'); - $this->assertInstanceOf('User', $user); + $this->assertInstanceOf(User::class, $user); $this->assertEquals('John Doe', $user->name); $this->assertCount(1, $items[0]->getRelations()); $this->assertNull($items[3]->getRelation('user')); @@ -108,7 +110,7 @@ public function testWithHashMany(): void $items = $user->getRelation('items'); $this->assertCount(3, $items); - $this->assertInstanceOf('Item', $items[0]); + $this->assertInstanceOf(Item::class, $items[0]); } public function testWithHasOne(): void @@ -120,7 +122,7 @@ public function testWithHasOne(): void $user = User::with('role')->find($user->_id); $role = $user->getRelation('role'); - $this->assertInstanceOf('Role', $role); + $this->assertInstanceOf(Role::class, $role); $this->assertEquals('admin', $role->type); } @@ -134,7 +136,7 @@ public function testEasyRelation(): void $user = User::find($user->_id); $items = $user->items; $this->assertCount(1, $items); - $this->assertInstanceOf('Item', $items[0]); + $this->assertInstanceOf(Item::class, $items[0]); $this->assertEquals($user->_id, $items[0]->user_id); // Has one @@ -144,7 +146,7 @@ public function testEasyRelation(): void $user = User::find($user->_id); $role = $user->role; - $this->assertInstanceOf('Role', $role); + $this->assertInstanceOf(Role::class, $role); $this->assertEquals('admin', $role->type); $this->assertEquals($user->_id, $role->user_id); } @@ -168,18 +170,18 @@ public function testBelongsToMany(): void $clients = $user->getRelation('clients'); $users = $client->getRelation('users'); - $this->assertInstanceOf('Illuminate\Database\Eloquent\Collection', $users); - $this->assertInstanceOf('Illuminate\Database\Eloquent\Collection', $clients); - $this->assertInstanceOf('Client', $clients[0]); - $this->assertInstanceOf('User', $users[0]); + $this->assertInstanceOf(Collection::class, $users); + $this->assertInstanceOf(Collection::class, $clients); + $this->assertInstanceOf(Client::class, $clients[0]); + $this->assertInstanceOf(User::class, $users[0]); $this->assertCount(2, $user->clients); $this->assertCount(1, $client->users); // Now create a new user to an existing client $user = $client->users()->create(['name' => 'Jane Doe']); - $this->assertInstanceOf('Illuminate\Database\Eloquent\Collection', $user->clients); - $this->assertInstanceOf('Client', $user->clients->first()); + $this->assertInstanceOf(Collection::class, $user->clients); + $this->assertInstanceOf(Client::class, $user->clients->first()); $this->assertCount(1, $user->clients); // Get user and unattached client @@ -187,8 +189,8 @@ public function testBelongsToMany(): void $client = Client::Where('name', '=', 'Buffet Bar Inc.')->first(); // Check the models are what they should be - $this->assertInstanceOf('Client', $client); - $this->assertInstanceOf('User', $user); + $this->assertInstanceOf(Client::class, $client); + $this->assertInstanceOf(User::class, $user); // Assert they are not attached $this->assertNotContains($client->_id, $user->client_ids); @@ -377,11 +379,11 @@ public function testMorph(): void $photos = Photo::with('imageable')->get(); $relations = $photos[0]->getRelations(); $this->assertArrayHasKey('imageable', $relations); - $this->assertInstanceOf('User', $photos[0]->imageable); + $this->assertInstanceOf(User::class, $photos[0]->imageable); $relations = $photos[1]->getRelations(); $this->assertArrayHasKey('imageable', $relations); - $this->assertInstanceOf('Client', $photos[1]->imageable); + $this->assertInstanceOf(Client::class, $photos[1]->imageable); } public function testHasManyHas(): void @@ -461,14 +463,14 @@ public function testNestedKeys(): void $client = Client::create([ 'data' => [ 'client_id' => 35298, - 'name' => 'John Doe', + 'name' => 'John Doe', ], ]); $address = $client->addresses()->create([ 'data' => [ 'address_id' => 1432, - 'city' => 'Paris', + 'city' => 'Paris', ], ]); diff --git a/tests/SchemaTest.php b/tests/SchemaTest.php index a8fac2f1f..e3ca81976 100644 --- a/tests/SchemaTest.php +++ b/tests/SchemaTest.php @@ -1,6 +1,8 @@ assertInstanceOf('Jenssegers\Mongodb\Schema\Blueprint', $collection); + $instance->assertInstanceOf(Blueprint::class, $collection); }); $this->assertTrue(Schema::hasCollection('newcollection')); @@ -46,11 +48,11 @@ public function testBluePrint(): void $instance = $this; Schema::collection('newcollection', function ($collection) use ($instance) { - $instance->assertInstanceOf('Jenssegers\Mongodb\Schema\Blueprint', $collection); + $instance->assertInstanceOf(Blueprint::class, $collection); }); Schema::table('newcollection', function ($collection) use ($instance) { - $instance->assertInstanceOf('Jenssegers\Mongodb\Schema\Blueprint', $collection); + $instance->assertInstanceOf(Blueprint::class, $collection); }); } diff --git a/tests/TestCase.php b/tests/TestCase.php index 5f9ec7a89..c27fec178 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -7,9 +7,7 @@ class TestCase extends Orchestra\Testbench\TestCase { /** * Get application providers. - * - * @param \Illuminate\Foundation\Application $app - * + * @param \Illuminate\Foundation\Application $app * @return array */ protected function getApplicationProviders($app) @@ -23,8 +21,7 @@ protected function getApplicationProviders($app) /** * Get package providers. - * - * @param \Illuminate\Foundation\Application $app + * @param \Illuminate\Foundation\Application $app * @return array */ protected function getPackageProviders($app) @@ -32,14 +29,13 @@ protected function getPackageProviders($app) return [ Jenssegers\Mongodb\MongodbServiceProvider::class, Jenssegers\Mongodb\Auth\PasswordResetServiceProvider::class, - Jenssegers\Mongodb\Validation\ValidationServiceProvider::class + Jenssegers\Mongodb\Validation\ValidationServiceProvider::class, ]; } /** * Define environment setup. - * - * @param Illuminate\Foundation\Application $app + * @param Illuminate\Foundation\Application $app * @return void */ protected function getEnvironmentSetUp($app) @@ -63,8 +59,8 @@ protected function getEnvironmentSetUp($app) $app['config']->set('queue.default', 'database'); $app['config']->set('queue.connections.database', [ 'driver' => 'mongodb', - 'table' => 'jobs', - 'queue' => 'default', + 'table' => 'jobs', + 'queue' => 'default', 'expire' => 60, ]); } diff --git a/tests/config/database.php b/tests/config/database.php index a210595fa..23f8ca990 100644 --- a/tests/config/database.php +++ b/tests/config/database.php @@ -8,27 +8,27 @@ 'connections' => [ 'mongodb' => [ - 'name' => 'mongodb', - 'driver' => 'mongodb', - 'host' => $mongoHost, - 'database' => env('MONGO_DATABASE', 'unittest'), + 'name' => 'mongodb', + 'driver' => 'mongodb', + 'host' => $mongoHost, + 'database' => env('MONGO_DATABASE', 'unittest'), ], 'dsn_mongodb' => [ - 'driver' => 'mongodb', - 'dsn' => "mongodb://$mongoHost:$mongoPort", - 'database' => env('MONGO_DATABASE', 'unittest'), + 'driver' => 'mongodb', + 'dsn' => "mongodb://$mongoHost:$mongoPort", + 'database' => env('MONGO_DATABASE', 'unittest'), ], 'mysql' => [ - 'driver' => 'mysql', - 'host' => env('MYSQL_HOST', 'mysql'), - 'database' => env('MYSQL_DATABASE', 'unittest'), - 'username' => env('MYSQL_USERNAME', 'root'), - 'password' => env('MYSQL_PASSWORD', ''), - 'charset' => 'utf8', + 'driver' => 'mysql', + 'host' => env('MYSQL_HOST', 'mysql'), + 'database' => env('MYSQL_DATABASE', 'unittest'), + 'username' => env('MYSQL_USERNAME', 'root'), + 'password' => env('MYSQL_PASSWORD', ''), + 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', - 'prefix' => '', + 'prefix' => '', ], ], diff --git a/tests/config/queue.php b/tests/config/queue.php index e8203d90b..20ef36703 100644 --- a/tests/config/queue.php +++ b/tests/config/queue.php @@ -8,8 +8,8 @@ 'database' => [ 'driver' => 'mongodb', - 'table' => 'jobs', - 'queue' => 'default', + 'table' => 'jobs', + 'queue' => 'default', 'expire' => 60, ], @@ -17,7 +17,7 @@ 'failed' => [ 'database' => env('MONGO_DATABASE'), - 'table' => 'failed_jobs', + 'table' => 'failed_jobs', ], ]; diff --git a/tests/models/Book.php b/tests/models/Book.php index 27243ebcb..e37cb7eaf 100644 --- a/tests/models/Book.php +++ b/tests/models/Book.php @@ -6,7 +6,6 @@ /** * Class Book - * * @property string $title * @property string $author * @property array $chapters diff --git a/tests/models/Item.php b/tests/models/Item.php index 1bdc4189e..b06484d25 100644 --- a/tests/models/Item.php +++ b/tests/models/Item.php @@ -7,7 +7,6 @@ /** * Class Item - * * @property \Carbon\Carbon $created_at */ class Item extends Eloquent diff --git a/tests/models/Scoped.php b/tests/models/Scoped.php index 444549916..9f312f943 100644 --- a/tests/models/Scoped.php +++ b/tests/models/Scoped.php @@ -1,8 +1,8 @@