diff --git a/src/CodeHelper/Methods/JsonSerializeMethod.php b/src/CodeHelper/Methods/JsonSerializeMethod.php index 7666267..b00c793 100644 --- a/src/CodeHelper/Methods/JsonSerializeMethod.php +++ b/src/CodeHelper/Methods/JsonSerializeMethod.php @@ -18,7 +18,7 @@ */ final class JsonSerializeMethod extends PhpMethod { - public static function fromClass(PhpClass $class, TypeCallResolverInterface $resolver = null): self + public static function fromClass(PhpClass $class, ?TypeCallResolverInterface $resolver = null): self { $resolver = $resolver ?? new JsonSerializeTypeCallResolver(); diff --git a/src/PhpFile.php b/src/PhpFile.php index e9ae1d1..b47c703 100644 --- a/src/PhpFile.php +++ b/src/PhpFile.php @@ -139,7 +139,7 @@ public function addFunction(PhpFunction $function): self /** * Add use statement after namespace declaration */ - public function addUse(Identifier|string $identifier, string $alias = null): self + public function addUse(Identifier|string $identifier, ?string $alias = null): self { $identifier = Identifier::fromUnknown($identifier); if ($alias) { diff --git a/src/PhpMethod.php b/src/PhpMethod.php index 82289fb..21fbf11 100644 --- a/src/PhpMethod.php +++ b/src/PhpMethod.php @@ -113,7 +113,7 @@ public static function getter(PhpVariable $var, array $source = []): self * @param PhpParam[] $params * @param array $source */ - public static function public(string $identifier, array $params, array $source, Type $type = null): self + public static function public(string $identifier, array $params, array $source, ?Type $type = null): self { return new self(self::PUBLIC_ACCESS, $identifier, $params, $source, $type ?? Type::empty()); } @@ -122,7 +122,7 @@ public static function public(string $identifier, array $params, array $source, * @param PhpParam[] $params * @param array $source */ - public static function private(string $identifier, array $params, array $source, Type $type = null): self + public static function private(string $identifier, array $params, array $source, ?Type $type = null): self { return new self(self::PRIVATE_ACCESS, $identifier, $params, $source, $type ?? Type::empty()); } @@ -131,7 +131,7 @@ public static function private(string $identifier, array $params, array $source, * @param PhpParam[] $params * @param array $source */ - public static function protected(string $identifier, array $params, array $source, Type $type = null): self + public static function protected(string $identifier, array $params, array $source, ?Type $type = null): self { return new self(self::PROTECTED_ACCESS, $identifier, $params, $source, $type ?? Type::empty()); } diff --git a/src/PhpTrait.php b/src/PhpTrait.php index 5e3ffba..dd6dd13 100644 --- a/src/PhpTrait.php +++ b/src/PhpTrait.php @@ -54,7 +54,7 @@ public function getComment(): PhpDocComment return $this->comment; } - public function addUse(Identifier|string $class, string $alias = null): static + public function addUse(Identifier|string $class, ?string $alias = null): static { $class = Identifier::fromUnknown($class); if (!$alias && $this->identifier->equal($class)) {