Skip to content
This repository has been archived by the owner on Aug 22, 2023. It is now read-only.

Commit

Permalink
Add header documentation for classes & traits that can be used in app…
Browse files Browse the repository at this point in the history
…lications (#12)

* Add header documentation for classes & traits that can be used in applications
* Precise mixed types when possible
  • Loading branch information
GromNaN committed Jul 13, 2023
1 parent 78319d4 commit bd86f85
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 8 deletions.
3 changes: 3 additions & 0 deletions src/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
use MongoDB\BSON\ObjectID;
use MongoDB\Collection as MongoCollection;

/**
* @mixin MongoCollection
*/
class Collection
{
/**
Expand Down
3 changes: 3 additions & 0 deletions src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
use MongoDB\Database;
use Throwable;

/**
* @mixin Database
*/
class Connection extends BaseConnection
{
use ManagesTransactions;
Expand Down
2 changes: 1 addition & 1 deletion src/Eloquent/Casts/BinaryUuid.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function get($model, string $key, $value, array $attributes)
* @param string $key
* @param mixed $value
* @param array $attributes
* @return mixed
* @return Binary
*/
public function set($model, string $key, $value, array $attributes)
{
Expand Down
3 changes: 3 additions & 0 deletions src/Eloquent/EmbedsRelations.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
use Jenssegers\Mongodb\Relations\EmbedsMany;
use Jenssegers\Mongodb\Relations\EmbedsOne;

/**
* Embeds relations for MongoDB models.
*/
trait EmbedsRelations
{
/**
Expand Down
4 changes: 4 additions & 0 deletions src/Eloquent/HybridRelations.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
use Jenssegers\Mongodb\Relations\MorphMany;
use Jenssegers\Mongodb\Relations\MorphTo;

/**
* Cross-database relationships between SQL and MongoDB.
* Use this trait in SQL models to define relationships with MongoDB models.
*/
trait HybridRelations
{
/**
Expand Down
14 changes: 7 additions & 7 deletions src/Query/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -788,9 +788,9 @@ public function raw($expression = null)
/**
* Append one or more values to an array.
*
* @param mixed $column
* @param mixed $value
* @param bool $unique
* @param string|array $column
* @param mixed $value
* @param bool $unique
* @return int
*/
public function push($column, $value = null, $unique = false)
Expand Down Expand Up @@ -818,14 +818,14 @@ public function push($column, $value = null, $unique = false)
/**
* Remove one or more values from an array.
*
* @param mixed $column
* @param mixed $value
* @param string|array $column
* @param mixed $value
* @return int
*/
public function pull($column, $value = null)
{
// Check if we passed an associative array.
$batch = (is_array($value) && array_keys($value) === range(0, count($value) - 1));
$batch = is_array($value) && array_is_list($value);

// If we are pulling multiple values, we need to use $pullAll.
$operator = $batch ? '$pullAll' : '$pull';
Expand All @@ -842,7 +842,7 @@ public function pull($column, $value = null)
/**
* Remove one or more fields.
*
* @param mixed $columns
* @param string|string[] $columns
* @return int
*/
public function drop($columns)
Expand Down

0 comments on commit bd86f85

Please sign in to comment.