From 97b219c3251acd631f95e80c4b31af9057ee08ff Mon Sep 17 00:00:00 2001 From: Michael Nabil <46572405+michaelnabil230@users.noreply.github.com> Date: Wed, 22 Feb 2023 09:58:09 +0200 Subject: [PATCH] Upgrade --- .github/ISSUE_TEMPLATE/bug.yml | 66 +++++++++++++++++++ .github/ISSUE_TEMPLATE/config.yml | 3 - .github/workflows/dependabot-auto-merge.yml | 2 +- .../workflows/fix-php-code-style-issues.yml | 7 +- .github/workflows/phpstan.yml | 2 +- .github/workflows/run-tests.yml | 19 +++--- README.md | 2 +- composer.json | 18 ++--- src/Interfaces/Store.php | 19 ++---- src/SettingManager.php | 2 - src/Stores/DatabaseSettingStore.php | 29 +------- src/Stores/JsonSettingStore.php | 18 +---- src/Stores/RedisSettingStore.php | 27 ++------ src/Stores/SettingStore.php | 38 ++--------- 14 files changed, 110 insertions(+), 142 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE/bug.yml diff --git a/.github/ISSUE_TEMPLATE/bug.yml b/.github/ISSUE_TEMPLATE/bug.yml new file mode 100644 index 0000000..8fa85ce --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug.yml @@ -0,0 +1,66 @@ +name: Bug Report +description: Report an Issue or Bug with the Package +title: "[Bug]: " +labels: ["bug"] +body: + - type: markdown + attributes: + value: | + We're sorry to hear you have a problem. Can you help us solve it by providing the following details. + - type: textarea + id: what-happened + attributes: + label: What happened? + description: What did you expect to happen? + placeholder: I cannot currently do X thing because when I do, it breaks X thing. + validations: + required: true + - type: textarea + id: how-to-reproduce + attributes: + label: How to reproduce the bug + description: How did this occur, please add any config values used and provide a set of reliable steps if possible. + placeholder: When I do X I see Y. + validations: + required: true + - type: input + id: package-version + attributes: + label: Package Version + description: What version of our Package are you running? Please be as specific as possible + placeholder: 2.0.0 + validations: + required: true + - type: input + id: php-version + attributes: + label: PHP Version + description: What version of PHP are you running? Please be as specific as possible + placeholder: 8.2.0 + validations: + required: true + - type: input + id: laravel-version + attributes: + label: Laravel Version + description: What version of Laravel are you running? Please be as specific as possible + placeholder: 9.0.0 + validations: + required: true + - type: dropdown + id: operating-systems + attributes: + label: Which operating systems does with happen with? + description: You may select more than one. + multiple: true + options: + - macOS + - Windows + - Linux + - type: textarea + id: notes + attributes: + label: Notes + description: Use this field to provide any other notes that you feel might be relevant to the issue. + validations: + required: false diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 63b1892..eeb3546 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -9,6 +9,3 @@ contact_links: - name: Report a security issue url: https://github.com/michaelnabil230/laravel-setting/security/policy about: Learn how to notify us for sensitive bugs - - name: Report a bug - url: https://github.com/michaelnabil230/laravel-setting/issues/new - about: Report a reproducible bug diff --git a/.github/workflows/dependabot-auto-merge.yml b/.github/workflows/dependabot-auto-merge.yml index 7886fe6..891c3c9 100644 --- a/.github/workflows/dependabot-auto-merge.yml +++ b/.github/workflows/dependabot-auto-merge.yml @@ -12,7 +12,7 @@ jobs: steps: - name: Dependabot metadata id: metadata - uses: dependabot/fetch-metadata@v1.3.4 + uses: dependabot/fetch-metadata@v1.3.6 with: github-token: "${{ secrets.GITHUB_TOKEN }}" diff --git a/.github/workflows/fix-php-code-style-issues.yml b/.github/workflows/fix-php-code-style-issues.yml index 970633c..f47ba1b 100644 --- a/.github/workflows/fix-php-code-style-issues.yml +++ b/.github/workflows/fix-php-code-style-issues.yml @@ -1,6 +1,9 @@ name: Fix PHP code style issues -on: [push] +on: + push: + paths: + - "**.php" jobs: php-code-styling: @@ -13,7 +16,7 @@ jobs: ref: ${{ github.head_ref }} - name: Fix PHP code style issues - uses: aglipanci/laravel-pint-action@1.0.0 + uses: aglipanci/laravel-pint-action@2.1.0 - name: Commit changes uses: stefanzweifel/git-auto-commit-action@v4 diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index 2669c70..0a3fd47 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -20,7 +20,7 @@ jobs: coverage: none - name: Install composer dependencies - uses: ramsey/composer-install@v1 + uses: ramsey/composer-install@v2 - name: Run PHPStan run: ./vendor/bin/phpstan --error-format=github diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 67a00eb..d24a241 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -6,17 +6,16 @@ jobs: test: runs-on: ${{ matrix.os }} strategy: - fail-fast: false + fail-fast: true matrix: os: [ubuntu-latest, windows-latest] - php: [8.0, 8.1] - laravel: [8.*, 9.*] - stability: [prefer-stable] + php: [8.2, 8.1] + laravel: [10.*] + stability: [prefer-lowest, prefer-stable] include: - - laravel: 8.* - testbench: ^6.25 - - laravel: 9.* - testbench: 7.* + - laravel: 10.* + testbench: 8.* + carbon: ^2.63 name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} @@ -38,10 +37,10 @@ jobs: - name: Install dependencies run: | - composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update + composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "nesbot/carbon:${{ matrix.carbon }}" --no-interaction --no-update composer update --${{ matrix.stability }} --prefer-dist --no-interaction - - name: List installed dependencies + - name: List Installed Dependencies run: composer show -D - name: Execute tests diff --git a/README.md b/README.md index f5f884c..3841a22 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# This package allows you to persist in setting for Laravel projects and support laravel 8 & 9. +# This package allows you to persist in setting for Laravel projects and support laravel 10. [](https://packagist.org/packages/michaelnabil230/laravel-setting) [](https://packagist.org/packages/michaelnabil230/laravel-setting) diff --git a/composer.json b/composer.json index 2a6bbb3..116af4d 100644 --- a/composer.json +++ b/composer.json @@ -24,21 +24,21 @@ } ], "require": { - "php": "^8.0", - "illuminate/contracts": "^8.73|^9.0", - "spatie/laravel-package-tools": "1.11.0" + "php": "^8.1", + "spatie/laravel-package-tools": "^1.14.0", + "illuminate/contracts": "^10.0" }, "require-dev": { - "laravel/pint": "^1.0", - "nunomaduro/collision": "^5.10|^6.0", - "nunomaduro/larastan": "^1.0|^2.2.5", - "orchestra/testbench": "^6.22|^7.0", + "laravel/pint": "^1.2", + "nunomaduro/collision": "^6.1", + "nunomaduro/larastan": "^2.0.1", + "orchestra/testbench": "^8.0", "pestphp/pest": "^1.21", "pestphp/pest-plugin-laravel": "^1.1", "phpstan/extension-installer": "^1.1", "phpstan/phpstan-deprecation-rules": "^1.0", "phpstan/phpstan-phpunit": "^1.0", - "phpunit/phpunit": "^9.5" + "phpunit/phpunit": "^9.6" }, "autoload": { "psr-4": { @@ -79,4 +79,4 @@ }, "minimum-stability": "dev", "prefer-stable": true -} +} \ No newline at end of file diff --git a/src/Interfaces/Store.php b/src/Interfaces/Store.php index 9d88c74..2df9af4 100644 --- a/src/Interfaces/Store.php +++ b/src/Interfaces/Store.php @@ -15,8 +15,6 @@ public function get($key, $default = null); /** * Loaded data from the store. - * - * @return void */ public function loadedData(): void; @@ -32,10 +30,9 @@ public function set($key, $value = null); /** * Determine if a key exists in the settings data. * - * @param string $key * @return bool */ - public function has($key); + public function has(string $key); /** * Save any changes done to the settings data. @@ -47,7 +44,6 @@ public function save(); /** * Write the data into the store. * - * @param array $data * @return void */ public function write(array $data); @@ -64,34 +60,30 @@ public function all(); * * This method exists for convenience. * - * @param mixed $key * @return $this */ - public function flip($key); + public function flip(mixed $key); /** * Sets the specified key to true. * - * @param mixed $key * @return $this */ - public function enable($key); + public function enable(mixed $key); /** * Sets the specified key to false. * - * @param mixed $key * @return $this */ - public function disable($key); + public function disable(mixed $key); /** * Unset a key in the settings data. * - * @param string $key * @return bool */ - public function forget($key); + public function forget(string $key); /** * Unset all keys in the settings data. @@ -103,7 +95,6 @@ public function forgetAll(); /** * Set extra columns to be added to the rows. * - * @param array $columns * @return $this */ public function setExtraColumns(array $columns); diff --git a/src/SettingManager.php b/src/SettingManager.php index 147e25b..581d705 100644 --- a/src/SettingManager.php +++ b/src/SettingManager.php @@ -20,8 +20,6 @@ public function getDefaultDriver() /** * Register a new store. * - * @param string $driver - * @param array $params * @return self */ public function register(string $driver, array $params) diff --git a/src/Stores/DatabaseSettingStore.php b/src/Stores/DatabaseSettingStore.php index df1425f..2316b9a 100644 --- a/src/Stores/DatabaseSettingStore.php +++ b/src/Stores/DatabaseSettingStore.php @@ -55,11 +55,8 @@ class DatabaseSettingStore extends SettingStore /** * SettingStore constructor. - * - * @param array $options - * @return void */ - public function postOptions($options = []): void + public function postOptions(array $options = []): void { $this->model = $options['model']; $this->cache = $this->app['cache']; @@ -69,9 +66,6 @@ public function postOptions($options = []): void /** * Write the data into the store. - * - * @param array $data - * @return void */ public function write(array $data): void { @@ -90,8 +84,6 @@ public function write(array $data): void /** * Loaded data from the store. - * - * @return void */ public function loadedData(): void { @@ -108,11 +100,8 @@ public function loadedData(): void /** * Unset a key in the settings data. - * - * @param string $key - * @return bool */ - public function forget($key): bool + public function forget(string $key): bool { $this->loadedData(); @@ -133,8 +122,6 @@ public function forget($key): bool /** * Unset all keys in the settings data. - * - * @return bool */ public function forgetAll(): bool { @@ -148,7 +135,6 @@ public function forgetAll(): bool /** * Set extra columns to be added to the rows. * - * @param array $columns * @return $this */ public function setExtraColumns(array $columns): self @@ -160,9 +146,6 @@ public function setExtraColumns(array $columns): self /** * Sync the deleted records. - * - * @param array $deleted - * @return void */ private function syncDeleted(array $deleted): void { @@ -173,8 +156,6 @@ private function syncDeleted(array $deleted): void /** * Read the original data from dataBase. - * - * @return array */ private function readOriginalData(): array { @@ -183,9 +164,6 @@ private function readOriginalData(): array /** * Get the changed settings data. - * - * @param array $data - * @return array */ private function getChanges(array $data): array { @@ -207,9 +185,6 @@ private function getChanges(array $data): array /** * Transforms settings data into an array ready to be inserted into the database. * Call array_dot on a multidimensional array before passing it into this method! - * - * @param array $data - * @return array */ private function prepareData(array $data): array { diff --git a/src/Stores/JsonSettingStore.php b/src/Stores/JsonSettingStore.php index b7a32db..7221643 100644 --- a/src/Stores/JsonSettingStore.php +++ b/src/Stores/JsonSettingStore.php @@ -23,11 +23,7 @@ class JsonSettingStore extends SettingStore */ protected $files = null; - /** - * @param array $options - * @return void - */ - public function postOptions($options = []): void + public function postOptions(array $options = []): void { $this->path = $options['path']; $this->files = $this->app['files']; @@ -38,7 +34,6 @@ public function postOptions($options = []): void /** * Loaded data from the store. * - * @return void * * @throws RuntimeException */ @@ -56,9 +51,6 @@ public function loadedData(): void /** * Write the data into the store. - * - * @param array $data - * @return void */ public function write(array $data): void { @@ -69,11 +61,8 @@ public function write(array $data): void /** * Unset a key in the settings data. - * - * @param string $key - * @return bool */ - public function forget($key): bool + public function forget(string $key): bool { $this->loadedData(); @@ -90,8 +79,6 @@ public function forget($key): bool /** * Unset all keys in the settings data. - * - * @return bool */ public function forgetAll(): bool { @@ -105,7 +92,6 @@ public function forgetAll(): bool /** * Throw any Exception first. * - * @return void * * @throws InvalidArgumentException */ diff --git a/src/Stores/RedisSettingStore.php b/src/Stores/RedisSettingStore.php index 2cdb97f..a572a7b 100644 --- a/src/Stores/RedisSettingStore.php +++ b/src/Stores/RedisSettingStore.php @@ -2,6 +2,7 @@ namespace MichaelNabil230\Setting\Stores; +use Illuminate\Redis\Connections\Connection; use Illuminate\Support\Arr; class RedisSettingStore extends SettingStore @@ -27,10 +28,6 @@ class RedisSettingStore extends SettingStore */ protected $connection = null; - /** - * @param array $options - * @return void - */ protected function postOptions(array $options): void { $this->redis = $this->app->make('redis'); @@ -40,8 +37,6 @@ protected function postOptions(array $options): void /** * Loaded data from the store. - * - * @return void */ public function loadedData(): void { @@ -52,9 +47,6 @@ public function loadedData(): void /** * Write the data into the store. - * - * @param array $data - * @return void */ public function write(array $data): void { @@ -63,11 +55,8 @@ public function write(array $data): void /** * Unset a key in the settings data. - * - * @param string $key - * @return bool */ - public function forget($key): bool + public function forget(string $key): bool { $this->loadedData(); @@ -84,8 +73,6 @@ public function forget($key): bool /** * Unset all keys in the settings data. - * - * @return bool */ public function forgetAll(): bool { @@ -96,22 +83,16 @@ public function forgetAll(): bool /** * Get a Redis connection by name. - * - * @return \Illuminate\Redis\Connections\Connection */ - private function connection() + private function connection(): Connection { return $this->redis->connection($this->connection); } /** * Run a command against the Redis database. - * - * @param string $method - * @param array $parameters - * @return mixed */ - private function command(string $method, array $parameters = []) + private function command(string $method, array $parameters = []): mixed { return $this->connection()->command($method, $parameters); } diff --git a/src/Stores/SettingStore.php b/src/Stores/SettingStore.php index 11ecae1..dc3c857 100644 --- a/src/Stores/SettingStore.php +++ b/src/Stores/SettingStore.php @@ -24,9 +24,6 @@ abstract class SettingStore implements Store /** * SettingStore constructor. - * - * @param Application $app - * @param array $options */ public function __construct(Application $app, array $options = []) { @@ -36,9 +33,6 @@ public function __construct(Application $app, array $options = []) /** * Fire the post options to customize the store. - * - * @param array $options - * @return void */ abstract protected function postOptions(array $options): void; @@ -47,7 +41,6 @@ abstract protected function postOptions(array $options): void; * * @param string|int|null $key * @param mixed $default - * @return mixed */ public function get($key, $default = null): mixed { @@ -60,19 +53,15 @@ public function get($key, $default = null): mixed /** * Loaded data from the store. - * - * @return void */ abstract public function loadedData(): void; /** * Set a specific key to a value in the settings data. * - * @param mixed $key - * @param mixed $value * @return $this */ - public function set($key, $value = null): self + public function set(mixed $key, mixed $value = null): self { $this->loadedData(); @@ -91,7 +80,6 @@ public function set($key, $value = null): self * Determine if a key exists in the settings data. * * @param string|array $key - * @return bool */ public function has($key): bool { @@ -102,8 +90,6 @@ public function has($key): bool /** * Save any changes done to the settings data. - * - * @return array */ public function save(): array { @@ -114,16 +100,11 @@ public function save(): array /** * Write the data into the store. - * - * @param array $data - * @return void */ abstract public function write(array $data): void; /** * Get all settings data. - * - * @return array */ public function all(): array { @@ -137,10 +118,9 @@ public function all(): array * * This method exists for convenience. * - * @param mixed $key * @return $this */ - public function flip($key): self + public function flip(mixed $key): self { return $this->set($key, ! $this->get($key)); } @@ -148,10 +128,9 @@ public function flip($key): self /** * Sets the specified key to true. * - * @param mixed $key * @return $this */ - public function enable($key): self + public function enable(mixed $key): self { return $this->set($key, true); } @@ -159,33 +138,26 @@ public function enable($key): self /** * Sets the specified key to false. * - * @param mixed $key * @return $this */ - public function disable($key): self + public function disable(mixed $key): self { return $this->set($key, false); } /** * Unset a key in the settings data. - * - * @param string $key - * @return bool */ - abstract public function forget($key): bool; + abstract public function forget(string $key): bool; /** * Unset all keys in the settings data. - * - * @return bool */ abstract public function forgetAll(): bool; /** * Set extra columns to be added to the rows. * - * @param array $columns * @return $this */ public function setExtraColumns(array $columns)