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 a580c50

Browse files
committed
FunctionLike changed to abstract class
1 parent da995ca commit a580c50

File tree

7 files changed

+18
-28
lines changed

7 files changed

+18
-28
lines changed

‎src/PhpGenerator/Closure.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,12 @@
99

1010
namespace Nette\PhpGenerator;
1111

12-
use Nette;
13-
1412

1513
/**
1614
* Closure.
17-
*
18-
* @property-deprecated string $body
1915
*/
20-
final class Closure
16+
final class Closureextends FunctionLike
2117
{
22-
use Nette\SmartObject;
23-
use Traits\FunctionLike;
2418
use Traits\AttributeAware;
2519

2620
/** @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: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,22 @@
77

88
declare(strict_types=1);
99

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

1212
use JetBrains\PhpStorm\Language;
1313
use Nette;
14-
use Nette\PhpGenerator\Dumper;
15-
use Nette\PhpGenerator\Parameter;
1614
use Nette\Utils\Type;
1715

1816

1917
/**
20-
* @internal
18+
* GlobalFunction/Closure/Method description.
19+
*
20+
* @property-deprecated string $body
2121
*/
22-
trait FunctionLike
22+
abstractclass FunctionLike
2323
{
24+
use Nette\SmartObject;
25+
2426
private string $body = '';
2527

2628
/** @var Parameter[] */

‎src/PhpGenerator/GlobalFunction.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,12 @@
99

1010
namespace Nette\PhpGenerator;
1111

12-
use Nette;
13-
1412

1513
/**
1614
* Global function.
17-
*
18-
* @property-deprecated string $body
1915
*/
20-
final class GlobalFunction
16+
final class GlobalFunctionextends FunctionLike
2117
{
22-
use Nette\SmartObject;
23-
use Traits\FunctionLike;
2418
use Traits\NameAware;
2519
use Traits\CommentAware;
2620
use Traits\AttributeAware;

‎src/PhpGenerator/Method.php

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

1515
/**
1616
* Class method.
17-
*
18-
* @property-deprecated string|null $body
1917
*/
20-
final class Method
18+
final class Methodextends FunctionLike
2119
{
22-
use Nette\SmartObject;
23-
use Traits\FunctionLike;
2420
use Traits\NameAware;
2521
use Traits\VisibilityAware;
2622
use Traits\CommentAware;
@@ -92,7 +88,11 @@ public function addPromotedParameter(string $name, mixed $defaultValue = null):
9288
$param->setDefaultValue($defaultValue);
9389
}
9490

95-
return $this->parameters[$name] = $param;
91+
$params = $this->getParameters();
92+
$params[$name] = $param;
93+
$this->setParameters($params);
94+
95+
return $param;
9696
}
9797

9898

‎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 によって変換されたページ (->オリジナル) /