Skip to content

Commit f4a2c56

Browse files
committedMar 19, 2025
feat: Support for PHPUnit 12.0.9
See: sebastianbergmann/phpunit#6156
1 parent 7b7a5cd commit f4a2c56

File tree

2 files changed

+66
-2
lines changed

2 files changed

+66
-2
lines changed
 

‎src/Plugin.php

+6-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@ public function __invoke(RegistrationInterface $psalm, ?SimpleXMLElement $config
1616
$psalm->addStubFile(__DIR__ . '/../stubs/Assert_75.phpstub');
1717
}
1818
$psalm->addStubFile(__DIR__ . '/../stubs/TestCase.phpstub');
19-
$psalm->addStubFile(__DIR__ . '/../stubs/MockBuilder.phpstub');
20-
$psalm->addStubFile(__DIR__ . '/../stubs/InvocationMocker.phpstub');
19+
if (VersionUtils::packageVersionIs('phpunit/phpunit', '<', '12.0.9')) {
20+
$psalm->addStubFile(__DIR__ . '/../stubs/MockBuilder.phpstub');
21+
$psalm->addStubFile(__DIR__ . '/../stubs/InvocationMocker.phpstub');
22+
} else {
23+
$psalm->addStubFile(__DIR__ . '/../stubs/MockBuilder_120.phpstub');
24+
}
2125
$psalm->addStubFile(__DIR__ . '/../stubs/Prophecy.phpstub');
2226

2327
class_exists(Hooks\TestCaseHandler::class, true);

‎stubs/MockBuilder_120.phpstub

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?php
2+
namespace PHPUnit\Framework\MockObject;
3+
4+
use PHPUnit\Framework\TestCase;
5+
use PHPUnit\Framework\Constraint\Constraint;
6+
7+
/**
8+
* @template T
9+
*/
10+
class MockBuilder
11+
{
12+
/**
13+
* @template-typeof T $type
14+
* @param TestCase $testCase
15+
* @param class-string $type
16+
*/
17+
public function __construct(TestCase $testCase, $type) {}
18+
19+
/**
20+
* Creates a mock object using a fluent interface.
21+
*
22+
* @return MockObject&T
23+
*/
24+
public function getMock() {}
25+
26+
/**
27+
* @return MockObject&T
28+
*/
29+
public function getMockForAbstractClass() {}
30+
31+
/**
32+
* Specifies the subset of methods to mock. Default is to mock none of them.
33+
*
34+
* @param array|null $methods
35+
*
36+
* @return static
37+
*/
38+
public function setMethods(array $methods = null) {}
39+
40+
/**
41+
* Specifies the arguments for the constructor.
42+
*
43+
* @param array $args
44+
*
45+
* @return static
46+
*/
47+
public function setConstructorArgs(array $args) {}
48+
}
49+
50+
interface MockObject
51+
{
52+
/**
53+
* @param Constraint|string $constraint
54+
*
55+
* @return InvocationStubber
56+
*
57+
* @throws \RuntimeException
58+
*/
59+
public function method($constraint);
60+
}

0 commit comments

Comments
 (0)
Please sign in to comment.