diff --git a/.github/workflows/tests.yml b/.github/workflows/workflow.yml similarity index 66% rename from .github/workflows/tests.yml rename to .github/workflows/workflow.yml index 7f16098..92e4771 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/workflow.yml @@ -1,4 +1,4 @@ -name: Tests +name: Linting & Testing on: workflow_dispatch: @@ -18,7 +18,33 @@ on: - "**.yml" jobs: - tests: + laravel-pint: + name: PHP Linting (Pint) + + if: github.event.pull_request.draft == false + + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + # Make sure the actual branch is checked out when running on pull requests. + ref: ${{ github.head_ref }} + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Laravel Pint + uses: aglipanci/laravel-pint-action@2.4 + + - name: Commit changes + uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: PHP Linting (Pint) + skip_fetch: true + + testing: + needs: laravel-pint + strategy: fail-fast: true matrix: diff --git a/.gitignore b/.gitignore index 09b9eba..9bf544b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ -/vendor /.idea -/composer.lock +/.php-cs-fixer.cache /.phpunit.cache /.phpunit.result.cache -/.php-cs-fixer.cache +/.pint.json +/composer.lock +/vendor diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php deleted file mode 100644 index c733dc1..0000000 --- a/.php-cs-fixer.php +++ /dev/null @@ -1,74 +0,0 @@ - true, - 'binary_operator_spaces' => [ - 'operators' => [ - '=>' => 'align_single_space_minimal', - ], - ], - 'concat_space' => [ - 'spacing' => 'one', - ], - 'increment_style' => ['style' => 'post'], - 'native_constant_invocation' => [ - 'fix_built_in' => true, - 'include' => [ - 'DIRECTORY_SEPARATOR', - 'PHP_SAPI', - 'PHP_VERSION_ID', - ], - 'scope' => 'namespaced', - 'strict' => true, - ], - 'native_function_invocation' => [ - 'include' => ['@compiler_optimized'], - 'scope' => 'namespaced', - 'strict' => true, - ], - 'no_alias_functions' => [ - 'sets' => ['@all'], - ], - 'no_empty_comment' => false, - 'no_superfluous_phpdoc_tags' => false, - 'no_unreachable_default_argument_value' => true, - 'not_operator_with_successor_space' => false, - 'nullable_type_declaration_for_default_null_value' => true, - 'ordered_imports' => [ - 'sort_algorithm' => 'alpha', - 'imports_order' => ['class', 'function', 'const'], - ], - 'ordered_traits' => true, - 'php_unit_test_class_requires_covers' => false, - 'phpdoc_annotation_without_dot' => false, - 'phpdoc_no_empty_return' => false, - 'phpdoc_types_order' => [ - 'sort_algorithm' => 'none', - 'null_adjustment' => 'always_last', - ], - 'simplified_null_return' => true, - 'single_line_comment_style' => [ - 'comment_types' => ['hash'], - ], - 'yoda_style' => false, -]; - -$finder = Finder::create() - ->notPath('vendor') - ->in(getcwd()) - ->name('*.php') - ->ignoreDotFiles(true) - ->ignoreVCS(true) -; - -return (new Config()) - ->setFinder($finder) - ->setRules($rules) - ->setIndent(' ') - ->setLineEnding("\n") - ->setRiskyAllowed(true) - ->setUsingCache(true) -; diff --git a/CHANGELOG.md b/CHANGELOG.md index 384ab59..ac734d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # Release Notes +## [v0.4.0 (2024-06-24)](https://github.com/FrittenKeeZ/laravel-vouchers/compare/0.3.2...0.4.0) + +### Added +- Added support for Laravel 11 + +### Deprecated +- Dropped support for Laravel 5.x - 8 +- Dropped support for PHP 7.4 - 8.0 + +## [v0.3.2 (2023-10-03)](https://github.com/FrittenKeeZ/laravel-vouchers/compare/0.3.1...0.3.2) + +### Added +- Added support for Laravel 10 + ## [v0.3.1 (2022-02-09)](https://github.com/FrittenKeeZ/laravel-vouchers/compare/0.3.0...0.3.1) ### Added diff --git a/composer.json b/composer.json index 9388a85..a395d9d 100644 --- a/composer.json +++ b/composer.json @@ -25,6 +25,7 @@ "require-dev": { "friendsofphp/php-cs-fixer": "^3.4", "illuminate/support": "^9.45|^10.0|^11.0", + "laravel/pint": "^1.16", "nesbot/carbon": "^2.63", "orchestra/testbench": "^7.0|^8.0|^9.0", "phpunit/phpunit": "^9.6|^10.5" @@ -49,9 +50,8 @@ } }, "scripts": { - "test": "phpunit", - "fixer-check": "php-cs-fixer fix --verbose --dry-run", - "fixer-fix": "php-cs-fixer fix" + "pint": "pint", + "test": "phpunit" }, "extra": { "laravel": { diff --git a/migrations/2018_06_12_000000_create_voucher_tables.php b/migrations/2018_06_12_000000_create_voucher_tables.php index 09bd09b..55f08ba 100644 --- a/migrations/2018_06_12_000000_create_voucher_tables.php +++ b/migrations/2018_06_12_000000_create_voucher_tables.php @@ -11,8 +11,6 @@ class CreateVoucherTables extends Migration { /** * Run the migrations. - * - * @return void */ public function up(): void { @@ -63,8 +61,6 @@ public function up(): void /** * Reverse the migrations. - * - * @return void */ public function down(): void { diff --git a/pint.json b/pint.json new file mode 100644 index 0000000..a9a2e14 --- /dev/null +++ b/pint.json @@ -0,0 +1,31 @@ +{ + "preset": "laravel", + "cache-file": ".pint.json", + "rules": { + "binary_operator_spaces": { + "operators": { + "=>": "align_single_space_minimal" + } + }, + "concat_space": { + "spacing": "one" + }, + "multiline_whitespace_before_semicolons": { + "strategy": "new_line_for_chained_calls" + }, + "not_operator_with_successor_space": false, + "ordered_types": { + "null_adjustment": "always_last", + "sort_algorithm": "alpha" + }, + "phpdoc_align": true, + "phpdoc_annotation_without_dot": false, + "phpdoc_order": true, + "phpdoc_separation": true, + "phpdoc_types_order": { + "null_adjustment": "always_last" + }, + "simplified_null_return": true, + "single_trait_insert_per_statement": true + } +} diff --git a/publishes/migrations/2021_02_02_000000_add_owner_to_vouchers_table.php b/publishes/migrations/2021_02_02_000000_add_owner_to_vouchers_table.php index db5a5d5..730e9de 100644 --- a/publishes/migrations/2021_02_02_000000_add_owner_to_vouchers_table.php +++ b/publishes/migrations/2021_02_02_000000_add_owner_to_vouchers_table.php @@ -11,8 +11,6 @@ class AddOwnerToVouchersTable extends Migration { /** * Run the migrations. - * - * @return void */ public function up(): void { @@ -25,8 +23,6 @@ public function up(): void /** * Reverse the migrations. - * - * @return void */ public function down(): void { diff --git a/publishes/migrations/2021_12_10_000000_add_primary_key_to_entities_table.php b/publishes/migrations/2021_12_10_000000_add_primary_key_to_entities_table.php index e948ddd..22f724a 100644 --- a/publishes/migrations/2021_12_10_000000_add_primary_key_to_entities_table.php +++ b/publishes/migrations/2021_12_10_000000_add_primary_key_to_entities_table.php @@ -11,8 +11,6 @@ class AddPrimaryKeyToEntitiesTable extends Migration { /** * Run the migrations. - * - * @return void */ public function up(): void { @@ -25,8 +23,6 @@ public function up(): void /** * Reverse the migrations. - * - * @return void */ public function down(): void { diff --git a/src/Concerns/HasRedeemers.php b/src/Concerns/HasRedeemers.php index cbe6b2f..08f476c 100644 --- a/src/Concerns/HasRedeemers.php +++ b/src/Concerns/HasRedeemers.php @@ -11,8 +11,6 @@ trait HasRedeemers { /** * Associated redeemers. - * - * @return \Illuminate\Database\Eloquent\Relations\MorphMany */ public function redeemers(): MorphMany { diff --git a/src/Concerns/HasVouchers.php b/src/Concerns/HasVouchers.php index 14452ba..33033b3 100644 --- a/src/Concerns/HasVouchers.php +++ b/src/Concerns/HasVouchers.php @@ -14,8 +14,6 @@ trait HasVouchers { /** * Owned vouchers. - * - * @return \Illuminate\Database\Eloquent\Relations\MorphMany */ public function vouchers(): MorphMany { @@ -24,8 +22,6 @@ public function vouchers(): MorphMany /** * Associated vouchers. - * - * @return \Illuminate\Database\Eloquent\Relations\MorphToMany */ public function associatedVouchers(): MorphToMany { @@ -34,8 +30,6 @@ public function associatedVouchers(): MorphToMany /** * Associated voucher entities. - * - * @return \Illuminate\Database\Eloquent\Relations\MorphMany */ public function voucherEntities(): MorphMany { @@ -44,10 +38,6 @@ public function voucherEntities(): MorphMany /** * Create a single voucher with this entity related. - * - * @param \Closure|null $callback - * - * @return object */ public function createVoucher(?Closure $callback = null): object { @@ -56,13 +46,8 @@ public function createVoucher(?Closure $callback = null): object /** * Create an amount of vouchers with this entity related. - * - * @param int $amount - * @param \Closure|null $callback - * - * @return object|array */ - public function createVouchers(int $amount, ?Closure $callback = null) + public function createVouchers(int $amount, ?Closure $callback = null): array|object { $vouchers = new Vouchers(); diff --git a/src/Config.php b/src/Config.php index c75a5b3..cba5d89 100644 --- a/src/Config.php +++ b/src/Config.php @@ -14,15 +14,11 @@ class Config { /** * Dynamic options. - * - * @var array */ protected array $options = []; /** * Get dynamically set options. - * - * @return array */ public function getOptions(): array { @@ -31,8 +27,6 @@ public function getOptions(): array /** * Get code character list. - * - * @return string */ public function getCharacters(): string { @@ -41,10 +35,6 @@ public function getCharacters(): string /** * With code character list. - * - * @param string $characters - * - * @return $this */ public function withCharacters(string $characters): self { @@ -55,8 +45,6 @@ public function withCharacters(string $characters): self /** * Get code mask. - * - * @return string */ public function getMask(): string { @@ -65,10 +53,6 @@ public function getMask(): string /** * With code mask. - * - * @param string $mask - * - * @return $this */ public function withMask(string $mask): self { @@ -79,8 +63,6 @@ public function withMask(string $mask): self /** * Get code prefix. - * - * @return string|null */ public function getPrefix(): ?string { @@ -89,10 +71,6 @@ public function getPrefix(): ?string /** * With code prefix. - * - * @param string $prefix - * - * @return $this */ public function withPrefix(string $prefix): self { @@ -103,8 +81,6 @@ public function withPrefix(string $prefix): self /** * Without code prefix. - * - * @return $this */ public function withoutPrefix(): self { @@ -115,8 +91,6 @@ public function withoutPrefix(): self /** * Get code suffix. - * - * @return string|null */ public function getSuffix(): ?string { @@ -125,10 +99,6 @@ public function getSuffix(): ?string /** * With code suffix. - * - * @param string $suffix - * - * @return $this */ public function withSuffix(string $suffix): self { @@ -139,8 +109,6 @@ public function withSuffix(string $suffix): self /** * Without code suffix. - * - * @return $this */ public function withoutSuffix(): self { @@ -151,8 +119,6 @@ public function withoutSuffix(): self /** * Get separator for prefix and suffix. - * - * @return string */ public function getSeparator(): string { @@ -161,10 +127,6 @@ public function getSeparator(): string /** * With prefix and suffix separator. - * - * @param string $separator - * - * @return $this */ public function withSeparator(string $separator): self { @@ -175,8 +137,6 @@ public function withSeparator(string $separator): self /** * Without prefix and suffix separator. - * - * @return $this */ public function withoutSeparator(): self { @@ -187,8 +147,6 @@ public function withoutSeparator(): self /** * Get metadata. - * - * @return array|null */ public function getMetadata(): ?array { @@ -197,10 +155,6 @@ public function getMetadata(): ?array /** * With metadata. - * - * @param array $metadata - * - * @return $this */ public function withMetadata(array $metadata): self { @@ -211,8 +165,6 @@ public function withMetadata(array $metadata): self /** * Get start time. - * - * @return \Carbon\Carbon|null */ public function getStartTime(): ?Carbon { @@ -221,10 +173,6 @@ public function getStartTime(): ?Carbon /** * With start time. - * - * @param \DateTime $timestamp - * - * @return $this */ public function withStartTime(DateTime $timestamp): self { @@ -235,10 +183,6 @@ public function withStartTime(DateTime $timestamp): self /** * With start time in the given interval. - * - * @param \DateInterval $interval - * - * @return $this */ public function withStartTimeIn(DateInterval $interval): self { @@ -247,10 +191,6 @@ public function withStartTimeIn(DateInterval $interval): self /** * With start date - time component is set to 00:00:00.000000. - * - * @param \DateTime $timestamp - * - * @return $this */ public function withStartDate(DateTime $timestamp): self { @@ -259,10 +199,6 @@ public function withStartDate(DateTime $timestamp): self /** * With start date in the given interval - time component is set to 00:00:00.000000. - * - * @param \DateInterval $interval - * - * @return $this */ public function withStartDateIn(DateInterval $interval): self { @@ -271,8 +207,6 @@ public function withStartDateIn(DateInterval $interval): self /** * Get expire time. - * - * @return \Carbon\Carbon|null */ public function getExpireTime(): ?Carbon { @@ -281,10 +215,6 @@ public function getExpireTime(): ?Carbon /** * With expire time. - * - * @param \DateTime $timestamp - * - * @return $this */ public function withExpireTime(DateTime $timestamp): self { @@ -295,10 +225,6 @@ public function withExpireTime(DateTime $timestamp): self /** * With expire time in the given interval. - * - * @param \DateInterval $interval - * - * @return $this */ public function withExpireTimeIn(DateInterval $interval): self { @@ -307,10 +233,6 @@ public function withExpireTimeIn(DateInterval $interval): self /** * With expire date - time component is set to 23:59:59.999999. - * - * @param \DateTime $timestamp - * - * @return $this */ public function withExpireDate(DateTime $timestamp): self { @@ -319,10 +241,6 @@ public function withExpireDate(DateTime $timestamp): self /** * With expire date in the given interval - time component is set to 23:59:59.999999. - * - * @param \DateInterval $interval - * - * @return $this */ public function withExpireDateIn(DateInterval $interval): self { @@ -332,7 +250,7 @@ public function withExpireDateIn(DateInterval $interval): self /** * Get entities. * - * @return \Illuminate\Database\Eloquent\Model[]|array + * @return array|\Illuminate\Database\Eloquent\Model[] */ public function getEntities(): array { @@ -341,10 +259,6 @@ public function getEntities(): array /** * With entities. - * - * @param \Illuminate\Database\Eloquent\Model ...$entities - * - * @return $this */ public function withEntities(Model ...$entities): self { @@ -355,8 +269,6 @@ public function withEntities(Model ...$entities): self /** * Get owner. - * - * @return \Illuminate\Database\Eloquent\Model|null */ public function getOwner(): ?Model { @@ -365,10 +277,6 @@ public function getOwner(): ?Model /** * With owner. - * - * @param \Illuminate\Database\Eloquent\Model $owner - * - * @return $this */ public function withOwner(Model $owner): self { @@ -379,10 +287,6 @@ public function withOwner(Model $owner): self /** * Get model class name from config. - * - * @param string $name - * - * @return string|null */ public static function model(string $name): ?string { @@ -391,10 +295,6 @@ public static function model(string $name): ?string /** * Get database table name for a model from config. - * - * @param string $name - * - * @return string|null */ public static function table(string $name): ?string { diff --git a/src/Console/Commands/MigrateCommand.php b/src/Console/Commands/MigrateCommand.php index fb38613..48265cf 100644 --- a/src/Console/Commands/MigrateCommand.php +++ b/src/Console/Commands/MigrateCommand.php @@ -32,8 +32,6 @@ class MigrateCommand extends Command /** * Execute the console command. - * - * @return int */ public function handle(): int { @@ -122,8 +120,6 @@ public function handle(): int /** * Get model classes. - * - * @return array */ protected function getModels(): array { @@ -159,6 +155,7 @@ protected function getModels(): array if (preg_match('/namespace\s+([^;]+);/i', $contents, $matches)) { return $matches[1] . '\\' . $class; } + // Fallback to the class itself. return '\\' . $class; }) @@ -169,6 +166,7 @@ protected function getModels(): array ->flatten() ->filter(function (string $class) { $traits = class_uses_recursive($class); + // Ensure only models using the `HasVouchers` trait are included. return !empty($traits) && \in_array(HasVouchers::class, $traits); }) diff --git a/src/Models/Redeemer.php b/src/Models/Redeemer.php index 61971ce..6db159d 100644 --- a/src/Models/Redeemer.php +++ b/src/Models/Redeemer.php @@ -31,10 +31,6 @@ class Redeemer extends Model /** * Constructor. - * - * @param array $attributes - * - * @return void */ public function __construct(array $attributes = []) { @@ -45,8 +41,6 @@ public function __construct(array $attributes = []) /** * Associated redeemer entity. - * - * @return \Illuminate\Database\Eloquent\Relations\MorphTo */ public function redeemer(): MorphTo { @@ -55,8 +49,6 @@ public function redeemer(): MorphTo /** * Associated voucher. - * - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function voucher(): BelongsTo { diff --git a/src/Models/Scopes/Voucher.php b/src/Models/Scopes/Voucher.php index 64b0ae8..21c53b4 100644 --- a/src/Models/Scopes/Voucher.php +++ b/src/Models/Scopes/Voucher.php @@ -13,11 +13,6 @@ trait Voucher { /** * Scope voucher query to a specific code. - * - * @param \Illuminate\Database\Eloquent\Builder $query - * @param string $code - * - * @return \Illuminate\Database\Eloquent\Builder */ public function scopeCode(Builder $query, string $code): Builder { @@ -26,13 +21,6 @@ public function scopeCode(Builder $query, string $code): Builder /** * Scope voucher query to (or exclude) a specific prefix, optionally specifying a separator different from config. - * - * @param \Illuminate\Database\Eloquent\Builder $query - * @param string $prefix - * @param string|null $separator - * @param bool $not - * - * @return \Illuminate\Database\Eloquent\Builder */ public function scopeWithPrefix( Builder $query, @@ -47,12 +35,6 @@ public function scopeWithPrefix( /** * Scope voucher query to exclude a specific prefix, optionally specifying a separator different from config. - * - * @param \Illuminate\Database\Eloquent\Builder $query - * @param string $prefix - * @param string|null $separator - * - * @return \Illuminate\Database\Eloquent\Builder */ public function scopeWithoutPrefix(Builder $query, string $prefix, ?string $separator = null): Builder { @@ -61,13 +43,6 @@ public function scopeWithoutPrefix(Builder $query, string $prefix, ?string $sepa /** * Scope voucher query to (or exclude) a specific suffix, optionally specifying a separator different from config. - * - * @param \Illuminate\Database\Eloquent\Builder $query - * @param string $suffix - * @param string|null $separator - * @param bool $not - * - * @return \Illuminate\Database\Eloquent\Builder */ public function scopeWithSuffix( Builder $query, @@ -82,12 +57,6 @@ public function scopeWithSuffix( /** * Scope voucher query to exclude a specific suffix, optionally specifying a separator different from config. - * - * @param \Illuminate\Database\Eloquent\Builder $query - * @param string $suffix - * @param string|null $separator - * - * @return \Illuminate\Database\Eloquent\Builder */ public function scopeWithoutSuffix(Builder $query, string $suffix, ?string $separator = null): Builder { @@ -96,11 +65,6 @@ public function scopeWithoutSuffix(Builder $query, string $suffix, ?string $sepa /** * Scope voucher query to started or unstarted vouchers. - * - * @param \Illuminate\Database\Eloquent\Builder $query - * @param bool $started - * - * @return \Illuminate\Database\Eloquent\Builder */ public function scopeWithStarted(Builder $query, bool $started = true): Builder { @@ -117,10 +81,6 @@ public function scopeWithStarted(Builder $query, bool $started = true): Builder /** * Scope voucher query to unstarted vouchers. - * - * @param \Illuminate\Database\Eloquent\Builder $query - * - * @return \Illuminate\Database\Eloquent\Builder */ public function scopeWithoutStarted(Builder $query): Builder { @@ -129,11 +89,6 @@ public function scopeWithoutStarted(Builder $query): Builder /** * Scope voucher query to expired or unexpired vouchers. - * - * @param \Illuminate\Database\Eloquent\Builder $query - * @param bool $expired - * - * @return \Illuminate\Database\Eloquent\Builder */ public function scopeWithExpired(Builder $query, bool $expired = true): Builder { @@ -148,10 +103,6 @@ public function scopeWithExpired(Builder $query, bool $expired = true): Builder /** * Scope voucher query to unexpired vouchers. - * - * @param \Illuminate\Database\Eloquent\Builder $query - * - * @return \Illuminate\Database\Eloquent\Builder */ public function scopeWithoutExpired(Builder $query): Builder { @@ -160,11 +111,6 @@ public function scopeWithoutExpired(Builder $query): Builder /** * Scope voucher query to redeemed or unredeemed vouchers. - * - * @param \Illuminate\Database\Eloquent\Builder $query - * @param bool $redeemed - * - * @return \Illuminate\Database\Eloquent\Builder */ public function scopeWithRedeemed(Builder $query, bool $redeemed = true): Builder { @@ -175,10 +121,6 @@ public function scopeWithRedeemed(Builder $query, bool $redeemed = true): Builde /** * Scope voucher query to unredeemed vouchers. - * - * @param \Illuminate\Database\Eloquent\Builder $query - * - * @return \Illuminate\Database\Eloquent\Builder */ public function scopeWithoutRedeemed(Builder $query): Builder { @@ -187,11 +129,6 @@ public function scopeWithoutRedeemed(Builder $query): Builder /** * Scope voucher query to redeemable or unredeemable vouchers. - * - * @param \Illuminate\Database\Eloquent\Builder $query - * @param bool $redeemable - * - * @return \Illuminate\Database\Eloquent\Builder */ public function scopeWithRedeemable(Builder $query, bool $redeemable = true): Builder { @@ -206,15 +143,12 @@ public function scopeWithRedeemable(Builder $query, bool $redeemable = true): Bu return $query->withStarted(false); })->orWhere(function (Builder $query) { return $query->withExpired(true); - }); + }) + ; } /** * Scope voucher query to unredeemable vouchers. - * - * @param \Illuminate\Database\Eloquent\Builder $query - * - * @return \Illuminate\Database\Eloquent\Builder */ public function scopeWithoutRedeemable(Builder $query): Builder { @@ -223,11 +157,6 @@ public function scopeWithoutRedeemable(Builder $query): Builder /** * Scope voucher query to have voucher entities, optionally of a specific type (class or alias). - * - * @param \Illuminate\Database\Eloquent\Builder $query - * @param string|null $type - * - * @return \Illuminate\Database\Eloquent\Builder */ public function scopeWithEntities(Builder $query, ?string $type = null): Builder { @@ -242,11 +171,6 @@ public function scopeWithEntities(Builder $query, ?string $type = null): Builder /** * Scope voucher query to specific owner type (class or alias). - * - * @param \Illuminate\Database\Eloquent\Builder $query - * @param string $type - * - * @return \Illuminate\Database\Eloquent\Builder */ public function scopeWithOwnerType(Builder $query, string $type): Builder { @@ -257,11 +181,6 @@ public function scopeWithOwnerType(Builder $query, string $type): Builder /** * Scope voucher query to specific owner. - * - * @param \Illuminate\Database\Eloquent\Builder $query - * @param \Illuminate\Database\Eloquent\Model $owner - * - * @return \Illuminate\Database\Eloquent\Builder */ public function scopeWithOwner(Builder $query, Model $owner): Builder { @@ -273,10 +192,6 @@ public function scopeWithOwner(Builder $query, Model $owner): Builder /** * Scope voucher query to no owners. - * - * @param \Illuminate\Database\Eloquent\Builder $query - * - * @return \Illuminate\Database\Eloquent\Builder */ public function scopeWithoutOwner(Builder $query): Builder { diff --git a/src/Models/Scopes/VoucherEntity.php b/src/Models/Scopes/VoucherEntity.php index 270761d..f252f25 100644 --- a/src/Models/Scopes/VoucherEntity.php +++ b/src/Models/Scopes/VoucherEntity.php @@ -12,11 +12,6 @@ trait VoucherEntity { /** * Scope voucher query to specific entity type (class or alias). - * - * @param \Illuminate\Database\Eloquent\Builder $query - * @param string $type - * - * @return \Illuminate\Database\Eloquent\Builder */ public function scopeWithEntityType(Builder $query, string $type): Builder { @@ -27,11 +22,6 @@ public function scopeWithEntityType(Builder $query, string $type): Builder /** * Scope voucher query to specific entity. - * - * @param \Illuminate\Database\Eloquent\Builder $query - * @param \Illuminate\Database\Eloquent\Model $entity - * - * @return \Illuminate\Database\Eloquent\Builder */ public function scopeWithEntity(Builder $query, Model $entity): Builder { diff --git a/src/Models/Voucher.php b/src/Models/Voucher.php index b701ee0..f3b9bb3 100644 --- a/src/Models/Voucher.php +++ b/src/Models/Voucher.php @@ -18,8 +18,6 @@ class Voucher extends Model /** * Active redeemer during events. - * - * @var \FrittenKeeZ\Vouchers\Models\Redeemer */ public ?Redeemer $redeemer; @@ -63,10 +61,6 @@ class Voucher extends Model /** * Constructor. - * - * @param array $attributes - * - * @return void */ public function __construct(array $attributes = []) { @@ -77,11 +71,6 @@ public function __construct(array $attributes = []) /** * Whether voucher has prefix, optionally specifying a separator different from config. - * - * @param string $prefix - * @param string|null $separator - * - * @return bool */ public function hasPrefix(string $prefix, ?string $separator = null): bool { @@ -92,11 +81,6 @@ public function hasPrefix(string $prefix, ?string $separator = null): bool /** * Whether voucher has suffix, optionally specifying a separator different from config. - * - * @param string $suffix - * @param string|null $separator - * - * @return bool */ public function hasSuffix(string $suffix, ?string $separator = null): bool { @@ -107,8 +91,6 @@ public function hasSuffix(string $suffix, ?string $separator = null): bool /** * Whether voucher is started. - * - * @return bool */ public function isStarted(): bool { @@ -117,8 +99,6 @@ public function isStarted(): bool /** * Whether voucher is expired. - * - * @return bool */ public function isExpired(): bool { @@ -127,8 +107,6 @@ public function isExpired(): bool /** * Whether voucher is redeemed. - * - * @return bool */ public function isRedeemed(): bool { @@ -137,8 +115,6 @@ public function isRedeemed(): bool /** * Whether voucher is redeemable. - * - * @return bool */ public function isRedeemable(): bool { @@ -147,10 +123,6 @@ public function isRedeemable(): bool /** * Redeem voucher with the provided redeemer. - * - * @param \FrittenKeeZ\Vouchers\Models\Redeemer $redeemer - * - * @return bool */ public function redeem(Redeemer $redeemer): bool { @@ -194,8 +166,6 @@ public function redeem(Redeemer $redeemer): bool /** * Associated owner entity. - * - * @return \Illuminate\Database\Eloquent\Relations\MorphTo */ public function owner(): MorphTo { @@ -204,8 +174,6 @@ public function owner(): MorphTo /** * Associated voucher entities. - * - * @return \Illuminate\Database\Eloquent\Relations\HasMany */ public function voucherEntities(): HasMany { @@ -214,8 +182,6 @@ public function voucherEntities(): HasMany /** * Associated redeemers. - * - * @return \Illuminate\Database\Eloquent\Relations\HasMany */ public function redeemers(): HasMany { @@ -224,10 +190,6 @@ public function redeemers(): HasMany /** * Add related entities. - * - * @param \Illuminate\Database\Eloquent\Model ...$entities - * - * @return void */ public function addEntities(Model ...$entities): void { @@ -242,10 +204,6 @@ public function addEntities(Model ...$entities): void /** * Get all associated entities - optionally with a specific type (class or alias). - * - * @param string|null $type - * - * @return \Illuminate\Support\Collection */ public function getEntities(?string $type = null): Collection { @@ -261,8 +219,6 @@ public function getEntities(?string $type = null): Collection * Register a redeeming voucher event with the dispatcher. * * @param \Closure|string $callback - * - * @return void */ public static function redeeming($callback): void { @@ -273,8 +229,6 @@ public static function redeeming($callback): void * Register a redeemed voucher event with the dispatcher. * * @param \Closure|string $callback - * - * @return void */ public static function redeemed($callback): void { @@ -285,8 +239,6 @@ public static function redeemed($callback): void * Register a shouldMarkRedeemed voucher event with the dispatcher. * * @param \Closure|string $callback - * - * @return void */ public static function shouldMarkRedeemed($callback): void { diff --git a/src/Models/VoucherEntity.php b/src/Models/VoucherEntity.php index f1114b2..82b3d18 100644 --- a/src/Models/VoucherEntity.php +++ b/src/Models/VoucherEntity.php @@ -29,10 +29,6 @@ class VoucherEntity extends Model /** * Constructor. - * - * @param array $attributes - * - * @return void */ public function __construct(array $attributes = []) { @@ -43,8 +39,6 @@ public function __construct(array $attributes = []) /** * Associated entity. - * - * @return \Illuminate\Database\Eloquent\Relations\MorphTo */ public function entity(): MorphTo { @@ -53,8 +47,6 @@ public function entity(): MorphTo /** * Associated voucher. - * - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function voucher(): BelongsTo { diff --git a/src/Vouchers.php b/src/Vouchers.php index 74cc952..cad0d06 100644 --- a/src/Vouchers.php +++ b/src/Vouchers.php @@ -17,15 +17,11 @@ class Vouchers { /** * Voucher config. - * - * @var \FrittenKeeZ\Vouchers\Config */ protected Config $config; /** * Constructor. - * - * @return void */ public function __construct() { @@ -36,13 +32,8 @@ public function __construct() * Proxy 'get', 'with' and 'without' calls to config. * * Will trigger undefined method error for all invalid calls. - * - * @param string $name - * @param array $args - * - * @return mixed */ - public function __call(string $name, array $args) + public function __call(string $name, array $args): mixed { if (method_exists($this->config, $name)) { if (Str::startsWith($name, 'get')) { @@ -61,8 +52,6 @@ public function __call(string $name, array $args) /** * Get current voucher config. - * - * @return \FrittenKeeZ\Vouchers\Config */ public function getConfig(): Config { @@ -73,12 +62,8 @@ public function getConfig(): Config * Create an amount of vouchers. * * Defaults to a single voucher if amount is absent. - * - * @param int $amount - * - * @return object|array */ - public function create(int $amount = 1) + public function create(int $amount = 1): array|object { if ($amount < 1) { return []; @@ -117,14 +102,11 @@ public function create(int $amount = 1) * * Returns whether redemption was successful. * - * @param string $code * @param \Illuminate\Database\Eloquent\Model $entity Redeemer entity. * @param array $metadata Additional metadata for redeemer. * * @throws \FrittenKeeZ\Vouchers\Exceptions\VoucherNotFoundException * @throws \FrittenKeeZ\Vouchers\Exceptions\VoucherAlreadyRedeemedException - * - * @return bool */ public function redeem(string $code, Model $entity, array $metadata = []): bool { @@ -152,11 +134,6 @@ public function redeem(string $code, Model $entity, array $metadata = []): bool /** * Whether a voucher code is redeemable. - * - * @param string $code - * @param \Closure|null $callback - * - * @return bool */ public function redeemable(string $code, ?Closure $callback = null): bool { @@ -170,9 +147,7 @@ public function redeemable(string $code, ?Closure $callback = null): bool * * Codes are checked against the database to ensure uniqueness. * - * @param int $amount - * - * @return string[]|array + * @return array|string[] */ public function batch(int $amount): array { @@ -197,11 +172,6 @@ public function batch(int $amount): array * * All asterisks (*) in the mask will be replaced by a random character. * If no mask or character list is provided, defaults will be used from config. - * - * @param string|null $mask - * @param string|null $characters - * - * @return string */ public function generate(?string $mask = null, ?string $characters = null): string { @@ -222,13 +192,6 @@ public function generate(?string $mask = null, ?string $characters = null): stri /** * Wrap string in prefix and suffix with separator. - * - * @param string $str - * @param string|null $prefix - * @param string|null $suffix - * @param string $separator - * - * @return string */ public function wrap(string $str, ?string $prefix, ?string $suffix, string $separator): string { @@ -242,11 +205,6 @@ public function wrap(string $str, ?string $prefix, ?string $suffix, string $sepa * Whether the given code already exists. * * Optionally check a given list of codes, before checking the database. - * - * @param string $code - * @param array $codes - * - * @return bool */ public function exists(string $code, array $codes = []): bool { @@ -255,8 +213,6 @@ public function exists(string $code, array $codes = []): bool /** * Reset voucher options. - * - * @return void */ public function reset(): void { @@ -265,8 +221,6 @@ public function reset(): void /** * Convenience method for interacting with Redeemer model. - * - * @return \FrittenKeeZ\Vouchers\Models\Redeemer */ protected function redeemers(): Redeemer { @@ -275,8 +229,6 @@ protected function redeemers(): Redeemer /** * Convenience method for interacting with Voucher model. - * - * @return \FrittenKeeZ\Vouchers\Models\Voucher */ protected function vouchers(): Voucher { diff --git a/src/VouchersServiceProvider.php b/src/VouchersServiceProvider.php index cd13a35..8812708 100644 --- a/src/VouchersServiceProvider.php +++ b/src/VouchersServiceProvider.php @@ -18,8 +18,6 @@ class VouchersServiceProvider extends ServiceProvider /** * Bootstrap the application services. - * - * @return void */ public function boot(): void { @@ -35,8 +33,6 @@ public function boot(): void /** * Register the application services. - * - * @return void */ public function register(): void { @@ -49,8 +45,6 @@ public function register(): void /** * Get publish config path. - * - * @return string */ protected function getPublishConfigPath(): string { @@ -59,8 +53,6 @@ protected function getPublishConfigPath(): string /** * Get publish migrations path. - * - * @return string */ protected function getPublishMigrationsPath(): string { diff --git a/tests/ConfigTest.php b/tests/ConfigTest.php index 26bf180..144137f 100644 --- a/tests/ConfigTest.php +++ b/tests/ConfigTest.php @@ -20,8 +20,6 @@ class ConfigTest extends TestCase { /** * Test Config::model() method. - * - * @return void */ public function testModelResolving(): void { @@ -48,8 +46,6 @@ public function testModelResolving(): void /** * Test Config::table() method. - * - * @return void */ public function testTableResolving(): void { @@ -76,8 +72,6 @@ public function testTableResolving(): void /** * Test default options from config. - * - * @return void */ public function testDefaultOptions(): void { @@ -94,8 +88,6 @@ public function testDefaultOptions(): void /** * Test options overridden in config. - * - * @return void */ public function testConfigOverriddenOptions(): void { @@ -126,8 +118,6 @@ public function testConfigOverriddenOptions(): void /** * Test dynamically overridden options using 'with' methods. - * - * @return void */ public function testDynamicallyOverriddenOptions(): void { @@ -168,8 +158,6 @@ public function testDynamicallyOverriddenOptions(): void /** * Test additional options using 'with' methods. - * - * @return void */ public function testAdditionalOptions(): void { @@ -234,11 +222,6 @@ public function testAdditionalOptions(): void /** * Assert array structure. - * - * @param array $expected - * @param array $actual - * - * @return void */ protected function assertArrayStructure(array $expected, array $actual): void { diff --git a/tests/HasVouchersTest.php b/tests/HasVouchersTest.php index 416d966..d660c51 100644 --- a/tests/HasVouchersTest.php +++ b/tests/HasVouchersTest.php @@ -15,8 +15,6 @@ class HasVouchersTest extends TestCase { /** * Test HasVouchers::createVoucher(). - * - * @return void */ public function testCreateVoucher(): void { @@ -30,8 +28,6 @@ public function testCreateVoucher(): void /** * Test HasVouchers::createVoucher() with callback. - * - * @return void */ public function testCreateVoucherWithCallback(): void { @@ -49,8 +45,6 @@ public function testCreateVoucherWithCallback(): void /** * Test HasVouchers::createVoucher() with associated entities. - * - * @return void */ public function testCreateVoucherWithAssociated(): void { @@ -71,8 +65,6 @@ public function testCreateVoucherWithAssociated(): void /** * Test HasVouchers::createVouchers(). - * - * @return void */ public function testCreateVouchers(): void { @@ -88,8 +80,6 @@ public function testCreateVouchers(): void /** * Test HasVouchers::createVouchers() with callback. - * - * @return void */ public function testCreateVouchersWithCallback(): void { diff --git a/tests/MigrateCommandTest.php b/tests/MigrateCommandTest.php index 69dd380..9955d94 100644 --- a/tests/MigrateCommandTest.php +++ b/tests/MigrateCommandTest.php @@ -29,8 +29,6 @@ protected function setUp(): void /** * Test arguments. - * - * @return void */ public function testArguments(): void { @@ -71,8 +69,6 @@ public function testArguments(): void /** * Test migration with auto mode. - * - * @return void */ public function testMigrationModeAuto(): void { @@ -108,8 +104,6 @@ public function testMigrationModeAuto(): void /** * Test migration with retain mode. - * - * @return void */ public function testMigrationModeRetain(): void { @@ -145,8 +139,6 @@ public function testMigrationModeRetain(): void /** * Test migration with delete mode. - * - * @return void */ public function testMigrationModeDelete(): void { diff --git a/tests/TestCase.php b/tests/TestCase.php index 0ae610a..5874415 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -42,8 +42,6 @@ protected function setUp(): void * Get package aliases. * * @param \Illuminate\Foundation\Application $app - * - * @return array */ protected function getPackageAliases($app): array { @@ -54,8 +52,6 @@ protected function getPackageAliases($app): array * Get package providers. * * @param \Illuminate\Foundation\Application $app - * - * @return array */ protected function getPackageProviders($app): array { @@ -65,10 +61,7 @@ protected function getPackageProviders($app): array /** * Factory helper to handle both Laravel 8 and earlier versions. * - * @param string $class - * @param int|null $amount - * - * @return \Illuminate\Database\Eloquent\FactoryBuilder|Illuminate\Database\Eloquent\Factories\Factory + * @return \Illuminate\Database\Eloquent\Factories\Factory|\Illuminate\Database\Eloquent\FactoryBuilder */ protected function factory(string $class, ?int $amount = null) { diff --git a/tests/VoucherEntityScopesTest.php b/tests/VoucherEntityScopesTest.php index 8be289b..0fc7b25 100644 --- a/tests/VoucherEntityScopesTest.php +++ b/tests/VoucherEntityScopesTest.php @@ -17,8 +17,6 @@ class VoucherEntityScopesTest extends TestCase { /** * Test Voucher::scopeWithEntityType() and Voucher::scopeWithEntity(). - * - * @return void */ public function testEntityScopes(): void { diff --git a/tests/VoucherHelpersTest.php b/tests/VoucherHelpersTest.php index 610df31..0e3513a 100644 --- a/tests/VoucherHelpersTest.php +++ b/tests/VoucherHelpersTest.php @@ -13,8 +13,6 @@ class VoucherHelpersTest extends TestCase { /** * Test Voucher::scopeCode(). - * - * @return void */ public function testPrefixAndSuffixHelpers(): void { diff --git a/tests/VoucherScopesTest.php b/tests/VoucherScopesTest.php index 2c259b9..e5b2106 100644 --- a/tests/VoucherScopesTest.php +++ b/tests/VoucherScopesTest.php @@ -17,8 +17,6 @@ class VoucherScopesTest extends TestCase { /** * Test Voucher::scopeCode(). - * - * @return void */ public function testCodeScope(): void { @@ -30,8 +28,6 @@ public function testCodeScope(): void /** * Test Voucher::scopeHasPrefix() and Voucher::scopeHasSuffix(). - * - * @return void */ public function testPrefixAndSuffixScopes(): void { @@ -128,8 +124,6 @@ public function testPrefixAndSuffixScopes(): void /** * Test Voucher::scopeWithStarted(). - * - * @return void */ public function testStartedScope(): void { @@ -144,8 +138,6 @@ public function testStartedScope(): void /** * Test Voucher::scopeWithExpired(). - * - * @return void */ public function testExpiredScope(): void { @@ -160,8 +152,6 @@ public function testExpiredScope(): void /** * Test Voucher::scopeWithRedeemed(). - * - * @return void */ public function testRedeemedScope(): void { @@ -175,8 +165,6 @@ public function testRedeemedScope(): void /** * Test Voucher::scopeWithRedeemable(). - * - * @return void */ public function testRedeemableScope(): void { @@ -194,8 +182,6 @@ public function testRedeemableScope(): void /** * Test Voucher::scopeWithEntities(). - * - * @return void */ public function testEntitiesScope(): void { @@ -215,8 +201,6 @@ public function testEntitiesScope(): void /** * Test Voucher::scopeWithOwnerType() and Voucher::scopeWithOwner(). - * - * @return void */ public function testOwnerScopes(): void { diff --git a/tests/VoucherTest.php b/tests/VoucherTest.php index 2f83056..e664a8b 100644 --- a/tests/VoucherTest.php +++ b/tests/VoucherTest.php @@ -15,8 +15,6 @@ class VoucherTest extends TestCase { /** * Test redeeming event. - * - * @return void */ public function testRedeemingEvent(): void { @@ -39,8 +37,6 @@ public function testRedeemingEvent(): void /** * Test redeemed event. - * - * @return void */ public function testRedeemedEvent(): void { @@ -61,8 +57,6 @@ public function testRedeemedEvent(): void /** * Test shouldMarkRedeemed event. - * - * @return void */ public function testShouldMarkRedeemedEvent(): void { @@ -86,8 +80,6 @@ public function testShouldMarkRedeemedEvent(): void /** * Test redeeming by owning user only event. - * - * @return void */ public function testRedeemingByOwningUserOnlyEvent(): void { diff --git a/tests/VouchersFacadeTest.php b/tests/VouchersFacadeTest.php index 881ef31..e41902d 100644 --- a/tests/VouchersFacadeTest.php +++ b/tests/VouchersFacadeTest.php @@ -14,8 +14,6 @@ class VouchersFacadeTest extends TestCase { /** * Test facade instance through app::make(). - * - * @return void */ public function testFacadeInstance(): void { @@ -24,8 +22,6 @@ public function testFacadeInstance(): void /** * Test facade accessor. - * - * @return void */ public function testFacadeAccessor(): void { diff --git a/tests/VouchersTest.php b/tests/VouchersTest.php index 846d0c7..c81f4af 100644 --- a/tests/VouchersTest.php +++ b/tests/VouchersTest.php @@ -21,8 +21,6 @@ class VouchersTest extends TestCase { /** * Test vouchers instance through app::make(). - * - * @return void */ public function testInstance(): void { @@ -31,8 +29,6 @@ public function testInstance(): void /** * Test that Vouchers::getConfig() returns clone and not same instance. - * - * @return void */ public function testConfigClone(): void { @@ -44,8 +40,6 @@ public function testConfigClone(): void /** * Test code generation. - * - * @return void */ public function testCodeGeneration(): void { @@ -88,8 +82,6 @@ public function testCodeGeneration(): void /** * Test voucher creation. - * - * @return void */ public function testVoucherCreation(): void { @@ -147,8 +139,6 @@ public function testVoucherCreation(): void /** * Test voucher redemption. - * - * @return void */ public function testVoucherRedemption(): void { @@ -185,8 +175,6 @@ public function testVoucherRedemption(): void /** * Test voucher not found exception. - * - * @return void */ public function testVoucherNotFoundException(): void { @@ -199,8 +187,6 @@ public function testVoucherNotFoundException(): void /** * Test voucher already redeemed exception. - * - * @return void */ public function testVoucherAlreadyRedeemedException(): void { @@ -217,14 +203,6 @@ public function testVoucherAlreadyRedeemedException(): void * Test Vouchers::wrap() method. * * @dataProvider wrapProvider - * - * @param string $str - * @param string|null $prefix - * @param string|null $suffix - * @param string $separator - * @param string $expected - * - * @return void */ public function testStringWrapping( string $str, @@ -238,8 +216,6 @@ public function testStringWrapping( /** * Test invalid magic call (Vouchers::__call()). - * - * @return void */ public function testInvalidMagicCall(): void { @@ -250,8 +226,6 @@ public function testInvalidMagicCall(): void /** * Data provider for Vouchers::wrap(). - * - * @return array */ public static function wrapProvider(): array { @@ -266,11 +240,6 @@ public static function wrapProvider(): array /** * Generate regex to validate a code generated with a specific mask, character list, prefix, suffix and separator. - * - * @param string $mask - * @param string $characters - * - * @return string */ protected function generateCodeValidationRegex( string $mask, diff --git a/tests/database/factories/ColorFactory.php b/tests/database/factories/ColorFactory.php index 68a445a..f848314 100644 --- a/tests/database/factories/ColorFactory.php +++ b/tests/database/factories/ColorFactory.php @@ -18,8 +18,6 @@ class ColorFactory extends Factory /** * Define the model's default state. - * - * @return array */ public function definition(): array { diff --git a/tests/database/factories/UserFactory.php b/tests/database/factories/UserFactory.php index c85c900..3c4518b 100644 --- a/tests/database/factories/UserFactory.php +++ b/tests/database/factories/UserFactory.php @@ -19,8 +19,6 @@ class UserFactory extends Factory /** * Define the model's default state. - * - * @return array */ public function definition(): array { diff --git a/tests/database/migrations/2019_12_19_000000_create_vouchers_test_tables.php b/tests/database/migrations/2019_12_19_000000_create_vouchers_test_tables.php index bf4d480..49752c0 100644 --- a/tests/database/migrations/2019_12_19_000000_create_vouchers_test_tables.php +++ b/tests/database/migrations/2019_12_19_000000_create_vouchers_test_tables.php @@ -10,8 +10,6 @@ class CreateVouchersTestTables extends Migration { /** * Run the migrations. - * - * @return void */ public function up(): void { @@ -24,8 +22,6 @@ public function up(): void /** * Reverse the migrations. - * - * @return void */ public function down(): void {