From 98a8c909cfd8db000932cd6af6f61d63fcbc3a23 Mon Sep 17 00:00:00 2001 From: galihlasahido Date: Fri, 17 Dec 2021 07:08:59 +0700 Subject: [PATCH 01/71] Update README.md typo in some service name (setting, suppose to be settings) resulting Call to a member function get() on null --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 97fef1e..c5b6cc0 100644 --- a/README.md +++ b/README.md @@ -70,14 +70,14 @@ will be converted back into a boolean when retrieved. Arrays and objects are ser when retrieved. ```php -service('setting')->set('App.siteName', 'My Great Site'); +service('settings')->set('App.siteName', 'My Great Site'); ``` You can delete a value from the persistent storage with the `forget()` method. Since it is removed from the storage, it effectively resets itself back to the default value in config file, if any. ```php -service('setting')->forget('App.siteName') +service('settings')->forget('App.siteName') ``` ### Contextual Settings @@ -96,14 +96,14 @@ change the theme for all visitors to the site, so you need to provide the user a ```php $context = 'user:' . user_id(); -service('setting')->set('App.theme', 'dark', $context); +service('settings')->set('App.theme', 'dark', $context); ``` Now when your filter is determining which theme to apply it can check for the current user as the context: ```php $context = 'user:' . user_id(); -$theme = service('setting')->get('App.theme', $context); +$theme = service('settings')->get('App.theme', $context); // or using the helper setting()->get('App.theme', $context); From b15077b2213bf3bb89f1cf2c97c00376c050ea53 Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 1 Apr 2022 09:11:39 +0900 Subject: [PATCH 02/71] chore: drop PHP 7.3 support --- .github/workflows/analyze.yml | 2 +- .github/workflows/test.yml | 2 +- composer.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/analyze.yml b/.github/workflows/analyze.yml index 12c48c1..f3c02b4 100644 --- a/.github/workflows/analyze.yml +++ b/.github/workflows/analyze.yml @@ -29,7 +29,7 @@ jobs: strategy: fail-fast: false matrix: - php-versions: ['7.3', '7.4', '8.0'] + php-versions: ['7.4', '8.0', '8.1'] steps: - name: Checkout uses: actions/checkout@v2 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ce38955..582206a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,7 +14,7 @@ jobs: strategy: matrix: - php-versions: ['7.3', '7.4', '8.0'] + php-versions: ['7.4', '8.0', '8.1'] runs-on: ubuntu-latest diff --git a/composer.json b/composer.json index b79fa47..3dc32d1 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ } ], "require": { - "php": "^7.3 || ^8.0" + "php": "^7.4 || ^8.0" }, "require-dev": { "codeigniter/coding-standard": "^1.1", From ad47291db6c31404fd8c9bfb40eaa87c603c08e1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 2 Apr 2022 12:08:18 +0000 Subject: [PATCH 03/71] Bump actions/checkout from 2 to 3 Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v2...v3) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/analyze.yml | 2 +- .github/workflows/compare.yml | 2 +- .github/workflows/deduplicate.yml | 2 +- .github/workflows/inspect.yml | 2 +- .github/workflows/test.yml | 2 +- .github/workflows/unused.yml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/analyze.yml b/.github/workflows/analyze.yml index f3c02b4..7f9616b 100644 --- a/.github/workflows/analyze.yml +++ b/.github/workflows/analyze.yml @@ -32,7 +32,7 @@ jobs: php-versions: ['7.4', '8.0', '8.1'] steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Setup PHP uses: shivammathur/setup-php@v2 diff --git a/.github/workflows/compare.yml b/.github/workflows/compare.yml index c6b5e9b..9897358 100644 --- a/.github/workflows/compare.yml +++ b/.github/workflows/compare.yml @@ -14,7 +14,7 @@ jobs: name: Compare for Backwards Compatibility runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: fetch-depth: 0 diff --git a/.github/workflows/deduplicate.yml b/.github/workflows/deduplicate.yml index 827bbbc..c418474 100644 --- a/.github/workflows/deduplicate.yml +++ b/.github/workflows/deduplicate.yml @@ -26,7 +26,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Setup PHP uses: shivammathur/setup-php@v2 diff --git a/.github/workflows/inspect.yml b/.github/workflows/inspect.yml index 23440fe..f3dba2f 100644 --- a/.github/workflows/inspect.yml +++ b/.github/workflows/inspect.yml @@ -28,7 +28,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Setup PHP uses: shivammathur/setup-php@v2 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 582206a..c4a5e28 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,7 +22,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Setup PHP, with composer and extensions uses: shivammathur/setup-php@v2 diff --git a/.github/workflows/unused.yml b/.github/workflows/unused.yml index 4d2ee36..bb1d49b 100644 --- a/.github/workflows/unused.yml +++ b/.github/workflows/unused.yml @@ -24,7 +24,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Setup PHP uses: shivammathur/setup-php@v2 From 10ffb1bbae6e8676953aa8cef3b1f65963ff0df9 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 21 Apr 2022 15:49:45 +0900 Subject: [PATCH 04/71] refactor: remove unneeded `return` Settings::set() returns void. --- src/Helpers/setting_helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Helpers/setting_helper.php b/src/Helpers/setting_helper.php index fa91380..b190085 100644 --- a/src/Helpers/setting_helper.php +++ b/src/Helpers/setting_helper.php @@ -22,6 +22,6 @@ function setting(?string $key = null, $value = null) } // Setting the value - return $setting->set($key, $value); + $setting->set($key, $value); } } From 19c8d3c0610a7560b7e2936ba09691ee221cde3e Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 21 Apr 2022 15:52:09 +0900 Subject: [PATCH 05/71] docs: improve @return --- src/Helpers/setting_helper.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Helpers/setting_helper.php b/src/Helpers/setting_helper.php index b190085..c2457f8 100644 --- a/src/Helpers/setting_helper.php +++ b/src/Helpers/setting_helper.php @@ -1,15 +1,18 @@ Date: Thu, 21 Apr 2022 15:55:02 +0900 Subject: [PATCH 06/71] docs: remove uneeded @var --- src/Config/Services.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Config/Services.php b/src/Config/Services.php index d7862f5..f08a742 100644 --- a/src/Config/Services.php +++ b/src/Config/Services.php @@ -30,7 +30,6 @@ public static function settings(?SettingsConfig $config = null, bool $getShared return static::getSharedInstance('settings', $config); } - /** @var SettingsConfig $config */ $config = $config ?? config('Settings'); return new Settings($config); From 2c929ab5738e9e244f8e418feeffc5354ffb9061 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 21 Apr 2022 15:55:20 +0900 Subject: [PATCH 07/71] refactor: run php-cs-fixer --- src/Config/Services.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Config/Services.php b/src/Config/Services.php index f08a742..5a26837 100644 --- a/src/Config/Services.php +++ b/src/Config/Services.php @@ -30,7 +30,7 @@ public static function settings(?SettingsConfig $config = null, bool $getShared return static::getSharedInstance('settings', $config); } - $config = $config ?? config('Settings'); + $config ??= config('Settings'); return new Settings($config); } From b233e113dbd1fa4c5ec64d59bdae0b9f29778dd5 Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 25 Apr 2022 08:31:14 +0900 Subject: [PATCH 08/71] refactor: remove intermediate variable --- src/Config/Services.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Config/Services.php b/src/Config/Services.php index 5a26837..f4fca95 100644 --- a/src/Config/Services.php +++ b/src/Config/Services.php @@ -30,8 +30,6 @@ public static function settings(?SettingsConfig $config = null, bool $getShared return static::getSharedInstance('settings', $config); } - $config ??= config('Settings'); - - return new Settings($config); + return new Settings($config ?? config('Settings')); } } From f60c28c673d73368256db25da7331431c93ab9a0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 31 Mar 2022 08:24:41 +0000 Subject: [PATCH 09/71] Bump actions/cache from 2 to 3.0.1 Bumps [actions/cache](https://github.com/actions/cache) from 2 to 3.0.1. - [Release notes](https://github.com/actions/cache/releases) - [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md) - [Commits](https://github.com/actions/cache/compare/v2...v3.0.1) --- updated-dependencies: - dependency-name: actions/cache dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/analyze.yml | 4 ++-- .github/workflows/inspect.yml | 4 ++-- .github/workflows/test.yml | 2 +- .github/workflows/unused.yml | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/analyze.yml b/.github/workflows/analyze.yml index 7f9616b..bdff521 100644 --- a/.github/workflows/analyze.yml +++ b/.github/workflows/analyze.yml @@ -51,7 +51,7 @@ jobs: run: mkdir -p ${{ steps.composer-cache.outputs.dir }} - name: Cache composer dependencies - uses: actions/cache@v2 + uses: actions/cache@v3.0.1 with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} @@ -61,7 +61,7 @@ jobs: run: mkdir -p build/phpstan - name: Cache PHPStan results - uses: actions/cache@v2 + uses: actions/cache@v3.0.1 with: path: build/phpstan key: ${{ runner.os }}-phpstan-${{ github.sha }} diff --git a/.github/workflows/inspect.yml b/.github/workflows/inspect.yml index f3dba2f..67bdca9 100644 --- a/.github/workflows/inspect.yml +++ b/.github/workflows/inspect.yml @@ -47,7 +47,7 @@ jobs: run: mkdir -p ${{ steps.composer-cache.outputs.dir }} - name: Cache composer dependencies - uses: actions/cache@v2 + uses: actions/cache@v3.0.1 with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} @@ -57,7 +57,7 @@ jobs: run: mkdir -p build/ - name: Cache Deptrac results - uses: actions/cache@v2 + uses: actions/cache@v3.0.1 with: path: build key: ${{ runner.os }}-deptrac-${{ github.sha }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c4a5e28..2b608a4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -39,7 +39,7 @@ jobs: run: echo "::set-output name=dir::$(composer config cache-files-dir)" - name: Cache composer dependencies - uses: actions/cache@v2 + uses: actions/cache@v3.0.1 with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} diff --git a/.github/workflows/unused.yml b/.github/workflows/unused.yml index bb1d49b..46c059b 100644 --- a/.github/workflows/unused.yml +++ b/.github/workflows/unused.yml @@ -40,7 +40,7 @@ jobs: run: echo "::set-output name=dir::$(composer config cache-files-dir)" - name: Cache composer dependencies - uses: actions/cache@v2 + uses: actions/cache@v3.0.1 with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} From 2416fb386f2ab5c80be51f5732cbd1d250225318 Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 25 Apr 2022 08:42:12 +0900 Subject: [PATCH 10/71] chore: remove step "Run comparison (limited)" --- .github/workflows/compare.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/compare.yml b/.github/workflows/compare.yml index 9897358..98697a3 100644 --- a/.github/workflows/compare.yml +++ b/.github/workflows/compare.yml @@ -18,10 +18,6 @@ jobs: with: fetch-depth: 0 - - name: Run comparison (limited) - if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name }} - uses: docker://nyholm/roave-bc-check-ga - - name: Run comparison (authenticated) if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name }} uses: docker://nyholm/roave-bc-check-ga From 26fcd84979520405f93f05fd09c4110fb834a937 Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 25 Apr 2022 08:46:48 +0900 Subject: [PATCH 11/71] chore: update workflows/unused.yml --- .github/workflows/unused.yml | 37 ++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/.github/workflows/unused.yml b/.github/workflows/unused.yml index 46c059b..c3b23d9 100644 --- a/.github/workflows/unused.yml +++ b/.github/workflows/unused.yml @@ -5,23 +5,25 @@ name: Unused on: pull_request: branches: - - 'develop' + - develop paths: - - 'src/**' - - 'tests/**' + - '**.php' + - 'composer.*' - '.github/workflows/unused.yml' push: branches: - - 'develop' + - develop paths: - - 'src/**' - - 'tests/**' + - '**.php' + - 'composer.*' - '.github/workflows/unused.yml' jobs: build: name: Unused Package Detection runs-on: ubuntu-latest + if: "!contains(github.event.head_commit.message, '[ci skip]')" + steps: - name: Checkout uses: actions/checkout@v3 @@ -32,6 +34,7 @@ jobs: php-version: '8.0' tools: composer, composer-unused extensions: intl, json, mbstring, xml + coverage: none env: COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -40,21 +43,19 @@ jobs: run: echo "::set-output name=dir::$(composer config cache-files-dir)" - name: Cache composer dependencies - uses: actions/cache@v3.0.1 + uses: actions/cache@v3 with: path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}-${{ hashFiles('**/composer.lock') }} restore-keys: ${{ runner.os }}-composer- - - name: Install dependencies (limited) - if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name }} - run: composer update --no-progress --no-interaction --prefer-dist --optimize-autoloader - - - name: Install dependencies (authenticated) - if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name }} - run: composer update --no-progress --no-interaction --prefer-dist --optimize-autoloader - env: - COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }} + - name: Install dependencies + run: | + if [ -f composer.lock ]; then + composer install --no-progress --no-interaction --prefer-dist --optimize-autoloader + else + composer update --no-progress --no-interaction --prefer-dist --optimize-autoloader + fi - name: Detect unused packages - run: composer-unused -vvv --profile --ansi --no-interaction --no-progress --excludePackage=php + run: composer-unused -vvv --output-format=github --ansi --no-interaction --no-progress From 11d155f3d9520772a14f1ee45ab63fba9ff7dd0e Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 25 Apr 2022 08:51:39 +0900 Subject: [PATCH 12/71] chore: remove step "Run comparison (limited)" --- .github/workflows/analyze.yml | 4 ---- .github/workflows/inspect.yml | 4 ---- .github/workflows/test.yml | 4 ---- 3 files changed, 12 deletions(-) diff --git a/.github/workflows/analyze.yml b/.github/workflows/analyze.yml index bdff521..475cf7f 100644 --- a/.github/workflows/analyze.yml +++ b/.github/workflows/analyze.yml @@ -67,10 +67,6 @@ jobs: key: ${{ runner.os }}-phpstan-${{ github.sha }} restore-keys: ${{ runner.os }}-phpstan- - - name: Install dependencies (limited) - if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name }} - run: composer update --no-progress --no-interaction --prefer-dist --optimize-autoloader - - name: Install dependencies (authenticated) if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name }} run: composer update --no-progress --no-interaction --prefer-dist --optimize-autoloader diff --git a/.github/workflows/inspect.yml b/.github/workflows/inspect.yml index 67bdca9..a6fa880 100644 --- a/.github/workflows/inspect.yml +++ b/.github/workflows/inspect.yml @@ -63,10 +63,6 @@ jobs: key: ${{ runner.os }}-deptrac-${{ github.sha }} restore-keys: ${{ runner.os }}-deptrac- - - name: Install dependencies (limited) - if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name }} - run: composer update --no-progress --no-interaction --prefer-dist --optimize-autoloader - - name: Install dependencies (authenticated) if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name }} run: composer update --no-progress --no-interaction --prefer-dist --optimize-autoloader diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2b608a4..3c1a6bd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -45,10 +45,6 @@ jobs: key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} restore-keys: ${{ runner.os }}-composer- - - name: Install dependencies (limited) - if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name }} - run: composer update --no-progress --no-interaction --prefer-dist --optimize-autoloader - - name: Install dependencies (authenticated) if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name }} run: composer update --no-progress --no-interaction --prefer-dist --optimize-autoloader From c62ed2a98a42d8a11e6450a2d09031bd1a2fe43f Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 25 Apr 2022 08:56:54 +0900 Subject: [PATCH 13/71] chore: install new deptrac.yml --- .../workflows/{inspect.yml => deptrac.yml} | 52 +++++++++---------- 1 file changed, 25 insertions(+), 27 deletions(-) rename .github/workflows/{inspect.yml => deptrac.yml} (56%) diff --git a/.github/workflows/inspect.yml b/.github/workflows/deptrac.yml similarity index 56% rename from .github/workflows/inspect.yml rename to .github/workflows/deptrac.yml index a6fa880..441c74d 100644 --- a/.github/workflows/inspect.yml +++ b/.github/workflows/deptrac.yml @@ -1,41 +1,40 @@ -# When a PR is opened or a push is made, perform an -# architectural inspection on the code using Deptrac. name: Deptrac on: pull_request: branches: - - 'develop' + - develop paths: - - 'src/**' - - 'tests/**' - - 'composer.**' + - '**.php' + - 'composer.*' - 'depfile.yaml' - - '.github/workflows/inspect.yml' + - '.github/workflows/deptrac.yml' push: branches: - - 'develop' + - develop paths: - - 'src/**' - - 'tests/**' - - 'composer.**' + - '**.php' + - 'composer.*' - 'depfile.yaml' - - '.github/workflows/inspect.yml' + - '.github/workflows/deptrac.yml' jobs: build: - name: Architectural Inspection + name: Dependency Tracing runs-on: ubuntu-latest + if: "!contains(github.event.head_commit.message, '[ci skip]')" + steps: - name: Checkout uses: actions/checkout@v3 - - name: Setup PHP + - name: Set up PHP uses: shivammathur/setup-php@v2 with: php-version: '8.0' - tools: composer, pecl, phive + tools: phive extensions: intl, json, mbstring, xml + coverage: none env: COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -43,33 +42,32 @@ jobs: id: composer-cache run: echo "::set-output name=dir::$(composer config cache-files-dir)" - - name: Create composer cache directory - run: mkdir -p ${{ steps.composer-cache.outputs.dir }} - - name: Cache composer dependencies - uses: actions/cache@v3.0.1 + uses: actions/cache@v3 with: path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}-${{ hashFiles('**/composer.lock') }} restore-keys: ${{ runner.os }}-composer- - name: Create Deptrac cache directory run: mkdir -p build/ - name: Cache Deptrac results - uses: actions/cache@v3.0.1 + uses: actions/cache@v3 with: path: build key: ${{ runner.os }}-deptrac-${{ github.sha }} restore-keys: ${{ runner.os }}-deptrac- - - name: Install dependencies (authenticated) - if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name }} - run: composer update --no-progress --no-interaction --prefer-dist --optimize-autoloader - env: - COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }} + - name: Install dependencies + run: | + if [ -f composer.lock ]; then + composer install --no-progress --no-interaction --prefer-dist --optimize-autoloader + else + composer update --no-progress --no-interaction --prefer-dist --optimize-autoloader + fi - - name: Run architectural inspection + - name: Trace dependencies run: | sudo phive --no-progress install --global --trust-gpg-keys B8F640134AB1782E,A98E898BB53EB748 qossmic/deptrac deptrac analyze --cache-file=build/deptrac.cache From 9cffa7a6ed51329e1e99d5ace33e30f7ac7b6a4b Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 25 Apr 2022 08:59:14 +0900 Subject: [PATCH 14/71] chore: install new phpcpd.yml --- .github/workflows/deduplicate.yml | 39 ------------------------------- .github/workflows/phpcpd.yml | 36 ++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 39 deletions(-) delete mode 100644 .github/workflows/deduplicate.yml create mode 100644 .github/workflows/phpcpd.yml diff --git a/.github/workflows/deduplicate.yml b/.github/workflows/deduplicate.yml deleted file mode 100644 index c418474..0000000 --- a/.github/workflows/deduplicate.yml +++ /dev/null @@ -1,39 +0,0 @@ -# When a PR is opened or a push is made, check code -# for duplication with PHP Copy/Paste Detector. -name: PHPCPD - -on: - pull_request: - branches: - - 'develop' - paths: - - 'app/**' - - 'src/**' - - 'tests/**' - - '.github/workflows/deduplicate.yml' - push: - branches: - - 'develop' - paths: - - 'app/**' - - 'src/**' - - 'tests/**' - - '.github/workflows/deduplicate.yml' - -jobs: - build: - name: Duplicate Code Detection - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '8.0' - tools: phpcpd - extensions: dom, mbstring - - - name: Detect code duplication - run: phpcpd app/ src/ tests/ diff --git a/.github/workflows/phpcpd.yml b/.github/workflows/phpcpd.yml new file mode 100644 index 0000000..d6a877d --- /dev/null +++ b/.github/workflows/phpcpd.yml @@ -0,0 +1,36 @@ +name: PHPCPD + +on: + pull_request: + branches: + - develop + paths: + - '**.php' + - '.github/workflows/phpcpd.yml' + push: + branches: + - develop + paths: + - '**.php' + - '.github/workflows/phpcpd.yml' + +jobs: + build: + name: Code Copy-Paste Detection + runs-on: ubuntu-latest + if: "!contains(github.event.head_commit.message, '[ci skip]')" + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.0' + tools: phpcpd + extensions: dom, mbstring + coverage: none + + - name: Detect duplicate code + run: phpcpd src/ tests/ From 037a01efca5b894e65733f5d176130f4aa5870c7 Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 25 Apr 2022 09:02:43 +0900 Subject: [PATCH 15/71] chore: install new phpunit.yml --- .github/workflows/{test.yml => phpunit.yml} | 46 +++++++++++---------- 1 file changed, 25 insertions(+), 21 deletions(-) rename .github/workflows/{test.yml => phpunit.yml} (69%) diff --git a/.github/workflows/test.yml b/.github/workflows/phpunit.yml similarity index 69% rename from .github/workflows/test.yml rename to .github/workflows/phpunit.yml index 3c1a6bd..c875e33 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/phpunit.yml @@ -4,32 +4,39 @@ on: pull_request: branches: - develop + paths: + - '**.php' + - 'composer.*' + - 'phpunit*' + - '.github/workflows/phpunit.yml' push: branches: - develop + paths: + - '**.php' + - 'composer.*' + - 'phpunit*' + - '.github/workflows/phpunit.yml' jobs: main: name: PHP ${{ matrix.php-versions }} Unit Tests - + runs-on: ubuntu-latest + if: "!contains(github.event.head_commit.message, '[ci skip]')" strategy: matrix: php-versions: ['7.4', '8.0', '8.1'] - runs-on: ubuntu-latest - - if: "!contains(github.event.head_commit.message, '[ci skip]')" - steps: - name: Checkout uses: actions/checkout@v3 - - name: Setup PHP, with composer and extensions + - name: Set up PHP uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-versions }} - tools: composer, infection, pecl, phive, phpunit - extensions: intl, json, mbstring, gd, mysqlnd, xdebug, xml, sqlite3 + tools: composer, phive, phpunit + extensions: intl, json, mbstring, gd, xdebug, xml, sqlite3 coverage: xdebug env: COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -39,17 +46,19 @@ jobs: run: echo "::set-output name=dir::$(composer config cache-files-dir)" - name: Cache composer dependencies - uses: actions/cache@v3.0.1 + uses: actions/cache@v3 with: path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}-${{ hashFiles('**/composer.lock') }} restore-keys: ${{ runner.os }}-composer- - - name: Install dependencies (authenticated) - if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name }} - run: composer update --no-progress --no-interaction --prefer-dist --optimize-autoloader - env: - COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }} + - name: Install dependencies + run: | + if [ -f composer.lock ]; then + composer install --no-progress --no-interaction --prefer-dist --optimize-autoloader + else + composer update --no-progress --no-interaction --prefer-dist --optimize-autoloader + fi - name: Test with PHPUnit run: vendor/bin/phpunit --verbose --coverage-text @@ -57,12 +66,6 @@ jobs: TERM: xterm-256color TACHYCARDIA_MONITOR_GA: enabled - - if: matrix.php-versions == '8.0' - name: Mutate with Infection - run: | - git fetch --depth=1 origin $GITHUB_BASE_REF - infection --threads=2 --skip-initial-tests --coverage=build/phpunit --git-diff-base=origin/$GITHUB_BASE_REF --git-diff-filter=AM --logger-github --ignore-msi-with-no-mutations - - if: matrix.php-versions == '8.0' name: Run Coveralls continue-on-error: true @@ -81,6 +84,7 @@ jobs: steps: - name: Upload Coveralls results uses: coverallsapp/github-action@master + continue-on-error: true with: github-token: ${{ secrets.GITHUB_TOKEN }} parallel-finished: true From 0ee6934e83366ae0659e111888a760ba3b087a44 Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 25 Apr 2022 09:04:46 +0900 Subject: [PATCH 16/71] chore: install new phpstan.yml --- .../workflows/{analyze.yml => phpstan.yml} | 48 +++++++++---------- 1 file changed, 23 insertions(+), 25 deletions(-) rename .github/workflows/{analyze.yml => phpstan.yml} (57%) diff --git a/.github/workflows/analyze.yml b/.github/workflows/phpstan.yml similarity index 57% rename from .github/workflows/analyze.yml rename to .github/workflows/phpstan.yml index 475cf7f..6bdd00f 100644 --- a/.github/workflows/analyze.yml +++ b/.github/workflows/phpstan.yml @@ -1,35 +1,33 @@ -# When a PR is opened or a push is made, perform -# a static analysis check on the code using PHPStan. name: PHPStan on: pull_request: branches: - - 'develop' + - develop paths: - - 'src/**' - - 'tests/**' - - 'composer.**' + - '**.php' + - 'composer.*' - 'phpstan*' - - '.github/workflows/analyze.yml' + - '.github/workflows/phpstan.yml' push: branches: - - 'develop' + - develop paths: - - 'src/**' - - 'tests/**' - - 'composer.**' + - '**.php' + - 'composer.*' - 'phpstan*' - - '.github/workflows/analyze.yml' + - '.github/workflows/phpstan.yml' jobs: build: name: PHP ${{ matrix.php-versions }} Static Analysis runs-on: ubuntu-latest + if: "!contains(github.event.head_commit.message, '[ci skip]')" strategy: fail-fast: false matrix: php-versions: ['7.4', '8.0', '8.1'] + steps: - name: Checkout uses: actions/checkout@v3 @@ -38,8 +36,9 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-versions }} - tools: composer, pecl, phpunit - extensions: intl, json, mbstring, gd, mysqlnd, xdebug, xml, sqlite3 + tools: phpstan, phpunit + extensions: intl, json, mbstring, xml + coverage: none env: COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -47,31 +46,30 @@ jobs: id: composer-cache run: echo "::set-output name=dir::$(composer config cache-files-dir)" - - name: Create composer cache directory - run: mkdir -p ${{ steps.composer-cache.outputs.dir }} - - name: Cache composer dependencies - uses: actions/cache@v3.0.1 + uses: actions/cache@v3 with: path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}-${{ hashFiles('**/composer.lock') }} restore-keys: ${{ runner.os }}-composer- - name: Create PHPStan cache directory run: mkdir -p build/phpstan - name: Cache PHPStan results - uses: actions/cache@v3.0.1 + uses: actions/cache@v3 with: path: build/phpstan key: ${{ runner.os }}-phpstan-${{ github.sha }} restore-keys: ${{ runner.os }}-phpstan- - - name: Install dependencies (authenticated) - if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name }} - run: composer update --no-progress --no-interaction --prefer-dist --optimize-autoloader - env: - COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }} + - name: Install dependencies + run: | + if [ -f composer.lock ]; then + composer install --no-progress --no-interaction --prefer-dist --optimize-autoloader + else + composer update --no-progress --no-interaction --prefer-dist --optimize-autoloader + fi - name: Run static analysis run: vendor/bin/phpstan analyze From 8b0fe2ca3c14f8b682ec3e128d60b60ff864642b Mon Sep 17 00:00:00 2001 From: Jordi de la Mano Date: Wed, 31 Aug 2022 12:02:18 +0200 Subject: [PATCH 17/71] - Improvements - Allow adding another database group --- composer.json | 8 +------ phpunit.xml.dist | 6 ++--- src/Config/Settings.php | 4 +++- .../2021-07-04-041948_CreateSettingsTable.php | 17 +++++++++++++ .../2021-11-14-143905_AddContextColumn.php | 17 +++++++++++++ src/Handlers/DatabaseHandler.php | 24 ++++++++++++------- 6 files changed, 57 insertions(+), 19 deletions(-) diff --git a/composer.json b/composer.json index 3dc32d1..a198a3a 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ }, "require-dev": { "codeigniter/coding-standard": "^1.1", - "codeigniter4/codeigniter4": "dev-develop", + "codeigniter4/framework": "^4", "fakerphp/faker": "^1.9", "mockery/mockery": "^1.0", "nexusphp/cs-config": "^3.1", @@ -45,12 +45,6 @@ "Tests\\Support\\": "tests/_support" } }, - "repositories": [ - { - "type": "vcs", - "url": "https://github.com/codeigniter4/CodeIgniter4" - } - ], "minimum-stability": "dev", "prefer-stable": true, "scripts": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index a90a1f2..6204cc6 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,7 +1,7 @@ - + - + diff --git a/src/Config/Settings.php b/src/Config/Settings.php index 7ac4fdc..a4695e3 100644 --- a/src/Config/Settings.php +++ b/src/Config/Settings.php @@ -2,10 +2,11 @@ namespace CodeIgniter\Settings\Config; +use CodeIgniter\Config\BaseConfig; use CodeIgniter\Settings\Handlers\ArrayHandler; use CodeIgniter\Settings\Handlers\DatabaseHandler; -class Settings +class Settings extends BaseConfig { /** * The available handlers. The alias must @@ -30,6 +31,7 @@ class Settings public $database = [ 'class' => DatabaseHandler::class, 'table' => 'settings', + 'group' => null, 'writeable' => true, ]; } diff --git a/src/Database/Migrations/2021-07-04-041948_CreateSettingsTable.php b/src/Database/Migrations/2021-07-04-041948_CreateSettingsTable.php index c7b0053..21201c9 100644 --- a/src/Database/Migrations/2021-07-04-041948_CreateSettingsTable.php +++ b/src/Database/Migrations/2021-07-04-041948_CreateSettingsTable.php @@ -2,10 +2,22 @@ namespace CodeIgniter\Settings\Database\Migrations; +use CodeIgniter\Config\BaseConfig; +use CodeIgniter\Database\Forge; use CodeIgniter\Database\Migration; class CreateSettingsTable extends Migration { + private BaseConfig $config; + + public function __construct(?Forge $forge = null) + { + $this->config = $this->_getConfig(); + $this->DBGroup = (isset($this->config->database['group']) && $this->config->database['group']) ? $this->config->database['group'] : null; + + parent::__construct($forge); + } + public function up() { $this->forge->addField('id'); @@ -39,6 +51,11 @@ public function up() $this->forge->createTable(config('Settings')->database['table'], true); } + private function _getConfig() + { + return config('Settings'); + } + public function down() { $this->forge->dropTable(config('Settings')->database['table']); diff --git a/src/Database/Migrations/2021-11-14-143905_AddContextColumn.php b/src/Database/Migrations/2021-11-14-143905_AddContextColumn.php index 5898512..f0dcf00 100644 --- a/src/Database/Migrations/2021-11-14-143905_AddContextColumn.php +++ b/src/Database/Migrations/2021-11-14-143905_AddContextColumn.php @@ -2,10 +2,22 @@ namespace CodeIgniter\Settings\Database\Migrations; +use CodeIgniter\Config\BaseConfig; +use CodeIgniter\Database\Forge; use CodeIgniter\Database\Migration; class AddContextColumn extends Migration { + private BaseConfig $config; + + public function __construct(?Forge $forge = null) + { + $this->config = $this->_getConfig(); + $this->DBGroup = (isset($this->config->database['group']) && $this->config->database['group']) ? $this->config->database['group'] : null; + + parent::__construct($forge); + } + public function up() { $this->forge->addColumn(config('Settings')->database['table'], [ @@ -18,6 +30,11 @@ public function up() ]); } + private function _getConfig() + { + return config('Settings'); + } + public function down() { $this->forge->dropColumn(config('Settings')->database['table'], 'context'); diff --git a/src/Handlers/DatabaseHandler.php b/src/Handlers/DatabaseHandler.php index ef136d3..05bb8cb 100644 --- a/src/Handlers/DatabaseHandler.php +++ b/src/Handlers/DatabaseHandler.php @@ -18,6 +18,13 @@ class DatabaseHandler extends ArrayHandler */ private $table; + /** + * The database group to use. + * + * @var string + */ + private $group; + /** * Array of contexts that have been stored. * @@ -31,6 +38,7 @@ class DatabaseHandler extends ArrayHandler public function __construct() { $this->table = config('Settings')->database['table'] ?? 'settings'; + $this->group = config('Settings')->database['group'] ?? null; } /** @@ -73,7 +81,7 @@ public function set(string $class, string $property, $value = null, ?string $con // If it was stored then we need to update if ($this->has($class, $property, $context)) { - $result = db_connect()->table($this->table) + $result = db_connect($this->group)->table($this->table) ->where('class', $class) ->where('key', $property) ->where('context', $context) @@ -85,7 +93,7 @@ public function set(string $class, string $property, $value = null, ?string $con ]); // ...otherwise insert it } else { - $result = db_connect()->table($this->table) + $result = db_connect($this->group)->table($this->table) ->insert([ 'class' => $class, 'key' => $property, @@ -98,7 +106,7 @@ public function set(string $class, string $property, $value = null, ?string $con } if ($result !== true) { - throw new RuntimeException(db_connect()->error()['message'] ?? 'Error writing to the database.'); + throw new RuntimeException(db_connect($this->group)->error()['message'] ?? 'Error writing to the database.'); } // Update storage @@ -116,14 +124,14 @@ public function forget(string $class, string $property, ?string $context = null) $this->hydrate($context); // Delete from the database - $result = db_connect()->table($this->table) + $result = db_connect($this->group)->table($this->table) ->where('class', $class) ->where('key', $property) ->where('context', $context) ->delete(); if (! $result) { - throw new RuntimeException(db_connect()->error()['message'] ?? 'Error writing to the database.'); + throw new RuntimeException(db_connect($this->group)->error()['message'] ?? 'Error writing to the database.'); } // Delete from local storage @@ -147,9 +155,9 @@ private function hydrate(?string $context): void if ($context === null) { $this->hydrated[] = null; - $query = db_connect()->table($this->table)->where('context', null); + $query = db_connect($this->group)->table($this->table)->where('context', null); } else { - $query = db_connect()->table($this->table)->where('context', $context); + $query = db_connect($this->group)->table($this->table)->where('context', $context); // If general has not been hydrated we will do that at the same time if (! in_array(null, $this->hydrated, true)) { @@ -161,7 +169,7 @@ private function hydrate(?string $context): void } if (is_bool($result = $query->get())) { - throw new RuntimeException(db_connect()->error()['message'] ?? 'Error reading from database.'); + throw new RuntimeException(db_connect($this->group)->error()['message'] ?? 'Error reading from database.'); } foreach ($result->getResultObject() as $row) { From 36e17c9253b7bbbc49ce2a524d43313fe6c290fa Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 1 Sep 2022 10:02:25 +0900 Subject: [PATCH 18/71] chore: update .editorconfig --- .editorconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.editorconfig b/.editorconfig index cd8eb86..7382bb8 100644 --- a/.editorconfig +++ b/.editorconfig @@ -11,5 +11,5 @@ end_of_line = lf insert_final_newline = true trim_trailing_whitespace = true -[*.md] -trim_trailing_whitespace = false +[*.{yml,yaml}] +indent_size = 2 From 618b72f9225a171d85630e3afc63ce9072ec995f Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 1 Sep 2022 10:06:50 +0900 Subject: [PATCH 19/71] chore: use codeigniter4/framework instead of odeigniter4/codeigniter4 --- composer.json | 8 +------- phpstan.neon.dist | 4 ++-- phpunit.xml.dist | 6 +++--- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/composer.json b/composer.json index 3dc32d1..28b16a6 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ }, "require-dev": { "codeigniter/coding-standard": "^1.1", - "codeigniter4/codeigniter4": "dev-develop", + "codeigniter4/framework": "^4.2.3", "fakerphp/faker": "^1.9", "mockery/mockery": "^1.0", "nexusphp/cs-config": "^3.1", @@ -45,12 +45,6 @@ "Tests\\Support\\": "tests/_support" } }, - "repositories": [ - { - "type": "vcs", - "url": "https://github.com/codeigniter4/CodeIgniter4" - } - ], "minimum-stability": "dev", "prefer-stable": true, "scripts": { diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 4d2089e..60fc715 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -5,7 +5,7 @@ parameters: - src - tests bootstrapFiles: - - vendor/codeigniter4/codeigniter4/system/Test/bootstrap.php + - vendor/codeigniter4/framework/system/Test/bootstrap.php excludePaths: - src/Config/Routes.php - src/Views/* @@ -15,7 +15,7 @@ parameters: - CodeIgniter\Entity\Entity - Faker\Generator scanDirectories: - - vendor/codeigniter4/codeigniter4/system/Helpers + - vendor/codeigniter4/framework/system/Helpers dynamicConstantNames: - APP_NAMESPACE - CI_DEBUG diff --git a/phpunit.xml.dist b/phpunit.xml.dist index a90a1f2..6204cc6 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,7 +1,7 @@ - + - + From 1744e8d07fbcfa29e90f47745fdcc0eae5423d54 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 1 Sep 2022 10:12:10 +0900 Subject: [PATCH 20/71] chore: update deptrac.yaml --- depfile.yaml | 155 -------------------------------------------------- deptrac.yaml | 156 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 156 insertions(+), 155 deletions(-) delete mode 100644 depfile.yaml create mode 100644 deptrac.yaml diff --git a/depfile.yaml b/depfile.yaml deleted file mode 100644 index 23e144a..0000000 --- a/depfile.yaml +++ /dev/null @@ -1,155 +0,0 @@ -paths: - - ./src - - ./vendor/codeigniter4/codeigniter4/system -exclude_files: - - '#.*test.*#i' -layers: - - name: Model - collectors: - - type: bool - must: - - type: className - regex: .*[A-Za-z]+Model$ - must_not: - - type: directory - regex: vendor/.* - - name: Vendor Model - collectors: - - type: bool - must: - - type: className - regex: .*[A-Za-z]+Model$ - - type: directory - regex: vendor/.* - - name: Controller - collectors: - - type: bool - must: - - type: className - regex: .*\/Controllers\/.* - must_not: - - type: directory - regex: vendor/.* - - name: Vendor Controller - collectors: - - type: bool - must: - - type: className - regex: .*\/Controllers\/.* - - type: directory - regex: vendor/.* - - name: Config - collectors: - - type: bool - must: - - type: directory - regex: src/Config/.* - must_not: - - type: className - regex: .*Services - - type: directory - regex: vendor/.* - - name: Vendor Config - collectors: - - type: bool - must: - - type: directory - regex: vendor/.*/Config/.* - must_not: - - type: className - regex: .*Services - - name: Entity - collectors: - - type: bool - must: - - type: directory - regex: src/Entities/.* - must_not: - - type: directory - regex: vendor/.* - - name: Vendor Entity - collectors: - - type: bool - must: - - type: directory - regex: vendor/.*/Entities/.* - - name: View - collectors: - - type: bool - must: - - type: directory - regex: src/Views/.* - must_not: - - type: directory - regex: vendor/.* - - name: Vendor View - collectors: - - type: bool - must: - - type: directory - regex: vendor/.*/Views/.* - - name: Service - collectors: - - type: className - regex: .*Services.* -ruleset: - Entity: - - Config - - Model - - Service - - Vendor Config - - Vendor Entity - - Vendor Model - Config: - - Service - - Vendor Config - Model: - - Config - - Entity - - Service - - Vendor Config - - Vendor Entity - - Vendor Model - Service: - - Config - - Vendor Config - - # Ignore anything in the Vendor layers - Vendor Model: - - Config - - Service - - Vendor Config - - Vendor Controller - - Vendor Entity - - Vendor Model - - Vendor View - Vendor Controller: - - Service - - Vendor Config - - Vendor Controller - - Vendor Entity - - Vendor Model - - Vendor View - Vendor Config: - - Config - - Service - - Vendor Config - - Vendor Controller - - Vendor Entity - - Vendor Model - - Vendor View - Vendor Entity: - - Service - - Vendor Config - - Vendor Controller - - Vendor Entity - - Vendor Model - - Vendor View - Vendor View: - - Service - - Vendor Config - - Vendor Controller - - Vendor Entity - - Vendor Model - - Vendor View -skip_violations: diff --git a/deptrac.yaml b/deptrac.yaml new file mode 100644 index 0000000..3b8c5ef --- /dev/null +++ b/deptrac.yaml @@ -0,0 +1,156 @@ +parameters: + paths: + - ./src + - ./vendor/codeigniter4/framework/system + exclude_files: + - '#.*test.*#i' + layers: + - name: Model + collectors: + - type: bool + must: + - type: className + regex: .*[A-Za-z]+Model$ + must_not: + - type: directory + regex: vendor/.* + - name: Vendor Model + collectors: + - type: bool + must: + - type: className + regex: .*[A-Za-z]+Model$ + - type: directory + regex: vendor/.* + - name: Controller + collectors: + - type: bool + must: + - type: className + regex: .*\/Controllers\/.* + must_not: + - type: directory + regex: vendor/.* + - name: Vendor Controller + collectors: + - type: bool + must: + - type: className + regex: .*\/Controllers\/.* + - type: directory + regex: vendor/.* + - name: Config + collectors: + - type: bool + must: + - type: directory + regex: src/Config/.* + must_not: + - type: className + regex: .*Services + - type: directory + regex: vendor/.* + - name: Vendor Config + collectors: + - type: bool + must: + - type: directory + regex: vendor/.*/Config/.* + must_not: + - type: className + regex: .*Services + - name: Entity + collectors: + - type: bool + must: + - type: directory + regex: src/Entities/.* + must_not: + - type: directory + regex: vendor/.* + - name: Vendor Entity + collectors: + - type: bool + must: + - type: directory + regex: vendor/.*/Entities/.* + - name: View + collectors: + - type: bool + must: + - type: directory + regex: src/Views/.* + must_not: + - type: directory + regex: vendor/.* + - name: Vendor View + collectors: + - type: bool + must: + - type: directory + regex: vendor/.*/Views/.* + - name: Service + collectors: + - type: className + regex: .*Services.* + ruleset: + Entity: + - Config + - Model + - Service + - Vendor Config + - Vendor Entity + - Vendor Model + Config: + - Service + - Vendor Config + Model: + - Config + - Entity + - Service + - Vendor Config + - Vendor Entity + - Vendor Model + Service: + - Config + - Vendor Config + + # Ignore anything in the Vendor layers + Vendor Model: + - Config + - Service + - Vendor Config + - Vendor Controller + - Vendor Entity + - Vendor Model + - Vendor View + Vendor Controller: + - Service + - Vendor Config + - Vendor Controller + - Vendor Entity + - Vendor Model + - Vendor View + Vendor Config: + - Config + - Service + - Vendor Config + - Vendor Controller + - Vendor Entity + - Vendor Model + - Vendor View + Vendor Entity: + - Service + - Vendor Config + - Vendor Controller + - Vendor Entity + - Vendor Model + - Vendor View + Vendor View: + - Service + - Vendor Config + - Vendor Controller + - Vendor Entity + - Vendor Model + - Vendor View + skip_violations: From 3b47c5d9e74fbaa5f2096c62d2eb48c08446f297 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 1 Sep 2022 10:23:02 +0900 Subject: [PATCH 21/71] chore: update composer scripts --- composer.json | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 28b16a6..d1fae7f 100644 --- a/composer.json +++ b/composer.json @@ -52,18 +52,21 @@ "bash -c \"if [ -f admin/setup.sh ]; then bash admin/setup.sh; fi\"" ], "analyze": "phpstan analyze", + "sa": "@analyze", "ci": [ "Composer\\Config::disableProcessTimeout", + "@cs", "@deduplicate", "@analyze", - "@test", "@inspect", - "@style" + "@test" ], + "cs": "php-cs-fixer fix --ansi --verbose --dry-run --diff", + "cs-fix": "php-cs-fixer fix --ansi --verbose --diff --using-cache=yes", + "style": "@cs-fix", "deduplicate": "phpcpd app/ src/", "inspect": "deptrac analyze --cache-file=build/deptrac.cache", "mutate": "infection --threads=2 --skip-initial-tests --coverage=build/phpunit", - "style": "php-cs-fixer fix --verbose --ansi --using-cache=no", "test": "phpunit" } } From 1de303c31281febf4c058639e04966d300e90162 Mon Sep 17 00:00:00 2001 From: MGatner Date: Thu, 1 Sep 2022 16:06:25 +0000 Subject: [PATCH 22/71] Switch to DevKit --- .github/workflows/deptrac.yml | 2 +- .github/workflows/phpcpd.yml | 2 +- .github/workflows/phpcsfixer.yml | 56 +++++++++++++++ .github/workflows/psalm.yml | 71 ++++++++++++++++++ .github/workflows/rector.yml | 67 +++++++++++++++++ .github/workflows/unused.yml | 8 +-- .php-cs-fixer.dist.php | 5 +- SECURITY.md | 2 +- composer-unused.php | 15 ++++ composer.json | 32 +++++---- deptrac.yaml | 4 +- infection.json.dist | 4 +- phpstan.neon.dist | 4 +- phpunit.xml.dist | 10 +-- psalm.xml | 18 +++++ psalm_autoload.php | 25 +++++++ rector.php | 120 +++++++++++++++++++++++++++++++ 17 files changed, 410 insertions(+), 35 deletions(-) create mode 100644 .github/workflows/phpcsfixer.yml create mode 100644 .github/workflows/psalm.yml create mode 100644 .github/workflows/rector.yml create mode 100644 composer-unused.php create mode 100644 psalm.xml create mode 100644 psalm_autoload.php create mode 100644 rector.php diff --git a/.github/workflows/deptrac.yml b/.github/workflows/deptrac.yml index 441c74d..c077f72 100644 --- a/.github/workflows/deptrac.yml +++ b/.github/workflows/deptrac.yml @@ -31,7 +31,7 @@ jobs: - name: Set up PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.0' + php-version: '8.1' tools: phive extensions: intl, json, mbstring, xml coverage: none diff --git a/.github/workflows/phpcpd.yml b/.github/workflows/phpcpd.yml index d6a877d..41abe9a 100644 --- a/.github/workflows/phpcpd.yml +++ b/.github/workflows/phpcpd.yml @@ -27,7 +27,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.0' + php-version: '8.1' tools: phpcpd extensions: dom, mbstring coverage: none diff --git a/.github/workflows/phpcsfixer.yml b/.github/workflows/phpcsfixer.yml new file mode 100644 index 0000000..3b1265e --- /dev/null +++ b/.github/workflows/phpcsfixer.yml @@ -0,0 +1,56 @@ +name: PHPCSFixer + +on: + pull_request: + branches: + - develop + paths: + - '**.php' + - '.github/workflows/phpcsfixer.yml' + push: + branches: + - develop + paths: + - '**.php' + - '.github/workflows/phpcsfixer.yml' + +jobs: + build: + name: Coding Standards + runs-on: ubuntu-latest + if: "!contains(github.event.head_commit.message, '[ci skip]')" + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set up PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.1' + extensions: json, tokenizer + coverage: none + env: + COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Get composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Cache composer dependencies + uses: actions/cache@v3 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Install dependencies + run: | + if [ -f composer.lock ]; then + composer install --no-progress --no-interaction --prefer-dist --optimize-autoloader + else + composer update --no-progress --no-interaction --prefer-dist --optimize-autoloader + fi + + - name: Check code for standards compliance + run: vendor/bin/php-cs-fixer fix --verbose --ansi --dry-run --using-cache=no --diff diff --git a/.github/workflows/psalm.yml b/.github/workflows/psalm.yml new file mode 100644 index 0000000..5e6ccf6 --- /dev/null +++ b/.github/workflows/psalm.yml @@ -0,0 +1,71 @@ +name: Psalm + +on: + pull_request: + branches: + - develop + paths: + - '**.php' + - 'composer.*' + - 'psalm*' + - '.github/workflows/psalm.yml' + push: + branches: + - develop + paths: + - '**.php' + - 'composer.*' + - 'psalm*' + - '.github/workflows/psalm.yml' + +jobs: + build: + name: Psalm Analysis + runs-on: ubuntu-latest + if: "!contains(github.event.head_commit.message, '[ci skip]')" + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.1' + tools: phpstan, phpunit + extensions: intl, json, mbstring, xml + coverage: none + env: + COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Get composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Cache composer dependencies + uses: actions/cache@v3 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Create Psalm cache directory + run: mkdir -p build/psalm + + - name: Cache Psalm results + uses: actions/cache@v3 + with: + path: build/psalm + key: ${{ runner.os }}-psalm-${{ github.sha }} + restore-keys: ${{ runner.os }}-psalm- + + - name: Install dependencies + run: | + if [ -f composer.lock ]; then + composer install --no-progress --no-interaction --prefer-dist --optimize-autoloader + else + composer update --no-progress --no-interaction --prefer-dist --optimize-autoloader + fi + + - name: Run Psalm analysis + run: vendor/bin/psalm diff --git a/.github/workflows/rector.yml b/.github/workflows/rector.yml new file mode 100644 index 0000000..c09365d --- /dev/null +++ b/.github/workflows/rector.yml @@ -0,0 +1,67 @@ +name: Rector + +on: + pull_request: + branches: + - develop + paths: + - '**.php' + - 'composer.*' + - 'rector.php' + - '.github/workflows/rector.yml' + push: + branches: + - develop + paths: + - '**.php' + - 'composer.*' + - 'rector.php' + - '.github/workflows/rector.yml' + +jobs: + build: + name: PHP ${{ matrix.php-versions }} Rector Analysis + runs-on: ubuntu-latest + if: "!contains(github.event.head_commit.message, '[ci skip]')" + strategy: + fail-fast: false + matrix: + php-versions: ['7.4', '8.0', '8.1'] + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set up PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + tools: phpstan + extensions: intl, json, mbstring, xml + coverage: none + env: + COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Get composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Cache composer dependencies + uses: actions/cache@v3 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Install dependencies + run: | + if [ -f composer.lock ]; then + composer install --no-progress --no-interaction --prefer-dist --optimize-autoloader + else + composer update --no-progress --no-interaction --prefer-dist --optimize-autoloader + fi + + - name: Analyze for refactoring + run: | + composer global require --dev rector/rector:^0.14 + rector process --dry-run --no-progress-bar diff --git a/.github/workflows/unused.yml b/.github/workflows/unused.yml index c3b23d9..b83ccb9 100644 --- a/.github/workflows/unused.yml +++ b/.github/workflows/unused.yml @@ -1,5 +1,3 @@ -# When a PR is opened or a push is made, check code -# for unused packages with Composer Unused. name: Unused on: @@ -31,7 +29,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.0' + php-version: '8.1' tools: composer, composer-unused extensions: intl, json, mbstring, xml coverage: none @@ -52,9 +50,9 @@ jobs: - name: Install dependencies run: | if [ -f composer.lock ]; then - composer install --no-progress --no-interaction --prefer-dist --optimize-autoloader + composer install --no-progress --no-interaction --prefer-dist --optimize-autoloader else - composer update --no-progress --no-interaction --prefer-dist --optimize-autoloader + composer update --no-progress --no-interaction --prefer-dist --optimize-autoloader fi - name: Detect unused packages diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index dfa45af..1185b9c 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -6,7 +6,10 @@ $finder = Finder::create() ->files() - ->in(__DIR__) + ->in([ + __DIR__ . '/src/', + __DIR__ . '/tests/', + ]) ->exclude('build') ->append([__FILE__]); diff --git a/SECURITY.md b/SECURITY.md index 81800d9..7879188 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -6,7 +6,7 @@ The development team and community take all security issues seriously. **Please Thank you for improving the security of our code! Any assistance in removing security flaws will be acknowledged. -**Please report security flaws by emailing the development team directly: **security@codeigniter.com**. +**Please report security flaws by emailing the development team directly: security@codeigniter.com**. The lead maintainer will acknowledge your email within 48 hours, and will send a more detailed response within 48 hours indicating the next steps in handling your report. After the initial reply to your report, the security team will endeavor to keep you informed of the diff --git a/composer-unused.php b/composer-unused.php new file mode 100644 index 0000000..6ba235a --- /dev/null +++ b/composer-unused.php @@ -0,0 +1,15 @@ + $config + // ->addNamedFilter(NamedFilter::fromString('symfony/config')) + // ->addPatternFilter(PatternFilter::fromString('/symfony-.*/')) + ->setAdditionalFilesFor('codeigniter4/framework', [ + ...Glob::glob(__DIR__ . '/vendor/codeigniter4/framework/system/Helpers/*.php'), + ]); diff --git a/composer.json b/composer.json index d1fae7f..e1416f2 100644 --- a/composer.json +++ b/composer.json @@ -1,14 +1,13 @@ { "name": "codeigniter4/settings", - "type": "library", "description": "Settings library for CodeIgniter 4", + "license": "MIT", + "type": "library", "keywords": [ "codeigniter", "codeigniter4", "settings" ], - "homepage": "https://github.com/codeigniter4/settings", - "license": "MIT", "authors": [ { "name": "Lonnie Ezell", @@ -16,21 +15,17 @@ "role": "Developer" } ], + "homepage": "https://github.com/codeigniter4/settings", "require": { "php": "^7.4 || ^8.0" }, "require-dev": { - "codeigniter/coding-standard": "^1.1", + "codeigniter4/devkit": "^1.0", "codeigniter4/framework": "^4.2.3", - "fakerphp/faker": "^1.9", - "mockery/mockery": "^1.0", - "nexusphp/cs-config": "^3.1", - "nexusphp/tachycardia": "^1.0", - "php-coveralls/php-coveralls": "^2.4", - "phpstan/phpstan": "^1.0", - "phpunit/phpunit": "^9.0", - "squizlabs/php_codesniffer": "^3.3" + "rector/rector": "0.14" }, + "minimum-stability": "dev", + "prefer-stable": true, "autoload": { "psr-4": { "CodeIgniter\\Settings\\": "src" @@ -45,13 +40,20 @@ "Tests\\Support\\": "tests/_support" } }, - "minimum-stability": "dev", - "prefer-stable": true, + "config": { + "allow-plugins": { + "phpstan/extension-installer": true + } + }, "scripts": { "post-update-cmd": [ "bash -c \"if [ -f admin/setup.sh ]; then bash admin/setup.sh; fi\"" ], - "analyze": "phpstan analyze", + "analyze": [ + "phpstan analyze", + "psalm", + "rector process --dry-run" + ], "sa": "@analyze", "ci": [ "Composer\\Config::disableProcessTimeout", diff --git a/deptrac.yaml b/deptrac.yaml index 3b8c5ef..ea116b1 100644 --- a/deptrac.yaml +++ b/deptrac.yaml @@ -1,7 +1,7 @@ parameters: paths: - - ./src - - ./vendor/codeigniter4/framework/system + - ./src/ + - ./vendor/codeigniter4/framework/system/ exclude_files: - '#.*test.*#i' layers: diff --git a/infection.json.dist b/infection.json.dist index b175102..7badcc6 100644 --- a/infection.json.dist +++ b/infection.json.dist @@ -1,7 +1,7 @@ { "source": { "directories": [ - "src" + "src/" ], "excludes": [ "Config", @@ -15,5 +15,5 @@ "mutators": { "@default": true }, - "bootstrap": "vendor/codeigniter4/codeigniter4/system/Test/bootstrap.php" + "bootstrap": "vendor/codeigniter4/framework/system/Test/bootstrap.php" } diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 60fc715..f27f414 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -2,8 +2,8 @@ parameters: tmpDir: build/phpstan level: 5 paths: - - src - - tests + - src/ + - tests/ bootstrapFiles: - vendor/codeigniter4/framework/system/Test/bootstrap.php excludePaths: diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 6204cc6..ac88cfc 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,6 +1,6 @@ - ./src + ./src/ + ./src/Config ./src/Views - ./src/Config/Routes.php @@ -37,7 +37,7 @@ - + ./tests @@ -74,7 +74,7 @@ - + diff --git a/psalm.xml b/psalm.xml new file mode 100644 index 0000000..386f4dc --- /dev/null +++ b/psalm.xml @@ -0,0 +1,18 @@ + + + + + + + + + + diff --git a/psalm_autoload.php b/psalm_autoload.php new file mode 100644 index 0000000..d9b911f --- /dev/null +++ b/psalm_autoload.php @@ -0,0 +1,25 @@ +sets([SetList::DEAD_CODE, LevelSetList::UP_TO_PHP_74, PHPUnitSetList::PHPUNIT_SPECIFIC_METHOD, PHPUnitSetList::PHPUNIT_80]); + $rectorConfig->parallel(); + // The paths to refactor (can also be supplied with CLI arguments) + $rectorConfig->paths([ + __DIR__ . '/src/', + __DIR__ . '/tests/', + ]); + + // Include Composer's autoload - required for global execution, remove if running locally + $rectorConfig->autoloadPaths([ + __DIR__ . '/vendor/autoload.php', + ]); + + // Do you need to include constants, class aliases, or a custom autoloader? + $rectorConfig->bootstrapFiles([ + realpath(getcwd()) . '/vendor/codeigniter4/framework/system/Test/bootstrap.php', + ]); + + if (is_file(__DIR__ . '/phpstan.neon.dist')) { + $rectorConfig->phpstanConfig(__DIR__ . '/phpstan.neon.dist'); + } + + // Set the target version for refactoring + $rectorConfig->phpVersion(PhpVersion::PHP_74); + + // Auto-import fully qualified class names + $rectorConfig->importNames(); + + // Are there files or rules you need to skip? + $rectorConfig->skip([ + __DIR__ . '/src/Views', + + JsonThrowOnErrorRector::class, + StringifyStrNeedlesRector::class, + + // Note: requires php 8 + RemoveUnusedPromotedPropertyRector::class, + + // Ignore tests that might make calls without a result + RemoveEmptyMethodCallRector::class => [ + __DIR__ . '/tests', + ], + + // Ignore files that should not be namespaced + NormalizeNamespaceByPSR4ComposerAutoloadRector::class => [ + __DIR__ . '/src/Helpers', + ], + + // May load view files directly when detecting classes + StringClassNameToClassConstantRector::class, + + // May be uninitialized on purpose + AddDefaultValueForUndefinedVariableRector::class, + ]); + $rectorConfig->rule(SimplifyUselessVariableRector::class); + $rectorConfig->rule(RemoveAlwaysElseRector::class); + $rectorConfig->rule(CountArrayToEmptyArrayComparisonRector::class); + $rectorConfig->rule(ForToForeachRector::class); + $rectorConfig->rule(ChangeNestedForeachIfsToEarlyContinueRector::class); + $rectorConfig->rule(ChangeIfElseValueAssignToEarlyReturnRector::class); + $rectorConfig->rule(SimplifyStrposLowerRector::class); + $rectorConfig->rule(CombineIfRector::class); + $rectorConfig->rule(SimplifyIfReturnBoolRector::class); + $rectorConfig->rule(InlineIfToExplicitIfRector::class); + $rectorConfig->rule(PreparedValueToEarlyReturnRector::class); + $rectorConfig->rule(ShortenElseIfRector::class); + $rectorConfig->rule(SimplifyIfElseToTernaryRector::class); + $rectorConfig->rule(UnusedForeachValueToArrayKeysRector::class); + $rectorConfig->rule(ChangeArrayPushToArrayAssignRector::class); + $rectorConfig->rule(UnnecessaryTernaryExpressionRector::class); + $rectorConfig->rule(AddPregQuoteDelimiterRector::class); + $rectorConfig->rule(SimplifyRegexPatternRector::class); + $rectorConfig->rule(FuncGetArgsToVariadicParamRector::class); + $rectorConfig->rule(MakeInheritedMethodVisibilitySameAsParentRector::class); + $rectorConfig->rule(SimplifyEmptyArrayCheckRector::class); + $rectorConfig->rule(NormalizeNamespaceByPSR4ComposerAutoloadRector::class); + $rectorConfig + ->ruleWithConfiguration(TypedPropertyRector::class, [ + // Set to false if you use in libraries, or it does create breaking changes. + TypedPropertyRector::INLINE_PUBLIC => false, + ]); +}; From 024ac1432094909469ad0dcb880ab2de4ab5154c Mon Sep 17 00:00:00 2001 From: MGatner Date: Thu, 1 Sep 2022 16:44:36 +0000 Subject: [PATCH 23/71] Apply Rector --- rector.php | 1 + src/Handlers/ArrayHandler.php | 12 ++++-------- src/Handlers/DatabaseHandler.php | 4 +--- src/Settings.php | 4 ++-- tests/HelperTest.php | 2 +- 5 files changed, 9 insertions(+), 14 deletions(-) diff --git a/rector.php b/rector.php index 53b78ab..d925df3 100644 --- a/rector.php +++ b/rector.php @@ -82,6 +82,7 @@ // Ignore files that should not be namespaced NormalizeNamespaceByPSR4ComposerAutoloadRector::class => [ __DIR__ . '/src/Helpers', + __DIR__ . '/tests/_support', ], // May load view files directly when detecting classes diff --git a/src/Handlers/ArrayHandler.php b/src/Handlers/ArrayHandler.php index 60b1cce..b78bfdb 100644 --- a/src/Handlers/ArrayHandler.php +++ b/src/Handlers/ArrayHandler.php @@ -17,7 +17,7 @@ class ArrayHandler extends BaseHandler * * @var array> */ - private $general = []; + private array $general = []; /** * Storage for context settings. @@ -25,7 +25,7 @@ class ArrayHandler extends BaseHandler * * @var array */ - private $contexts = []; + private array $contexts = []; public function has(string $class, string $property, ?string $context = null): bool { @@ -53,14 +53,10 @@ public function forget(string $class, string $property, ?string $context = null) protected function hasStored(string $class, string $property, ?string $context): bool { if ($context === null) { - return isset($this->general[$class]) - ? array_key_exists($property, $this->general[$class]) - : false; + return isset($this->general[$class]) && array_key_exists($property, $this->general[$class]); } - return isset($this->contexts[$context][$class]) - ? array_key_exists($property, $this->contexts[$context][$class]) - : false; + return isset($this->contexts[$context][$class]) && array_key_exists($property, $this->contexts[$context][$class]); } /** diff --git a/src/Handlers/DatabaseHandler.php b/src/Handlers/DatabaseHandler.php index ef136d3..cd35583 100644 --- a/src/Handlers/DatabaseHandler.php +++ b/src/Handlers/DatabaseHandler.php @@ -13,10 +13,8 @@ class DatabaseHandler extends ArrayHandler { /** * The database table to use. - * - * @var string */ - private $table; + private string $table; /** * Array of contexts that have been stored. diff --git a/src/Settings.php b/src/Settings.php index 1fe1237..dd3e7e8 100644 --- a/src/Settings.php +++ b/src/Settings.php @@ -19,7 +19,7 @@ class Settings * * @var BaseHandler[] */ - private $handlers = []; + private array $handlers = []; /** * An array of the config options for each handler. @@ -55,7 +55,7 @@ public function get(string $key, ?string $context = null) [$class, $property, $config] = $this->prepareClassAndProperty($key); // Check each of our handlers - foreach ($this->handlers as $name => $handler) { + foreach ($this->handlers as $handler) { if ($handler->has($class, $property, $context)) { return $handler->get($class, $property, $context); } diff --git a/tests/HelperTest.php b/tests/HelperTest.php index a058c00..9ac17ea 100644 --- a/tests/HelperTest.php +++ b/tests/HelperTest.php @@ -1,6 +1,6 @@ Date: Thu, 1 Sep 2022 16:50:39 +0000 Subject: [PATCH 24/71] Disable RoaveBC workflow --- .github/workflows/compare.yml | 25 ------------------------- 1 file changed, 25 deletions(-) delete mode 100644 .github/workflows/compare.yml diff --git a/.github/workflows/compare.yml b/.github/workflows/compare.yml deleted file mode 100644 index 98697a3..0000000 --- a/.github/workflows/compare.yml +++ /dev/null @@ -1,25 +0,0 @@ -# When a PR is opened or a push is made, compare -# code for backwards compatibility. -name: RoaveBC - -on: - pull_request: - branches: - - develop - paths: - - 'src/**' - -jobs: - compare: - name: Compare for Backwards Compatibility - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Run comparison (authenticated) - if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name }} - uses: docker://nyholm/roave-bc-check-ga - env: - COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }} From 8065827f3fa20393b895e250901fd00104676622 Mon Sep 17 00:00:00 2001 From: daycry <7590335+daycry@users.noreply.github.com> Date: Fri, 2 Sep 2022 00:37:30 +0200 Subject: [PATCH 25/71] - remove private method --- .../Migrations/2021-07-04-041948_CreateSettingsTable.php | 7 +------ .../Migrations/2021-11-14-143905_AddContextColumn.php | 7 +------ 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/src/Database/Migrations/2021-07-04-041948_CreateSettingsTable.php b/src/Database/Migrations/2021-07-04-041948_CreateSettingsTable.php index 21201c9..abe84b9 100644 --- a/src/Database/Migrations/2021-07-04-041948_CreateSettingsTable.php +++ b/src/Database/Migrations/2021-07-04-041948_CreateSettingsTable.php @@ -12,7 +12,7 @@ class CreateSettingsTable extends Migration public function __construct(?Forge $forge = null) { - $this->config = $this->_getConfig(); + $this->config = config('Settings'); $this->DBGroup = (isset($this->config->database['group']) && $this->config->database['group']) ? $this->config->database['group'] : null; parent::__construct($forge); @@ -51,11 +51,6 @@ public function up() $this->forge->createTable(config('Settings')->database['table'], true); } - private function _getConfig() - { - return config('Settings'); - } - public function down() { $this->forge->dropTable(config('Settings')->database['table']); diff --git a/src/Database/Migrations/2021-11-14-143905_AddContextColumn.php b/src/Database/Migrations/2021-11-14-143905_AddContextColumn.php index f0dcf00..ad0f3c8 100644 --- a/src/Database/Migrations/2021-11-14-143905_AddContextColumn.php +++ b/src/Database/Migrations/2021-11-14-143905_AddContextColumn.php @@ -12,7 +12,7 @@ class AddContextColumn extends Migration public function __construct(?Forge $forge = null) { - $this->config = $this->_getConfig(); + $this->config = config('Settings'); $this->DBGroup = (isset($this->config->database['group']) && $this->config->database['group']) ? $this->config->database['group'] : null; parent::__construct($forge); @@ -30,11 +30,6 @@ public function up() ]); } - private function _getConfig() - { - return config('Settings'); - } - public function down() { $this->forge->dropColumn(config('Settings')->database['table'], 'context'); From 3080c6be2fdf83c90306d1f2ab356d916769a214 Mon Sep 17 00:00:00 2001 From: daycry <7590335+daycry@users.noreply.github.com> Date: Sat, 3 Sep 2022 11:10:32 +0200 Subject: [PATCH 26/71] Update src/Database/Migrations/2021-11-14-143905_AddContextColumn.php This may break backwards compatibility as if it doesn't check if it exists it will return error, because group doesn't currently exist. Co-authored-by: MGatner --- src/Database/Migrations/2021-11-14-143905_AddContextColumn.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Database/Migrations/2021-11-14-143905_AddContextColumn.php b/src/Database/Migrations/2021-11-14-143905_AddContextColumn.php index ad0f3c8..8e4c715 100644 --- a/src/Database/Migrations/2021-11-14-143905_AddContextColumn.php +++ b/src/Database/Migrations/2021-11-14-143905_AddContextColumn.php @@ -13,7 +13,7 @@ class AddContextColumn extends Migration public function __construct(?Forge $forge = null) { $this->config = config('Settings'); - $this->DBGroup = (isset($this->config->database['group']) && $this->config->database['group']) ? $this->config->database['group'] : null; + $this->DBGroup = $this->config->database['group']; parent::__construct($forge); } From 136734ac307c2aca761336a005aec6295db82e2e Mon Sep 17 00:00:00 2001 From: daycry <7590335+daycry@users.noreply.github.com> Date: Sat, 3 Sep 2022 11:27:00 +0200 Subject: [PATCH 27/71] - Testing --- .../2021-07-04-041948_CreateSettingsTable.php | 6 +-- .../2021-11-14-143905_AddContextColumn.php | 6 +-- tests/DatabaseHandlerTest.php | 38 +++++++++++++++++++ 3 files changed, 40 insertions(+), 10 deletions(-) diff --git a/src/Database/Migrations/2021-07-04-041948_CreateSettingsTable.php b/src/Database/Migrations/2021-07-04-041948_CreateSettingsTable.php index abe84b9..26627ab 100644 --- a/src/Database/Migrations/2021-07-04-041948_CreateSettingsTable.php +++ b/src/Database/Migrations/2021-07-04-041948_CreateSettingsTable.php @@ -2,18 +2,14 @@ namespace CodeIgniter\Settings\Database\Migrations; -use CodeIgniter\Config\BaseConfig; use CodeIgniter\Database\Forge; use CodeIgniter\Database\Migration; class CreateSettingsTable extends Migration { - private BaseConfig $config; - public function __construct(?Forge $forge = null) { - $this->config = config('Settings'); - $this->DBGroup = (isset($this->config->database['group']) && $this->config->database['group']) ? $this->config->database['group'] : null; + $this->DBGroup = config('Settings')->database['group'] ?? null; parent::__construct($forge); } diff --git a/src/Database/Migrations/2021-11-14-143905_AddContextColumn.php b/src/Database/Migrations/2021-11-14-143905_AddContextColumn.php index ad0f3c8..26ee063 100644 --- a/src/Database/Migrations/2021-11-14-143905_AddContextColumn.php +++ b/src/Database/Migrations/2021-11-14-143905_AddContextColumn.php @@ -2,18 +2,14 @@ namespace CodeIgniter\Settings\Database\Migrations; -use CodeIgniter\Config\BaseConfig; use CodeIgniter\Database\Forge; use CodeIgniter\Database\Migration; class AddContextColumn extends Migration { - private BaseConfig $config; - public function __construct(?Forge $forge = null) { - $this->config = config('Settings'); - $this->DBGroup = (isset($this->config->database['group']) && $this->config->database['group']) ? $this->config->database['group'] : null; + $this->DBGroup = config('Settings')->database['group'] ?? null; parent::__construct($forge); } diff --git a/tests/DatabaseHandlerTest.php b/tests/DatabaseHandlerTest.php index fb603eb..564c94b 100644 --- a/tests/DatabaseHandlerTest.php +++ b/tests/DatabaseHandlerTest.php @@ -22,6 +22,11 @@ final class DatabaseHandlerTest extends TestCase */ protected $table; + /** + * @var string + */ + protected $group; + /** * Ensures we are using the database handler. */ @@ -34,7 +39,9 @@ protected function setUp(): void $this->settings = new Settings($config); $this->table = $config->database['table']; + $this->group = $config->database['group']; } + public function testSetInsertsNewRows() { @@ -48,6 +55,37 @@ public function testSetInsertsNewRows() ]); } + public function testInvalidGroup() + { + $this->expectException(\InvalidArgumentException::class); + + $config = config('Settings'); + $config->handlers = ['database']; + $config->database['group'] = 'another'; + + $this->settings = new Settings($config); + + $this->settings->set('Test.siteName', true); + } + + public function testSetDefaultGroup() + { + $config = config('Settings'); + $config->handlers = ['database']; + $config->database['group'] = 'default'; + + $this->settings->set('Test.siteName', true); + + $this->seeInDatabase($this->table, [ + 'class' => 'Tests\Support\Config\Test', + 'key' => 'siteName', + 'value' => '1', + 'type' => 'boolean', + ]); + + $this->assertTrue($this->settings->get('Test.siteName')); + } + public function testSetInsertsBoolTrue() { $this->settings->set('Test.siteName', true); From 02611357f5aa497f9398b25d17dc01f3db658bb0 Mon Sep 17 00:00:00 2001 From: daycry <7590335+daycry@users.noreply.github.com> Date: Sat, 3 Sep 2022 11:28:49 +0200 Subject: [PATCH 28/71] Update DatabaseHandlerTest.php --- tests/DatabaseHandlerTest.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/DatabaseHandlerTest.php b/tests/DatabaseHandlerTest.php index 564c94b..251d149 100644 --- a/tests/DatabaseHandlerTest.php +++ b/tests/DatabaseHandlerTest.php @@ -5,6 +5,7 @@ use CodeIgniter\I18n\Time; use CodeIgniter\Settings\Settings; use CodeIgniter\Test\DatabaseTestTrait; +use InvalidArgumentException; use Tests\Support\TestCase; /** @@ -41,7 +42,6 @@ protected function setUp(): void $this->table = $config->database['table']; $this->group = $config->database['group']; } - public function testSetInsertsNewRows() { @@ -57,10 +57,10 @@ public function testSetInsertsNewRows() public function testInvalidGroup() { - $this->expectException(\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); - $config = config('Settings'); - $config->handlers = ['database']; + $config = config('Settings'); + $config->handlers = ['database']; $config->database['group'] = 'another'; $this->settings = new Settings($config); @@ -70,8 +70,8 @@ public function testInvalidGroup() public function testSetDefaultGroup() { - $config = config('Settings'); - $config->handlers = ['database']; + $config = config('Settings'); + $config->handlers = ['database']; $config->database['group'] = 'default'; $this->settings->set('Test.siteName', true); From 507b34091faf51f76c72121f3e45d77617b34f9d Mon Sep 17 00:00:00 2001 From: daycry <7590335+daycry@users.noreply.github.com> Date: Mon, 5 Sep 2022 09:42:29 +0200 Subject: [PATCH 29/71] . Refactoring --- src/Handlers/DatabaseHandler.php | 33 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/src/Handlers/DatabaseHandler.php b/src/Handlers/DatabaseHandler.php index 05bb8cb..f5d94eb 100644 --- a/src/Handlers/DatabaseHandler.php +++ b/src/Handlers/DatabaseHandler.php @@ -2,6 +2,7 @@ namespace CodeIgniter\Settings\Handlers; +use CodeIgniter\Database\BaseBuilder; use CodeIgniter\I18n\Time; use RuntimeException; @@ -12,18 +13,9 @@ class DatabaseHandler extends ArrayHandler { /** - * The database table to use. - * - * @var string - */ - private $table; - - /** - * The database group to use. - * - * @var string + * The Query Builder for the Settings table. */ - private $group; + private BaseBuilder $builder; /** * Array of contexts that have been stored. @@ -37,8 +29,7 @@ class DatabaseHandler extends ArrayHandler */ public function __construct() { - $this->table = config('Settings')->database['table'] ?? 'settings'; - $this->group = config('Settings')->database['group'] ?? null; + $this->builder = $builder ?? db_connect(config('Settings')->database['group'])->table(config('Settings')->database['table']); } /** @@ -81,7 +72,7 @@ public function set(string $class, string $property, $value = null, ?string $con // If it was stored then we need to update if ($this->has($class, $property, $context)) { - $result = db_connect($this->group)->table($this->table) + $result = $this->builder ->where('class', $class) ->where('key', $property) ->where('context', $context) @@ -93,7 +84,7 @@ public function set(string $class, string $property, $value = null, ?string $con ]); // ...otherwise insert it } else { - $result = db_connect($this->group)->table($this->table) + $result = $this->builder ->insert([ 'class' => $class, 'key' => $property, @@ -106,7 +97,7 @@ public function set(string $class, string $property, $value = null, ?string $con } if ($result !== true) { - throw new RuntimeException(db_connect($this->group)->error()['message'] ?? 'Error writing to the database.'); + throw new RuntimeException(db_connect(config('Settings')->database['group'])->error()['message'] ?? 'Error writing to the database.'); } // Update storage @@ -124,14 +115,14 @@ public function forget(string $class, string $property, ?string $context = null) $this->hydrate($context); // Delete from the database - $result = db_connect($this->group)->table($this->table) + $result = $this->builder ->where('class', $class) ->where('key', $property) ->where('context', $context) ->delete(); if (! $result) { - throw new RuntimeException(db_connect($this->group)->error()['message'] ?? 'Error writing to the database.'); + throw new RuntimeException(db_connect(config('Settings')->database['group'])->error()['message'] ?? 'Error writing to the database.'); } // Delete from local storage @@ -155,9 +146,9 @@ private function hydrate(?string $context): void if ($context === null) { $this->hydrated[] = null; - $query = db_connect($this->group)->table($this->table)->where('context', null); + $query = $this->builder->where('context', null); } else { - $query = db_connect($this->group)->table($this->table)->where('context', $context); + $query = $this->builder->where('context', $context); // If general has not been hydrated we will do that at the same time if (! in_array(null, $this->hydrated, true)) { @@ -169,7 +160,7 @@ private function hydrate(?string $context): void } if (is_bool($result = $query->get())) { - throw new RuntimeException(db_connect($this->group)->error()['message'] ?? 'Error reading from database.'); + throw new RuntimeException(db_connect(config('Settings')->database['group'])->error()['message'] ?? 'Error reading from database.'); } foreach ($result->getResultObject() as $row) { From 79406edfb26a76d5422b570f508867fc4caa03be Mon Sep 17 00:00:00 2001 From: daycry <7590335+daycry@users.noreply.github.com> Date: Mon, 5 Sep 2022 10:10:07 +0200 Subject: [PATCH 30/71] Update DatabaseHandler.php --- src/Handlers/DatabaseHandler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Handlers/DatabaseHandler.php b/src/Handlers/DatabaseHandler.php index f5d94eb..78f5b72 100644 --- a/src/Handlers/DatabaseHandler.php +++ b/src/Handlers/DatabaseHandler.php @@ -29,7 +29,7 @@ class DatabaseHandler extends ArrayHandler */ public function __construct() { - $this->builder = $builder ?? db_connect(config('Settings')->database['group'])->table(config('Settings')->database['table']); + $this->builder = db_connect(config('Settings')->database['group'])->table(config('Settings')->database['table']); } /** From 7e6538dad66ccbfa4cb4fbfebef535d9bbd0a3c1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 Sep 2022 14:48:05 +0000 Subject: [PATCH 31/71] chore(deps-dev): update rector/rector requirement from 0.14 to 0.14.2 Updates the requirements on [rector/rector](https://github.com/rectorphp/rector) to permit the latest version. - [Release notes](https://github.com/rectorphp/rector/releases) - [Commits](https://github.com/rectorphp/rector/compare/0.14.0...0.14.2) --- updated-dependencies: - dependency-name: rector/rector dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index e1416f2..5811213 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "require-dev": { "codeigniter4/devkit": "^1.0", "codeigniter4/framework": "^4.2.3", - "rector/rector": "0.14" + "rector/rector": "0.14.2" }, "minimum-stability": "dev", "prefer-stable": true, From 21edc595135eea85991bc07096c12147137882b5 Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 9 Sep 2022 15:37:13 +0900 Subject: [PATCH 32/71] docs: add CONTRIBUTING.md --- CONTRIBUTING.md | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..b712dd6 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,10 @@ +# Contributing to CodeIgniter4 + +CodeIgniter is a community driven project and accepts contributions of +code and documentation from the community. + +If you'd like to contribute, please read [Contributing to CodeIgniter](https://github.com/codeigniter4/CodeIgniter4/blob/develop/contributing/README.md) +in the [main repository](https://github.com/codeigniter4/CodeIgniter4). + +If you are going to contribute to this repository, please report bugs or send PRs +to this repository instead of the main repository. From 7d5636c619a0b1f8296485e57b3dbc158dd60290 Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 21 Sep 2022 11:13:25 +0900 Subject: [PATCH 33/71] style: composer cs-fix Because of update of coding standard. --- src/Handlers/BaseHandler.php | 8 ++++---- src/Handlers/DatabaseHandler.php | 4 ++-- src/Settings.php | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Handlers/BaseHandler.php b/src/Handlers/BaseHandler.php index cf2a22c..6ec86a7 100644 --- a/src/Handlers/BaseHandler.php +++ b/src/Handlers/BaseHandler.php @@ -26,9 +26,9 @@ abstract public function get(string $class, string $property, ?string $context = * * @param mixed $value * - * @throws RuntimeException - * * @return void + * + * @throws RuntimeException */ public function set(string $class, string $property, $value = null, ?string $context = null) { @@ -41,9 +41,9 @@ public function set(string $class, string $property, $value = null, ?string $con * Not all Handlers will support writing values. * Must throw RuntimeException for any failures. * - * @throws RuntimeException - * * @return void + * + * @throws RuntimeException */ public function forget(string $class, string $property, ?string $context = null) { diff --git a/src/Handlers/DatabaseHandler.php b/src/Handlers/DatabaseHandler.php index 78f5b72..abeffda 100644 --- a/src/Handlers/DatabaseHandler.php +++ b/src/Handlers/DatabaseHandler.php @@ -60,9 +60,9 @@ public function get(string $class, string $property, ?string $context = null) * * @param mixed $value * - * @throws RuntimeException For database failures - * * @return void + * + * @throws RuntimeException For database failures */ public function set(string $class, string $property, $value = null, ?string $context = null) { diff --git a/src/Settings.php b/src/Settings.php index dd3e7e8..9da736c 100644 --- a/src/Settings.php +++ b/src/Settings.php @@ -104,9 +104,9 @@ public function forget(string $key, ?string $context = null) /** * Returns the handler that is set to store values. * - * @throws RuntimeException - * * @return BaseHandler[] + * + * @throws RuntimeException */ private function getWriteHandlers() { @@ -128,9 +128,9 @@ private function getWriteHandlers() /** * Analyzes the given key and breaks it into the class.field parts. * - * @throws InvalidArgumentException - * * @return string[] + * + * @throws InvalidArgumentException */ private function parseDotSyntax(string $key): array { From 09ea35f7dd36db130f732750a02df62c01c81b4c Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 21 Sep 2022 11:22:22 +0900 Subject: [PATCH 34/71] refactor: add property $config --- .../2021-07-04-041948_CreateSettingsTable.php | 10 +++++++--- .../Migrations/2021-11-14-143905_AddContextColumn.php | 10 +++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/Database/Migrations/2021-07-04-041948_CreateSettingsTable.php b/src/Database/Migrations/2021-07-04-041948_CreateSettingsTable.php index 26627ab..eb45235 100644 --- a/src/Database/Migrations/2021-07-04-041948_CreateSettingsTable.php +++ b/src/Database/Migrations/2021-07-04-041948_CreateSettingsTable.php @@ -4,12 +4,16 @@ use CodeIgniter\Database\Forge; use CodeIgniter\Database\Migration; +use CodeIgniter\Settings\Config\Settings; class CreateSettingsTable extends Migration { + private Settings $config; + public function __construct(?Forge $forge = null) { - $this->DBGroup = config('Settings')->database['group'] ?? null; + $this->config = config('Settings'); + $this->DBGroup = $this->config->database['group'] ?? null; parent::__construct($forge); } @@ -44,11 +48,11 @@ public function up() 'null' => false, ], ]); - $this->forge->createTable(config('Settings')->database['table'], true); + $this->forge->createTable($this->config->database['table'], true); } public function down() { - $this->forge->dropTable(config('Settings')->database['table']); + $this->forge->dropTable($this->config->database['table']); } } diff --git a/src/Database/Migrations/2021-11-14-143905_AddContextColumn.php b/src/Database/Migrations/2021-11-14-143905_AddContextColumn.php index 26ee063..9bf7fe2 100644 --- a/src/Database/Migrations/2021-11-14-143905_AddContextColumn.php +++ b/src/Database/Migrations/2021-11-14-143905_AddContextColumn.php @@ -4,19 +4,23 @@ use CodeIgniter\Database\Forge; use CodeIgniter\Database\Migration; +use CodeIgniter\Settings\Config\Settings; class AddContextColumn extends Migration { + private Settings $config; + public function __construct(?Forge $forge = null) { - $this->DBGroup = config('Settings')->database['group'] ?? null; + $this->config = config('Settings'); + $this->DBGroup = $this->config->database['group'] ?? null; parent::__construct($forge); } public function up() { - $this->forge->addColumn(config('Settings')->database['table'], [ + $this->forge->addColumn($this->config->database['table'], [ 'context' => [ 'type' => 'varchar', 'constraint' => 255, @@ -28,6 +32,6 @@ public function up() public function down() { - $this->forge->dropColumn(config('Settings')->database['table'], 'context'); + $this->forge->dropColumn($this->config->database['table'], 'context'); } } From a220b5cf9ddb35496bcefcc45bd82481b91c80a6 Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 21 Sep 2022 11:23:00 +0900 Subject: [PATCH 35/71] refactor: add property $config --- src/Handlers/DatabaseHandler.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Handlers/DatabaseHandler.php b/src/Handlers/DatabaseHandler.php index abeffda..6421bc7 100644 --- a/src/Handlers/DatabaseHandler.php +++ b/src/Handlers/DatabaseHandler.php @@ -4,6 +4,7 @@ use CodeIgniter\Database\BaseBuilder; use CodeIgniter\I18n\Time; +use CodeIgniter\Settings\Config\Settings; use RuntimeException; /** @@ -24,12 +25,15 @@ class DatabaseHandler extends ArrayHandler */ private $hydrated = []; + private Settings $config; + /** * Stores the configured database table. */ public function __construct() { - $this->builder = db_connect(config('Settings')->database['group'])->table(config('Settings')->database['table']); + $this->config = config('Settings'); + $this->builder = db_connect($this->config->database['group'])->table($this->config->database['table']); } /** @@ -97,7 +101,7 @@ public function set(string $class, string $property, $value = null, ?string $con } if ($result !== true) { - throw new RuntimeException(db_connect(config('Settings')->database['group'])->error()['message'] ?? 'Error writing to the database.'); + throw new RuntimeException(db_connect($this->config->database['group'])->error()['message'] ?? 'Error writing to the database.'); } // Update storage @@ -122,7 +126,7 @@ public function forget(string $class, string $property, ?string $context = null) ->delete(); if (! $result) { - throw new RuntimeException(db_connect(config('Settings')->database['group'])->error()['message'] ?? 'Error writing to the database.'); + throw new RuntimeException(db_connect($this->config->database['group'])->error()['message'] ?? 'Error writing to the database.'); } // Delete from local storage @@ -160,7 +164,7 @@ private function hydrate(?string $context): void } if (is_bool($result = $query->get())) { - throw new RuntimeException(db_connect(config('Settings')->database['group'])->error()['message'] ?? 'Error reading from database.'); + throw new RuntimeException(db_connect($this->config->database['group'])->error()['message'] ?? 'Error reading from database.'); } foreach ($result->getResultObject() as $row) { From 95012c6126c0cdc5ce47b46de021624dd12f39ac Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 21 Sep 2022 11:23:19 +0900 Subject: [PATCH 36/71] docs: add @var --- tests/DatabaseHandlerTest.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/DatabaseHandlerTest.php b/tests/DatabaseHandlerTest.php index 251d149..2244c2c 100644 --- a/tests/DatabaseHandlerTest.php +++ b/tests/DatabaseHandlerTest.php @@ -35,6 +35,7 @@ protected function setUp(): void { parent::setUp(); + /** @var \CodeIgniter\Settings\Config\Settings $config */ $config = config('Settings'); $config->handlers = ['database']; @@ -59,6 +60,7 @@ public function testInvalidGroup() { $this->expectException(InvalidArgumentException::class); + /** @var \CodeIgniter\Settings\Config\Settings $config */ $config = config('Settings'); $config->handlers = ['database']; $config->database['group'] = 'another'; @@ -70,6 +72,7 @@ public function testInvalidGroup() public function testSetDefaultGroup() { + /** @var \CodeIgniter\Settings\Config\Settings $config */ $config = config('Settings'); $config->handlers = ['database']; $config->database['group'] = 'default'; From 922b24b31a5d39791d2bb603e748d3fb31574520 Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 21 Sep 2022 11:28:53 +0900 Subject: [PATCH 37/71] refactor: add property $db --- src/Handlers/DatabaseHandler.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Handlers/DatabaseHandler.php b/src/Handlers/DatabaseHandler.php index 6421bc7..240ee2b 100644 --- a/src/Handlers/DatabaseHandler.php +++ b/src/Handlers/DatabaseHandler.php @@ -3,6 +3,7 @@ namespace CodeIgniter\Settings\Handlers; use CodeIgniter\Database\BaseBuilder; +use CodeIgniter\Database\BaseConnection; use CodeIgniter\I18n\Time; use CodeIgniter\Settings\Config\Settings; use RuntimeException; @@ -13,6 +14,11 @@ */ class DatabaseHandler extends ArrayHandler { + /** + * The DB connection for the Settings. + */ + private BaseConnection $db; + /** * The Query Builder for the Settings table. */ @@ -33,7 +39,8 @@ class DatabaseHandler extends ArrayHandler public function __construct() { $this->config = config('Settings'); - $this->builder = db_connect($this->config->database['group'])->table($this->config->database['table']); + $this->db = db_connect($this->config->database['group']); + $this->builder = $this->db->table($this->config->database['table']); } /** @@ -101,7 +108,7 @@ public function set(string $class, string $property, $value = null, ?string $con } if ($result !== true) { - throw new RuntimeException(db_connect($this->config->database['group'])->error()['message'] ?? 'Error writing to the database.'); + throw new RuntimeException($this->db->error()['message'] ?? 'Error writing to the database.'); } // Update storage @@ -126,7 +133,7 @@ public function forget(string $class, string $property, ?string $context = null) ->delete(); if (! $result) { - throw new RuntimeException(db_connect($this->config->database['group'])->error()['message'] ?? 'Error writing to the database.'); + throw new RuntimeException($this->db->error()['message'] ?? 'Error writing to the database.'); } // Delete from local storage @@ -164,7 +171,7 @@ private function hydrate(?string $context): void } if (is_bool($result = $query->get())) { - throw new RuntimeException(db_connect($this->config->database['group'])->error()['message'] ?? 'Error reading from database.'); + throw new RuntimeException($this->db->error()['message'] ?? 'Error reading from database.'); } foreach ($result->getResultObject() as $row) { From ea32d77743b30077d786a6f7444fdac717a5b40a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 26 Sep 2022 08:23:00 +0000 Subject: [PATCH 38/71] chore(deps-dev): update rector/rector requirement from 0.14.2 to 0.14.3 Updates the requirements on [rector/rector](https://github.com/rectorphp/rector) to permit the latest version. - [Release notes](https://github.com/rectorphp/rector/releases) - [Commits](https://github.com/rectorphp/rector/compare/0.14.2...0.14.3) --- updated-dependencies: - dependency-name: rector/rector dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 5811213..5bdc627 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "require-dev": { "codeigniter4/devkit": "^1.0", "codeigniter4/framework": "^4.2.3", - "rector/rector": "0.14.2" + "rector/rector": "0.14.3" }, "minimum-stability": "dev", "prefer-stable": true, From 1442ed574097eaad6acd95b892a946e41312a503 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 28 Sep 2022 08:13:41 +0000 Subject: [PATCH 39/71] chore(deps-dev): update rector/rector requirement from 0.14.3 to 0.14.4 Updates the requirements on [rector/rector](https://github.com/rectorphp/rector) to permit the latest version. - [Release notes](https://github.com/rectorphp/rector/releases) - [Commits](https://github.com/rectorphp/rector/compare/0.14.3...0.14.4) --- updated-dependencies: - dependency-name: rector/rector dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 5bdc627..43dbbc0 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "require-dev": { "codeigniter4/devkit": "^1.0", "codeigniter4/framework": "^4.2.3", - "rector/rector": "0.14.3" + "rector/rector": "0.14.4" }, "minimum-stability": "dev", "prefer-stable": true, From c087c6da748eb188f7b1b403af6c3dfba8493fa7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 30 Sep 2022 08:24:39 +0000 Subject: [PATCH 40/71] chore(deps-dev): update rector/rector requirement from 0.14.4 to 0.14.5 Updates the requirements on [rector/rector](https://github.com/rectorphp/rector) to permit the latest version. - [Release notes](https://github.com/rectorphp/rector/releases) - [Commits](https://github.com/rectorphp/rector/compare/0.14.4...0.14.5) --- updated-dependencies: - dependency-name: rector/rector dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 43dbbc0..09fc125 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "require-dev": { "codeigniter4/devkit": "^1.0", "codeigniter4/framework": "^4.2.3", - "rector/rector": "0.14.4" + "rector/rector": "0.14.5" }, "minimum-stability": "dev", "prefer-stable": true, From 96b8cf33355797010b15dbaf337a60e0f4e5b996 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Oct 2022 08:15:18 +0000 Subject: [PATCH 41/71] chore(deps-dev): update rector/rector requirement from 0.14.5 to 0.14.6 Updates the requirements on [rector/rector](https://github.com/rectorphp/rector) to permit the latest version. - [Release notes](https://github.com/rectorphp/rector/releases) - [Commits](https://github.com/rectorphp/rector/compare/0.14.5...0.14.6) --- updated-dependencies: - dependency-name: rector/rector dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 09fc125..b01323c 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "require-dev": { "codeigniter4/devkit": "^1.0", "codeigniter4/framework": "^4.2.3", - "rector/rector": "0.14.5" + "rector/rector": "0.14.6" }, "minimum-stability": "dev", "prefer-stable": true, From e7b645ca1061691a8c41398a8370fe11e97b6b01 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 8 Nov 2022 08:07:08 +0000 Subject: [PATCH 42/71] chore(deps-dev): update rector/rector requirement from 0.14.6 to 0.14.7 Updates the requirements on [rector/rector](https://github.com/rectorphp/rector) to permit the latest version. - [Release notes](https://github.com/rectorphp/rector/releases) - [Commits](https://github.com/rectorphp/rector/compare/0.14.6...0.14.7) --- updated-dependencies: - dependency-name: rector/rector dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index b01323c..5d6e31c 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "require-dev": { "codeigniter4/devkit": "^1.0", "codeigniter4/framework": "^4.2.3", - "rector/rector": "0.14.6" + "rector/rector": "0.14.7" }, "minimum-stability": "dev", "prefer-stable": true, From ce607528779009dca14c52a66d1b54f24c83e6cb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 15 Nov 2022 08:02:43 +0000 Subject: [PATCH 43/71] chore(deps-dev): update rector/rector requirement from 0.14.7 to 0.14.8 Updates the requirements on [rector/rector](https://github.com/rectorphp/rector) to permit the latest version. - [Release notes](https://github.com/rectorphp/rector/releases) - [Commits](https://github.com/rectorphp/rector/compare/0.14.7...0.14.8) --- updated-dependencies: - dependency-name: rector/rector dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 5d6e31c..05a24f0 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "require-dev": { "codeigniter4/devkit": "^1.0", "codeigniter4/framework": "^4.2.3", - "rector/rector": "0.14.7" + "rector/rector": "0.14.8" }, "minimum-stability": "dev", "prefer-stable": true, From 87fdee6d9c82d895fcfc95ed52f42cfbaa146005 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 Dec 2022 08:05:33 +0000 Subject: [PATCH 44/71] chore(deps-dev): update rector/rector requirement from 0.14.8 to 0.15.0 Updates the requirements on [rector/rector](https://github.com/rectorphp/rector) to permit the latest version. - [Release notes](https://github.com/rectorphp/rector/releases) - [Commits](https://github.com/rectorphp/rector/compare/0.14.8...0.15.0) --- updated-dependencies: - dependency-name: rector/rector dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 05a24f0..cd72a76 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "require-dev": { "codeigniter4/devkit": "^1.0", "codeigniter4/framework": "^4.2.3", - "rector/rector": "0.14.8" + "rector/rector": "0.15.0" }, "minimum-stability": "dev", "prefer-stable": true, From 7212409ac8bb95076df2a4ad5c6d4a207d6082dd Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Mon, 5 Dec 2022 15:59:00 +0700 Subject: [PATCH 45/71] update deprecated TypedPropertyRector to use TypedPropertyFromAssignsRector --- rector.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rector.php b/rector.php index d925df3..217b1f3 100644 --- a/rector.php +++ b/rector.php @@ -1,5 +1,6 @@ rule(SimplifyEmptyArrayCheckRector::class); $rectorConfig->rule(NormalizeNamespaceByPSR4ComposerAutoloadRector::class); $rectorConfig - ->ruleWithConfiguration(TypedPropertyRector::class, [ + ->ruleWithConfiguration(TypedPropertyFromAssignsRector::class, [ // Set to false if you use in libraries, or it does create breaking changes. - TypedPropertyRector::INLINE_PUBLIC => false, + TypedPropertyFromAssignsRector::INLINE_PUBLIC => false, ]); }; From 4d8343fb5f7ebf7ac1be3e72600af3eb606778f3 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Mon, 5 Dec 2022 16:01:15 +0700 Subject: [PATCH 46/71] Re-run Rector --- src/Handlers/DatabaseHandler.php | 2 +- src/Settings.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Handlers/DatabaseHandler.php b/src/Handlers/DatabaseHandler.php index 240ee2b..96806cb 100644 --- a/src/Handlers/DatabaseHandler.php +++ b/src/Handlers/DatabaseHandler.php @@ -27,7 +27,7 @@ class DatabaseHandler extends ArrayHandler /** * Array of contexts that have been stored. * - * @var ?string[] + * @var null[]|string[] */ private $hydrated = []; diff --git a/src/Settings.php b/src/Settings.php index 9da736c..244ea9f 100644 --- a/src/Settings.php +++ b/src/Settings.php @@ -26,7 +26,7 @@ class Settings * * @var array> */ - private $options; + private ?array $options = null; /** * Grabs instances of our handlers. From 6fd1634323ae1c2194c1c33e566098a46da1a0ac Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Mon, 5 Dec 2022 16:31:18 +0700 Subject: [PATCH 47/71] Fix rector workflow --- .github/workflows/rector.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rector.yml b/.github/workflows/rector.yml index c09365d..e102b9f 100644 --- a/.github/workflows/rector.yml +++ b/.github/workflows/rector.yml @@ -63,5 +63,5 @@ jobs: - name: Analyze for refactoring run: | - composer global require --dev rector/rector:^0.14 + composer global require --dev rector/rector:^0.15 rector process --dry-run --no-progress-bar From 16ddf438c8cb2fe5d32675c47abf4c6dfd0577c1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 15 Dec 2022 08:02:59 +0000 Subject: [PATCH 48/71] chore(deps-dev): update rector/rector requirement from 0.15.0 to 0.15.1 Updates the requirements on [rector/rector](https://github.com/rectorphp/rector) to permit the latest version. - [Release notes](https://github.com/rectorphp/rector/releases) - [Commits](https://github.com/rectorphp/rector/compare/0.15.0...0.15.1) --- updated-dependencies: - dependency-name: rector/rector dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index cd72a76..7fbabc4 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "require-dev": { "codeigniter4/devkit": "^1.0", "codeigniter4/framework": "^4.2.3", - "rector/rector": "0.15.0" + "rector/rector": "0.15.1" }, "minimum-stability": "dev", "prefer-stable": true, From 66a744a5c9317232da79819d71f25408edd334a3 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Dadashi Date: Wed, 21 Dec 2022 01:48:49 +0330 Subject: [PATCH 49/71] fix: remove duplicate statement 'can' --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c5b6cc0..3f38911 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ service('settings')->forget('App.siteName') ### Contextual Settings -In addition to the default behavior describe above, `Settings` can can be used to define "contextual settings". +In addition to the default behavior describe above, `Settings` can be used to define "contextual settings". A context may be anything you want, but common examples are a runtime environment or an authenticated user. In order to use a context you pass it as an additional parameter to the `get()`/`set()`/`forget()` methods; if a context setting is requested and does not exist then the general value will be used. From 512a5dbf6c2b1f2d91affe55036914b88a2c22d9 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Dadashi Date: Sat, 24 Dec 2022 13:13:10 +0330 Subject: [PATCH 50/71] docs: use lang tag --- README.md | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 3f38911..dc55e8d 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,12 @@ config classes. ## Quick Start -1. Install with Composer: `> composer require codeigniter4/settings` +1. Install with Composer: + +```console +composer require codeigniter4/settings +``` + 2. Create a new migration and copy the provided class from below into it. `Settings` provides a simple interface that you can use in place of calling `config()` to allow you to read and store @@ -24,7 +29,10 @@ and still allows your users to override those settings once the site is live. Install easily via Composer to take advantage of CodeIgniter 4's autoloading capabilities and always be up-to-date: -* `> composer require codeigniter4/settings` + +```console +composer require codeigniter4/settings +``` Or, install manually by downloading the source files and adding the directory to `app/Config/Autoload.php`. @@ -33,8 +41,8 @@ Or, install manually by downloading the source files and adding the directory to In order to store the settings in the database, you can run the provided migration: -``` -> php spark migrate --all +```console +php spark migrate --all ``` This will also migrate all other packages. If you don't want to do that you can copy the file @@ -77,7 +85,7 @@ You can delete a value from the persistent storage with the `forget()` method. S it effectively resets itself back to the default value in config file, if any. ```php -service('settings')->forget('App.siteName') +service('settings')->forget('App.siteName'); ``` ### Contextual Settings @@ -88,7 +96,7 @@ In order to use a context you pass it as an additional parameter to the `get()`/ a context setting is requested and does not exist then the general value will be used. Contexts may be any unique string you choose, but a recommended format for supplying some consistency is to -give them a category and identifier, like `environment:production` or `group:42`. +give them a category and identifier, like `environment:production`, `group:superadmin` or `lang:en`. An example... Say your App config includes the name of a theme to use to enhance your display. By default your config file specifies `App.theme = 'default'`. When a user changes their theme, you do not want this to @@ -133,7 +141,7 @@ setting()->set('App.siteName', 'My Great Site'); setting()->forget('App.siteName'); ``` -> Note: Due to the shorthand nature of the helper function it cannot access contextual settings. +> **Note** Due to the shorthand nature of the helper function it cannot access contextual settings. ## Known Limitations From 976de46a8a6c40e4b65e79bbea0fe4e6cd5b8bf4 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Dadashi Date: Sat, 24 Dec 2022 13:29:44 +0330 Subject: [PATCH 51/71] docs: add note for run just `Settings` migrate --- README.md | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index dc55e8d..7d3ebae 100644 --- a/README.md +++ b/README.md @@ -12,9 +12,9 @@ config classes. 1. Install with Composer: -```console -composer require codeigniter4/settings -``` + ```console + composer require codeigniter4/settings + ``` 2. Create a new migration and copy the provided class from below into it. @@ -45,9 +45,17 @@ In order to store the settings in the database, you can run the provided migrati php spark migrate --all ``` -This will also migrate all other packages. If you don't want to do that you can copy the file -from `vendor/codeigniter4/settings/src/Database/Migrations/2021-07-04-041948_CreateSettingsTable.php` -into `app/Database/Migrations`, and migrate without the `--all` flag. +This will also migrate all other packages. If you don't want to do that you can run migrate with the `-n` flag: + +1. **For Windows:** + ```console + php spark migrate -n CodeIgniter\Settings + ``` + +2. **For Unix:** + ```console + php spark migrate -n CodeIgniter\\Settings + ``` ## dot Notation From 5ecb7b2e31ba805bbcce4225ecc11d217657c319 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 26 Dec 2022 08:04:32 +0000 Subject: [PATCH 52/71] chore(deps-dev): update rector/rector requirement from 0.15.1 to 0.15.2 Updates the requirements on [rector/rector](https://github.com/rectorphp/rector) to permit the latest version. - [Release notes](https://github.com/rectorphp/rector/releases) - [Commits](https://github.com/rectorphp/rector/compare/0.15.1...0.15.2) --- updated-dependencies: - dependency-name: rector/rector dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 7fbabc4..9910f25 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "require-dev": { "codeigniter4/devkit": "^1.0", "codeigniter4/framework": "^4.2.3", - "rector/rector": "0.15.1" + "rector/rector": "0.15.2" }, "minimum-stability": "dev", "prefer-stable": true, From 811b059217d8bd0f890049b62a7a6f6ef1df7950 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 Jan 2023 08:07:53 +0000 Subject: [PATCH 53/71] chore(deps-dev): update rector/rector requirement from 0.15.2 to 0.15.3 Updates the requirements on [rector/rector](https://github.com/rectorphp/rector) to permit the latest version. - [Release notes](https://github.com/rectorphp/rector/releases) - [Commits](https://github.com/rectorphp/rector/compare/0.15.2...0.15.3) --- updated-dependencies: - dependency-name: rector/rector dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 9910f25..d700b47 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "require-dev": { "codeigniter4/devkit": "^1.0", "codeigniter4/framework": "^4.2.3", - "rector/rector": "0.15.2" + "rector/rector": "0.15.3" }, "minimum-stability": "dev", "prefer-stable": true, From a45a648994e7a0bc6eb600dc528a36ce0d86119f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 11 Jan 2023 08:07:08 +0000 Subject: [PATCH 54/71] chore(deps-dev): update rector/rector requirement from 0.15.3 to 0.15.4 Updates the requirements on [rector/rector](https://github.com/rectorphp/rector) to permit the latest version. - [Release notes](https://github.com/rectorphp/rector/releases) - [Commits](https://github.com/rectorphp/rector/compare/0.15.3...0.15.4) --- updated-dependencies: - dependency-name: rector/rector dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index d700b47..7fe59e5 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "require-dev": { "codeigniter4/devkit": "^1.0", "codeigniter4/framework": "^4.2.3", - "rector/rector": "0.15.3" + "rector/rector": "0.15.4" }, "minimum-stability": "dev", "prefer-stable": true, From 5f2ad61bb3e1991db657a668336b7a682c451c99 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 13 Jan 2023 08:03:35 +0000 Subject: [PATCH 55/71] chore(deps-dev): update rector/rector requirement from 0.15.4 to 0.15.5 Updates the requirements on [rector/rector](https://github.com/rectorphp/rector) to permit the latest version. - [Release notes](https://github.com/rectorphp/rector/releases) - [Commits](https://github.com/rectorphp/rector/compare/0.15.4...0.15.5) --- updated-dependencies: - dependency-name: rector/rector dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 7fe59e5..ac8a9cd 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "require-dev": { "codeigniter4/devkit": "^1.0", "codeigniter4/framework": "^4.2.3", - "rector/rector": "0.15.4" + "rector/rector": "0.15.5" }, "minimum-stability": "dev", "prefer-stable": true, From 55dab9263588b618394b559411e5d14333b55288 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Jan 2023 08:05:49 +0000 Subject: [PATCH 56/71] chore(deps-dev): update rector/rector requirement from 0.15.5 to 0.15.7 Updates the requirements on [rector/rector](https://github.com/rectorphp/rector) to permit the latest version. - [Release notes](https://github.com/rectorphp/rector/releases) - [Commits](https://github.com/rectorphp/rector/compare/0.15.5...0.15.7) --- updated-dependencies: - dependency-name: rector/rector dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index ac8a9cd..d72c06c 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "require-dev": { "codeigniter4/devkit": "^1.0", "codeigniter4/framework": "^4.2.3", - "rector/rector": "0.15.5" + "rector/rector": "0.15.7" }, "minimum-stability": "dev", "prefer-stable": true, From 9a931a6420cf1ef656b5122eb214defff92d71f9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 23 Jan 2023 08:07:46 +0000 Subject: [PATCH 57/71] chore(deps-dev): update rector/rector requirement from 0.15.7 to 0.15.10 Updates the requirements on [rector/rector](https://github.com/rectorphp/rector) to permit the latest version. - [Release notes](https://github.com/rectorphp/rector/releases) - [Commits](https://github.com/rectorphp/rector/compare/0.15.7...0.15.10) --- updated-dependencies: - dependency-name: rector/rector dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index d72c06c..25c4321 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "require-dev": { "codeigniter4/devkit": "^1.0", "codeigniter4/framework": "^4.2.3", - "rector/rector": "0.15.7" + "rector/rector": "0.15.10" }, "minimum-stability": "dev", "prefer-stable": true, From 2df64fdea2135cc60e2e0ed374cc70f31b120c78 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Dadashi Date: Thu, 2 Feb 2023 17:17:59 +0330 Subject: [PATCH 58/71] chore: replace deprecated `COMPOSER_TOKEN` with `GITHUB_TOKEN` --- .github/workflows/deptrac.yml | 2 +- .github/workflows/phpcsfixer.yml | 2 +- .github/workflows/phpstan.yml | 2 +- .github/workflows/phpunit.yml | 2 +- .github/workflows/psalm.yml | 2 +- .github/workflows/rector.yml | 2 +- .github/workflows/unused.yml | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/deptrac.yml b/.github/workflows/deptrac.yml index c077f72..9042772 100644 --- a/.github/workflows/deptrac.yml +++ b/.github/workflows/deptrac.yml @@ -36,7 +36,7 @@ jobs: extensions: intl, json, mbstring, xml coverage: none env: - COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Get composer cache directory id: composer-cache diff --git a/.github/workflows/phpcsfixer.yml b/.github/workflows/phpcsfixer.yml index 3b1265e..302e3ae 100644 --- a/.github/workflows/phpcsfixer.yml +++ b/.github/workflows/phpcsfixer.yml @@ -31,7 +31,7 @@ jobs: extensions: json, tokenizer coverage: none env: - COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Get composer cache directory id: composer-cache diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index 6bdd00f..55c2bd9 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -40,7 +40,7 @@ jobs: extensions: intl, json, mbstring, xml coverage: none env: - COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Get composer cache directory id: composer-cache diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index c875e33..cd165a5 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -39,7 +39,7 @@ jobs: extensions: intl, json, mbstring, gd, xdebug, xml, sqlite3 coverage: xdebug env: - COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Get composer cache directory id: composer-cache diff --git a/.github/workflows/psalm.yml b/.github/workflows/psalm.yml index 5e6ccf6..aabe1f2 100644 --- a/.github/workflows/psalm.yml +++ b/.github/workflows/psalm.yml @@ -36,7 +36,7 @@ jobs: extensions: intl, json, mbstring, xml coverage: none env: - COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Get composer cache directory id: composer-cache diff --git a/.github/workflows/rector.yml b/.github/workflows/rector.yml index e102b9f..d8bd7b0 100644 --- a/.github/workflows/rector.yml +++ b/.github/workflows/rector.yml @@ -40,7 +40,7 @@ jobs: extensions: intl, json, mbstring, xml coverage: none env: - COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Get composer cache directory id: composer-cache diff --git a/.github/workflows/unused.yml b/.github/workflows/unused.yml index b83ccb9..0506531 100644 --- a/.github/workflows/unused.yml +++ b/.github/workflows/unused.yml @@ -34,7 +34,7 @@ jobs: extensions: intl, json, mbstring, xml coverage: none env: - COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Get composer cache directory id: composer-cache From 0b0ae36623f0aca48ef047bc8db83dd1259624d8 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Dadashi Date: Thu, 2 Feb 2023 18:56:19 +0330 Subject: [PATCH 59/71] chore: fix psalm error --- psalm-baseline.xml | 8 ++++++++ psalm.xml | 1 + 2 files changed, 9 insertions(+) create mode 100644 psalm-baseline.xml diff --git a/psalm-baseline.xml b/psalm-baseline.xml new file mode 100644 index 0000000..dc57fc2 --- /dev/null +++ b/psalm-baseline.xml @@ -0,0 +1,8 @@ + + + + + $query->get() + + + \ No newline at end of file diff --git a/psalm.xml b/psalm.xml index 386f4dc..34d358b 100644 --- a/psalm.xml +++ b/psalm.xml @@ -7,6 +7,7 @@ xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" autoloader="psalm_autoload.php" cacheDirectory="build/psalm/" + errorBaseline="psalm-baseline.xml" > From 1eba240de864164f9ab223d66bb37dfba7498333 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Dadashi Date: Thu, 2 Feb 2023 19:12:32 +0330 Subject: [PATCH 60/71] update: psalm_autoload.php file and new line fix --- psalm_autoload.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/psalm_autoload.php b/psalm_autoload.php index d9b911f..046a273 100644 --- a/psalm_autoload.php +++ b/psalm_autoload.php @@ -23,3 +23,5 @@ require_once $filePath; } } + +chdir(__DIR__); From 1afdf4e136326c7c7f9db2094e1a309885b3c96b Mon Sep 17 00:00:00 2001 From: Pooya Parsa Dadashi Date: Thu, 2 Feb 2023 19:27:21 +0330 Subject: [PATCH 61/71] fix new line --- psalm-baseline.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/psalm-baseline.xml b/psalm-baseline.xml index dc57fc2..d5494fe 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -5,4 +5,4 @@ $query->get() - \ No newline at end of file + From 787c3653945274056ebd44cf9677bd41fc70f9d2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 3 Feb 2023 08:02:30 +0000 Subject: [PATCH 62/71] chore(deps-dev): update rector/rector requirement Updates the requirements on [rector/rector](https://github.com/rectorphp/rector) to permit the latest version. - [Release notes](https://github.com/rectorphp/rector/releases) - [Commits](https://github.com/rectorphp/rector/compare/0.15.10...0.15.11) --- updated-dependencies: - dependency-name: rector/rector dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 25c4321..56a6c15 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "require-dev": { "codeigniter4/devkit": "^1.0", "codeigniter4/framework": "^4.2.3", - "rector/rector": "0.15.10" + "rector/rector": "0.15.11" }, "minimum-stability": "dev", "prefer-stable": true, From 837a6ed4521f3c85424426ba5377d8d083bd18d4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 Feb 2023 08:12:31 +0000 Subject: [PATCH 63/71] chore(deps-dev): update rector/rector requirement Updates the requirements on [rector/rector](https://github.com/rectorphp/rector) to permit the latest version. - [Release notes](https://github.com/rectorphp/rector/releases) - [Commits](https://github.com/rectorphp/rector/compare/0.15.11...0.15.12) --- updated-dependencies: - dependency-name: rector/rector dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 56a6c15..9b4e5a5 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "require-dev": { "codeigniter4/devkit": "^1.0", "codeigniter4/framework": "^4.2.3", - "rector/rector": "0.15.11" + "rector/rector": "0.15.12" }, "minimum-stability": "dev", "prefer-stable": true, From 249ad918c2ed59053f4b6b49e2f790176fceefab Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 15 Feb 2023 08:59:28 +0000 Subject: [PATCH 64/71] chore(deps-dev): update rector/rector requirement Updates the requirements on [rector/rector](https://github.com/rectorphp/rector) to permit the latest version. - [Release notes](https://github.com/rectorphp/rector/releases) - [Commits](https://github.com/rectorphp/rector/compare/0.15.12...0.15.16) --- updated-dependencies: - dependency-name: rector/rector dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 9b4e5a5..9e882b6 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "require-dev": { "codeigniter4/devkit": "^1.0", "codeigniter4/framework": "^4.2.3", - "rector/rector": "0.15.12" + "rector/rector": "0.15.16" }, "minimum-stability": "dev", "prefer-stable": true, From 21a9b5fb386ae832632e8b64de340d4c89cc9bb0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 Feb 2023 09:03:37 +0000 Subject: [PATCH 65/71] chore(deps-dev): update rector/rector requirement Updates the requirements on [rector/rector](https://github.com/rectorphp/rector) to permit the latest version. - [Release notes](https://github.com/rectorphp/rector/releases) - [Commits](https://github.com/rectorphp/rector/compare/0.15.16...0.15.17) --- updated-dependencies: - dependency-name: rector/rector dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 9e882b6..5b69b57 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "require-dev": { "codeigniter4/devkit": "^1.0", "codeigniter4/framework": "^4.2.3", - "rector/rector": "0.15.16" + "rector/rector": "0.15.17" }, "minimum-stability": "dev", "prefer-stable": true, From 8b176e955cae677a8ea3b0c19be1022a26bc6ce0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Mar 2023 09:06:09 +0000 Subject: [PATCH 66/71] chore(deps-dev): update rector/rector requirement Updates the requirements on [rector/rector](https://github.com/rectorphp/rector) to permit the latest version. - [Release notes](https://github.com/rectorphp/rector/releases) - [Commits](https://github.com/rectorphp/rector/compare/0.15.17...0.15.19) --- updated-dependencies: - dependency-name: rector/rector dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 5b69b57..403e792 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "require-dev": { "codeigniter4/devkit": "^1.0", "codeigniter4/framework": "^4.2.3", - "rector/rector": "0.15.17" + "rector/rector": "0.15.19" }, "minimum-stability": "dev", "prefer-stable": true, From aed562951c726a0168208b9b0d37b848df1a3060 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 7 Mar 2023 08:59:30 +0000 Subject: [PATCH 67/71] chore(deps-dev): update rector/rector requirement Updates the requirements on [rector/rector](https://github.com/rectorphp/rector) to permit the latest version. - [Release notes](https://github.com/rectorphp/rector/releases) - [Commits](https://github.com/rectorphp/rector/compare/0.15.19...0.15.21) --- updated-dependencies: - dependency-name: rector/rector dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 403e792..778cf75 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "require-dev": { "codeigniter4/devkit": "^1.0", "codeigniter4/framework": "^4.2.3", - "rector/rector": "0.15.19" + "rector/rector": "0.15.21" }, "minimum-stability": "dev", "prefer-stable": true, From 71aa563c957ca5b8e88053b150ab0bd662ec1a79 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 23 Mar 2023 08:59:10 +0000 Subject: [PATCH 68/71] chore(deps-dev): update rector/rector requirement Updates the requirements on [rector/rector](https://github.com/rectorphp/rector) to permit the latest version. - [Release notes](https://github.com/rectorphp/rector/releases) - [Commits](https://github.com/rectorphp/rector/compare/0.15.21...0.15.23) --- updated-dependencies: - dependency-name: rector/rector dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 778cf75..38b2694 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "require-dev": { "codeigniter4/devkit": "^1.0", "codeigniter4/framework": "^4.2.3", - "rector/rector": "0.15.21" + "rector/rector": "0.15.23" }, "minimum-stability": "dev", "prefer-stable": true, From 412af283426eacfdfd2164ab01248f97c11cafd7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 5 Apr 2023 08:58:15 +0000 Subject: [PATCH 69/71] chore(deps-dev): update rector/rector requirement Updates the requirements on [rector/rector](https://github.com/rectorphp/rector) to permit the latest version. - [Release notes](https://github.com/rectorphp/rector/releases) - [Commits](https://github.com/rectorphp/rector/compare/0.15.23...0.15.24) --- updated-dependencies: - dependency-name: rector/rector dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 38b2694..4a1413f 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "require-dev": { "codeigniter4/devkit": "^1.0", "codeigniter4/framework": "^4.2.3", - "rector/rector": "0.15.23" + "rector/rector": "0.15.24" }, "minimum-stability": "dev", "prefer-stable": true, From 71870f388c80580f9685f3a16061a257bdbe6c55 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 21 Apr 2023 08:58:28 +0000 Subject: [PATCH 70/71] chore(deps-dev): update rector/rector requirement Updates the requirements on [rector/rector](https://github.com/rectorphp/rector) to permit the latest version. - [Release notes](https://github.com/rectorphp/rector/releases) - [Commits](https://github.com/rectorphp/rector/compare/0.15.24...0.15.25) --- updated-dependencies: - dependency-name: rector/rector dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 4a1413f..f4c7e28 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "require-dev": { "codeigniter4/devkit": "^1.0", "codeigniter4/framework": "^4.2.3", - "rector/rector": "0.15.24" + "rector/rector": "0.15.25" }, "minimum-stability": "dev", "prefer-stable": true, From 5d0554cc15ca3f14b146a4cc371e1337135bd6d4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 May 2023 08:59:23 +0000 Subject: [PATCH 71/71] chore(deps-dev): update rector/rector requirement from 0.15.25 to 0.16.0 Updates the requirements on [rector/rector](https://github.com/rectorphp/rector) to permit the latest version. - [Release notes](https://github.com/rectorphp/rector/releases) - [Commits](https://github.com/rectorphp/rector/compare/0.15.25...0.16.0) --- updated-dependencies: - dependency-name: rector/rector dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index f4c7e28..1ac2c78 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "require-dev": { "codeigniter4/devkit": "^1.0", "codeigniter4/framework": "^4.2.3", - "rector/rector": "0.15.25" + "rector/rector": "0.16.0" }, "minimum-stability": "dev", "prefer-stable": true,