Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/2.12.x' into 1.x
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
nicolas-grekas committed May 19, 2021
2 parents 9b3d488 + 568e465 commit 587bfdd
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 26 deletions.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"homepage": "http://ocramius.github.io/"
},
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
}
],
"replace": {
Expand All @@ -36,7 +36,7 @@
},
"require-dev": {
"ext-phar": "*",
"symfony/phpunit-bridge": "^5.2"
"symfony/phpunit-bridge": "^5.2|^6.0"
},
"autoload": {
"psr-4": {
Expand Down
3 changes: 2 additions & 1 deletion src/ProxyManager/Generator/MagicMethodGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace ProxyManager\Generator;

use Laminas\Code\Generator\ParameterGenerator;
use ReflectionClass;

use function strtolower;
Expand All @@ -14,7 +15,7 @@
class MagicMethodGenerator extends MethodGenerator
{
/**
* @param mixed[] $parameters
* @param ParameterGenerator[]|array[]|string[] $parameters
*/
public function __construct(ReflectionClass $originalClass, string $name, array $parameters = [])
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function __construct(FileLocatorInterface $fileLocator)
public function generate(ClassGenerator $classGenerator): string
{
$generatedCode = $classGenerator->generate();
$className = $classGenerator->getNamespaceName() . '\\' . $classGenerator->getName();
$className = (string) $classGenerator->getNamespaceName() . '\\' . $classGenerator->getName();
$fileName = $this->fileLocator->getProxyFileName($className);

set_error_handler($this->emptyErrorHandler);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ protected function createProperty(): PropertyGenerator

public function testInitializationFlagIsFalseByDefault(): void
{
$property = $this->createProperty();
$defaultValue = $this->createProperty()
->getDefaultValue();

self::assertFalse($property->getDefaultValue()->getValue());
self::assertNotNull($defaultValue);
self::assertFalse($defaultValue->getValue());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,29 @@ protected function createProperty(): PropertyGenerator

public function testExtractsProtectedProperties(): void
{
$map = new PrivatePropertiesMap(
$defaultValue = (new PrivatePropertiesMap(
Properties::fromReflectionClass(new ReflectionClass(ClassWithMixedProperties::class))
);
))->getDefaultValue();

self::assertNotNull($defaultValue);
self::assertSame(
[
'privateProperty0' => [ClassWithMixedProperties::class => true],
'privateProperty1' => [ClassWithMixedProperties::class => true],
'privateProperty2' => [ClassWithMixedProperties::class => true],
],
$map->getDefaultValue()->getValue()
$defaultValue->getValue()
);
}

public function testSkipsAbstractProtectedMethods(): void
{
$map = new PrivatePropertiesMap(
$defaultValue = (new PrivatePropertiesMap(
Properties::fromReflectionClass(new ReflectionClass(ClassWithAbstractProtectedMethod::class))
);
))->getDefaultValue();

self::assertSame([], $map->getDefaultValue()->getValue());
self::assertNotNull($defaultValue);
self::assertSame([], $defaultValue->getValue());
}

public function testIsStaticPrivate(): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,29 @@ protected function createProperty(): PropertyGenerator

public function testExtractsProtectedProperties(): void
{
$map = new ProtectedPropertiesMap(
$defaultValue = (new ProtectedPropertiesMap(
Properties::fromReflectionClass(new ReflectionClass(ClassWithMixedProperties::class))
);
))->getDefaultValue();

self::assertNotNull($defaultValue);
self::assertSame(
[
'protectedProperty0' => ClassWithMixedProperties::class,
'protectedProperty1' => ClassWithMixedProperties::class,
'protectedProperty2' => ClassWithMixedProperties::class,
],
$map->getDefaultValue()->getValue()
$defaultValue->getValue()
);
}

public function testSkipsAbstractProtectedMethods(): void
{
$map = new ProtectedPropertiesMap(
$defaultValue = (new ProtectedPropertiesMap(
Properties::fromReflectionClass(new ReflectionClass(ClassWithAbstractProtectedMethod::class))
);
))->getDefaultValue();

self::assertSame([], $map->getDefaultValue()->getValue());
self::assertNotNull($defaultValue);
self::assertSame([], $defaultValue->getValue());
}

public function testIsStaticPrivate(): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@ public function testEmptyClass(): void
Properties::fromReflectionClass(new ReflectionClass(EmptyClass::class))
);

self::assertIsArray($publicProperties->getDefaultValue()->getValue());
self::assertEmpty($publicProperties->getDefaultValue()->getValue());
$defaultValue = $publicProperties->getDefaultValue();

self::assertNotNull($defaultValue);
self::assertIsArray($defaultValue->getValue());
self::assertEmpty($defaultValue->getValue());
self::assertTrue($publicProperties->isStatic());
self::assertSame('private', $publicProperties->getVisibility());
self::assertTrue($publicProperties->isEmpty());
Expand All @@ -39,9 +42,12 @@ public function testClassWithPublicProperties(): void
Properties::fromReflectionClass(new ReflectionClass(ClassWithPublicProperties::class))
);

$defaultValue = $publicProperties->getDefaultValue();

self::assertTrue($publicProperties->isStatic());
self::assertSame('private', $publicProperties->getVisibility());
self::assertFalse($publicProperties->isEmpty());
self::assertNotNull($defaultValue);
self::assertSame(
[
'property0' => true,
Expand All @@ -55,21 +61,24 @@ public function testClassWithPublicProperties(): void
'property8' => true,
'property9' => true,
],
$publicProperties->getDefaultValue()->getValue()
$defaultValue->getValue()
);
}

public function testClassWithMixedProperties(): void
{
$defaultValue = (new PublicPropertiesMap(
Properties::fromReflectionClass(new ReflectionClass(ClassWithMixedProperties::class))
))->getDefaultValue();

self::assertNotNull($defaultValue);
self::assertSame(
[
'publicProperty0' => true,
'publicProperty1' => true,
'publicProperty2' => true,
],
(new PublicPropertiesMap(
Properties::fromReflectionClass(new ReflectionClass(ClassWithMixedProperties::class))
))->getDefaultValue()->getValue()
$defaultValue->getValue()
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,13 @@ public function testAddSignature(): void
->expects(self::once())
->method('addPropertyFromGenerator')
->with(self::callback(static function (PropertyGenerator $property): bool {
$defaultValue = $property->getDefaultValue();

return $property->getName() === 'signaturePropertyName'
&& $property->isStatic()
&& $property->getVisibility() === 'private'
&& $property->getDefaultValue()->getValue() === 'valid-signature';
&& $defaultValue !== null
&& $defaultValue->getValue() === 'valid-signature';
}));

$this
Expand Down

0 comments on commit 587bfdd

Please sign in to comment.