Commit cc00aff8 authored by Jens Segers's avatar Jens Segers

🚨 Linting

parent cf45ec63
......@@ -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),
];
}
/**
......
......@@ -8,7 +8,6 @@ class PasswordResetServiceProvider extends BasePasswordResetServiceProvider
{
/**
* Register the token repository implementation.
*
* @return void
*/
protected function registerTokenRepository()
......
......@@ -10,14 +10,12 @@ class Collection
{
/**
* The connection instance.
*
* @var Connection
*/
protected $connection;
/**
* The MongoCollection instance..
*
* @var MongoCollection
*/
protected $collection;
......@@ -34,7 +32,6 @@ class Collection
/**
* Handle dynamic method calls.
*
* @param string $method
* @param array $parameters
* @return mixed
......
......@@ -10,21 +10,18 @@ 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
*/
public function __construct(array $config)
......@@ -52,7 +49,6 @@ class Connection extends BaseConnection
/**
* Begin a fluent query against a database collection.
*
* @param string $collection
* @return Query\Builder
*/
......@@ -65,7 +61,6 @@ class Connection extends BaseConnection
/**
* Begin a fluent query against a database collection.
*
* @param string $table
* @param string|null $as
* @return Query\Builder
......@@ -77,7 +72,6 @@ class Connection extends BaseConnection
/**
* Get a MongoDB collection.
*
* @param string $name
* @return Collection
*/
......@@ -96,7 +90,6 @@ class Connection extends BaseConnection
/**
* Get the MongoDB database object.
*
* @return \MongoDB\Database
*/
public function getMongoDB()
......@@ -106,7 +99,6 @@ class Connection extends BaseConnection
/**
* return MongoDB object.
*
* @return \MongoDB\Client
*/
public function getMongoClient()
......@@ -124,7 +116,6 @@ class Connection extends BaseConnection
/**
* Create a new MongoDB connection.
*
* @param string $dsn
* @param array $config
* @param array $options
......@@ -160,18 +151,16 @@ class Connection extends BaseConnection
/**
* Determine if the given configuration array has a dsn string.
*
* @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
* @return string
*/
......@@ -182,7 +171,6 @@ class Connection extends BaseConnection
/**
* Get the DSN string for a host / port configuration.
*
* @param array $config
* @return string
*/
......@@ -206,7 +194,6 @@ class Connection extends BaseConnection
/**
* Create a DSN string from a configuration.
*
* @param array $config
* @return string
*/
......@@ -259,7 +246,6 @@ class Connection extends BaseConnection
/**
* Dynamically pass methods to the connection.
*
* @param string $method
* @param array $parameters
* @return mixed
......
......@@ -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 @@ class Builder extends EloquentBuilder
* 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
* @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;
}
......
......@@ -10,7 +10,6 @@ trait EmbedsRelations
{
/**
* Define an embedded one-to-many relationship.
*
* @param string $related
* @param string $localKey
* @param string $foreignKey
......@@ -45,7 +44,6 @@ trait EmbedsRelations
/**
* Define an embedded one-to-many relationship.
*
* @param string $related
* @param string $localKey
* @param string $foreignKey
......
......@@ -16,7 +16,6 @@ trait HybridRelations
{
/**
* Define a one-to-one relationship.
*
* @param string $related
* @param string $foreignKey
* @param string $localKey
......@@ -40,7 +39,6 @@ trait HybridRelations
/**
* Define a polymorphic one-to-one relationship.
*
* @param string $related
* @param string $name
* @param string $type
......@@ -66,7 +64,6 @@ trait HybridRelations
/**
* Define a one-to-many relationship.
*
* @param string $related
* @param string $foreignKey
* @param string $localKey
......@@ -90,7 +87,6 @@ trait HybridRelations
/**
* Define a polymorphic one-to-many relationship.
*
* @param string $related
* @param string $name
* @param string $type
......@@ -121,7 +117,6 @@ trait HybridRelations
/**
* Define an inverse one-to-one or many relationship.
*
* @param string $related
* @param string $foreignKey
* @param string $otherKey
......@@ -165,7 +160,6 @@ trait HybridRelations
/**
* Define a polymorphic, inverse one-to-one or many relationship.
*
* @param string $name
* @param string $type
* @param string $id
......@@ -208,7 +202,6 @@ trait HybridRelations
/**
* Define a many-to-many relationship.
*
* @param string $related
* @param string $collection
* @param string $foreignKey
......@@ -282,7 +275,6 @@ trait HybridRelations
/**
* Get the relationship name of the belongs to many.
*
* @return string
*/
protected function guessBelongsToManyRelation()
......
......@@ -4,6 +4,8 @@ namespace Jenssegers\Mongodb\Eloquent;
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 Jenssegers\Mongodb\Query\Builder as QueryBuilder;
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,35 +21,30 @@ 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
* @return mixed
*/
......@@ -267,7 +262,6 @@ abstract class Model extends BaseModel
/**
* Remove one or more fields.
*
* @param mixed $columns
* @return int
*/
......@@ -313,7 +307,6 @@ abstract class Model extends BaseModel
/**
* Remove one or more values from an array.
*
* @param string $column
* @param mixed $values
* @return mixed
......@@ -332,7 +325,6 @@ abstract class Model extends BaseModel
/**
* Append one or more values to the underlying attribute value and sync with original.
*
* @param string $column
* @param array $values
* @param bool $unique
......@@ -357,7 +349,6 @@ abstract class Model extends BaseModel
/**
* Remove one or more values to the underlying attribute value and sync with original.
*
* @param string $column
* @param array $values
*/
......@@ -390,7 +381,6 @@ abstract class Model extends BaseModel
/**
* Set the parent relation.
*
* @param \Illuminate\Database\Eloquent\Relations\Relation $relation
*/
public function setParentRelation(Relation $relation)
......@@ -400,7 +390,6 @@ abstract class Model extends BaseModel
/**
* Get the parent relation.
*
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function getParentRelation()
......@@ -436,7 +425,6 @@ abstract class Model extends BaseModel
/**
* Get the queueable relationships for the entity.
*
* @return array
*/
public function getQueueableRelations()
......@@ -450,13 +438,13 @@ abstract class Model extends BaseModel
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 @@ abstract class Model extends BaseModel
/**
* Get loaded relations for the instance without parent.
*
* @return array
*/
protected function getRelationsWithoutParent()
......
......@@ -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 Closure|null $callback
* @return Builder|static
*/
public function has($relation, $operator = '>=', $count = 1, $boolean = 'and', Closure $callback = null)
{
......@@ -74,7 +75,7 @@ trait QueriesRelationships
* @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 @@ trait QueriesRelationships
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 @@ trait QueriesRelationships
// 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.');
}
}
......@@ -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 @@ class Builder extends BaseBuilder
/**
* Returns true if Laravel or Lumen >= 5.3
*
* @return bool
*/
protected function shouldUseCollections()
......@@ -159,7 +149,6 @@ class Builder extends BaseBuilder
/**
* Set the projections.
*
* @param array $columns
* @return $this
*/
......@@ -172,7 +161,6 @@ class Builder extends BaseBuilder
/**
* Set the cursor timeout in seconds.
*
* @param int $seconds
* @return $this
*/
......@@ -185,7 +173,6 @@ class Builder extends BaseBuilder
/**
* Set the cursor hint.
*
* @param mixed $index
* @return $this
*/
......@@ -224,7 +211,6 @@ class Builder extends BaseBuilder
/**
* Execute the query as a fresh "select" statement.
*
* @param array $columns
* @return array|static[]|Collection
*/
......@@ -412,7 +398,6 @@ class Builder extends BaseBuilder
/**
* Generate the unique cache key for the current query.
*
* @return string
*/
public function generateCacheKey()
......@@ -506,7 +491,6 @@ class Builder extends BaseBuilder
/**
* Add a "where all" clause to the query.
*
* @param string $column
* @param array $values
* @param string $boolean
......@@ -711,11 +695,10 @@ class Builder extends BaseBuilder
/**
* Get an array with the values of a given column.
*
* @deprecated
* @param string $column
* @param string $key
* @return array
* @deprecated
*/
public function lists($column, $key = null)
{
......@@ -743,7 +726,6 @@ class Builder extends BaseBuilder
/**
* Append one or more values to an array.
*
* @param mixed $column
* @param mixed $value
* @param bool $unique
......@@ -770,7 +752,6 @@ class Builder extends BaseBuilder
/**
* Remove one or more values from an array.
*
* @param mixed $column
* @param mixed $value
* @return int
......@@ -794,7 +775,6 @@ class Builder extends BaseBuilder
/**
* Remove one or more fields.
*
* @param mixed $columns
* @return int
*/
......@@ -825,7 +805,6 @@ class Builder extends BaseBuilder
/**
* Perform an update query.
*
* @param array $query
* @param array $options
* @return int
......@@ -848,7 +827,6 @@ class Builder extends BaseBuilder
/**
* Convert a key to ObjectID if needed.
*
* @param mixed $id
* @return mixed
*/
......@@ -886,7 +864,6 @@ class Builder extends BaseBuilder
/**
* Compile the where array.
*
* @return array
*/
protected function compileWheres()
......@@ -1146,7 +1123,6 @@ class Builder extends BaseBuilder
/**
* Set custom options for the query.
*
* @param array $options
* @return $this
*/
......
......@@ -9,11 +9,9 @@ class MongoFailedJobProvider extends DatabaseFailedJobProvider
{
/**
* Log a failed job into storage.
*
* @param string $connection
* @param string $queue
* @param string $payload
*
* @return void
*/
public function log($connection, $queue, $payload, $exception)
......@@ -25,7 +23,6 @@ class MongoFailedJobProvider extends DatabaseFailedJobProvider
/**
* Get a list of all of the failed jobs.
*
* @return object[]
*/
public function all()
......@@ -42,7 +39,6 @@ class MongoFailedJobProvider extends DatabaseFailedJobProvider
/**
* Get a single failed job.
*
* @param mixed $id
* @return object
*/
......@@ -57,7 +53,6 @@ class MongoFailedJobProvider extends DatabaseFailedJobProvider
/**
* Delete a single failed job from storage.
*
* @param mixed $id
* @return bool
*/
......
......@@ -10,14 +10,12 @@ class MongoConnector implements ConnectorInterface
{
/**
* Database connections.
*
* @var \Illuminate\Database\ConnectionResolverInterface
*/
protected $connections;
/**
* Create a new connector instance.
*
* @param \Illuminate\Database\ConnectionResolverInterface $connections
*/
public function __construct(ConnectionResolverInterface $connections)
......@@ -27,7 +25,6 @@ class MongoConnector implements ConnectorInterface
/**
* Establish a queue connection.
*
* @param array $config
* @return \Illuminate\Contracts\Queue\Queue
*/
......
......@@ -8,7 +8,6 @@ class MongoJob extends DatabaseJob
{
/**
* Indicates if the job has been reserved.
*
* @return bool
*/
public function isReserved()
......
......@@ -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 @@ class MongoQueue extends DatabaseQueue
/**
* 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
*
* @return \StdClass|null
*/
protected function getNextAvailableJobAndReserve($queue)
......@@ -94,7 +88,6 @@ class MongoQueue extends DatabaseQueue
/**
* Release the jobs that have been reserved for too long.
*
* @param string $queue
* @return void
*/
......@@ -124,7 +117,6 @@ class MongoQueue extends DatabaseQueue
/**
* Release the given job ID from reservation.
*
* @param string $id
* @param int $attempts
* @return void
......
......@@ -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 @@ class BelongsTo extends \Illuminate\Database\Eloquent\Relations\BelongsTo
/**
* Get the owner key with backwards compatible support.
*
* @return string
*/
public function getOwnerKey()
......@@ -63,7 +61,6 @@ class BelongsTo extends \Illuminate\Database\Eloquent\Relations\BelongsTo
/**
* Get the name of the "where in" method for eager loading.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param string $key
* @return string
......
......@@ -5,15 +5,14 @@ namespace Jenssegers\Mongodb\Relations;
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,7 +38,6 @@ class BelongsToMany extends EloquentBelongsToMany
/**
* Set the select clause for the relation query.
*
* @param array $columns
* @return array
*/
......@@ -68,7 +66,6 @@ class BelongsToMany extends EloquentBelongsToMany
/**
* Set the where clause for the relation query.
*
* @return $this
*/
protected function setWhere()
......@@ -275,7 +272,6 @@ class BelongsToMany extends EloquentBelongsToMany
/**
* Create a new query builder for the related model.
*
* @return \Illuminate\Database\Query\Builder
*/
public function newRelatedQuery()
......@@ -285,7 +281,6 @@ class BelongsToMany extends EloquentBelongsToMany
/**
* Get the fully qualified foreign key for the relation.
*
* @return string
*/
public function getForeignKey()
......@@ -312,10 +307,9 @@ class BelongsToMany extends EloquentBelongsToMany
/**
* 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
* @return array
* @deprecated
*/
protected function formatSyncList(array $records)
{
......@@ -331,7 +325,6 @@ class BelongsToMany extends EloquentBelongsToMany
/**
* Get the related key with backwards compatible support.
*
* @return string
*/
public function getRelatedKey()
......@@ -341,7 +334,6 @@ class BelongsToMany extends EloquentBelongsToMany
/**
* Get the name of the "where in" method for eager loading.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param string $key
* @return string
......
......@@ -4,10 +4,10 @@ namespace Jenssegers\Mongodb\Relations;
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,7 +33,6 @@ class EmbedsMany extends EmbedsOneOrMany
/**
* Save a new model and attach it to the parent model.
*
* @param Model $model
* @return Model|bool
*/
......@@ -63,7 +62,6 @@ class EmbedsMany extends EmbedsOneOrMany
/**
* Save an existing model and attach it to the parent model.
*
* @param Model $model
* @return Model|bool
*/
......@@ -95,7 +93,6 @@ class EmbedsMany extends EmbedsOneOrMany
/**
* Delete an existing model and detach it from the parent model.
*
* @param Model $model
* @return int
*/
......@@ -122,7 +119,6 @@ class EmbedsMany extends EmbedsOneOrMany
/**
* Associate the model instance to the given parent, without saving it to the database.
*
* @param Model $model
* @return Model
*/
......@@ -137,7 +133,6 @@ class EmbedsMany extends EmbedsOneOrMany
/**
* Dissociate the model instance from the given parent, without saving it to the database.
*
* @param mixed $ids
* @return int
*/
......@@ -166,7 +161,6 @@ class EmbedsMany extends EmbedsOneOrMany
/**
* Destroy the embedded models for the given IDs.
*
* @param mixed $ids
* @return int
*/
......@@ -191,7 +185,6 @@ class EmbedsMany extends EmbedsOneOrMany
/**
* Delete all embedded models.
*
* @return int
*/
public function delete()
......@@ -208,7 +201,6 @@ class EmbedsMany extends EmbedsOneOrMany
/**
* Destroy alias.
*
* @param mixed $ids
* @return int
*/
......@@ -219,7 +211,6 @@ class EmbedsMany extends EmbedsOneOrMany
/**
* Save alias.
*
* @param Model $model
* @return Model
*/
......@@ -230,7 +221,6 @@ class EmbedsMany extends EmbedsOneOrMany
/**
* Associate a new model instance to the given parent, without saving it to the database.
*
* @param Model $model
* @return Model
*/
......@@ -251,7 +241,6 @@ class EmbedsMany extends EmbedsOneOrMany
/**
* Associate an existing model instance to the given parent, without saving it to the database.
*
* @param Model $model
* @return Model
*/
......@@ -277,7 +266,6 @@ class EmbedsMany extends EmbedsOneOrMany
/**
* Get a paginator for the "select" statement.
*
* @param int $perPage
* @return \Illuminate\Pagination\AbstractPaginator
*/
......@@ -332,7 +320,6 @@ class EmbedsMany extends EmbedsOneOrMany
/**
* Get the name of the "where in" method for eager loading.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param string $key
* @return string
......
......@@ -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,7 +30,6 @@ class EmbedsOne extends EmbedsOneOrMany
/**
* Save a new model and attach it to the parent model.
*
* @param Model $model
* @return Model|bool
*/
......@@ -59,7 +58,6 @@ class EmbedsOne extends EmbedsOneOrMany
/**
* Save an existing model and attach it to the parent model.
*
* @param Model $model
* @return Model|bool
*/
......@@ -85,7 +83,6 @@ class EmbedsOne extends EmbedsOneOrMany
/**
* Delete an existing model and detach it from the parent model.
*
* @return int
*/
public function performDelete()
......@@ -109,7 +106,6 @@ class EmbedsOne extends EmbedsOneOrMany
/**
* Attach the model to its parent.
*
* @param Model $model
* @return Model
*/
......@@ -120,7 +116,6 @@ class EmbedsOne extends EmbedsOneOrMany
/**
* Detach the model from its parent.
*
* @return Model
*/
public function dissociate()
......@@ -130,7 +125,6 @@ class EmbedsOne extends EmbedsOneOrMany
/**
* Delete all embedded models.
*
* @return int
*/
public function delete()
......@@ -140,7 +134,6 @@ class EmbedsOne extends EmbedsOneOrMany
/**
* Get the name of the "where in" method for eager loading.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param string $key
* @return string
......
......@@ -4,36 +4,32 @@ namespace Jenssegers\Mongodb\Relations;
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
......@@ -94,9 +90,7 @@ abstract class EmbedsOneOrMany extends Relation
/**
* Shorthand to get the results of the relationship.
*
* @param array $columns
*
* @return Collection
*/
public function get($columns = ['*'])
......@@ -106,7 +100,6 @@ abstract class EmbedsOneOrMany extends Relation
/**
* Get the number of embedded models.
*
* @return int
*/
public function count()
......@@ -116,7 +109,6 @@ abstract class EmbedsOneOrMany extends Relation
/**
* Attach a model instance to the parent model.
*
* @param Model $model
* @return Model|bool
*/
......@@ -129,7 +121,6 @@ abstract class EmbedsOneOrMany extends Relation
/**
* Attach a collection of models to the parent instance.
*
* @param Collection|array $models
* @return Collection|array
*/
......@@ -144,7 +135,6 @@ abstract class EmbedsOneOrMany extends Relation
/**
* Create a new instance of the related model.
*
* @param array $attributes
* @return Model
*/
......@@ -164,7 +154,6 @@ abstract class EmbedsOneOrMany extends Relation
/**
* Create an array of new instances of the related model.
*
* @param array $records
* @return array
*/
......@@ -181,7 +170,6 @@ abstract class EmbedsOneOrMany extends Relation
/**
* Transform single ID, single Model or array of Models into an array of IDs.
*
* @param mixed $ids
* @return array
*/
......@@ -236,7 +224,6 @@ abstract class EmbedsOneOrMany extends Relation
/**
* Get the foreign key value for the relation.
*
* @param mixed $id
* @return mixed
*/
......@@ -252,7 +239,6 @@ abstract class EmbedsOneOrMany extends Relation
/**
* Convert an array of records to a Collection.
*
* @param array $records
* @return Collection
*/
......@@ -273,7 +259,6 @@ abstract class EmbedsOneOrMany extends Relation
/**
* Create a related model instanced.
*
* @param array $attributes
* @return Model
*/
......@@ -302,7 +287,6 @@ abstract class EmbedsOneOrMany extends Relation
/**
* Get the relation instance of the parent.
*
* @return Relation
*/
protected function getParentRelation()
......@@ -332,7 +316,6 @@ abstract class EmbedsOneOrMany extends Relation
/**
* Check if this relation is nested in another relation.
*
* @return bool
*/
protected function isNested()
......@@ -342,7 +325,6 @@ abstract class EmbedsOneOrMany extends Relation
/**
* Get the fully qualified local key name.
*
* @param string $glue
* @return string
*/
......@@ -369,7 +351,6 @@ abstract class EmbedsOneOrMany extends Relation
/**
* Get the primary key value of the parent.
*
* @return string
*/
protected function getParentKey()
......@@ -379,7 +360,6 @@ abstract class EmbedsOneOrMany extends Relation
/**
* Return update values
*
* @param $array
* @param string $prepend
* @return array
......@@ -389,7 +369,7 @@ abstract class EmbedsOneOrMany extends Relation
$results = [];
foreach ($array as $key => $value) {
$results[$prepend.$key] = $value;
$results[$prepend . $key] = $value;
}
return $results;
......@@ -397,7 +377,6 @@ abstract class EmbedsOneOrMany extends Relation
/**
* Get the foreign key for the relationship.
*
* @return string
*/
public function getQualifiedForeignKeyName()
......@@ -407,7 +386,6 @@ abstract class EmbedsOneOrMany extends Relation
/**
* Get the name of the "where in" method for eager loading.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param string $key
* @return string
......
......@@ -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 @@ class HasMany extends EloquentHasMany
/**
* Get the plain foreign key.
*
* @return string
*/
public function getPlainForeignKey()
......@@ -30,7 +28,6 @@ class HasMany extends EloquentHasMany
/**
* Get the key for comparing against the parent key in "has" query.
*
* @return string
*/
public function getHasCompareKey()
......@@ -50,7 +47,6 @@ class HasMany extends EloquentHasMany
/**
* Add the constraints for a relationship count query.
*
* @param Builder $query
* @param Builder $parent
* @return Builder
......@@ -64,7 +60,6 @@ class HasMany extends EloquentHasMany
/**
* Add the constraints for a relationship query.
*
* @param Builder $query
* @param Builder $parent
* @param array|mixed $columns
......@@ -81,7 +76,6 @@ class HasMany extends EloquentHasMany
/**
* Get the name of the "where in" method for eager loading.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param string $key
* @return string
......
......@@ -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 @@ class HasOne extends EloquentHasOne
/**
* Get the key for comparing against the parent key in "has" query.
*
* @return string
*/
public function getHasCompareKey()
......@@ -30,7 +28,6 @@ class HasOne extends EloquentHasOne
/**
* Get the plain foreign key.
*
* @return string
*/
public function getPlainForeignKey()
......@@ -50,7 +47,6 @@ class HasOne extends EloquentHasOne
/**
* Add the constraints for a relationship count query.
*
* @param Builder $query
* @param Builder $parent
* @return Builder
......@@ -64,7 +60,6 @@ class HasOne extends EloquentHasOne
/**
* Add the constraints for a relationship query.
*
* @param Builder $query
* @param Builder $parent
* @param array|mixed $columns
......@@ -81,7 +76,6 @@ class HasOne extends EloquentHasOne
/**
* Get the name of the "where in" method for eager loading.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param string $key
* @return string
......
......@@ -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 @@ class MorphTo extends EloquentMorphTo
/**
* Get the owner key with backwards compatible support.
*
* @return string
*/
public function getOwnerKey()
......@@ -46,7 +45,6 @@ class MorphTo extends EloquentMorphTo
/**
* Get the name of the "where in" method for eager loading.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param string $key
* @return string
......
......@@ -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,7 +109,6 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint
/**
* Specify a non blocking index for the collection.
*
* @param string|array $columns
* @return Blueprint
*/
......@@ -127,7 +123,6 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint
/**
* Specify a sparse index for the collection.
*
* @param string|array $columns
* @param array $options
* @return Blueprint
......@@ -145,7 +140,6 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint
/**
* Specify a geospatial index for the collection.
*
* @param string|array $columns
* @param string $index
* @param array $options
......@@ -171,7 +165,6 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint
/**
* 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
* @return Blueprint
......@@ -218,7 +211,6 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint
/**
* Specify a sparse and unique index for the collection.
*
* @param string|array $columns
* @param array $options
* @return Blueprint
......@@ -237,7 +229,6 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint
/**
* Allow fluent columns.
*
* @param string|array $columns
* @return string|array
*/
......@@ -254,7 +245,6 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint
/**
* Allows the use of unsupported schema methods.
*
* @param $method
* @param $args
* @return Blueprint
......
......@@ -33,7 +33,6 @@ class Builder extends \Illuminate\Database\Schema\Builder
/**
* Determine if the given collection exists.
*
* @param string $collection
* @return bool
*/
......@@ -60,7 +59,6 @@ class Builder extends \Illuminate\Database\Schema\Builder
/**
* Modify a collection on the schema.
*
* @param string $collection
* @param Closure $callback
* @return bool
......@@ -138,7 +136,6 @@ class Builder extends \Illuminate\Database\Schema\Builder
/**
* Get all of the collections names for the database.
*
* @return array
*/
protected function getAllCollections()
......
......@@ -6,7 +6,6 @@ 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
......@@ -32,7 +31,6 @@ class DatabasePresenceVerifier extends \Illuminate\Validation\DatabasePresenceVe
/**
* Count the number of objects in a collection with the given values.
*
* @param string $collection
* @param string $column
* @param array $values
......
......@@ -2,6 +2,7 @@
use Illuminate\Auth\Passwords\PasswordBroker;
use Illuminate\Foundation\Application;
use MongoDB\BSON\UTCDateTime;
class AuthTest extends TestCase
{
......@@ -49,7 +50,7 @@ class AuthTest extends TestCase
$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',
......
<?php
declare(strict_types=1);
use Jenssegers\Mongodb\Connection;
use Jenssegers\Mongodb\Collection;
use MongoDB\Collection as MongoCollection;
use Jenssegers\Mongodb\Connection;
use MongoDB\BSON\ObjectID;
use MongoDB\Collection as MongoCollection;
class CollectionTest extends TestCase
{
......
This diff is collapsed.
......@@ -54,7 +54,8 @@ class GeospatialTest extends TestCase
$locations = Location::where('location', 'geoWithin', [
'$geometry' => [
'type' => 'Polygon',
'coordinates' => [[
'coordinates' => [
[
[
-0.1450383,
51.5069158,
......@@ -75,7 +76,8 @@ class GeospatialTest extends TestCase
-0.1450383,
51.5069158,
],
]],
],
],
],
]);
......@@ -105,7 +107,7 @@ class GeospatialTest extends TestCase
51.5078646,
],
],
]
],
]);
$this->assertEquals(1, $locations->count());
......
<?php
declare(strict_types=1);
use Illuminate\Database\MySqlConnection;
class HybridRelationsTest extends TestCase
{
public function setUp(): void
......@@ -22,8 +24,8 @@ class HybridRelationsTest extends TestCase
public function testMysqlRelations()
{
$user = new MysqlUser;
$this->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 @@ class HybridRelationsTest extends TestCase
{
$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 @@ class HybridRelationsTest extends TestCase
{
$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";
......
......@@ -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 @@ class QueryBuilderTest extends TestCase
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 @@ class QueryBuilderTest extends TestCase
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()
......@@ -222,14 +226,14 @@ class QueryBuilderTest extends TestCase
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);
......@@ -274,12 +278,20 @@ class QueryBuilderTest extends TestCase
$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']);
}
......@@ -459,7 +471,14 @@ class QueryBuilderTest extends TestCase
{
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' => []],
]);
......@@ -531,7 +550,9 @@ class QueryBuilderTest extends TestCase
['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();
......@@ -707,11 +728,12 @@ class QueryBuilderTest extends TestCase
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'));
}
......
<?php
declare(strict_types=1);
use Illuminate\Database\Eloquent\Collection;
class RelationsTest extends TestCase
{
public function tearDown(): void
......@@ -90,7 +92,7 @@ class RelationsTest extends TestCase
$items = Item::with('user')->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 @@ class RelationsTest extends TestCase
$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 @@ class RelationsTest extends TestCase
$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 @@ class RelationsTest extends TestCase
$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 @@ class RelationsTest extends TestCase
$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 @@ class RelationsTest extends TestCase
$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 @@ class RelationsTest extends TestCase
$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 @@ class RelationsTest extends TestCase
$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
......
<?php
declare(strict_types=1);
use Jenssegers\Mongodb\Schema\Blueprint;
class SchemaTest extends TestCase
{
public function tearDown(): void
......@@ -21,7 +23,7 @@ class SchemaTest extends TestCase
$instance = $this;
Schema::create('newcollection', function ($collection) use ($instance) {
$instance->assertInstanceOf('Jenssegers\Mongodb\Schema\Blueprint', $collection);
$instance->assertInstanceOf(Blueprint::class, $collection);
});
$this->assertTrue(Schema::hasCollection('newcollection'));
......@@ -46,11 +48,11 @@ class SchemaTest extends TestCase
$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);
});
}
......
......@@ -7,9 +7,7 @@ class TestCase extends Orchestra\Testbench\TestCase
{
/**
* Get application providers.
*
* @param \Illuminate\Foundation\Application $app
*
* @return array
*/
protected function getApplicationProviders($app)
......@@ -23,7 +21,6 @@ class TestCase extends Orchestra\Testbench\TestCase
/**
* Get package providers.
*
* @param \Illuminate\Foundation\Application $app
* @return array
*/
......@@ -32,13 +29,12 @@ class TestCase extends Orchestra\Testbench\TestCase
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
* @return void
*/
......
......@@ -6,7 +6,6 @@ use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
/**
* Class Book
*
* @property string $title
* @property string $author
* @property array $chapters
......
......@@ -7,7 +7,6 @@ use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
/**
* Class Item
*
* @property \Carbon\Carbon $created_at
*/
class Item extends Eloquent
......
<?php
declare(strict_types=1);
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
use Jenssegers\Mongodb\Eloquent\Builder;
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
class Scoped extends Eloquent
{
......
......@@ -6,7 +6,6 @@ use Jenssegers\Mongodb\Eloquent\SoftDeletes;
/**
* Class Soft
*
* @property \Carbon\Carbon $deleted_at
*/
class Soft extends Eloquent
......
<?php
declare(strict_types=1);
use Illuminate\Notifications\Notifiable;
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
use Jenssegers\Mongodb\Eloquent\HybridRelations;
use Illuminate\Auth\Authenticatable;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
use Illuminate\Notifications\Notifiable;
use Jenssegers\Mongodb\Eloquent\HybridRelations;
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
/**
* Class User
*
* @property string $_id
* @property string $name
* @property string $title
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment