From 35b2bf5a2d6a352eed7933c0f1d9f1e5448b6c35 Mon Sep 17 00:00:00 2001 From: Akihito Koriyama Date: Thu, 18 Feb 2021 09:51:42 +0900 Subject: [PATCH 1/4] Add red testGetNamedArgumentsWithDefaultValue test --- tests/Fake/FakeClass.php | 4 ++++ tests/ReflectiveMethodInvocationTest.php | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/tests/Fake/FakeClass.php b/tests/Fake/FakeClass.php index 85e5bf45..48fdb28b 100644 --- a/tests/Fake/FakeClass.php +++ b/tests/Fake/FakeClass.php @@ -45,4 +45,8 @@ public function getTriple(int $c): int { return $c * 3; } + + public function defaultValue(int $a = 1) + { + } } diff --git a/tests/ReflectiveMethodInvocationTest.php b/tests/ReflectiveMethodInvocationTest.php index 9da04c07..e607520d 100644 --- a/tests/ReflectiveMethodInvocationTest.php +++ b/tests/ReflectiveMethodInvocationTest.php @@ -85,6 +85,16 @@ public function testGetNamedArguments(): void $this->assertSame((array) $args, ['n' => 1]); } + /** + * @covers ReflectiveMethodInvocation::getNamedArguments + */ + public function testGetNamedArgumentsWithDefaultValue(): void + { + $invocation = new ReflectiveMethodInvocation(new FakeWeavedClass(), 'defaultValue', [], [new FakeInterceptor(), new FakeInterceptor()]); + $args = $invocation->getNamedArguments(); + $this->assertSame((array) $args, []); + } + public function testGetAnnotation(): void { $fakeMarker = $this->invocation->getMethod()->getAnnotation(FakeMarker::class); From 0ec8b223e34b1e78cdbd2077eddf673e7fe2a6f2 Mon Sep 17 00:00:00 2001 From: Akihito Koriyama Date: Thu, 18 Feb 2021 09:51:58 +0900 Subject: [PATCH 2/4] Chec argument exists --- src/ReflectiveMethodInvocation.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/ReflectiveMethodInvocation.php b/src/ReflectiveMethodInvocation.php index 6220acd2..b9d0b7de 100644 --- a/src/ReflectiveMethodInvocation.php +++ b/src/ReflectiveMethodInvocation.php @@ -85,8 +85,11 @@ public function getNamedArguments(): ArrayObject $params = $this->getMethod()->getParameters(); $namedParams = []; foreach ($params as $param) { - /** @psalm-suppress MixedAssignment */ - $namedParams[$param->getName()] = $args[$param->getPosition()]; + $pos = $param->getPosition(); + if (isset($args[$pos])) { + /** @psalm-suppress MixedAssignment */ + $namedParams[$param->getName()] = $args[$pos]; + } } return new ArrayObject($namedParams); From 634cda2cc5f4e181ff18df18be3b91f24632d7b2 Mon Sep 17 00:00:00 2001 From: Akihito Koriyama Date: Thu, 18 Feb 2021 09:52:12 +0900 Subject: [PATCH 3/4] Update composer.lock --- vendor-bin/tools/composer.lock | 169 ++++++++++++++++++--------------- 1 file changed, 91 insertions(+), 78 deletions(-) diff --git a/vendor-bin/tools/composer.lock b/vendor-bin/tools/composer.lock index 00550c25..c0f887b1 100644 --- a/vendor-bin/tools/composer.lock +++ b/vendor-bin/tools/composer.lock @@ -1531,16 +1531,16 @@ }, { "name": "phpstan/phpstan", - "version": "0.12.68", + "version": "0.12.77", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "ddbe01af0706ee094c3f1ce9730b35aebb508d3d" + "reference": "1f10b8c8d118d01e7b492f9707999d456be5812c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/ddbe01af0706ee094c3f1ce9730b35aebb508d3d", - "reference": "ddbe01af0706ee094c3f1ce9730b35aebb508d3d", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/1f10b8c8d118d01e7b492f9707999d456be5812c", + "reference": "1f10b8c8d118d01e7b492f9707999d456be5812c", "shasum": "" }, "require": { @@ -1569,6 +1569,10 @@ "MIT" ], "description": "PHPStan - PHP Static Analysis Tool", + "support": { + "issues": "https://github.com/phpstan/phpstan/issues", + "source": "https://github.com/phpstan/phpstan/tree/0.12.77" + }, "funding": [ { "url": "https://github.com/ondrejmirtes", @@ -1583,7 +1587,7 @@ "type": "tidelift" } ], - "time": "2021-01-18T12:29:17+00:00" + "time": "2021-02-17T16:22:19+00:00" }, { "name": "phpunit/php-code-coverage", @@ -1905,16 +1909,16 @@ }, { "name": "phpunit/phpunit", - "version": "9.5.1", + "version": "9.5.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "e7bdf4085de85a825f4424eae52c99a1cec2f360" + "reference": "f661659747f2f87f9e72095bb207bceb0f151cb4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/e7bdf4085de85a825f4424eae52c99a1cec2f360", - "reference": "e7bdf4085de85a825f4424eae52c99a1cec2f360", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/f661659747f2f87f9e72095bb207bceb0f151cb4", + "reference": "f661659747f2f87f9e72095bb207bceb0f151cb4", "shasum": "" }, "require": { @@ -1990,6 +1994,10 @@ "testing", "xunit" ], + "support": { + "issues": "https://github.com/sebastianbergmann/phpunit/issues", + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.2" + }, "funding": [ { "url": "https://phpunit.de/donate.html", @@ -2000,7 +2008,7 @@ "type": "github" } ], - "time": "2021-01-17T07:42:25+00:00" + "time": "2021-02-02T14:45:58+00:00" }, { "name": "psalm/plugin-phpunit", @@ -3244,16 +3252,16 @@ }, { "name": "symfony/config", - "version": "v5.2.1", + "version": "v5.2.3", "source": { "type": "git", "url": "https://github.com/symfony/config.git", - "reference": "d0a82d965296083fe463d655a3644cbe49cbaa80" + "reference": "50e0e1314a3b2609d32b6a5a0d0fb5342494c4ab" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/config/zipball/d0a82d965296083fe463d655a3644cbe49cbaa80", - "reference": "d0a82d965296083fe463d655a3644cbe49cbaa80", + "url": "https://api.github.com/repos/symfony/config/zipball/50e0e1314a3b2609d32b6a5a0d0fb5342494c4ab", + "reference": "50e0e1314a3b2609d32b6a5a0d0fb5342494c4ab", "shasum": "" }, "require": { @@ -3299,10 +3307,10 @@ "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony Config Component", + "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.1" + "source": "https://github.com/symfony/config/tree/v5.2.3" }, "funding": [ { @@ -3318,20 +3326,20 @@ "type": "tidelift" } ], - "time": "2020-12-09T18:54:12+00:00" + "time": "2021-01-27T10:15:41+00:00" }, { "name": "symfony/console", - "version": "v5.2.1", + "version": "v5.2.3", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "47c02526c532fb381374dab26df05e7313978976" + "reference": "89d4b176d12a2946a1ae4e34906a025b7b6b135a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/47c02526c532fb381374dab26df05e7313978976", - "reference": "47c02526c532fb381374dab26df05e7313978976", + "url": "https://api.github.com/repos/symfony/console/zipball/89d4b176d12a2946a1ae4e34906a025b7b6b135a", + "reference": "89d4b176d12a2946a1ae4e34906a025b7b6b135a", "shasum": "" }, "require": { @@ -3390,7 +3398,7 @@ "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony Console Component", + "description": "Eases the creation of beautiful and testable command line interfaces", "homepage": "https://symfony.com", "keywords": [ "cli", @@ -3399,7 +3407,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v5.2.1" + "source": "https://github.com/symfony/console/tree/v5.2.3" }, "funding": [ { @@ -3415,20 +3423,20 @@ "type": "tidelift" } ], - "time": "2020-12-18T08:03:05+00:00" + "time": "2021-01-28T22:06:19+00:00" }, { "name": "symfony/dependency-injection", - "version": "v5.2.1", + "version": "v5.2.3", "source": { "type": "git", "url": "https://github.com/symfony/dependency-injection.git", - "reference": "7f8a9e9eff0581a33e20f6c5d41096fe22832d25" + "reference": "62f72187be689540385dce6c68a5d4c16f034139" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/7f8a9e9eff0581a33e20f6c5d41096fe22832d25", - "reference": "7f8a9e9eff0581a33e20f6c5d41096fe22832d25", + "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/62f72187be689540385dce6c68a5d4c16f034139", + "reference": "62f72187be689540385dce6c68a5d4c16f034139", "shasum": "" }, "require": { @@ -3483,10 +3491,10 @@ "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony DependencyInjection Component", + "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.1" + "source": "https://github.com/symfony/dependency-injection/tree/v5.2.3" }, "funding": [ { @@ -3502,7 +3510,7 @@ "type": "tidelift" } ], - "time": "2020-12-18T08:03:05+00:00" + "time": "2021-01-27T12:56:27+00:00" }, { "name": "symfony/deprecation-contracts", @@ -3573,16 +3581,16 @@ }, { "name": "symfony/filesystem", - "version": "v5.2.1", + "version": "v5.2.3", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "fa8f8cab6b65e2d99a118e082935344c5ba8c60d" + "reference": "262d033b57c73e8b59cd6e68a45c528318b15038" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/fa8f8cab6b65e2d99a118e082935344c5ba8c60d", - "reference": "fa8f8cab6b65e2d99a118e082935344c5ba8c60d", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/262d033b57c73e8b59cd6e68a45c528318b15038", + "reference": "262d033b57c73e8b59cd6e68a45c528318b15038", "shasum": "" }, "require": { @@ -3612,10 +3620,10 @@ "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony Filesystem Component", + "description": "Provides basic utilities for the filesystem", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/filesystem/tree/v5.2.1" + "source": "https://github.com/symfony/filesystem/tree/v5.2.3" }, "funding": [ { @@ -3631,11 +3639,11 @@ "type": "tidelift" } ], - "time": "2020-11-30T17:05:38+00:00" + "time": "2021-01-27T10:01:46+00:00" }, { "name": "symfony/polyfill-ctype", - "version": "v1.22.0", + "version": "v1.22.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", @@ -3694,7 +3702,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.22.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.22.1" }, "funding": [ { @@ -3714,16 +3722,16 @@ }, { "name": "symfony/polyfill-intl-grapheme", - "version": "v1.22.0", + "version": "v1.22.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-grapheme.git", - "reference": "267a9adeb8ecb8071040a740930e077cdfb987af" + "reference": "5601e09b69f26c1828b13b6bb87cb07cddba3170" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/267a9adeb8ecb8071040a740930e077cdfb987af", - "reference": "267a9adeb8ecb8071040a740930e077cdfb987af", + "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/5601e09b69f26c1828b13b6bb87cb07cddba3170", + "reference": "5601e09b69f26c1828b13b6bb87cb07cddba3170", "shasum": "" }, "require": { @@ -3775,7 +3783,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.22.0" + "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.22.1" }, "funding": [ { @@ -3791,20 +3799,20 @@ "type": "tidelift" } ], - "time": "2021-01-07T16:49:33+00:00" + "time": "2021-01-22T09:19:47+00:00" }, { "name": "symfony/polyfill-intl-normalizer", - "version": "v1.22.0", + "version": "v1.22.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-normalizer.git", - "reference": "6e971c891537eb617a00bb07a43d182a6915faba" + "reference": "43a0283138253ed1d48d352ab6d0bdb3f809f248" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/6e971c891537eb617a00bb07a43d182a6915faba", - "reference": "6e971c891537eb617a00bb07a43d182a6915faba", + "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/43a0283138253ed1d48d352ab6d0bdb3f809f248", + "reference": "43a0283138253ed1d48d352ab6d0bdb3f809f248", "shasum": "" }, "require": { @@ -3859,7 +3867,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.22.0" + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.22.1" }, "funding": [ { @@ -3875,20 +3883,20 @@ "type": "tidelift" } ], - "time": "2021-01-07T17:09:11+00:00" + "time": "2021-01-22T09:19:47+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.22.0", + "version": "v1.22.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "f377a3dd1fde44d37b9831d68dc8dea3ffd28e13" + "reference": "5232de97ee3b75b0360528dae24e73db49566ab1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/f377a3dd1fde44d37b9831d68dc8dea3ffd28e13", - "reference": "f377a3dd1fde44d37b9831d68dc8dea3ffd28e13", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/5232de97ee3b75b0360528dae24e73db49566ab1", + "reference": "5232de97ee3b75b0360528dae24e73db49566ab1", "shasum": "" }, "require": { @@ -3939,7 +3947,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.22.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.22.1" }, "funding": [ { @@ -3955,11 +3963,11 @@ "type": "tidelift" } ], - "time": "2021-01-07T16:49:33+00:00" + "time": "2021-01-22T09:19:47+00:00" }, { "name": "symfony/polyfill-php73", - "version": "v1.22.0", + "version": "v1.22.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php73.git", @@ -4018,7 +4026,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php73/tree/v1.22.0" + "source": "https://github.com/symfony/polyfill-php73/tree/v1.22.1" }, "funding": [ { @@ -4038,7 +4046,7 @@ }, { "name": "symfony/polyfill-php80", - "version": "v1.22.0", + "version": "v1.22.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", @@ -4101,7 +4109,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.22.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.22.1" }, "funding": [ { @@ -4200,16 +4208,16 @@ }, { "name": "symfony/string", - "version": "v5.2.1", + "version": "v5.2.3", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "5bd67751d2e3f7d6f770c9154b8fbcb2aa05f7ed" + "reference": "c95468897f408dd0aca2ff582074423dd0455122" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/5bd67751d2e3f7d6f770c9154b8fbcb2aa05f7ed", - "reference": "5bd67751d2e3f7d6f770c9154b8fbcb2aa05f7ed", + "url": "https://api.github.com/repos/symfony/string/zipball/c95468897f408dd0aca2ff582074423dd0455122", + "reference": "c95468897f408dd0aca2ff582074423dd0455122", "shasum": "" }, "require": { @@ -4252,7 +4260,7 @@ "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony String component", + "description": "Provides an object-oriented API to strings and deals with bytes, UTF-8 code points and grapheme clusters in a unified way", "homepage": "https://symfony.com", "keywords": [ "grapheme", @@ -4263,7 +4271,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v5.2.1" + "source": "https://github.com/symfony/string/tree/v5.2.3" }, "funding": [ { @@ -4279,7 +4287,7 @@ "type": "tidelift" } ], - "time": "2020-12-05T07:33:16+00:00" + "time": "2021-01-25T15:14:59+00:00" }, { "name": "theseer/tokenizer", @@ -4333,16 +4341,16 @@ }, { "name": "vimeo/psalm", - "version": "4.4.1", + "version": "4.6.1", "source": { "type": "git", "url": "https://github.com/vimeo/psalm.git", - "reference": "9fd7a7d885b3a216cff8dec9d8c21a132f275224" + "reference": "e93e532e4eaad6d68c4d7b606853800eaceccc72" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/vimeo/psalm/zipball/9fd7a7d885b3a216cff8dec9d8c21a132f275224", - "reference": "9fd7a7d885b3a216cff8dec9d8c21a132f275224", + "url": "https://api.github.com/repos/vimeo/psalm/zipball/e93e532e4eaad6d68c4d7b606853800eaceccc72", + "reference": "e93e532e4eaad6d68c4d7b606853800eaceccc72", "shasum": "" }, "require": { @@ -4360,7 +4368,7 @@ "ext-tokenizer": "*", "felixfbecker/advanced-json-rpc": "^3.0.3", "felixfbecker/language-server-protocol": "^1.4", - "netresearch/jsonmapper": "^1.0 || ^2.0 || ^3.0", + "netresearch/jsonmapper": "^1.0 || ^2.0 || ^3.0 || ^4.0", "nikic/php-parser": "^4.10.1", "openlss/lib-array2xml": "^1.0", "php": "^7.1|^8", @@ -4376,6 +4384,7 @@ "bamarni/composer-bin-plugin": "^1.2", "brianium/paratest": "^4.0||^6.0", "ext-curl": "*", + "php-parallel-lint/php-parallel-lint": "^1.2", "phpdocumentor/reflection-docblock": "^5", "phpmyadmin/sql-parser": "5.1.0||dev-master", "phpspec/prophecy": ">=1.9.0", @@ -4429,7 +4438,11 @@ "inspection", "php" ], - "time": "2021-01-14T21:44:29+00:00" + "support": { + "issues": "https://github.com/vimeo/psalm/issues", + "source": "https://github.com/vimeo/psalm/tree/4.6.1" + }, + "time": "2021-02-17T21:54:11+00:00" }, { "name": "webmozart/assert", @@ -4479,8 +4492,8 @@ "validate" ], "support": { - "issues": "https://github.com/webmozart/assert/issues", - "source": "https://github.com/webmozart/assert/tree/master" + "issues": "https://github.com/webmozarts/assert/issues", + "source": "https://github.com/webmozarts/assert/tree/1.9.1" }, "time": "2020-07-08T17:02:28+00:00" }, @@ -4543,5 +4556,5 @@ "prefer-lowest": false, "platform": [], "platform-dev": [], - "plugin-api-version": "1.1.0" + "plugin-api-version": "2.0.0" } From 85f7ebe7eb44b69b66fe376c6227dd8fef27a22e Mon Sep 17 00:00:00 2001 From: Akihito Koriyama Date: Thu, 18 Feb 2021 09:59:18 +0900 Subject: [PATCH 4/4] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index b39d0bea..d90ec748 100644 --- a/composer.json +++ b/composer.json @@ -49,7 +49,7 @@ "cs-fix": ["./vendor/bin/phpcbf src tests"], "clean": ["./vendor/bin/phpstan clear-result-cache", "./vendor/bin/psalm --clear-cache", "rm -rf tests/tmp/*.php"], "sa": ["./vendor/bin/phpstan analyse -c phpstan.neon", "psalm --show-info=true"], - "metrics": ["./vendor/bin/phpmetrics --report-html=build/metrics --exclude=Exception --log-junit=build/junit.xml --junit=build/junit.xml src"], + "metrics": ["./vendor/bin/phpmetrics --report-html=build/metrics --exclude=Exception src"], "phpmd": ["./vendor/bin/phpmd src text ./phpmd.xml"], "build": ["@cs", "@sa", "@pcov", "@metrics"] }