Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2debfd6

Browse files
committed
Parameter & Property: isNullable() returns true when default value is null (possible BC break)
For compatibility with PHP 8.4
1 parent 9afe1f0 commit 2debfd6

File tree

7 files changed

+8
-8
lines changed

7 files changed

+8
-8
lines changed

‎src/PhpGenerator/Parameter.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function setNullable(bool $state = true): static
6666

6767
public function isNullable(): bool
6868
{
69-
return $this->nullable;
69+
return $this->nullable || ($this->hasDefaultValue && $this->defaultValue === null);
7070
}
7171

7272

‎src/PhpGenerator/Property.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function setNullable(bool $state = true): static
8383

8484
public function isNullable(): bool
8585
{
86-
return $this->nullable;
86+
return $this->nullable || ($this->initialized && $this->value === null);
8787
}
8888

8989

‎tests/PhpGenerator/expected/ClassType.expect‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ abstract class Example extends ParentClass implements IExample, IOne
2727
public $order = RecursiveIteratorIterator::SELF_FIRST;
2828
public readonly array $typed1;
2929
public ?array $typed2 = null;
30-
public array $typed3 = null;
30+
public ?array $typed3 = null;
3131
public static $sections = ['first' => true];
3232

3333

‎tests/PhpGenerator/expected/Extractor.bodies.expect‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ abstract class Class7
4848
}
4949

5050

51-
function resolving($a = a\FOO, self $b = null, $c = self::FOO)
51+
function resolving($a = a\FOO, ?self $b = null, $c = self::FOO)
5252
{
5353
// constants
5454
echo FOO;

‎tests/PhpGenerator/expected/Extractor.bodies.resolving.expect‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ abstract class Class7
4343
}
4444

4545

46-
function resolving($a = \Abc\a\FOO, self $b = null, $c = self::FOO)
46+
function resolving($a = \Abc\a\FOO, ?self $b = null, $c = self::FOO)
4747
{
4848
// constants
4949
echo FOO;

‎tests/PhpGenerator/expected/Extractor.bodies.unresolving.expect‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ abstract class Class7
4343
}
4444

4545

46-
function resolving($a = \Abc\a\FOO, self $b = null, $c = self::FOO)
46+
function resolving($a = \Abc\a\FOO, ?self $b = null, $c = self::FOO)
4747
{
4848
// constants
4949
echo FOO;

‎tests/PhpGenerator/expected/Extractor.classes.expect‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class Class2 extends Class1 implements Interface2
7272
}
7373

7474

75-
private function func4(array $a = [], Class2 $b = null, $c = Unknown::ABC)
75+
private function func4(array $a = [], ?Class2 $b = null, $c = Unknown::ABC)
7676
{
7777
}
7878

@@ -94,7 +94,7 @@ class Class4
9494

9595
class Class5
9696
{
97-
public function func1(\A $a, ?\B $b, ?\C $c = null, \D $d = null, ?int $i = 1, ?array $arr = [])
97+
public function func1(\A $a, ?\B $b, ?\C $c = null, ?\D $d = null, ?int $i = 1, ?array $arr = [])
9898
{
9999
}
100100

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /