Skip to content

Commit 587bfdd

Browse files
Merge remote-tracking branch 'upstream/2.12.x' into 1.x
* upstream/2.12.x: Bump laminas/laminas-code from 4.2.2 to 4.3.0 Bump nikic/php-parser from 4.10.4 to 4.10.5 Bump laminas/laminas-code from 4.2.1 to 4.2.2 Bump laminas/laminas-code from 4.2.0 to 4.2.1 Bump webimpress/safe-writer from 2.1.0 to 2.2.0 Adjusted references to `laminas/laminas-code` symbols that were made more type-safe (or rather precise) with `4.1.0+` Bump laminas/laminas-code from 4.0.0 to 4.2.0 Bump doctrine/coding-standard from 8.2.0 to 8.2.1 Fix doc url Bump squizlabs/php_codesniffer from 3.5.8 to 3.6.0 Bump infection/infection from 0.21.4 to 0.21.5 Bump phpunit/phpunit from 9.5.3 to 9.5.4 Bump phpunit/phpunit from 9.5.2 to 9.5.3 Bump infection/infection from 0.21.2 to 0.21.4 Bump infection/infection from 0.21.0 to 0.21.2 Bump phpunit/phpunit from 9.5.1 to 9.5.2 Bump codelicia/xulieta from 0.1.5 to 0.1.6
2 parents 9b3d488 + 568e465 commit 587bfdd

File tree

8 files changed

+45
-26
lines changed

8 files changed

+45
-26
lines changed

