From 799536381b9c08746b72cb2027f199af47c60c0e Mon Sep 17 00:00:00 2001 From: MGatner Date: Fri, 13 Aug 2021 18:47:56 +0000 Subject: [PATCH 1/5] Apply updated toolkit --- .gitattributes | 13 +++ .github/dependabot.yml | 12 +++ .github/workflows/analyze.yml | 81 ++++++++++++++++++ .github/workflows/inspect.yml | 83 ++++++++++++++++++ .github/workflows/test.yml | 88 +++++++++++++++++++ .gitignore | 1 + composer.json | 115 +++++++++++++------------ depfile.yaml | 153 +++++++++++++++++++++++++++++++++ infection.json.dist | 19 +++++ phpstan.neon.dist | 1 + phpunit.xml.dist | 155 ++++++++++++++++++++++------------ 11 files changed, 610 insertions(+), 111 deletions(-) create mode 100644 .gitattributes create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/analyze.yml create mode 100644 .github/workflows/inspect.yml create mode 100644 .github/workflows/test.yml create mode 100644 depfile.yaml create mode 100644 infection.json.dist diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..fcf895c --- /dev/null +++ b/.gitattributes @@ -0,0 +1,13 @@ +/.github export-ignore +/docs export-ignore +/examples export-ignore +/tests export-ignore +/.editorconfig export-ignore +/.gitattributes export-ignore +/.gitignore export-ignore +/phpunit.xml.dist export-ignore +/phpstan.neon.dist export-ignore + +# Configure diff output for .php and .phar files. +*.php diff=php +*.phar -diff diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..fd20b19 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,12 @@ +version: 2 +updates: +- package-ecosystem: composer + directory: "/" + schedule: + interval: daily + open-pull-requests-limit: 10 + +- package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: daily diff --git a/.github/workflows/analyze.yml b/.github/workflows/analyze.yml new file mode 100644 index 0000000..12c48c1 --- /dev/null +++ b/.github/workflows/analyze.yml @@ -0,0 +1,81 @@ +# 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' + paths: + - 'src/**' + - 'tests/**' + - 'composer.**' + - 'phpstan*' + - '.github/workflows/analyze.yml' + push: + branches: + - 'develop' + paths: + - 'src/**' + - 'tests/**' + - 'composer.**' + - 'phpstan*' + - '.github/workflows/analyze.yml' + +jobs: + build: + name: PHP ${{ matrix.php-versions }} Static Analysis + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php-versions: ['7.3', '7.4', '8.0'] + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + tools: composer, pecl, phpunit + extensions: intl, json, mbstring, gd, mysqlnd, xdebug, xml, sqlite3 + 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: Create composer cache directory + run: mkdir -p ${{ steps.composer-cache.outputs.dir }} + + - name: Cache composer dependencies + uses: actions/cache@v2 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Create PHPStan cache directory + run: mkdir -p build/phpstan + + - name: Cache PHPStan results + uses: actions/cache@v2 + with: + path: build/phpstan + 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 + env: + COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }} + + - name: Run static analysis + run: vendor/bin/phpstan analyze diff --git a/.github/workflows/inspect.yml b/.github/workflows/inspect.yml new file mode 100644 index 0000000..1a8dfbd --- /dev/null +++ b/.github/workflows/inspect.yml @@ -0,0 +1,83 @@ +# 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' + paths: + - 'src/**' + - 'tests/**' + - 'composer.**' + - 'depfile.yaml' + - '.github/workflows/inspect.yml' + push: + branches: + - 'develop' + paths: + - 'src/**' + - 'tests/**' + - 'composer.**' + - 'depfile.yaml' + - '.github/workflows/inspect.yml' + +jobs: + build: + name: PHP ${{ matrix.php-versions }} Architectural Inspection + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php-versions: ['7.4', '8.0'] + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + tools: composer, pecl, phive, phpunit + extensions: intl, json, mbstring, gd, mysqlnd, xdebug, xml, sqlite3 + 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: Create composer cache directory + run: mkdir -p ${{ steps.composer-cache.outputs.dir }} + + - name: Cache composer dependencies + uses: actions/cache@v2 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Create Deptrac cache directory + run: mkdir -p build/ + + - name: Cache Deptrac results + uses: actions/cache@v2 + with: + path: build + 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 + env: + COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }} + + - name: Run architectural inspection + run: | + sudo phive --no-progress install --global qossmic/deptrac --trust-gpg-keys B8F640134AB1782E + deptrac analyze --cache-file=build/deptrac.cache diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..561601d --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,88 @@ +name: PHPUnit + +on: + pull_request: + branches: + - develop + push: + branches: + - develop + +jobs: + main: + name: PHP ${{ matrix.php-versions }} Unit Tests + + strategy: + matrix: + php-versions: ['7.3', '7.4', '8.0'] + + runs-on: ubuntu-latest + + if: "!contains(github.event.head_commit.message, '[ci skip]')" + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup PHP, with composer and extensions + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + tools: composer, pecl, phpunit + extensions: intl, json, mbstring, gd, mysqlnd, xdebug, xml, sqlite3 + coverage: xdebug + 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@v2 + with: + path: ${{ steps.composer-cache.outputs.dir }} + 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 + env: + COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }} + + - name: Test with PHPUnit + run: vendor/bin/phpunit --verbose --coverage-text + env: + TERM: xterm-256color + TACHYCARDIA_MONITOR_GA: enabled + + - if: matrix.php-versions == '8.0' + name: Mutate with Infection + run: | + composer global require infection/infection + 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 + run: vendor/bin/php-coveralls --verbose --coverage_clover=build/phpunit/clover.xml --json_path build/phpunit/coveralls-upload.json + env: + COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} + COVERALLS_PARALLEL: true + COVERALLS_FLAG_NAME: PHP ${{ matrix.php-versions }} + + coveralls: + needs: [main] + name: Coveralls Finished + runs-on: ubuntu-latest + steps: + - name: Upload Coveralls results + uses: coverallsapp/github-action@master + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + parallel-finished: true diff --git a/.gitignore b/.gitignore index 36ac44a..14bdec5 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ vendor/ build/ phpunit*.xml phpunit +*.cache composer.lock .DS_Store .idea/ diff --git a/composer.json b/composer.json index 3ccc44e..589dc76 100644 --- a/composer.json +++ b/composer.json @@ -1,58 +1,63 @@ { - "name": "codeigniter4/settings", - "type": "library", - "description": "Settings library for CodeIgniter 4", - "keywords": [ - "codeigniter", - "codeigniter4", - "settings" - ], - "homepage": "https://github.com/codeigniter4/settings", - "license": "MIT", - "authors": [ - { - "name": "Lonnie Ezell", - "email": "lonnieje@gmail.com", - "role": "Developer" - } - ], - "require": { - "php": ">=7.3" - }, - "require-dev": { - "codeigniter4/codeigniter4": "dev-develop", - "codeigniter4/codeigniter4-standard": "^1.0", - "phpstan/phpstan": "^0.12", - "phpunit/phpunit": "^8.0 || ^9.0", - "fakerphp/faker": "^1.9", - "mockery/mockery": "^1.0", - "squizlabs/php_codesniffer": "^3.3" - }, - "autoload": { - "psr-4": { - "Sparks\\Settings\\": "src" - } - }, - "autoload-dev": { - "psr-4": { + "name": "codeigniter4/settings", + "type": "library", + "description": "Settings library for CodeIgniter 4", + "keywords": [ + "codeigniter", + "codeigniter4", + "settings" + ], + "homepage": "https://github.com/codeigniter4/settings", + "license": "MIT", + "authors": [ + { + "name": "Lonnie Ezell", + "email": "lonnieje@gmail.com", + "role": "Developer" + } + ], + "require": { + "php": "^7.3 || ^8.0" + }, + "require-dev": { + "codeigniter4/codeigniter4": "dev-develop", + "codeigniter4/codeigniter4-standard": "^1.0", + "fakerphp/faker": "^1.9", + "mockery/mockery": "^1.0", + "phpstan/phpstan": "^0.12", + "phpunit/phpunit": "^9.0", + "squizlabs/php_codesniffer": "^3.3" + }, + "autoload": { + "psr-4": { + "Sparks\\Settings\\": "src" + }, + "exclude-from-classmap": [ + "**/Database/Migrations/**" + ] + }, + "autoload-dev": { + "psr-4": { "Tests\\": "tests", - "Tests\\Support\\": "tests/_support" - } - }, - "repositories": [ - { - "type": "vcs", - "url": "https://github.com/codeigniter4/CodeIgniter4" - } - ], - "minimum-stability": "dev", - "prefer-stable": true, - "scripts": { - "post-update-cmd": [ - "bash admin/setup.sh" - ], - "analyze": "phpstan analyze", - "style": "phpcbf --standard=PSR12 tests/ src/", - "test": "phpunit" - } + "Tests\\Support\\": "tests/_support" + } + }, + "repositories": [ + { + "type": "vcs", + "url": "https://github.com/codeigniter4/CodeIgniter4" + } + ], + "minimum-stability": "dev", + "prefer-stable": true, + "scripts": { + "post-update-cmd": [ + "bash admin/setup.sh" + ], + "analyze": "phpstan analyze", + "inspect": "deptrac analyze --cache-file=build/deptrac.cache", + "mutate": "infection --threads=2 --skip-initial-tests --coverage=build/phpunit", + "style": "phpcbf --standard=PSR12 tests/ src/", + "test": "phpunit" + } } diff --git a/depfile.yaml b/depfile.yaml new file mode 100644 index 0000000..79ec82a --- /dev/null +++ b/depfile.yaml @@ -0,0 +1,153 @@ +paths: + - ./src + - ./vendor/codeigniter4/codeigniter4/system + - ./vendor/tatter +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 Model + Service: + - Config + - Vendor Config + + # Ignore anything in the Vendor layers + Vendor Model: + - 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: + - 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/infection.json.dist b/infection.json.dist new file mode 100644 index 0000000..b175102 --- /dev/null +++ b/infection.json.dist @@ -0,0 +1,19 @@ +{ + "source": { + "directories": [ + "src" + ], + "excludes": [ + "Config", + "Database/Migrations", + "Views" + ] + }, + "logs": { + "text": "build/infection.log" + }, + "mutators": { + "@default": true + }, + "bootstrap": "vendor/codeigniter4/codeigniter4/system/Test/bootstrap.php" +} diff --git a/phpstan.neon.dist b/phpstan.neon.dist index ef5ed8c..2d563a5 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -13,6 +13,7 @@ parameters: - '#Unsafe usage of new static\(\)#' universalObjectCratesClasses: - CodeIgniter\Entity + - CodeIgniter\Entity\Entity - Faker\Generator scanDirectories: - vendor/codeigniter4/codeigniter4/system/Helpers diff --git a/phpunit.xml.dist b/phpunit.xml.dist index c053d2b..a90a1f2 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,59 +1,102 @@ - - - ./src - - - ./src/Views - ./src/Config/Routes.php - - - - - - - - - - - ./tests - - - - - - - - - - - - - - - - - - - - - - - - - - - + xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" + bootstrap="vendor/codeigniter4/codeigniter4/system/Test/bootstrap.php" + backupGlobals="false" + beStrictAboutCoversAnnotation="true" + beStrictAboutOutputDuringTests="true" + beStrictAboutTodoAnnotatedTests="true" + colors="true" + convertErrorsToExceptions="true" + convertNoticesToExceptions="true" + convertWarningsToExceptions="true" + executionOrder="random" + failOnRisky="true" + failOnWarning="true" + stopOnError="false" + stopOnFailure="false" + stopOnIncomplete="false" + stopOnSkipped="false" + verbose="true"> + + + + ./src + + + ./src/Views + ./src/Config/Routes.php + + + + + + + + + + + + + ./tests + + + + + + + + + 0.50 + + + 30 + + + 2 + + + true + + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 5d5627e2c2c2723f36043d7a0fd7ee79b4f3b561 Mon Sep 17 00:00:00 2001 From: MGatner Date: Fri, 13 Aug 2021 18:51:23 +0000 Subject: [PATCH 2/5] Consolidate and fix tests --- .github/workflows/test-phpunit.yml | 52 ------------------------------ src/Helpers/setting_helper.php | 3 +- tests/HelperTest.php | 7 +--- tests/SettingsTest.php | 11 ------- tests/_support/TestCase.php | 25 ++++++++++---- 5 files changed, 21 insertions(+), 77 deletions(-) delete mode 100644 .github/workflows/test-phpunit.yml diff --git a/.github/workflows/test-phpunit.yml b/.github/workflows/test-phpunit.yml deleted file mode 100644 index 3f9c963..0000000 --- a/.github/workflows/test-phpunit.yml +++ /dev/null @@ -1,52 +0,0 @@ -name: PHPUnit - -on: - pull_request: - branches: - - develop - push: - branches: - - develop - -jobs: - main: - name: Build and test - - strategy: - matrix: - php-versions: ['7.3', '7.4', '8.0'] - - runs-on: ubuntu-latest - - if: "!contains(github.event.head_commit.message, '[ci skip]')" - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Setup PHP, with composer and extensions - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php-versions }} - tools: composer, pecl, phpunit - extensions: intl, json, mbstring, mysqlnd, xdebug, xml, sqlite3 - coverage: xdebug - - - 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@v2 - with: - path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} - restore-keys: ${{ runner.os }}-composer- - - - name: Install dependencies - run: composer install --no-progress --no-interaction --prefer-dist --optimize-autoloader - env: - COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }} - - - name: Test with PHPUnit - run: vendor/bin/phpunit --verbose --coverage-text diff --git a/src/Helpers/setting_helper.php b/src/Helpers/setting_helper.php index c88d3ba..95494f5 100644 --- a/src/Helpers/setting_helper.php +++ b/src/Helpers/setting_helper.php @@ -3,8 +3,7 @@ if (! function_exists('setting')) { /** - * Provides a convenience interface to the - * Bonfire/Settings/Settings class. + * Provides a convenience interface to the Settings service. * * @param string|null $field * @param null $value diff --git a/tests/HelperTest.php b/tests/HelperTest.php index 12aa86e..9b759d7 100644 --- a/tests/HelperTest.php +++ b/tests/HelperTest.php @@ -11,16 +11,11 @@ class HelperTest extends TestCase { use DatabaseTestTrait; - protected $namespace = 'Sparks\Settings'; - protected $refresh = true; - protected $table; - public function setUp(): void { parent::setUp(); - $this->table = config('Settings')->database['table']; - helper('setting'); + helper(['setting']); } public function testReturnsServiceByDefault() diff --git a/tests/SettingsTest.php b/tests/SettingsTest.php index 22dfe80..91bc24b 100644 --- a/tests/SettingsTest.php +++ b/tests/SettingsTest.php @@ -11,17 +11,6 @@ class SettingsTest extends TestCase { use DatabaseTestTrait; - protected $namespace = 'Sparks\Settings'; - protected $refresh = true; - protected $table; - - public function setUp(): void - { - parent::setUp(); - - $this->table = config('Settings')->database['table']; - } - public function testSettingsGetsFromConfig() { $settings = new Settings(); diff --git a/tests/_support/TestCase.php b/tests/_support/TestCase.php index 27bbcdf..b671d26 100644 --- a/tests/_support/TestCase.php +++ b/tests/_support/TestCase.php @@ -4,14 +4,27 @@ use CodeIgniter\Test\CIUnitTestCase; -class TestCase extends CIUnitTestCase +abstract class TestCase extends CIUnitTestCase { + protected $namespace = 'Sparks\Settings'; + protected $refresh = true; + /** + * @var string + */ + protected $table; - protected function setUp(): void - { - parent::setUp(); + public function setUp(): void + { + parent::setUp(); - $_SESSION = []; - } + $this->table = config('Settings')->database['table']; + } + + public function tearDown(): void + { + parent::tearDown(); + + $this->resetServices(); + } } From afb606f7e430aee5d6761bbb68be4947f1dbfc8f Mon Sep 17 00:00:00 2001 From: MGatner Date: Fri, 13 Aug 2021 18:51:38 +0000 Subject: [PATCH 3/5] Apply static analysis --- phpstan.neon.dist | 1 - src/Handlers/BaseHandler.php | 8 ++++---- src/Handlers/DatabaseHandler.php | 2 +- src/Helpers/setting_helper.php | 2 +- src/Settings.php | 2 +- 5 files changed, 7 insertions(+), 8 deletions(-) diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 2d563a5..e2db4ba 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -10,7 +10,6 @@ parameters: - src/Config/Routes.php - src/Views/* ignoreErrors: - - '#Unsafe usage of new static\(\)#' universalObjectCratesClasses: - CodeIgniter\Entity - CodeIgniter\Entity\Entity diff --git a/src/Handlers/BaseHandler.php b/src/Handlers/BaseHandler.php index 90b5b5d..e02a803 100644 --- a/src/Handlers/BaseHandler.php +++ b/src/Handlers/BaseHandler.php @@ -20,7 +20,7 @@ abstract public function get(string $class, string $key); * Not all Handlers will support writing values. * * @param string $key - * @param null $value + * @param mixed $value * * @return mixed */ @@ -33,7 +33,7 @@ public function set(string $class, string $key, $value = null) * Takes care of converting some item types so they can be safely * stored and re-hydrated into the config files. * - * @param $value + * @param mixed $value * * @return string|mixed */ @@ -57,7 +57,7 @@ protected function prepareValue($value) * data might have been saved as, such as booleans * and serialized data. * - * @param $value + * @param mixed $value * * @return boolean|mixed */ @@ -79,7 +79,7 @@ protected function parseValue($value, string $type) * * Taken from Wordpress core functions. * - * @param $data + * @param mixed $data * @param boolean $strict Whether to be strict about the end of the string. * * @return boolean diff --git a/src/Handlers/DatabaseHandler.php b/src/Handlers/DatabaseHandler.php index efce0a3..eb8c085 100644 --- a/src/Handlers/DatabaseHandler.php +++ b/src/Handlers/DatabaseHandler.php @@ -62,7 +62,7 @@ public function get(string $class, string $key) * * @param string $class * @param string $key - * @param null $value + * @param mixed $value * * @return mixed|void */ diff --git a/src/Helpers/setting_helper.php b/src/Helpers/setting_helper.php index 95494f5..9f805d0 100644 --- a/src/Helpers/setting_helper.php +++ b/src/Helpers/setting_helper.php @@ -6,7 +6,7 @@ * Provides a convenience interface to the Settings service. * * @param string|null $field - * @param null $value + * @param mixed|null $value * * @return mixed */ diff --git a/src/Settings.php b/src/Settings.php index 59678cd..cc952e3 100644 --- a/src/Settings.php +++ b/src/Settings.php @@ -78,7 +78,7 @@ public function get(string $class, string $key) * * @param string $class * @param string $key - * @param null $value + * @param mixed $value * * @return void|null */ From 65237c08aa4b9c8901c73159536ee76dd6f5c49e Mon Sep 17 00:00:00 2001 From: MGatner Date: Fri, 13 Aug 2021 18:59:30 +0000 Subject: [PATCH 4/5] Repair workflows --- .github/workflows/inspect.yml | 8 ++------ composer.json | 2 ++ depfile.yaml | 1 - tests/_support/TestCase.php | 3 +++ 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/inspect.yml b/.github/workflows/inspect.yml index 1a8dfbd..e58e531 100644 --- a/.github/workflows/inspect.yml +++ b/.github/workflows/inspect.yml @@ -24,12 +24,8 @@ on: jobs: build: - name: PHP ${{ matrix.php-versions }} Architectural Inspection + name: Architectural Inspection runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - php-versions: ['7.4', '8.0'] steps: - name: Checkout uses: actions/checkout@v2 @@ -37,7 +33,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: ${{ matrix.php-versions }} + php-version: '8.0' tools: composer, pecl, phive, phpunit extensions: intl, json, mbstring, gd, mysqlnd, xdebug, xml, sqlite3 env: diff --git a/composer.json b/composer.json index 589dc76..58e51e8 100644 --- a/composer.json +++ b/composer.json @@ -24,6 +24,8 @@ "codeigniter4/codeigniter4-standard": "^1.0", "fakerphp/faker": "^1.9", "mockery/mockery": "^1.0", + "nexusphp/tachycardia": "^1.0", + "php-coveralls/php-coveralls": "^2.4", "phpstan/phpstan": "^0.12", "phpunit/phpunit": "^9.0", "squizlabs/php_codesniffer": "^3.3" diff --git a/depfile.yaml b/depfile.yaml index 79ec82a..e039a7c 100644 --- a/depfile.yaml +++ b/depfile.yaml @@ -1,7 +1,6 @@ paths: - ./src - ./vendor/codeigniter4/codeigniter4/system - - ./vendor/tatter exclude_files: - '#.*test.*#i' layers: diff --git a/tests/_support/TestCase.php b/tests/_support/TestCase.php index b671d26..998d5e3 100644 --- a/tests/_support/TestCase.php +++ b/tests/_support/TestCase.php @@ -3,9 +3,12 @@ namespace Tests\Support; use CodeIgniter\Test\CIUnitTestCase; +use Nexus\PHPUnit\Extension\Expeditable; abstract class TestCase extends CIUnitTestCase { + use Expeditable; + protected $namespace = 'Sparks\Settings'; protected $refresh = true; From b7c5d22a2056a7efaa2ccc887483cc6012c02e01 Mon Sep 17 00:00:00 2001 From: MGatner Date: Fri, 13 Aug 2021 19:04:09 +0000 Subject: [PATCH 5/5] Apply badges --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index b45e590..9d3ca09 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,11 @@ Provides database storage and retrieval of application settings, with a fallback to the config classes. +[![](https://github.com/codeigniter4/settings/workflows/PHPUnit/badge.svg)](https://github.com/codeigniter4/settings/actions/workflows/test.yml) +[![](https://github.com/codeigniter4/settings/workflows/PHPStan/badge.svg)](https://github.com/codeigniter4/settings/actions/workflows/analyze.yml) +[![](https://github.com/codeigniter4/settings/workflows/Deptrac/badge.svg)](https://github.com/codeigniter4/settings/actions/workflows/inspect.yml) +[![Coverage Status](https://coveralls.io/repos/github/codeigniter4/settings/badge.svg?branch=develop)](https://coveralls.io/github/codeigniter4/settings?branch=develop) + ## Quick Start 1. Install with Composer: `> composer require codeigniter4/settings`