Skip to content

Commit c1d720e

Browse files
committed
marked new deprecated stuff
1 parent fc77854 commit c1d720e

15 files changed

+31
-17
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"phpstan/phpstan": "^1.0"
2626
},
2727
"suggest": {
28-
"nikic/php-parser": "to use ClassType::withBodiesFrom() & GlobalFunction::withBodyFrom()"
28+
"nikic/php-parser": "to use ClassType::from(withBodies: true) & ClassType::fromCode()"
2929
},
3030
"autoload": {
3131
"classmap": ["src/"]

readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -721,9 +721,9 @@ Function and method bodies are empty by default. If you want to load them as wel
721721
(it requires `nikic/php-parser` to be installed):
722722

723723
```php
724-
$class = Nette\PhpGenerator\ClassType::withBodiesFrom(MyClass::class);
724+
$class = Nette\PhpGenerator\ClassType::from(PDO::class, withBodies: true);
725725

726-
$function = Nette\PhpGenerator\GlobalFunction::withBodyFrom('dump');
726+
$function = Nette\PhpGenerator\GlobalFunction::from('dump', withBody: true);
727727
```
728728

729729
Load class from file

src/PhpGenerator/ClassType.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,10 @@ public static function from(string|object $class, bool $withBodies = false, bool
9999
}
100100

101101

102+
/** @deprecated use ClassType::from(..., withBodies: true) */
102103
public static function withBodiesFrom(string|object $class): self
103104
{
105+
trigger_error(__METHOD__ . '() is deprecated, use ClassType::from(..., withBodies: true)', E_USER_DEPRECATED);
104106
return (new Factory)
105107
->fromClassReflection(new \ReflectionClass($class), withBodies: true);
106108
}
@@ -150,9 +152,10 @@ public function getName(): ?string
150152
}
151153

152154

153-
/** @deprecated */
155+
/** @deprecated use setType('class') or create using ClassType::class() */
154156
public function setClass(): static
155157
{
158+
trigger_error(__METHOD__ . "() is deprecated, use setType('class').", E_USER_DEPRECATED);
156159
$this->type = self::TYPE_CLASS;
157160
return $this;
158161
}
@@ -164,8 +167,10 @@ public function isClass(): bool
164167
}
165168

166169

170+
/** @deprecated use setType('interface') or create using ClassType::interface() */
167171
public function setInterface(): static
168172
{
173+
trigger_error(__METHOD__ . '() is deprecated, use $class->setType($class::TYPE_INTERFACE) or create object using ClassType::interface()', E_USER_DEPRECATED);
169174
$this->type = self::TYPE_INTERFACE;
170175
return $this;
171176
}
@@ -177,8 +182,10 @@ public function isInterface(): bool
177182
}
178183

179184

185+
/** @deprecated use setType('trait') or create using ClassType::trait() */
180186
public function setTrait(): static
181187
{
188+
trigger_error(__METHOD__ . '() is deprecated, use $class->setType($class::TYPE_TRAIT) or create object using ClassType::trait()', E_USER_DEPRECATED);
182189
$this->type = self::TYPE_TRAIT;
183190
return $this;
184191
}

src/PhpGenerator/GlobalFunction.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@ public static function from(string $function, bool $withBody = false): self
3131
}
3232

3333

34+
/** @deprecated use GlobalFunction::from(..., withBody: true) */
3435
public static function withBodyFrom(string $function): self
3536
{
37+
trigger_error(__METHOD__ . '() is deprecated, use GlobalFunction::from(..., withBody: true)', E_USER_DEPRECATED);
3638
return (new Factory)->fromFunctionReflection(new \ReflectionFunction($function), withBody: true);
3739
}
3840

src/PhpGenerator/Helpers.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,23 @@ final class Helpers
5151
/** @deprecated use (new Nette\PhpGenerator\Dumper)->dump() */
5252
public static function dump($var): string
5353
{
54+
trigger_error(__METHOD__ . '() is deprecated, use (new Nette\PhpGenerator\Dumper)->dump().', E_USER_DEPRECATED);
5455
return (new Dumper)->dump($var);
5556
}
5657

5758

5859
/** @deprecated use (new Nette\PhpGenerator\Dumper)->format() */
5960
public static function format(string $statement, ...$args): string
6061
{
62+
trigger_error(__METHOD__ . '() is deprecated, use (new Nette\PhpGenerator\Dumper)->format().', E_USER_DEPRECATED);
6163
return (new Dumper)->format($statement, ...$args);
6264
}
6365

6466

6567
/** @deprecated use (new Nette\PhpGenerator\Dumper)->format() */
6668
public static function formatArgs(string $statement, array $args): string
6769
{
70+
trigger_error(__METHOD__ . '() is deprecated, use (new Nette\PhpGenerator\Dumper)->format().', E_USER_DEPRECATED);
6871
return (new Dumper)->format($statement, ...$args);
6972
}
7073

src/PhpGenerator/Parameter.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,15 @@ public function getType(bool $asObject = false): Type|string|null
6262
/** @deprecated use setType() */
6363
public function setTypeHint(?string $type): static
6464
{
65+
trigger_error(__METHOD__ . '() is deprecated, use setType().', E_USER_DEPRECATED);
6566
return $this->setType($type);
6667
}
6768

6869

6970
/** @deprecated use getType() */
7071
public function getTypeHint(): ?string
7172
{
73+
trigger_error(__METHOD__ . '() is deprecated, use getType().', E_USER_DEPRECATED);
7274
return $this->getType();
7375
}
7476

src/PhpGenerator/PhpFile.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ public function hasStrictTypes(): bool
153153
/** @deprecated use hasStrictTypes() */
154154
public function getStrictTypes(): bool
155155
{
156+
trigger_error(__METHOD__ . '() is deprecated, use hasStrictTypes().', E_USER_DEPRECATED);
156157
return $this->strictTypes;
157158
}
158159

src/PhpGenerator/PhpLiteral.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
namespace Nette\PhpGenerator;
1111

1212

13+
/** @deprecated use Nette\PhpGenerator\Literal */
1314
class PhpLiteral extends Literal
1415
{
1516
}

src/PhpGenerator/PhpNamespace.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ public function hasBracketedSyntax(): bool
8383
/** @deprecated use hasBracketedSyntax() */
8484
public function getBracketedSyntax(): bool
8585
{
86+
trigger_error(__METHOD__ . '() is deprecated, use hasBracketedSyntax().', E_USER_DEPRECATED);
8687
return $this->bracketedSyntax;
8788
}
8889

@@ -157,6 +158,7 @@ public function getUses(string $of = self::NAME_NORMAL): array
157158
/** @deprecated use simplifyName() */
158159
public function unresolveName(string $name): string
159160
{
161+
trigger_error(__METHOD__ . '() is deprecated, use simplifyName()', E_USER_DEPRECATED);
160162
return $this->simplifyName($name);
161163
}
162164

src/PhpGenerator/Traits/FunctionLike.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ public function isReturnNullable(): bool
155155
/** @deprecated use isReturnNullable() */
156156
public function getReturnNullable(): bool
157157
{
158+
trigger_error(__METHOD__ . '() is deprecated, use isReturnNullable().', E_USER_DEPRECATED);
158159
return $this->returnNullable;
159160
}
160161
}

0 commit comments

Comments
 (0)