Skip to content

Commit 0439a21

Browse files
committed
fixed bugs reported by PHPStan
1 parent a15649b commit 0439a21

File tree

8 files changed

+9
-11
lines changed

8 files changed

+9
-11
lines changed

src/PhpGenerator/ClassType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ final class ClassType
6969

7070
/**
7171
* @param string|object $class
72-
* @return static
7372
*/
7473
public static function from($class): self
7574
{
@@ -93,6 +92,7 @@ public function __toString(): string
9392
throw $e;
9493
}
9594
trigger_error('Exception in ' . __METHOD__ . "(): {$e->getMessage()} in {$e->getFile()}:{$e->getLine()}", E_USER_ERROR);
95+
return '';
9696
}
9797
}
9898

src/PhpGenerator/Closure.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ final class Closure
2626
private $uses = [];
2727

2828

29-
/**
30-
* @return static
31-
*/
3229
public static function from(\Closure $closure): self
3330
{
3431
return (new Factory)->fromFunctionReflection(new \ReflectionFunction($closure));
@@ -44,6 +41,7 @@ public function __toString(): string
4441
throw $e;
4542
}
4643
trigger_error('Exception in ' . __METHOD__ . "(): {$e->getMessage()} in {$e->getFile()}:{$e->getLine()}", E_USER_ERROR);
44+
return '';
4745
}
4846
}
4947

src/PhpGenerator/GlobalFunction.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ final class GlobalFunction
2424
use Traits\NameAware;
2525
use Traits\CommentAware;
2626

27-
/**
28-
* @return static
29-
*/
3027
public static function from(string $function): self
3128
{
3229
return (new Factory)->fromFunctionReflection(new \ReflectionFunction($function));
@@ -42,6 +39,7 @@ public function __toString(): string
4239
throw $e;
4340
}
4441
trigger_error('Exception in ' . __METHOD__ . "(): {$e->getMessage()} in {$e->getFile()}:{$e->getLine()}", E_USER_ERROR);
42+
return '';
4543
}
4644
}
4745
}

src/PhpGenerator/Method.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ final class Method
4040

4141
/**
4242
* @param string|array $method
43-
* @return static
4443
*/
4544
public static function from($method): self
4645
{
@@ -57,6 +56,7 @@ public function __toString(): string
5756
throw $e;
5857
}
5958
trigger_error('Exception in ' . __METHOD__ . "(): {$e->getMessage()} in {$e->getFile()}:{$e->getLine()}", E_USER_ERROR);
59+
return '';
6060
}
6161
}
6262

src/PhpGenerator/PhpFile.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ public function __toString(): string
120120
throw $e;
121121
}
122122
trigger_error('Exception in ' . __METHOD__ . "(): {$e->getMessage()} in {$e->getFile()}:{$e->getLine()}", E_USER_ERROR);
123+
return '';
123124
}
124125
}
125126
}

src/PhpGenerator/PhpNamespace.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ public function __toString(): string
204204
throw $e;
205205
}
206206
trigger_error('Exception in ' . __METHOD__ . "(): {$e->getMessage()} in {$e->getFile()}:{$e->getLine()}", E_USER_ERROR);
207+
return '';
207208
}
208209
}
209210
}

src/PhpGenerator/Printer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ protected function printUses(PhpNamespace $namespace): string
241241

242242

243243
/**
244-
* @param Nette\PhpGenerator\Traits\FunctionLike $function
244+
* @param Closure|GlobalFunction|Method $function
245245
*/
246246
protected function printParameters($function, ?PhpNamespace $namespace): string
247247
{
@@ -264,7 +264,7 @@ protected function printParameters($function, ?PhpNamespace $namespace): string
264264

265265

266266
/**
267-
* @param Nette\PhpGenerator\Traits\FunctionLike $function
267+
* @param Closure|GlobalFunction|Method $function
268268
*/
269269
protected function printReturnType($function, ?PhpNamespace $namespace): string
270270
{

src/PhpGenerator/Traits/FunctionLike.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ public function getReturnNullable(): bool
188188
/**
189189
* @deprecated
190190
*/
191-
public function setNamespace(PhpNamespace $val = null): self
191+
public function setNamespace(Nette\PhpGenerator\PhpNamespace $val = null): self
192192
{
193193
trigger_error(__METHOD__ . '() is deprecated', E_USER_DEPRECATED);
194194
return $this;

0 commit comments

Comments
 (0)