Skip to content

Commit e5e3a69

Browse files
committed
fix optional nullable parameters with another case
1 parent 9a8ca05 commit e5e3a69

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 8.0.6 (2024-01-17)
4+
5+
* Fixed optional nullable parameters with another case
6+
37
## 8.0.5 (2024-01-14)
48

59
* Restrict deprecated support for methods and functions without a return type to user-defined methods and functions

src/main/php/internal/Parameters.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ private function isNonOptionalNullable(ReflectionParameter $parameter): bool
8080
$type = $parameter->getType();
8181
return $type instanceof ReflectionNamedType
8282
&& 'mixed' !== $type->getName()
83-
&& !$parameter->isOptional()
84-
&& $parameter->allowsNull();
83+
&& ($parameter->isOptional() || $parameter->allowsNull());
8584
}
8685

8786
private function defaultValue(ReflectionParameter $parameter): string

src/test/php/NonOptionalNullableTest.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111
namespace bovigo\callmap;
1212

13+
use PDOStatement;
1314
use PHPUnit\Framework\Attributes\Group;
1415
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
1516
use PHPUnit\Framework\Attributes\Test;
@@ -22,19 +23,34 @@
2223
* @since 8.0.4
2324
*/
2425
#[Group('bug_nonoptional_nullable')]
25-
#[RequiresPhpExtension('xsl')]
2626
class NonOptionalNullableTest extends TestCase
2727
{
2828
/**
2929
* XSLTProcessor::setProfiling(?string $filename) has
3030
* a non-optional nullable parameter.
3131
*/
3232
#[Test]
33+
#[Group('xsl')]
34+
#[RequiresPhpExtension('xsl')]
3335
public function canCreateClassProxy(): void
3436
{
3537
assertInstanceOf(
3638
ClassProxy::class,
3739
NewInstance::of(XSLTProcessor::class)
3840
);
3941
}
42+
43+
/**
44+
* @since 8.0.6
45+
*/
46+
#[Test]
47+
#[Group('pdo')]
48+
#[RequiresPhpExtension('pdo')]
49+
public function canCreatePdoStatementProxy(): void
50+
{
51+
assertInstanceOf(
52+
ClassProxy::class,
53+
NewInstance::of(PDOStatement::class)
54+
);
55+
}
4056
}

0 commit comments

Comments
 (0)