Skip to content

Commit

Permalink
used PhpStorm Language attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Mar 13, 2023
1 parent 70acf62 commit e9f713c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"nette/tester": "^2.4",
"nikic/php-parser": "^4.15",
"tracy/tracy": "^2.8",
"phpstan/phpstan": "^1.0"
"phpstan/phpstan": "^1.0",
"jetbrains/phpstorm-attributes": "dev-master"
},
"suggest": {
"nikic/php-parser": "to use ClassType::from(withBodies: true) & ClassType::fromCode()"
Expand Down
13 changes: 11 additions & 2 deletions src/PhpGenerator/Traits/FunctionLike.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

namespace Nette\PhpGenerator\Traits;

use JetBrains\PhpStorm\Language;
use Nette;
use Nette\PhpGenerator\Dumper;
use Nette\PhpGenerator\Parameter;
Expand All @@ -31,7 +32,11 @@ trait FunctionLike


/** @param ?mixed[] $args */
public function setBody(string $code, ?array $args = null): static
public function setBody(
#[Language('PHP')]
string $code,
?array $args = null,
): static
{
$this->body = $args === null
? $code
Expand All @@ -47,7 +52,11 @@ public function getBody(): string


/** @param ?mixed[] $args */
public function addBody(string $code, ?array $args = null): static
public function addBody(
#[Language('PHP')]
string $code,
?array $args = null,
): static
{
$this->body .= ($args === null ? $code : (new Dumper)->format($code, ...$args)) . "\n";
return $this;
Expand Down

0 comments on commit e9f713c

Please sign in to comment.