Skip to content

Commit

Permalink
ClassType: getType() is deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Oct 13, 2023
1 parent e602704 commit 0a277da
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 21 deletions.
22 changes: 2 additions & 20 deletions src/PhpGenerator/ClassType.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ final class ClassType extends ClassLike
TYPE_TRAIT = 'trait',
TYPE_ENUM = 'enum';

private string $type = self::TYPE_CLASS;
private bool $final = false;
private bool $abstract = false;
private ?string $extends = null;
Expand Down Expand Up @@ -82,28 +81,11 @@ public function __construct(?string $name = null, ?PhpNamespace $namespace = nul
}


public function isClass(): bool
{
return $this->type === self::TYPE_CLASS;
}


public function isInterface(): bool
{
return $this->type === self::TYPE_INTERFACE;
}


public function isTrait(): bool
{
return $this->type === self::TYPE_TRAIT;
}


/** @deprecated */
public function getType(): string
{
return $this->type;
trigger_error(__METHOD__ . "() is deprecated, method always returns 'class'", E_USER_DEPRECATED);
return self::TYPE_CLASS;
}


Expand Down
2 changes: 1 addition & 1 deletion src/PhpGenerator/Printer.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ public function printClass(
}

$line[] = match (true) {
$class instanceof ClassType => $class->getName() ? $class->getType() . ' ' . $class->getName() : null,
$class instanceof ClassType => $class->getName() ? 'class ' . $class->getName() : null,
$class instanceof InterfaceType => 'interface ' . $class->getName(),
$class instanceof TraitType => 'trait ' . $class->getName(),
$class instanceof EnumType => 'enum ' . $class->getName() . ($enumType ? $this->returnTypeColon . $enumType : ''),
Expand Down

0 comments on commit 0a277da

Please sign in to comment.