Skip to content

Commit 2d57a84

Browse files
committed
cs nullable typehints
1 parent 2072d9b commit 2d57a84

File tree

7 files changed

+15
-15
lines changed

7 files changed

+15
-15
lines changed

src/PhpGenerator/ClassType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public static function fromCode(string $code): self
123123
}
124124

125125

126-
public function __construct(string $name = null, PhpNamespace $namespace = null)
126+
public function __construct(?string $name = null, ?PhpNamespace $namespace = null)
127127
{
128128
$this->setName($name);
129129
$this->namespace = $namespace;

src/PhpGenerator/Literal.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Literal
2222
private $args;
2323

2424

25-
public function __construct(string $value, array $args = null)
25+
public function __construct(string $value, ?array $args = null)
2626
{
2727
$this->value = $value;
2828
$this->args = $args;

src/PhpGenerator/Method.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function __toString(): string
6464

6565

6666
/** @return static */
67-
public function setBody(?string $code, array $args = null): self
67+
public function setBody(?string $code, ?array $args = null): self
6868
{
6969
$this->body = $args === null || $code === null
7070
? $code

src/PhpGenerator/PhpFile.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public function getFunctions(): array
137137

138138

139139
/** @return static */
140-
public function addUse(string $name, string $alias = null, string $of = PhpNamespace::NAME_NORMAL): self
140+
public function addUse(string $name, ?string $alias = null, string $of = PhpNamespace::NAME_NORMAL): self
141141
{
142142
$this->addNamespace('')->addUse($name, $alias, $of);
143143
return $this;

src/PhpGenerator/PhpNamespace.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public function getBracketedSyntax(): bool
9494
* @throws InvalidStateException
9595
* @return static
9696
*/
97-
public function addUse(string $name, string $alias = null, string $of = self::NAME_NORMAL): self
97+
public function addUse(string $name, ?string $alias = null, string $of = self::NAME_NORMAL): self
9898
{
9999
if (
100100
!Helpers::isNamespaceIdentifier($name, true)
@@ -135,14 +135,14 @@ public function addUse(string $name, string $alias = null, string $of = self::NA
135135

136136

137137
/** @return static */
138-
public function addUseFunction(string $name, string $alias = null): self
138+
public function addUseFunction(string $name, ?string $alias = null): self
139139
{
140140
return $this->addUse($name, $alias, self::NAME_FUNCTION);
141141
}
142142

143143

144144
/** @return static */
145-
public function addUseConstant(string $name, string $alias = null): self
145+
public function addUseConstant(string $name, ?string $alias = null): self
146146
{
147147
return $this->addUse($name, $alias, self::NAME_CONSTANT);
148148
}

src/PhpGenerator/Printer.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function __construct()
5151
}
5252

5353

54-
public function printFunction(GlobalFunction $function, PhpNamespace $namespace = null): string
54+
public function printFunction(GlobalFunction $function, ?PhpNamespace $namespace = null): string
5555
{
5656
$this->namespace = $this->resolveTypes ? $namespace : null;
5757
$line = 'function '
@@ -69,7 +69,7 @@ public function printFunction(GlobalFunction $function, PhpNamespace $namespace
6969
}
7070

7171

72-
public function printClosure(Closure $closure, PhpNamespace $namespace = null): string
72+
public function printClosure(Closure $closure, ?PhpNamespace $namespace = null): string
7373
{
7474
$this->namespace = $this->resolveTypes ? $namespace : null;
7575
$uses = [];
@@ -92,7 +92,7 @@ public function printClosure(Closure $closure, PhpNamespace $namespace = null):
9292
}
9393

9494

95-
public function printArrowFunction(Closure $closure, PhpNamespace $namespace = null): string
95+
public function printArrowFunction(Closure $closure, ?PhpNamespace $namespace = null): string
9696
{
9797
$this->namespace = $this->resolveTypes ? $namespace : null;
9898
foreach ($closure->getUses() as $use) {
@@ -112,7 +112,7 @@ public function printArrowFunction(Closure $closure, PhpNamespace $namespace = n
112112
}
113113

114114

115-
public function printMethod(Method $method, PhpNamespace $namespace = null): string
115+
public function printMethod(Method $method, ?PhpNamespace $namespace = null): string
116116
{
117117
$this->namespace = $this->resolveTypes ? $namespace : null;
118118
$method->validate();
@@ -141,7 +141,7 @@ public function printMethod(Method $method, PhpNamespace $namespace = null): str
141141
}
142142

143143

144-
public function printClass(ClassType $class, PhpNamespace $namespace = null): string
144+
public function printClass(ClassType $class, ?PhpNamespace $namespace = null): string
145145
{
146146
$this->namespace = $this->resolveTypes ? $namespace : null;
147147
$class->validate();

src/PhpGenerator/Traits/FunctionLike.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ trait FunctionLike
4040

4141

4242
/** @return static */
43-
public function setBody(string $code, array $args = null): self
43+
public function setBody(string $code, ?array $args = null): self
4444
{
4545
$this->body = $args === null
4646
? $code
@@ -56,7 +56,7 @@ public function getBody(): string
5656

5757

5858
/** @return static */
59-
public function addBody(string $code, array $args = null): self
59+
public function addBody(string $code, ?array $args = null): self
6060
{
6161
$this->body .= ($args === null ? $code : (new Dumper)->format($code, ...$args)) . "\n";
6262
return $this;
@@ -180,7 +180,7 @@ public function getReturnNullable(): bool
180180

181181

182182
/** @deprecated */
183-
public function setNamespace(Nette\PhpGenerator\PhpNamespace $val = null): self
183+
public function setNamespace(?Nette\PhpGenerator\PhpNamespace $val = null): self
184184
{
185185
trigger_error(__METHOD__ . '() is deprecated', E_USER_DEPRECATED);
186186
return $this;

0 commit comments

Comments
 (0)