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 99835ca

Browse files
committed
FunctionLike changed to abstract class
1 parent 13480f6 commit 99835ca

File tree

7 files changed

+16
-21
lines changed

7 files changed

+16
-21
lines changed

‎src/PhpGenerator/Closure.php‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,10 @@
1414

1515
/**
1616
* Closure.
17-
*
18-
* @property-deprecated string $body
1917
*/
20-
final class Closure
18+
final class Closureextends FunctionLike
2119
{
2220
use Nette\SmartObject;
23-
use Traits\FunctionLike;
2421
use Traits\AttributeAware;
2522

2623
/** @var Parameter[] */

‎src/PhpGenerator/Extractor.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ private function addCommentAndAttributes($element, Node $node): void
385385
}
386386

387387

388-
private function setupFunction(GlobalFunction|Method $function, Node\FunctionLike $node): void
388+
private function setupFunction(FunctionLike $function, Node\FunctionLike $node): void
389389
{
390390
$function->setReturnReference($node->returnsByRef());
391391
$function->setReturnType($node->getReturnType() ? $this->toPhp($node->getReturnType()) : null);

‎src/PhpGenerator/Factory.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ public function fromFunctionReflection(\ReflectionFunction $from, bool $withBody
194194
}
195195

196196

197-
public function fromCallable(callable $from): Method|GlobalFunction|Closure
197+
public function fromCallable(callable $from): FunctionLike
198198
{
199199
$ref = Nette\Utils\Callback::toReflection($from);
200200
return $ref instanceof \ReflectionMethod

‎src/PhpGenerator/Traits/FunctionLike.php‎ renamed to ‎src/PhpGenerator/FunctionLike.php‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@
77

88
declare(strict_types=1);
99

10-
namespace Nette\PhpGenerator\Traits;
10+
namespace Nette\PhpGenerator;
1111

1212
use Nette;
13-
use Nette\PhpGenerator\Dumper;
14-
use Nette\PhpGenerator\Parameter;
1513
use Nette\Utils\Type;
1614

1715

1816
/**
19-
* @internal
17+
* GlobalFunction/Closure/Method description.
18+
*
19+
* @property-deprecated string $body
2020
*/
21-
trait FunctionLike
21+
abstractclass FunctionLike
2222
{
2323
private string $body = '';
2424

‎src/PhpGenerator/GlobalFunction.php‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,10 @@
1414

1515
/**
1616
* Global function.
17-
*
18-
* @property-deprecated string $body
1917
*/
20-
final class GlobalFunction
18+
final class GlobalFunctionextends FunctionLike
2119
{
2220
use Nette\SmartObject;
23-
use Traits\FunctionLike;
2421
use Traits\NameAware;
2522
use Traits\CommentAware;
2623
use Traits\AttributeAware;

‎src/PhpGenerator/Method.php‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,10 @@
1414

1515
/**
1616
* Class method.
17-
*
18-
* @property-deprecated string|null $body
1917
*/
20-
final class Method
18+
final class Methodextends FunctionLike
2119
{
2220
use Nette\SmartObject;
23-
use Traits\FunctionLike;
2421
use Traits\NameAware;
2522
use Traits\VisibilityAware;
2623
use Traits\CommentAware;
@@ -92,7 +89,11 @@ public function addPromotedParameter(string $name, mixed $defaultValue = null):
9289
$param->setDefaultValue($defaultValue);
9390
}
9491

95-
return $this->parameters[$name] = $param;
92+
$params = $this->getParameters();
93+
$params[$name] = $param;
94+
$this->setParameters($params);
95+
96+
return $param;
9697
}
9798

9899

‎src/PhpGenerator/Printer.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ protected function printDocComment(/*Traits\CommentAware*/ $commentable): string
385385
}
386386

387387

388-
private function printReturnType(Closure|GlobalFunction|Method $function): string
388+
private function printReturnType(FunctionLike $function): string
389389
{
390390
return ($tmp = $this->printType($function->getReturnType(), $function->isReturnNullable()))
391391
? $this->returnTypeColon . $tmp

0 commit comments

Comments
(0)

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