33namespace Stefna \PhpCodeBuilder ;
44
55use Stefna \PhpCodeBuilder \ValueObject \Identifier ;
6+ use Stefna \PhpCodeBuilder \ValueObject \Type ;
67
78class PhpConstant
89{
@@ -14,26 +15,27 @@ class PhpConstant
1415 public const CASE_LOWER = 1 ;
1516 public const CASE_NONE = 2 ;
1617
17- public static function public (string $ identifier , mixed $ value = null ): self
18+ public static function public (string $ identifier , mixed $ value = null , ? Type $ type = null ): self
1819 {
19- return new self (self ::PUBLIC_ACCESS , $ identifier , $ value );
20+ return new self (self ::PUBLIC_ACCESS , $ identifier , $ value, type: $ type );
2021 }
2122
22- public static function private (string $ identifier , mixed $ value = null ): self
23+ public static function private (string $ identifier , mixed $ value = null , ? Type $ type = null ): self
2324 {
24- return new self (self ::PRIVATE_ACCESS , $ identifier , $ value );
25+ return new self (self ::PRIVATE_ACCESS , $ identifier , $ value, type: $ type );
2526 }
2627
27- public static function protected (string $ identifier , mixed $ value = null ): self
28+ public static function protected (string $ identifier , mixed $ value = null , ? Type $ type = null ): self
2829 {
29- return new self (self ::PROTECTED_ACCESS , $ identifier , $ value );
30+ return new self (self ::PROTECTED_ACCESS , $ identifier , $ value, type: $ type );
3031 }
3132
3233 public function __construct (
3334 protected string $ access ,
3435 protected string $ identifier ,
3536 protected mixed $ value = null ,
3637 protected int $ case = self ::CASE_UPPER ,
38+ protected ?Type $ type = null ,
3739 ) {}
3840
3941 public function getName (): string
@@ -83,6 +85,11 @@ public function getAccess(): string
8385 return $ this ->access ;
8486 }
8587
88+ public function getType (): ?Type
89+ {
90+ return $ this ->type ;
91+ }
92+
8693 public function setAccess (string $ access ): static
8794 {
8895 $ this ->access = $ access ;
0 commit comments