Skip to content

Fix Docblocks in Model class and Embed Relationship classes #568

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 28, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 20 additions & 15 deletions src/Jenssegers/Mongodb/Model.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<?php namespace Jenssegers\Mongodb;

use Carbon\Carbon;
use DateTime;
use MongoId;
use MongoDate;
use Carbon\Carbon;
use ReflectionMethod;
use MongoId;
use Illuminate\Database\Eloquent\Relations\Relation;
use Jenssegers\Mongodb\Eloquent\Builder;
use Jenssegers\Mongodb\Relations\EmbedsOneOrMany;
use Jenssegers\Mongodb\Relations\EmbedsMany;
use Jenssegers\Mongodb\Relations\EmbedsOne;
use Jenssegers\Mongodb\Relations\EmbedsOneOrMany;
use ReflectionMethod;

abstract class Model extends \Jenssegers\Eloquent\Model {

Expand Down Expand Up @@ -37,8 +37,7 @@ abstract class Model extends \Jenssegers\Eloquent\Model {
/**
* Custom accessor for the model's id.
*
* @param mixed $value
*
* @param mixed $value
* @return mixed
*/
public function getIdAttribute($value)
Expand Down Expand Up @@ -73,8 +72,10 @@ public function getQualifiedKeyName()
* Define an embedded one-to-many relationship.
*
* @param string $related
* @param string $collection
* @return \Illuminate\Database\Eloquent\Relations\EmbedsMany
* @param string $localKey
* @param string $foreignKey
* @param string $relation
* @return EmbedsMany
*/
protected function embedsMany($related, $localKey = null, $foreignKey = null, $relation = null)
{
Expand Down Expand Up @@ -109,8 +110,10 @@ protected function embedsMany($related, $localKey = null, $foreignKey = null, $r
* Define an embedded one-to-many relationship.
*
* @param string $related
* @param string $collection
* @return \Illuminate\Database\Eloquent\Relations\EmbedsMany
* @param string $localKey
* @param string $foreignKey
* @param string $relation
* @return \Jenssegers\Mongodb\Relations\EmbedsOne
*/
protected function embedsOne($related, $localKey = null, $foreignKey = null, $relation = null)
{
Expand Down Expand Up @@ -311,7 +314,7 @@ public function setAttribute($key, $value)

array_set($this->attributes, $key, $value);

return;
return;
}

parent::setAttribute($key, $value);
Expand Down Expand Up @@ -353,7 +356,7 @@ public function attributesToArray()
/**
* Remove one or more fields.
*
* @param mixed $columns
* @param mixed $columns
* @return int
*/
public function drop($columns)
Expand Down Expand Up @@ -406,6 +409,8 @@ public function push()
/**
* Remove one or more values from an array.
*
* @param string $column
* @param mixed $values
* @return mixed
*/
public function pull($column, $values)
Expand Down Expand Up @@ -446,7 +451,7 @@ protected function pushAttributeValues($column, array $values, $unique = false)
}

/**
* Rempove one or more values to the underlying attribute value and sync with original.
* Remove one or more values to the underlying attribute value and sync with original.
*
* @param string $column
* @param array $values
Expand Down Expand Up @@ -474,7 +479,7 @@ protected function pullAttributeValues($column, array $values)
/**
* Set the parent relation.
*
* @param Relation $relation
* @param \Illuminate\Database\Eloquent\Relations\Relation $relation
*/
public function setParentRelation(Relation $relation)
{
Expand All @@ -484,7 +489,7 @@ public function setParentRelation(Relation $relation)
/**
* Get the parent relation.
*
* @return Relation
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function getParentRelation()
{
Expand Down
19 changes: 9 additions & 10 deletions src/Jenssegers/Mongodb/Relations/EmbedsMany.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<?php namespace Jenssegers\Mongodb\Relations;

use MongoId;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Pagination\Paginator;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Pagination\Paginator;
use MongoId;

class EmbedsMany extends EmbedsOneOrMany {

/**
* Get the results of the relationship.
*
* @return Jenssegers\Mongodb\Eloquent\Collection
* @return \Jenssegers\Mongodb\Eloquent\Collection
*/
public function getResults()
{
Expand All @@ -20,10 +20,10 @@ public function getResults()
/**
* Save a new model and attach it to the parent model.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param \Illuminate\Database\Eloquent\Model $model
* @return \Illuminate\Database\Eloquent\Model
*/
public function performInsert(Model $model, array $values)
public function performInsert(Model $model)
{
// Generate a new key if needed.
if ($model->getKeyName() == '_id' and ! $model->getKey())
Expand Down Expand Up @@ -54,7 +54,7 @@ public function performInsert(Model $model, array $values)
* @param \Illuminate\Database\Eloquent\Model $model
* @return Model|bool
*/
public function performUpdate(Model $model, array $values)
public function performUpdate(Model $model)
{
// For deeply nested documents, let the parent handle the changes.
if ($this->isNested())
Expand Down Expand Up @@ -269,11 +269,10 @@ protected function associateExisting($model)
/**
* Get a paginator for the "select" statement.
*
* @param int $perPage
* @param array $columns
* @param int $perPage
* @return \Illuminate\Pagination\Paginator
*/
public function paginate($perPage = null, $columns = array('*'))
public function paginate($perPage = null)
{
$page = Paginator::resolveCurrentPage();
$perPage = $perPage ?: $this->related->getPerPage();
Expand Down Expand Up @@ -303,7 +302,7 @@ protected function getEmbedded()
/**
* Set the embedded records array.
*
* @param array $models
* @param array $models
* @return void
*/
protected function setEmbedded($models)
Expand Down
10 changes: 5 additions & 5 deletions src/Jenssegers/Mongodb/Relations/EmbedsOne.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php namespace Jenssegers\Mongodb\Relations;

use MongoId;
use Illuminate\Database\Eloquent\Model;
use MongoId;

class EmbedsOne extends EmbedsOneOrMany {

Expand All @@ -21,7 +21,7 @@ public function getResults()
* @param \Illuminate\Database\Eloquent\Model $model
* @return \Illuminate\Database\Eloquent\Model
*/
public function performInsert(Model $model, array $values)
public function performInsert(Model $model)
{
// Generate a new key if needed.
if ($model->getKeyName() == '_id' and ! $model->getKey())
Expand Down Expand Up @@ -49,9 +49,9 @@ public function performInsert(Model $model, array $values)
* Save an existing model and attach it to the parent model.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @return Model|bool
* @return \Illuminate\Database\Eloquent\Model|bool
*/
public function performUpdate(Model $model, array $values)
public function performUpdate(Model $model)
{
if ($this->isNested())
{
Expand All @@ -74,7 +74,7 @@ public function performUpdate(Model $model, array $values)
/**
* Delete an existing model and detach it from the parent model.
*
* @param Model $model
* @param \Illuminate\Database\Eloquent\Model $model
* @return int
*/
public function performDelete(Model $model)
Expand Down
18 changes: 9 additions & 9 deletions src/Jenssegers/Mongodb/Relations/EmbedsOneOrMany.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<?php namespace Jenssegers\Mongodb\Relations;

use MongoId;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Database\Eloquent\Collection as BaseCollection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\Relation;
use Jenssegers\Mongodb\Eloquent\Collection;

abstract class EmbedsOneOrMany extends Relation {
Expand Down Expand Up @@ -35,10 +34,10 @@ abstract class EmbedsOneOrMany extends Relation {
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param \Illuminate\Database\Eloquent\Model $parent
* @param \Illuminate\Database\Eloquent\Model $related
* @param string $localKey
* @param string $foreignKey
* @param string $relation
* @return void
*/
public function __construct(Builder $query, Model $parent, Model $related, $localKey, $foreignKey, $relation)
{
Expand Down Expand Up @@ -126,7 +125,7 @@ public function match(array $models, BaseCollection $results, $relation)
/**
* Shorthand to get the results of the relationship.
*
* @return Jenssegers\Mongodb\Eloquent\Collection
* @return \Jenssegers\Mongodb\Eloquent\Collection
*/
public function get()
{
Expand Down Expand Up @@ -241,7 +240,7 @@ protected function getEmbedded()
/**
* Set the embedded records array.
*
* @param array $records
* @param array $records
* @return \Illuminate\Database\Eloquent\Model
*/
protected function setEmbedded($records)
Expand All @@ -260,7 +259,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)
Expand All @@ -278,7 +277,7 @@ protected function getForeignKeyValue($id)
* Convert an array of records to a Collection.
*
* @param array $records
* @return Jenssegers\Mongodb\Eloquent\Collection
* @return \Jenssegers\Mongodb\Eloquent\Collection
*/
protected function toCollection(array $records = array())
{
Expand Down Expand Up @@ -322,7 +321,7 @@ protected function toModel($attributes = array())
/**
* Get the relation instance of the parent.
*
* @return Illuminate\Database\Eloquent\Relations\Relation
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
protected function getParentRelation()
{
Expand Down Expand Up @@ -366,6 +365,7 @@ protected function isNested()
/**
* Get the fully qualified local key name.
*
* @param string $glue
* @return string
*/
protected function getPathHierarchy($glue = '.')
Expand Down