Skip to content

Commit 8e1022f

Browse files
committed
added PHP 7.1 type hints
1 parent 1d90d52 commit 8e1022f

File tree

6 files changed

+13
-39
lines changed

6 files changed

+13
-39
lines changed

src/PhpGenerator/ClassType.php

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -124,20 +124,16 @@ public function __toString(): string
124124
}
125125

126126

127-
/**
128-
* @return PhpNamespace|null
129-
*/
130-
public function getNamespace()
127+
public function getNamespace(): ?PhpNamespace
131128
{
132129
return $this->namespace;
133130
}
134131

135132

136133
/**
137-
* @param string|null
138134
* @return static
139135
*/
140-
public function setName($name): self
136+
public function setName(?string $name): self
141137
{
142138
if ($name !== null && !Helpers::isIdentifier($name)) {
143139
throw new Nette\InvalidArgumentException("Value '$name' is not valid class name.");
@@ -147,10 +143,7 @@ public function setName($name): self
147143
}
148144

149145

150-
/**
151-
* @return string|null
152-
*/
153-
public function getName()
146+
public function getName(): ?string
154147
{
155148
return $this->name;
156149
}

src/PhpGenerator/Method.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,20 +75,16 @@ public function __toString(): string
7575

7676

7777
/**
78-
* @param string|null
7978
* @return static
8079
*/
81-
public function setBody($code, array $args = null): self
80+
public function setBody(?string $code, array $args = null): self
8281
{
8382
$this->body = $args === null ? $code : Helpers::formatArgs($code, $args);
8483
return $this;
8584
}
8685

8786

88-
/**
89-
* @return string|null
90-
*/
91-
public function getBody()
87+
public function getBody(): ?string
9288
{
9389
return $this->body;
9490
}

src/PhpGenerator/Parameter.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,20 +55,16 @@ public function isReference(): bool
5555

5656

5757
/**
58-
* @param string|null
5958
* @return static
6059
*/
61-
public function setTypeHint($hint): self
60+
public function setTypeHint(?string $hint): self
6261
{
6362
$this->typeHint = $hint ? (string) $hint : null;
6463
return $this;
6564
}
6665

6766

68-
/**
69-
* @return string|null
70-
*/
71-
public function getTypeHint()
67+
public function getTypeHint(): ?string
7268
{
7369
return $this->typeHint;
7470
}

src/PhpGenerator/Traits/CommentAware.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,16 @@ trait CommentAware
2020

2121

2222
/**
23-
* @param string|null
2423
* @return static
2524
*/
26-
public function setComment($val): self
25+
public function setComment(?string $val): self
2726
{
2827
$this->comment = $val ? (string) $val : null;
2928
return $this;
3029
}
3130

3231

33-
/**
34-
* @return string|null
35-
*/
36-
public function getComment()
32+
public function getComment(): ?string
3733
{
3834
return $this->comment;
3935
}

src/PhpGenerator/Traits/FunctionLike.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,20 +124,16 @@ public function isVariadic(): bool
124124

125125

126126
/**
127-
* @param string|null
128127
* @return static
129128
*/
130-
public function setReturnType($val): self
129+
public function setReturnType(?string $val): self
131130
{
132131
$this->returnType = $val ? (string) $val : null;
133132
return $this;
134133
}
135134

136135

137-
/**
138-
* @return string|null
139-
*/
140-
public function getReturnType()
136+
public function getReturnType(): ?string
141137
{
142138
return $this->returnType;
143139
}

src/PhpGenerator/Traits/VisibilityAware.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ trait VisibilityAware
2525
* @param string|null public|protected|private
2626
* @return static
2727
*/
28-
public function setVisibility($val): self
28+
public function setVisibility(?string $val): self
2929
{
3030
if (!in_array($val, ['public', 'protected', 'private', null], true)) {
3131
throw new Nette\InvalidArgumentException('Argument must be public|protected|private.');
@@ -35,10 +35,7 @@ public function setVisibility($val): self
3535
}
3636

3737

38-
/**
39-
* @return string|null
40-
*/
41-
public function getVisibility()
38+
public function getVisibility(): ?string
4239
{
4340
return $this->visibility;
4441
}

0 commit comments

Comments
 (0)