From 0df8384ba1de3b6d881699b619328dc793c75d3b Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 5 Mar 2021 16:06:43 +0900 Subject: [PATCH 01/11] chore: add github workflows --- .github/workflows/coding-standards.yml | 54 +++++++++ .github/workflows/phpunit.yml | 74 ++++++++++++ .github/workflows/static-analysis.yml | 155 +++++++++++++++++++++++++ 3 files changed, 283 insertions(+) create mode 100644 .github/workflows/coding-standards.yml create mode 100644 .github/workflows/phpunit.yml create mode 100644 .github/workflows/static-analysis.yml diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml new file mode 100644 index 0000000..4f29fd9 --- /dev/null +++ b/.github/workflows/coding-standards.yml @@ -0,0 +1,54 @@ +name: Coding Standards + +on: + push: + branches: + - 1.x + paths: + - 'src/**' + - 'tests/**' + - phpcs.xml + pull_request: + branches: + - 1.x + paths: + - 'src/**' + - 'tests/**' + - phpcs.xml + workflow_dispatch: + +jobs: + coding-standards: + name: Coding Standards + runs-on: ubuntu-latest + if: "!contains(github.event.head_commit.message, '[ci skip]')" + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 8.0 + tools: cs2pr + coverage: none + + - name: Get composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Cache dependencies + uses: actions/cache@v2 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Install dependencies + run: composer install --no-interaction --no-progress --prefer-dist + + - name: Validate composer.json + run: composer validate --strict + + - name: Run PHP_CodeSniffer + run: ./vendor/bin/phpcs -q --no-colors --report=checkstyle src tests | cs2pr diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml new file mode 100644 index 0000000..41f38f2 --- /dev/null +++ b/.github/workflows/phpunit.yml @@ -0,0 +1,74 @@ +name: PHPUnit + +on: + push: + branches: + - 1.x + paths: + - 'src/**' + - 'tests/**' + - composer.json + - phpunit.xml.dist + pull_request: + branches: + - 1.x + paths: + - 'src/**' + - 'tests/**' + - composer.json + - phpunit.xml.dist + workflow_dispatch: + +jobs: + phpunit: + name: PHPUnit + runs-on: ubuntu-latest + strategy: + matrix: + operating-system: + - ubuntu-latest + php-version: + - '7.3' + - '7.4' + - '8.0' + dependencies: + - lowest + - highest + 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@master + with: + php-version: ${{ matrix.php-version }} + coverage: pcov + ini-values: zend.assertions=1 + + - name: Get composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Cache dependencies + uses: actions/cache@v2 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Install lowest dependencies + if: ${{ matrix.dependencies == 'lowest' }} + run: composer update --prefer-lowest --no-interaction --no-progress + + - name: Install highest dependencies + if: ${{ matrix.dependencies == 'highest' }} + run: composer update --no-interaction --no-progress + + - name: Run test suite + run: ./vendor/bin/phpunit --coverage-clover=coverage.xml --coverage-text + + - name: Upload coverage report + uses: codecov/codecov-action@v1 + with: + file: ./coverage.xml diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml new file mode 100644 index 0000000..74e6c97 --- /dev/null +++ b/.github/workflows/static-analysis.yml @@ -0,0 +1,155 @@ +name: Static Analysis + +on: + push: + branches: + - 1.x + paths: + - 'src/**' + - 'tests/**' + - phpmd.xml + - phpstan.neon + - psalm.xml + pull_request: + branches: + - 1.x + paths: + - 'src/**' + - 'tests/**' + - phpmd.xml + - phpstan.neon + - psalm.xml + workflow_dispatch: + +jobs: + static-analysis-phpstan: + name: Static Analysis with PHPStan + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 8.0 + tools: cs2pr + coverage: none + + - name: Get composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Cache dependencies + uses: actions/cache@v2 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Install dependencies + run: composer install --no-interaction --no-progress --prefer-dist + + - name: Run PHPStan + run: ./vendor/bin/phpstan analyse -c phpstan.neon --no-progress --no-interaction --error-format=checkstyle | cs2pr + + static-analysis-psalm: + name: Static Analysis with Psalm + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 8.0 + tools: cs2pr + coverage: none + + - name: Get composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Install dependencies + run: composer install --no-interaction --no-progress --prefer-dist + + - name: Run Psalm + run: ./vendor/bin/psalm --show-info=false --output-format=checkstyle --shepherd | cs2pr + + static-analysis-phpmd: + name: Static Analysis with PHPMD + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 7.4 + + - name: Get composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Cache dependencies + uses: actions/cache@v2 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Install dependencies + run: composer install --no-interaction --no-progress --prefer-dist + + - name: Run PHP Mess Detector + run: ./vendor/bin/phpmd src text --exclude src/Annotation ./phpmd.xml + + static-analysis-php-metrics: + name: Static Analysis with PhpMetrics + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 8.0 + coverage: none + + - name: Get composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Install dependencies + run: composer install --no-interaction --no-progress --prefer-dist + + - name: Run PhpMetrics + run: ./vendor/bin/phpmetrics --exclude=Exception src + + static-analysis-composer-require-checker: + name: Static Analysis with ComposerRequireChecker + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 8.0 + coverage: none + + - name: Get composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Install dependencies + run: | + composer install --no-interaction --no-progress --prefer-dist + composer require --dev maglnet/composer-require-checker ^3.0 + + - name: Run composer-require-checker + run: ./vendor/bin/composer-require-checker From 1e18dcdcd9161be3cb7a976e3f216aa2d4c60996 Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 5 Mar 2021 16:11:27 +0900 Subject: [PATCH 02/11] chore: add .github/workflows/ in paths --- .github/workflows/coding-standards.yml | 1 + .github/workflows/phpunit.yml | 1 + .github/workflows/static-analysis.yml | 1 + 3 files changed, 3 insertions(+) diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml index 4f29fd9..71ce4e3 100644 --- a/.github/workflows/coding-standards.yml +++ b/.github/workflows/coding-standards.yml @@ -15,6 +15,7 @@ on: - 'src/**' - 'tests/**' - phpcs.xml + - '.github/workflows/**' workflow_dispatch: jobs: diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index 41f38f2..652f1e9 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -17,6 +17,7 @@ on: - 'tests/**' - composer.json - phpunit.xml.dist + - '.github/workflows/**' workflow_dispatch: jobs: diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 74e6c97..1c2578a 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -19,6 +19,7 @@ on: - phpmd.xml - phpstan.neon - psalm.xml + - '.github/workflows/**' workflow_dispatch: jobs: From ead89f728506b03af01bbf7b025471c8132f3d71 Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 5 Mar 2021 16:18:48 +0900 Subject: [PATCH 03/11] chore: fix composer require composer-require-checker reported --- composer.json | 12 +++-- vendor-bin/tools/composer.lock | 98 +++++++++++++++++----------------- 2 files changed, 56 insertions(+), 54 deletions(-) diff --git a/composer.json b/composer.json index 9ab98c9..ee424de 100644 --- a/composer.json +++ b/composer.json @@ -8,17 +8,19 @@ "authors": [ { "name": "Kenji Suzuki", - "email": "kenji.uui@gmail.com" + "homepage": "https://github.com/kenjis" } ], "require": { - "php": "^7.3 || ^8.0" + "php": "^7.3 || ^8.0", + "ext-openssl": "*", + "ext-tokenizer": "*", + "phpunit/phpunit": "^9.5", + "nikic/php-parser": "^4.10" }, "require-dev": { "bamarni/composer-bin-plugin": "^1.4", - "phpunit/phpunit": "^9.5", - "kenjis/phpunit-helper": "^1.0", - "nikic/php-parser": "^4.10" + "kenjis/phpunit-helper": "^1.0" }, "autoload": { "psr-4": { diff --git a/vendor-bin/tools/composer.lock b/vendor-bin/tools/composer.lock index df17209..66672b2 100644 --- a/vendor-bin/tools/composer.lock +++ b/vendor-bin/tools/composer.lock @@ -3610,16 +3610,16 @@ }, { "name": "symfony/config", - "version": "v5.2.3", + "version": "v5.2.4", "source": { "type": "git", "url": "https://github.com/symfony/config.git", - "reference": "50e0e1314a3b2609d32b6a5a0d0fb5342494c4ab" + "reference": "212d54675bf203ff8aef7d8cee8eecfb72f4a263" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/config/zipball/50e0e1314a3b2609d32b6a5a0d0fb5342494c4ab", - "reference": "50e0e1314a3b2609d32b6a5a0d0fb5342494c4ab", + "url": "https://api.github.com/repos/symfony/config/zipball/212d54675bf203ff8aef7d8cee8eecfb72f4a263", + "reference": "212d54675bf203ff8aef7d8cee8eecfb72f4a263", "shasum": "" }, "require": { @@ -3668,7 +3668,7 @@ "description": "Helps you find, load, combine, autofill and validate configuration values of any kind", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/config/tree/v5.2.3" + "source": "https://github.com/symfony/config/tree/v5.2.4" }, "funding": [ { @@ -3684,20 +3684,20 @@ "type": "tidelift" } ], - "time": "2021-01-27T10:15:41+00:00" + "time": "2021-02-23T23:58:19+00:00" }, { "name": "symfony/console", - "version": "v5.2.3", + "version": "v5.2.4", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "89d4b176d12a2946a1ae4e34906a025b7b6b135a" + "reference": "d6d0cc30d8c0fda4e7b213c20509b0159a8f4556" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/89d4b176d12a2946a1ae4e34906a025b7b6b135a", - "reference": "89d4b176d12a2946a1ae4e34906a025b7b6b135a", + "url": "https://api.github.com/repos/symfony/console/zipball/d6d0cc30d8c0fda4e7b213c20509b0159a8f4556", + "reference": "d6d0cc30d8c0fda4e7b213c20509b0159a8f4556", "shasum": "" }, "require": { @@ -3765,7 +3765,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v5.2.3" + "source": "https://github.com/symfony/console/tree/v5.2.4" }, "funding": [ { @@ -3781,20 +3781,20 @@ "type": "tidelift" } ], - "time": "2021-01-28T22:06:19+00:00" + "time": "2021-02-23T10:08:49+00:00" }, { "name": "symfony/dependency-injection", - "version": "v5.2.3", + "version": "v5.2.4", "source": { "type": "git", "url": "https://github.com/symfony/dependency-injection.git", - "reference": "62f72187be689540385dce6c68a5d4c16f034139" + "reference": "f7d89110c55d88620dc811f342f94393b8a045d4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/62f72187be689540385dce6c68a5d4c16f034139", - "reference": "62f72187be689540385dce6c68a5d4c16f034139", + "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/f7d89110c55d88620dc811f342f94393b8a045d4", + "reference": "f7d89110c55d88620dc811f342f94393b8a045d4", "shasum": "" }, "require": { @@ -3812,7 +3812,7 @@ }, "provide": { "psr/container-implementation": "1.0", - "symfony/service-implementation": "1.0" + "symfony/service-implementation": "1.0|2.0" }, "require-dev": { "symfony/config": "^5.1", @@ -3852,7 +3852,7 @@ "description": "Allows you to standardize and centralize the way objects are constructed in your application", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/dependency-injection/tree/v5.2.3" + "source": "https://github.com/symfony/dependency-injection/tree/v5.2.4" }, "funding": [ { @@ -3868,7 +3868,7 @@ "type": "tidelift" } ], - "time": "2021-01-27T12:56:27+00:00" + "time": "2021-03-04T15:41:09+00:00" }, { "name": "symfony/deprecation-contracts", @@ -3939,16 +3939,16 @@ }, { "name": "symfony/event-dispatcher", - "version": "v5.2.3", + "version": "v5.2.4", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "4f9760f8074978ad82e2ce854dff79a71fe45367" + "reference": "d08d6ec121a425897951900ab692b612a61d6240" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/4f9760f8074978ad82e2ce854dff79a71fe45367", - "reference": "4f9760f8074978ad82e2ce854dff79a71fe45367", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/d08d6ec121a425897951900ab692b612a61d6240", + "reference": "d08d6ec121a425897951900ab692b612a61d6240", "shasum": "" }, "require": { @@ -4004,7 +4004,7 @@ "description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/event-dispatcher/tree/v5.2.3" + "source": "https://github.com/symfony/event-dispatcher/tree/v5.2.4" }, "funding": [ { @@ -4020,7 +4020,7 @@ "type": "tidelift" } ], - "time": "2021-01-27T10:36:42+00:00" + "time": "2021-02-18T17:12:37+00:00" }, { "name": "symfony/event-dispatcher-contracts", @@ -4103,16 +4103,16 @@ }, { "name": "symfony/filesystem", - "version": "v5.2.3", + "version": "v5.2.4", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "262d033b57c73e8b59cd6e68a45c528318b15038" + "reference": "710d364200997a5afde34d9fe57bd52f3cc1e108" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/262d033b57c73e8b59cd6e68a45c528318b15038", - "reference": "262d033b57c73e8b59cd6e68a45c528318b15038", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/710d364200997a5afde34d9fe57bd52f3cc1e108", + "reference": "710d364200997a5afde34d9fe57bd52f3cc1e108", "shasum": "" }, "require": { @@ -4145,7 +4145,7 @@ "description": "Provides basic utilities for the filesystem", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/filesystem/tree/v5.2.3" + "source": "https://github.com/symfony/filesystem/tree/v5.2.4" }, "funding": [ { @@ -4161,20 +4161,20 @@ "type": "tidelift" } ], - "time": "2021-01-27T10:01:46+00:00" + "time": "2021-02-12T10:38:38+00:00" }, { "name": "symfony/finder", - "version": "v5.2.3", + "version": "v5.2.4", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "4adc8d172d602008c204c2e16956f99257248e03" + "reference": "0d639a0943822626290d169965804f79400e6a04" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/4adc8d172d602008c204c2e16956f99257248e03", - "reference": "4adc8d172d602008c204c2e16956f99257248e03", + "url": "https://api.github.com/repos/symfony/finder/zipball/0d639a0943822626290d169965804f79400e6a04", + "reference": "0d639a0943822626290d169965804f79400e6a04", "shasum": "" }, "require": { @@ -4206,7 +4206,7 @@ "description": "Finds files and directories via an intuitive fluent interface", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/finder/tree/v5.2.3" + "source": "https://github.com/symfony/finder/tree/v5.2.4" }, "funding": [ { @@ -4222,11 +4222,11 @@ "type": "tidelift" } ], - "time": "2021-01-28T22:06:19+00:00" + "time": "2021-02-15T18:55:04+00:00" }, { "name": "symfony/options-resolver", - "version": "v5.2.3", + "version": "v5.2.4", "source": { "type": "git", "url": "https://github.com/symfony/options-resolver.git", @@ -4275,7 +4275,7 @@ "options" ], "support": { - "source": "https://github.com/symfony/options-resolver/tree/v5.2.3" + "source": "https://github.com/symfony/options-resolver/tree/v5.2.4" }, "funding": [ { @@ -4925,7 +4925,7 @@ }, { "name": "symfony/process", - "version": "v5.2.3", + "version": "v5.2.4", "source": { "type": "git", "url": "https://github.com/symfony/process.git", @@ -4967,7 +4967,7 @@ "description": "Executes commands in sub-processes", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/process/tree/v5.2.3" + "source": "https://github.com/symfony/process/tree/v5.2.4" }, "funding": [ { @@ -5066,7 +5066,7 @@ }, { "name": "symfony/stopwatch", - "version": "v5.2.3", + "version": "v5.2.4", "source": { "type": "git", "url": "https://github.com/symfony/stopwatch.git", @@ -5108,7 +5108,7 @@ "description": "Provides a way to profile code", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/stopwatch/tree/v5.2.3" + "source": "https://github.com/symfony/stopwatch/tree/v5.2.4" }, "funding": [ { @@ -5128,16 +5128,16 @@ }, { "name": "symfony/string", - "version": "v5.2.3", + "version": "v5.2.4", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "c95468897f408dd0aca2ff582074423dd0455122" + "reference": "4e78d7d47061fa183639927ec40d607973699609" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/c95468897f408dd0aca2ff582074423dd0455122", - "reference": "c95468897f408dd0aca2ff582074423dd0455122", + "url": "https://api.github.com/repos/symfony/string/zipball/4e78d7d47061fa183639927ec40d607973699609", + "reference": "4e78d7d47061fa183639927ec40d607973699609", "shasum": "" }, "require": { @@ -5191,7 +5191,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v5.2.3" + "source": "https://github.com/symfony/string/tree/v5.2.4" }, "funding": [ { @@ -5207,7 +5207,7 @@ "type": "tidelift" } ], - "time": "2021-01-25T15:14:59+00:00" + "time": "2021-02-16T10:20:28+00:00" }, { "name": "theseer/tokenizer", From ef6106097561b1567f7b3f8c51a2d059860f659a Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 5 Mar 2021 16:25:15 +0900 Subject: [PATCH 04/11] chore: fix phpunit-helper version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index ee424de..ad4cff3 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ }, "require-dev": { "bamarni/composer-bin-plugin": "^1.4", - "kenjis/phpunit-helper": "^1.0" + "kenjis/phpunit-helper": "^1.1" }, "autoload": { "psr-4": { From afa0262914a307eb9d16ebf44e444be8752c72b2 Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 5 Mar 2021 16:30:21 +0900 Subject: [PATCH 05/11] refactor: remove `use MonkeyPatchManager` --- src/Traits/MonkeyPatchTrait.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Traits/MonkeyPatchTrait.php b/src/Traits/MonkeyPatchTrait.php index 5a752cc..c028880 100644 --- a/src/Traits/MonkeyPatchTrait.php +++ b/src/Traits/MonkeyPatchTrait.php @@ -14,7 +14,7 @@ namespace Kenjis\MonkeyPatch\Traits; use Kenjis\MonkeyPatch\MonkeyPatch; -use MonkeyPatchManager; +use Kenjis\MonkeyPatch\MonkeyPatchManager; use PHPUnit\Framework\ExpectationFailedException; use function class_exists; From 6ab12467fc87c90d1131021f1739e00ceb771eec Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 5 Mar 2021 16:30:53 +0900 Subject: [PATCH 06/11] refactor: add use statement --- src/functions/exit__.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/functions/exit__.php b/src/functions/exit__.php index 30668d4..5d4c79b 100644 --- a/src/functions/exit__.php +++ b/src/functions/exit__.php @@ -12,6 +12,7 @@ */ use Kenjis\MonkeyPatch\Exception\ExitException; +use Kenjis\MonkeyPatch\MonkeyPatchManager; /** * @param string|int|null $status @@ -30,7 +31,7 @@ function exit__($status = null): void $message = 'exit() called in ' . $class . '::' . $method . '()'; } - $exception_name = Kenjis\MonkeyPatch\MonkeyPatchManager::getExitExceptionClassname(); + $exception_name = MonkeyPatchManager::getExitExceptionClassname(); /** * @var ExitException From e76190cfa0cea7d4900abe48b8c6be8f35bb668b Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 5 Mar 2021 16:33:23 +0900 Subject: [PATCH 07/11] chore: add phpmd to `composer sa` --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index ad4cff3..7ca6d0c 100644 --- a/composer.json +++ b/composer.json @@ -53,7 +53,8 @@ ], "sa": [ "./vendor/bin/phpstan analyse -c phpstan.neon", - "psalm --show-info=true" + "psalm --show-info=true", + "./vendor/bin/phpmd src text ./phpmd.xml" ], "tests": [ "@cs", From 58664bd69a94c7c91d8857091aa9ba9e5ea90e2c Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 5 Mar 2021 16:39:00 +0900 Subject: [PATCH 08/11] chore: update phpmd.xml --- phpmd.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpmd.xml b/phpmd.xml index ddf1aed..7adba95 100644 --- a/phpmd.xml +++ b/phpmd.xml @@ -43,8 +43,8 @@ - - + + From a184cc289e3ee04a8fd01f9fe465e1afb8cc8a6f Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 5 Mar 2021 16:39:15 +0900 Subject: [PATCH 09/11] docs: add @SuppressWarnings --- src/IncludeStream.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/IncludeStream.php b/src/IncludeStream.php index 53a98e7..1c6176b 100644 --- a/src/IncludeStream.php +++ b/src/IncludeStream.php @@ -69,6 +69,9 @@ use const STREAM_OPTION_WRITE_BUFFER; use const STREAM_URL_STAT_QUIET; +/** + * @SuppressWarnings(PHPMD) + */ class IncludeStream { public const STREAM_OPEN_FOR_INCLUDE = 128; From c38497071b403d3f191c94b00e30f2a632bd02f0 Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 5 Mar 2021 16:39:29 +0900 Subject: [PATCH 10/11] refactor: remove unused variables --- src/MonkeyPatchManager.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/MonkeyPatchManager.php b/src/MonkeyPatchManager.php index 2dcec33..5fa392b 100644 --- a/src/MonkeyPatchManager.php +++ b/src/MonkeyPatchManager.php @@ -75,7 +75,7 @@ public static function log(string $message): void } $time = date('Y-m-d H:i:s'); - [$usec, $sec] = explode(' ', microtime()); + [$usec] = explode(' ', microtime()); $usec = substr($usec, 1); $log = "[$time $usec] $message\n"; file_put_contents(self::$log_file, $log, FILE_APPEND); @@ -325,7 +325,7 @@ public static function patch(string $path) $source = file_get_contents($path); assert(is_string($source)); - [$new_source, $patched] = self::execPatchers($source); + [$new_source] = self::execPatchers($source); // Write to cache file self::log('write_cache: ' . $path); From eb74566531e12d77f74d86365a2b88d2be21f24a Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 5 Mar 2021 16:42:58 +0900 Subject: [PATCH 11/11] chore: change target to 80% --- codecov.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/codecov.yml b/codecov.yml index 7a6ecf3..be3ee73 100644 --- a/codecov.yml +++ b/codecov.yml @@ -6,9 +6,9 @@ coverage: status: project: default: - target: 100% + target: 80% patch: default: - target: 100% + target: 80% comment: false