Skip to content

Commit 526d12d

Browse files
authored
Rename imported interfaces aliases suffixes from *Contract to *Interface (#178)
Rename imported interfaces aliases suffixes from *Contract to *Interface
1 parent 6334529 commit 526d12d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+311
-303
lines changed

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to `laravel-love` will be documented in this file.
44

55
## [Unreleased]
66

7+
## [8.6.1] - 2020-10-04
8+
9+
### Changed
10+
11+
- ([#178]) Rename imported interfaces aliases
12+
713
## [8.6.0] - 2020-10-02
814

915
### Added
@@ -450,7 +456,8 @@ Follow [upgrade instructions](UPGRADING.md#from-v5-to-v6) to migrate database to
450456

451457
- Initial release
452458

453-
[Unreleased]: https://github.com/cybercog/laravel-love/compare/8.6.0...master
459+
[Unreleased]: https://github.com/cybercog/laravel-love/compare/8.6.1...master
460+
[8.6.1]: https://github.com/cybercog/laravel-love/compare/8.6.0...8.6.1
454461
[8.6.0]: https://github.com/cybercog/laravel-love/compare/8.5.0...8.6.0
455462
[8.5.0]: https://github.com/cybercog/laravel-love/compare/8.4.0...8.5.0
456463
[8.4.0]: https://github.com/cybercog/laravel-love/compare/8.3.1...8.4.0
@@ -493,6 +500,7 @@ Follow [upgrade instructions](UPGRADING.md#from-v5-to-v6) to migrate database to
493500
[1.1.1]: https://github.com/cybercog/laravel-love/compare/1.1.0...1.1.1
494501
[1.1.0]: https://github.com/cybercog/laravel-love/compare/1.0.0...1.1.0
495502

503+
[#178]: https://github.com/cybercog/laravel-love/pull/178
496504
[#177]: https://github.com/cybercog/laravel-love/pull/177
497505
[#176]: https://github.com/cybercog/laravel-love/pull/176
498506
[#165]: https://github.com/cybercog/laravel-love/pull/165

contracts/Reactable/Exceptions/ReactableInvalid.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
namespace Cog\Contracts\Love\Reactable\Exceptions;
1515

1616
use Cog\Contracts\Love\Exceptions\LoveThrowable;
17-
use Cog\Contracts\Love\Reactable\Models\Reactable as ReactableContract;
17+
use Cog\Contracts\Love\Reactable\Models\Reactable;
1818
use RuntimeException;
1919

2020
final class ReactableInvalid extends RuntimeException implements
@@ -32,7 +32,7 @@ public static function notImplementInterface(string $type): self
3232
{
3333
return new self(sprintf(
3434
'[%s] must implement `%s` contract.',
35-
$type, ReactableContract::class
35+
$type, Reactable::class
3636
));
3737
}
3838
}

contracts/Reacterable/Exceptions/ReacterableInvalid.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
namespace Cog\Contracts\Love\Reacterable\Exceptions;
1515

1616
use Cog\Contracts\Love\Exceptions\LoveThrowable;
17-
use Cog\Contracts\Love\Reacterable\Models\Reacterable as ReacterableContract;
17+
use Cog\Contracts\Love\Reacterable\Models\Reacterable;
1818
use RuntimeException;
1919

2020
final class ReacterableInvalid extends RuntimeException implements
@@ -32,7 +32,7 @@ public static function notImplementInterface(string $type): self
3232
{
3333
return new self(sprintf(
3434
'[%s] must implement `%s` contract.',
35-
$type, ReacterableContract::class
35+
$type, Reacterable::class
3636
));
3737
}
3838
}

src/Console/Commands/Recount.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
namespace Cog\Laravel\Love\Console\Commands;
1515

1616
use Cog\Contracts\Love\Reactable\Exceptions\ReactableInvalid;
17-
use Cog\Contracts\Love\Reactable\Models\Reactable as ReactableContract;
17+
use Cog\Contracts\Love\Reactable\Models\Reactable as ReactableInterface;
1818
use Cog\Laravel\Love\Reactant\Jobs\RebuildReactionAggregatesJob;
1919
use Cog\Laravel\Love\Reactant\Models\Reactant;
2020
use Cog\Laravel\Love\ReactionType\Models\ReactionType;
2121
use Illuminate\Console\Command;
22-
use Illuminate\Contracts\Bus\Dispatcher as DispatcherContract;
22+
use Illuminate\Contracts\Bus\Dispatcher as DispatcherInterface;
2323
use Illuminate\Database\Eloquent\Relations\Relation;
2424
use Symfony\Component\Console\Input\InputOption;
2525

@@ -59,7 +59,7 @@ protected function getOptions(
5959
}
6060

6161
public function __construct(
62-
DispatcherContract $dispatcher
62+
DispatcherInterface $dispatcher
6363
) {
6464
parent::__construct();
6565
$this->dispatcher = $dispatcher;
@@ -130,14 +130,14 @@ private function normalizeReactableModelType(
130130
*/
131131
private function reactableModelFromType(
132132
string $modelType
133-
): ReactableContract {
133+
): ReactableInterface {
134134
if (!class_exists($modelType)) {
135135
$modelType = $this->findModelTypeInMorphMap($modelType);
136136
}
137137

138138
$model = new $modelType();
139139

140-
if (!$model instanceof ReactableContract) {
140+
if (!$model instanceof ReactableInterface) {
141141
throw ReactableInvalid::notImplementInterface($modelType);
142142
}
143143

src/Console/Commands/RegisterReactants.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
namespace Cog\Laravel\Love\Console\Commands;
1515

1616
use Cog\Contracts\Love\Reactable\Exceptions\ReactableInvalid;
17-
use Cog\Contracts\Love\Reactable\Models\Reactable as ReactableContract;
17+
use Cog\Contracts\Love\Reactable\Models\Reactable as ReactableInterface;
1818
use Illuminate\Console\Command;
1919
use Illuminate\Database\Eloquent\Collection;
2020
use Illuminate\Database\Eloquent\Relations\Relation;
@@ -94,14 +94,14 @@ public function handle(): int
9494
*/
9595
private function reactableModelFromType(
9696
string $modelType
97-
): ReactableContract {
97+
): ReactableInterface {
9898
if (!class_exists($modelType)) {
9999
$modelType = $this->findModelTypeInMorphMap($modelType);
100100
}
101101

102102
$model = new $modelType();
103103

104-
if (!$model instanceof ReactableContract) {
104+
if (!$model instanceof ReactableInterface) {
105105
throw ReactableInvalid::notImplementInterface($modelType);
106106
}
107107

@@ -149,7 +149,7 @@ private function normalizeIds(array $modelIds): array
149149
* @return Collection
150150
*/
151151
private function collectModels(
152-
ReactableContract $reactableModel,
152+
ReactableInterface $reactableModel,
153153
array $modelIds
154154
): Collection {
155155
$query = $reactableModel

src/Console/Commands/RegisterReacters.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
namespace Cog\Laravel\Love\Console\Commands;
1515

1616
use Cog\Contracts\Love\Reacterable\Exceptions\ReacterableInvalid;
17-
use Cog\Contracts\Love\Reacterable\Models\Reacterable as ReacterableContract;
17+
use Cog\Contracts\Love\Reacterable\Models\Reacterable as ReacterableInterface;
1818
use Illuminate\Console\Command;
1919
use Illuminate\Database\Eloquent\Collection;
2020
use Illuminate\Database\Eloquent\Relations\Relation;
@@ -94,14 +94,14 @@ public function handle(): int
9494
*/
9595
private function reacterableModelFromType(
9696
string $modelType
97-
): ReacterableContract {
97+
): ReacterableInterface {
9898
if (!class_exists($modelType)) {
9999
$modelType = $this->findModelTypeInMorphMap($modelType);
100100
}
101101

102102
$model = new $modelType();
103103

104-
if (!$model instanceof ReacterableContract) {
104+
if (!$model instanceof ReacterableInterface) {
105105
throw ReacterableInvalid::notImplementInterface($modelType);
106106
}
107107

@@ -149,7 +149,7 @@ private function normalizeIds(array $modelIds): array
149149
* @return Collection
150150
*/
151151
private function collectModels(
152-
ReacterableContract $reacterableModel,
152+
ReacterableInterface $reacterableModel,
153153
array $modelIds
154154
): Collection {
155155
$query = $reacterableModel

src/Console/Commands/SetupReactable.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
namespace Cog\Laravel\Love\Console\Commands;
1515

16-
use Cog\Contracts\Love\Reactable\Models\Reactable as ReactableContract;
16+
use Cog\Contracts\Love\Reactable\Models\Reactable as ReactableInterface;
1717
use Cog\Laravel\Love\Reactant\Models\Reactant;
1818
use Cog\Laravel\Love\Support\Database\AddForeignColumnStub;
1919
use Cog\Laravel\Love\Support\Database\MigrationCreator;
@@ -170,7 +170,7 @@ private function sanitizeName(string $name): string
170170

171171
private function isModelInvalid(Model $model): bool
172172
{
173-
return !$model instanceof ReactableContract;
173+
return !$model instanceof ReactableInterface;
174174
}
175175

176176
private function getMigrationsPath(): string

src/Console/Commands/SetupReacterable.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
namespace Cog\Laravel\Love\Console\Commands;
1515

16-
use Cog\Contracts\Love\Reacterable\Models\Reacterable as ReacterableContract;
16+
use Cog\Contracts\Love\Reacterable\Models\Reacterable as ReacterableInterface;
1717
use Cog\Laravel\Love\Reacter\Models\Reacter;
1818
use Cog\Laravel\Love\Support\Database\AddForeignColumnStub;
1919
use Cog\Laravel\Love\Support\Database\MigrationCreator;
@@ -170,7 +170,7 @@ private function sanitizeName(string $name): string
170170

171171
private function isModelInvalid(Model $model): bool
172172
{
173-
return !$model instanceof ReacterableContract;
173+
return !$model instanceof ReacterableInterface;
174174
}
175175

176176
private function getMigrationsPath(): string

src/Console/Commands/UpgradeV5ToV6.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313

1414
namespace Cog\Laravel\Love\Console\Commands;
1515

16-
use Cog\Contracts\Love\Reactable\Models\Reactable as ReactableContract;
17-
use Cog\Contracts\Love\Reacterable\Models\Reacterable as ReacterableContract;
16+
use Cog\Contracts\Love\Reactable\Models\Reactable as ReactableInterface;
17+
use Cog\Contracts\Love\Reacterable\Models\Reacterable as ReacterableInterface;
1818
use Cog\Laravel\Love\Reaction\Models\Reaction;
1919
use Cog\Laravel\Love\ReactionType\Models\ReactionType;
2020
use Illuminate\Console\Command;
@@ -145,7 +145,7 @@ private function populateReacters(): void
145145
continue;
146146
}
147147

148-
if (!in_array(ReacterableContract::class, class_implements($class))) {
148+
if (!in_array(ReacterableInterface::class, class_implements($class))) {
149149
$this->warn("Class `{$class}` need to implement Reacterable contract.");
150150
continue;
151151
}
@@ -192,7 +192,7 @@ private function populateReactants(): void
192192
continue;
193193
}
194194

195-
if (!in_array(ReactableContract::class, class_implements($class))) {
195+
if (!in_array(ReactableInterface::class, class_implements($class))) {
196196
$this->warn("Class `{$class}` need to implement Reactable contract.");
197197
continue;
198198
}
@@ -246,7 +246,7 @@ private function populateReactions(): void
246246
continue;
247247
}
248248

249-
/** @var ReactableContract $reactable */
249+
/** @var ReactableInterface $reactable */
250250
$reactable = $class::whereKey($like->likeable_id)->firstOrFail();
251251

252252
$userClass = $this->getUserClass();
@@ -257,7 +257,7 @@ private function populateReactions(): void
257257
continue;
258258
}
259259

260-
/** @var ReacterableContract $reacterable */
260+
/** @var ReacterableInterface $reacterable */
261261
$reacterable = $userClass::whereKey($like->user_id)->firstOrFail();
262262
$reactionTypeName = $this->reactionTypeNameFromLikeTypeName($like->type_id);
263263

src/Reactable/Models/Traits/Reactable.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
namespace Cog\Laravel\Love\Reactable\Models\Traits;
1515

1616
use Cog\Contracts\Love\Reactable\Exceptions\AlreadyRegisteredAsLoveReactant;
17-
use Cog\Contracts\Love\Reactant\Facades\Reactant as ReactantFacadeContract;
18-
use Cog\Contracts\Love\Reactant\Models\Reactant as ReactantContract;
19-
use Cog\Contracts\Love\Reacterable\Models\Reacterable as ReacterableContract;
17+
use Cog\Contracts\Love\Reactant\Facades\Reactant as ReactantFacadeInterface;
18+
use Cog\Contracts\Love\Reactant\Models\Reactant as ReactantInterface;
19+
use Cog\Contracts\Love\Reacterable\Models\Reacterable as ReacterableInterface;
2020
use Cog\Laravel\Love\Reactable\Observers\ReactableObserver;
2121
use Cog\Laravel\Love\Reactant\Facades\Reactant as ReactantFacade;
2222
use Cog\Laravel\Love\Reactant\Models\NullReactant;
@@ -45,12 +45,12 @@ public function loveReactant(): BelongsTo
4545
return $this->belongsTo(Reactant::class, 'love_reactant_id');
4646
}
4747

48-
public function getLoveReactant(): ReactantContract
48+
public function getLoveReactant(): ReactantInterface
4949
{
5050
return $this->getAttribute('loveReactant') ?? new NullReactant($this);
5151
}
5252

53-
public function viaLoveReactant(): ReactantFacadeContract
53+
public function viaLoveReactant(): ReactantFacadeInterface
5454
{
5555
return new ReactantFacade($this->getLoveReactant());
5656
}
@@ -82,7 +82,7 @@ public function registerAsLoveReactant(): void
8282

8383
public function scopeWhereReactedBy(
8484
Builder $query,
85-
ReacterableContract $reacterable,
85+
ReacterableInterface $reacterable,
8686
?string $reactionTypeName = null
8787
): Builder {
8888
return $query->whereHas('loveReactant.reactions', function (Builder $reactionsQuery) use ($reacterable, $reactionTypeName) {
@@ -95,7 +95,7 @@ public function scopeWhereReactedBy(
9595

9696
public function scopeWhereNotReactedBy(
9797
Builder $query,
98-
ReacterableContract $reacterable,
98+
ReacterableInterface $reacterable,
9999
?string $reactionTypeName = null
100100
): Builder {
101101
return $query->whereDoesntHave('loveReactant.reactions', function (Builder $reactionsQuery) use ($reacterable, $reactionTypeName) {

0 commit comments

Comments
 (0)