Skip to content
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

chore: bump packages #171

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
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
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
],
"require": {
"php": "^8.0",
"leroy-merlin-br/mongolid": "v3.7",
"leroy-merlin-br/mongolid": "chore/bump-packages-fix-dev",
"illuminate/support": "^9.0 || ^10.0",
"illuminate/auth": "^9.0 || ^10.0",
"illuminate/queue": "^9.0 || ^10.0"
Expand All @@ -34,7 +34,8 @@
"phpunit/phpunit": "^9.0",
"orchestra/testbench": "^7.0 || ^8.0",
"mockery/mockery": "^1.5.1",
"leroy-merlin-br/coding-standard": "^3.1.0"
"leroy-merlin-br/coding-standard": "^3.1.0",
"ext-mongodb": "*"
},
"autoload": {
"psr-4": {
Expand Down
2,575 changes: 1,059 additions & 1,516 deletions composer.lock

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3'

services:
php:
build: docker
Expand Down
8 changes: 3 additions & 5 deletions src/LaravelCacheComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@ class LaravelCacheComponent implements CacheComponentInterface

/**
* Copy cache result in memory array.
*
* @var mixed[]
*/
private $inMemoryCache = [];
private array $inMemoryCache = [];

/**
* Injects the dependencies of LaravelCacheComponent.
Expand All @@ -42,7 +40,7 @@ public function __construct(Repository $laravelCache)
*
* @return mixed
*/
public function get(string $key)
public function get(string $key): mixed
{
if (isset($this->inMemoryCache[$key])) {
return $this->inMemoryCache[$key];
Expand All @@ -61,7 +59,7 @@ public function get(string $key)
* @param mixed $value value being stored in cache
* @param float $minutes cache ttl
*/
public function put(string $key, $value, float $minutes)
public function put(string $key, $value, float $minutes): void
{
if (is_array($value)) {
foreach ($value as $index => $document) {
Expand Down
9 changes: 4 additions & 5 deletions src/LaravelEventTrigger.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ class LaravelEventTrigger implements EventTriggerInterface
{
/**
* Laravel's Event dispatcher.
*
* @var \Illuminate\Contracts\Events\Dispatcher
*/
protected $dispatcher;
protected Dispatcher $dispatcher;

/**
* Injects a Laravel's event dispatcher instance.
Expand All @@ -39,12 +37,13 @@ public function __construct(Dispatcher $dispatcher)
*
* @return mixed Event handler return. The importance of this return is determined by $halt
*/
public function fire(string $event, $payload, bool $halt)
public function fire(string $event, mixed $payload, bool $halt): mixed
{
if (method_exists($this->dispatcher, 'fire')) {
return $this->dispatcher->fire($event, $payload, $halt);
}
$this->dispatcher->dispatch($event, $payload, $halt);

return $this->dispatcher->dispatch($event, $payload, $halt);
return true;
}
}
2 changes: 1 addition & 1 deletion src/LegacyMongolidModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public static function firstOrFail(
$query = [],
array $projection = [],
bool $useCache = false
) {
): mixed {
return static::callMockOrParent('firstOrFail', func_get_args());
}

Expand Down
19 changes: 10 additions & 9 deletions src/MongolidModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@
use Mongolid\Cursor\CursorInterface;
use Mongolid\LegacyRecord;
use Mongolid\Model\AbstractModel;
use stdClass;

/**
* This class extends the Mongolid\LegacyRecord, so, in order
* to understand the ODM implementation make sure to check the
* base class.
*
* The MongolidLaravel\MongolidModel simply extends the original
* and framework agnostic model of MongoLid and implements some
* and framework-agnostic model of MongoLid and implements some
* validation rules using Laravel validation components.
*
* Remember, this package is meant to be used with Laravel while
Expand Down Expand Up @@ -124,7 +125,7 @@ public function isValid()
$attributes = $this->getDocumentAttributes();

// Verify attributes that are hashed and that have not changed
// those doesn't need to be validated.
// this doesn't need to be validated.
foreach ($this->hashedAttributes as $hashedAttr) {
if (isset($this->original[$hashedAttr]) && $this->$hashedAttr == $this->original[$hashedAttr]) {
unset($rules[$hashedAttr]);
Expand Down Expand Up @@ -181,7 +182,7 @@ public function messages(): array
*
* @return Expectation
*/
public function shouldReceiveSave()
public function shouldReceiveSave(): Expectation
{
return $this->localMockShouldReceive('save');
}
Expand All @@ -191,7 +192,7 @@ public function shouldReceiveSave()
*
* @return Expectation
*/
public function shouldReceiveDelete()
public function shouldReceiveDelete(): Expectation
{
return $this->localMockShouldReceive('delete');
}
Expand All @@ -209,7 +210,7 @@ public static function first(
$query = [],
array $projection = [],
bool $useCache = false
) {
): stdClass|static|null {
return static::callMockOrParent('first', func_get_args());
}

Expand All @@ -229,7 +230,7 @@ public static function firstOrFail(
$query = [],
array $projection = [],
bool $useCache = false
) {
): stdClass|static|null {
return static::callMockOrParent('firstOrFail', func_get_args());
}

Expand All @@ -242,7 +243,7 @@ public static function firstOrFail(
*
* @return LegacyRecord
*/
public static function firstOrNew($id)
public static function firstOrNew(mixed $id): stdClass|static|null
{
return static::callMockOrParent('firstOrNew', func_get_args());
}
Expand Down Expand Up @@ -283,7 +284,7 @@ protected function collection(): Collection
* Hashes the attributes specified in the hashedAttributes
* array.
*/
protected function hashAttributes()
protected function hashAttributes(): void
{
foreach ($this->hashedAttributes as $attr) {
// Hash attribute if changed
Expand Down Expand Up @@ -334,7 +335,7 @@ protected function localMockShouldReceive(string $method)
}

/**
* Check for a expectation for given method on local mock.
* Check for an expectation for given method on local mock.
*
* @param string $method name of the method being checked
*/
Expand Down
26 changes: 13 additions & 13 deletions tests/MongolidModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public function testShouldSave()
$dataMapper = $this->instance(Builder::class, m::mock(Builder::class));

$model = new class () extends MongolidModel {
protected $collection = 'users';
protected ?string $collection = 'users';
};

// Expectations
Expand Down Expand Up @@ -185,7 +185,7 @@ public function testShouldHashAttributesOnSaveAndUpdate($method)
$hasher = $this->instance(Hasher::class, m::mock(Hasher::class));

$model = new class () extends MongolidModel {
protected $collection = 'users';
protected ?string $collection = 'users';

protected $hashedAttributes = ['password'];
};
Expand Down Expand Up @@ -280,7 +280,7 @@ public function testShouldDelete()
$dataMapper = $this->instance(Builder::class, m::mock(Builder::class));

$model = new class () extends MongolidModel {
protected $collection = 'collection_name';
protected ?string $collection = 'collection_name';
};

// Expectations
Expand Down Expand Up @@ -323,7 +323,7 @@ public function testShouldGetFirst()
$dataMapper = $this->instance(Builder::class, m::mock(Builder::class));

$model = new class () extends MongolidModel {
protected $collection = 'collection_name';
protected ?string $collection = 'collection_name';
};

// Expectations
Expand All @@ -345,7 +345,7 @@ public function testShouldMockFirst()
{
// Set
$model = new class () extends MongolidModel {
protected $collection = 'collection_name';
protected ?string $collection = 'collection_name';
};

// Expectations
Expand All @@ -367,7 +367,7 @@ public function testShouldGetFirstOrNew()
$dataMapper = $this->instance(Builder::class, m::mock(Builder::class));

$model = new class () extends MongolidModel {
protected $collection = 'collection_name';
protected ?string $collection = 'collection_name';
};

// Expectations
Expand All @@ -389,7 +389,7 @@ public function testShouldMockFirstOrNew()
{
// Set
$model = new class () extends MongolidModel {
protected $collection = 'collection_name';
protected ?string $collection = 'collection_name';
};

// Expectations
Expand All @@ -411,7 +411,7 @@ public function testShouldGetFirstOrFailAndFoundIt()
$dataMapper = $this->instance(Builder::class, m::mock(Builder::class));

$model = new class () extends MongolidModel {
protected $collection = 'collection_name';
protected ?string $collection = 'collection_name';
};

// Expectations
Expand All @@ -435,7 +435,7 @@ public function testShouldGetFirstOrFailAndFail()
$dataMapper = $this->instance(Builder::class, m::mock(Builder::class));

$model = new class () extends MongolidModel {
protected $collection = 'collection_name';
protected ?string $collection = 'collection_name';
};

// Expectations
Expand All @@ -456,7 +456,7 @@ public function testShouldMockFirstOrFail()
{
// Set
$model = new class () extends MongolidModel {
protected $collection = 'collection_name';
protected ?string $collection = 'collection_name';
};

// Expectations
Expand All @@ -479,7 +479,7 @@ public function testShouldGetWhere()
$cursor = m::mock(CursorInterface::class);

$model = new class () extends MongolidModel {
protected $collection = 'collection_name';
protected ?string $collection = 'collection_name';
};

// Expectations
Expand All @@ -504,7 +504,7 @@ public function testShouldGetAll()
$cursor = m::mock(CursorInterface::class);

$model = new class () extends MongolidModel {
protected $collection = 'collection_name';
protected ?string $collection = 'collection_name';
};

// Expectations
Expand Down Expand Up @@ -547,7 +547,7 @@ public function testShouldGetCollection()
$client = m::mock(Client::class);

$model = new class () extends MongolidModel {
protected $collection = 'collection_name';
protected ?string $collection = 'collection_name';

public function rawCollection()
{
Expand Down
6 changes: 4 additions & 2 deletions tests/MongolidUserProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Illuminate\Foundation\Auth\User;
use Mockery as m;
use MongoDB\BSON\ObjectID;
use stdClass;

class MongolidUserProviderTest extends TestCase
{
Expand Down Expand Up @@ -78,7 +79,8 @@ public static function first(
$query = [],
array $projection = [],
bool $useCache = false
) {
): stdClass|static|null {
return null;
}
};

Expand Down Expand Up @@ -121,7 +123,7 @@ public static function first(
$query = [],
array $projection = [],
bool $useCache = false
) {
): stdClass|static|null {
return m::mock(MongolidModel::class);
}
};
Expand Down
2 changes: 1 addition & 1 deletion tests/Stubs/LegacyMongolidModelStub.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class LegacyMongolidModelStub extends LegacyMongolidModel
/**
* @var ?string
*/
protected $collection = 'collection_name';
protected ?string $collection = 'collection_name';

/**
* @var string[]
Expand Down
Loading