Skip to content

Commit c65e8be

Browse files
Merge branch '11.5'
2 parents b01240d + 8da3b58 commit c65e8be

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

src/Framework/MockObject/Generator/Generator.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
namespace PHPUnit\Framework\MockObject\Generator;
1111

1212
use const PHP_EOL;
13+
use const PHP_VERSION;
1314
use function array_merge;
1415
use function array_pop;
1516
use function array_unique;
@@ -22,14 +23,14 @@
2223
use function interface_exists;
2324
use function is_array;
2425
use function md5;
25-
use function method_exists;
2626
use function mt_rand;
2727
use function preg_match;
2828
use function serialize;
2929
use function sort;
3030
use function sprintf;
3131
use function substr;
3232
use function trait_exists;
33+
use function version_compare;
3334
use Exception;
3435
use Iterator;
3536
use IteratorAggregate;
@@ -48,7 +49,6 @@
4849
use ReflectionClass;
4950
use ReflectionMethod;
5051
use ReflectionObject;
51-
use ReflectionProperty;
5252
use SebastianBergmann\Type\ReflectionMapper;
5353
use SebastianBergmann\Type\Type;
5454
use Throwable;
@@ -815,7 +815,7 @@ private function configurableMethods(DoubledMethodSet $methods, array $propertie
815815
*/
816816
private function properties(?ReflectionClass $class): array
817817
{
818-
if (!method_exists(ReflectionProperty::class, 'isFinal')) {
818+
if (version_compare('8.4.1', PHP_VERSION, '>')) {
819819
// @codeCoverageIgnoreStart
820820
return [];
821821
// @codeCoverageIgnoreEnd
@@ -829,12 +829,6 @@ private function properties(?ReflectionClass $class): array
829829
$properties = [];
830830

831831
foreach ($class->getProperties() as $property) {
832-
assert(method_exists($property, 'getHook'));
833-
assert(method_exists($property, 'hasHooks'));
834-
assert(method_exists($property, 'hasHook'));
835-
assert(method_exists($property, 'isFinal'));
836-
assert(class_exists(PropertyHookType::class));
837-
838832
if (!$property->isPublic()) {
839833
continue;
840834
}

tests/unit/Framework/MockObject/TestDoubleTestCase.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
use Exception;
1313
use PHPUnit\Framework\Attributes\IgnorePhpunitDeprecations;
14-
use PHPUnit\Framework\Attributes\RequiresMethod;
14+
use PHPUnit\Framework\Attributes\RequiresPhp;
1515
use PHPUnit\Framework\Attributes\TestDox;
1616
use PHPUnit\Framework\Attributes\Ticket;
1717
use PHPUnit\Framework\MockObject\Runtime\PropertyHook;
@@ -25,7 +25,6 @@
2525
use PHPUnit\TestFixture\MockObject\InterfaceWithNeverReturningMethod;
2626
use PHPUnit\TestFixture\MockObject\InterfaceWithPropertyWithGetHook;
2727
use PHPUnit\TestFixture\MockObject\InterfaceWithReturnTypeDeclaration;
28-
use ReflectionProperty;
2928
use stdClass;
3029

3130
abstract class TestDoubleTestCase extends TestCase
@@ -309,7 +308,7 @@ public function testDoubledMethodsCanBeCalledFromDestructorOnTestDoubleCreatedBy
309308
);
310309
}
311310

312-
#[RequiresMethod(ReflectionProperty::class, 'isFinal')]
311+
#[RequiresPhp('^8.4')]
313312
public function testGetHookForPropertyOfInterfaceCanBeConfigured(): void
314313
{
315314
$double = $this->createTestDouble(InterfaceWithPropertyWithGetHook::class);
@@ -319,7 +318,7 @@ public function testGetHookForPropertyOfInterfaceCanBeConfigured(): void
319318
$this->assertSame('value', $double->property);
320319
}
321320

322-
#[RequiresMethod(ReflectionProperty::class, 'isFinal')]
321+
#[RequiresPhp('^8.4')]
323322
public function testGetHookForPropertyOfExtendableClassCanBeConfigured(): void
324323
{
325324
$double = $this->createTestDouble(ExtendableClassWithPropertyWithGetHook::class);

0 commit comments

Comments
 (0)