Skip to content

Commit 0235d4d

Browse files
Fix deprecations related to implicit nullable types
1 parent ecadbdc commit 0235d4d

File tree

8 files changed

+20
-10
lines changed

8 files changed

+20
-10
lines changed

.github/workflows/phpunit.yml

+8-3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ jobs:
2424
- "8.0"
2525
- "8.1"
2626
- "8.2"
27+
- "8.3"
28+
- "8.4"
2729
operating-system:
2830
- "ubuntu-latest"
2931
fail-fast: false
@@ -50,10 +52,13 @@ jobs:
5052
restore-keys: "php-${{ matrix.php-version }}"
5153

5254
- name: "Test with lowest dependencies"
53-
if: "matrix.php-version != '8.2'"
55+
if: "matrix.php-version != '8.4'"
5456
run: |
55-
composer update --prefer-lowest --no-interaction --no-progress --no-suggest && vendor/bin/simple-phpunit
57+
composer update --prefer-lowest --no-interaction --no-progress --no-suggest
58+
composer update symfony/phpunit-bridge --no-interaction --no-progress --no-suggest
59+
vendor/bin/simple-phpunit
5660
5761
- name: "Test with highest dependencies"
5862
run: |
59-
composer update --no-interaction --no-progress --no-suggest $([[ "${{ matrix.php-version }}" = "8.2" ]] && echo ' --ignore-platform-req=php+') && vendor/bin/simple-phpunit
63+
composer update --no-interaction --no-progress --no-suggest $([[ "${{ matrix.php-version }}" = "8.4" ]] && echo ' --ignore-platform-req=php+')
64+
vendor/bin/simple-phpunit

src/ProxyManager/Generator/MethodGenerator.php

+5
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ public static function copyMethodSignature(MethodReflection $reflectionMethod):
6767

6868
if ($default !== null) {
6969
$parameter->setDefaultValue(new ValueGenerator($default, $reflectionParameter));
70+
$type = $parameter->getType();
71+
72+
if ($default->getValue() === null && strpos($type ?? '?', '?') !== 0 && strpos($type, '|') === false) {
73+
$parameter->setType('?' . $type);
74+
}
7075
}
7176

7277
$method->setParameter($parameter);

src/ProxyManager/ProxyGenerator/AccessInterceptor/MethodGenerator/SetMethodPrefixInterceptor.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function __construct(PropertyGenerator $prefixInterceptor)
2727

2828
$interceptor = new ParameterGenerator('prefixInterceptor');
2929

30-
$interceptor->setType(Closure::class);
30+
$interceptor->setType('?' . Closure::class);
3131
$interceptor->setDefaultValue(null);
3232
$this->setParameter(new ParameterGenerator('methodName', 'string'));
3333
$this->setParameter($interceptor);

src/ProxyManager/ProxyGenerator/AccessInterceptor/MethodGenerator/SetMethodSuffixInterceptor.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function __construct(PropertyGenerator $suffixInterceptor)
2727

2828
$interceptor = new ParameterGenerator('suffixInterceptor');
2929

30-
$interceptor->setType(Closure::class);
30+
$interceptor->setType('?' . Closure::class);
3131
$interceptor->setDefaultValue(null);
3232
$this->setParameter(new ParameterGenerator('methodName', 'string'));
3333
$this->setParameter($interceptor);

src/ProxyManager/ProxyGenerator/LazyLoadingGhost/MethodGenerator/SetProxyInitializer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function __construct(PropertyGenerator $initializerProperty)
2222
{
2323
parent::__construct(
2424
'setProxyInitializer',
25-
[(new ParameterGenerator('initializer', Closure::class))->setDefaultValue(null)],
25+
[(new ParameterGenerator('initializer', '?' . Closure::class))->setDefaultValue(null)],
2626
self::FLAG_PUBLIC,
2727
'$this->' . $initializerProperty->getName() . ' = $initializer;'
2828
);

src/ProxyManager/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/SetProxyInitializer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function __construct(PropertyGenerator $initializerProperty)
2727

2828
$initializerParameter = new ParameterGenerator('initializer');
2929

30-
$initializerParameter->setType(Closure::class);
30+
$initializerParameter->setType('?' . Closure::class);
3131
$initializerParameter->setDefaultValue(null);
3232
$this->setParameter($initializerParameter);
3333
$this->setBody('$this->' . $initializerProperty->getName() . ' = $initializer;');

tests/ProxyManagerTestAsset/AccessInterceptorValueHolderMock.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ public static function staticProxyConstructor($instance, $prefixInterceptors, $s
4545
return $selfInstance;
4646
}
4747

48-
public function setMethodPrefixInterceptor(string $methodName, \Closure $prefixInterceptor = null) : void
48+
public function setMethodPrefixInterceptor(string $methodName, ?\Closure $prefixInterceptor = null) : void
4949
{
5050
// no-op (on purpose)
5151
}
5252

53-
public function setMethodSuffixInterceptor(string $methodName, \Closure $suffixInterceptor = null) : void
53+
public function setMethodSuffixInterceptor(string $methodName, ?\Closure $suffixInterceptor = null) : void
5454
{
5555
// no-op (on purpose)
5656
}

tests/ProxyManagerTestAsset/LazyLoadingMock.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public static function staticProxyConstructor($initializer) : self
3535
return $instance;
3636
}
3737

38-
public function setProxyInitializer(\Closure $initializer = null) : void
38+
public function setProxyInitializer(?\Closure $initializer = null) : void
3939
{
4040
$this->initializer = $initializer;
4141
}

0 commit comments

Comments
 (0)