Skip to content
Snippets Groups Projects
Commit c3142a2c authored by David Prévot's avatar David Prévot
Browse files

Update upstream source from tag 'upstream/2.11.1+1.0.18'

Update to upstream version '2.11.1+1.0.18'
with Debian dir 9a6bdbd5187dfb8c8f0178a5a4c6876a7cb6e723
parents 52877ae3 3501ce81
No related branches found
No related tags found
No related merge requests found
Showing
with 55 additions and 10 deletions
......@@ -24,6 +24,8 @@ jobs:
- "8.0"
- "8.1"
- "8.2"
- "8.3"
- "8.4"
operating-system:
- "ubuntu-latest"
fail-fast: false
......@@ -50,10 +52,13 @@ jobs:
restore-keys: "php-${{ matrix.php-version }}"
- name: "Test with lowest dependencies"
if: "matrix.php-version != '8.2'"
if: "matrix.php-version != '8.4'"
run: |
composer update --prefer-lowest --no-interaction --no-progress --no-suggest && vendor/bin/simple-phpunit
composer update --prefer-lowest --no-interaction --no-progress --no-suggest
composer update symfony/phpunit-bridge --no-interaction --no-progress --no-suggest
vendor/bin/simple-phpunit
- name: "Test with highest dependencies"
run: |
composer update --no-interaction --no-progress --no-suggest $([[ "${{ matrix.php-version }}" = "8.2" ]] && echo ' --ignore-platform-req=php+') && vendor/bin/simple-phpunit
composer update --no-interaction --no-progress --no-suggest $([[ "${{ matrix.php-version }}" = "8.4" ]] && echo ' --ignore-platform-req=php+')
vendor/bin/simple-phpunit
......@@ -67,6 +67,11 @@ class MethodGenerator extends LaminasMethodGenerator
if ($default !== null) {
$parameter->setDefaultValue(new ValueGenerator($default, $reflectionParameter));
$type = $parameter->getType();
if ($default->getValue() === null && strpos($type ?? '?', '?') !== 0 && strpos($type, '|') === false && $type !== 'mixed') {
$parameter->setType('?' . $type);
}
}
$method->setParameter($parameter);
......
......@@ -27,7 +27,7 @@ class SetMethodPrefixInterceptor extends MethodGenerator
$interceptor = new ParameterGenerator('prefixInterceptor');
$interceptor->setType(Closure::class);
$interceptor->setType('?' . Closure::class);
$interceptor->setDefaultValue(null);
$this->setParameter(new ParameterGenerator('methodName', 'string'));
$this->setParameter($interceptor);
......
......@@ -27,7 +27,7 @@ class SetMethodSuffixInterceptor extends MethodGenerator
$interceptor = new ParameterGenerator('suffixInterceptor');
$interceptor->setType(Closure::class);
$interceptor->setType('?' . Closure::class);
$interceptor->setDefaultValue(null);
$this->setParameter(new ParameterGenerator('methodName', 'string'));
$this->setParameter($interceptor);
......
......@@ -22,7 +22,7 @@ class SetProxyInitializer extends MethodGenerator
{
parent::__construct(
'setProxyInitializer',
[(new ParameterGenerator('initializer', Closure::class))->setDefaultValue(null)],
[(new ParameterGenerator('initializer', '?' . Closure::class))->setDefaultValue(null)],
self::FLAG_PUBLIC,
'$this->' . $initializerProperty->getName() . ' = $initializer;'
);
......
......@@ -27,7 +27,7 @@ class SetProxyInitializer extends MethodGenerator
$initializerParameter = new ParameterGenerator('initializer');
$initializerParameter->setType(Closure::class);
$initializerParameter->setType('?' . Closure::class);
$initializerParameter->setDefaultValue(null);
$this->setParameter($initializerParameter);
$this->setBody('$this->' . $initializerProperty->getName() . ' = $initializer;');
......
......@@ -10,6 +10,7 @@ use PHPUnit\Framework\TestCase;
use ProxyManager\Generator\MethodGenerator;
use ProxyManagerTestAsset\BaseClass;
use ProxyManagerTestAsset\ClassWithAbstractPublicMethod;
use ProxyManagerTestAsset\ClassWithNullDefaultMethodArguments;
use ProxyManagerTestAsset\EmptyClass;
use ProxyManagerTestAsset\ReturnTypeHintedClass;
use ProxyManagerTestAsset\ScalarTypeHintedClass;
......@@ -134,6 +135,27 @@ final class MethodGeneratorTest extends TestCase
];
}
/**
* @requires PHP 8.0
*/
public function testGenerateMethodWithNullDefaultMixedArgument(): void
{
$method = MethodGenerator::fromReflectionWithoutBodyAndDocBlock(new MethodReflection(
ClassWithNullDefaultMethodArguments::class,
'acceptMixed'
));
self::assertSame('acceptMixed', $method->getName());
$parameters = $method->getParameters();
self::assertCount(1, $parameters);
$param = $parameters['param'];
self::assertSame('mixed', $param->getType());
}
public function testGenerateMethodWithVoidReturnTypeHinting(): void
{
$method = MethodGenerator::fromReflectionWithoutBodyAndDocBlock(new MethodReflection(
......
......@@ -45,12 +45,12 @@ class AccessInterceptorValueHolderMock implements AccessInterceptorValueHolderIn
return $selfInstance;
}
public function setMethodPrefixInterceptor(string $methodName, \Closure $prefixInterceptor = null) : void
public function setMethodPrefixInterceptor(string $methodName, ?\Closure $prefixInterceptor = null) : void
{
// no-op (on purpose)
}
public function setMethodSuffixInterceptor(string $methodName, \Closure $suffixInterceptor = null) : void
public function setMethodSuffixInterceptor(string $methodName, ?\Closure $suffixInterceptor = null) : void
{
// no-op (on purpose)
}
......
<?php
declare(strict_types=1);
namespace ProxyManagerTestAsset;
class ClassWithNullDefaultMethodArguments
{
public function acceptMixed(mixed $param = null)
{
return $param;
}
}
......@@ -35,7 +35,7 @@ class LazyLoadingMock implements VirtualProxyInterface, GhostObjectInterface
return $instance;
}
public function setProxyInitializer(\Closure $initializer = null) : void
public function setProxyInitializer(?\Closure $initializer = null) : void
{
$this->initializer = $initializer;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment