Skip to content

Commit 8dd037c

Browse files
committed
removed deprecated stuff
1 parent 0c65000 commit 8dd037c

13 files changed

+9
-182
lines changed

src/PhpGenerator/ClassLike.php

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,25 +39,13 @@ abstract class ClassLike
3939
private ?string $name;
4040

4141

42-
public static function from(string|object $class, bool $withBodies = false, ?bool $materializeTraits = null): self
42+
public static function from(string|object $class, bool $withBodies = false): self
4343
{
44-
if ($materializeTraits !== null) {
45-
trigger_error(__METHOD__ . '() parameter $materializeTraits has been removed (is always false).', E_USER_DEPRECATED);
46-
}
4744
return (new Factory)
4845
->fromClassReflection(new \ReflectionClass($class), $withBodies);
4946
}
5047

5148

52-
/** @deprecated use from(..., withBodies: true) */
53-
public static function withBodiesFrom(string|object $class): self
54-
{
55-
trigger_error(__METHOD__ . '() is deprecated, use from(..., withBodies: true)', E_USER_DEPRECATED);
56-
return (new Factory)
57-
->fromClassReflection(new \ReflectionClass($class), withBodies: true);
58-
}
59-
60-
6149
public static function fromCode(string $code): self
6250
{
6351
return (new Factory)

src/PhpGenerator/ClassType.php

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -81,65 +81,24 @@ public function __construct(?string $name = null, ?PhpNamespace $namespace = nul
8181
}
8282

8383

84-
/** @deprecated */
85-
public function setClass(): static
86-
{
87-
trigger_error(__METHOD__ . '() is deprecated.', E_USER_DEPRECATED);
88-
$this->type = self::TYPE_CLASS;
89-
return $this;
90-
}
91-
92-
9384
public function isClass(): bool
9485
{
9586
return $this->type === self::TYPE_CLASS;
9687
}
9788

9889

99-
/** @deprecated create object using 'new Nette\PhpGenerator\InterfaceType' */
100-
public function setInterface(): static
101-
{
102-
trigger_error(__METHOD__ . "() is deprecated, create object using 'new Nette\\PhpGenerator\\InterfaceType'", E_USER_DEPRECATED);
103-
$this->type = self::TYPE_INTERFACE;
104-
return $this;
105-
}
106-
107-
10890
public function isInterface(): bool
10991
{
11092
return $this->type === self::TYPE_INTERFACE;
11193
}
11294

11395

114-
/** @deprecated create object using 'new Nette\PhpGenerator\TraitType' */
115-
public function setTrait(): static
116-
{
117-
trigger_error(__METHOD__ . "() is deprecated, create object using 'new Nette\\PhpGenerator\\TraitType'", E_USER_DEPRECATED);
118-
$this->type = self::TYPE_TRAIT;
119-
return $this;
120-
}
121-
122-
12396
public function isTrait(): bool
12497
{
12598
return $this->type === self::TYPE_TRAIT;
12699
}
127100

128101

129-
/** @deprecated create object using 'new Nette\PhpGenerator\InterfaceType' or 'TraitType' */
130-
public function setType(string $type): static
131-
{
132-
$upper = ucfirst($type);
133-
trigger_error(__METHOD__ . "() is deprecated, create object using 'new Nette\\PhpGenerator\\{$upper}Type'", E_USER_DEPRECATED);
134-
if (!in_array($type, [self::TYPE_CLASS, self::TYPE_INTERFACE, self::TYPE_TRAIT], true)) {
135-
throw new Nette\InvalidArgumentException('Argument must be class|interface|trait.');
136-
}
137-
138-
$this->type = $type;
139-
return $this;
140-
}
141-
142-
143102
/** @deprecated */
144103
public function getType(): string
145104
{

src/PhpGenerator/Factory.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,8 @@ final class Factory
3131
public function fromClassReflection(
3232
\ReflectionClass $from,
3333
bool $withBodies = false,
34-
?bool $materializeTraits = null,
3534
): ClassLike
3635
{
37-
if ($materializeTraits !== null) {
38-
trigger_error(__METHOD__ . '() parameter $materializeTraits has been removed (is always false).', E_USER_DEPRECATED);
39-
}
4036
if ($withBodies && $from->isAnonymous()) {
4137
throw new Nette\NotSupportedException('The $withBodies parameter cannot be used for anonymous functions.');
4238
}

src/PhpGenerator/GlobalFunction.php

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

3333

34-
/** @deprecated use GlobalFunction::from(..., withBody: true) */
35-
public static function withBodyFrom(string $function): self
36-
{
37-
trigger_error(__METHOD__ . '() is deprecated, use GlobalFunction::from(..., withBody: true)', E_USER_DEPRECATED);
38-
return (new Factory)->fromFunctionReflection(new \ReflectionFunction($function), withBody: true);
39-
}
40-
41-
4234
public function __toString(): string
4335
{
4436
return (new Printer)->printFunction($this);

src/PhpGenerator/Helpers.php

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -50,30 +50,6 @@ final class Helpers
5050
KEYWORDS = self::Keywords;
5151

5252

53-
/** @deprecated use (new Nette\PhpGenerator\Dumper)->dump() */
54-
public static function dump(mixed $var): string
55-
{
56-
trigger_error(__METHOD__ . '() is deprecated, use (new Nette\PhpGenerator\Dumper)->dump().', E_USER_DEPRECATED);
57-
return (new Dumper)->dump($var);
58-
}
59-
60-
61-
/** @deprecated use (new Nette\PhpGenerator\Dumper)->format() */
62-
public static function format(string $statement, mixed ...$args): string
63-
{
64-
trigger_error(__METHOD__ . '() is deprecated, use (new Nette\PhpGenerator\Dumper)->format().', E_USER_DEPRECATED);
65-
return (new Dumper)->format($statement, ...$args);
66-
}
67-
68-
69-
/** @deprecated use (new Nette\PhpGenerator\Dumper)->format() */
70-
public static function formatArgs(string $statement, array $args): string
71-
{
72-
trigger_error(__METHOD__ . '() is deprecated, use (new Nette\PhpGenerator\Dumper)->format().', E_USER_DEPRECATED);
73-
return (new Dumper)->format($statement, ...$args);
74-
}
75-
76-
7753
public static function formatDocComment(string $content, bool $forceMultiLine = false): string
7854
{
7955
$s = trim($content);

src/PhpGenerator/Parameter.php

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -61,22 +61,6 @@ public function getType(bool $asObject = false): Type|string|null
6161
}
6262

6363

64-
/** @deprecated use setType() */
65-
public function setTypeHint(?string $type): static
66-
{
67-
trigger_error(__METHOD__ . '() is deprecated, use setType().', E_USER_DEPRECATED);
68-
return $this->setType($type);
69-
}
70-
71-
72-
/** @deprecated use getType() */
73-
public function getTypeHint(): ?string
74-
{
75-
trigger_error(__METHOD__ . '() is deprecated, use getType().', E_USER_DEPRECATED);
76-
return $this->getType();
77-
}
78-
79-
8064
public function setNullable(bool $state = true): static
8165
{
8266
$this->nullable = $state;

src/PhpGenerator/PhpFile.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -150,14 +150,6 @@ public function hasStrictTypes(): bool
150150
}
151151

152152

153-
/** @deprecated use hasStrictTypes() */
154-
public function getStrictTypes(): bool
155-
{
156-
trigger_error(__METHOD__ . '() is deprecated, use hasStrictTypes().', E_USER_DEPRECATED);
157-
return $this->strictTypes;
158-
}
159-
160-
161153
public function __toString(): string
162154
{
163155
return (new Printer)->printFile($this);

src/PhpGenerator/PhpNamespace.php

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,6 @@ public function hasBracketedSyntax(): bool
8989
}
9090

9191

92-
/** @deprecated use hasBracketedSyntax() */
93-
public function getBracketedSyntax(): bool
94-
{
95-
trigger_error(__METHOD__ . '() is deprecated, use hasBracketedSyntax().', E_USER_DEPRECATED);
96-
return $this->bracketedSyntax;
97-
}
98-
99-
10092
/**
10193
* @throws InvalidStateException
10294
*/
@@ -174,14 +166,6 @@ public function getUses(string $of = self::NameNormal): array
174166
}
175167

176168

177-
/** @deprecated use simplifyName() */
178-
public function unresolveName(string $name): string
179-
{
180-
trigger_error(__METHOD__ . '() is deprecated, use simplifyName()', E_USER_DEPRECATED);
181-
return $this->simplifyName($name);
182-
}
183-
184-
185169
public function resolveName(string $name, string $of = self::NameNormal): string
186170
{
187171
if (isset(Helpers::Keywords[strtolower($name)]) || $name === '') {

src/PhpGenerator/TraitUse.php

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,21 @@
1717
*/
1818
final class TraitUse
1919
{
20-
use Nette\SmartObject {
21-
__call as private parentCall;
22-
}
20+
use Nette\SmartObject;
2321
use Traits\NameAware;
2422
use Traits\CommentAware;
2523

2624
/** @var string[] */
2725
private array $resolutions = [];
28-
private ?ClassLike $parent;
2926

3027

31-
public function __construct(string $name, ?ClassLike $parent = null)
28+
public function __construct(string $name)
3229
{
3330
if (!Nette\PhpGenerator\Helpers::isNamespaceIdentifier($name, allowLeadingSlash: true)) {
3431
throw new Nette\InvalidArgumentException("Value '$name' is not valid trait name.");
3532
}
3633

3734
$this->name = $name;
38-
$this->parent = $parent;
3935
}
4036

4137

@@ -51,19 +47,4 @@ public function getResolutions(): array
5147
{
5248
return $this->resolutions;
5349
}
54-
55-
56-
/** @param mixed[] $args */
57-
public function __call(string $nm, array $args): mixed
58-
{
59-
if (!$this->parent) {
60-
return $this->parentCall($nm, $args);
61-
}
62-
$trace = debug_backtrace(0);
63-
$loc = isset($trace[0]['file'])
64-
? ' in ' . $trace[0]['file'] . ':' . $trace[0]['line']
65-
: '';
66-
trigger_error('The ClassType::addTrait() method now returns a TraitUse object instead of ClassType. Please fix the method chaining' . $loc, E_USER_DEPRECATED);
67-
return $this->parent->$nm(...$args);
68-
}
6950
}

src/PhpGenerator/Traits/ConstantsAware.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,9 @@ trait ConstantsAware
2525
/** @param Constant[] $consts */
2626
public function setConstants(array $consts): static
2727
{
28+
(function (Constant ...$consts) {})(...$consts);
2829
$this->consts = [];
2930
foreach ($consts as $k => $const) {
30-
if (!$const instanceof Constant) {
31-
trigger_error(__METHOD__ . '() accepts an array of Constant as parameter, ' . get_debug_type($const) . ' given.', E_USER_DEPRECATED);
32-
$const = (new Constant($k))->setValue($const)->setPublic();
33-
}
34-
3531
$this->consts[$const->getName()] = $const;
3632
}
3733

0 commit comments

Comments
 (0)