Skip to content

Add override attributes #23

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 2 commits into from
Aug 24, 2024
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
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"php": "^8.1",
"illuminate/console": "^10.0|^11.0",
"illuminate/support": "^10.0|^11.0",
"spatie/laravel-package-tools": "^1.16.2"
"spatie/laravel-package-tools": "^1.16.2",
"symfony/polyfill-php83": "^1.30"
},
"require-dev": {
"illuminate/testing": "^10.0|^11.0",
Expand Down
3 changes: 3 additions & 0 deletions src/AndSpecification.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Maartenpaauw\Specifications;

use Override;

/**
* @template TCandidate
*
Expand All @@ -18,6 +20,7 @@ public function __construct(
private readonly array $specifications,
) {}

#[Override]
public function isSatisfiedBy(mixed $candidate): bool
{
foreach ($this->specifications as $specification) {
Expand Down
5 changes: 5 additions & 0 deletions src/Commands/MakeSpecificationCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Maartenpaauw\Specifications\Commands;

use Illuminate\Console\GeneratorCommand;
use Override;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Input\InputOption;

Expand All @@ -19,6 +20,7 @@ final class MakeSpecificationCommand extends GeneratorCommand
*/
protected $type = 'Specification';

#[Override]
protected function getStub(): string
{
if ($this->option('composite')) {
Expand All @@ -35,6 +37,7 @@ protected function getStub(): string
/**
* @inheritDoc
*/
#[Override]
protected function getDefaultNamespace(mixed $rootNamespace): string
{
return sprintf('%s\Specifications', $rootNamespace);
Expand All @@ -43,6 +46,7 @@ protected function getDefaultNamespace(mixed $rootNamespace): string
/**
* @inheritDoc
*/
#[Override]
protected function buildClass(mixed $name): string
{
$replacements = [
Expand All @@ -59,6 +63,7 @@ protected function buildClass(mixed $name): string
/**
* @return array<int, InputOption>
*/
#[Override]
protected function getOptions(): array
{
return [
Expand Down
3 changes: 3 additions & 0 deletions src/NotSpecification.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Maartenpaauw\Specifications;

use Override;

/**
* @template TCandidate
*
Expand All @@ -18,6 +20,7 @@ public function __construct(
private readonly Specification $specification,
) {}

#[Override]
public function isSatisfiedBy(mixed $candidate): bool
{
return ! $this->specification->isSatisfiedBy($candidate);
Expand Down
3 changes: 3 additions & 0 deletions src/OrSpecification.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Maartenpaauw\Specifications;

use Override;

/**
* @template TCandidate
*
Expand All @@ -18,6 +20,7 @@ public function __construct(
private readonly array $specifications,
) {}

#[Override]
public function isSatisfiedBy(mixed $candidate): bool
{
foreach ($this->specifications as $specification) {
Expand Down
3 changes: 3 additions & 0 deletions src/SpecificationsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
use Illuminate\Support\Collection;
use Maartenpaauw\Specifications\Commands\MakeSpecificationCommand;
use Maartenpaauw\Specifications\Laravel\CollectionMatchingMacro;
use Override;
use Spatie\LaravelPackageTools\Package;
use Spatie\LaravelPackageTools\PackageServiceProvider;

final class SpecificationsServiceProvider extends PackageServiceProvider
{
#[Override]
public function configurePackage(Package $package): void
{
$package
Expand All @@ -20,6 +22,7 @@ public function configurePackage(Package $package): void
->hasCommand(MakeSpecificationCommand::class);
}

#[Override]
public function packageRegistered(): void
{
/** @var string $method */
Expand Down
3 changes: 3 additions & 0 deletions src/VerboseSpecification.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Maartenpaauw\Specifications;

use Override;

/**
* @template TCandidate
*
Expand Down Expand Up @@ -40,6 +42,7 @@ public function message(): string
*
* @throws DissatisfiedSpecification
*/
#[Override]
public function isSatisfiedBy(mixed $candidate): bool
{
if ($this->origin->isSatisfiedBy($candidate)) {
Expand Down
3 changes: 3 additions & 0 deletions src/XorSpecification.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Maartenpaauw\Specifications;

use Override;

/**
* @template TCandidate
*
Expand All @@ -18,6 +20,7 @@ public function __construct(
private readonly array $specifications,
) {}

#[Override]
public function isSatisfiedBy(mixed $candidate): bool
{
$satisfiedSpecifications = array_filter(
Expand Down
2 changes: 1 addition & 1 deletion tests/Commands/MakeSpecificationCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,6 @@ public function test_it_should_be_possible_to_create_a_composite_specification_w

protected function assertSpecificationMatchesSnapshot(string $name): void
{
$this->assertMatchesFileSnapshot(app_path(sprintf('Specifications/%s.php', $name)));
$this->assertMatchesFileSnapshot(app_path(\sprintf('Specifications/%s.php', $name)));
}
}
2 changes: 2 additions & 0 deletions workbench/app/LengthSpecification.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Workbench\App;

use Maartenpaauw\Specifications\CompositeSpecification;
use Override;

/**
* @extends CompositeSpecification<string>
Expand All @@ -18,6 +19,7 @@ public function __construct(
/**
* @inheritDoc
*/
#[Override]
public function isSatisfiedBy(mixed $candidate): bool
{
return mb_strlen($candidate) === $this->length;
Expand Down
2 changes: 2 additions & 0 deletions workbench/app/NegativeSpecification.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Workbench\App;

use Maartenpaauw\Specifications\CompositeSpecification;
use Override;

/**
* @extends CompositeSpecification<mixed>
Expand All @@ -14,6 +15,7 @@ final class NegativeSpecification extends CompositeSpecification
/**
* @inheritDoc
*/
#[Override]
public function isSatisfiedBy(mixed $candidate): bool
{
return false;
Expand Down
2 changes: 2 additions & 0 deletions workbench/app/PositiveSpecification.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Workbench\App;

use Maartenpaauw\Specifications\CompositeSpecification;
use Override;

/**
* @extends CompositeSpecification<mixed>
Expand All @@ -14,6 +15,7 @@ final class PositiveSpecification extends CompositeSpecification
/**
* @inheritDoc
*/
#[Override]
public function isSatisfiedBy(mixed $candidate): bool
{
return true;
Expand Down
2 changes: 2 additions & 0 deletions workbench/app/UppercaseSpecification.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Workbench\App;

use Maartenpaauw\Specifications\CompositeSpecification;
use Override;

/**
* @extends CompositeSpecification<string>
Expand All @@ -14,6 +15,7 @@ final class UppercaseSpecification extends CompositeSpecification
/**
* @inheritDoc
*/
#[Override]
public function isSatisfiedBy(mixed $candidate): bool
{
return mb_strtoupper($candidate) === $candidate;
Expand Down