From a32a2c68998c4422dc6de4e0036501608601cbb0 Mon Sep 17 00:00:00 2001 From: Tom Klingenberg Date: Wed, 5 Aug 2020 00:53:33 +0200 Subject: [PATCH 1/5] WS-Fixes Phpunit upstream indents (prefixes) docblock @param annotations and I can imagine that some white-space has been taken over from that into the stub files when writing them. Also for separation by empty lines between methods which looks as well as an error quickly porting from upstream (better than anything else). --- stubs/MockBuilder.phpstub | 2 +- stubs/TestCase.phpstub | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/stubs/MockBuilder.phpstub b/stubs/MockBuilder.phpstub index 2ffcde3..ea97e34 100644 --- a/stubs/MockBuilder.phpstub +++ b/stubs/MockBuilder.phpstub @@ -11,7 +11,7 @@ class MockBuilder { /** * @template-typeof T $type - * @param TestCase $testCase + * @param TestCase $testCase * @param class-string $type */ public function __construct(TestCase $testCase, $type) {} diff --git a/stubs/TestCase.phpstub b/stubs/TestCase.phpstub index 2e6e0cf..46edfc7 100644 --- a/stubs/TestCase.phpstub +++ b/stubs/TestCase.phpstub @@ -30,6 +30,7 @@ abstract class TestCase extends Assert implements Test, SelfDescribing * @return ObjectProphecy */ public function prophesize($classOrInterface): ObjectProphecy {} + /** * @param class-string<\Throwable> $exception * @return void From 7ccaf51a10a1e2fc6b852cad61fdc8d64e8ca96d Mon Sep 17 00:00:00 2001 From: Tom Klingenberg Date: Wed, 5 Aug 2020 01:04:43 +0200 Subject: [PATCH 2/5] Resolve Constraint for MockBuilder stubs File contains two classes (one class and one interface), the mock-object interface was missing resolution for Constraint. This Constraint is PHPUnit\Framework\Constraint\Constraint. --- stubs/MockBuilder.phpstub | 1 + 1 file changed, 1 insertion(+) diff --git a/stubs/MockBuilder.phpstub b/stubs/MockBuilder.phpstub index ea97e34..f5a3e5f 100644 --- a/stubs/MockBuilder.phpstub +++ b/stubs/MockBuilder.phpstub @@ -3,6 +3,7 @@ namespace PHPUnit\Framework\MockObject; use PHPUnit\Framework\TestCase; use PHPUnit\Framework\MockObject\Builder\InvocationMocker; +use PHPUnit\Framework\Constraint\Constraint; /** * @template T From 7355af1380331864440b86482b7b54953d949b50 Mon Sep 17 00:00:00 2001 From: Tom Klingenberg Date: Wed, 5 Aug 2020 02:00:24 +0200 Subject: [PATCH 3/5] Remove superfluous phpcs:ignoreFile marker Remove markers that command PHP_CodeSniffer (Pear package base-name for "phpcs") to skip files based on their own configuration as those files are already with the .phpstub extension which effectively has them not configured/already ignored by phpcs base/upstr. configuration (project configuration file: phpcs.xml.dist) Fix is to remove these markers/directives, also not all .phpstub files had them therefore this is effectively streamlining the file formats for .phpstub to this regard. --- stubs/Assert_75.phpstub | 2 +- stubs/TestCase.phpstub | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/stubs/Assert_75.phpstub b/stubs/Assert_75.phpstub index a318639..37e6ff2 100644 --- a/stubs/Assert_75.phpstub +++ b/stubs/Assert_75.phpstub @@ -1,4 +1,4 @@ - Date: Wed, 5 Aug 2020 02:02:19 +0200 Subject: [PATCH 4/5] Fix visibility TestCase::createMock Upstream PHPUnit\Framework\TestCase::createMock() is protected, not public. Fix is to set the proper upstream visibility; change from public to protected. Public for the method introcuded back in 2018 in fa76f652. Checked against Phpunit 7.5+ and 8. Ref: fa76f65209a4cb4c0da2e144935bad7919d94951 --- stubs/TestCase.phpstub | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/TestCase.phpstub b/stubs/TestCase.phpstub index 17fa82a..a6509b6 100644 --- a/stubs/TestCase.phpstub +++ b/stubs/TestCase.phpstub @@ -12,7 +12,7 @@ abstract class TestCase extends Assert implements Test, SelfDescribing * @param class-string $class * @return MockObject&T */ - public function createMock($class) {} + protected function createMock($class) {} /** * Returns a builder object to create mock objects using a fluent interface. From 45fd05f3553a571c0cc92fd10f22200dc913e962 Mon Sep 17 00:00:00 2001 From: Tom Klingenberg Date: Wed, 5 Aug 2020 03:12:57 +0200 Subject: [PATCH 5/5] Add TestCase::createConfigured/PartialMock() to stub Previously the create-configured and create-partial mock-methods were not part of the stub. Add them. --- stubs/TestCase.phpstub | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/stubs/TestCase.phpstub b/stubs/TestCase.phpstub index a6509b6..b910c9d 100644 --- a/stubs/TestCase.phpstub +++ b/stubs/TestCase.phpstub @@ -14,6 +14,24 @@ abstract class TestCase extends Assert implements Test, SelfDescribing */ protected function createMock($class) {} + /** + * @template T + * @param class-string $class + * @param array $config + * @return MockObject&T + */ + protected function createConfiguredMock($class, array $config) {} + + /** + * Returns a partial test double for the specified class. + * + * @template T + * @param class-string $class + * @param array $methods + * @return MockObject&T + */ + protected function createPartialMock($class, array $methods) {} + /** * Returns a builder object to create mock objects using a fluent interface. *