composer.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
"homepage": "http://ocramius.github.io/"
1919
},
2020
{
21-
"name": "Nicolas Grekas",
22-
"email": "[email protected]"
21+
"name": "Nicolas Grekas",
22+
"email": "[email protected]"
2323
}
2424
],
2525
"replace": {
@@ -36,7 +36,7 @@
3636
},
3737
"require-dev": {
3838
"ext-phar": "*",
39-
"symfony/phpunit-bridge": "^5.2"
39+
"symfony/phpunit-bridge": "^5.2|^6.0"
4040
},
4141
"autoload": {
4242
"psr-4": {

src/ProxyManager/Generator/MagicMethodGenerator.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace ProxyManager\Generator;
66

7+
use Laminas\Code\Generator\ParameterGenerator;
78
use ReflectionClass;
89

910
use function strtolower;
@@ -14,7 +15,7 @@
1415
class MagicMethodGenerator extends MethodGenerator
1516
{
1617
/**
17-
* @param mixed[] $parameters
18+
* @param ParameterGenerator[]|array[]|string[] $parameters
1819
*/
1920
public function __construct(ReflectionClass $originalClass, string $name, array $parameters = [])
2021
{

src/ProxyManager/GeneratorStrategy/FileWriterGeneratorStrategy.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function __construct(FileLocatorInterface $fileLocator)
4444
public function generate(ClassGenerator $classGenerator): string
4545
{
4646
$generatedCode = $classGenerator->generate();
47-
$className = $classGenerator->getNamespaceName() . '\\' . $classGenerator->getName();
47+
$className = (string) $classGenerator->getNamespaceName() . '\\' . $classGenerator->getName();
4848
$fileName = $this->fileLocator->getProxyFileName($className);
4949

5050
set_error_handler($this->emptyErrorHandler);

tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/PropertyGenerator/InitializationTrackerTest.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ protected function createProperty(): PropertyGenerator
2323

2424
public function testInitializationFlagIsFalseByDefault(): void
2525
{
26-
$property = $this->createProperty();
26+
$defaultValue = $this->createProperty()
27+
->getDefaultValue();
2728

28-
self::assertFalse($property->getDefaultValue()->getValue());
29+
self::assertNotNull($defaultValue);
30+
self::assertFalse($defaultValue->getValue());
2931
}
3032
}

tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/PropertyGenerator/PrivatePropertiesMapTest.php

+8-6
Original file line numberDiff line numberDiff line change
@@ -30,27 +30,29 @@ protected function createProperty(): PropertyGenerator
3030

3131
public function testExtractsProtectedProperties(): void
3232
{
33-
$map = new PrivatePropertiesMap(
33+
$defaultValue = (new PrivatePropertiesMap(
3434
Properties::fromReflectionClass(new ReflectionClass(ClassWithMixedProperties::class))
35-
);
35+
))->getDefaultValue();
3636

37+
self::assertNotNull($defaultValue);
3738
self::assertSame(
3839
[
3940
'privateProperty0' => [ClassWithMixedProperties::class => true],
4041
'privateProperty1' => [ClassWithMixedProperties::class => true],
4142
'privateProperty2' => [ClassWithMixedProperties::class => true],
4243
],
43-
$map->getDefaultValue()->getValue()
44+
$defaultValue->getValue()
4445
);
4546
}
4647

4748
public function testSkipsAbstractProtectedMethods(): void
4849
{
49-
$map = new PrivatePropertiesMap(
50+
$defaultValue = (new PrivatePropertiesMap(
5051
Properties::fromReflectionClass(new ReflectionClass(ClassWithAbstractProtectedMethod::class))
51-
);
52+
))->getDefaultValue();
5253

53-
self::assertSame([], $map->getDefaultValue()->getValue());
54+
self::assertNotNull($defaultValue);
55+
self::assertSame([], $defaultValue->getValue());
5456
}
5557

5658
public function testIsStaticPrivate(): void

tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/PropertyGenerator/ProtectedPropertiesMapTest.php

+8-6
Original file line numberDiff line numberDiff line change
@@ -29,27 +29,29 @@ protected function createProperty(): PropertyGenerator
2929

3030
public function testExtractsProtectedProperties(): void
3131
{
32-
$map = new ProtectedPropertiesMap(
32+
$defaultValue = (new ProtectedPropertiesMap(
3333
Properties::fromReflectionClass(new ReflectionClass(ClassWithMixedProperties::class))
34-
);
34+
))->getDefaultValue();
3535

36+
self::assertNotNull($defaultValue);
3637
self::assertSame(
3738
[
3839
'protectedProperty0' => ClassWithMixedProperties::class,
3940
'protectedProperty1' => ClassWithMixedProperties::class,
4041
'protectedProperty2' => ClassWithMixedProperties::class,
4142
],
42-
$map->getDefaultValue()->getValue()
43+
$defaultValue->getValue()
4344
);
4445
}
4546

4647
public function testSkipsAbstractProtectedMethods(): void
4748
{
48-
$map = new ProtectedPropertiesMap(
49+
$defaultValue = (new ProtectedPropertiesMap(
4950
Properties::fromReflectionClass(new ReflectionClass(ClassWithAbstractProtectedMethod::class))
50-
);
51+
))->getDefaultValue();
5152

52-
self::assertSame([], $map->getDefaultValue()->getValue());
53+
self::assertNotNull($defaultValue);
54+
self::assertSame([], $defaultValue->getValue());
5355
}
5456

5557
public function testIsStaticPrivate(): void

tests/ProxyManagerTest/ProxyGenerator/PropertyGenerator/PublicPropertiesMapTest.php

+15-6
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,11 @@ public function testEmptyClass(): void
2626
Properties::fromReflectionClass(new ReflectionClass(EmptyClass::class))
2727
);
2828

29-
self::assertIsArray($publicProperties->getDefaultValue()->getValue());
30-
self::assertEmpty($publicProperties->getDefaultValue()->getValue());
29+
$defaultValue = $publicProperties->getDefaultValue();
30+
31+
self::assertNotNull($defaultValue);
32+
self::assertIsArray($defaultValue->getValue());
33+
self::assertEmpty($defaultValue->getValue());
3134
self::assertTrue($publicProperties->isStatic());
3235
self::assertSame('private', $publicProperties->getVisibility());
3336
self::assertTrue($publicProperties->isEmpty());
@@ -39,9 +42,12 @@ public function testClassWithPublicProperties(): void
3942
Properties::fromReflectionClass(new ReflectionClass(ClassWithPublicProperties::class))
4043
);
4144

45+
$defaultValue = $publicProperties->getDefaultValue();
46+
4247
self::assertTrue($publicProperties->isStatic());
4348
self::assertSame('private', $publicProperties->getVisibility());
4449
self::assertFalse($publicProperties->isEmpty());
50+
self::assertNotNull($defaultValue);
4551
self::assertSame(
4652
[
4753
'property0' => true,
@@ -55,21 +61,24 @@ public function testClassWithPublicProperties(): void
5561
'property8' => true,
5662
'property9' => true,
5763
],
58-
$publicProperties->getDefaultValue()->getValue()
64+
$defaultValue->getValue()
5965
);
6066
}
6167

6268
public function testClassWithMixedProperties(): void
6369
{
70+
$defaultValue = (new PublicPropertiesMap(
71+
Properties::fromReflectionClass(new ReflectionClass(ClassWithMixedProperties::class))
72+
))->getDefaultValue();
73+
74+
self::assertNotNull($defaultValue);
6475
self::assertSame(
6576
[
6677
'publicProperty0' => true,
6778
'publicProperty1' => true,
6879
'publicProperty2' => true,
6980
],
70-
(new PublicPropertiesMap(
71-
Properties::fromReflectionClass(new ReflectionClass(ClassWithMixedProperties::class))
72-
))->getDefaultValue()->getValue()
81+
$defaultValue->getValue()
7382
);
7483
}
7584
}

tests/ProxyManagerTest/Signature/ClassSignatureGeneratorTest.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,13 @@ public function testAddSignature(): void
3737
->expects(self::once())
3838
->method('addPropertyFromGenerator')
3939
->with(self::callback(static function (PropertyGenerator $property): bool {
40+
$defaultValue = $property->getDefaultValue();
41+
4042
return $property->getName() === 'signaturePropertyName'
4143
&& $property->isStatic()
4244
&& $property->getVisibility() === 'private'
43-
&& $property->getDefaultValue()->getValue() === 'valid-signature';
45+
&& $defaultValue !== null
46+
&& $defaultValue->getValue() === 'valid-signature';
4447
}));
4548

4649
$this

0 commit comments

Comments
 (0)